highcharts.src.js 1.9 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170
  1. /**
  2. * @license Highcharts JS v8.2.2 (2020-10-22)
  3. *
  4. * (c) 2009-2018 Torstein Honsi
  5. *
  6. * License: www.highcharts.com/license
  7. */
  8. 'use strict';
  9. (function (root, factory) {
  10. if (typeof module === 'object' && module.exports) {
  11. factory['default'] = factory;
  12. module.exports = root.document ?
  13. factory(root) :
  14. factory;
  15. } else if (typeof define === 'function' && define.amd) {
  16. define('highcharts/highcharts', function () {
  17. return factory(root);
  18. });
  19. } else {
  20. if (root.Highcharts) {
  21. root.Highcharts.error(16, true);
  22. }
  23. root.Highcharts = factory(root);
  24. }
  25. }(typeof window !== 'undefined' ? window : this, function (win) {
  26. var _modules = {};
  27. function _registerModule(obj, path, args, fn) {
  28. if (!obj.hasOwnProperty(path)) {
  29. obj[path] = fn.apply(null, args);
  30. }
  31. }
  32. _registerModule(_modules, 'Core/Globals.js', [], function () {
  33. /* *
  34. *
  35. * (c) 2010-2020 Torstein Honsi
  36. *
  37. * License: www.highcharts.com/license
  38. *
  39. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  40. *
  41. * */
  42. /* globals Image, window */
  43. /**
  44. * Reference to the global SVGElement class as a workaround for a name conflict
  45. * in the Highcharts namespace.
  46. *
  47. * @global
  48. * @typedef {global.SVGElement} GlobalSVGElement
  49. *
  50. * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGElement
  51. */
  52. // glob is a temporary fix to allow our es-modules to work.
  53. var glob = ( // @todo UMD variable named `window`, and glob named `win`
  54. typeof win !== 'undefined' ?
  55. win :
  56. typeof window !== 'undefined' ?
  57. window :
  58. {}), doc = glob.document, SVG_NS = 'http://www.w3.org/2000/svg', userAgent = (glob.navigator && glob.navigator.userAgent) || '', svg = (doc &&
  59. doc.createElementNS &&
  60. !!doc.createElementNS(SVG_NS, 'svg').createSVGRect), isMS = /(edge|msie|trident)/i.test(userAgent) && !glob.opera, isFirefox = userAgent.indexOf('Firefox') !== -1, isChrome = userAgent.indexOf('Chrome') !== -1, hasBidiBug = (isFirefox &&
  61. parseInt(userAgent.split('Firefox/')[1], 10) < 4 // issue #38
  62. );
  63. var H = {
  64. product: 'Highcharts',
  65. version: '8.2.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. * Theme options that should get applied to the chart. In module mode it
  86. * might not be possible to change this property because of read-only
  87. * restrictions, instead use {@link Highcharts.setOptions}.
  88. *
  89. * @name Highcharts.theme
  90. * @type {Highcharts.Options}
  91. */
  92. /**
  93. * An array containing the current chart objects in the page. A chart's
  94. * position in the array is preserved throughout the page's lifetime. When
  95. * a chart is destroyed, the array item becomes `undefined`.
  96. *
  97. * @name Highcharts.charts
  98. * @type {Array<Highcharts.Chart|undefined>}
  99. */
  100. charts: [],
  101. /**
  102. * A hook for defining additional date format specifiers. New
  103. * specifiers are defined as key-value pairs by using the
  104. * specifier as key, and a function which takes the timestamp as
  105. * value. This function returns the formatted portion of the
  106. * date.
  107. *
  108. * @sample highcharts/global/dateformats/
  109. * Adding support for week number
  110. *
  111. * @name Highcharts.dateFormats
  112. * @type {Highcharts.Dictionary<Highcharts.TimeFormatCallbackFunction>}
  113. */
  114. dateFormats: {}
  115. };
  116. return H;
  117. });
  118. _registerModule(_modules, 'Core/Utilities.js', [_modules['Core/Globals.js']], function (H) {
  119. /* *
  120. *
  121. * (c) 2010-2020 Torstein Honsi
  122. *
  123. * License: www.highcharts.com/license
  124. *
  125. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  126. *
  127. * */
  128. /**
  129. * An animation configuration. Animation configurations can also be defined as
  130. * booleans, where `false` turns off animation and `true` defaults to a duration
  131. * of 500ms and defer of 0ms.
  132. *
  133. * @interface Highcharts.AnimationOptionsObject
  134. */ /**
  135. * A callback function to exectute when the animation finishes.
  136. * @name Highcharts.AnimationOptionsObject#complete
  137. * @type {Function|undefined}
  138. */ /**
  139. * The animation defer in milliseconds.
  140. * @name Highcharts.AnimationOptionsObject#defer
  141. * @type {number|undefined}
  142. */ /**
  143. * The animation duration in milliseconds.
  144. * @name Highcharts.AnimationOptionsObject#duration
  145. * @type {number|undefined}
  146. */ /**
  147. * The name of an easing function as defined on the `Math` object.
  148. * @name Highcharts.AnimationOptionsObject#easing
  149. * @type {string|Function|undefined}
  150. */ /**
  151. * A callback function to execute on each step of each attribute or CSS property
  152. * that's being animated. The first argument contains information about the
  153. * animation and progress.
  154. * @name Highcharts.AnimationOptionsObject#step
  155. * @type {Function|undefined}
  156. */
  157. /**
  158. * Creates a frame for the animated SVG element.
  159. *
  160. * @callback Highcharts.AnimationStepCallbackFunction
  161. *
  162. * @param {Highcharts.SVGElement} this
  163. * The SVG element to animate.
  164. *
  165. * @return {void}
  166. */
  167. /**
  168. * Interface description for a class.
  169. *
  170. * @interface Highcharts.Class<T>
  171. * @extends Function
  172. */ /**
  173. * Class costructor.
  174. * @function Highcharts.Class<T>#new
  175. * @param {...Array<*>} args
  176. * Constructor arguments.
  177. * @return {T}
  178. * Class instance.
  179. */
  180. /**
  181. * A style object with camel case property names to define visual appearance of
  182. * a SVG element or HTML element. The properties can be whatever styles are
  183. * supported on the given SVG or HTML element.
  184. *
  185. * @example
  186. * {
  187. * fontFamily: 'monospace',
  188. * fontSize: '1.2em'
  189. * }
  190. *
  191. * @interface Highcharts.CSSObject
  192. */ /**
  193. * @name Highcharts.CSSObject#[key:string]
  194. * @type {boolean|number|string|undefined}
  195. */ /**
  196. * Background style for the element.
  197. * @name Highcharts.CSSObject#background
  198. * @type {string|undefined}
  199. */ /**
  200. * Background color of the element.
  201. * @name Highcharts.CSSObject#backgroundColor
  202. * @type {Highcharts.ColorString|undefined}
  203. */ /**
  204. * Border style for the element.
  205. * @name Highcharts.CSSObject#border
  206. * @type {string|undefined}
  207. */ /**
  208. * Radius of the element border.
  209. * @name Highcharts.CSSObject#borderRadius
  210. * @type {number|undefined}
  211. */ /**
  212. * Color used in the element. The 'contrast' option is a Highcharts custom
  213. * property that results in black or white, depending on the background of the
  214. * element.
  215. * @name Highcharts.CSSObject#color
  216. * @type {'contrast'|Highcharts.ColorString|undefined}
  217. */ /**
  218. * Style of the mouse cursor when resting over the element.
  219. * @name Highcharts.CSSObject#cursor
  220. * @type {Highcharts.CursorValue|undefined}
  221. */ /**
  222. * Font family of the element text. Multiple values have to be in decreasing
  223. * preference order and separated by comma.
  224. * @name Highcharts.CSSObject#fontFamily
  225. * @type {string|undefined}
  226. */ /**
  227. * Font size of the element text.
  228. * @name Highcharts.CSSObject#fontSize
  229. * @type {string|undefined}
  230. */ /**
  231. * Font weight of the element text.
  232. * @name Highcharts.CSSObject#fontWeight
  233. * @type {string|undefined}
  234. */ /**
  235. * Height of the element.
  236. * @name Highcharts.CSSObject#height
  237. * @type {number|undefined}
  238. */ /**
  239. * Width of the element border.
  240. * @name Highcharts.CSSObject#lineWidth
  241. * @type {number|undefined}
  242. */ /**
  243. * Opacity of the element.
  244. * @name Highcharts.CSSObject#opacity
  245. * @type {number|undefined}
  246. */ /**
  247. * Space around the element content.
  248. * @name Highcharts.CSSObject#padding
  249. * @type {string|undefined}
  250. */ /**
  251. * Behaviour of the element when the mouse cursor rests over it.
  252. * @name Highcharts.CSSObject#pointerEvents
  253. * @type {string|undefined}
  254. */ /**
  255. * Positioning of the element.
  256. * @name Highcharts.CSSObject#position
  257. * @type {string|undefined}
  258. */ /**
  259. * Alignment of the element text.
  260. * @name Highcharts.CSSObject#textAlign
  261. * @type {string|undefined}
  262. */ /**
  263. * Additional decoration of the element text.
  264. * @name Highcharts.CSSObject#textDecoration
  265. * @type {string|undefined}
  266. */ /**
  267. * Outline style of the element text.
  268. * @name Highcharts.CSSObject#textOutline
  269. * @type {string|undefined}
  270. */ /**
  271. * Line break style of the element text. Highcharts SVG elements support
  272. * `ellipsis` when a `width` is set.
  273. * @name Highcharts.CSSObject#textOverflow
  274. * @type {string|undefined}
  275. */ /**
  276. * Top spacing of the element relative to the parent element.
  277. * @name Highcharts.CSSObject#top
  278. * @type {string|undefined}
  279. */ /**
  280. * Animated transition of selected element properties.
  281. * @name Highcharts.CSSObject#transition
  282. * @type {string|undefined}
  283. */ /**
  284. * Line break style of the element text.
  285. * @name Highcharts.CSSObject#whiteSpace
  286. * @type {string|undefined}
  287. */ /**
  288. * Width of the element.
  289. * @name Highcharts.CSSObject#width
  290. * @type {number|undefined}
  291. */
  292. /**
  293. * All possible cursor styles.
  294. *
  295. * @typedef {'alias'|'all-scroll'|'auto'|'cell'|'col-resize'|'context-menu'|'copy'|'crosshair'|'default'|'e-resize'|'ew-resize'|'grab'|'grabbing'|'help'|'move'|'n-resize'|'ne-resize'|'nesw-resize'|'no-drop'|'none'|'not-allowed'|'ns-resize'|'nw-resize'|'nwse-resize'|'pointer'|'progress'|'row-resize'|'s-resize'|'se-resize'|'sw-resize'|'text'|'vertical-text'|'w-resize'|'wait'|'zoom-in'|'zoom-out'} Highcharts.CursorValue
  296. */
  297. /**
  298. * All possible dash styles.
  299. *
  300. * @typedef {'Dash'|'DashDot'|'Dot'|'LongDash'|'LongDashDot'|'LongDashDotDot'|'ShortDash'|'ShortDashDot'|'ShortDashDotDot'|'ShortDot'|'Solid'} Highcharts.DashStyleValue
  301. */
  302. /**
  303. * Generic dictionary in TypeScript notation.
  304. * Use the native `Record<string, any>` instead.
  305. *
  306. * @deprecated
  307. * @interface Highcharts.Dictionary<T>
  308. */ /**
  309. * @name Highcharts.Dictionary<T>#[key:string]
  310. * @type {T}
  311. */
  312. /**
  313. * The function callback to execute when the event is fired. The `this` context
  314. * contains the instance, that fired the event.
  315. *
  316. * @callback Highcharts.EventCallbackFunction<T>
  317. *
  318. * @param {T} this
  319. *
  320. * @param {Highcharts.Dictionary<*>|Event} [eventArguments]
  321. * Event arguments.
  322. *
  323. * @return {boolean|void}
  324. */
  325. /**
  326. * The event options for adding function callback.
  327. *
  328. * @interface Highcharts.EventOptionsObject
  329. */ /**
  330. * The order the event handler should be called. This opens for having one
  331. * handler be called before another, independent of in which order they were
  332. * added.
  333. * @name Highcharts.EventOptionsObject#order
  334. * @type {number}
  335. */
  336. /**
  337. * Formats data as a string. Usually the data is accessible throught the `this`
  338. * keyword.
  339. *
  340. * @callback Highcharts.FormatterCallbackFunction<T>
  341. *
  342. * @param {T} this
  343. * Context to format
  344. *
  345. * @return {string}
  346. * Formatted text
  347. */
  348. /**
  349. * An object of key-value pairs for HTML attributes.
  350. *
  351. * @typedef {Highcharts.Dictionary<boolean|number|string|Function>} Highcharts.HTMLAttributes
  352. */
  353. /**
  354. * An HTML DOM element. The type is a reference to the regular HTMLElement in
  355. * the global scope.
  356. *
  357. * @typedef {global.HTMLElement} Highcharts.HTMLDOMElement
  358. *
  359. * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement
  360. */
  361. /**
  362. * The iterator callback.
  363. *
  364. * @callback Highcharts.ObjectEachCallbackFunction<T>
  365. *
  366. * @param {T} this
  367. * The context.
  368. *
  369. * @param {*} value
  370. * The property value.
  371. *
  372. * @param {string} key
  373. * The property key.
  374. *
  375. * @param {*} obj
  376. * The object that objectEach is being applied to.
  377. */
  378. /**
  379. * An object containing `left` and `top` properties for the position in the
  380. * page.
  381. *
  382. * @interface Highcharts.OffsetObject
  383. */ /**
  384. * Left distance to the page border.
  385. * @name Highcharts.OffsetObject#left
  386. * @type {number}
  387. */ /**
  388. * Top distance to the page border.
  389. * @name Highcharts.OffsetObject#top
  390. * @type {number}
  391. */
  392. /**
  393. * Describes a range.
  394. *
  395. * @interface Highcharts.RangeObject
  396. */ /**
  397. * Maximum number of the range.
  398. * @name Highcharts.RangeObject#max
  399. * @type {number}
  400. */ /**
  401. * Minimum number of the range.
  402. * @name Highcharts.RangeObject#min
  403. * @type {number}
  404. */
  405. /**
  406. * If a number is given, it defines the pixel length. If a percentage string is
  407. * given, like for example `'50%'`, the setting defines a length relative to a
  408. * base size, for example the size of a container.
  409. *
  410. * @typedef {number|string} Highcharts.RelativeSize
  411. */
  412. /**
  413. * Proceed function to call original (wrapped) function.
  414. *
  415. * @callback Highcharts.WrapProceedFunction
  416. *
  417. * @param {*} [arg1]
  418. * Optional argument. Without any arguments defaults to first argument of
  419. * the wrapping function.
  420. *
  421. * @param {*} [arg2]
  422. * Optional argument. Without any arguments defaults to second argument
  423. * of the wrapping function.
  424. *
  425. * @param {*} [arg3]
  426. * Optional argument. Without any arguments defaults to third argument of
  427. * the wrapping function.
  428. *
  429. * @return {*}
  430. * Return value of the original function.
  431. */
  432. /**
  433. * The Highcharts object is the placeholder for all other members, and various
  434. * utility functions. The most important member of the namespace would be the
  435. * chart constructor.
  436. *
  437. * @example
  438. * var chart = Highcharts.chart('container', { ... });
  439. *
  440. * @namespace Highcharts
  441. */
  442. H.timers = [];
  443. var charts = H.charts,
  444. doc = H.doc,
  445. win = H.win;
  446. /**
  447. * Provide error messages for debugging, with links to online explanation. This
  448. * function can be overridden to provide custom error handling.
  449. *
  450. * @sample highcharts/chart/highcharts-error/
  451. * Custom error handler
  452. *
  453. * @function Highcharts.error
  454. *
  455. * @param {number|string} code
  456. * The error code. See
  457. * [errors.xml](https://github.com/highcharts/highcharts/blob/master/errors/errors.xml)
  458. * for available codes. If it is a string, the error message is printed
  459. * directly in the console.
  460. *
  461. * @param {boolean} [stop=false]
  462. * Whether to throw an error or just log a warning in the console.
  463. *
  464. * @param {Highcharts.Chart} [chart]
  465. * Reference to the chart that causes the error. Used in 'debugger'
  466. * module to display errors directly on the chart.
  467. * Important note: This argument is undefined for errors that lack
  468. * access to the Chart instance.
  469. *
  470. * @param {Highcharts.Dictionary<string>} [params]
  471. * Additional parameters for the generated message.
  472. *
  473. * @return {void}
  474. */
  475. function error(code, stop, chart, params) {
  476. var severity = stop ? 'Highcharts error' : 'Highcharts warning';
  477. if (code === 32) {
  478. code = severity + ": Deprecated member";
  479. }
  480. var isCode = isNumber(code),
  481. message = isCode ?
  482. severity + " #" + code + ": www.highcharts.com/errors/" + code + "/" :
  483. code.toString(),
  484. defaultHandler = function () {
  485. if (stop) {
  486. throw new Error(message);
  487. }
  488. // else ...
  489. if (win.console &&
  490. error.messages.indexOf(message) === -1 // prevent console flooting
  491. ) {
  492. console.log(message); // eslint-disable-line no-console
  493. }
  494. };
  495. if (typeof params !== 'undefined') {
  496. var additionalMessages_1 = '';
  497. if (isCode) {
  498. message += '?';
  499. }
  500. objectEach(params, function (value, key) {
  501. additionalMessages_1 += "\n - " + key + ": " + value;
  502. if (isCode) {
  503. message += encodeURI(key) + '=' + encodeURI(value);
  504. }
  505. });
  506. message += additionalMessages_1;
  507. }
  508. if (chart) {
  509. fireEvent(chart, 'displayError', { code: code, message: message, params: params }, defaultHandler);
  510. }
  511. else {
  512. defaultHandler();
  513. }
  514. error.messages.push(message);
  515. }
  516. (function (error) {
  517. error.messages = [];
  518. })(error || (error = {}));
  519. H.error = error;
  520. /* eslint-disable valid-jsdoc */
  521. /**
  522. * Utility function to deep merge two or more objects and return a third object.
  523. * If the first argument is true, the contents of the second object is copied
  524. * into the first object. The merge function can also be used with a single
  525. * object argument to create a deep copy of an object.
  526. *
  527. * @function Highcharts.merge<T>
  528. *
  529. * @param {boolean} extend
  530. * Whether to extend the left-side object (a) or return a whole new
  531. * object.
  532. *
  533. * @param {T|undefined} a
  534. * The first object to extend. When only this is given, the function
  535. * returns a deep copy.
  536. *
  537. * @param {...Array<object|undefined>} [n]
  538. * An object to merge into the previous one.
  539. *
  540. * @return {T}
  541. * The merged object. If the first argument is true, the return is the
  542. * same as the second argument.
  543. */ /**
  544. * Utility function to deep merge two or more objects and return a third object.
  545. * The merge function can also be used with a single object argument to create a
  546. * deep copy of an object.
  547. *
  548. * @function Highcharts.merge<T>
  549. *
  550. * @param {T|undefined} a
  551. * The first object to extend. When only this is given, the function
  552. * returns a deep copy.
  553. *
  554. * @param {...Array<object|undefined>} [n]
  555. * An object to merge into the previous one.
  556. *
  557. * @return {T}
  558. * The merged object. If the first argument is true, the return is the
  559. * same as the second argument.
  560. */
  561. function merge() {
  562. /* eslint-enable valid-jsdoc */
  563. var i,
  564. args = arguments,
  565. len,
  566. ret = {},
  567. doCopy = function (copy,
  568. original) {
  569. // An object is replacing a primitive
  570. if (typeof copy !== 'object') {
  571. copy = {};
  572. }
  573. objectEach(original, function (value, key) {
  574. // Copy the contents of objects, but not arrays or DOM nodes
  575. if (isObject(value, true) &&
  576. !isClass(value) &&
  577. !isDOMElement(value)) {
  578. copy[key] = doCopy(copy[key] || {}, value);
  579. // Primitives and arrays are copied over directly
  580. }
  581. else {
  582. copy[key] = original[key];
  583. }
  584. });
  585. return copy;
  586. };
  587. // If first argument is true, copy into the existing object. Used in
  588. // setOptions.
  589. if (args[0] === true) {
  590. ret = args[1];
  591. args = Array.prototype.slice.call(args, 2);
  592. }
  593. // For each argument, extend the return
  594. len = args.length;
  595. for (i = 0; i < len; i++) {
  596. ret = doCopy(ret, args[i]);
  597. }
  598. return ret;
  599. }
  600. H.merge = merge;
  601. /**
  602. * Constrain a value to within a lower and upper threshold.
  603. *
  604. * @private
  605. * @param {number} value The initial value
  606. * @param {number} min The lower threshold
  607. * @param {number} max The upper threshold
  608. * @return {number} Returns a number value within min and max.
  609. */
  610. function clamp(value, min, max) {
  611. return value > min ? value < max ? value : max : min;
  612. }
  613. /**
  614. * Shortcut for parseInt
  615. *
  616. * @private
  617. * @function Highcharts.pInt
  618. *
  619. * @param {*} s
  620. * any
  621. *
  622. * @param {number} [mag]
  623. * Magnitude
  624. *
  625. * @return {number}
  626. * number
  627. */
  628. var pInt = H.pInt = function pInt(s,
  629. mag) {
  630. return parseInt(s,
  631. mag || 10);
  632. };
  633. /**
  634. * Utility function to check for string type.
  635. *
  636. * @function Highcharts.isString
  637. *
  638. * @param {*} s
  639. * The item to check.
  640. *
  641. * @return {boolean}
  642. * True if the argument is a string.
  643. */
  644. var isString = H.isString = function isString(s) {
  645. return typeof s === 'string';
  646. };
  647. /**
  648. * Utility function to check if an item is an array.
  649. *
  650. * @function Highcharts.isArray
  651. *
  652. * @param {*} obj
  653. * The item to check.
  654. *
  655. * @return {boolean}
  656. * True if the argument is an array.
  657. */
  658. var isArray = H.isArray = function isArray(obj) {
  659. var str = Object.prototype.toString.call(obj);
  660. return str === '[object Array]' || str === '[object Array Iterator]';
  661. };
  662. /**
  663. * Utility function to check if an item is of type object.
  664. *
  665. * @function Highcharts.isObject
  666. *
  667. * @param {*} obj
  668. * The item to check.
  669. *
  670. * @param {boolean} [strict=false]
  671. * Also checks that the object is not an array.
  672. *
  673. * @return {boolean}
  674. * True if the argument is an object.
  675. */
  676. function isObject(obj, strict) {
  677. return (!!obj &&
  678. typeof obj === 'object' &&
  679. (!strict || !isArray(obj))); // eslint-disable-line @typescript-eslint/no-explicit-any
  680. }
  681. H.isObject = isObject;
  682. /**
  683. * Utility function to check if an Object is a HTML Element.
  684. *
  685. * @function Highcharts.isDOMElement
  686. *
  687. * @param {*} obj
  688. * The item to check.
  689. *
  690. * @return {boolean}
  691. * True if the argument is a HTML Element.
  692. */
  693. var isDOMElement = H.isDOMElement = function isDOMElement(obj) {
  694. return isObject(obj) && typeof obj.nodeType === 'number';
  695. };
  696. /**
  697. * Utility function to check if an Object is a class.
  698. *
  699. * @function Highcharts.isClass
  700. *
  701. * @param {object|undefined} obj
  702. * The item to check.
  703. *
  704. * @return {boolean}
  705. * True if the argument is a class.
  706. */
  707. var isClass = H.isClass = function isClass(obj) {
  708. var c = obj && obj.constructor;
  709. return !!(isObject(obj, true) &&
  710. !isDOMElement(obj) &&
  711. (c && c.name && c.name !== 'Object'));
  712. };
  713. /**
  714. * Utility function to check if an item is a number and it is finite (not NaN,
  715. * Infinity or -Infinity).
  716. *
  717. * @function Highcharts.isNumber
  718. *
  719. * @param {*} n
  720. * The item to check.
  721. *
  722. * @return {boolean}
  723. * True if the item is a finite number
  724. */
  725. var isNumber = H.isNumber = function isNumber(n) {
  726. return typeof n === 'number' && !isNaN(n) && n < Infinity && n > -Infinity;
  727. };
  728. /**
  729. * Remove the last occurence of an item from an array.
  730. *
  731. * @function Highcharts.erase
  732. *
  733. * @param {Array<*>} arr
  734. * The array.
  735. *
  736. * @param {*} item
  737. * The item to remove.
  738. *
  739. * @return {void}
  740. */
  741. var erase = H.erase = function erase(arr,
  742. item) {
  743. var i = arr.length;
  744. while (i--) {
  745. if (arr[i] === item) {
  746. arr.splice(i, 1);
  747. break;
  748. }
  749. }
  750. };
  751. /**
  752. * Check if an object is null or undefined.
  753. *
  754. * @function Highcharts.defined
  755. *
  756. * @param {*} obj
  757. * The object to check.
  758. *
  759. * @return {boolean}
  760. * False if the object is null or undefined, otherwise true.
  761. */
  762. var defined = H.defined = function defined(obj) {
  763. return typeof obj !== 'undefined' && obj !== null;
  764. };
  765. /**
  766. * Set or get an attribute or an object of attributes. To use as a setter, pass
  767. * a key and a value, or let the second argument be a collection of keys and
  768. * values. To use as a getter, pass only a string as the second argument.
  769. *
  770. * @function Highcharts.attr
  771. *
  772. * @param {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement} elem
  773. * The DOM element to receive the attribute(s).
  774. *
  775. * @param {string|Highcharts.HTMLAttributes|Highcharts.SVGAttributes} [prop]
  776. * The property or an object of key-value pairs.
  777. *
  778. * @param {number|string} [value]
  779. * The value if a single property is set.
  780. *
  781. * @return {string|null|undefined}
  782. * When used as a getter, return the value.
  783. */
  784. function attr(elem, prop, value) {
  785. var ret;
  786. // if the prop is a string
  787. if (isString(prop)) {
  788. // set the value
  789. if (defined(value)) {
  790. elem.setAttribute(prop, value);
  791. // get the value
  792. }
  793. else if (elem && elem.getAttribute) {
  794. ret = elem.getAttribute(prop);
  795. // IE7 and below cannot get class through getAttribute (#7850)
  796. if (!ret && prop === 'class') {
  797. ret = elem.getAttribute(prop + 'Name');
  798. }
  799. }
  800. // else if prop is defined, it is a hash of key/value pairs
  801. }
  802. else {
  803. objectEach(prop, function (val, key) {
  804. elem.setAttribute(key, val);
  805. });
  806. }
  807. return ret;
  808. }
  809. H.attr = attr;
  810. /**
  811. * Check if an element is an array, and if not, make it into an array.
  812. *
  813. * @function Highcharts.splat
  814. *
  815. * @param {*} obj
  816. * The object to splat.
  817. *
  818. * @return {Array}
  819. * The produced or original array.
  820. */
  821. var splat = H.splat = function splat(obj) {
  822. return isArray(obj) ? obj : [obj];
  823. };
  824. /**
  825. * Set a timeout if the delay is given, otherwise perform the function
  826. * synchronously.
  827. *
  828. * @function Highcharts.syncTimeout
  829. *
  830. * @param {Function} fn
  831. * The function callback.
  832. *
  833. * @param {number} delay
  834. * Delay in milliseconds.
  835. *
  836. * @param {*} [context]
  837. * An optional context to send to the function callback.
  838. *
  839. * @return {number}
  840. * An identifier for the timeout that can later be cleared with
  841. * Highcharts.clearTimeout. Returns -1 if there is no timeout.
  842. */
  843. var syncTimeout = H.syncTimeout = function syncTimeout(fn,
  844. delay,
  845. context) {
  846. if (delay > 0) {
  847. return setTimeout(fn,
  848. delay,
  849. context);
  850. }
  851. fn.call(0, context);
  852. return -1;
  853. };
  854. /**
  855. * Internal clear timeout. The function checks that the `id` was not removed
  856. * (e.g. by `chart.destroy()`). For the details see
  857. * [issue #7901](https://github.com/highcharts/highcharts/issues/7901).
  858. *
  859. * @function Highcharts.clearTimeout
  860. *
  861. * @param {number} id
  862. * Id of a timeout.
  863. *
  864. * @return {void}
  865. */
  866. var internalClearTimeout = H.clearTimeout = function (id) {
  867. if (defined(id)) {
  868. clearTimeout(id);
  869. }
  870. };
  871. /* eslint-disable valid-jsdoc */
  872. /**
  873. * Utility function to extend an object with the members of another.
  874. *
  875. * @function Highcharts.extend<T>
  876. *
  877. * @param {T|undefined} a
  878. * The object to be extended.
  879. *
  880. * @param {object} b
  881. * The object to add to the first one.
  882. *
  883. * @return {T}
  884. * Object a, the original object.
  885. */
  886. var extend = H.extend = function extend(a,
  887. b) {
  888. /* eslint-enable valid-jsdoc */
  889. var n;
  890. if (!a) {
  891. a = {};
  892. }
  893. for (n in b) { // eslint-disable-line guard-for-in
  894. a[n] = b[n];
  895. }
  896. return a;
  897. };
  898. /* eslint-disable valid-jsdoc */
  899. /**
  900. * Return the first value that is not null or undefined.
  901. *
  902. * @function Highcharts.pick<T>
  903. *
  904. * @param {...Array<T|null|undefined>} items
  905. * Variable number of arguments to inspect.
  906. *
  907. * @return {T}
  908. * The value of the first argument that is not null or undefined.
  909. */
  910. function pick() {
  911. var args = arguments;
  912. var length = args.length;
  913. for (var i = 0; i < length; i++) {
  914. var arg = args[i];
  915. if (typeof arg !== 'undefined' && arg !== null) {
  916. return arg;
  917. }
  918. }
  919. }
  920. H.pick = pick;
  921. /**
  922. * Set CSS on a given element.
  923. *
  924. * @function Highcharts.css
  925. *
  926. * @param {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement} el
  927. * An HTML DOM element.
  928. *
  929. * @param {Highcharts.CSSObject} styles
  930. * Style object with camel case property names.
  931. *
  932. * @return {void}
  933. */
  934. var css = H.css = function css(el,
  935. styles) {
  936. if (H.isMS && !H.svg) { // #2686
  937. if (styles && typeof styles.opacity !== 'undefined') {
  938. styles.filter =
  939. 'alpha(opacity=' + (styles.opacity * 100) + ')';
  940. }
  941. }
  942. extend(el.style, styles);
  943. };
  944. /**
  945. * Utility function to create an HTML element with attributes and styles.
  946. *
  947. * @function Highcharts.createElement
  948. *
  949. * @param {string} tag
  950. * The HTML tag.
  951. *
  952. * @param {Highcharts.HTMLAttributes} [attribs]
  953. * Attributes as an object of key-value pairs.
  954. *
  955. * @param {Highcharts.CSSObject} [styles]
  956. * Styles as an object of key-value pairs.
  957. *
  958. * @param {Highcharts.HTMLDOMElement} [parent]
  959. * The parent HTML object.
  960. *
  961. * @param {boolean} [nopad=false]
  962. * If true, remove all padding, border and margin.
  963. *
  964. * @return {Highcharts.HTMLDOMElement}
  965. * The created DOM element.
  966. */
  967. var createElement = H.createElement = function createElement(tag,
  968. attribs,
  969. styles,
  970. parent,
  971. nopad) {
  972. var el = doc.createElement(tag);
  973. if (attribs) {
  974. extend(el, attribs);
  975. }
  976. if (nopad) {
  977. css(el, { padding: '0', border: 'none', margin: '0' });
  978. }
  979. if (styles) {
  980. css(el, styles);
  981. }
  982. if (parent) {
  983. parent.appendChild(el);
  984. }
  985. return el;
  986. };
  987. // eslint-disable-next-line valid-jsdoc
  988. /**
  989. * Extend a prototyped class by new members.
  990. *
  991. * @function Highcharts.extendClass<T>
  992. *
  993. * @param {Highcharts.Class<T>} parent
  994. * The parent prototype to inherit.
  995. *
  996. * @param {Highcharts.Dictionary<*>} members
  997. * A collection of prototype members to add or override compared to the
  998. * parent prototype.
  999. *
  1000. * @return {Highcharts.Class<T>}
  1001. * A new prototype.
  1002. */
  1003. var extendClass = H.extendClass = function extendClass(parent,
  1004. members) {
  1005. var obj = (function () { });
  1006. obj.prototype = new parent(); // eslint-disable-line new-cap
  1007. extend(obj.prototype, members);
  1008. return obj;
  1009. };
  1010. /**
  1011. * Left-pad a string to a given length by adding a character repetetively.
  1012. *
  1013. * @function Highcharts.pad
  1014. *
  1015. * @param {number} number
  1016. * The input string or number.
  1017. *
  1018. * @param {number} [length]
  1019. * The desired string length.
  1020. *
  1021. * @param {string} [padder=0]
  1022. * The character to pad with.
  1023. *
  1024. * @return {string}
  1025. * The padded string.
  1026. */
  1027. var pad = H.pad = function pad(number, length, padder) {
  1028. return new Array((length || 2) +
  1029. 1 -
  1030. String(number)
  1031. .replace('-', '')
  1032. .length).join(padder || '0') + number;
  1033. };
  1034. /**
  1035. * Return a length based on either the integer value, or a percentage of a base.
  1036. *
  1037. * @function Highcharts.relativeLength
  1038. *
  1039. * @param {Highcharts.RelativeSize} value
  1040. * A percentage string or a number.
  1041. *
  1042. * @param {number} base
  1043. * The full length that represents 100%.
  1044. *
  1045. * @param {number} [offset=0]
  1046. * A pixel offset to apply for percentage values. Used internally in
  1047. * axis positioning.
  1048. *
  1049. * @return {number}
  1050. * The computed length.
  1051. */
  1052. var relativeLength = H.relativeLength = function relativeLength(value,
  1053. base,
  1054. offset) {
  1055. return (/%$/).test(value) ?
  1056. (base * parseFloat(value) / 100) + (offset || 0) :
  1057. parseFloat(value);
  1058. };
  1059. /**
  1060. * Wrap a method with extended functionality, preserving the original function.
  1061. *
  1062. * @function Highcharts.wrap
  1063. *
  1064. * @param {*} obj
  1065. * The context object that the method belongs to. In real cases, this is
  1066. * often a prototype.
  1067. *
  1068. * @param {string} method
  1069. * The name of the method to extend.
  1070. *
  1071. * @param {Highcharts.WrapProceedFunction} func
  1072. * A wrapper function callback. This function is called with the same
  1073. * arguments as the original function, except that the original function
  1074. * is unshifted and passed as the first argument.
  1075. */
  1076. var wrap = H.wrap = function wrap(obj,
  1077. method,
  1078. func) {
  1079. var proceed = obj[method];
  1080. obj[method] = function () {
  1081. var args = Array.prototype.slice.call(arguments),
  1082. outerArgs = arguments,
  1083. ctx = this,
  1084. ret;
  1085. ctx.proceed = function () {
  1086. proceed.apply(ctx, arguments.length ? arguments : outerArgs);
  1087. };
  1088. args.unshift(proceed);
  1089. ret = func.apply(this, args);
  1090. ctx.proceed = null;
  1091. return ret;
  1092. };
  1093. };
  1094. /**
  1095. * Format a string according to a subset of the rules of Python's String.format
  1096. * method.
  1097. *
  1098. * @example
  1099. * var s = Highcharts.format(
  1100. * 'The {color} fox was {len:.2f} feet long',
  1101. * { color: 'red', len: Math.PI }
  1102. * );
  1103. * // => The red fox was 3.14 feet long
  1104. *
  1105. * @function Highcharts.format
  1106. *
  1107. * @param {string} str
  1108. * The string to format.
  1109. *
  1110. * @param {Record<string, *>} ctx
  1111. * The context, a collection of key-value pairs where each key is
  1112. * replaced by its value.
  1113. *
  1114. * @param {Highcharts.Chart} [chart]
  1115. * A `Chart` instance used to get numberFormatter and time.
  1116. *
  1117. * @return {string}
  1118. * The formatted string.
  1119. */
  1120. var format = H.format = function (str,
  1121. ctx,
  1122. chart) {
  1123. var splitter = '{',
  1124. isInside = false,
  1125. segment,
  1126. valueAndFormat,
  1127. ret = [],
  1128. val,
  1129. index;
  1130. var floatRegex = /f$/;
  1131. var decRegex = /\.([0-9])/;
  1132. var lang = H.defaultOptions.lang;
  1133. var time = chart && chart.time || H.time;
  1134. var numberFormatter = chart && chart.numberFormatter || numberFormat;
  1135. while (str) {
  1136. index = str.indexOf(splitter);
  1137. if (index === -1) {
  1138. break;
  1139. }
  1140. segment = str.slice(0, index);
  1141. if (isInside) { // we're on the closing bracket looking back
  1142. valueAndFormat = segment.split(':');
  1143. val = getNestedProperty(valueAndFormat.shift() || '', ctx);
  1144. // Format the replacement
  1145. if (valueAndFormat.length && typeof val === 'number') {
  1146. segment = valueAndFormat.join(':');
  1147. if (floatRegex.test(segment)) { // float
  1148. var decimals = parseInt((segment.match(decRegex) || ['', '-1'])[1], 10);
  1149. if (val !== null) {
  1150. val = numberFormatter(val, decimals, lang.decimalPoint, segment.indexOf(',') > -1 ? lang.thousandsSep : '');
  1151. }
  1152. }
  1153. else {
  1154. val = time.dateFormat(segment, val);
  1155. }
  1156. }
  1157. // Push the result and advance the cursor
  1158. ret.push(val);
  1159. }
  1160. else {
  1161. ret.push(segment);
  1162. }
  1163. str = str.slice(index + 1); // the rest
  1164. isInside = !isInside; // toggle
  1165. splitter = isInside ? '}' : '{'; // now look for next matching bracket
  1166. }
  1167. ret.push(str);
  1168. return ret.join('');
  1169. };
  1170. /**
  1171. * Get the magnitude of a number.
  1172. *
  1173. * @function Highcharts.getMagnitude
  1174. *
  1175. * @param {number} num
  1176. * The number.
  1177. *
  1178. * @return {number}
  1179. * The magnitude, where 1-9 are magnitude 1, 10-99 magnitude 2 etc.
  1180. */
  1181. var getMagnitude = H.getMagnitude = function (num) {
  1182. return Math.pow(10,
  1183. Math.floor(Math.log(num) / Math.LN10));
  1184. };
  1185. /**
  1186. * Take an interval and normalize it to multiples of round numbers.
  1187. *
  1188. * @deprecated
  1189. * @function Highcharts.normalizeTickInterval
  1190. *
  1191. * @param {number} interval
  1192. * The raw, un-rounded interval.
  1193. *
  1194. * @param {Array<*>} [multiples]
  1195. * Allowed multiples.
  1196. *
  1197. * @param {number} [magnitude]
  1198. * The magnitude of the number.
  1199. *
  1200. * @param {boolean} [allowDecimals]
  1201. * Whether to allow decimals.
  1202. *
  1203. * @param {boolean} [hasTickAmount]
  1204. * If it has tickAmount, avoid landing on tick intervals lower than
  1205. * original.
  1206. *
  1207. * @return {number}
  1208. * The normalized interval.
  1209. *
  1210. * @todo
  1211. * Move this function to the Axis prototype. It is here only for historical
  1212. * reasons.
  1213. */
  1214. var normalizeTickInterval = H.normalizeTickInterval = function (interval,
  1215. multiples,
  1216. magnitude,
  1217. allowDecimals,
  1218. hasTickAmount) {
  1219. var normalized,
  1220. i,
  1221. retInterval = interval;
  1222. // round to a tenfold of 1, 2, 2.5 or 5
  1223. magnitude = pick(magnitude, 1);
  1224. normalized = interval / magnitude;
  1225. // multiples for a linear scale
  1226. if (!multiples) {
  1227. multiples = hasTickAmount ?
  1228. // Finer grained ticks when the tick amount is hard set, including
  1229. // when alignTicks is true on multiple axes (#4580).
  1230. [1, 1.2, 1.5, 2, 2.5, 3, 4, 5, 6, 8, 10] :
  1231. // Else, let ticks fall on rounder numbers
  1232. [1, 2, 2.5, 5, 10];
  1233. // the allowDecimals option
  1234. if (allowDecimals === false) {
  1235. if (magnitude === 1) {
  1236. multiples = multiples.filter(function (num) {
  1237. return num % 1 === 0;
  1238. });
  1239. }
  1240. else if (magnitude <= 0.1) {
  1241. multiples = [1 / magnitude];
  1242. }
  1243. }
  1244. }
  1245. // normalize the interval to the nearest multiple
  1246. for (i = 0; i < multiples.length; i++) {
  1247. retInterval = multiples[i];
  1248. // only allow tick amounts smaller than natural
  1249. if ((hasTickAmount &&
  1250. retInterval * magnitude >= interval) ||
  1251. (!hasTickAmount &&
  1252. (normalized <=
  1253. (multiples[i] +
  1254. (multiples[i + 1] || multiples[i])) / 2))) {
  1255. break;
  1256. }
  1257. }
  1258. // Multiply back to the correct magnitude. Correct floats to appropriate
  1259. // precision (#6085).
  1260. retInterval = correctFloat(retInterval * magnitude, -Math.round(Math.log(0.001) / Math.LN10));
  1261. return retInterval;
  1262. };
  1263. /**
  1264. * Sort an object array and keep the order of equal items. The ECMAScript
  1265. * standard does not specify the behaviour when items are equal.
  1266. *
  1267. * @function Highcharts.stableSort
  1268. *
  1269. * @param {Array<*>} arr
  1270. * The array to sort.
  1271. *
  1272. * @param {Function} sortFunction
  1273. * The function to sort it with, like with regular Array.prototype.sort.
  1274. *
  1275. * @return {void}
  1276. */
  1277. var stableSort = H.stableSort = function stableSort(arr,
  1278. sortFunction) {
  1279. // @todo It seems like Chrome since v70 sorts in a stable way internally,
  1280. // plus all other browsers do it, so over time we may be able to remove this
  1281. // function
  1282. var length = arr.length,
  1283. sortValue,
  1284. i;
  1285. // Add index to each item
  1286. for (i = 0; i < length; i++) {
  1287. arr[i].safeI = i; // stable sort index
  1288. }
  1289. arr.sort(function (a, b) {
  1290. sortValue = sortFunction(a, b);
  1291. return sortValue === 0 ? a.safeI - b.safeI : sortValue;
  1292. });
  1293. // Remove index from items
  1294. for (i = 0; i < length; i++) {
  1295. delete arr[i].safeI; // stable sort index
  1296. }
  1297. };
  1298. /**
  1299. * Non-recursive method to find the lowest member of an array. `Math.min` raises
  1300. * a maximum call stack size exceeded error in Chrome when trying to apply more
  1301. * than 150.000 points. This method is slightly slower, but safe.
  1302. *
  1303. * @function Highcharts.arrayMin
  1304. *
  1305. * @param {Array<*>} data
  1306. * An array of numbers.
  1307. *
  1308. * @return {number}
  1309. * The lowest number.
  1310. */
  1311. var arrayMin = H.arrayMin = function arrayMin(data) {
  1312. var i = data.length,
  1313. min = data[0];
  1314. while (i--) {
  1315. if (data[i] < min) {
  1316. min = data[i];
  1317. }
  1318. }
  1319. return min;
  1320. };
  1321. /**
  1322. * Non-recursive method to find the lowest member of an array. `Math.max` raises
  1323. * a maximum call stack size exceeded error in Chrome when trying to apply more
  1324. * than 150.000 points. This method is slightly slower, but safe.
  1325. *
  1326. * @function Highcharts.arrayMax
  1327. *
  1328. * @param {Array<*>} data
  1329. * An array of numbers.
  1330. *
  1331. * @return {number}
  1332. * The highest number.
  1333. */
  1334. var arrayMax = H.arrayMax = function arrayMax(data) {
  1335. var i = data.length,
  1336. max = data[0];
  1337. while (i--) {
  1338. if (data[i] > max) {
  1339. max = data[i];
  1340. }
  1341. }
  1342. return max;
  1343. };
  1344. /**
  1345. * Utility method that destroys any SVGElement instances that are properties on
  1346. * the given object. It loops all properties and invokes destroy if there is a
  1347. * destroy method. The property is then delete.
  1348. *
  1349. * @function Highcharts.destroyObjectProperties
  1350. *
  1351. * @param {*} obj
  1352. * The object to destroy properties on.
  1353. *
  1354. * @param {*} [except]
  1355. * Exception, do not destroy this property, only delete it.
  1356. */
  1357. var destroyObjectProperties = H.destroyObjectProperties =
  1358. function destroyObjectProperties(obj,
  1359. except) {
  1360. objectEach(obj,
  1361. function (val,
  1362. n) {
  1363. // If the object is non-null and destroy is defined
  1364. if (val && val !== except && val.destroy) {
  1365. // Invoke the destroy
  1366. val.destroy();
  1367. }
  1368. // Delete the property from the object.
  1369. delete obj[n];
  1370. });
  1371. };
  1372. /**
  1373. * Discard a HTML element by moving it to the bin and delete.
  1374. *
  1375. * @function Highcharts.discardElement
  1376. *
  1377. * @param {Highcharts.HTMLDOMElement} element
  1378. * The HTML node to discard.
  1379. */
  1380. var discardElement = H.discardElement = function discardElement(element) {
  1381. var garbageBin = H.garbageBin;
  1382. // create a garbage bin element, not part of the DOM
  1383. if (!garbageBin) {
  1384. garbageBin = createElement('div');
  1385. }
  1386. // move the node and empty bin
  1387. if (element) {
  1388. garbageBin.appendChild(element);
  1389. }
  1390. garbageBin.innerHTML = '';
  1391. };
  1392. /**
  1393. * Fix JS round off float errors.
  1394. *
  1395. * @function Highcharts.correctFloat
  1396. *
  1397. * @param {number} num
  1398. * A float number to fix.
  1399. *
  1400. * @param {number} [prec=14]
  1401. * The precision.
  1402. *
  1403. * @return {number}
  1404. * The corrected float number.
  1405. */
  1406. var correctFloat = H.correctFloat = function correctFloat(num,
  1407. prec) {
  1408. return parseFloat(num.toPrecision(prec || 14));
  1409. };
  1410. /**
  1411. * The time unit lookup
  1412. *
  1413. * @ignore
  1414. */
  1415. var timeUnits = H.timeUnits = {
  1416. millisecond: 1,
  1417. second: 1000,
  1418. minute: 60000,
  1419. hour: 3600000,
  1420. day: 24 * 3600000,
  1421. week: 7 * 24 * 3600000,
  1422. month: 28 * 24 * 3600000,
  1423. year: 364 * 24 * 3600000
  1424. };
  1425. /**
  1426. * Format a number and return a string based on input settings.
  1427. *
  1428. * @sample highcharts/members/highcharts-numberformat/
  1429. * Custom number format
  1430. *
  1431. * @function Highcharts.numberFormat
  1432. *
  1433. * @param {number} number
  1434. * The input number to format.
  1435. *
  1436. * @param {number} decimals
  1437. * The amount of decimals. A value of -1 preserves the amount in the
  1438. * input number.
  1439. *
  1440. * @param {string} [decimalPoint]
  1441. * The decimal point, defaults to the one given in the lang options, or
  1442. * a dot.
  1443. *
  1444. * @param {string} [thousandsSep]
  1445. * The thousands separator, defaults to the one given in the lang
  1446. * options, or a space character.
  1447. *
  1448. * @return {string}
  1449. * The formatted number.
  1450. */
  1451. var numberFormat = H.numberFormat = function numberFormat(number,
  1452. decimals,
  1453. decimalPoint,
  1454. thousandsSep) {
  1455. number = +number || 0;
  1456. decimals = +decimals;
  1457. var lang = H.defaultOptions.lang, origDec = (number.toString().split('.')[1] || '').split('e')[0].length, strinteger, thousands, ret, roundedNumber, exponent = number.toString().split('e'), fractionDigits;
  1458. if (decimals === -1) {
  1459. // Preserve decimals. Not huge numbers (#3793).
  1460. decimals = Math.min(origDec, 20);
  1461. }
  1462. else if (!isNumber(decimals)) {
  1463. decimals = 2;
  1464. }
  1465. else if (decimals && exponent[1] && exponent[1] < 0) {
  1466. // Expose decimals from exponential notation (#7042)
  1467. fractionDigits = decimals + +exponent[1];
  1468. if (fractionDigits >= 0) {
  1469. // remove too small part of the number while keeping the notation
  1470. exponent[0] = (+exponent[0]).toExponential(fractionDigits)
  1471. .split('e')[0];
  1472. decimals = fractionDigits;
  1473. }
  1474. else {
  1475. // fractionDigits < 0
  1476. exponent[0] = exponent[0].split('.')[0] || 0;
  1477. if (decimals < 20) {
  1478. // use number instead of exponential notation (#7405)
  1479. number = (exponent[0] * Math.pow(10, exponent[1]))
  1480. .toFixed(decimals);
  1481. }
  1482. else {
  1483. // or zero
  1484. number = 0;
  1485. }
  1486. exponent[1] = 0;
  1487. }
  1488. }
  1489. // Add another decimal to avoid rounding errors of float numbers. (#4573)
  1490. // Then use toFixed to handle rounding.
  1491. roundedNumber = (Math.abs(exponent[1] ? exponent[0] : number) +
  1492. Math.pow(10, -Math.max(decimals, origDec) - 1)).toFixed(decimals);
  1493. // A string containing the positive integer component of the number
  1494. strinteger = String(pInt(roundedNumber));
  1495. // Leftover after grouping into thousands. Can be 0, 1 or 2.
  1496. thousands = strinteger.length > 3 ? strinteger.length % 3 : 0;
  1497. // Language
  1498. decimalPoint = pick(decimalPoint, lang.decimalPoint);
  1499. thousandsSep = pick(thousandsSep, lang.thousandsSep);
  1500. // Start building the return
  1501. ret = number < 0 ? '-' : '';
  1502. // Add the leftover after grouping into thousands. For example, in the
  1503. // number 42 000 000, this line adds 42.
  1504. ret += thousands ? strinteger.substr(0, thousands) + thousandsSep : '';
  1505. // Add the remaining thousands groups, joined by the thousands separator
  1506. ret += strinteger
  1507. .substr(thousands)
  1508. .replace(/(\d{3})(?=\d)/g, '$1' + thousandsSep);
  1509. // Add the decimal point and the decimal component
  1510. if (decimals) {
  1511. // Get the decimal component
  1512. ret += decimalPoint + roundedNumber.slice(-decimals);
  1513. }
  1514. if (exponent[1] && +ret !== 0) {
  1515. ret += 'e' + exponent[1];
  1516. }
  1517. return ret;
  1518. };
  1519. /**
  1520. * Easing definition
  1521. *
  1522. * @private
  1523. * @function Math.easeInOutSine
  1524. *
  1525. * @param {number} pos
  1526. * Current position, ranging from 0 to 1.
  1527. *
  1528. * @return {number}
  1529. * Ease result
  1530. */
  1531. Math.easeInOutSine = function (pos) {
  1532. return -0.5 * (Math.cos(Math.PI * pos) - 1);
  1533. };
  1534. /**
  1535. * Returns the value of a property path on a given object.
  1536. *
  1537. * @private
  1538. * @function getNestedProperty
  1539. *
  1540. * @param {string} path
  1541. * Path to the property, for example `custom.myValue`.
  1542. *
  1543. * @param {unknown} obj
  1544. * Instance containing the property on the specific path.
  1545. *
  1546. * @return {unknown}
  1547. * The unknown property value.
  1548. */
  1549. function getNestedProperty(path, obj) {
  1550. if (!path) {
  1551. return obj;
  1552. }
  1553. var pathElements = path.split('.').reverse();
  1554. var subProperty = obj;
  1555. if (pathElements.length === 1) {
  1556. return subProperty[path];
  1557. }
  1558. var pathElement = pathElements.pop();
  1559. while (typeof pathElement !== 'undefined' &&
  1560. typeof subProperty !== 'undefined' &&
  1561. subProperty !== null) {
  1562. subProperty = subProperty[pathElement];
  1563. pathElement = pathElements.pop();
  1564. }
  1565. return subProperty;
  1566. }
  1567. /**
  1568. * Get the computed CSS value for given element and property, only for numerical
  1569. * properties. For width and height, the dimension of the inner box (excluding
  1570. * padding) is returned. Used for fitting the chart within the container.
  1571. *
  1572. * @function Highcharts.getStyle
  1573. *
  1574. * @param {Highcharts.HTMLDOMElement} el
  1575. * An HTML element.
  1576. *
  1577. * @param {string} prop
  1578. * The property name.
  1579. *
  1580. * @param {boolean} [toInt=true]
  1581. * Parse to integer.
  1582. *
  1583. * @return {number|string}
  1584. * The numeric value.
  1585. */
  1586. var getStyle = H.getStyle = function (el,
  1587. prop,
  1588. toInt) {
  1589. var style;
  1590. // For width and height, return the actual inner pixel size (#4913)
  1591. if (prop === 'width') {
  1592. var offsetWidth = Math.min(el.offsetWidth,
  1593. el.scrollWidth);
  1594. // In flex boxes, we need to use getBoundingClientRect and floor it,
  1595. // because scrollWidth doesn't support subpixel precision (#6427) ...
  1596. var boundingClientRectWidth = el.getBoundingClientRect &&
  1597. el.getBoundingClientRect().width;
  1598. // ...unless if the containing div or its parents are transform-scaled
  1599. // down, in which case the boundingClientRect can't be used as it is
  1600. // also scaled down (#9871, #10498).
  1601. if (boundingClientRectWidth < offsetWidth &&
  1602. boundingClientRectWidth >= offsetWidth - 1) {
  1603. offsetWidth = Math.floor(boundingClientRectWidth);
  1604. }
  1605. return Math.max(0, // #8377
  1606. (offsetWidth -
  1607. H.getStyle(el, 'padding-left') -
  1608. H.getStyle(el, 'padding-right')));
  1609. }
  1610. if (prop === 'height') {
  1611. return Math.max(0, // #8377
  1612. Math.min(el.offsetHeight, el.scrollHeight) -
  1613. H.getStyle(el, 'padding-top') -
  1614. H.getStyle(el, 'padding-bottom'));
  1615. }
  1616. if (!win.getComputedStyle) {
  1617. // SVG not supported, forgot to load oldie.js?
  1618. error(27, true);
  1619. }
  1620. // Otherwise, get the computed style
  1621. style = win.getComputedStyle(el, undefined); // eslint-disable-line no-undefined
  1622. if (style) {
  1623. style = style.getPropertyValue(prop);
  1624. if (pick(toInt, prop !== 'opacity')) {
  1625. style = pInt(style);
  1626. }
  1627. }
  1628. return style;
  1629. };
  1630. /**
  1631. * Search for an item in an array.
  1632. *
  1633. * @function Highcharts.inArray
  1634. *
  1635. * @deprecated
  1636. *
  1637. * @param {*} item
  1638. * The item to search for.
  1639. *
  1640. * @param {Array<*>} arr
  1641. * The array or node collection to search in.
  1642. *
  1643. * @param {number} [fromIndex=0]
  1644. * The index to start searching from.
  1645. *
  1646. * @return {number}
  1647. * The index within the array, or -1 if not found.
  1648. */
  1649. var inArray = H.inArray = function (item,
  1650. arr,
  1651. fromIndex) {
  1652. error(32,
  1653. false,
  1654. void 0, { 'Highcharts.inArray': 'use Array.indexOf' });
  1655. return arr.indexOf(item, fromIndex);
  1656. };
  1657. /* eslint-disable valid-jsdoc */
  1658. /**
  1659. * Return the value of the first element in the array that satisfies the
  1660. * provided testing function.
  1661. *
  1662. * @function Highcharts.find<T>
  1663. *
  1664. * @param {Array<T>} arr
  1665. * The array to test.
  1666. *
  1667. * @param {Function} callback
  1668. * The callback function. The function receives the item as the first
  1669. * argument. Return `true` if this item satisfies the condition.
  1670. *
  1671. * @return {T|undefined}
  1672. * The value of the element.
  1673. */
  1674. var find = H.find = Array.prototype.find ?
  1675. /* eslint-enable valid-jsdoc */
  1676. function (arr,
  1677. callback) {
  1678. return arr.find(callback);
  1679. } :
  1680. // Legacy implementation. PhantomJS, IE <= 11 etc. #7223.
  1681. function (arr, callback) {
  1682. var i,
  1683. length = arr.length;
  1684. for (i = 0; i < length; i++) {
  1685. if (callback(arr[i], i)) { // eslint-disable-line callback-return
  1686. return arr[i];
  1687. }
  1688. }
  1689. };
  1690. /**
  1691. * Returns an array of a given object's own properties.
  1692. *
  1693. * @function Highcharts.keys
  1694. * @deprecated
  1695. *
  1696. * @param {*} obj
  1697. * The object of which the properties are to be returned.
  1698. *
  1699. * @return {Array<string>}
  1700. * An array of strings that represents all the properties.
  1701. */
  1702. H.keys = function (obj) {
  1703. error(32, false, void 0, { 'Highcharts.keys': 'use Object.keys' });
  1704. return Object.keys(obj);
  1705. };
  1706. /**
  1707. * Get the element's offset position, corrected for `overflow: auto`.
  1708. *
  1709. * @function Highcharts.offset
  1710. *
  1711. * @param {global.Element} el
  1712. * The DOM element.
  1713. *
  1714. * @return {Highcharts.OffsetObject}
  1715. * An object containing `left` and `top` properties for the position in
  1716. * the page.
  1717. */
  1718. var offset = H.offset = function offset(el) {
  1719. var docElem = doc.documentElement,
  1720. box = (el.parentElement || el.parentNode) ?
  1721. el.getBoundingClientRect() :
  1722. { top: 0,
  1723. left: 0 };
  1724. return {
  1725. top: box.top + (win.pageYOffset || docElem.scrollTop) -
  1726. (docElem.clientTop || 0),
  1727. left: box.left + (win.pageXOffset || docElem.scrollLeft) -
  1728. (docElem.clientLeft || 0)
  1729. };
  1730. };
  1731. /* eslint-disable valid-jsdoc */
  1732. /**
  1733. * Iterate over object key pairs in an object.
  1734. *
  1735. * @function Highcharts.objectEach<T>
  1736. *
  1737. * @param {*} obj
  1738. * The object to iterate over.
  1739. *
  1740. * @param {Highcharts.ObjectEachCallbackFunction<T>} fn
  1741. * The iterator callback. It passes three arguments:
  1742. * * value - The property value.
  1743. * * key - The property key.
  1744. * * obj - The object that objectEach is being applied to.
  1745. *
  1746. * @param {T} [ctx]
  1747. * The context.
  1748. *
  1749. * @return {void}
  1750. */
  1751. var objectEach = H.objectEach = function objectEach(obj,
  1752. fn,
  1753. ctx) {
  1754. /* eslint-enable valid-jsdoc */
  1755. for (var key in obj) {
  1756. if (Object.hasOwnProperty.call(obj,
  1757. key)) {
  1758. fn.call(ctx || obj[key],
  1759. obj[key],
  1760. key,
  1761. obj);
  1762. }
  1763. }
  1764. };
  1765. /**
  1766. * Iterate over an array.
  1767. *
  1768. * @deprecated
  1769. * @function Highcharts.each
  1770. *
  1771. * @param {Array<*>} arr
  1772. * The array to iterate over.
  1773. *
  1774. * @param {Function} fn
  1775. * The iterator callback. It passes three arguments:
  1776. * - `item`: The array item.
  1777. * - `index`: The item's index in the array.
  1778. * - `arr`: The array that each is being applied to.
  1779. *
  1780. * @param {*} [ctx]
  1781. * The context.
  1782. *
  1783. * @return {void}
  1784. */
  1785. /**
  1786. * Filter an array by a callback.
  1787. *
  1788. * @deprecated
  1789. * @function Highcharts.grep
  1790. *
  1791. * @param {Array<*>} arr
  1792. * The array to filter.
  1793. *
  1794. * @param {Function} callback
  1795. * The callback function. The function receives the item as the first
  1796. * argument. Return `true` if the item is to be preserved.
  1797. *
  1798. * @return {Array<*>}
  1799. * A new, filtered array.
  1800. */
  1801. /**
  1802. * Map an array by a callback.
  1803. *
  1804. * @deprecated
  1805. * @function Highcharts.map
  1806. *
  1807. * @param {Array<*>} arr
  1808. * The array to map.
  1809. *
  1810. * @param {Function} fn
  1811. * The callback function. Return the new value for the new array.
  1812. *
  1813. * @return {Array<*>}
  1814. * A new array item with modified items.
  1815. */
  1816. /**
  1817. * Reduce an array to a single value.
  1818. *
  1819. * @deprecated
  1820. * @function Highcharts.reduce
  1821. *
  1822. * @param {Array<*>} arr
  1823. * The array to reduce.
  1824. *
  1825. * @param {Function} fn
  1826. * The callback function. Return the reduced value. Receives 4
  1827. * arguments: Accumulated/reduced value, current value, current array
  1828. * index, and the array.
  1829. *
  1830. * @param {*} initialValue
  1831. * The initial value of the accumulator.
  1832. *
  1833. * @return {*}
  1834. * The reduced value.
  1835. */
  1836. /**
  1837. * Test whether at least one element in the array passes the test implemented by
  1838. * the provided function.
  1839. *
  1840. * @deprecated
  1841. * @function Highcharts.some
  1842. *
  1843. * @param {Array<*>} arr
  1844. * The array to test
  1845. *
  1846. * @param {Function} fn
  1847. * The function to run on each item. Return truty to pass the test.
  1848. * Receives arguments `currentValue`, `index` and `array`.
  1849. *
  1850. * @param {*} ctx
  1851. * The context.
  1852. *
  1853. * @return {boolean}
  1854. */
  1855. objectEach({
  1856. map: 'map',
  1857. each: 'forEach',
  1858. grep: 'filter',
  1859. reduce: 'reduce',
  1860. some: 'some'
  1861. }, function (val, key) {
  1862. H[key] = function (arr) {
  1863. var _a;
  1864. error(32, false, void 0, (_a = {}, _a["Highcharts." + key] = "use Array." + val, _a));
  1865. return Array.prototype[val].apply(arr, [].slice.call(arguments, 1));
  1866. };
  1867. });
  1868. /* eslint-disable valid-jsdoc */
  1869. /**
  1870. * Add an event listener.
  1871. *
  1872. * @function Highcharts.addEvent<T>
  1873. *
  1874. * @param {Highcharts.Class<T>|T} el
  1875. * The element or object to add a listener to. It can be a
  1876. * {@link HTMLDOMElement}, an {@link SVGElement} or any other object.
  1877. *
  1878. * @param {string} type
  1879. * The event type.
  1880. *
  1881. * @param {Highcharts.EventCallbackFunction<T>|Function} fn
  1882. * The function callback to execute when the event is fired.
  1883. *
  1884. * @param {Highcharts.EventOptionsObject} [options]
  1885. * Options for adding the event.
  1886. *
  1887. * @return {Function}
  1888. * A callback function to remove the added event.
  1889. */
  1890. var addEvent = H.addEvent = function (el,
  1891. type,
  1892. fn,
  1893. options) {
  1894. if (options === void 0) { options = {}; }
  1895. /* eslint-enable valid-jsdoc */
  1896. var events,
  1897. addEventListener = (el.addEventListener || H.addEventListenerPolyfill);
  1898. // If we're setting events directly on the constructor, use a separate
  1899. // collection, `protoEvents` to distinguish it from the item events in
  1900. // `hcEvents`.
  1901. if (typeof el === 'function' && el.prototype) {
  1902. events = el.prototype.protoEvents = el.prototype.protoEvents || {};
  1903. }
  1904. else {
  1905. events = el.hcEvents = el.hcEvents || {};
  1906. }
  1907. // Allow click events added to points, otherwise they will be prevented by
  1908. // the TouchPointer.pinch function after a pinch zoom operation (#7091).
  1909. if (H.Point &&
  1910. el instanceof H.Point &&
  1911. el.series &&
  1912. el.series.chart) {
  1913. el.series.chart.runTrackerClick = true;
  1914. }
  1915. // Handle DOM events
  1916. if (addEventListener) {
  1917. addEventListener.call(el, type, fn, false);
  1918. }
  1919. if (!events[type]) {
  1920. events[type] = [];
  1921. }
  1922. var eventObject = {
  1923. fn: fn,
  1924. order: typeof options.order === 'number' ? options.order : Infinity
  1925. };
  1926. events[type].push(eventObject);
  1927. // Order the calls
  1928. events[type].sort(function (a, b) {
  1929. return a.order - b.order;
  1930. });
  1931. // Return a function that can be called to remove this event.
  1932. return function () {
  1933. removeEvent(el, type, fn);
  1934. };
  1935. };
  1936. /* eslint-disable valid-jsdoc */
  1937. /**
  1938. * Remove an event that was added with {@link Highcharts#addEvent}.
  1939. *
  1940. * @function Highcharts.removeEvent<T>
  1941. *
  1942. * @param {Highcharts.Class<T>|T} el
  1943. * The element to remove events on.
  1944. *
  1945. * @param {string} [type]
  1946. * The type of events to remove. If undefined, all events are removed
  1947. * from the element.
  1948. *
  1949. * @param {Highcharts.EventCallbackFunction<T>} [fn]
  1950. * The specific callback to remove. If undefined, all events that match
  1951. * the element and optionally the type are removed.
  1952. *
  1953. * @return {void}
  1954. */
  1955. var removeEvent = H.removeEvent = function removeEvent(el,
  1956. type,
  1957. fn) {
  1958. /* eslint-enable valid-jsdoc */
  1959. var events;
  1960. /**
  1961. * @private
  1962. * @param {string} type - event type
  1963. * @param {Highcharts.EventCallbackFunction<T>} fn - callback
  1964. * @return {void}
  1965. */
  1966. function removeOneEvent(type, fn) {
  1967. var removeEventListener = (el.removeEventListener || H.removeEventListenerPolyfill);
  1968. if (removeEventListener) {
  1969. removeEventListener.call(el, type, fn, false);
  1970. }
  1971. }
  1972. /**
  1973. * @private
  1974. * @param {any} eventCollection - collection
  1975. * @return {void}
  1976. */
  1977. function removeAllEvents(eventCollection) {
  1978. var types,
  1979. len;
  1980. if (!el.nodeName) {
  1981. return; // break on non-DOM events
  1982. }
  1983. if (type) {
  1984. types = {};
  1985. types[type] = true;
  1986. }
  1987. else {
  1988. types = eventCollection;
  1989. }
  1990. objectEach(types, function (_val, n) {
  1991. if (eventCollection[n]) {
  1992. len = eventCollection[n].length;
  1993. while (len--) {
  1994. removeOneEvent(n, eventCollection[n][len].fn);
  1995. }
  1996. }
  1997. });
  1998. }
  1999. ['protoEvents', 'hcEvents'].forEach(function (coll, i) {
  2000. var eventElem = i ? el : el.prototype;
  2001. var eventCollection = eventElem && eventElem[coll];
  2002. if (eventCollection) {
  2003. if (type) {
  2004. events = (eventCollection[type] || []);
  2005. if (fn) {
  2006. eventCollection[type] = events.filter(function (obj) {
  2007. return fn !== obj.fn;
  2008. });
  2009. removeOneEvent(type, fn);
  2010. }
  2011. else {
  2012. removeAllEvents(eventCollection);
  2013. eventCollection[type] = [];
  2014. }
  2015. }
  2016. else {
  2017. removeAllEvents(eventCollection);
  2018. eventElem[coll] = {};
  2019. }
  2020. }
  2021. });
  2022. };
  2023. /* eslint-disable valid-jsdoc */
  2024. /**
  2025. * Fire an event that was registered with {@link Highcharts#addEvent}.
  2026. *
  2027. * @function Highcharts.fireEvent<T>
  2028. *
  2029. * @param {T} el
  2030. * The object to fire the event on. It can be a {@link HTMLDOMElement},
  2031. * an {@link SVGElement} or any other object.
  2032. *
  2033. * @param {string} type
  2034. * The type of event.
  2035. *
  2036. * @param {Highcharts.Dictionary<*>|Event} [eventArguments]
  2037. * Custom event arguments that are passed on as an argument to the event
  2038. * handler.
  2039. *
  2040. * @param {Highcharts.EventCallbackFunction<T>|Function} [defaultFunction]
  2041. * The default function to execute if the other listeners haven't
  2042. * returned false.
  2043. *
  2044. * @return {void}
  2045. */
  2046. var fireEvent = H.fireEvent = function (el,
  2047. type,
  2048. eventArguments,
  2049. defaultFunction) {
  2050. /* eslint-enable valid-jsdoc */
  2051. var e,
  2052. i;
  2053. eventArguments = eventArguments || {};
  2054. if (doc.createEvent &&
  2055. (el.dispatchEvent || el.fireEvent)) {
  2056. e = doc.createEvent('Events');
  2057. e.initEvent(type, true, true);
  2058. extend(e, eventArguments);
  2059. if (el.dispatchEvent) {
  2060. el.dispatchEvent(e);
  2061. }
  2062. else {
  2063. el.fireEvent(type, e);
  2064. }
  2065. }
  2066. else {
  2067. if (!eventArguments.target) {
  2068. // We're running a custom event
  2069. extend(eventArguments, {
  2070. // Attach a simple preventDefault function to skip
  2071. // default handler if called. The built-in
  2072. // defaultPrevented property is not overwritable (#5112)
  2073. preventDefault: function () {
  2074. eventArguments.defaultPrevented = true;
  2075. },
  2076. // Setting target to native events fails with clicking
  2077. // the zoom-out button in Chrome.
  2078. target: el,
  2079. // If the type is not set, we're running a custom event
  2080. // (#2297). If it is set, we're running a browser event,
  2081. // and setting it will cause en error in IE8 (#2465).
  2082. type: type
  2083. });
  2084. }
  2085. var fireInOrder = function (protoEvents,
  2086. hcEvents) {
  2087. if (protoEvents === void 0) { protoEvents = []; }
  2088. if (hcEvents === void 0) { hcEvents = []; }
  2089. var iA = 0;
  2090. var iB = 0;
  2091. var length = protoEvents.length + hcEvents.length;
  2092. for (i = 0; i < length; i++) {
  2093. var obj = (!protoEvents[iA] ?
  2094. hcEvents[iB++] :
  2095. !hcEvents[iB] ?
  2096. protoEvents[iA++] :
  2097. protoEvents[iA].order <= hcEvents[iB].order ?
  2098. protoEvents[iA++] :
  2099. hcEvents[iB++]);
  2100. // If the event handler return false, prevent the default
  2101. // handler from executing
  2102. if (obj.fn.call(el, eventArguments) === false) {
  2103. eventArguments.preventDefault();
  2104. }
  2105. }
  2106. };
  2107. fireInOrder(el.protoEvents && el.protoEvents[type], el.hcEvents && el.hcEvents[type]);
  2108. }
  2109. // Run the default if not prevented
  2110. if (defaultFunction && !eventArguments.defaultPrevented) {
  2111. defaultFunction.call(el, eventArguments);
  2112. }
  2113. };
  2114. var serialMode;
  2115. /**
  2116. * Get a unique key for using in internal element id's and pointers. The key is
  2117. * composed of a random hash specific to this Highcharts instance, and a
  2118. * counter.
  2119. *
  2120. * @example
  2121. * var id = uniqueKey(); // => 'highcharts-x45f6hp-0'
  2122. *
  2123. * @function Highcharts.uniqueKey
  2124. *
  2125. * @return {string}
  2126. * A unique key.
  2127. */
  2128. var uniqueKey = H.uniqueKey = (function () {
  2129. var hash = Math.random().toString(36).substring(2, 9) + '-';
  2130. var id = 0;
  2131. return function () {
  2132. return 'highcharts-' + (serialMode ? '' : hash) + id++;
  2133. };
  2134. }());
  2135. /**
  2136. * Activates a serial mode for element IDs provided by
  2137. * {@link Highcharts.uniqueKey}. This mode can be used in automated tests, where
  2138. * a simple comparison of two rendered SVG graphics is needed.
  2139. *
  2140. * **Note:** This is only for testing purposes and will break functionality in
  2141. * webpages with multiple charts.
  2142. *
  2143. * @example
  2144. * if (
  2145. * process &&
  2146. * process.env.NODE_ENV === 'development'
  2147. * ) {
  2148. * Highcharts.useSerialIds(true);
  2149. * }
  2150. *
  2151. * @function Highcharts.useSerialIds
  2152. *
  2153. * @param {boolean} [mode]
  2154. * Changes the state of serial mode.
  2155. *
  2156. * @return {boolean|undefined}
  2157. * State of the serial mode.
  2158. */
  2159. var useSerialIds = H.useSerialIds = function (mode) {
  2160. return (serialMode = pick(mode,
  2161. serialMode));
  2162. };
  2163. var isFunction = H.isFunction = function (obj) {
  2164. return typeof obj === 'function';
  2165. };
  2166. /**
  2167. * Get the updated default options. Until 3.0.7, merely exposing defaultOptions
  2168. * for outside modules wasn't enough because the setOptions method created a new
  2169. * object.
  2170. *
  2171. * @function Highcharts.getOptions
  2172. *
  2173. * @return {Highcharts.Options}
  2174. */
  2175. var getOptions = H.getOptions = function () {
  2176. return H.defaultOptions;
  2177. };
  2178. /**
  2179. * Merge the default options with custom options and return the new options
  2180. * structure. Commonly used for defining reusable templates.
  2181. *
  2182. * @sample highcharts/global/useutc-false Setting a global option
  2183. * @sample highcharts/members/setoptions Applying a global theme
  2184. *
  2185. * @function Highcharts.setOptions
  2186. *
  2187. * @param {Highcharts.Options} options
  2188. * The new custom chart options.
  2189. *
  2190. * @return {Highcharts.Options}
  2191. * Updated options.
  2192. */
  2193. var setOptions = H.setOptions = function (options) {
  2194. // Copy in the default options
  2195. H.defaultOptions = merge(true,
  2196. H.defaultOptions,
  2197. options);
  2198. // Update the time object
  2199. if (options.time || options.global) {
  2200. H.time.update(merge(H.defaultOptions.global, H.defaultOptions.time, options.global, options.time));
  2201. }
  2202. return H.defaultOptions;
  2203. };
  2204. // Register Highcharts as a plugin in jQuery
  2205. if (win.jQuery) {
  2206. /**
  2207. * Highcharts-extended JQuery.
  2208. *
  2209. * @external JQuery
  2210. */
  2211. /**
  2212. * Helper function to return the chart of the current JQuery selector
  2213. * element.
  2214. *
  2215. * @function external:JQuery#highcharts
  2216. *
  2217. * @return {Highcharts.Chart}
  2218. * The chart that is linked to the JQuery selector element.
  2219. */ /**
  2220. * Factory function to create a chart in the current JQuery selector
  2221. * element.
  2222. *
  2223. * @function external:JQuery#highcharts
  2224. *
  2225. * @param {'Chart'|'Map'|'StockChart'|string} [className]
  2226. * Name of the factory class in the Highcharts namespace.
  2227. *
  2228. * @param {Highcharts.Options} [options]
  2229. * The chart options structure.
  2230. *
  2231. * @param {Highcharts.ChartCallbackFunction} [callback]
  2232. * Function to run when the chart has loaded and and all external
  2233. * images are loaded. Defining a
  2234. * [chart.events.load](https://api.highcharts.com/highcharts/chart.events.load)
  2235. * handler is equivalent.
  2236. *
  2237. * @return {JQuery}
  2238. * The current JQuery selector.
  2239. */
  2240. win.jQuery.fn.highcharts = function () {
  2241. var args = [].slice.call(arguments);
  2242. if (this[0]) { // this[0] is the renderTo div
  2243. // Create the chart
  2244. if (args[0]) {
  2245. new H[ // eslint-disable-line computed-property-spacing, no-new
  2246. // Constructor defaults to Chart
  2247. isString(args[0]) ? args.shift() : 'Chart'](this[0], args[0], args[1]);
  2248. return this;
  2249. }
  2250. // When called without parameters or with the return argument,
  2251. // return an existing chart
  2252. return charts[attr(this[0], 'data-highcharts-chart')];
  2253. }
  2254. };
  2255. }
  2256. // TODO use named exports when supported.
  2257. var utilitiesModule = {
  2258. addEvent: addEvent,
  2259. arrayMax: arrayMax,
  2260. arrayMin: arrayMin,
  2261. attr: attr,
  2262. clamp: clamp,
  2263. clearTimeout: internalClearTimeout,
  2264. correctFloat: correctFloat,
  2265. createElement: createElement,
  2266. css: css,
  2267. defined: defined,
  2268. destroyObjectProperties: destroyObjectProperties,
  2269. discardElement: discardElement,
  2270. erase: erase,
  2271. error: error,
  2272. extend: extend,
  2273. extendClass: extendClass,
  2274. find: find,
  2275. fireEvent: fireEvent,
  2276. format: format,
  2277. getMagnitude: getMagnitude,
  2278. getNestedProperty: getNestedProperty,
  2279. getOptions: getOptions,
  2280. getStyle: getStyle,
  2281. inArray: inArray,
  2282. isArray: isArray,
  2283. isClass: isClass,
  2284. isDOMElement: isDOMElement,
  2285. isFunction: isFunction,
  2286. isNumber: isNumber,
  2287. isObject: isObject,
  2288. isString: isString,
  2289. merge: merge,
  2290. normalizeTickInterval: normalizeTickInterval,
  2291. numberFormat: numberFormat,
  2292. objectEach: objectEach,
  2293. offset: offset,
  2294. pad: pad,
  2295. pick: pick,
  2296. pInt: pInt,
  2297. relativeLength: relativeLength,
  2298. removeEvent: removeEvent,
  2299. setOptions: setOptions,
  2300. splat: splat,
  2301. stableSort: stableSort,
  2302. syncTimeout: syncTimeout,
  2303. timeUnits: timeUnits,
  2304. uniqueKey: uniqueKey,
  2305. useSerialIds: useSerialIds,
  2306. wrap: wrap
  2307. };
  2308. return utilitiesModule;
  2309. });
  2310. _registerModule(_modules, 'Core/Color/Color.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  2311. /* *
  2312. *
  2313. * (c) 2010-2020 Torstein Honsi
  2314. *
  2315. * License: www.highcharts.com/license
  2316. *
  2317. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  2318. *
  2319. * */
  2320. var isNumber = U.isNumber,
  2321. merge = U.merge,
  2322. pInt = U.pInt;
  2323. /**
  2324. * A valid color to be parsed and handled by Highcharts. Highcharts internally
  2325. * supports hex colors like `#ffffff`, rgb colors like `rgb(255,255,255)` and
  2326. * rgba colors like `rgba(255,255,255,1)`. Other colors may be supported by the
  2327. * browsers and displayed correctly, but Highcharts is not able to process them
  2328. * and apply concepts like opacity and brightening.
  2329. *
  2330. * @typedef {string} Highcharts.ColorString
  2331. */
  2332. /**
  2333. * A valid color type than can be parsed and handled by Highcharts. It can be a
  2334. * color string, a gradient object, or a pattern object.
  2335. *
  2336. * @typedef {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject} Highcharts.ColorType
  2337. */
  2338. /**
  2339. * Gradient options instead of a solid color.
  2340. *
  2341. * @example
  2342. * // Linear gradient used as a color option
  2343. * color: {
  2344. * linearGradient: { x1: 0, x2: 0, y1: 0, y2: 1 },
  2345. * stops: [
  2346. * [0, '#003399'], // start
  2347. * [0.5, '#ffffff'], // middle
  2348. * [1, '#3366AA'] // end
  2349. * ]
  2350. * }
  2351. *
  2352. * @interface Highcharts.GradientColorObject
  2353. */ /**
  2354. * Holds an object that defines the start position and the end position relative
  2355. * to the shape.
  2356. * @name Highcharts.GradientColorObject#linearGradient
  2357. * @type {Highcharts.LinearGradientColorObject|undefined}
  2358. */ /**
  2359. * Holds an object that defines the center position and the radius.
  2360. * @name Highcharts.GradientColorObject#radialGradient
  2361. * @type {Highcharts.RadialGradientColorObject|undefined}
  2362. */ /**
  2363. * The first item in each tuple is the position in the gradient, where 0 is the
  2364. * start of the gradient and 1 is the end of the gradient. Multiple stops can be
  2365. * applied. The second item is the color for each stop. This color can also be
  2366. * given in the rgba format.
  2367. * @name Highcharts.GradientColorObject#stops
  2368. * @type {Array<Highcharts.GradientColorStopObject>}
  2369. */
  2370. /**
  2371. * Color stop tuple.
  2372. *
  2373. * @see Highcharts.GradientColorObject
  2374. *
  2375. * @interface Highcharts.GradientColorStopObject
  2376. */ /**
  2377. * @name Highcharts.GradientColorStopObject#0
  2378. * @type {number}
  2379. */ /**
  2380. * @name Highcharts.GradientColorStopObject#1
  2381. * @type {Highcharts.ColorString}
  2382. */ /**
  2383. * @name Highcharts.GradientColorStopObject#color
  2384. * @type {Highcharts.Color|undefined}
  2385. */
  2386. /**
  2387. * Defines the start position and the end position for a gradient relative
  2388. * to the shape. Start position (x1, y1) and end position (x2, y2) are relative
  2389. * to the shape, where 0 means top/left and 1 is bottom/right.
  2390. *
  2391. * @interface Highcharts.LinearGradientColorObject
  2392. */ /**
  2393. * Start horizontal position of the gradient. Float ranges 0-1.
  2394. * @name Highcharts.LinearGradientColorObject#x1
  2395. * @type {number}
  2396. */ /**
  2397. * End horizontal position of the gradient. Float ranges 0-1.
  2398. * @name Highcharts.LinearGradientColorObject#x2
  2399. * @type {number}
  2400. */ /**
  2401. * Start vertical position of the gradient. Float ranges 0-1.
  2402. * @name Highcharts.LinearGradientColorObject#y1
  2403. * @type {number}
  2404. */ /**
  2405. * End vertical position of the gradient. Float ranges 0-1.
  2406. * @name Highcharts.LinearGradientColorObject#y2
  2407. * @type {number}
  2408. */
  2409. /**
  2410. * Defines the center position and the radius for a gradient.
  2411. *
  2412. * @interface Highcharts.RadialGradientColorObject
  2413. */ /**
  2414. * Center horizontal position relative to the shape. Float ranges 0-1.
  2415. * @name Highcharts.RadialGradientColorObject#cx
  2416. * @type {number}
  2417. */ /**
  2418. * Center vertical position relative to the shape. Float ranges 0-1.
  2419. * @name Highcharts.RadialGradientColorObject#cy
  2420. * @type {number}
  2421. */ /**
  2422. * Radius relative to the shape. Float ranges 0-1.
  2423. * @name Highcharts.RadialGradientColorObject#r
  2424. * @type {number}
  2425. */
  2426. ''; // detach doclets above
  2427. /* *
  2428. *
  2429. * Class
  2430. *
  2431. * */
  2432. /* eslint-disable no-invalid-this, valid-jsdoc */
  2433. /**
  2434. * Handle color operations. Some object methods are chainable.
  2435. *
  2436. * @class
  2437. * @name Highcharts.Color
  2438. *
  2439. * @param {Highcharts.ColorType} input
  2440. * The input color in either rbga or hex format
  2441. */
  2442. var Color = /** @class */ (function () {
  2443. /* *
  2444. *
  2445. * Constructors
  2446. *
  2447. * */
  2448. function Color(input) {
  2449. // Collection of parsers. This can be extended from the outside by pushing
  2450. // parsers to Highcharts.Color.prototype.parsers.
  2451. this.parsers = [{
  2452. // RGBA color
  2453. // eslint-disable-next-line max-len
  2454. 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*\)/,
  2455. parse: function (result) {
  2456. return [
  2457. pInt(result[1]),
  2458. pInt(result[2]),
  2459. pInt(result[3]),
  2460. parseFloat(result[4], 10)
  2461. ];
  2462. }
  2463. }, {
  2464. // RGB color
  2465. regex: /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/,
  2466. parse: function (result) {
  2467. return [pInt(result[1]), pInt(result[2]), pInt(result[3]), 1];
  2468. }
  2469. }];
  2470. this.rgba = [];
  2471. // Backwards compatibility, allow class overwrite
  2472. if (H.Color !== Color) {
  2473. return new H.Color(input);
  2474. }
  2475. // Backwards compatibility, allow instanciation without new (#13053)
  2476. if (!(this instanceof Color)) {
  2477. return new Color(input);
  2478. }
  2479. this.init(input);
  2480. }
  2481. /* *
  2482. *
  2483. * Static Functions
  2484. *
  2485. * */
  2486. /**
  2487. * Creates a color instance out of a color string or object.
  2488. *
  2489. * @function Highcharts.Color.parse
  2490. *
  2491. * @param {Highcharts.ColorType} input
  2492. * The input color in either rbga or hex format.
  2493. *
  2494. * @return {Highcharts.Color}
  2495. * Color instance.
  2496. */
  2497. Color.parse = function (input) {
  2498. return new Color(input);
  2499. };
  2500. /* *
  2501. *
  2502. * Functions
  2503. *
  2504. * */
  2505. /**
  2506. * Parse the input color to rgba array
  2507. *
  2508. * @private
  2509. * @function Highcharts.Color#init
  2510. *
  2511. * @param {Highcharts.ColorType} input
  2512. * The input color in either rbga or hex format
  2513. *
  2514. * @return {void}
  2515. */
  2516. Color.prototype.init = function (input) {
  2517. var result,
  2518. rgba,
  2519. i,
  2520. parser,
  2521. len;
  2522. this.input = input = Color.names[input && input.toLowerCase ?
  2523. input.toLowerCase() :
  2524. ''] || input;
  2525. // Gradients
  2526. if (input && input.stops) {
  2527. this.stops = input.stops.map(function (stop) {
  2528. return new Color(stop[1]);
  2529. });
  2530. // Solid colors
  2531. }
  2532. else {
  2533. // Bitmasking as input[0] is not working for legacy IE.
  2534. if (input &&
  2535. input.charAt &&
  2536. input.charAt() === '#') {
  2537. len = input.length;
  2538. input = parseInt(input.substr(1), 16);
  2539. // Handle long-form, e.g. #AABBCC
  2540. if (len === 7) {
  2541. rgba = [
  2542. (input & 0xFF0000) >> 16,
  2543. (input & 0xFF00) >> 8,
  2544. (input & 0xFF),
  2545. 1
  2546. ];
  2547. // Handle short-form, e.g. #ABC
  2548. // In short form, the value is assumed to be the same
  2549. // for both nibbles for each component. e.g. #ABC = #AABBCC
  2550. }
  2551. else if (len === 4) {
  2552. rgba = [
  2553. (((input & 0xF00) >> 4) |
  2554. (input & 0xF00) >> 8),
  2555. (((input & 0xF0) >> 4) |
  2556. (input & 0xF0)),
  2557. ((input & 0xF) << 4) | (input & 0xF),
  2558. 1
  2559. ];
  2560. }
  2561. }
  2562. // Otherwise, check regex parsers
  2563. if (!rgba) {
  2564. i = this.parsers.length;
  2565. while (i-- && !rgba) {
  2566. parser = this.parsers[i];
  2567. result = parser.regex.exec(input);
  2568. if (result) {
  2569. rgba = parser.parse(result);
  2570. }
  2571. }
  2572. }
  2573. }
  2574. this.rgba = rgba || [];
  2575. };
  2576. /**
  2577. * Return the color or gradient stops in the specified format
  2578. *
  2579. * @function Highcharts.Color#get
  2580. *
  2581. * @param {string} [format]
  2582. * Possible values are 'a', 'rgb', 'rgba' (default).
  2583. *
  2584. * @return {Highcharts.ColorType}
  2585. * This color as a string or gradient stops.
  2586. */
  2587. Color.prototype.get = function (format) {
  2588. var input = this.input,
  2589. rgba = this.rgba,
  2590. ret;
  2591. if (typeof this.stops !== 'undefined') {
  2592. ret = merge(input);
  2593. ret.stops = [].concat(ret.stops);
  2594. this.stops.forEach(function (stop, i) {
  2595. ret.stops[i] = [
  2596. ret.stops[i][0],
  2597. stop.get(format)
  2598. ];
  2599. });
  2600. // it's NaN if gradient colors on a column chart
  2601. }
  2602. else if (rgba && isNumber(rgba[0])) {
  2603. if (format === 'rgb' || (!format && rgba[3] === 1)) {
  2604. ret = 'rgb(' + rgba[0] + ',' + rgba[1] + ',' + rgba[2] + ')';
  2605. }
  2606. else if (format === 'a') {
  2607. ret = rgba[3];
  2608. }
  2609. else {
  2610. ret = 'rgba(' + rgba.join(',') + ')';
  2611. }
  2612. }
  2613. else {
  2614. ret = input;
  2615. }
  2616. return ret;
  2617. };
  2618. /**
  2619. * Brighten the color instance.
  2620. *
  2621. * @function Highcharts.Color#brighten
  2622. *
  2623. * @param {number} alpha
  2624. * The alpha value.
  2625. *
  2626. * @return {Highcharts.Color}
  2627. * This color with modifications.
  2628. */
  2629. Color.prototype.brighten = function (alpha) {
  2630. var i,
  2631. rgba = this.rgba;
  2632. if (this.stops) {
  2633. this.stops.forEach(function (stop) {
  2634. stop.brighten(alpha);
  2635. });
  2636. }
  2637. else if (isNumber(alpha) && alpha !== 0) {
  2638. for (i = 0; i < 3; i++) {
  2639. rgba[i] += pInt(alpha * 255);
  2640. if (rgba[i] < 0) {
  2641. rgba[i] = 0;
  2642. }
  2643. if (rgba[i] > 255) {
  2644. rgba[i] = 255;
  2645. }
  2646. }
  2647. }
  2648. return this;
  2649. };
  2650. /**
  2651. * Set the color's opacity to a given alpha value.
  2652. *
  2653. * @function Highcharts.Color#setOpacity
  2654. *
  2655. * @param {number} alpha
  2656. * Opacity between 0 and 1.
  2657. *
  2658. * @return {Highcharts.Color}
  2659. * Color with modifications.
  2660. */
  2661. Color.prototype.setOpacity = function (alpha) {
  2662. this.rgba[3] = alpha;
  2663. return this;
  2664. };
  2665. /**
  2666. * Return an intermediate color between two colors.
  2667. *
  2668. * @function Highcharts.Color#tweenTo
  2669. *
  2670. * @param {Highcharts.Color} to
  2671. * The color object to tween to.
  2672. *
  2673. * @param {number} pos
  2674. * The intermediate position, where 0 is the from color (current
  2675. * color item), and 1 is the `to` color.
  2676. *
  2677. * @return {Highcharts.ColorString}
  2678. * The intermediate color in rgba notation.
  2679. */
  2680. Color.prototype.tweenTo = function (to, pos) {
  2681. // Check for has alpha, because rgba colors perform worse due to lack of
  2682. // support in WebKit.
  2683. var fromRgba = this.rgba,
  2684. toRgba = to.rgba,
  2685. hasAlpha,
  2686. ret;
  2687. // Unsupported color, return to-color (#3920, #7034)
  2688. if (!toRgba.length || !fromRgba || !fromRgba.length) {
  2689. ret = to.input || 'none';
  2690. // Interpolate
  2691. }
  2692. else {
  2693. hasAlpha = (toRgba[3] !== 1 || fromRgba[3] !== 1);
  2694. ret = (hasAlpha ? 'rgba(' : 'rgb(') +
  2695. Math.round(toRgba[0] + (fromRgba[0] - toRgba[0]) * (1 - pos)) +
  2696. ',' +
  2697. Math.round(toRgba[1] + (fromRgba[1] - toRgba[1]) * (1 - pos)) +
  2698. ',' +
  2699. Math.round(toRgba[2] + (fromRgba[2] - toRgba[2]) * (1 - pos)) +
  2700. (hasAlpha ?
  2701. (',' +
  2702. (toRgba[3] + (fromRgba[3] - toRgba[3]) * (1 - pos))) :
  2703. '') +
  2704. ')';
  2705. }
  2706. return ret;
  2707. };
  2708. /* *
  2709. *
  2710. * Static Properties
  2711. *
  2712. * */
  2713. // Collection of named colors. Can be extended from the outside by adding
  2714. // colors to Highcharts.Color.names.
  2715. Color.names = {
  2716. white: '#ffffff',
  2717. black: '#000000'
  2718. };
  2719. return Color;
  2720. }());
  2721. H.Color = Color;
  2722. /**
  2723. * Creates a color instance out of a color string.
  2724. *
  2725. * @function Highcharts.color
  2726. *
  2727. * @param {Highcharts.ColorType} input
  2728. * The input color in either rbga or hex format
  2729. *
  2730. * @return {Highcharts.Color}
  2731. * Color instance
  2732. */
  2733. H.color = Color.parse;
  2734. /* *
  2735. *
  2736. * Export
  2737. *
  2738. * */
  2739. return Color;
  2740. });
  2741. _registerModule(_modules, 'Core/Animation/Fx.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  2742. /* *
  2743. *
  2744. * (c) 2010-2020 Torstein Honsi
  2745. *
  2746. * License: www.highcharts.com/license
  2747. *
  2748. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  2749. *
  2750. * */
  2751. var win = H.win;
  2752. var isNumber = U.isNumber,
  2753. objectEach = U.objectEach;
  2754. /* eslint-disable no-invalid-this, valid-jsdoc */
  2755. /**
  2756. * An animator object used internally. One instance applies to one property
  2757. * (attribute or style prop) on one element. Animation is always initiated
  2758. * through {@link SVGElement#animate}.
  2759. *
  2760. * @example
  2761. * var rect = renderer.rect(0, 0, 10, 10).add();
  2762. * rect.animate({ width: 100 });
  2763. *
  2764. * @private
  2765. * @class
  2766. * @name Highcharts.Fx
  2767. */
  2768. var Fx = /** @class */ (function () {
  2769. /* *
  2770. *
  2771. * Constructors
  2772. *
  2773. * */
  2774. /**
  2775. *
  2776. * @param {Highcharts.HTMLDOMElement|Highcharts.SVGElement} elem
  2777. * The element to animate.
  2778. *
  2779. * @param {Partial<Highcharts.AnimationOptionsObject>} options
  2780. * Animation options.
  2781. *
  2782. * @param {string} prop
  2783. * The single attribute or CSS property to animate.
  2784. */
  2785. function Fx(elem, options, prop) {
  2786. this.pos = NaN;
  2787. this.options = options;
  2788. this.elem = elem;
  2789. this.prop = prop;
  2790. }
  2791. /* *
  2792. *
  2793. * Functions
  2794. *
  2795. * */
  2796. /**
  2797. * Set the current step of a path definition on SVGElement.
  2798. *
  2799. * @function Highcharts.Fx#dSetter
  2800. *
  2801. * @return {void}
  2802. */
  2803. Fx.prototype.dSetter = function () {
  2804. var paths = this.paths,
  2805. start = paths && paths[0],
  2806. end = paths && paths[1],
  2807. path = [],
  2808. now = this.now || 0;
  2809. // Land on the final path without adjustment points appended in the ends
  2810. if (now === 1 || !start || !end) {
  2811. path = this.toD || [];
  2812. }
  2813. else if (start.length === end.length && now < 1) {
  2814. for (var i = 0; i < end.length; i++) {
  2815. // Tween between the start segment and the end segment. Start
  2816. // with a copy of the end segment and tween the appropriate
  2817. // numerics
  2818. var startSeg = start[i];
  2819. var endSeg = end[i];
  2820. var tweenSeg = [];
  2821. for (var j = 0; j < endSeg.length; j++) {
  2822. var startItem = startSeg[j];
  2823. var endItem = endSeg[j];
  2824. // Tween numbers
  2825. if (typeof startItem === 'number' &&
  2826. typeof endItem === 'number' &&
  2827. // Arc boolean flags
  2828. !(endSeg[0] === 'A' && (j === 4 || j === 5))) {
  2829. tweenSeg[j] = startItem + now * (endItem - startItem);
  2830. // Strings, take directly from the end segment
  2831. }
  2832. else {
  2833. tweenSeg[j] = endItem;
  2834. }
  2835. }
  2836. path.push(tweenSeg);
  2837. }
  2838. // If animation is finished or length not matching, land on right value
  2839. }
  2840. else {
  2841. path = end;
  2842. }
  2843. this.elem.attr('d', path, void 0, true);
  2844. };
  2845. /**
  2846. * Update the element with the current animation step.
  2847. *
  2848. * @function Highcharts.Fx#update
  2849. *
  2850. * @return {void}
  2851. */
  2852. Fx.prototype.update = function () {
  2853. var elem = this.elem,
  2854. prop = this.prop, // if destroyed, it is null
  2855. now = this.now,
  2856. step = this.options.step;
  2857. // Animation setter defined from outside
  2858. if (this[prop + 'Setter']) {
  2859. this[prop + 'Setter']();
  2860. // Other animations on SVGElement
  2861. }
  2862. else if (elem.attr) {
  2863. if (elem.element) {
  2864. elem.attr(prop, now, null, true);
  2865. }
  2866. // HTML styles, raw HTML content like container size
  2867. }
  2868. else {
  2869. elem.style[prop] = now + this.unit;
  2870. }
  2871. if (step) {
  2872. step.call(elem, now, this);
  2873. }
  2874. };
  2875. /**
  2876. * Run an animation.
  2877. *
  2878. * @function Highcharts.Fx#run
  2879. *
  2880. * @param {number} from
  2881. * The current value, value to start from.
  2882. *
  2883. * @param {number} to
  2884. * The end value, value to land on.
  2885. *
  2886. * @param {string} unit
  2887. * The property unit, for example `px`.
  2888. *
  2889. * @return {void}
  2890. */
  2891. Fx.prototype.run = function (from, to, unit) {
  2892. var self = this,
  2893. options = self.options,
  2894. timer = function (gotoEnd) {
  2895. return timer.stopped ? false : self.step(gotoEnd);
  2896. }, requestAnimationFrame = win.requestAnimationFrame ||
  2897. function (step) {
  2898. setTimeout(step, 13);
  2899. }, step = function () {
  2900. for (var i = 0; i < H.timers.length; i++) {
  2901. if (!H.timers[i]()) {
  2902. H.timers.splice(i--, 1);
  2903. }
  2904. }
  2905. if (H.timers.length) {
  2906. requestAnimationFrame(step);
  2907. }
  2908. };
  2909. if (from === to && !this.elem['forceAnimate:' + this.prop]) {
  2910. delete options.curAnim[this.prop];
  2911. if (options.complete && Object.keys(options.curAnim).length === 0) {
  2912. options.complete.call(this.elem);
  2913. }
  2914. }
  2915. else { // #7166
  2916. this.startTime = +new Date();
  2917. this.start = from;
  2918. this.end = to;
  2919. this.unit = unit;
  2920. this.now = this.start;
  2921. this.pos = 0;
  2922. timer.elem = this.elem;
  2923. timer.prop = this.prop;
  2924. if (timer() && H.timers.push(timer) === 1) {
  2925. requestAnimationFrame(step);
  2926. }
  2927. }
  2928. };
  2929. /**
  2930. * Run a single step in the animation.
  2931. *
  2932. * @function Highcharts.Fx#step
  2933. *
  2934. * @param {boolean} [gotoEnd]
  2935. * Whether to go to the endpoint of the animation after abort.
  2936. *
  2937. * @return {boolean}
  2938. * Returns `true` if animation continues.
  2939. */
  2940. Fx.prototype.step = function (gotoEnd) {
  2941. var t = +new Date(),
  2942. ret,
  2943. done,
  2944. options = this.options,
  2945. elem = this.elem,
  2946. complete = options.complete,
  2947. duration = options.duration,
  2948. curAnim = options.curAnim;
  2949. if (elem.attr && !elem.element) { // #2616, element is destroyed
  2950. ret = false;
  2951. }
  2952. else if (gotoEnd || t >= duration + this.startTime) {
  2953. this.now = this.end;
  2954. this.pos = 1;
  2955. this.update();
  2956. curAnim[this.prop] = true;
  2957. done = true;
  2958. objectEach(curAnim, function (val) {
  2959. if (val !== true) {
  2960. done = false;
  2961. }
  2962. });
  2963. if (done && complete) {
  2964. complete.call(elem);
  2965. }
  2966. ret = false;
  2967. }
  2968. else {
  2969. this.pos = options.easing((t - this.startTime) / duration);
  2970. this.now = this.start + ((this.end - this.start) * this.pos);
  2971. this.update();
  2972. ret = true;
  2973. }
  2974. return ret;
  2975. };
  2976. /**
  2977. * Prepare start and end values so that the path can be animated one to one.
  2978. *
  2979. * @function Highcharts.Fx#initPath
  2980. *
  2981. * @param {Highcharts.SVGElement} elem
  2982. * The SVGElement item.
  2983. *
  2984. * @param {Highcharts.SVGPathArray|undefined} fromD
  2985. * Starting path definition.
  2986. *
  2987. * @param {Highcharts.SVGPathArray} toD
  2988. * Ending path definition.
  2989. *
  2990. * @return {Array<Highcharts.SVGPathArray,Highcharts.SVGPathArray>}
  2991. * An array containing start and end paths in array form so that
  2992. * they can be animated in parallel.
  2993. */
  2994. Fx.prototype.initPath = function (elem, fromD, toD) {
  2995. var shift,
  2996. startX = elem.startX,
  2997. endX = elem.endX,
  2998. fullLength,
  2999. i,
  3000. start = fromD && fromD.slice(), // copy
  3001. end = toD.slice(), // copy
  3002. isArea = elem.isArea,
  3003. positionFactor = isArea ? 2 : 1,
  3004. reverse;
  3005. if (!start) {
  3006. return [end, end];
  3007. }
  3008. /**
  3009. * If shifting points, prepend a dummy point to the end path.
  3010. * @private
  3011. * @param {Highcharts.SVGPathArray} arr - array
  3012. * @param {Highcharts.SVGPathArray} other - array
  3013. * @return {void}
  3014. */
  3015. function prepend(arr, other) {
  3016. while (arr.length < fullLength) {
  3017. // Move to, line to or curve to?
  3018. var moveSegment = arr[0],
  3019. otherSegment = other[fullLength - arr.length];
  3020. if (otherSegment && moveSegment[0] === 'M') {
  3021. if (otherSegment[0] === 'C') {
  3022. arr[0] = [
  3023. 'C',
  3024. moveSegment[1],
  3025. moveSegment[2],
  3026. moveSegment[1],
  3027. moveSegment[2],
  3028. moveSegment[1],
  3029. moveSegment[2]
  3030. ];
  3031. }
  3032. else {
  3033. arr[0] = ['L', moveSegment[1], moveSegment[2]];
  3034. }
  3035. }
  3036. // Prepend a copy of the first point
  3037. arr.unshift(moveSegment);
  3038. // For areas, the bottom path goes back again to the left, so we
  3039. // need to append a copy of the last point.
  3040. if (isArea) {
  3041. arr.push(arr[arr.length - 1]);
  3042. }
  3043. }
  3044. }
  3045. /**
  3046. * Copy and append last point until the length matches the end length.
  3047. * @private
  3048. * @param {Highcharts.SVGPathArray} arr - array
  3049. * @param {Highcharts.SVGPathArray} other - array
  3050. * @return {void}
  3051. */
  3052. function append(arr, other) {
  3053. while (arr.length < fullLength) {
  3054. // Pull out the slice that is going to be appended or inserted.
  3055. // In a line graph, the positionFactor is 1, and the last point
  3056. // is sliced out. In an area graph, the positionFactor is 2,
  3057. // causing the middle two points to be sliced out, since an area
  3058. // path starts at left, follows the upper path then turns and
  3059. // follows the bottom back.
  3060. var segmentToAdd = arr[arr.length / positionFactor - 1].slice();
  3061. // Disable the first control point of curve segments
  3062. if (segmentToAdd[0] === 'C') {
  3063. segmentToAdd[1] = segmentToAdd[5];
  3064. segmentToAdd[2] = segmentToAdd[6];
  3065. }
  3066. if (!isArea) {
  3067. arr.push(segmentToAdd);
  3068. }
  3069. else {
  3070. var lowerSegmentToAdd = arr[arr.length / positionFactor].slice();
  3071. arr.splice(arr.length / 2, 0, segmentToAdd, lowerSegmentToAdd);
  3072. }
  3073. }
  3074. }
  3075. // For sideways animation, find out how much we need to shift to get the
  3076. // start path Xs to match the end path Xs.
  3077. if (startX && endX) {
  3078. for (i = 0; i < startX.length; i++) {
  3079. // Moving left, new points coming in on right
  3080. if (startX[i] === endX[0]) {
  3081. shift = i;
  3082. break;
  3083. // Moving right
  3084. }
  3085. else if (startX[0] ===
  3086. endX[endX.length - startX.length + i]) {
  3087. shift = i;
  3088. reverse = true;
  3089. break;
  3090. // Fixed from the right side, "scaling" left
  3091. }
  3092. else if (startX[startX.length - 1] ===
  3093. endX[endX.length - startX.length + i]) {
  3094. shift = startX.length - i;
  3095. break;
  3096. }
  3097. }
  3098. if (typeof shift === 'undefined') {
  3099. start = [];
  3100. }
  3101. }
  3102. if (start.length && isNumber(shift)) {
  3103. // The common target length for the start and end array, where both
  3104. // arrays are padded in opposite ends
  3105. fullLength = end.length + shift * positionFactor;
  3106. if (!reverse) {
  3107. prepend(end, start);
  3108. append(start, end);
  3109. }
  3110. else {
  3111. prepend(start, end);
  3112. append(end, start);
  3113. }
  3114. }
  3115. return [start, end];
  3116. };
  3117. /**
  3118. * Handle animation of the color attributes directly.
  3119. *
  3120. * @function Highcharts.Fx#fillSetter
  3121. *
  3122. * @return {void}
  3123. */
  3124. Fx.prototype.fillSetter = function () {
  3125. Fx.prototype.strokeSetter.apply(this, arguments);
  3126. };
  3127. /**
  3128. * Handle animation of the color attributes directly.
  3129. *
  3130. * @function Highcharts.Fx#strokeSetter
  3131. *
  3132. * @return {void}
  3133. */
  3134. Fx.prototype.strokeSetter = function () {
  3135. this.elem.attr(this.prop, H.color(this.start).tweenTo(H.color(this.end), this.pos), null, true);
  3136. };
  3137. return Fx;
  3138. }());
  3139. H.Fx = Fx;
  3140. return Fx;
  3141. });
  3142. _registerModule(_modules, 'Core/Animation/AnimationUtilities.js', [_modules['Core/Animation/Fx.js'], _modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (Fx, H, U) {
  3143. /* *
  3144. *
  3145. * (c) 2010-2020 Torstein Honsi
  3146. *
  3147. * License: www.highcharts.com/license
  3148. *
  3149. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  3150. *
  3151. * */
  3152. var defined = U.defined,
  3153. getStyle = U.getStyle,
  3154. isArray = U.isArray,
  3155. isNumber = U.isNumber,
  3156. isObject = U.isObject,
  3157. merge = U.merge,
  3158. objectEach = U.objectEach,
  3159. pick = U.pick;
  3160. /**
  3161. * Set the global animation to either a given value, or fall back to the given
  3162. * chart's animation option.
  3163. *
  3164. * @function Highcharts.setAnimation
  3165. *
  3166. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>|undefined} animation
  3167. * The animation object.
  3168. *
  3169. * @param {Highcharts.Chart} chart
  3170. * The chart instance.
  3171. *
  3172. * @todo
  3173. * This function always relates to a chart, and sets a property on the renderer,
  3174. * so it should be moved to the SVGRenderer.
  3175. */
  3176. var setAnimation = H.setAnimation = function setAnimation(animation,
  3177. chart) {
  3178. chart.renderer.globalAnimation = pick(animation,
  3179. chart.options.chart.animation,
  3180. true);
  3181. };
  3182. /**
  3183. * Get the animation in object form, where a disabled animation is always
  3184. * returned as `{ duration: 0 }`.
  3185. *
  3186. * @function Highcharts.animObject
  3187. *
  3188. * @param {boolean|Highcharts.AnimationOptionsObject} [animation=0]
  3189. * An animation setting. Can be an object with duration, complete and
  3190. * easing properties, or a boolean to enable or disable.
  3191. *
  3192. * @return {Highcharts.AnimationOptionsObject}
  3193. * An object with at least a duration property.
  3194. */
  3195. var animObject = H.animObject = function animObject(animation) {
  3196. return isObject(animation) ?
  3197. H.merge({ duration: 500,
  3198. defer: 0 },
  3199. animation) :
  3200. { duration: animation ? 500 : 0,
  3201. defer: 0 };
  3202. };
  3203. /**
  3204. * Get the defer as a number value from series animation options.
  3205. *
  3206. * @function Highcharts.getDeferredAnimation
  3207. *
  3208. * @param {Highcharts.Chart} chart
  3209. * The chart instance.
  3210. *
  3211. * @param {boolean|Highcharts.AnimationOptionsObject} animation
  3212. * An animation setting. Can be an object with duration, complete and
  3213. * easing properties, or a boolean to enable or disable.
  3214. *
  3215. * @param {Highcharts.Series} [series]
  3216. * Series to defer animation.
  3217. *
  3218. * @return {number}
  3219. * The numeric value.
  3220. */
  3221. var getDeferredAnimation = H.getDeferredAnimation = function (chart,
  3222. animation,
  3223. series) {
  3224. var labelAnimation = animObject(animation);
  3225. var s = series ? [series] : chart.series;
  3226. var defer = 0;
  3227. var duration = 0;
  3228. s.forEach(function (series) {
  3229. var seriesAnim = animObject(series.options.animation);
  3230. defer = animation && defined(animation.defer) ?
  3231. labelAnimation.defer :
  3232. Math.max(defer, seriesAnim.duration + seriesAnim.defer);
  3233. duration = Math.min(labelAnimation.duration, seriesAnim.duration);
  3234. });
  3235. // Disable defer for exporting
  3236. if (chart.renderer.forExport) {
  3237. defer = 0;
  3238. }
  3239. var anim = {
  3240. defer: Math.max(0,
  3241. defer - duration),
  3242. duration: Math.min(defer,
  3243. duration)
  3244. };
  3245. return anim;
  3246. };
  3247. /**
  3248. * The global animate method, which uses Fx to create individual animators.
  3249. *
  3250. * @function Highcharts.animate
  3251. *
  3252. * @param {Highcharts.HTMLDOMElement|Highcharts.SVGElement} el
  3253. * The element to animate.
  3254. *
  3255. * @param {Highcharts.CSSObject|Highcharts.SVGAttributes} params
  3256. * An object containing key-value pairs of the properties to animate.
  3257. * Supports numeric as pixel-based CSS properties for HTML objects and
  3258. * attributes for SVGElements.
  3259. *
  3260. * @param {Partial<Highcharts.AnimationOptionsObject>} [opt]
  3261. * Animation options.
  3262. *
  3263. * @return {void}
  3264. */
  3265. var animate = H.animate = function (el,
  3266. params,
  3267. opt) {
  3268. var start,
  3269. unit = '',
  3270. end,
  3271. fx,
  3272. args;
  3273. if (!isObject(opt)) { // Number or undefined/null
  3274. args = arguments;
  3275. opt = {
  3276. duration: args[2],
  3277. easing: args[3],
  3278. complete: args[4]
  3279. };
  3280. }
  3281. if (!isNumber(opt.duration)) {
  3282. opt.duration = 400;
  3283. }
  3284. opt.easing = typeof opt.easing === 'function' ?
  3285. opt.easing :
  3286. (Math[opt.easing] || Math.easeInOutSine);
  3287. opt.curAnim = merge(params);
  3288. objectEach(params, function (val, prop) {
  3289. // Stop current running animation of this property
  3290. stop(el, prop);
  3291. fx = new Fx(el, opt, prop);
  3292. end = null;
  3293. if (prop === 'd' && isArray(params.d)) {
  3294. fx.paths = fx.initPath(el, el.pathArray, params.d);
  3295. fx.toD = params.d;
  3296. start = 0;
  3297. end = 1;
  3298. }
  3299. else if (el.attr) {
  3300. start = el.attr(prop);
  3301. }
  3302. else {
  3303. start = parseFloat(getStyle(el, prop)) || 0;
  3304. if (prop !== 'opacity') {
  3305. unit = 'px';
  3306. }
  3307. }
  3308. if (!end) {
  3309. end = val;
  3310. }
  3311. if (end && end.match && end.match('px')) {
  3312. end = end.replace(/px/g, ''); // #4351
  3313. }
  3314. fx.run(start, end, unit);
  3315. });
  3316. };
  3317. /**
  3318. * Stop running animation.
  3319. *
  3320. * @function Highcharts.stop
  3321. *
  3322. * @param {Highcharts.SVGElement} el
  3323. * The SVGElement to stop animation on.
  3324. *
  3325. * @param {string} [prop]
  3326. * The property to stop animating. If given, the stop method will stop a
  3327. * single property from animating, while others continue.
  3328. *
  3329. * @return {void}
  3330. *
  3331. * @todo
  3332. * A possible extension to this would be to stop a single property, when
  3333. * we want to continue animating others. Then assign the prop to the timer
  3334. * in the Fx.run method, and check for the prop here. This would be an
  3335. * improvement in all cases where we stop the animation from .attr. Instead of
  3336. * stopping everything, we can just stop the actual attributes we're setting.
  3337. */
  3338. var stop = H.stop = function (el,
  3339. prop) {
  3340. var i = H.timers.length;
  3341. // Remove timers related to this element (#4519)
  3342. while (i--) {
  3343. if (H.timers[i].elem === el && (!prop || prop === H.timers[i].prop)) {
  3344. H.timers[i].stopped = true; // #4667
  3345. }
  3346. }
  3347. };
  3348. var animationExports = {
  3349. animate: animate,
  3350. animObject: animObject,
  3351. getDeferredAnimation: getDeferredAnimation,
  3352. setAnimation: setAnimation,
  3353. stop: stop
  3354. };
  3355. return animationExports;
  3356. });
  3357. _registerModule(_modules, 'Core/Renderer/SVG/SVGElement.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Color/Color.js'], _modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (A, Color, H, U) {
  3358. /* *
  3359. *
  3360. * (c) 2010-2020 Torstein Honsi
  3361. *
  3362. * License: www.highcharts.com/license
  3363. *
  3364. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  3365. *
  3366. * */
  3367. var animate = A.animate,
  3368. animObject = A.animObject,
  3369. stop = A.stop;
  3370. var deg2rad = H.deg2rad,
  3371. doc = H.doc,
  3372. hasTouch = H.hasTouch,
  3373. isFirefox = H.isFirefox,
  3374. noop = H.noop,
  3375. svg = H.svg,
  3376. SVG_NS = H.SVG_NS,
  3377. win = H.win;
  3378. var attr = U.attr,
  3379. createElement = U.createElement,
  3380. css = U.css,
  3381. defined = U.defined,
  3382. erase = U.erase,
  3383. extend = U.extend,
  3384. fireEvent = U.fireEvent,
  3385. isArray = U.isArray,
  3386. isFunction = U.isFunction,
  3387. isNumber = U.isNumber,
  3388. isString = U.isString,
  3389. merge = U.merge,
  3390. objectEach = U.objectEach,
  3391. pick = U.pick,
  3392. pInt = U.pInt,
  3393. syncTimeout = U.syncTimeout,
  3394. uniqueKey = U.uniqueKey;
  3395. /**
  3396. * The horizontal alignment of an element.
  3397. *
  3398. * @typedef {"center"|"left"|"right"} Highcharts.AlignValue
  3399. */
  3400. /**
  3401. * Options to align the element relative to the chart or another box.
  3402. *
  3403. * @interface Highcharts.AlignObject
  3404. */ /**
  3405. * Horizontal alignment. Can be one of `left`, `center` and `right`.
  3406. *
  3407. * @name Highcharts.AlignObject#align
  3408. * @type {Highcharts.AlignValue|undefined}
  3409. *
  3410. * @default left
  3411. */ /**
  3412. * Vertical alignment. Can be one of `top`, `middle` and `bottom`.
  3413. *
  3414. * @name Highcharts.AlignObject#verticalAlign
  3415. * @type {Highcharts.VerticalAlignValue|undefined}
  3416. *
  3417. * @default top
  3418. */ /**
  3419. * Horizontal pixel offset from alignment.
  3420. *
  3421. * @name Highcharts.AlignObject#x
  3422. * @type {number|undefined}
  3423. *
  3424. * @default 0
  3425. */ /**
  3426. * Vertical pixel offset from alignment.
  3427. *
  3428. * @name Highcharts.AlignObject#y
  3429. * @type {number|undefined}
  3430. *
  3431. * @default 0
  3432. */ /**
  3433. * Use the `transform` attribute with translateX and translateY custom
  3434. * attributes to align this elements rather than `x` and `y` attributes.
  3435. *
  3436. * @name Highcharts.AlignObject#alignByTranslate
  3437. * @type {boolean|undefined}
  3438. *
  3439. * @default false
  3440. */
  3441. /**
  3442. * Bounding box of an element.
  3443. *
  3444. * @interface Highcharts.BBoxObject
  3445. * @extends Highcharts.PositionObject
  3446. */ /**
  3447. * Height of the bounding box.
  3448. *
  3449. * @name Highcharts.BBoxObject#height
  3450. * @type {number}
  3451. */ /**
  3452. * Width of the bounding box.
  3453. *
  3454. * @name Highcharts.BBoxObject#width
  3455. * @type {number}
  3456. */ /**
  3457. * Horizontal position of the bounding box.
  3458. *
  3459. * @name Highcharts.BBoxObject#x
  3460. * @type {number}
  3461. */ /**
  3462. * Vertical position of the bounding box.
  3463. *
  3464. * @name Highcharts.BBoxObject#y
  3465. * @type {number}
  3466. */
  3467. /**
  3468. * An object of key-value pairs for SVG attributes. Attributes in Highcharts
  3469. * elements for the most parts correspond to SVG, but some are specific to
  3470. * Highcharts, like `zIndex`, `rotation`, `rotationOriginX`,
  3471. * `rotationOriginY`, `translateX`, `translateY`, `scaleX` and `scaleY`. SVG
  3472. * attributes containing a hyphen are _not_ camel-cased, they should be
  3473. * quoted to preserve the hyphen.
  3474. *
  3475. * @example
  3476. * {
  3477. * 'stroke': '#ff0000', // basic
  3478. * 'stroke-width': 2, // hyphenated
  3479. * 'rotation': 45 // custom
  3480. * 'd': ['M', 10, 10, 'L', 30, 30, 'z'] // path definition, note format
  3481. * }
  3482. *
  3483. * @interface Highcharts.SVGAttributes
  3484. */ /**
  3485. * @name Highcharts.SVGAttributes#[key:string]
  3486. * @type {*}
  3487. */ /**
  3488. * @name Highcharts.SVGAttributes#d
  3489. * @type {string|Highcharts.SVGPathArray|undefined}
  3490. */ /**
  3491. * @name Highcharts.SVGAttributes#fill
  3492. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject|undefined}
  3493. */ /**
  3494. * @name Highcharts.SVGAttributes#inverted
  3495. * @type {boolean|undefined}
  3496. */ /**
  3497. * @name Highcharts.SVGAttributes#matrix
  3498. * @type {Array<number>|undefined}
  3499. */ /**
  3500. * @name Highcharts.SVGAttributes#rotation
  3501. * @type {number|undefined}
  3502. */ /**
  3503. * @name Highcharts.SVGAttributes#rotationOriginX
  3504. * @type {number|undefined}
  3505. */ /**
  3506. * @name Highcharts.SVGAttributes#rotationOriginY
  3507. * @type {number|undefined}
  3508. */ /**
  3509. * @name Highcharts.SVGAttributes#scaleX
  3510. * @type {number|undefined}
  3511. */ /**
  3512. * @name Highcharts.SVGAttributes#scaleY
  3513. * @type {number|undefined}
  3514. */ /**
  3515. * @name Highcharts.SVGAttributes#stroke
  3516. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject|undefined}
  3517. */ /**
  3518. * @name Highcharts.SVGAttributes#style
  3519. * @type {string|Highcharts.CSSObject|undefined}
  3520. */ /**
  3521. * @name Highcharts.SVGAttributes#translateX
  3522. * @type {number|undefined}
  3523. */ /**
  3524. * @name Highcharts.SVGAttributes#translateY
  3525. * @type {number|undefined}
  3526. */ /**
  3527. * @name Highcharts.SVGAttributes#zIndex
  3528. * @type {number|undefined}
  3529. */
  3530. /**
  3531. * An SVG DOM element. The type is a reference to the regular SVGElement in the
  3532. * global scope.
  3533. *
  3534. * @typedef {globals.GlobalSVGElement} Highcharts.SVGDOMElement
  3535. *
  3536. * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGElement
  3537. */
  3538. /**
  3539. * The vertical alignment of an element.
  3540. *
  3541. * @typedef {"bottom"|"middle"|"top"} Highcharts.VerticalAlignValue
  3542. */
  3543. ''; // detach doclets above
  3544. /* eslint-disable no-invalid-this, valid-jsdoc */
  3545. /**
  3546. * The SVGElement prototype is a JavaScript wrapper for SVG elements used in the
  3547. * rendering layer of Highcharts. Combined with the
  3548. * {@link Highcharts.SVGRenderer}
  3549. * object, these prototypes allow freeform annotation in the charts or even in
  3550. * HTML pages without instanciating a chart. The SVGElement can also wrap HTML
  3551. * labels, when `text` or `label` elements are created with the `useHTML`
  3552. * parameter.
  3553. *
  3554. * The SVGElement instances are created through factory functions on the
  3555. * {@link Highcharts.SVGRenderer}
  3556. * object, like
  3557. * {@link Highcharts.SVGRenderer#rect|rect},
  3558. * {@link Highcharts.SVGRenderer#path|path},
  3559. * {@link Highcharts.SVGRenderer#text|text},
  3560. * {@link Highcharts.SVGRenderer#label|label},
  3561. * {@link Highcharts.SVGRenderer#g|g}
  3562. * and more.
  3563. *
  3564. * @class
  3565. * @name Highcharts.SVGElement
  3566. */
  3567. var SVGElement = /** @class */ (function () {
  3568. function SVGElement() {
  3569. /* *
  3570. *
  3571. * Properties
  3572. *
  3573. * */
  3574. this.element = void 0;
  3575. this.height = void 0;
  3576. this.opacity = 1; // Default base for animation
  3577. this.renderer = void 0;
  3578. this.SVG_NS = SVG_NS;
  3579. // Custom attributes used for symbols, these should be filtered out when
  3580. // setting SVGElement attributes (#9375).
  3581. this.symbolCustomAttribs = [
  3582. 'x',
  3583. 'y',
  3584. 'width',
  3585. 'height',
  3586. 'r',
  3587. 'start',
  3588. 'end',
  3589. 'innerR',
  3590. 'anchorX',
  3591. 'anchorY',
  3592. 'rounded'
  3593. ];
  3594. this.width = void 0;
  3595. }
  3596. /* *
  3597. *
  3598. * Functions
  3599. *
  3600. * */
  3601. /**
  3602. * Get the current value of an attribute or pseudo attribute,
  3603. * used mainly for animation. Called internally from
  3604. * the {@link Highcharts.SVGRenderer#attr} function.
  3605. *
  3606. * @private
  3607. * @function Highcharts.SVGElement#_defaultGetter
  3608. *
  3609. * @param {string} key
  3610. * Property key.
  3611. *
  3612. * @return {number|string}
  3613. * Property value.
  3614. */
  3615. SVGElement.prototype._defaultGetter = function (key) {
  3616. var ret = pick(this[key + 'Value'], // align getter
  3617. this[key],
  3618. this.element ? this.element.getAttribute(key) : null, 0);
  3619. if (/^[\-0-9\.]+$/.test(ret)) { // is numerical
  3620. ret = parseFloat(ret);
  3621. }
  3622. return ret;
  3623. };
  3624. /**
  3625. * @private
  3626. * @function Highcharts.SVGElement#_defaultSetter
  3627. *
  3628. * @param {string} value
  3629. *
  3630. * @param {string} key
  3631. *
  3632. * @param {Highcharts.SVGDOMElement} element
  3633. *
  3634. * @return {void}
  3635. */
  3636. SVGElement.prototype._defaultSetter = function (value, key, element) {
  3637. element.setAttribute(key, value);
  3638. };
  3639. /**
  3640. * Add the element to the DOM. All elements must be added this way.
  3641. *
  3642. * @sample highcharts/members/renderer-g
  3643. * Elements added to a group
  3644. *
  3645. * @function Highcharts.SVGElement#add
  3646. *
  3647. * @param {Highcharts.SVGElement} [parent]
  3648. * The parent item to add it to. If undefined, the element is added
  3649. * to the {@link Highcharts.SVGRenderer.box}.
  3650. *
  3651. * @return {Highcharts.SVGElement}
  3652. * Returns the SVGElement for chaining.
  3653. */
  3654. SVGElement.prototype.add = function (parent) {
  3655. var renderer = this.renderer,
  3656. element = this.element,
  3657. inserted;
  3658. if (parent) {
  3659. this.parentGroup = parent;
  3660. }
  3661. // Mark as inverted
  3662. this.parentInverted = parent && parent.inverted;
  3663. // Build formatted text
  3664. if (typeof this.textStr !== 'undefined' &&
  3665. this.element.nodeName === 'text' // Not for SVGLabel instances
  3666. ) {
  3667. renderer.buildText(this);
  3668. }
  3669. // Mark as added
  3670. this.added = true;
  3671. // If we're adding to renderer root, or other elements in the group
  3672. // have a z index, we need to handle it
  3673. if (!parent || parent.handleZ || this.zIndex) {
  3674. inserted = this.zIndexSetter();
  3675. }
  3676. // If zIndex is not handled, append at the end
  3677. if (!inserted) {
  3678. (parent ?
  3679. parent.element :
  3680. renderer.box).appendChild(element);
  3681. }
  3682. // fire an event for internal hooks
  3683. if (this.onAdd) {
  3684. this.onAdd();
  3685. }
  3686. return this;
  3687. };
  3688. /**
  3689. * Add a class name to an element.
  3690. *
  3691. * @function Highcharts.SVGElement#addClass
  3692. *
  3693. * @param {string} className
  3694. * The new class name to add.
  3695. *
  3696. * @param {boolean} [replace=false]
  3697. * When true, the existing class name(s) will be overwritten with the new
  3698. * one. When false, the new one is added.
  3699. *
  3700. * @return {Highcharts.SVGElement}
  3701. * Return the SVG element for chainability.
  3702. */
  3703. SVGElement.prototype.addClass = function (className, replace) {
  3704. var currentClassName = replace ? '' : (this.attr('class') || '');
  3705. // Trim the string and remove duplicates
  3706. className = (className || '')
  3707. .split(/ /g)
  3708. .reduce(function (newClassName, name) {
  3709. if (currentClassName.indexOf(name) === -1) {
  3710. newClassName.push(name);
  3711. }
  3712. return newClassName;
  3713. }, (currentClassName ?
  3714. [currentClassName] :
  3715. []))
  3716. .join(' ');
  3717. if (className !== currentClassName) {
  3718. this.attr('class', className);
  3719. }
  3720. return this;
  3721. };
  3722. /**
  3723. * This method is executed in the end of `attr()`, after setting all
  3724. * attributes in the hash. In can be used to efficiently consolidate
  3725. * multiple attributes in one SVG property -- e.g., translate, rotate and
  3726. * scale are merged in one "transform" attribute in the SVG node.
  3727. *
  3728. * @private
  3729. * @function Highcharts.SVGElement#afterSetters
  3730. */
  3731. SVGElement.prototype.afterSetters = function () {
  3732. // Update transform. Do this outside the loop to prevent redundant
  3733. // updating for batch setting of attributes.
  3734. if (this.doTransform) {
  3735. this.updateTransform();
  3736. this.doTransform = false;
  3737. }
  3738. };
  3739. /**
  3740. * Align the element relative to the chart or another box.
  3741. *
  3742. * @function Highcharts.SVGElement#align
  3743. *
  3744. * @param {Highcharts.AlignObject} [alignOptions]
  3745. * The alignment options. The function can be called without this
  3746. * parameter in order to re-align an element after the box has been
  3747. * updated.
  3748. *
  3749. * @param {boolean} [alignByTranslate]
  3750. * Align element by translation.
  3751. *
  3752. * @param {string|Highcharts.BBoxObject} [box]
  3753. * The box to align to, needs a width and height. When the box is a
  3754. * string, it refers to an object in the Renderer. For example, when
  3755. * box is `spacingBox`, it refers to `Renderer.spacingBox` which
  3756. * holds `width`, `height`, `x` and `y` properties.
  3757. *
  3758. * @return {Highcharts.SVGElement} Returns the SVGElement for chaining.
  3759. */
  3760. SVGElement.prototype.align = function (alignOptions, alignByTranslate, box) {
  3761. var align,
  3762. vAlign,
  3763. x,
  3764. y,
  3765. attribs = {},
  3766. alignTo,
  3767. renderer = this.renderer,
  3768. alignedObjects = renderer.alignedObjects,
  3769. alignFactor,
  3770. vAlignFactor;
  3771. // First call on instanciate
  3772. if (alignOptions) {
  3773. this.alignOptions = alignOptions;
  3774. this.alignByTranslate = alignByTranslate;
  3775. if (!box || isString(box)) {
  3776. this.alignTo = alignTo = box || 'renderer';
  3777. // prevent duplicates, like legendGroup after resize
  3778. erase(alignedObjects, this);
  3779. alignedObjects.push(this);
  3780. box = void 0; // reassign it below
  3781. }
  3782. // When called on resize, no arguments are supplied
  3783. }
  3784. else {
  3785. alignOptions = this.alignOptions;
  3786. alignByTranslate = this.alignByTranslate;
  3787. alignTo = this.alignTo;
  3788. }
  3789. box = pick(box, renderer[alignTo], renderer);
  3790. // Assign variables
  3791. align = alignOptions.align;
  3792. vAlign = alignOptions.verticalAlign;
  3793. // default: left align
  3794. x = (box.x || 0) + (alignOptions.x || 0);
  3795. // default: top align
  3796. y = (box.y || 0) + (alignOptions.y || 0);
  3797. // Align
  3798. if (align === 'right') {
  3799. alignFactor = 1;
  3800. }
  3801. else if (align === 'center') {
  3802. alignFactor = 2;
  3803. }
  3804. if (alignFactor) {
  3805. x += (box.width - (alignOptions.width || 0)) /
  3806. alignFactor;
  3807. }
  3808. attribs[alignByTranslate ? 'translateX' : 'x'] = Math.round(x);
  3809. // Vertical align
  3810. if (vAlign === 'bottom') {
  3811. vAlignFactor = 1;
  3812. }
  3813. else if (vAlign === 'middle') {
  3814. vAlignFactor = 2;
  3815. }
  3816. if (vAlignFactor) {
  3817. y += (box.height - (alignOptions.height || 0)) /
  3818. vAlignFactor;
  3819. }
  3820. attribs[alignByTranslate ? 'translateY' : 'y'] = Math.round(y);
  3821. // Animate only if already placed
  3822. this[this.placed ? 'animate' : 'attr'](attribs);
  3823. this.placed = true;
  3824. this.alignAttr = attribs;
  3825. return this;
  3826. };
  3827. /**
  3828. * @private
  3829. * @function Highcharts.SVGElement#alignSetter
  3830. * @param {"left"|"center"|"right"} value
  3831. */
  3832. SVGElement.prototype.alignSetter = function (value) {
  3833. var convert = {
  3834. left: 'start',
  3835. center: 'middle',
  3836. right: 'end'
  3837. };
  3838. if (convert[value]) {
  3839. this.alignValue = value;
  3840. this.element.setAttribute('text-anchor', convert[value]);
  3841. }
  3842. };
  3843. /**
  3844. * Animate to given attributes or CSS properties.
  3845. *
  3846. * @sample highcharts/members/element-on/
  3847. * Setting some attributes by animation
  3848. *
  3849. * @function Highcharts.SVGElement#animate
  3850. *
  3851. * @param {Highcharts.SVGAttributes} params
  3852. * SVG attributes or CSS to animate.
  3853. *
  3854. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [options]
  3855. * Animation options.
  3856. *
  3857. * @param {Function} [complete]
  3858. * Function to perform at the end of animation.
  3859. *
  3860. * @return {Highcharts.SVGElement}
  3861. * Returns the SVGElement for chaining.
  3862. */
  3863. SVGElement.prototype.animate = function (params, options, complete) {
  3864. var _this = this;
  3865. var animOptions = animObject(pick(options,
  3866. this.renderer.globalAnimation,
  3867. true)),
  3868. deferTime = animOptions.defer;
  3869. // When the page is hidden save resources in the background by not
  3870. // running animation at all (#9749).
  3871. if (pick(doc.hidden, doc.msHidden, doc.webkitHidden, false)) {
  3872. animOptions.duration = 0;
  3873. }
  3874. if (animOptions.duration !== 0) {
  3875. // allows using a callback with the global animation without
  3876. // overwriting it
  3877. if (complete) {
  3878. animOptions.complete = complete;
  3879. }
  3880. // If defer option is defined delay the animation #12901
  3881. syncTimeout(function () {
  3882. if (_this.element) {
  3883. animate(_this, params, animOptions);
  3884. }
  3885. }, deferTime);
  3886. }
  3887. else {
  3888. this.attr(params, void 0, complete);
  3889. // Call the end step synchronously
  3890. objectEach(params, function (val, prop) {
  3891. if (animOptions.step) {
  3892. animOptions.step.call(this, val, { prop: prop, pos: 1 });
  3893. }
  3894. }, this);
  3895. }
  3896. return this;
  3897. };
  3898. /**
  3899. * Apply a text outline through a custom CSS property, by copying the text
  3900. * element and apply stroke to the copy. Used internally. Contrast checks at
  3901. * [example](https://jsfiddle.net/highcharts/43soe9m1/2/).
  3902. *
  3903. * @example
  3904. * // Specific color
  3905. * text.css({
  3906. * textOutline: '1px black'
  3907. * });
  3908. * // Automatic contrast
  3909. * text.css({
  3910. * color: '#000000', // black text
  3911. * textOutline: '1px contrast' // => white outline
  3912. * });
  3913. *
  3914. * @private
  3915. * @function Highcharts.SVGElement#applyTextOutline
  3916. *
  3917. * @param {string} textOutline
  3918. * A custom CSS `text-outline` setting, defined by `width color`.
  3919. */
  3920. SVGElement.prototype.applyTextOutline = function (textOutline) {
  3921. var elem = this.element,
  3922. tspans,
  3923. hasContrast = textOutline.indexOf('contrast') !== -1,
  3924. styles = {},
  3925. color,
  3926. strokeWidth,
  3927. firstRealChild;
  3928. // When the text shadow is set to contrast, use dark stroke for light
  3929. // text and vice versa.
  3930. if (hasContrast) {
  3931. styles.textOutline = textOutline = textOutline.replace(/contrast/g, this.renderer.getContrast(elem.style.fill));
  3932. }
  3933. // Extract the stroke width and color
  3934. textOutline = textOutline.split(' ');
  3935. color = textOutline[textOutline.length - 1];
  3936. strokeWidth = textOutline[0];
  3937. if (strokeWidth && strokeWidth !== 'none' && H.svg) {
  3938. this.fakeTS = true; // Fake text shadow
  3939. tspans = [].slice.call(elem.getElementsByTagName('tspan'));
  3940. // In order to get the right y position of the clone,
  3941. // copy over the y setter
  3942. this.ySetter = this.xSetter;
  3943. // Since the stroke is applied on center of the actual outline, we
  3944. // need to double it to get the correct stroke-width outside the
  3945. // glyphs.
  3946. strokeWidth = strokeWidth.replace(/(^[\d\.]+)(.*?)$/g, function (match, digit, unit) {
  3947. return (2 * digit) + unit;
  3948. });
  3949. // Remove shadows from previous runs.
  3950. this.removeTextOutline(tspans);
  3951. // Check if the element contains RTL characters.
  3952. // Comparing against Hebrew and Arabic characters,
  3953. // excluding Arabic digits. Source:
  3954. // https://www.unicode.org/Public/UNIDATA/extracted/DerivedBidiClass.txt
  3955. var isRTL_1 = elem.textContent ?
  3956. /^[\u0591-\u065F\u066A-\u07FF\uFB1D-\uFDFD\uFE70-\uFEFC]/
  3957. .test(elem.textContent) : false;
  3958. // For each of the tspans, create a stroked copy behind it.
  3959. firstRealChild = elem.firstChild;
  3960. tspans.forEach(function (tspan, y) {
  3961. var clone;
  3962. // Let the first line start at the correct X position
  3963. if (y === 0) {
  3964. tspan.setAttribute('x', elem.getAttribute('x'));
  3965. y = elem.getAttribute('y');
  3966. tspan.setAttribute('y', y || 0);
  3967. if (y === null) {
  3968. elem.setAttribute('y', 0);
  3969. }
  3970. }
  3971. // Create the clone and apply outline properties.
  3972. // For RTL elements apply outline properties for orginal element
  3973. // to prevent outline from overlapping the text.
  3974. // For RTL in Firefox keep the orginal order (#10162).
  3975. clone = tspan.cloneNode(true);
  3976. attr((isRTL_1 && !isFirefox) ? tspan : clone, {
  3977. 'class': 'highcharts-text-outline',
  3978. fill: color,
  3979. stroke: color,
  3980. 'stroke-width': strokeWidth,
  3981. 'stroke-linejoin': 'round'
  3982. });
  3983. elem.insertBefore(clone, firstRealChild);
  3984. });
  3985. // Create a whitespace between tspan and clone,
  3986. // to fix the display of Arabic characters in Firefox.
  3987. if (isRTL_1 && isFirefox && tspans[0]) {
  3988. var whitespace = tspans[0].cloneNode(true);
  3989. whitespace.textContent = ' ';
  3990. elem.insertBefore(whitespace, firstRealChild);
  3991. }
  3992. }
  3993. };
  3994. /**
  3995. * @function Highcharts.SVGElement#attr
  3996. * @param {string} key
  3997. * @return {number|string}
  3998. */ /**
  3999. * Apply native and custom attributes to the SVG elements.
  4000. *
  4001. * In order to set the rotation center for rotation, set x and y to 0 and
  4002. * use `translateX` and `translateY` attributes to position the element
  4003. * instead.
  4004. *
  4005. * Attributes frequently used in Highcharts are `fill`, `stroke`,
  4006. * `stroke-width`.
  4007. *
  4008. * @sample highcharts/members/renderer-rect/
  4009. * Setting some attributes
  4010. *
  4011. * @example
  4012. * // Set multiple attributes
  4013. * element.attr({
  4014. * stroke: 'red',
  4015. * fill: 'blue',
  4016. * x: 10,
  4017. * y: 10
  4018. * });
  4019. *
  4020. * // Set a single attribute
  4021. * element.attr('stroke', 'red');
  4022. *
  4023. * // Get an attribute
  4024. * element.attr('stroke'); // => 'red'
  4025. *
  4026. * @function Highcharts.SVGElement#attr
  4027. *
  4028. * @param {string|Highcharts.SVGAttributes} [hash]
  4029. * The native and custom SVG attributes.
  4030. *
  4031. * @param {number|string|Highcharts.SVGPathArray} [val]
  4032. * If the type of the first argument is `string`, the second can be a
  4033. * value, which will serve as a single attribute setter. If the first
  4034. * argument is a string and the second is undefined, the function
  4035. * serves as a getter and the current value of the property is
  4036. * returned.
  4037. *
  4038. * @param {Function} [complete]
  4039. * A callback function to execute after setting the attributes. This
  4040. * makes the function compliant and interchangeable with the
  4041. * {@link SVGElement#animate} function.
  4042. *
  4043. * @param {boolean} [continueAnimation=true]
  4044. * Used internally when `.attr` is called as part of an animation
  4045. * step. Otherwise, calling `.attr` for an attribute will stop
  4046. * animation for that attribute.
  4047. *
  4048. * @return {Highcharts.SVGElement}
  4049. * If used as a setter, it returns the current
  4050. * {@link Highcharts.SVGElement} so the calls can be chained. If
  4051. * used as a getter, the current value of the attribute is returned.
  4052. */
  4053. SVGElement.prototype.attr = function (hash, val, complete, continueAnimation) {
  4054. var key,
  4055. element = this.element,
  4056. hasSetSymbolSize,
  4057. ret = this,
  4058. skipAttr,
  4059. setter,
  4060. symbolCustomAttribs = this.symbolCustomAttribs;
  4061. // single key-value pair
  4062. if (typeof hash === 'string' && typeof val !== 'undefined') {
  4063. key = hash;
  4064. hash = {};
  4065. hash[key] = val;
  4066. }
  4067. // used as a getter: first argument is a string, second is undefined
  4068. if (typeof hash === 'string') {
  4069. ret = (this[hash + 'Getter'] ||
  4070. this._defaultGetter).call(this, hash, element);
  4071. // setter
  4072. }
  4073. else {
  4074. objectEach(hash, function eachAttribute(val, key) {
  4075. skipAttr = false;
  4076. // Unless .attr is from the animator update, stop current
  4077. // running animation of this property
  4078. if (!continueAnimation) {
  4079. stop(this, key);
  4080. }
  4081. // Special handling of symbol attributes
  4082. if (this.symbolName &&
  4083. symbolCustomAttribs.indexOf(key) !== -1) {
  4084. if (!hasSetSymbolSize) {
  4085. this.symbolAttr(hash);
  4086. hasSetSymbolSize = true;
  4087. }
  4088. skipAttr = true;
  4089. }
  4090. if (this.rotation && (key === 'x' || key === 'y')) {
  4091. this.doTransform = true;
  4092. }
  4093. if (!skipAttr) {
  4094. setter = (this[key + 'Setter'] ||
  4095. this._defaultSetter);
  4096. setter.call(this, val, key, element);
  4097. // Let the shadow follow the main element
  4098. if (!this.styledMode &&
  4099. this.shadows &&
  4100. /^(width|height|visibility|x|y|d|transform|cx|cy|r)$/.test(key)) {
  4101. this.updateShadows(key, val, setter);
  4102. }
  4103. }
  4104. }, this);
  4105. this.afterSetters();
  4106. }
  4107. // In accordance with animate, run a complete callback
  4108. if (complete) {
  4109. complete.call(this);
  4110. }
  4111. return ret;
  4112. };
  4113. /**
  4114. * Apply a clipping rectangle to this element.
  4115. *
  4116. * @function Highcharts.SVGElement#clip
  4117. *
  4118. * @param {Highcharts.ClipRectElement} [clipRect]
  4119. * The clipping rectangle. If skipped, the current clip is removed.
  4120. *
  4121. * @return {Highcharts.SVGElement}
  4122. * Returns the SVG element to allow chaining.
  4123. */
  4124. SVGElement.prototype.clip = function (clipRect) {
  4125. return this.attr('clip-path', clipRect ?
  4126. 'url(' + this.renderer.url + '#' + clipRect.id + ')' :
  4127. 'none');
  4128. };
  4129. /**
  4130. * Calculate the coordinates needed for drawing a rectangle crisply and
  4131. * return the calculated attributes.
  4132. *
  4133. * @function Highcharts.SVGElement#crisp
  4134. *
  4135. * @param {Highcharts.RectangleObject} rect
  4136. * Rectangle to crisp.
  4137. *
  4138. * @param {number} [strokeWidth]
  4139. * The stroke width to consider when computing crisp positioning. It can
  4140. * also be set directly on the rect parameter.
  4141. *
  4142. * @return {Highcharts.RectangleObject}
  4143. * The modified rectangle arguments.
  4144. */
  4145. SVGElement.prototype.crisp = function (rect, strokeWidth) {
  4146. var wrapper = this,
  4147. normalizer;
  4148. strokeWidth = strokeWidth || rect.strokeWidth || 0;
  4149. // Math.round because strokeWidth can sometimes have roundoff errors
  4150. normalizer = Math.round(strokeWidth) % 2 / 2;
  4151. // normalize for crisp edges
  4152. rect.x = Math.floor(rect.x || wrapper.x || 0) + normalizer;
  4153. rect.y = Math.floor(rect.y || wrapper.y || 0) + normalizer;
  4154. rect.width = Math.floor((rect.width || wrapper.width || 0) - 2 * normalizer);
  4155. rect.height = Math.floor((rect.height || wrapper.height || 0) - 2 * normalizer);
  4156. if (defined(rect.strokeWidth)) {
  4157. rect.strokeWidth = strokeWidth;
  4158. }
  4159. return rect;
  4160. };
  4161. /**
  4162. * Build and apply an SVG gradient out of a common JavaScript configuration
  4163. * object. This function is called from the attribute setters. An event
  4164. * hook is added for supporting other complex color types.
  4165. *
  4166. * @private
  4167. * @function Highcharts.SVGElement#complexColor
  4168. *
  4169. * @param {Highcharts.GradientColorObject|Highcharts.PatternObject} colorOptions
  4170. * The gradient or pattern options structure.
  4171. *
  4172. * @param {string} prop
  4173. * The property to apply, can either be `fill` or `stroke`.
  4174. *
  4175. * @param {Highcharts.SVGDOMElement} elem
  4176. * SVG element to apply the gradient on.
  4177. */
  4178. SVGElement.prototype.complexColor = function (colorOptions, prop, elem) {
  4179. var renderer = this.renderer,
  4180. colorObject,
  4181. gradName,
  4182. gradAttr,
  4183. radAttr,
  4184. gradients,
  4185. stops,
  4186. stopColor,
  4187. stopOpacity,
  4188. radialReference,
  4189. id,
  4190. key = [],
  4191. value;
  4192. fireEvent(this.renderer, 'complexColor', {
  4193. args: arguments
  4194. }, function () {
  4195. // Apply linear or radial gradients
  4196. if (colorOptions.radialGradient) {
  4197. gradName = 'radialGradient';
  4198. }
  4199. else if (colorOptions.linearGradient) {
  4200. gradName = 'linearGradient';
  4201. }
  4202. if (gradName) {
  4203. gradAttr = colorOptions[gradName];
  4204. gradients = renderer.gradients;
  4205. stops = colorOptions.stops;
  4206. radialReference = elem.radialReference;
  4207. // Keep < 2.2 kompatibility
  4208. if (isArray(gradAttr)) {
  4209. colorOptions[gradName] = gradAttr = {
  4210. x1: gradAttr[0],
  4211. y1: gradAttr[1],
  4212. x2: gradAttr[2],
  4213. y2: gradAttr[3],
  4214. gradientUnits: 'userSpaceOnUse'
  4215. };
  4216. }
  4217. // Correct the radial gradient for the radial reference system
  4218. if (gradName === 'radialGradient' &&
  4219. radialReference &&
  4220. !defined(gradAttr.gradientUnits)) {
  4221. // Save the radial attributes for updating
  4222. radAttr = gradAttr;
  4223. gradAttr = merge(gradAttr, renderer.getRadialAttr(radialReference, radAttr), { gradientUnits: 'userSpaceOnUse' });
  4224. }
  4225. // Build the unique key to detect whether we need to create a
  4226. // new element (#1282)
  4227. objectEach(gradAttr, function (val, n) {
  4228. if (n !== 'id') {
  4229. key.push(n, val);
  4230. }
  4231. });
  4232. objectEach(stops, function (val) {
  4233. key.push(val);
  4234. });
  4235. key = key.join(',');
  4236. // Check if a gradient object with the same config object is
  4237. // created within this renderer
  4238. if (gradients[key]) {
  4239. id = gradients[key].attr('id');
  4240. }
  4241. else {
  4242. // Set the id and create the element
  4243. gradAttr.id = id = uniqueKey();
  4244. var gradientObject_1 = gradients[key] =
  4245. renderer.createElement(gradName)
  4246. .attr(gradAttr)
  4247. .add(renderer.defs);
  4248. gradientObject_1.radAttr = radAttr;
  4249. // The gradient needs to keep a list of stops to be able to
  4250. // destroy them
  4251. gradientObject_1.stops = [];
  4252. stops.forEach(function (stop) {
  4253. var stopObject;
  4254. if (stop[1].indexOf('rgba') === 0) {
  4255. colorObject = Color.parse(stop[1]);
  4256. stopColor = colorObject.get('rgb');
  4257. stopOpacity = colorObject.get('a');
  4258. }
  4259. else {
  4260. stopColor = stop[1];
  4261. stopOpacity = 1;
  4262. }
  4263. stopObject = renderer.createElement('stop').attr({
  4264. offset: stop[0],
  4265. 'stop-color': stopColor,
  4266. 'stop-opacity': stopOpacity
  4267. }).add(gradientObject_1);
  4268. // Add the stop element to the gradient
  4269. gradientObject_1.stops.push(stopObject);
  4270. });
  4271. }
  4272. // Set the reference to the gradient object
  4273. value = 'url(' + renderer.url + '#' + id + ')';
  4274. elem.setAttribute(prop, value);
  4275. elem.gradient = key;
  4276. // Allow the color to be concatenated into tooltips formatters
  4277. // etc. (#2995)
  4278. colorOptions.toString = function () {
  4279. return value;
  4280. };
  4281. }
  4282. });
  4283. };
  4284. /**
  4285. * Set styles for the element. In addition to CSS styles supported by
  4286. * native SVG and HTML elements, there are also some custom made for
  4287. * Highcharts, like `width`, `ellipsis` and `textOverflow` for SVG text
  4288. * elements.
  4289. *
  4290. * @sample highcharts/members/renderer-text-on-chart/
  4291. * Styled text
  4292. *
  4293. * @function Highcharts.SVGElement#css
  4294. *
  4295. * @param {Highcharts.CSSObject} styles
  4296. * The new CSS styles.
  4297. *
  4298. * @return {Highcharts.SVGElement}
  4299. * Return the SVG element for chaining.
  4300. */
  4301. SVGElement.prototype.css = function (styles) {
  4302. var oldStyles = this.styles, newStyles = {}, elem = this.element, textWidth, serializedCss = '', hyphenate, hasNew = !oldStyles,
  4303. // These CSS properties are interpreted internally by the SVG
  4304. // renderer, but are not supported by SVG and should not be added to
  4305. // the DOM. In styled mode, no CSS should find its way to the DOM
  4306. // whatsoever (#6173, #6474).
  4307. svgPseudoProps = ['textOutline', 'textOverflow', 'width'];
  4308. // convert legacy
  4309. if (styles && styles.color) {
  4310. styles.fill = styles.color;
  4311. }
  4312. // Filter out existing styles to increase performance (#2640)
  4313. if (oldStyles) {
  4314. objectEach(styles, function (style, n) {
  4315. if (oldStyles && oldStyles[n] !== style) {
  4316. newStyles[n] = style;
  4317. hasNew = true;
  4318. }
  4319. });
  4320. }
  4321. if (hasNew) {
  4322. // Merge the new styles with the old ones
  4323. if (oldStyles) {
  4324. styles = extend(oldStyles, newStyles);
  4325. }
  4326. // Get the text width from style
  4327. if (styles) {
  4328. // Previously set, unset it (#8234)
  4329. if (styles.width === null || styles.width === 'auto') {
  4330. delete this.textWidth;
  4331. // Apply new
  4332. }
  4333. else if (elem.nodeName.toLowerCase() === 'text' &&
  4334. styles.width) {
  4335. textWidth = this.textWidth = pInt(styles.width);
  4336. }
  4337. }
  4338. // store object
  4339. this.styles = styles;
  4340. if (textWidth && (!svg && this.renderer.forExport)) {
  4341. delete styles.width;
  4342. }
  4343. // Serialize and set style attribute
  4344. if (elem.namespaceURI === this.SVG_NS) { // #7633
  4345. hyphenate = function (a, b) {
  4346. return '-' + b.toLowerCase();
  4347. };
  4348. objectEach(styles, function (style, n) {
  4349. if (svgPseudoProps.indexOf(n) === -1) {
  4350. serializedCss +=
  4351. n.replace(/([A-Z])/g, hyphenate) + ':' +
  4352. style + ';';
  4353. }
  4354. });
  4355. if (serializedCss) {
  4356. attr(elem, 'style', serializedCss); // #1881
  4357. }
  4358. }
  4359. else {
  4360. css(elem, styles);
  4361. }
  4362. if (this.added) {
  4363. // Rebuild text after added. Cache mechanisms in the buildText
  4364. // will prevent building if there are no significant changes.
  4365. if (this.element.nodeName === 'text') {
  4366. this.renderer.buildText(this);
  4367. }
  4368. // Apply text outline after added
  4369. if (styles && styles.textOutline) {
  4370. this.applyTextOutline(styles.textOutline);
  4371. }
  4372. }
  4373. }
  4374. return this;
  4375. };
  4376. /**
  4377. * @private
  4378. * @function Highcharts.SVGElement#dashstyleSetter
  4379. * @param {string} value
  4380. */
  4381. SVGElement.prototype.dashstyleSetter = function (value) {
  4382. var i,
  4383. strokeWidth = this['stroke-width'];
  4384. // If "inherit", like maps in IE, assume 1 (#4981). With HC5 and the new
  4385. // strokeWidth function, we should be able to use that instead.
  4386. if (strokeWidth === 'inherit') {
  4387. strokeWidth = 1;
  4388. }
  4389. value = value && value.toLowerCase();
  4390. if (value) {
  4391. var v = value
  4392. .replace('shortdashdotdot', '3,1,1,1,1,1,')
  4393. .replace('shortdashdot', '3,1,1,1')
  4394. .replace('shortdot', '1,1,')
  4395. .replace('shortdash', '3,1,')
  4396. .replace('longdash', '8,3,')
  4397. .replace(/dot/g, '1,3,')
  4398. .replace('dash', '4,3,')
  4399. .replace(/,$/, '')
  4400. .split(','); // ending comma
  4401. i = v.length;
  4402. while (i--) {
  4403. v[i] = '' + (pInt(v[i]) * pick(strokeWidth, NaN));
  4404. }
  4405. value = v.join(',').replace(/NaN/g, 'none'); // #3226
  4406. this.element.setAttribute('stroke-dasharray', value);
  4407. }
  4408. };
  4409. /**
  4410. * Destroy the element and element wrapper and clear up the DOM and event
  4411. * hooks.
  4412. *
  4413. * @function Highcharts.SVGElement#destroy
  4414. */
  4415. SVGElement.prototype.destroy = function () {
  4416. var wrapper = this,
  4417. element = wrapper.element || {},
  4418. renderer = wrapper.renderer,
  4419. parentToClean = (renderer.isSVG &&
  4420. element.nodeName === 'SPAN' &&
  4421. wrapper.parentGroup ||
  4422. void 0),
  4423. grandParent,
  4424. ownerSVGElement = element.ownerSVGElement,
  4425. i;
  4426. // remove events
  4427. element.onclick = element.onmouseout = element.onmouseover =
  4428. element.onmousemove = element.point = null;
  4429. stop(wrapper); // stop running animations
  4430. if (wrapper.clipPath && ownerSVGElement) {
  4431. var clipPath_1 = wrapper.clipPath;
  4432. // Look for existing references to this clipPath and remove them
  4433. // before destroying the element (#6196).
  4434. // The upper case version is for Edge
  4435. [].forEach.call(ownerSVGElement.querySelectorAll('[clip-path],[CLIP-PATH]'), function (el) {
  4436. var clipPathAttr = el.getAttribute('clip-path');
  4437. if (clipPathAttr.indexOf(clipPath_1.element.id) > -1) {
  4438. el.removeAttribute('clip-path');
  4439. }
  4440. });
  4441. wrapper.clipPath = clipPath_1.destroy();
  4442. }
  4443. // Destroy stops in case this is a gradient object @todo old code?
  4444. if (wrapper.stops) {
  4445. for (i = 0; i < wrapper.stops.length; i++) {
  4446. wrapper.stops[i].destroy();
  4447. }
  4448. wrapper.stops.length = 0;
  4449. wrapper.stops = void 0;
  4450. }
  4451. // remove element
  4452. wrapper.safeRemoveChild(element);
  4453. if (!renderer.styledMode) {
  4454. wrapper.destroyShadows();
  4455. }
  4456. // In case of useHTML, clean up empty containers emulating SVG groups
  4457. // (#1960, #2393, #2697).
  4458. while (parentToClean &&
  4459. parentToClean.div &&
  4460. parentToClean.div.childNodes.length === 0) {
  4461. grandParent = parentToClean.parentGroup;
  4462. wrapper.safeRemoveChild(parentToClean.div);
  4463. delete parentToClean.div;
  4464. parentToClean = grandParent;
  4465. }
  4466. // remove from alignObjects
  4467. if (wrapper.alignTo) {
  4468. erase(renderer.alignedObjects, wrapper);
  4469. }
  4470. objectEach(wrapper, function (val, key) {
  4471. // Destroy child elements of a group
  4472. if (wrapper[key] &&
  4473. wrapper[key].parentGroup === wrapper &&
  4474. wrapper[key].destroy) {
  4475. wrapper[key].destroy();
  4476. }
  4477. // Delete all properties
  4478. delete wrapper[key];
  4479. });
  4480. return;
  4481. };
  4482. /**
  4483. * Destroy shadows on the element.
  4484. *
  4485. * @private
  4486. * @function Highcharts.SVGElement#destroyShadows
  4487. *
  4488. * @return {void}
  4489. */
  4490. SVGElement.prototype.destroyShadows = function () {
  4491. (this.shadows || []).forEach(function (shadow) {
  4492. this.safeRemoveChild(shadow);
  4493. }, this);
  4494. this.shadows = void 0;
  4495. };
  4496. /**
  4497. * @private
  4498. */
  4499. SVGElement.prototype.destroyTextPath = function (elem, path) {
  4500. var textElement = elem.getElementsByTagName('text')[0];
  4501. var tspans;
  4502. if (textElement) {
  4503. // Remove textPath attributes
  4504. textElement.removeAttribute('dx');
  4505. textElement.removeAttribute('dy');
  4506. // Remove ID's:
  4507. path.element.setAttribute('id', '');
  4508. // Check if textElement includes textPath,
  4509. if (this.textPathWrapper &&
  4510. textElement.getElementsByTagName('textPath').length) {
  4511. // Move nodes to <text>
  4512. tspans = this.textPathWrapper.element.childNodes;
  4513. // Now move all <tspan>'s to the <textPath> node
  4514. while (tspans.length) {
  4515. textElement.appendChild(tspans[0]);
  4516. }
  4517. // Remove <textPath> from the DOM
  4518. textElement.removeChild(this.textPathWrapper.element);
  4519. }
  4520. }
  4521. else if (elem.getAttribute('dx') || elem.getAttribute('dy')) {
  4522. // Remove textPath attributes from elem
  4523. // to get correct text-outline position
  4524. elem.removeAttribute('dx');
  4525. elem.removeAttribute('dy');
  4526. }
  4527. if (this.textPathWrapper) {
  4528. // Set textPathWrapper to undefined and destroy it
  4529. this.textPathWrapper = this.textPathWrapper.destroy();
  4530. }
  4531. };
  4532. /**
  4533. * @private
  4534. * @function Highcharts.SVGElement#dSettter
  4535. * @param {number|string|Highcharts.SVGPathArray} value
  4536. * @param {string} key
  4537. * @param {Highcharts.SVGDOMElement} element
  4538. */
  4539. SVGElement.prototype.dSetter = function (value, key, element) {
  4540. if (isArray(value)) {
  4541. // Backwards compatibility, convert one-dimensional array into an
  4542. // array of segments
  4543. if (typeof value[0] === 'string') {
  4544. value = this.renderer.pathToSegments(value);
  4545. }
  4546. this.pathArray = value;
  4547. value = value.reduce(function (acc, seg, i) {
  4548. if (!seg || !seg.join) {
  4549. return (seg || '').toString();
  4550. }
  4551. return (i ? acc + ' ' : '') + seg.join(' ');
  4552. }, '');
  4553. }
  4554. if (/(NaN| {2}|^$)/.test(value)) {
  4555. value = 'M 0 0';
  4556. }
  4557. // Check for cache before resetting. Resetting causes disturbance in the
  4558. // DOM, causing flickering in some cases in Edge/IE (#6747). Also
  4559. // possible performance gain.
  4560. if (this[key] !== value) {
  4561. element.setAttribute(key, value);
  4562. this[key] = value;
  4563. }
  4564. };
  4565. /**
  4566. * Fade out an element by animating its opacity down to 0, and hide it on
  4567. * complete. Used internally for the tooltip.
  4568. *
  4569. * @function Highcharts.SVGElement#fadeOut
  4570. *
  4571. * @param {number} [duration=150]
  4572. * The fade duration in milliseconds.
  4573. */
  4574. SVGElement.prototype.fadeOut = function (duration) {
  4575. var elemWrapper = this;
  4576. elemWrapper.animate({
  4577. opacity: 0
  4578. }, {
  4579. duration: pick(duration, 150),
  4580. complete: function () {
  4581. // #3088, assuming we're only using this for tooltips
  4582. elemWrapper.attr({ y: -9999 }).hide();
  4583. }
  4584. });
  4585. };
  4586. /**
  4587. * @private
  4588. * @function Highcharts.SVGElement#fillSetter
  4589. * @param {Highcharts.ColorType} value
  4590. * @param {string} key
  4591. * @param {Highcharts.SVGDOMElement} element
  4592. */
  4593. SVGElement.prototype.fillSetter = function (value, key, element) {
  4594. if (typeof value === 'string') {
  4595. element.setAttribute(key, value);
  4596. }
  4597. else if (value) {
  4598. this.complexColor(value, key, element);
  4599. }
  4600. };
  4601. /**
  4602. * Get the bounding box (width, height, x and y) for the element. Generally
  4603. * used to get rendered text size. Since this is called a lot in charts,
  4604. * the results are cached based on text properties, in order to save DOM
  4605. * traffic. The returned bounding box includes the rotation, so for example
  4606. * a single text line of rotation 90 will report a greater height, and a
  4607. * width corresponding to the line-height.
  4608. *
  4609. * @sample highcharts/members/renderer-on-chart/
  4610. * Draw a rectangle based on a text's bounding box
  4611. *
  4612. * @function Highcharts.SVGElement#getBBox
  4613. *
  4614. * @param {boolean} [reload]
  4615. * Skip the cache and get the updated DOM bouding box.
  4616. *
  4617. * @param {number} [rot]
  4618. * Override the element's rotation. This is internally used on axis
  4619. * labels with a value of 0 to find out what the bounding box would
  4620. * be have been if it were not rotated.
  4621. *
  4622. * @return {Highcharts.BBoxObject}
  4623. * The bounding box with `x`, `y`, `width` and `height` properties.
  4624. */
  4625. SVGElement.prototype.getBBox = function (reload, rot) {
  4626. var wrapper = this,
  4627. bBox, // = wrapper.bBox,
  4628. renderer = wrapper.renderer,
  4629. width,
  4630. height,
  4631. element = wrapper.element,
  4632. styles = wrapper.styles,
  4633. fontSize,
  4634. textStr = wrapper.textStr,
  4635. toggleTextShadowShim,
  4636. cache = renderer.cache,
  4637. cacheKeys = renderer.cacheKeys,
  4638. isSVG = element.namespaceURI === wrapper.SVG_NS,
  4639. cacheKey;
  4640. var rotation = pick(rot,
  4641. wrapper.rotation, 0);
  4642. fontSize = renderer.styledMode ? (element &&
  4643. SVGElement.prototype.getStyle.call(element, 'font-size')) : (styles && styles.fontSize);
  4644. // Avoid undefined and null (#7316)
  4645. if (defined(textStr)) {
  4646. cacheKey = textStr.toString();
  4647. // Since numbers are monospaced, and numerical labels appear a lot
  4648. // in a chart, we assume that a label of n characters has the same
  4649. // bounding box as others of the same length. Unless there is inner
  4650. // HTML in the label. In that case, leave the numbers as is (#5899).
  4651. if (cacheKey.indexOf('<') === -1) {
  4652. cacheKey = cacheKey.replace(/[0-9]/g, '0');
  4653. }
  4654. // Properties that affect bounding box
  4655. cacheKey += [
  4656. '',
  4657. rotation,
  4658. fontSize,
  4659. wrapper.textWidth,
  4660. styles && styles.textOverflow,
  4661. styles && styles.fontWeight // #12163
  4662. ].join(',');
  4663. }
  4664. if (cacheKey && !reload) {
  4665. bBox = cache[cacheKey];
  4666. }
  4667. // No cache found
  4668. if (!bBox) {
  4669. // SVG elements
  4670. if (isSVG || renderer.forExport) {
  4671. try { // Fails in Firefox if the container has display: none.
  4672. // When the text shadow shim is used, we need to hide the
  4673. // fake shadows to get the correct bounding box (#3872)
  4674. toggleTextShadowShim = this.fakeTS && function (display) {
  4675. [].forEach.call(element.querySelectorAll('.highcharts-text-outline'), function (tspan) {
  4676. tspan.style.display = display;
  4677. });
  4678. };
  4679. // Workaround for #3842, Firefox reporting wrong bounding
  4680. // box for shadows
  4681. if (isFunction(toggleTextShadowShim)) {
  4682. toggleTextShadowShim('none');
  4683. }
  4684. bBox = element.getBBox ?
  4685. // SVG: use extend because IE9 is not allowed to change
  4686. // width and height in case of rotation (below)
  4687. extend({}, element.getBBox()) : {
  4688. // Legacy IE in export mode
  4689. width: element.offsetWidth,
  4690. height: element.offsetHeight
  4691. };
  4692. // #3842
  4693. if (isFunction(toggleTextShadowShim)) {
  4694. toggleTextShadowShim('');
  4695. }
  4696. }
  4697. catch (e) {
  4698. '';
  4699. }
  4700. // If the bBox is not set, the try-catch block above failed. The
  4701. // other condition is for Opera that returns a width of
  4702. // -Infinity on hidden elements.
  4703. if (!bBox || bBox.width < 0) {
  4704. bBox = { width: 0, height: 0 };
  4705. }
  4706. // VML Renderer or useHTML within SVG
  4707. }
  4708. else {
  4709. bBox = wrapper.htmlGetBBox();
  4710. }
  4711. // True SVG elements as well as HTML elements in modern browsers
  4712. // using the .useHTML option need to compensated for rotation
  4713. if (renderer.isSVG) {
  4714. width = bBox.width;
  4715. height = bBox.height;
  4716. // Workaround for wrong bounding box in IE, Edge and Chrome on
  4717. // Windows. With Highcharts' default font, IE and Edge report
  4718. // a box height of 16.899 and Chrome rounds it to 17. If this
  4719. // stands uncorrected, it results in more padding added below
  4720. // the text than above when adding a label border or background.
  4721. // Also vertical positioning is affected.
  4722. // https://jsfiddle.net/highcharts/em37nvuj/
  4723. // (#1101, #1505, #1669, #2568, #6213).
  4724. if (isSVG) {
  4725. bBox.height = height = ({
  4726. '11px,17': 14,
  4727. '13px,20': 16
  4728. }[styles &&
  4729. styles.fontSize + ',' + Math.round(height)] ||
  4730. height);
  4731. }
  4732. // Adjust for rotated text
  4733. if (rotation) {
  4734. var rad = rotation * deg2rad;
  4735. bBox.width = Math.abs(height * Math.sin(rad)) +
  4736. Math.abs(width * Math.cos(rad));
  4737. bBox.height = Math.abs(height * Math.cos(rad)) +
  4738. Math.abs(width * Math.sin(rad));
  4739. }
  4740. }
  4741. // Cache it. When loading a chart in a hidden iframe in Firefox and
  4742. // IE/Edge, the bounding box height is 0, so don't cache it (#5620).
  4743. if (cacheKey && bBox.height > 0) {
  4744. // Rotate (#4681)
  4745. while (cacheKeys.length > 250) {
  4746. delete cache[cacheKeys.shift()];
  4747. }
  4748. if (!cache[cacheKey]) {
  4749. cacheKeys.push(cacheKey);
  4750. }
  4751. cache[cacheKey] = bBox;
  4752. }
  4753. }
  4754. return bBox;
  4755. };
  4756. /**
  4757. * Get the computed style. Only in styled mode.
  4758. *
  4759. * @example
  4760. * chart.series[0].points[0].graphic.getStyle('stroke-width'); // => '1px'
  4761. *
  4762. * @function Highcharts.SVGElement#getStyle
  4763. *
  4764. * @param {string} prop
  4765. * The property name to check for.
  4766. *
  4767. * @return {string}
  4768. * The current computed value.
  4769. */
  4770. SVGElement.prototype.getStyle = function (prop) {
  4771. return win
  4772. .getComputedStyle(this.element || this, '')
  4773. .getPropertyValue(prop);
  4774. };
  4775. /**
  4776. * Check if an element has the given class name.
  4777. *
  4778. * @function Highcharts.SVGElement#hasClass
  4779. *
  4780. * @param {string} className
  4781. * The class name to check for.
  4782. *
  4783. * @return {boolean}
  4784. * Whether the class name is found.
  4785. */
  4786. SVGElement.prototype.hasClass = function (className) {
  4787. return ('' + this.attr('class'))
  4788. .split(' ')
  4789. .indexOf(className) !== -1;
  4790. };
  4791. /**
  4792. * Hide the element, similar to setting the `visibility` attribute to
  4793. * `hidden`.
  4794. *
  4795. * @function Highcharts.SVGElement#hide
  4796. *
  4797. * @param {boolean} [hideByTranslation=false]
  4798. * The flag to determine if element should be hidden by moving out
  4799. * of the viewport. Used for example for dataLabels.
  4800. *
  4801. * @return {Highcharts.SVGElement}
  4802. * Returns the SVGElement for chaining.
  4803. */
  4804. SVGElement.prototype.hide = function (hideByTranslation) {
  4805. if (hideByTranslation) {
  4806. this.attr({ y: -9999 });
  4807. }
  4808. else {
  4809. this.attr({ visibility: 'hidden' });
  4810. }
  4811. return this;
  4812. };
  4813. /**
  4814. * @private
  4815. */
  4816. SVGElement.prototype.htmlGetBBox = function () {
  4817. return { height: 0, width: 0, x: 0, y: 0 };
  4818. };
  4819. /**
  4820. * Initialize the SVG element. This function only exists to make the
  4821. * initialization process overridable. It should not be called directly.
  4822. *
  4823. * @function Highcharts.SVGElement#init
  4824. *
  4825. * @param {Highcharts.SVGRenderer} renderer
  4826. * The SVGRenderer instance to initialize to.
  4827. *
  4828. * @param {string} nodeName
  4829. * The SVG node name.
  4830. */
  4831. SVGElement.prototype.init = function (renderer, nodeName) {
  4832. /**
  4833. * The primary DOM node. Each `SVGElement` instance wraps a main DOM
  4834. * node, but may also represent more nodes.
  4835. *
  4836. * @name Highcharts.SVGElement#element
  4837. * @type {Highcharts.SVGDOMElement|Highcharts.HTMLDOMElement}
  4838. */
  4839. this.element = nodeName === 'span' ?
  4840. createElement(nodeName) :
  4841. doc.createElementNS(this.SVG_NS, nodeName);
  4842. /**
  4843. * The renderer that the SVGElement belongs to.
  4844. *
  4845. * @name Highcharts.SVGElement#renderer
  4846. * @type {Highcharts.SVGRenderer}
  4847. */
  4848. this.renderer = renderer;
  4849. fireEvent(this, 'afterInit');
  4850. };
  4851. /**
  4852. * Invert a group, rotate and flip. This is used internally on inverted
  4853. * charts, where the points and graphs are drawn as if not inverted, then
  4854. * the series group elements are inverted.
  4855. *
  4856. * @function Highcharts.SVGElement#invert
  4857. *
  4858. * @param {boolean} inverted
  4859. * Whether to invert or not. An inverted shape can be un-inverted by
  4860. * setting it to false.
  4861. *
  4862. * @return {Highcharts.SVGElement}
  4863. * Return the SVGElement for chaining.
  4864. */
  4865. SVGElement.prototype.invert = function (inverted) {
  4866. var wrapper = this;
  4867. wrapper.inverted = inverted;
  4868. wrapper.updateTransform();
  4869. return wrapper;
  4870. };
  4871. /**
  4872. * Add an event listener. This is a simple setter that replaces all other
  4873. * events of the same type, opposed to the {@link Highcharts#addEvent}
  4874. * function.
  4875. *
  4876. * @sample highcharts/members/element-on/
  4877. * A clickable rectangle
  4878. *
  4879. * @function Highcharts.SVGElement#on
  4880. *
  4881. * @param {string} eventType
  4882. * The event type. If the type is `click`, Highcharts will internally
  4883. * translate it to a `touchstart` event on touch devices, to prevent the
  4884. * browser from waiting for a click event from firing.
  4885. *
  4886. * @param {Function} handler
  4887. * The handler callback.
  4888. *
  4889. * @return {Highcharts.SVGElement}
  4890. * The SVGElement for chaining.
  4891. */
  4892. SVGElement.prototype.on = function (eventType, handler) {
  4893. var svgElement = this,
  4894. element = svgElement.element,
  4895. touchStartPos,
  4896. touchEventFired;
  4897. // touch
  4898. if (hasTouch && eventType === 'click') {
  4899. element.ontouchstart = function (e) {
  4900. // save touch position for later calculation
  4901. touchStartPos = {
  4902. clientX: e.touches[0].clientX,
  4903. clientY: e.touches[0].clientY
  4904. };
  4905. };
  4906. // Instead of ontouchstart, event handlers should be called
  4907. // on touchend - similar to how current mouseup events are called
  4908. element.ontouchend = function (e) {
  4909. // hasMoved is a boolean variable containing logic if page
  4910. // was scrolled, so if touch position changed more than
  4911. // ~4px (value borrowed from general touch handler)
  4912. var hasMoved = touchStartPos.clientX ? Math.sqrt(Math.pow(touchStartPos.clientX - e.changedTouches[0].clientX, 2) +
  4913. Math.pow(touchStartPos.clientY - e.changedTouches[0].clientY, 2)) >= 4 : false;
  4914. if (!hasMoved) { // only call handlers if page was not scrolled
  4915. handler.call(element, e);
  4916. }
  4917. touchEventFired = true;
  4918. if (e.cancelable !== false) {
  4919. // prevent other events from being fired. #9682
  4920. e.preventDefault();
  4921. }
  4922. };
  4923. element.onclick = function (e) {
  4924. // Do not call onclick handler if touch event was fired already.
  4925. if (!touchEventFired) {
  4926. handler.call(element, e);
  4927. }
  4928. };
  4929. }
  4930. else {
  4931. // simplest possible event model for internal use
  4932. element['on' + eventType] = handler;
  4933. }
  4934. return this;
  4935. };
  4936. /**
  4937. * @private
  4938. * @function Highcharts.SVGElement#opacitySetter
  4939. * @param {string} value
  4940. * @param {string} key
  4941. * @param {Highcharts.SVGDOMElement} element
  4942. */
  4943. SVGElement.prototype.opacitySetter = function (value, key, element) {
  4944. // Round off to avoid float errors, like tests where opacity lands on
  4945. // 9.86957e-06 instead of 0
  4946. var opacity = Number(Number(value).toFixed(3));
  4947. this.opacity = opacity;
  4948. element.setAttribute(key, opacity);
  4949. };
  4950. /**
  4951. * Remove a class name from the element.
  4952. *
  4953. * @function Highcharts.SVGElement#removeClass
  4954. *
  4955. * @param {string|RegExp} className
  4956. * The class name to remove.
  4957. *
  4958. * @return {Highcharts.SVGElement} Returns the SVG element for chainability.
  4959. */
  4960. SVGElement.prototype.removeClass = function (className) {
  4961. return this.attr('class', ('' + this.attr('class'))
  4962. .replace(isString(className) ?
  4963. new RegExp("(^| )" + className + "( |$)") : // #12064, #13590
  4964. className, ' ')
  4965. .replace(/ +/g, ' ')
  4966. .trim());
  4967. };
  4968. /**
  4969. * @private
  4970. * @param {Array<Highcharts.SVGDOMElement>} tspans
  4971. * Text spans.
  4972. */
  4973. SVGElement.prototype.removeTextOutline = function (tspans) {
  4974. // Iterate from the end to
  4975. // support removing items inside the cycle (#6472).
  4976. var i = tspans.length,
  4977. tspan;
  4978. while (i--) {
  4979. tspan = tspans[i];
  4980. if (tspan.getAttribute('class') === 'highcharts-text-outline') {
  4981. // Remove then erase
  4982. erase(tspans, this.element.removeChild(tspan));
  4983. }
  4984. }
  4985. };
  4986. /**
  4987. * Removes an element from the DOM.
  4988. *
  4989. * @private
  4990. * @function Highcharts.SVGElement#safeRemoveChild
  4991. *
  4992. * @param {Highcharts.SVGDOMElement|Highcharts.HTMLDOMElement} element
  4993. * The DOM node to remove.
  4994. */
  4995. SVGElement.prototype.safeRemoveChild = function (element) {
  4996. var parentNode = element.parentNode;
  4997. if (parentNode) {
  4998. parentNode.removeChild(element);
  4999. }
  5000. };
  5001. /**
  5002. * Set the coordinates needed to draw a consistent radial gradient across
  5003. * a shape regardless of positioning inside the chart. Used on pie slices
  5004. * to make all the slices have the same radial reference point.
  5005. *
  5006. * @function Highcharts.SVGElement#setRadialReference
  5007. *
  5008. * @param {Array<number>} coordinates
  5009. * The center reference. The format is `[centerX, centerY, diameter]` in
  5010. * pixels.
  5011. *
  5012. * @return {Highcharts.SVGElement}
  5013. * Returns the SVGElement for chaining.
  5014. */
  5015. SVGElement.prototype.setRadialReference = function (coordinates) {
  5016. var existingGradient = (this.element.gradient &&
  5017. this.renderer.gradients[this.element.gradient]);
  5018. this.element.radialReference = coordinates;
  5019. // On redrawing objects with an existing gradient, the gradient needs
  5020. // to be repositioned (#3801)
  5021. if (existingGradient && existingGradient.radAttr) {
  5022. existingGradient.animate(this.renderer.getRadialAttr(coordinates, existingGradient.radAttr));
  5023. }
  5024. return this;
  5025. };
  5026. /**
  5027. * @private
  5028. * @function Highcharts.SVGElement#setTextPath
  5029. * @param {Highcharts.SVGElement} path
  5030. * Path to follow.
  5031. * @param {Highcharts.DataLabelsTextPathOptionsObject} textPathOptions
  5032. * Options.
  5033. * @return {Highcharts.SVGElement}
  5034. * Returns the SVGElement for chaining.
  5035. */
  5036. SVGElement.prototype.setTextPath = function (path, textPathOptions) {
  5037. var elem = this.element,
  5038. attribsMap = {
  5039. textAnchor: 'text-anchor'
  5040. },
  5041. attrs,
  5042. adder = false,
  5043. textPathElement,
  5044. textPathId,
  5045. textPathWrapper = this.textPathWrapper,
  5046. tspans,
  5047. firstTime = !textPathWrapper;
  5048. // Defaults
  5049. textPathOptions = merge(true, {
  5050. enabled: true,
  5051. attributes: {
  5052. dy: -5,
  5053. startOffset: '50%',
  5054. textAnchor: 'middle'
  5055. }
  5056. }, textPathOptions);
  5057. attrs = textPathOptions.attributes;
  5058. if (path && textPathOptions && textPathOptions.enabled) {
  5059. // In case of fixed width for a text, string is rebuilt
  5060. // (e.g. ellipsis is applied), so we need to rebuild textPath too
  5061. if (textPathWrapper &&
  5062. textPathWrapper.element.parentNode === null) {
  5063. // When buildText functionality was triggered again
  5064. // and deletes textPathWrapper parentNode
  5065. firstTime = true;
  5066. textPathWrapper = textPathWrapper.destroy();
  5067. }
  5068. else if (textPathWrapper) {
  5069. // Case after drillup when spans were added into
  5070. // the DOM outside the textPathWrapper parentGroup
  5071. this.removeTextOutline.call(textPathWrapper.parentGroup, [].slice.call(elem.getElementsByTagName('tspan')));
  5072. }
  5073. // label() has padding, text() doesn't
  5074. if (this.options && this.options.padding) {
  5075. attrs.dx = -this.options.padding;
  5076. }
  5077. if (!textPathWrapper) {
  5078. // Create <textPath>, defer the DOM adder
  5079. this.textPathWrapper = textPathWrapper =
  5080. this.renderer.createElement('textPath');
  5081. adder = true;
  5082. }
  5083. textPathElement = textPathWrapper.element;
  5084. // Set ID for the path
  5085. textPathId = path.element.getAttribute('id');
  5086. if (!textPathId) {
  5087. path.element.setAttribute('id', textPathId = uniqueKey());
  5088. }
  5089. // Change DOM structure, by placing <textPath> tag in <text>
  5090. if (firstTime) {
  5091. tspans = elem.getElementsByTagName('tspan');
  5092. // Now move all <tspan>'s to the <textPath> node
  5093. while (tspans.length) {
  5094. // Remove "y" from tspans, as Firefox translates them
  5095. tspans[0].setAttribute('y', 0);
  5096. // Remove "x" from tspans
  5097. if (isNumber(attrs.dx)) {
  5098. tspans[0].setAttribute('x', -attrs.dx);
  5099. }
  5100. textPathElement.appendChild(tspans[0]);
  5101. }
  5102. }
  5103. // Add <textPath> to the DOM
  5104. if (adder &&
  5105. textPathWrapper) {
  5106. textPathWrapper.add({
  5107. // label() is placed in a group, text() is standalone
  5108. element: this.text ? this.text.element : elem
  5109. });
  5110. }
  5111. // Set basic options:
  5112. // Use `setAttributeNS` because Safari needs this..
  5113. textPathElement.setAttributeNS('http://www.w3.org/1999/xlink', 'href', this.renderer.url + '#' + textPathId);
  5114. // Presentation attributes:
  5115. // dx/dy options must by set on <text> (parent),
  5116. // the rest should be set on <textPath>
  5117. if (defined(attrs.dy)) {
  5118. textPathElement.parentNode
  5119. .setAttribute('dy', attrs.dy);
  5120. delete attrs.dy;
  5121. }
  5122. if (defined(attrs.dx)) {
  5123. textPathElement.parentNode
  5124. .setAttribute('dx', attrs.dx);
  5125. delete attrs.dx;
  5126. }
  5127. // Additional attributes
  5128. objectEach(attrs, function (val, key) {
  5129. textPathElement.setAttribute(attribsMap[key] || key, val);
  5130. });
  5131. // Remove translation, text that follows path does not need that
  5132. elem.removeAttribute('transform');
  5133. // Remove shadows and text outlines
  5134. this.removeTextOutline.call(textPathWrapper, [].slice.call(elem.getElementsByTagName('tspan')));
  5135. // Remove background and border for label(), see #10545
  5136. // Alternatively, we can disable setting background rects in
  5137. // series.drawDataLabels()
  5138. if (this.text && !this.renderer.styledMode) {
  5139. this.attr({
  5140. fill: 'none',
  5141. 'stroke-width': 0
  5142. });
  5143. }
  5144. // Disable some functions
  5145. this.updateTransform = noop;
  5146. this.applyTextOutline = noop;
  5147. }
  5148. else if (textPathWrapper) {
  5149. // Reset to prototype
  5150. delete this.updateTransform;
  5151. delete this.applyTextOutline;
  5152. // Restore DOM structure:
  5153. this.destroyTextPath(elem, path);
  5154. // Bring attributes back
  5155. this.updateTransform();
  5156. // Set textOutline back for text()
  5157. if (this.options && this.options.rotation) {
  5158. this.applyTextOutline(this.options.style.textOutline);
  5159. }
  5160. }
  5161. return this;
  5162. };
  5163. /**
  5164. * Add a shadow to the element. Must be called after the element is added to
  5165. * the DOM. In styled mode, this method is not used, instead use `defs` and
  5166. * filters.
  5167. *
  5168. * @example
  5169. * renderer.rect(10, 100, 100, 100)
  5170. * .attr({ fill: 'red' })
  5171. * .shadow(true);
  5172. *
  5173. * @function Highcharts.SVGElement#shadow
  5174. *
  5175. * @param {boolean|Highcharts.ShadowOptionsObject} [shadowOptions]
  5176. * The shadow options. If `true`, the default options are applied. If
  5177. * `false`, the current shadow will be removed.
  5178. *
  5179. * @param {Highcharts.SVGElement} [group]
  5180. * The SVG group element where the shadows will be applied. The
  5181. * default is to add it to the same parent as the current element.
  5182. * Internally, this is ised for pie slices, where all the shadows are
  5183. * added to an element behind all the slices.
  5184. *
  5185. * @param {boolean} [cutOff]
  5186. * Used internally for column shadows.
  5187. *
  5188. * @return {Highcharts.SVGElement}
  5189. * Returns the SVGElement for chaining.
  5190. */
  5191. SVGElement.prototype.shadow = function (shadowOptions, group, cutOff) {
  5192. var shadows = [],
  5193. i,
  5194. shadow,
  5195. element = this.element,
  5196. strokeWidth,
  5197. shadowElementOpacity,
  5198. update = false,
  5199. oldShadowOptions = this.oldShadowOptions,
  5200. // compensate for inverted plot area
  5201. transform;
  5202. var defaultShadowOptions = {
  5203. color: '#000000',
  5204. offsetX: 1,
  5205. offsetY: 1,
  5206. opacity: 0.15,
  5207. width: 3
  5208. };
  5209. var options;
  5210. if (shadowOptions === true) {
  5211. options = defaultShadowOptions;
  5212. }
  5213. else if (typeof shadowOptions === 'object') {
  5214. options = extend(defaultShadowOptions, shadowOptions);
  5215. }
  5216. // Update shadow when options change (#12091).
  5217. if (options) {
  5218. // Go over each key to look for change
  5219. if (options && oldShadowOptions) {
  5220. objectEach(options, function (value, key) {
  5221. if (value !== oldShadowOptions[key]) {
  5222. update = true;
  5223. }
  5224. });
  5225. }
  5226. if (update) {
  5227. this.destroyShadows();
  5228. }
  5229. this.oldShadowOptions = options;
  5230. }
  5231. if (!options) {
  5232. this.destroyShadows();
  5233. }
  5234. else if (!this.shadows) {
  5235. shadowElementOpacity = options.opacity / options.width;
  5236. transform = this.parentInverted ?
  5237. 'translate(-1,-1)' :
  5238. "translate(" + options.offsetX + ", " + options.offsetY + ")";
  5239. for (i = 1; i <= options.width; i++) {
  5240. shadow = element.cloneNode(false);
  5241. strokeWidth = (options.width * 2) + 1 - (2 * i);
  5242. attr(shadow, {
  5243. stroke: (shadowOptions.color ||
  5244. '#000000'),
  5245. 'stroke-opacity': shadowElementOpacity * i,
  5246. 'stroke-width': strokeWidth,
  5247. transform: transform,
  5248. fill: 'none'
  5249. });
  5250. shadow.setAttribute('class', (shadow.getAttribute('class') || '') + ' highcharts-shadow');
  5251. if (cutOff) {
  5252. attr(shadow, 'height', Math.max(attr(shadow, 'height') - strokeWidth, 0));
  5253. shadow.cutHeight = strokeWidth;
  5254. }
  5255. if (group) {
  5256. group.element.appendChild(shadow);
  5257. }
  5258. else if (element.parentNode) {
  5259. element.parentNode.insertBefore(shadow, element);
  5260. }
  5261. shadows.push(shadow);
  5262. }
  5263. this.shadows = shadows;
  5264. }
  5265. return this;
  5266. };
  5267. /**
  5268. * Show the element after it has been hidden.
  5269. *
  5270. * @function Highcharts.SVGElement#show
  5271. *
  5272. * @param {boolean} [inherit=false]
  5273. * Set the visibility attribute to `inherit` rather than `visible`.
  5274. * The difference is that an element with `visibility="visible"`
  5275. * will be visible even if the parent is hidden.
  5276. *
  5277. * @return {Highcharts.SVGElement}
  5278. * Returns the SVGElement for chaining.
  5279. */
  5280. SVGElement.prototype.show = function (inherit) {
  5281. return this.attr({ visibility: inherit ? 'inherit' : 'visible' });
  5282. };
  5283. /**
  5284. * WebKit and Batik have problems with a stroke-width of zero, so in this
  5285. * case we remove the stroke attribute altogether. #1270, #1369, #3065,
  5286. * #3072.
  5287. *
  5288. * @private
  5289. * @function Highcharts.SVGElement#strokeSetter
  5290. * @param {number|string} value
  5291. * @param {string} key
  5292. * @param {Highcharts.SVGDOMElement} element
  5293. */
  5294. SVGElement.prototype.strokeSetter = function (value, key, element) {
  5295. this[key] = value;
  5296. // Only apply the stroke attribute if the stroke width is defined and
  5297. // larger than 0
  5298. if (this.stroke && this['stroke-width']) {
  5299. // Use prototype as instance may be overridden
  5300. SVGElement.prototype.fillSetter.call(this, this.stroke, 'stroke', element);
  5301. element.setAttribute('stroke-width', this['stroke-width']);
  5302. this.hasStroke = true;
  5303. }
  5304. else if (key === 'stroke-width' && value === 0 && this.hasStroke) {
  5305. element.removeAttribute('stroke');
  5306. this.hasStroke = false;
  5307. }
  5308. else if (this.renderer.styledMode && this['stroke-width']) {
  5309. element.setAttribute('stroke-width', this['stroke-width']);
  5310. this.hasStroke = true;
  5311. }
  5312. };
  5313. /**
  5314. * Get the computed stroke width in pixel values. This is used extensively
  5315. * when drawing shapes to ensure the shapes are rendered crisp and
  5316. * positioned correctly relative to each other. Using
  5317. * `shape-rendering: crispEdges` leaves us less control over positioning,
  5318. * for example when we want to stack columns next to each other, or position
  5319. * things pixel-perfectly within the plot box.
  5320. *
  5321. * The common pattern when placing a shape is:
  5322. * - Create the SVGElement and add it to the DOM. In styled mode, it will
  5323. * now receive a stroke width from the style sheet. In classic mode we
  5324. * will add the `stroke-width` attribute.
  5325. * - Read the computed `elem.strokeWidth()`.
  5326. * - Place it based on the stroke width.
  5327. *
  5328. * @function Highcharts.SVGElement#strokeWidth
  5329. *
  5330. * @return {number}
  5331. * The stroke width in pixels. Even if the given stroke widtch (in CSS or by
  5332. * attributes) is based on `em` or other units, the pixel size is returned.
  5333. */
  5334. SVGElement.prototype.strokeWidth = function () {
  5335. // In non-styled mode, read the stroke width as set by .attr
  5336. if (!this.renderer.styledMode) {
  5337. return this['stroke-width'] || 0;
  5338. }
  5339. // In styled mode, read computed stroke width
  5340. var val = this.getStyle('stroke-width'),
  5341. ret = 0,
  5342. dummy;
  5343. // Read pixel values directly
  5344. if (val.indexOf('px') === val.length - 2) {
  5345. ret = pInt(val);
  5346. // Other values like em, pt etc need to be measured
  5347. }
  5348. else if (val !== '') {
  5349. dummy = doc.createElementNS(SVG_NS, 'rect');
  5350. attr(dummy, {
  5351. width: val,
  5352. 'stroke-width': 0
  5353. });
  5354. this.element.parentNode.appendChild(dummy);
  5355. ret = dummy.getBBox().width;
  5356. dummy.parentNode.removeChild(dummy);
  5357. }
  5358. return ret;
  5359. };
  5360. /**
  5361. * If one of the symbol size affecting parameters are changed,
  5362. * check all the others only once for each call to an element's
  5363. * .attr() method
  5364. *
  5365. * @private
  5366. * @function Highcharts.SVGElement#symbolAttr
  5367. *
  5368. * @param {Highcharts.SVGAttributes} hash
  5369. * The attributes to set.
  5370. */
  5371. SVGElement.prototype.symbolAttr = function (hash) {
  5372. var wrapper = this;
  5373. [
  5374. 'x',
  5375. 'y',
  5376. 'r',
  5377. 'start',
  5378. 'end',
  5379. 'width',
  5380. 'height',
  5381. 'innerR',
  5382. 'anchorX',
  5383. 'anchorY',
  5384. 'clockwise'
  5385. ].forEach(function (key) {
  5386. wrapper[key] = pick(hash[key], wrapper[key]);
  5387. });
  5388. wrapper.attr({
  5389. d: wrapper.renderer.symbols[wrapper.symbolName](wrapper.x, wrapper.y, wrapper.width, wrapper.height, wrapper)
  5390. });
  5391. };
  5392. /**
  5393. * @private
  5394. * @function Highcharts.SVGElement#textSetter
  5395. * @param {string} value
  5396. */
  5397. SVGElement.prototype.textSetter = function (value) {
  5398. if (value !== this.textStr) {
  5399. // Delete size caches when the text changes
  5400. // delete this.bBox; // old code in series-label
  5401. delete this.textPxLength;
  5402. this.textStr = value;
  5403. if (this.added) {
  5404. this.renderer.buildText(this);
  5405. }
  5406. }
  5407. };
  5408. /**
  5409. * @private
  5410. * @function Highcharts.SVGElement#titleSetter
  5411. * @param {string} value
  5412. */
  5413. SVGElement.prototype.titleSetter = function (value) {
  5414. var titleNode = this.element.getElementsByTagName('title')[0];
  5415. if (!titleNode) {
  5416. titleNode = doc.createElementNS(this.SVG_NS, 'title');
  5417. this.element.appendChild(titleNode);
  5418. }
  5419. // Remove text content if it exists
  5420. if (titleNode.firstChild) {
  5421. titleNode.removeChild(titleNode.firstChild);
  5422. }
  5423. titleNode.appendChild(doc.createTextNode(
  5424. // #3276, #3895
  5425. String(pick(value, ''))
  5426. .replace(/<[^>]*>/g, '')
  5427. .replace(/&lt;/g, '<')
  5428. .replace(/&gt;/g, '>')));
  5429. };
  5430. /**
  5431. * Bring the element to the front. Alternatively, a new zIndex can be set.
  5432. *
  5433. * @sample highcharts/members/element-tofront/
  5434. * Click an element to bring it to front
  5435. *
  5436. * @function Highcharts.SVGElement#toFront
  5437. *
  5438. * @return {Highcharts.SVGElement}
  5439. * Returns the SVGElement for chaining.
  5440. */
  5441. SVGElement.prototype.toFront = function () {
  5442. var element = this.element;
  5443. element.parentNode.appendChild(element);
  5444. return this;
  5445. };
  5446. /**
  5447. * Move an object and its children by x and y values.
  5448. *
  5449. * @function Highcharts.SVGElement#translate
  5450. *
  5451. * @param {number} x
  5452. * The x value.
  5453. *
  5454. * @param {number} y
  5455. * The y value.
  5456. *
  5457. * @return {Highcharts.SVGElement}
  5458. */
  5459. SVGElement.prototype.translate = function (x, y) {
  5460. return this.attr({
  5461. translateX: x,
  5462. translateY: y
  5463. });
  5464. };
  5465. /**
  5466. * Update the shadow elements with new attributes.
  5467. *
  5468. * @private
  5469. * @function Highcharts.SVGElement#updateShadows
  5470. *
  5471. * @param {string} key
  5472. * The attribute name.
  5473. *
  5474. * @param {number} value
  5475. * The value of the attribute.
  5476. *
  5477. * @param {Function} setter
  5478. * The setter function, inherited from the parent wrapper.
  5479. */
  5480. SVGElement.prototype.updateShadows = function (key, value, setter) {
  5481. var shadows = this.shadows;
  5482. if (shadows) {
  5483. var i = shadows.length;
  5484. while (i--) {
  5485. setter.call(shadows[i], key === 'height' ?
  5486. Math.max(value - (shadows[i].cutHeight || 0), 0) :
  5487. key === 'd' ? this.d : value, key, shadows[i]);
  5488. }
  5489. }
  5490. };
  5491. /**
  5492. * Update the transform attribute based on internal properties. Deals with
  5493. * the custom `translateX`, `translateY`, `rotation`, `scaleX` and `scaleY`
  5494. * attributes and updates the SVG `transform` attribute.
  5495. *
  5496. * @private
  5497. * @function Highcharts.SVGElement#updateTransform
  5498. */
  5499. SVGElement.prototype.updateTransform = function () {
  5500. var wrapper = this,
  5501. translateX = wrapper.translateX || 0,
  5502. translateY = wrapper.translateY || 0,
  5503. scaleX = wrapper.scaleX,
  5504. scaleY = wrapper.scaleY,
  5505. inverted = wrapper.inverted,
  5506. rotation = wrapper.rotation,
  5507. matrix = wrapper.matrix,
  5508. element = wrapper.element,
  5509. transform;
  5510. // Flipping affects translate as adjustment for flipping around the
  5511. // group's axis
  5512. if (inverted) {
  5513. translateX += wrapper.width;
  5514. translateY += wrapper.height;
  5515. }
  5516. // Apply translate. Nearly all transformed elements have translation,
  5517. // so instead of checking for translate = 0, do it always (#1767,
  5518. // #1846).
  5519. transform = ['translate(' + translateX + ',' + translateY + ')'];
  5520. // apply matrix
  5521. if (defined(matrix)) {
  5522. transform.push('matrix(' + matrix.join(',') + ')');
  5523. }
  5524. // apply rotation
  5525. if (inverted) {
  5526. transform.push('rotate(90) scale(-1,1)');
  5527. }
  5528. else if (rotation) { // text rotation
  5529. transform.push('rotate(' + rotation + ' ' +
  5530. pick(this.rotationOriginX, element.getAttribute('x'), 0) +
  5531. ' ' +
  5532. pick(this.rotationOriginY, element.getAttribute('y') || 0) + ')');
  5533. }
  5534. // apply scale
  5535. if (defined(scaleX) || defined(scaleY)) {
  5536. transform.push('scale(' + pick(scaleX, 1) + ' ' + pick(scaleY, 1) + ')');
  5537. }
  5538. if (transform.length) {
  5539. element.setAttribute('transform', transform.join(' '));
  5540. }
  5541. };
  5542. /**
  5543. * @private
  5544. * @function Highcharts.SVGElement#visibilitySetter
  5545. *
  5546. * @param {string} value
  5547. *
  5548. * @param {string} key
  5549. *
  5550. * @param {Highcharts.SVGDOMElement} element
  5551. *
  5552. * @return {void}
  5553. */
  5554. SVGElement.prototype.visibilitySetter = function (value, key, element) {
  5555. // IE9-11 doesn't handle visibilty:inherit well, so we remove the
  5556. // attribute instead (#2881, #3909)
  5557. if (value === 'inherit') {
  5558. element.removeAttribute(key);
  5559. }
  5560. else if (this[key] !== value) { // #6747
  5561. element.setAttribute(key, value);
  5562. }
  5563. this[key] = value;
  5564. };
  5565. /**
  5566. * @private
  5567. * @function Highcharts.SVGElement#xGetter
  5568. *
  5569. * @param {string} key
  5570. *
  5571. * @return {number|string|null}
  5572. */
  5573. SVGElement.prototype.xGetter = function (key) {
  5574. if (this.element.nodeName === 'circle') {
  5575. if (key === 'x') {
  5576. key = 'cx';
  5577. }
  5578. else if (key === 'y') {
  5579. key = 'cy';
  5580. }
  5581. }
  5582. return this._defaultGetter(key);
  5583. };
  5584. /**
  5585. * @private
  5586. * @function Highcharts.SVGElement#zIndexSetter
  5587. * @param {number} [value]
  5588. * @param {string} [key]
  5589. * @return {boolean}
  5590. */
  5591. SVGElement.prototype.zIndexSetter = function (value, key) {
  5592. var renderer = this.renderer,
  5593. parentGroup = this.parentGroup,
  5594. parentWrapper = parentGroup || renderer,
  5595. parentNode = parentWrapper.element || renderer.box,
  5596. childNodes,
  5597. otherElement,
  5598. otherZIndex,
  5599. element = this.element,
  5600. inserted = false,
  5601. undefinedOtherZIndex,
  5602. svgParent = parentNode === renderer.box,
  5603. run = this.added,
  5604. i;
  5605. if (defined(value)) {
  5606. // So we can read it for other elements in the group
  5607. element.setAttribute('data-z-index', value);
  5608. value = +value;
  5609. if (this[key] === value) {
  5610. // Only update when needed (#3865)
  5611. run = false;
  5612. }
  5613. }
  5614. else if (defined(this[key])) {
  5615. element.removeAttribute('data-z-index');
  5616. }
  5617. this[key] = value;
  5618. // Insert according to this and other elements' zIndex. Before .add() is
  5619. // called, nothing is done. Then on add, or by later calls to
  5620. // zIndexSetter, the node is placed on the right place in the DOM.
  5621. if (run) {
  5622. value = this.zIndex;
  5623. if (value && parentGroup) {
  5624. parentGroup.handleZ = true;
  5625. }
  5626. childNodes = parentNode.childNodes;
  5627. for (i = childNodes.length - 1; i >= 0 && !inserted; i--) {
  5628. otherElement = childNodes[i];
  5629. otherZIndex = otherElement.getAttribute('data-z-index');
  5630. undefinedOtherZIndex = !defined(otherZIndex);
  5631. if (otherElement !== element) {
  5632. if (
  5633. // Negative zIndex versus no zIndex:
  5634. // On all levels except the highest. If the parent is
  5635. // <svg>, then we don't want to put items before <desc>
  5636. // or <defs>
  5637. value < 0 &&
  5638. undefinedOtherZIndex &&
  5639. !svgParent &&
  5640. !i) {
  5641. parentNode.insertBefore(element, childNodes[i]);
  5642. inserted = true;
  5643. }
  5644. else if (
  5645. // Insert after the first element with a lower zIndex
  5646. pInt(otherZIndex) <= value ||
  5647. // If negative zIndex, add this before first undefined
  5648. // zIndex element
  5649. (undefinedOtherZIndex &&
  5650. (!defined(value) || value >= 0))) {
  5651. parentNode.insertBefore(element, childNodes[i + 1] || null // null for oldIE export
  5652. );
  5653. inserted = true;
  5654. }
  5655. }
  5656. }
  5657. if (!inserted) {
  5658. parentNode.insertBefore(element, childNodes[svgParent ? 3 : 0] || null // null for oldIE
  5659. );
  5660. inserted = true;
  5661. }
  5662. }
  5663. return inserted;
  5664. };
  5665. return SVGElement;
  5666. }());
  5667. // Some shared setters and getters
  5668. SVGElement.prototype['stroke-widthSetter'] = SVGElement.prototype.strokeSetter;
  5669. SVGElement.prototype.yGetter = SVGElement.prototype.xGetter;
  5670. SVGElement.prototype.matrixSetter =
  5671. SVGElement.prototype.rotationOriginXSetter =
  5672. SVGElement.prototype.rotationOriginYSetter =
  5673. SVGElement.prototype.rotationSetter =
  5674. SVGElement.prototype.scaleXSetter =
  5675. SVGElement.prototype.scaleYSetter =
  5676. SVGElement.prototype.translateXSetter =
  5677. SVGElement.prototype.translateYSetter =
  5678. SVGElement.prototype.verticalAlignSetter = function (value, key) {
  5679. this[key] = value;
  5680. this.doTransform = true;
  5681. };
  5682. H.SVGElement = SVGElement;
  5683. return H.SVGElement;
  5684. });
  5685. _registerModule(_modules, 'Core/Renderer/SVG/SVGLabel.js', [_modules['Core/Renderer/SVG/SVGElement.js'], _modules['Core/Utilities.js']], function (SVGElement, U) {
  5686. /* *
  5687. *
  5688. * (c) 2010-2020 Torstein Honsi
  5689. *
  5690. * License: www.highcharts.com/license
  5691. *
  5692. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  5693. *
  5694. * */
  5695. var __extends = (this && this.__extends) || (function () {
  5696. var extendStatics = function (d,
  5697. b) {
  5698. extendStatics = Object.setPrototypeOf ||
  5699. ({ __proto__: [] } instanceof Array && function (d,
  5700. b) { d.__proto__ = b; }) ||
  5701. function (d,
  5702. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  5703. return extendStatics(d, b);
  5704. };
  5705. return function (d, b) {
  5706. extendStatics(d, b);
  5707. function __() { this.constructor = d; }
  5708. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  5709. };
  5710. })();
  5711. var defined = U.defined,
  5712. extend = U.extend,
  5713. isNumber = U.isNumber,
  5714. merge = U.merge,
  5715. removeEvent = U.removeEvent;
  5716. /**
  5717. * SVG label to render text.
  5718. * @private
  5719. * @class
  5720. * @name Highcharts.SVGLabel
  5721. * @augments Highcharts.SVGElement
  5722. */
  5723. var SVGLabel = /** @class */ (function (_super) {
  5724. __extends(SVGLabel, _super);
  5725. /* *
  5726. *
  5727. * Constructors
  5728. *
  5729. * */
  5730. function SVGLabel(renderer, str, x, y, shape, anchorX, anchorY, useHTML, baseline, className) {
  5731. var _this = _super.call(this) || this;
  5732. _this.init(renderer, 'g');
  5733. _this.textStr = str;
  5734. _this.x = x;
  5735. _this.y = y;
  5736. _this.anchorX = anchorX;
  5737. _this.anchorY = anchorY;
  5738. _this.baseline = baseline;
  5739. _this.className = className;
  5740. if (className !== 'button') {
  5741. _this.addClass('highcharts-label');
  5742. }
  5743. if (className) {
  5744. _this.addClass('highcharts-' + className);
  5745. }
  5746. _this.text = renderer.text('', 0, 0, useHTML)
  5747. .attr({
  5748. zIndex: 1
  5749. });
  5750. // Validate the shape argument
  5751. var hasBGImage;
  5752. if (typeof shape === 'string') {
  5753. hasBGImage = /^url\((.*?)\)$/.test(shape);
  5754. if (_this.renderer.symbols[shape] || hasBGImage) {
  5755. _this.symbolKey = shape;
  5756. }
  5757. }
  5758. _this.bBox = SVGLabel.emptyBBox;
  5759. _this.padding = 3;
  5760. _this.paddingLeft = 0;
  5761. _this.baselineOffset = 0;
  5762. _this.needsBox = renderer.styledMode || hasBGImage;
  5763. _this.deferredAttr = {};
  5764. _this.alignFactor = 0;
  5765. return _this;
  5766. }
  5767. /* *
  5768. *
  5769. * Functions
  5770. *
  5771. * */
  5772. SVGLabel.prototype.alignSetter = function (value) {
  5773. var alignFactor = {
  5774. left: 0,
  5775. center: 0.5,
  5776. right: 1
  5777. }[value];
  5778. if (alignFactor !== this.alignFactor) {
  5779. this.alignFactor = alignFactor;
  5780. // Bounding box exists, means we're dynamically changing
  5781. if (this.bBox && isNumber(this.xSetting)) {
  5782. this.attr({ x: this.xSetting }); // #5134
  5783. }
  5784. }
  5785. };
  5786. SVGLabel.prototype.anchorXSetter = function (value, key) {
  5787. this.anchorX = value;
  5788. this.boxAttr(key, Math.round(value) - this.getCrispAdjust() - this.xSetting);
  5789. };
  5790. SVGLabel.prototype.anchorYSetter = function (value, key) {
  5791. this.anchorY = value;
  5792. this.boxAttr(key, value - this.ySetting);
  5793. };
  5794. /*
  5795. * Set a box attribute, or defer it if the box is not yet created
  5796. */
  5797. SVGLabel.prototype.boxAttr = function (key, value) {
  5798. if (this.box) {
  5799. this.box.attr(key, value);
  5800. }
  5801. else {
  5802. this.deferredAttr[key] = value;
  5803. }
  5804. };
  5805. /*
  5806. * Pick up some properties and apply them to the text instead of the
  5807. * wrapper.
  5808. */
  5809. SVGLabel.prototype.css = function (styles) {
  5810. if (styles) {
  5811. var textStyles = {},
  5812. isWidth,
  5813. isFontStyle;
  5814. // Create a copy to avoid altering the original object
  5815. // (#537)
  5816. styles = merge(styles);
  5817. SVGLabel.textProps.forEach(function (prop) {
  5818. if (typeof styles[prop] !== 'undefined') {
  5819. textStyles[prop] = styles[prop];
  5820. delete styles[prop];
  5821. }
  5822. });
  5823. this.text.css(textStyles);
  5824. isWidth = 'width' in textStyles;
  5825. isFontStyle = 'fontSize' in textStyles ||
  5826. 'fontWeight' in textStyles;
  5827. // Update existing text, box (#9400, #12163)
  5828. if (isWidth || isFontStyle) {
  5829. this.updateBoxSize();
  5830. // Keep updated (#9400, #12163)
  5831. if (isFontStyle) {
  5832. this.updateTextPadding();
  5833. }
  5834. }
  5835. }
  5836. return SVGElement.prototype.css.call(this, styles);
  5837. };
  5838. /*
  5839. * Destroy and release memory.
  5840. */
  5841. SVGLabel.prototype.destroy = function () {
  5842. // Added by button implementation
  5843. removeEvent(this.element, 'mouseenter');
  5844. removeEvent(this.element, 'mouseleave');
  5845. if (this.text) {
  5846. this.text.destroy();
  5847. }
  5848. if (this.box) {
  5849. this.box = this.box.destroy();
  5850. }
  5851. // Call base implementation to destroy the rest
  5852. SVGElement.prototype.destroy.call(this);
  5853. return void 0;
  5854. };
  5855. SVGLabel.prototype.fillSetter = function (value, key) {
  5856. if (value) {
  5857. this.needsBox = true;
  5858. }
  5859. // for animation getter (#6776)
  5860. this.fill = value;
  5861. this.boxAttr(key, value);
  5862. };
  5863. /*
  5864. * Return the bounding box of the box, not the group.
  5865. */
  5866. SVGLabel.prototype.getBBox = function () {
  5867. var bBox = this.bBox;
  5868. var padding = this.padding;
  5869. return {
  5870. width: bBox.width + 2 * padding,
  5871. height: bBox.height + 2 * padding,
  5872. x: bBox.x - padding,
  5873. y: bBox.y - padding
  5874. };
  5875. };
  5876. SVGLabel.prototype.getCrispAdjust = function () {
  5877. return this.renderer.styledMode && this.box ?
  5878. this.box.strokeWidth() % 2 / 2 :
  5879. (this['stroke-width'] ? parseInt(this['stroke-width'], 10) : 0) % 2 / 2;
  5880. };
  5881. SVGLabel.prototype.heightSetter = function (value) {
  5882. this.heightSetting = value;
  5883. };
  5884. // Event handling. In case of useHTML, we need to make sure that events
  5885. // are captured on the span as well, and that mouseenter/mouseleave
  5886. // between the SVG group and the HTML span are not treated as real
  5887. // enter/leave events. #13310.
  5888. SVGLabel.prototype.on = function (eventType, handler) {
  5889. var label = this;
  5890. var text = label.text;
  5891. var span = text && text.element.tagName === 'SPAN' ? text : void 0;
  5892. var selectiveHandler;
  5893. if (span) {
  5894. selectiveHandler = function (e) {
  5895. if ((eventType === 'mouseenter' ||
  5896. eventType === 'mouseleave') &&
  5897. e.relatedTarget instanceof Element &&
  5898. (label.element.contains(e.relatedTarget) ||
  5899. span.element.contains(e.relatedTarget))) {
  5900. return;
  5901. }
  5902. handler.call(label.element, e);
  5903. };
  5904. span.on(eventType, selectiveHandler);
  5905. }
  5906. SVGElement.prototype.on.call(label, eventType, selectiveHandler || handler);
  5907. return label;
  5908. };
  5909. /*
  5910. * After the text element is added, get the desired size of the border
  5911. * box and add it before the text in the DOM.
  5912. */
  5913. SVGLabel.prototype.onAdd = function () {
  5914. var str = this.textStr;
  5915. this.text.add(this);
  5916. this.attr({
  5917. // Alignment is available now (#3295, 0 not rendered if given
  5918. // as a value)
  5919. text: (defined(str) ? str : ''),
  5920. x: this.x,
  5921. y: this.y
  5922. });
  5923. if (this.box && defined(this.anchorX)) {
  5924. this.attr({
  5925. anchorX: this.anchorX,
  5926. anchorY: this.anchorY
  5927. });
  5928. }
  5929. };
  5930. SVGLabel.prototype.paddingSetter = function (value) {
  5931. if (defined(value) && value !== this.padding) {
  5932. this.padding = value;
  5933. this.updateTextPadding();
  5934. }
  5935. };
  5936. SVGLabel.prototype.paddingLeftSetter = function (value) {
  5937. if (defined(value) && value !== this.paddingLeft) {
  5938. this.paddingLeft = value;
  5939. this.updateTextPadding();
  5940. }
  5941. };
  5942. SVGLabel.prototype.rSetter = function (value, key) {
  5943. this.boxAttr(key, value);
  5944. };
  5945. SVGLabel.prototype.shadow = function (b) {
  5946. if (b && !this.renderer.styledMode) {
  5947. this.updateBoxSize();
  5948. if (this.box) {
  5949. this.box.shadow(b);
  5950. }
  5951. }
  5952. return this;
  5953. };
  5954. SVGLabel.prototype.strokeSetter = function (value, key) {
  5955. // for animation getter (#6776)
  5956. this.stroke = value;
  5957. this.boxAttr(key, value);
  5958. };
  5959. SVGLabel.prototype['stroke-widthSetter'] = function (value, key) {
  5960. if (value) {
  5961. this.needsBox = true;
  5962. }
  5963. this['stroke-width'] = value;
  5964. this.boxAttr(key, value);
  5965. };
  5966. SVGLabel.prototype['text-alignSetter'] = function (value) {
  5967. this.textAlign = value;
  5968. };
  5969. SVGLabel.prototype.textSetter = function (text) {
  5970. if (typeof text !== 'undefined') {
  5971. // Must use .attr to ensure transforms are done (#10009)
  5972. this.text.attr({ text: text });
  5973. }
  5974. this.updateBoxSize();
  5975. this.updateTextPadding();
  5976. };
  5977. /*
  5978. * This function runs after the label is added to the DOM (when the bounding
  5979. * box is available), and after the text of the label is updated to detect
  5980. * the new bounding box and reflect it in the border box.
  5981. */
  5982. SVGLabel.prototype.updateBoxSize = function () {
  5983. var style = this.text.element.style,
  5984. crispAdjust,
  5985. attribs = {};
  5986. var padding = this.padding;
  5987. var paddingLeft = this.paddingLeft;
  5988. // #12165 error when width is null (auto)
  5989. // #12163 when fontweight: bold, recalculate bBox withot cache
  5990. // #3295 && 3514 box failure when string equals 0
  5991. var bBox = ((!isNumber(this.widthSetting) || !isNumber(this.heightSetting) || this.textAlign) &&
  5992. defined(this.text.textStr)) ?
  5993. this.text.getBBox() : SVGLabel.emptyBBox;
  5994. this.width = ((this.widthSetting || bBox.width || 0) +
  5995. 2 * padding +
  5996. paddingLeft);
  5997. this.height = (this.heightSetting || bBox.height || 0) + 2 * padding;
  5998. // Update the label-scoped y offset. Math.min because of inline
  5999. // style (#9400)
  6000. this.baselineOffset = padding + Math.min(this.renderer.fontMetrics(style && style.fontSize, this.text).b,
  6001. // When the height is 0, there is no bBox, so go with the font
  6002. // metrics. Highmaps CSS demos.
  6003. bBox.height || Infinity);
  6004. if (this.needsBox) {
  6005. // Create the border box if it is not already present
  6006. if (!this.box) {
  6007. // Symbol definition exists (#5324)
  6008. var box = this.box = this.symbolKey ?
  6009. this.renderer.symbol(this.symbolKey) :
  6010. this.renderer.rect();
  6011. box.addClass(// Don't use label className for buttons
  6012. (this.className === 'button' ? '' : 'highcharts-label-box') +
  6013. (this.className ? ' highcharts-' + this.className + '-box' : ''));
  6014. box.add(this);
  6015. crispAdjust = this.getCrispAdjust();
  6016. attribs.x = crispAdjust;
  6017. attribs.y = (this.baseline ? -this.baselineOffset : 0) + crispAdjust;
  6018. }
  6019. // Apply the box attributes
  6020. attribs.width = Math.round(this.width);
  6021. attribs.height = Math.round(this.height);
  6022. this.box.attr(extend(attribs, this.deferredAttr));
  6023. this.deferredAttr = {};
  6024. }
  6025. this.bBox = bBox;
  6026. };
  6027. /*
  6028. * This function runs after setting text or padding, but only if padding
  6029. * is changed.
  6030. */
  6031. SVGLabel.prototype.updateTextPadding = function () {
  6032. var text = this.text;
  6033. // Determine y based on the baseline
  6034. var textY = this.baseline ? 0 : this.baselineOffset;
  6035. var textX = this.paddingLeft + this.padding;
  6036. // compensate for alignment
  6037. if (defined(this.widthSetting) &&
  6038. this.bBox &&
  6039. (this.textAlign === 'center' || this.textAlign === 'right')) {
  6040. textX += { center: 0.5, right: 1 }[this.textAlign] *
  6041. (this.widthSetting - this.bBox.width);
  6042. }
  6043. // update if anything changed
  6044. if (textX !== text.x || textY !== text.y) {
  6045. text.attr('x', textX);
  6046. // #8159 - prevent misplaced data labels in treemap
  6047. // (useHTML: true)
  6048. if (text.hasBoxWidthChanged) {
  6049. this.bBox = text.getBBox(true);
  6050. this.updateBoxSize();
  6051. }
  6052. if (typeof textY !== 'undefined') {
  6053. text.attr('y', textY);
  6054. }
  6055. }
  6056. // record current values
  6057. text.x = textX;
  6058. text.y = textY;
  6059. };
  6060. SVGLabel.prototype.widthSetter = function (value) {
  6061. // width:auto => null
  6062. this.widthSetting = isNumber(value) ? value : void 0;
  6063. };
  6064. SVGLabel.prototype.xSetter = function (value) {
  6065. this.x = value; // for animation getter
  6066. if (this.alignFactor) {
  6067. value -= this.alignFactor * ((this.widthSetting || this.bBox.width) +
  6068. 2 * this.padding);
  6069. // Force animation even when setting to the same value (#7898)
  6070. this['forceAnimate:x'] = true;
  6071. }
  6072. this.xSetting = Math.round(value);
  6073. this.attr('translateX', this.xSetting);
  6074. };
  6075. SVGLabel.prototype.ySetter = function (value) {
  6076. this.ySetting = this.y = Math.round(value);
  6077. this.attr('translateY', this.ySetting);
  6078. };
  6079. /* *
  6080. *
  6081. * Static Properties
  6082. *
  6083. * */
  6084. SVGLabel.emptyBBox = { width: 0, height: 0, x: 0, y: 0 };
  6085. /* *
  6086. *
  6087. * Properties
  6088. *
  6089. * */
  6090. /**
  6091. * For labels, these CSS properties are applied to the `text` node directly.
  6092. *
  6093. * @private
  6094. * @name Highcharts.SVGLabel#textProps
  6095. * @type {Array<string>}
  6096. */
  6097. SVGLabel.textProps = [
  6098. 'color', 'cursor', 'direction', 'fontFamily', 'fontSize', 'fontStyle',
  6099. 'fontWeight', 'lineHeight', 'textAlign', 'textDecoration',
  6100. 'textOutline', 'textOverflow', 'width'
  6101. ];
  6102. return SVGLabel;
  6103. }(SVGElement));
  6104. return SVGLabel;
  6105. });
  6106. _registerModule(_modules, 'Core/Renderer/SVG/SVGRenderer.js', [_modules['Core/Color/Color.js'], _modules['Core/Globals.js'], _modules['Core/Renderer/SVG/SVGElement.js'], _modules['Core/Renderer/SVG/SVGLabel.js'], _modules['Core/Utilities.js']], function (Color, H, SVGElement, SVGLabel, U) {
  6107. /* *
  6108. *
  6109. * (c) 2010-2020 Torstein Honsi
  6110. *
  6111. * License: www.highcharts.com/license
  6112. *
  6113. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  6114. *
  6115. * */
  6116. var addEvent = U.addEvent,
  6117. attr = U.attr,
  6118. createElement = U.createElement,
  6119. css = U.css,
  6120. defined = U.defined,
  6121. destroyObjectProperties = U.destroyObjectProperties,
  6122. extend = U.extend,
  6123. isArray = U.isArray,
  6124. isNumber = U.isNumber,
  6125. isObject = U.isObject,
  6126. isString = U.isString,
  6127. merge = U.merge,
  6128. objectEach = U.objectEach,
  6129. pick = U.pick,
  6130. pInt = U.pInt,
  6131. splat = U.splat,
  6132. uniqueKey = U.uniqueKey;
  6133. /**
  6134. * A clipping rectangle that can be applied to one or more {@link SVGElement}
  6135. * instances. It is instanciated with the {@link SVGRenderer#clipRect} function
  6136. * and applied with the {@link SVGElement#clip} function.
  6137. *
  6138. * @example
  6139. * var circle = renderer.circle(100, 100, 100)
  6140. * .attr({ fill: 'red' })
  6141. * .add();
  6142. * var clipRect = renderer.clipRect(100, 100, 100, 100);
  6143. *
  6144. * // Leave only the lower right quarter visible
  6145. * circle.clip(clipRect);
  6146. *
  6147. * @typedef {Highcharts.SVGElement} Highcharts.ClipRectElement
  6148. */
  6149. /**
  6150. * The font metrics.
  6151. *
  6152. * @interface Highcharts.FontMetricsObject
  6153. */ /**
  6154. * The baseline relative to the top of the box.
  6155. *
  6156. * @name Highcharts.FontMetricsObject#b
  6157. * @type {number}
  6158. */ /**
  6159. * The font size.
  6160. *
  6161. * @name Highcharts.FontMetricsObject#f
  6162. * @type {number}
  6163. */ /**
  6164. * The line height.
  6165. *
  6166. * @name Highcharts.FontMetricsObject#h
  6167. * @type {number}
  6168. */
  6169. /**
  6170. * An object containing `x` and `y` properties for the position of an element.
  6171. *
  6172. * @interface Highcharts.PositionObject
  6173. */ /**
  6174. * X position of the element.
  6175. * @name Highcharts.PositionObject#x
  6176. * @type {number}
  6177. */ /**
  6178. * Y position of the element.
  6179. * @name Highcharts.PositionObject#y
  6180. * @type {number}
  6181. */
  6182. /**
  6183. * A rectangle.
  6184. *
  6185. * @interface Highcharts.RectangleObject
  6186. */ /**
  6187. * Height of the rectangle.
  6188. * @name Highcharts.RectangleObject#height
  6189. * @type {number}
  6190. */ /**
  6191. * Width of the rectangle.
  6192. * @name Highcharts.RectangleObject#width
  6193. * @type {number}
  6194. */ /**
  6195. * Horizontal position of the rectangle.
  6196. * @name Highcharts.RectangleObject#x
  6197. * @type {number}
  6198. */ /**
  6199. * Vertical position of the rectangle.
  6200. * @name Highcharts.RectangleObject#y
  6201. * @type {number}
  6202. */
  6203. /**
  6204. * The shadow options.
  6205. *
  6206. * @interface Highcharts.ShadowOptionsObject
  6207. */ /**
  6208. * The shadow color.
  6209. * @name Highcharts.ShadowOptionsObject#color
  6210. * @type {Highcharts.ColorString|undefined}
  6211. * @default #000000
  6212. */ /**
  6213. * The horizontal offset from the element.
  6214. *
  6215. * @name Highcharts.ShadowOptionsObject#offsetX
  6216. * @type {number|undefined}
  6217. * @default 1
  6218. */ /**
  6219. * The vertical offset from the element.
  6220. * @name Highcharts.ShadowOptionsObject#offsetY
  6221. * @type {number|undefined}
  6222. * @default 1
  6223. */ /**
  6224. * The shadow opacity.
  6225. *
  6226. * @name Highcharts.ShadowOptionsObject#opacity
  6227. * @type {number|undefined}
  6228. * @default 0.15
  6229. */ /**
  6230. * The shadow width or distance from the element.
  6231. * @name Highcharts.ShadowOptionsObject#width
  6232. * @type {number|undefined}
  6233. * @default 3
  6234. */
  6235. /**
  6236. * @interface Highcharts.SizeObject
  6237. */ /**
  6238. * @name Highcharts.SizeObject#height
  6239. * @type {number}
  6240. */ /**
  6241. * @name Highcharts.SizeObject#width
  6242. * @type {number}
  6243. */
  6244. /**
  6245. * Serialized form of an SVG definition, including children. Some key
  6246. * property names are reserved: tagName, textContent, and children.
  6247. *
  6248. * @interface Highcharts.SVGDefinitionObject
  6249. */ /**
  6250. * @name Highcharts.SVGDefinitionObject#[key:string]
  6251. * @type {boolean|number|string|Array<Highcharts.SVGDefinitionObject>|undefined}
  6252. */ /**
  6253. * @name Highcharts.SVGDefinitionObject#children
  6254. * @type {Array<Highcharts.SVGDefinitionObject>|undefined}
  6255. */ /**
  6256. * @name Highcharts.SVGDefinitionObject#tagName
  6257. * @type {string|undefined}
  6258. */ /**
  6259. * @name Highcharts.SVGDefinitionObject#textContent
  6260. * @type {string|undefined}
  6261. */
  6262. /**
  6263. * Array of path commands, that will go into the `d` attribute of an SVG
  6264. * element.
  6265. *
  6266. * @typedef {Array<(Array<Highcharts.SVGPathCommand>|Array<Highcharts.SVGPathCommand,number>|Array<Highcharts.SVGPathCommand,number,number>|Array<Highcharts.SVGPathCommand,number,number,number,number>|Array<Highcharts.SVGPathCommand,number,number,number,number,number,number>|Array<Highcharts.SVGPathCommand,number,number,number,number,number,number,number>)>} Highcharts.SVGPathArray
  6267. */
  6268. /**
  6269. * Possible path commands in an SVG path array. Valid values are `A`, `C`, `H`,
  6270. * `L`, `M`, `Q`, `S`, `T`, `V`, `Z`.
  6271. *
  6272. * @typedef {string} Highcharts.SVGPathCommand
  6273. * @validvalue ["a","c","h","l","m","q","s","t","v","z","A","C","H","L","M","Q","S","T","V","Z"]
  6274. */
  6275. /**
  6276. * An extendable collection of functions for defining symbol paths. Symbols are
  6277. * used internally for point markers, button and label borders and backgrounds,
  6278. * or custom shapes. Extendable by adding to {@link SVGRenderer#symbols}.
  6279. *
  6280. * @interface Highcharts.SymbolDictionary
  6281. */ /**
  6282. * @name Highcharts.SymbolDictionary#[key:string]
  6283. * @type {Function|undefined}
  6284. */ /**
  6285. * @name Highcharts.SymbolDictionary#arc
  6286. * @type {Function|undefined}
  6287. */ /**
  6288. * @name Highcharts.SymbolDictionary#callout
  6289. * @type {Function|undefined}
  6290. */ /**
  6291. * @name Highcharts.SymbolDictionary#circle
  6292. * @type {Function|undefined}
  6293. */ /**
  6294. * @name Highcharts.SymbolDictionary#diamond
  6295. * @type {Function|undefined}
  6296. */ /**
  6297. * @name Highcharts.SymbolDictionary#square
  6298. * @type {Function|undefined}
  6299. */ /**
  6300. * @name Highcharts.SymbolDictionary#triangle
  6301. * @type {Function|undefined}
  6302. */
  6303. /**
  6304. * Can be one of `arc`, `callout`, `circle`, `diamond`, `square`, `triangle`,
  6305. * and `triangle-down`. Symbols are used internally for point markers, button
  6306. * and label borders and backgrounds, or custom shapes. Extendable by adding to
  6307. * {@link SVGRenderer#symbols}.
  6308. *
  6309. * @typedef {"arc"|"callout"|"circle"|"diamond"|"square"|"triangle"|"triangle-down"} Highcharts.SymbolKeyValue
  6310. */
  6311. /**
  6312. * Additional options, depending on the actual symbol drawn.
  6313. *
  6314. * @interface Highcharts.SymbolOptionsObject
  6315. */ /**
  6316. * The anchor X position for the `callout` symbol. This is where the chevron
  6317. * points to.
  6318. *
  6319. * @name Highcharts.SymbolOptionsObject#anchorX
  6320. * @type {number|undefined}
  6321. */ /**
  6322. * The anchor Y position for the `callout` symbol. This is where the chevron
  6323. * points to.
  6324. *
  6325. * @name Highcharts.SymbolOptionsObject#anchorY
  6326. * @type {number|undefined}
  6327. */ /**
  6328. * The end angle of an `arc` symbol.
  6329. *
  6330. * @name Highcharts.SymbolOptionsObject#end
  6331. * @type {number|undefined}
  6332. */ /**
  6333. * Whether to draw `arc` symbol open or closed.
  6334. *
  6335. * @name Highcharts.SymbolOptionsObject#open
  6336. * @type {boolean|undefined}
  6337. */ /**
  6338. * The radius of an `arc` symbol, or the border radius for the `callout` symbol.
  6339. *
  6340. * @name Highcharts.SymbolOptionsObject#r
  6341. * @type {number|undefined}
  6342. */ /**
  6343. * The start angle of an `arc` symbol.
  6344. *
  6345. * @name Highcharts.SymbolOptionsObject#start
  6346. * @type {number|undefined}
  6347. */
  6348. /* eslint-disable no-invalid-this, valid-jsdoc */
  6349. var charts = H.charts,
  6350. deg2rad = H.deg2rad,
  6351. doc = H.doc,
  6352. isFirefox = H.isFirefox,
  6353. isMS = H.isMS,
  6354. isWebKit = H.isWebKit,
  6355. noop = H.noop,
  6356. svg = H.svg,
  6357. SVG_NS = H.SVG_NS,
  6358. symbolSizes = H.symbolSizes,
  6359. win = H.win;
  6360. /**
  6361. * Allows direct access to the Highcharts rendering layer in order to draw
  6362. * primitive shapes like circles, rectangles, paths or text directly on a chart,
  6363. * or independent from any chart. The SVGRenderer represents a wrapper object
  6364. * for SVG in modern browsers. Through the VMLRenderer, part of the `oldie.js`
  6365. * module, it also brings vector graphics to IE <= 8.
  6366. *
  6367. * An existing chart's renderer can be accessed through {@link Chart.renderer}.
  6368. * The renderer can also be used completely decoupled from a chart.
  6369. *
  6370. * @sample highcharts/members/renderer-on-chart
  6371. * Annotating a chart programmatically.
  6372. * @sample highcharts/members/renderer-basic
  6373. * Independent SVG drawing.
  6374. *
  6375. * @example
  6376. * // Use directly without a chart object.
  6377. * var renderer = new Highcharts.Renderer(parentNode, 600, 400);
  6378. *
  6379. * @class
  6380. * @name Highcharts.SVGRenderer
  6381. *
  6382. * @param {Highcharts.HTMLDOMElement} container
  6383. * Where to put the SVG in the web page.
  6384. *
  6385. * @param {number} width
  6386. * The width of the SVG.
  6387. *
  6388. * @param {number} height
  6389. * The height of the SVG.
  6390. *
  6391. * @param {Highcharts.CSSObject} [style]
  6392. * The box style, if not in styleMode
  6393. *
  6394. * @param {boolean} [forExport=false]
  6395. * Whether the rendered content is intended for export.
  6396. *
  6397. * @param {boolean} [allowHTML=true]
  6398. * Whether the renderer is allowed to include HTML text, which will be
  6399. * projected on top of the SVG.
  6400. *
  6401. * @param {boolean} [styledMode=false]
  6402. * Whether the renderer belongs to a chart that is in styled mode.
  6403. * If it does, it will avoid setting presentational attributes in
  6404. * some cases, but not when set explicitly through `.attr` and `.css`
  6405. * etc.
  6406. */
  6407. var SVGRenderer = /** @class */ (function () {
  6408. /* *
  6409. *
  6410. * Constructors
  6411. *
  6412. * */
  6413. function SVGRenderer(container, width, height, style, forExport, allowHTML, styledMode) {
  6414. /* *
  6415. *
  6416. * Properties
  6417. *
  6418. * */
  6419. this.alignedObjects = void 0;
  6420. /**
  6421. * The root `svg` node of the renderer.
  6422. *
  6423. * @name Highcharts.SVGRenderer#box
  6424. * @type {Highcharts.SVGDOMElement}
  6425. */
  6426. this.box = void 0;
  6427. /**
  6428. * The wrapper for the root `svg` node of the renderer.
  6429. *
  6430. * @name Highcharts.SVGRenderer#boxWrapper
  6431. * @type {Highcharts.SVGElement}
  6432. */
  6433. this.boxWrapper = void 0;
  6434. this.cache = void 0;
  6435. this.cacheKeys = void 0;
  6436. this.chartIndex = void 0;
  6437. /**
  6438. * A pointer to the `defs` node of the root SVG.
  6439. *
  6440. * @name Highcharts.SVGRenderer#defs
  6441. * @type {Highcharts.SVGElement}
  6442. */
  6443. this.defs = void 0;
  6444. this.globalAnimation = void 0;
  6445. this.gradients = void 0;
  6446. this.height = void 0;
  6447. this.imgCount = void 0;
  6448. this.isSVG = void 0;
  6449. this.style = void 0;
  6450. /**
  6451. * Page url used for internal references.
  6452. *
  6453. * @private
  6454. * @name Highcharts.SVGRenderer#url
  6455. * @type {string}
  6456. */
  6457. this.url = void 0;
  6458. this.width = void 0;
  6459. this.init(container, width, height, style, forExport, allowHTML, styledMode);
  6460. }
  6461. /* *
  6462. *
  6463. * Functions
  6464. *
  6465. * */
  6466. /**
  6467. * Initialize the SVGRenderer. Overridable initializer function that takes
  6468. * the same parameters as the constructor.
  6469. *
  6470. * @function Highcharts.SVGRenderer#init
  6471. *
  6472. * @param {Highcharts.HTMLDOMElement} container
  6473. * Where to put the SVG in the web page.
  6474. *
  6475. * @param {number} width
  6476. * The width of the SVG.
  6477. *
  6478. * @param {number} height
  6479. * The height of the SVG.
  6480. *
  6481. * @param {Highcharts.CSSObject} [style]
  6482. * The box style, if not in styleMode
  6483. *
  6484. * @param {boolean} [forExport=false]
  6485. * Whether the rendered content is intended for export.
  6486. *
  6487. * @param {boolean} [allowHTML=true]
  6488. * Whether the renderer is allowed to include HTML text, which will be
  6489. * projected on top of the SVG.
  6490. *
  6491. * @param {boolean} [styledMode=false]
  6492. * Whether the renderer belongs to a chart that is in styled mode. If it
  6493. * does, it will avoid setting presentational attributes in some cases, but
  6494. * not when set explicitly through `.attr` and `.css` etc.
  6495. */
  6496. SVGRenderer.prototype.init = function (container, width, height, style, forExport, allowHTML, styledMode) {
  6497. var renderer = this,
  6498. boxWrapper,
  6499. element,
  6500. desc;
  6501. boxWrapper = renderer.createElement('svg')
  6502. .attr({
  6503. version: '1.1',
  6504. 'class': 'highcharts-root'
  6505. });
  6506. if (!styledMode) {
  6507. boxWrapper.css(this.getStyle(style));
  6508. }
  6509. element = boxWrapper.element;
  6510. container.appendChild(element);
  6511. // Always use ltr on the container, otherwise text-anchor will be
  6512. // flipped and text appear outside labels, buttons, tooltip etc (#3482)
  6513. attr(container, 'dir', 'ltr');
  6514. // For browsers other than IE, add the namespace attribute (#1978)
  6515. if (container.innerHTML.indexOf('xmlns') === -1) {
  6516. attr(element, 'xmlns', this.SVG_NS);
  6517. }
  6518. // object properties
  6519. renderer.isSVG = true;
  6520. this.box = element;
  6521. this.boxWrapper = boxWrapper;
  6522. renderer.alignedObjects = [];
  6523. // #24, #672, #1070
  6524. this.url = ((isFirefox || isWebKit) &&
  6525. doc.getElementsByTagName('base').length) ?
  6526. win.location.href
  6527. .split('#')[0] // remove the hash
  6528. .replace(/<[^>]*>/g, '') // wing cut HTML
  6529. // escape parantheses and quotes
  6530. .replace(/([\('\)])/g, '\\$1')
  6531. // replace spaces (needed for Safari only)
  6532. .replace(/ /g, '%20') :
  6533. '';
  6534. // Add description
  6535. desc = this.createElement('desc').add();
  6536. desc.element.appendChild(doc.createTextNode('Created with Highcharts 8.2.2'));
  6537. renderer.defs = this.createElement('defs').add();
  6538. renderer.allowHTML = allowHTML;
  6539. renderer.forExport = forExport;
  6540. renderer.styledMode = styledMode;
  6541. renderer.gradients = {}; // Object where gradient SvgElements are stored
  6542. renderer.cache = {}; // Cache for numerical bounding boxes
  6543. renderer.cacheKeys = [];
  6544. renderer.imgCount = 0;
  6545. renderer.setSize(width, height, false);
  6546. // Issue 110 workaround:
  6547. // In Firefox, if a div is positioned by percentage, its pixel position
  6548. // may land between pixels. The container itself doesn't display this,
  6549. // but an SVG element inside this container will be drawn at subpixel
  6550. // precision. In order to draw sharp lines, this must be compensated
  6551. // for. This doesn't seem to work inside iframes though (like in
  6552. // jsFiddle).
  6553. var subPixelFix,
  6554. rect;
  6555. if (isFirefox && container.getBoundingClientRect) {
  6556. subPixelFix = function () {
  6557. css(container, { left: 0, top: 0 });
  6558. rect = container.getBoundingClientRect();
  6559. css(container, {
  6560. left: (Math.ceil(rect.left) - rect.left) + 'px',
  6561. top: (Math.ceil(rect.top) - rect.top) + 'px'
  6562. });
  6563. };
  6564. // run the fix now
  6565. subPixelFix();
  6566. // run it on resize
  6567. renderer.unSubPixelFix = addEvent(win, 'resize', subPixelFix);
  6568. }
  6569. };
  6570. /**
  6571. * General method for adding a definition to the SVG `defs` tag. Can be used
  6572. * for gradients, fills, filters etc. Styled mode only. A hook for adding
  6573. * general definitions to the SVG's defs tag. Definitions can be referenced
  6574. * from the CSS by its `id`. Read more in
  6575. * [gradients, shadows and patterns](https://www.highcharts.com/docs/chart-design-and-style/gradients-shadows-and-patterns).
  6576. * Styled mode only.
  6577. *
  6578. * @function Highcharts.SVGRenderer#definition
  6579. *
  6580. * @param {Highcharts.SVGDefinitionObject} def
  6581. * A serialized form of an SVG definition, including children.
  6582. *
  6583. * @return {Highcharts.SVGElement}
  6584. * The inserted node.
  6585. */
  6586. SVGRenderer.prototype.definition = function (def) {
  6587. var ren = this;
  6588. /**
  6589. * @private
  6590. * @param {Highcharts.SVGDefinitionObject} config - SVG definition
  6591. * @param {Highcharts.SVGElement} [parent] - parent node
  6592. */
  6593. function recurse(config, parent) {
  6594. var ret;
  6595. splat(config).forEach(function (item) {
  6596. var node = ren.createElement(item.tagName),
  6597. attr = {};
  6598. // Set attributes
  6599. objectEach(item, function (val, key) {
  6600. if (key !== 'tagName' &&
  6601. key !== 'children' &&
  6602. key !== 'textContent') {
  6603. attr[key] = val;
  6604. }
  6605. });
  6606. node.attr(attr);
  6607. // Add to the tree
  6608. node.add(parent || ren.defs);
  6609. // Add text content
  6610. if (item.textContent) {
  6611. node.element.appendChild(doc.createTextNode(item.textContent));
  6612. }
  6613. // Recurse
  6614. recurse(item.children || [], node);
  6615. ret = node;
  6616. });
  6617. // Return last node added (on top level it's the only one)
  6618. return ret;
  6619. }
  6620. return recurse(def);
  6621. };
  6622. /**
  6623. * Get the global style setting for the renderer.
  6624. *
  6625. * @private
  6626. * @function Highcharts.SVGRenderer#getStyle
  6627. *
  6628. * @param {Highcharts.CSSObject} style
  6629. * Style settings.
  6630. *
  6631. * @return {Highcharts.CSSObject}
  6632. * The style settings mixed with defaults.
  6633. */
  6634. SVGRenderer.prototype.getStyle = function (style) {
  6635. this.style = extend({
  6636. fontFamily: '"Lucida Grande", "Lucida Sans Unicode", ' +
  6637. 'Arial, Helvetica, sans-serif',
  6638. fontSize: '12px'
  6639. }, style);
  6640. return this.style;
  6641. };
  6642. /**
  6643. * Apply the global style on the renderer, mixed with the default styles.
  6644. *
  6645. * @function Highcharts.SVGRenderer#setStyle
  6646. *
  6647. * @param {Highcharts.CSSObject} style
  6648. * CSS to apply.
  6649. */
  6650. SVGRenderer.prototype.setStyle = function (style) {
  6651. this.boxWrapper.css(this.getStyle(style));
  6652. };
  6653. /**
  6654. * Detect whether the renderer is hidden. This happens when one of the
  6655. * parent elements has `display: none`. Used internally to detect when we
  6656. * needto render preliminarily in another div to get the text bounding boxes
  6657. * right.
  6658. *
  6659. * @function Highcharts.SVGRenderer#isHidden
  6660. *
  6661. * @return {boolean}
  6662. * True if it is hidden.
  6663. */
  6664. SVGRenderer.prototype.isHidden = function () {
  6665. return !this.boxWrapper.getBBox().width;
  6666. };
  6667. /**
  6668. * Destroys the renderer and its allocated members.
  6669. *
  6670. * @function Highcharts.SVGRenderer#destroy
  6671. *
  6672. * @return {null}
  6673. */
  6674. SVGRenderer.prototype.destroy = function () {
  6675. var renderer = this,
  6676. rendererDefs = renderer.defs;
  6677. renderer.box = null;
  6678. renderer.boxWrapper = renderer.boxWrapper.destroy();
  6679. // Call destroy on all gradient elements
  6680. destroyObjectProperties(renderer.gradients || {});
  6681. renderer.gradients = null;
  6682. // Defs are null in VMLRenderer
  6683. // Otherwise, destroy them here.
  6684. if (rendererDefs) {
  6685. renderer.defs = rendererDefs.destroy();
  6686. }
  6687. // Remove sub pixel fix handler (#982)
  6688. if (renderer.unSubPixelFix) {
  6689. renderer.unSubPixelFix();
  6690. }
  6691. renderer.alignedObjects = null;
  6692. return null;
  6693. };
  6694. /**
  6695. * Create a wrapper for an SVG element. Serves as a factory for
  6696. * {@link SVGElement}, but this function is itself mostly called from
  6697. * primitive factories like {@link SVGRenderer#path}, {@link
  6698. * SVGRenderer#rect} or {@link SVGRenderer#text}.
  6699. *
  6700. * @function Highcharts.SVGRenderer#createElement
  6701. *
  6702. * @param {string} nodeName
  6703. * The node name, for example `rect`, `g` etc.
  6704. *
  6705. * @return {Highcharts.SVGElement}
  6706. * The generated SVGElement.
  6707. */
  6708. SVGRenderer.prototype.createElement = function (nodeName) {
  6709. var wrapper = new this.Element();
  6710. wrapper.init(this, nodeName);
  6711. return wrapper;
  6712. };
  6713. /**
  6714. * Get converted radial gradient attributes according to the radial
  6715. * reference. Used internally from the {@link SVGElement#colorGradient}
  6716. * function.
  6717. *
  6718. * @private
  6719. * @function Highcharts.SVGRenderer#getRadialAttr
  6720. */
  6721. SVGRenderer.prototype.getRadialAttr = function (radialReference, gradAttr) {
  6722. return {
  6723. cx: (radialReference[0] - radialReference[2] / 2) +
  6724. gradAttr.cx * radialReference[2],
  6725. cy: (radialReference[1] - radialReference[2] / 2) +
  6726. gradAttr.cy * radialReference[2],
  6727. r: gradAttr.r * radialReference[2]
  6728. };
  6729. };
  6730. /**
  6731. * Truncate the text node contents to a given length. Used when the css
  6732. * width is set. If the `textOverflow` is `ellipsis`, the text is truncated
  6733. * character by character to the given length. If not, the text is
  6734. * word-wrapped line by line.
  6735. *
  6736. * @private
  6737. * @function Highcharts.SVGRenderer#truncate
  6738. *
  6739. * @return {boolean}
  6740. * True if tspan is too long.
  6741. */
  6742. SVGRenderer.prototype.truncate = function (wrapper, tspan, text, words, startAt, width, getString) {
  6743. var renderer = this,
  6744. rotation = wrapper.rotation,
  6745. str,
  6746. // Word wrap can not be truncated to shorter than one word, ellipsis
  6747. // text can be completely blank.
  6748. minIndex = words ? 1 : 0,
  6749. maxIndex = (text || words).length,
  6750. currentIndex = maxIndex,
  6751. // Cache the lengths to avoid checking the same twice
  6752. lengths = [],
  6753. updateTSpan = function (s) {
  6754. if (tspan.firstChild) {
  6755. tspan.removeChild(tspan.firstChild);
  6756. }
  6757. if (s) {
  6758. tspan.appendChild(doc.createTextNode(s));
  6759. }
  6760. }, getSubStringLength = function (charEnd, concatenatedEnd) {
  6761. // charEnd is useed when finding the character-by-character
  6762. // break for ellipsis, concatenatedEnd is used for word-by-word
  6763. // break for word wrapping.
  6764. var end = concatenatedEnd || charEnd;
  6765. if (typeof lengths[end] === 'undefined') {
  6766. // Modern browsers
  6767. if (tspan.getSubStringLength) {
  6768. // Fails with DOM exception on unit-tests/legend/members
  6769. // of unknown reason. Desired width is 0, text content
  6770. // is "5" and end is 1.
  6771. try {
  6772. lengths[end] = startAt +
  6773. tspan.getSubStringLength(0, words ? end + 1 : end);
  6774. }
  6775. catch (e) {
  6776. '';
  6777. }
  6778. // Legacy
  6779. }
  6780. else if (renderer.getSpanWidth) { // #9058 jsdom
  6781. updateTSpan(getString(text || words, charEnd));
  6782. lengths[end] = startAt +
  6783. renderer.getSpanWidth(wrapper, tspan);
  6784. }
  6785. }
  6786. return lengths[end];
  6787. }, actualWidth, truncated;
  6788. wrapper.rotation = 0; // discard rotation when computing box
  6789. actualWidth = getSubStringLength(tspan.textContent.length);
  6790. truncated = startAt + actualWidth > width;
  6791. if (truncated) {
  6792. // Do a binary search for the index where to truncate the text
  6793. while (minIndex <= maxIndex) {
  6794. currentIndex = Math.ceil((minIndex + maxIndex) / 2);
  6795. // When checking words for word-wrap, we need to build the
  6796. // string and measure the subStringLength at the concatenated
  6797. // word length.
  6798. if (words) {
  6799. str = getString(words, currentIndex);
  6800. }
  6801. actualWidth = getSubStringLength(currentIndex, str && str.length - 1);
  6802. if (minIndex === maxIndex) {
  6803. // Complete
  6804. minIndex = maxIndex + 1;
  6805. }
  6806. else if (actualWidth > width) {
  6807. // Too large. Set max index to current.
  6808. maxIndex = currentIndex - 1;
  6809. }
  6810. else {
  6811. // Within width. Set min index to current.
  6812. minIndex = currentIndex;
  6813. }
  6814. }
  6815. // If max index was 0 it means the shortest possible text was also
  6816. // too large. For ellipsis that means only the ellipsis, while for
  6817. // word wrap it means the whole first word.
  6818. if (maxIndex === 0) {
  6819. // Remove ellipsis
  6820. updateTSpan('');
  6821. // If the new text length is one less than the original, we don't
  6822. // need the ellipsis
  6823. }
  6824. else if (!(text && maxIndex === text.length - 1)) {
  6825. updateTSpan(str || getString(text || words, currentIndex));
  6826. }
  6827. }
  6828. // When doing line wrapping, prepare for the next line by removing the
  6829. // items from this line.
  6830. if (words) {
  6831. words.splice(0, currentIndex);
  6832. }
  6833. wrapper.actualWidth = actualWidth;
  6834. wrapper.rotation = rotation; // Apply rotation again.
  6835. return truncated;
  6836. };
  6837. /**
  6838. * Parse a simple HTML string into SVG tspans. Called internally when text
  6839. * is set on an SVGElement. The function supports a subset of HTML tags, CSS
  6840. * text features like `width`, `text-overflow`, `white-space`, and also
  6841. * attributes like `href` and `style`.
  6842. *
  6843. * @private
  6844. * @function Highcharts.SVGRenderer#buildText
  6845. *
  6846. * @param {Highcharts.SVGElement} wrapper
  6847. * The parent SVGElement.
  6848. */
  6849. SVGRenderer.prototype.buildText = function (wrapper) {
  6850. 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) {
  6851. var fontSizeStyle;
  6852. if (!renderer.styledMode) {
  6853. fontSizeStyle =
  6854. /(px|em)$/.test(tspan && tspan.style.fontSize) ?
  6855. tspan.style.fontSize :
  6856. (fontSize || renderer.style.fontSize || 12);
  6857. }
  6858. return textLineHeight ?
  6859. pInt(textLineHeight) :
  6860. renderer.fontMetrics(fontSizeStyle,
  6861. // Get the computed size from parent if not explicit
  6862. (tspan.getAttribute('style') ? tspan : textNode)).h;
  6863. }, unescapeEntities = function (inputStr, except) {
  6864. objectEach(renderer.escapes, function (value, key) {
  6865. if (!except || except.indexOf(value) === -1) {
  6866. inputStr = inputStr.toString().replace(new RegExp(value, 'g'), key);
  6867. }
  6868. });
  6869. return inputStr;
  6870. }, parseAttribute = function (s, attr) {
  6871. var start,
  6872. delimiter;
  6873. start = s.indexOf('<');
  6874. s = s.substring(start, s.indexOf('>') - start);
  6875. start = s.indexOf(attr + '=');
  6876. if (start !== -1) {
  6877. start = start + attr.length + 1;
  6878. delimiter = s.charAt(start);
  6879. if (delimiter === '"' || delimiter === "'") { // eslint-disable-line quotes
  6880. s = s.substring(start + 1);
  6881. return s.substring(0, s.indexOf(delimiter));
  6882. }
  6883. }
  6884. };
  6885. var regexMatchBreaks = /<br.*?>/g;
  6886. // The buildText code is quite heavy, so if we're not changing something
  6887. // that affects the text, skip it (#6113).
  6888. textCache = [
  6889. textStr,
  6890. ellipsis,
  6891. noWrap,
  6892. textLineHeight,
  6893. textOutline,
  6894. fontSize,
  6895. width
  6896. ].join(',');
  6897. if (textCache === wrapper.textCache) {
  6898. return;
  6899. }
  6900. wrapper.textCache = textCache;
  6901. // Remove old text
  6902. while (i--) {
  6903. textNode.removeChild(childNodes[i]);
  6904. }
  6905. // Skip tspans, add text directly to text node. The forceTSpan is a hook
  6906. // used in text outline hack.
  6907. if (!hasMarkup &&
  6908. !textOutline &&
  6909. !ellipsis &&
  6910. !width &&
  6911. (textStr.indexOf(' ') === -1 ||
  6912. (noWrap && !regexMatchBreaks.test(textStr)))) {
  6913. textNode.appendChild(doc.createTextNode(unescapeEntities(textStr)));
  6914. // Complex strings, add more logic
  6915. }
  6916. else {
  6917. if (tempParent) {
  6918. // attach it to the DOM to read offset width
  6919. tempParent.appendChild(textNode);
  6920. }
  6921. if (hasMarkup) {
  6922. lines = renderer.styledMode ? (textStr
  6923. .replace(/<(b|strong)>/g, '<span class="highcharts-strong">')
  6924. .replace(/<(i|em)>/g, '<span class="highcharts-emphasized">')) : (textStr
  6925. .replace(/<(b|strong)>/g, '<span style="font-weight:bold">')
  6926. .replace(/<(i|em)>/g, '<span style="font-style:italic">'));
  6927. lines = lines
  6928. .replace(/<a/g, '<span')
  6929. .replace(/<\/(b|strong|i|em|a)>/g, '</span>')
  6930. .split(regexMatchBreaks);
  6931. }
  6932. else {
  6933. lines = [textStr];
  6934. }
  6935. // Trim empty lines (#5261)
  6936. lines = lines.filter(function (line) {
  6937. return line !== '';
  6938. });
  6939. // build the lines
  6940. lines.forEach(function (line, lineNo) {
  6941. var spans,
  6942. spanNo = 0,
  6943. lineLength = 0;
  6944. line = line
  6945. // Trim to prevent useless/costly process on the spaces
  6946. // (#5258)
  6947. .replace(/^\s+|\s+$/g, '')
  6948. .replace(/<span/g, '|||<span')
  6949. .replace(/<\/span>/g, '</span>|||');
  6950. spans = line.split('|||');
  6951. spans.forEach(function buildTextSpans(span) {
  6952. if (span !== '' || spans.length === 1) {
  6953. var attributes = {},
  6954. tspan = doc.createElementNS(renderer.SVG_NS, 'tspan'),
  6955. a,
  6956. classAttribute,
  6957. styleAttribute, // #390
  6958. hrefAttribute;
  6959. classAttribute = parseAttribute(span, 'class');
  6960. if (classAttribute) {
  6961. attr(tspan, 'class', classAttribute);
  6962. }
  6963. styleAttribute = parseAttribute(span, 'style');
  6964. if (styleAttribute) {
  6965. styleAttribute = styleAttribute.replace(/(;| |^)color([ :])/, '$1fill$2');
  6966. attr(tspan, 'style', styleAttribute);
  6967. }
  6968. // For anchors, wrap the tspan in an <a> tag and apply
  6969. // the href attribute as is (#13559). Not for export
  6970. // (#1529)
  6971. hrefAttribute = parseAttribute(span, 'href');
  6972. if (hrefAttribute && !forExport) {
  6973. if (
  6974. // Stop JavaScript links, vulnerable to XSS
  6975. hrefAttribute.split(':')[0].toLowerCase()
  6976. .indexOf('javascript') === -1) {
  6977. a = doc.createElementNS(renderer.SVG_NS, 'a');
  6978. attr(a, 'href', hrefAttribute);
  6979. attr(tspan, 'class', 'highcharts-anchor');
  6980. a.appendChild(tspan);
  6981. if (!renderer.styledMode) {
  6982. css(tspan, { cursor: 'pointer' });
  6983. }
  6984. }
  6985. }
  6986. // Strip away unsupported HTML tags (#7126)
  6987. span = unescapeEntities(span.replace(/<[a-zA-Z\/](.|\n)*?>/g, '') || ' ');
  6988. // Nested tags aren't supported, and cause crash in
  6989. // Safari (#1596)
  6990. if (span !== ' ') {
  6991. // add the text node
  6992. tspan.appendChild(doc.createTextNode(span));
  6993. // First span in a line, align it to the left
  6994. if (!spanNo) {
  6995. if (lineNo && parentX !== null) {
  6996. attributes.x = parentX;
  6997. }
  6998. }
  6999. else {
  7000. attributes.dx = 0; // #16
  7001. }
  7002. // add attributes
  7003. attr(tspan, attributes);
  7004. // Append it
  7005. textNode.appendChild(a || tspan);
  7006. // first span on subsequent line, add the line
  7007. // height
  7008. if (!spanNo && isSubsequentLine) {
  7009. // allow getting the right offset height in
  7010. // exporting in IE
  7011. if (!svg && forExport) {
  7012. css(tspan, { display: 'block' });
  7013. }
  7014. // Set the line height based on the font size of
  7015. // either the text element or the tspan element
  7016. attr(tspan, 'dy', getLineHeight(tspan));
  7017. }
  7018. // Check width and apply soft breaks or ellipsis
  7019. if (width) {
  7020. var words = span.replace(/([^\^])-/g, '$1- ').split(' '), // #1273
  7021. hasWhiteSpace = !noWrap && (spans.length > 1 ||
  7022. lineNo ||
  7023. words.length > 1),
  7024. wrapLineNo = 0,
  7025. dy = getLineHeight(tspan);
  7026. if (ellipsis) {
  7027. truncated = renderer.truncate(wrapper, tspan, span, void 0, 0,
  7028. // Target width
  7029. Math.max(0,
  7030. // Substract the font face to make
  7031. // room for the ellipsis itself
  7032. width - parseInt(fontSize || 12, 10)),
  7033. // Build the text to test for
  7034. function (text, currentIndex) {
  7035. return text.substring(0, currentIndex) + '\u2026';
  7036. });
  7037. }
  7038. else if (hasWhiteSpace) {
  7039. while (words.length) {
  7040. // For subsequent lines, create tspans
  7041. // with the same style attributes as the
  7042. // parent text node.
  7043. if (words.length &&
  7044. !noWrap &&
  7045. wrapLineNo > 0) {
  7046. tspan = doc.createElementNS(SVG_NS, 'tspan');
  7047. attr(tspan, {
  7048. dy: dy,
  7049. x: parentX
  7050. });
  7051. if (styleAttribute) { // #390
  7052. attr(tspan, 'style', styleAttribute);
  7053. }
  7054. // Start by appending the full
  7055. // remaining text
  7056. tspan.appendChild(doc.createTextNode(words.join(' ')
  7057. .replace(/- /g, '-')));
  7058. textNode.appendChild(tspan);
  7059. }
  7060. // For each line, truncate the remaining
  7061. // words into the line length.
  7062. renderer.truncate(wrapper, tspan, null, words, wrapLineNo === 0 ? lineLength : 0, width,
  7063. // Build the text to test for
  7064. function (text, currentIndex) {
  7065. return words
  7066. .slice(0, currentIndex)
  7067. .join(' ')
  7068. .replace(/- /g, '-');
  7069. });
  7070. lineLength = wrapper.actualWidth;
  7071. wrapLineNo++;
  7072. }
  7073. }
  7074. }
  7075. spanNo++;
  7076. }
  7077. }
  7078. });
  7079. // To avoid beginning lines that doesn't add to the textNode
  7080. // (#6144)
  7081. isSubsequentLine = (isSubsequentLine ||
  7082. textNode.childNodes.length);
  7083. });
  7084. if (ellipsis && truncated) {
  7085. wrapper.attr('title', unescapeEntities(wrapper.textStr || '', ['&lt;', '&gt;']) // #7179
  7086. );
  7087. }
  7088. if (tempParent) {
  7089. tempParent.removeChild(textNode);
  7090. }
  7091. // Apply the text outline
  7092. if (isString(textOutline) && wrapper.applyTextOutline) {
  7093. wrapper.applyTextOutline(textOutline);
  7094. }
  7095. }
  7096. };
  7097. /**
  7098. * Returns white for dark colors and black for bright colors.
  7099. *
  7100. * @function Highcharts.SVGRenderer#getContrast
  7101. *
  7102. * @param {Highcharts.ColorString} rgba
  7103. * The color to get the contrast for.
  7104. *
  7105. * @return {Highcharts.ColorString}
  7106. * The contrast color, either `#000000` or `#FFFFFF`.
  7107. */
  7108. SVGRenderer.prototype.getContrast = function (rgba) {
  7109. rgba = Color.parse(rgba).rgba;
  7110. // The threshold may be discussed. Here's a proposal for adding
  7111. // different weight to the color channels (#6216)
  7112. rgba[0] *= 1; // red
  7113. rgba[1] *= 1.2; // green
  7114. rgba[2] *= 0.5; // blue
  7115. return rgba[0] + rgba[1] + rgba[2] >
  7116. 1.8 * 255 ?
  7117. '#000000' :
  7118. '#FFFFFF';
  7119. };
  7120. /**
  7121. * Create a button with preset states.
  7122. *
  7123. * @function Highcharts.SVGRenderer#button
  7124. *
  7125. * @param {string} text
  7126. * The text or HTML to draw.
  7127. *
  7128. * @param {number} x
  7129. * The x position of the button's left side.
  7130. *
  7131. * @param {number} y
  7132. * The y position of the button's top side.
  7133. *
  7134. * @param {Highcharts.EventCallbackFunction<Highcharts.SVGElement>} callback
  7135. * The function to execute on button click or touch.
  7136. *
  7137. * @param {Highcharts.SVGAttributes} [normalState]
  7138. * SVG attributes for the normal state.
  7139. *
  7140. * @param {Highcharts.SVGAttributes} [hoverState]
  7141. * SVG attributes for the hover state.
  7142. *
  7143. * @param {Highcharts.SVGAttributes} [pressedState]
  7144. * SVG attributes for the pressed state.
  7145. *
  7146. * @param {Highcharts.SVGAttributes} [disabledState]
  7147. * SVG attributes for the disabled state.
  7148. *
  7149. * @param {Highcharts.SymbolKeyValue} [shape=rect]
  7150. * The shape type.
  7151. *
  7152. * @param {boolean} [useHTML=false]
  7153. * Wether to use HTML to render the label.
  7154. *
  7155. * @return {Highcharts.SVGElement}
  7156. * The button element.
  7157. */
  7158. SVGRenderer.prototype.button = function (text, x, y, callback, normalState, hoverState, pressedState, disabledState, shape, useHTML) {
  7159. var label = this.label(text,
  7160. x,
  7161. y,
  7162. shape,
  7163. void 0,
  7164. void 0,
  7165. useHTML,
  7166. void 0, 'button'),
  7167. curState = 0,
  7168. styledMode = this.styledMode,
  7169. // Make a copy of normalState (#13798)
  7170. // (reference to options.rangeSelector.buttonTheme)
  7171. normalState = normalState ? merge(normalState) : normalState,
  7172. userNormalStyle = normalState && normalState.style || {};
  7173. // Remove stylable attributes
  7174. if (normalState && normalState.style) {
  7175. delete normalState.style;
  7176. }
  7177. // Default, non-stylable attributes
  7178. label.attr(merge({ padding: 8, r: 2 }, normalState));
  7179. if (!styledMode) {
  7180. // Presentational
  7181. var normalStyle,
  7182. hoverStyle,
  7183. pressedStyle,
  7184. disabledStyle;
  7185. // Normal state - prepare the attributes
  7186. normalState = merge({
  7187. fill: '#f7f7f7',
  7188. stroke: '#cccccc',
  7189. 'stroke-width': 1,
  7190. style: {
  7191. color: '#333333',
  7192. cursor: 'pointer',
  7193. fontWeight: 'normal'
  7194. }
  7195. }, {
  7196. style: userNormalStyle
  7197. }, normalState);
  7198. normalStyle = normalState.style;
  7199. delete normalState.style;
  7200. // Hover state
  7201. hoverState = merge(normalState, {
  7202. fill: '#e6e6e6'
  7203. }, hoverState);
  7204. hoverStyle = hoverState.style;
  7205. delete hoverState.style;
  7206. // Pressed state
  7207. pressedState = merge(normalState, {
  7208. fill: '#e6ebf5',
  7209. style: {
  7210. color: '#000000',
  7211. fontWeight: 'bold'
  7212. }
  7213. }, pressedState);
  7214. pressedStyle = pressedState.style;
  7215. delete pressedState.style;
  7216. // Disabled state
  7217. disabledState = merge(normalState, {
  7218. style: {
  7219. color: '#cccccc'
  7220. }
  7221. }, disabledState);
  7222. disabledStyle = disabledState.style;
  7223. delete disabledState.style;
  7224. }
  7225. // Add the events. IE9 and IE10 need mouseover and mouseout to funciton
  7226. // (#667).
  7227. addEvent(label.element, isMS ? 'mouseover' : 'mouseenter', function () {
  7228. if (curState !== 3) {
  7229. label.setState(1);
  7230. }
  7231. });
  7232. addEvent(label.element, isMS ? 'mouseout' : 'mouseleave', function () {
  7233. if (curState !== 3) {
  7234. label.setState(curState);
  7235. }
  7236. });
  7237. label.setState = function (state) {
  7238. // Hover state is temporary, don't record it
  7239. if (state !== 1) {
  7240. label.state = curState = state;
  7241. }
  7242. // Update visuals
  7243. label
  7244. .removeClass(/highcharts-button-(normal|hover|pressed|disabled)/)
  7245. .addClass('highcharts-button-' +
  7246. ['normal', 'hover', 'pressed', 'disabled'][state || 0]);
  7247. if (!styledMode) {
  7248. label
  7249. .attr([
  7250. normalState,
  7251. hoverState,
  7252. pressedState,
  7253. disabledState
  7254. ][state || 0])
  7255. .css([
  7256. normalStyle,
  7257. hoverStyle,
  7258. pressedStyle,
  7259. disabledStyle
  7260. ][state || 0]);
  7261. }
  7262. };
  7263. // Presentational attributes
  7264. if (!styledMode) {
  7265. label
  7266. .attr(normalState)
  7267. .css(extend({ cursor: 'default' }, normalStyle));
  7268. }
  7269. return label
  7270. .on('click', function (e) {
  7271. if (curState !== 3) {
  7272. callback.call(label, e);
  7273. }
  7274. });
  7275. };
  7276. /**
  7277. * Make a straight line crisper by not spilling out to neighbour pixels.
  7278. *
  7279. * @function Highcharts.SVGRenderer#crispLine
  7280. *
  7281. * @param {Highcharts.SVGPathArray} points
  7282. * The original points on the format `[['M', 0, 0], ['L', 100, 0]]`.
  7283. *
  7284. * @param {number} width
  7285. * The width of the line.
  7286. *
  7287. * @param {string} roundingFunction
  7288. * The rounding function name on the `Math` object, can be one of
  7289. * `round`, `floor` or `ceil`.
  7290. *
  7291. * @return {Highcharts.SVGPathArray}
  7292. * The original points array, but modified to render crisply.
  7293. */
  7294. SVGRenderer.prototype.crispLine = function (points, width, roundingFunction) {
  7295. if (roundingFunction === void 0) { roundingFunction = 'round'; }
  7296. var start = points[0];
  7297. var end = points[1];
  7298. // Normalize to a crisp line
  7299. if (start[1] === end[1]) {
  7300. // Substract due to #1129. Now bottom and left axis gridlines behave
  7301. // the same.
  7302. start[1] = end[1] =
  7303. Math[roundingFunction](start[1]) - (width % 2 / 2);
  7304. }
  7305. if (start[2] === end[2]) {
  7306. start[2] = end[2] =
  7307. Math[roundingFunction](start[2]) + (width % 2 / 2);
  7308. }
  7309. return points;
  7310. };
  7311. /**
  7312. * Draw a path, wraps the SVG `path` element.
  7313. *
  7314. * @sample highcharts/members/renderer-path-on-chart/
  7315. * Draw a path in a chart
  7316. * @sample highcharts/members/renderer-path/
  7317. * Draw a path independent from a chart
  7318. *
  7319. * @example
  7320. * var path = renderer.path(['M', 10, 10, 'L', 30, 30, 'z'])
  7321. * .attr({ stroke: '#ff00ff' })
  7322. * .add();
  7323. *
  7324. * @function Highcharts.SVGRenderer#path
  7325. *
  7326. * @param {Highcharts.SVGPathArray} [path]
  7327. * An SVG path definition in array form.
  7328. *
  7329. * @return {Highcharts.SVGElement}
  7330. * The generated wrapper element.
  7331. *
  7332. */ /**
  7333. * Draw a path, wraps the SVG `path` element.
  7334. *
  7335. * @function Highcharts.SVGRenderer#path
  7336. *
  7337. * @param {Highcharts.SVGAttributes} [attribs]
  7338. * The initial attributes.
  7339. *
  7340. * @return {Highcharts.SVGElement}
  7341. * The generated wrapper element.
  7342. */
  7343. SVGRenderer.prototype.path = function (path) {
  7344. var attribs = (this.styledMode ? {} : {
  7345. fill: 'none'
  7346. });
  7347. if (isArray(path)) {
  7348. attribs.d = path;
  7349. }
  7350. else if (isObject(path)) { // attributes
  7351. extend(attribs, path);
  7352. }
  7353. return this.createElement('path').attr(attribs);
  7354. };
  7355. /**
  7356. * Draw a circle, wraps the SVG `circle` element.
  7357. *
  7358. * @sample highcharts/members/renderer-circle/
  7359. * Drawing a circle
  7360. *
  7361. * @function Highcharts.SVGRenderer#circle
  7362. *
  7363. * @param {number} [x]
  7364. * The center x position.
  7365. *
  7366. * @param {number} [y]
  7367. * The center y position.
  7368. *
  7369. * @param {number} [r]
  7370. * The radius.
  7371. *
  7372. * @return {Highcharts.SVGElement}
  7373. * The generated wrapper element.
  7374. */ /**
  7375. * Draw a circle, wraps the SVG `circle` element.
  7376. *
  7377. * @function Highcharts.SVGRenderer#circle
  7378. *
  7379. * @param {Highcharts.SVGAttributes} [attribs]
  7380. * The initial attributes.
  7381. *
  7382. * @return {Highcharts.SVGElement}
  7383. * The generated wrapper element.
  7384. */
  7385. SVGRenderer.prototype.circle = function (x, y, r) {
  7386. var attribs = (isObject(x) ?
  7387. x :
  7388. typeof x === 'undefined' ? {} : { x: x, y: y, r: r }), wrapper = this.createElement('circle');
  7389. // Setting x or y translates to cx and cy
  7390. wrapper.xSetter = wrapper.ySetter = function (value, key, element) {
  7391. element.setAttribute('c' + key, value);
  7392. };
  7393. return wrapper.attr(attribs);
  7394. };
  7395. /**
  7396. * Draw and return an arc.
  7397. *
  7398. * @sample highcharts/members/renderer-arc/
  7399. * Drawing an arc
  7400. *
  7401. * @function Highcharts.SVGRenderer#arc
  7402. *
  7403. * @param {number} [x=0]
  7404. * Center X position.
  7405. *
  7406. * @param {number} [y=0]
  7407. * Center Y position.
  7408. *
  7409. * @param {number} [r=0]
  7410. * The outer radius' of the arc.
  7411. *
  7412. * @param {number} [innerR=0]
  7413. * Inner radius like used in donut charts.
  7414. *
  7415. * @param {number} [start=0]
  7416. * The starting angle of the arc in radians, where 0 is to the right and
  7417. * `-Math.PI/2` is up.
  7418. *
  7419. * @param {number} [end=0]
  7420. * The ending angle of the arc in radians, where 0 is to the right and
  7421. * `-Math.PI/2` is up.
  7422. *
  7423. * @return {Highcharts.SVGElement}
  7424. * The generated wrapper element.
  7425. */ /**
  7426. * Draw and return an arc. Overloaded function that takes arguments object.
  7427. *
  7428. * @function Highcharts.SVGRenderer#arc
  7429. *
  7430. * @param {Highcharts.SVGAttributes} attribs
  7431. * Initial SVG attributes.
  7432. *
  7433. * @return {Highcharts.SVGElement}
  7434. * The generated wrapper element.
  7435. */
  7436. SVGRenderer.prototype.arc = function (x, y, r, innerR, start, end) {
  7437. var arc,
  7438. options;
  7439. if (isObject(x)) {
  7440. options = x;
  7441. y = options.y;
  7442. r = options.r;
  7443. innerR = options.innerR;
  7444. start = options.start;
  7445. end = options.end;
  7446. x = options.x;
  7447. }
  7448. else {
  7449. options = {
  7450. innerR: innerR,
  7451. start: start,
  7452. end: end
  7453. };
  7454. }
  7455. // Arcs are defined as symbols for the ability to set
  7456. // attributes in attr and animate
  7457. arc = this.symbol('arc', x, y, r, r, options);
  7458. arc.r = r; // #959
  7459. return arc;
  7460. };
  7461. /**
  7462. * Draw and return a rectangle.
  7463. *
  7464. * @function Highcharts.SVGRenderer#rect
  7465. *
  7466. * @param {number} [x]
  7467. * Left position.
  7468. *
  7469. * @param {number} [y]
  7470. * Top position.
  7471. *
  7472. * @param {number} [width]
  7473. * Width of the rectangle.
  7474. *
  7475. * @param {number} [height]
  7476. * Height of the rectangle.
  7477. *
  7478. * @param {number} [r]
  7479. * Border corner radius.
  7480. *
  7481. * @param {number} [strokeWidth]
  7482. * A stroke width can be supplied to allow crisp drawing.
  7483. *
  7484. * @return {Highcharts.SVGElement}
  7485. * The generated wrapper element.
  7486. */ /**
  7487. * Draw and return a rectangle.
  7488. *
  7489. * @sample highcharts/members/renderer-rect-on-chart/
  7490. * Draw a rectangle in a chart
  7491. * @sample highcharts/members/renderer-rect/
  7492. * Draw a rectangle independent from a chart
  7493. *
  7494. * @function Highcharts.SVGRenderer#rect
  7495. *
  7496. * @param {Highcharts.SVGAttributes} [attributes]
  7497. * General SVG attributes for the rectangle.
  7498. *
  7499. * @return {Highcharts.SVGElement}
  7500. * The generated wrapper element.
  7501. */
  7502. SVGRenderer.prototype.rect = function (x, y, width, height, r, strokeWidth) {
  7503. r = isObject(x) ? x.r : r;
  7504. var wrapper = this.createElement('rect'),
  7505. attribs = isObject(x) ?
  7506. x :
  7507. typeof x === 'undefined' ?
  7508. {} :
  7509. {
  7510. x: x,
  7511. y: y,
  7512. width: Math.max(width, 0),
  7513. height: Math.max(height, 0)
  7514. };
  7515. if (!this.styledMode) {
  7516. if (typeof strokeWidth !== 'undefined') {
  7517. attribs.strokeWidth = strokeWidth;
  7518. attribs = wrapper.crisp(attribs);
  7519. }
  7520. attribs.fill = 'none';
  7521. }
  7522. if (r) {
  7523. attribs.r = r;
  7524. }
  7525. wrapper.rSetter = function (value, key, element) {
  7526. wrapper.r = value;
  7527. attr(element, {
  7528. rx: value,
  7529. ry: value
  7530. });
  7531. };
  7532. wrapper.rGetter = function () {
  7533. return wrapper.r;
  7534. };
  7535. return wrapper.attr(attribs);
  7536. };
  7537. /**
  7538. * Resize the {@link SVGRenderer#box} and re-align all aligned child
  7539. * elements.
  7540. *
  7541. * @sample highcharts/members/renderer-g/
  7542. * Show and hide grouped objects
  7543. *
  7544. * @function Highcharts.SVGRenderer#setSize
  7545. *
  7546. * @param {number} width
  7547. * The new pixel width.
  7548. *
  7549. * @param {number} height
  7550. * The new pixel height.
  7551. *
  7552. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animate=true]
  7553. * Whether and how to animate.
  7554. */
  7555. SVGRenderer.prototype.setSize = function (width, height, animate) {
  7556. var renderer = this,
  7557. alignedObjects = renderer.alignedObjects,
  7558. i = alignedObjects.length;
  7559. renderer.width = width;
  7560. renderer.height = height;
  7561. renderer.boxWrapper.animate({
  7562. width: width,
  7563. height: height
  7564. }, {
  7565. step: function () {
  7566. this.attr({
  7567. viewBox: '0 0 ' + this.attr('width') + ' ' +
  7568. this.attr('height')
  7569. });
  7570. },
  7571. duration: pick(animate, true) ? void 0 : 0
  7572. });
  7573. while (i--) {
  7574. alignedObjects[i].align();
  7575. }
  7576. };
  7577. /**
  7578. * Create and return an svg group element. Child
  7579. * {@link Highcharts.SVGElement} objects are added to the group by using the
  7580. * group as the first parameter in {@link Highcharts.SVGElement#add|add()}.
  7581. *
  7582. * @function Highcharts.SVGRenderer#g
  7583. *
  7584. * @param {string} [name]
  7585. * The group will be given a class name of `highcharts-{name}`. This
  7586. * can be used for styling and scripting.
  7587. *
  7588. * @return {Highcharts.SVGElement}
  7589. * The generated wrapper element.
  7590. */
  7591. SVGRenderer.prototype.g = function (name) {
  7592. var elem = this.createElement('g');
  7593. return name ?
  7594. elem.attr({ 'class': 'highcharts-' + name }) :
  7595. elem;
  7596. };
  7597. /**
  7598. * Display an image.
  7599. *
  7600. * @sample highcharts/members/renderer-image-on-chart/
  7601. * Add an image in a chart
  7602. * @sample highcharts/members/renderer-image/
  7603. * Add an image independent of a chart
  7604. *
  7605. * @function Highcharts.SVGRenderer#image
  7606. *
  7607. * @param {string} src
  7608. * The image source.
  7609. *
  7610. * @param {number} [x]
  7611. * The X position.
  7612. *
  7613. * @param {number} [y]
  7614. * The Y position.
  7615. *
  7616. * @param {number} [width]
  7617. * The image width. If omitted, it defaults to the image file width.
  7618. *
  7619. * @param {number} [height]
  7620. * The image height. If omitted it defaults to the image file
  7621. * height.
  7622. *
  7623. * @param {Function} [onload]
  7624. * Event handler for image load.
  7625. *
  7626. * @return {Highcharts.SVGElement}
  7627. * The generated wrapper element.
  7628. */
  7629. SVGRenderer.prototype.image = function (src, x, y, width, height, onload) {
  7630. var attribs = { preserveAspectRatio: 'none' }, elemWrapper, dummy, setSVGImageSource = function (el, src) {
  7631. // Set the href in the xlink namespace
  7632. if (el.setAttributeNS) {
  7633. el.setAttributeNS('http://www.w3.org/1999/xlink', 'href', src);
  7634. }
  7635. else {
  7636. // could be exporting in IE
  7637. // using href throws "not supported" in ie7 and under,
  7638. // requries regex shim to fix later
  7639. el.setAttribute('hc-svg-href', src);
  7640. }
  7641. }, onDummyLoad = function (e) {
  7642. setSVGImageSource(elemWrapper.element, src);
  7643. onload.call(elemWrapper, e);
  7644. };
  7645. // optional properties
  7646. if (arguments.length > 1) {
  7647. extend(attribs, {
  7648. x: x,
  7649. y: y,
  7650. width: width,
  7651. height: height
  7652. });
  7653. }
  7654. elemWrapper = this.createElement('image').attr(attribs);
  7655. // Add load event if supplied
  7656. if (onload) {
  7657. // We have to use a dummy HTML image since IE support for SVG image
  7658. // load events is very buggy. First set a transparent src, wait for
  7659. // dummy to load, and then add the real src to the SVG image.
  7660. setSVGImageSource(elemWrapper.element, 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==' /* eslint-disable-line */);
  7661. dummy = new win.Image();
  7662. addEvent(dummy, 'load', onDummyLoad);
  7663. dummy.src = src;
  7664. if (dummy.complete) {
  7665. onDummyLoad({});
  7666. }
  7667. }
  7668. else {
  7669. setSVGImageSource(elemWrapper.element, src);
  7670. }
  7671. return elemWrapper;
  7672. };
  7673. /**
  7674. * Draw a symbol out of pre-defined shape paths from
  7675. * {@link SVGRenderer#symbols}.
  7676. * It is used in Highcharts for point makers, which cake a `symbol` option,
  7677. * and label and button backgrounds like in the tooltip and stock flags.
  7678. *
  7679. * @function Highcharts.SVGRenderer#symbol
  7680. *
  7681. * @param {string} symbol
  7682. * The symbol name.
  7683. *
  7684. * @param {number} [x]
  7685. * The X coordinate for the top left position.
  7686. *
  7687. * @param {number} [y]
  7688. * The Y coordinate for the top left position.
  7689. *
  7690. * @param {number} [width]
  7691. * The pixel width.
  7692. *
  7693. * @param {number} [height]
  7694. * The pixel height.
  7695. *
  7696. * @param {Highcharts.SymbolOptionsObject} [options]
  7697. * Additional options, depending on the actual symbol drawn.
  7698. *
  7699. * @return {Highcharts.SVGElement}
  7700. */
  7701. SVGRenderer.prototype.symbol = function (symbol, x, y, width, height, options) {
  7702. var ren = this,
  7703. obj,
  7704. imageRegex = /^url\((.*?)\)$/,
  7705. isImage = imageRegex.test(symbol),
  7706. sym = (!isImage && (this.symbols[symbol] ? symbol : 'circle')),
  7707. // get the symbol definition function
  7708. symbolFn = (sym && this.symbols[sym]),
  7709. path,
  7710. imageSrc,
  7711. centerImage;
  7712. if (symbolFn) {
  7713. // Check if there's a path defined for this symbol
  7714. if (typeof x === 'number') {
  7715. path = symbolFn.call(this.symbols, Math.round(x || 0), Math.round(y || 0), width || 0, height || 0, options);
  7716. }
  7717. obj = this.path(path);
  7718. if (!ren.styledMode) {
  7719. obj.attr('fill', 'none');
  7720. }
  7721. // expando properties for use in animate and attr
  7722. extend(obj, {
  7723. symbolName: sym,
  7724. x: x,
  7725. y: y,
  7726. width: width,
  7727. height: height
  7728. });
  7729. if (options) {
  7730. extend(obj, options);
  7731. }
  7732. // Image symbols
  7733. }
  7734. else if (isImage) {
  7735. imageSrc = symbol.match(imageRegex)[1];
  7736. // Create the image synchronously, add attribs async
  7737. obj = this.image(imageSrc);
  7738. // The image width is not always the same as the symbol width. The
  7739. // image may be centered within the symbol, as is the case when
  7740. // image shapes are used as label backgrounds, for example in flags.
  7741. obj.imgwidth = pick(symbolSizes[imageSrc] && symbolSizes[imageSrc].width, options && options.width);
  7742. obj.imgheight = pick(symbolSizes[imageSrc] && symbolSizes[imageSrc].height, options && options.height);
  7743. /**
  7744. * Set the size and position
  7745. */
  7746. centerImage = function () {
  7747. obj.attr({
  7748. width: obj.width,
  7749. height: obj.height
  7750. });
  7751. };
  7752. /**
  7753. * Width and height setters that take both the image's physical size
  7754. * and the label size into consideration, and translates the image
  7755. * to center within the label.
  7756. */
  7757. ['width', 'height'].forEach(function (key) {
  7758. obj[key + 'Setter'] = function (value, key) {
  7759. var attribs = {}, imgSize = this['img' + key], trans = key === 'width' ? 'translateX' : 'translateY';
  7760. this[key] = value;
  7761. if (defined(imgSize)) {
  7762. // Scale and center the image within its container.
  7763. // The name `backgroundSize` is taken from the CSS spec,
  7764. // but the value `within` is made up. Other possible
  7765. // values in the spec, `cover` and `contain`, can be
  7766. // implemented if needed.
  7767. if (options &&
  7768. options.backgroundSize === 'within' &&
  7769. this.width &&
  7770. this.height) {
  7771. imgSize = Math.round(imgSize * Math.min(this.width / this.imgwidth, this.height / this.imgheight));
  7772. }
  7773. if (this.element) {
  7774. this.element.setAttribute(key, imgSize);
  7775. }
  7776. if (!this.alignByTranslate) {
  7777. attribs[trans] = ((this[key] || 0) - imgSize) / 2;
  7778. this.attr(attribs);
  7779. }
  7780. }
  7781. };
  7782. });
  7783. if (defined(x)) {
  7784. obj.attr({
  7785. x: x,
  7786. y: y
  7787. });
  7788. }
  7789. obj.isImg = true;
  7790. if (defined(obj.imgwidth) && defined(obj.imgheight)) {
  7791. centerImage();
  7792. }
  7793. else {
  7794. // Initialize image to be 0 size so export will still function
  7795. // if there's no cached sizes.
  7796. obj.attr({ width: 0, height: 0 });
  7797. // Create a dummy JavaScript image to get the width and height.
  7798. createElement('img', {
  7799. onload: function () {
  7800. var chart = charts[ren.chartIndex];
  7801. // Special case for SVGs on IE11, the width is not
  7802. // accessible until the image is part of the DOM
  7803. // (#2854).
  7804. if (this.width === 0) {
  7805. css(this, {
  7806. position: 'absolute',
  7807. top: '-999em'
  7808. });
  7809. doc.body.appendChild(this);
  7810. }
  7811. // Center the image
  7812. symbolSizes[imageSrc] = {
  7813. width: this.width,
  7814. height: this.height
  7815. };
  7816. obj.imgwidth = this.width;
  7817. obj.imgheight = this.height;
  7818. if (obj.element) {
  7819. centerImage();
  7820. }
  7821. // Clean up after #2854 workaround.
  7822. if (this.parentNode) {
  7823. this.parentNode.removeChild(this);
  7824. }
  7825. // Fire the load event when all external images are
  7826. // loaded
  7827. ren.imgCount--;
  7828. if (!ren.imgCount && chart && !chart.hasLoaded) {
  7829. chart.onload();
  7830. }
  7831. },
  7832. src: imageSrc
  7833. });
  7834. this.imgCount++;
  7835. }
  7836. }
  7837. return obj;
  7838. };
  7839. /**
  7840. * Define a clipping rectangle. The clipping rectangle is later applied
  7841. * to {@link SVGElement} objects through the {@link SVGElement#clip}
  7842. * function.
  7843. *
  7844. * @example
  7845. * var circle = renderer.circle(100, 100, 100)
  7846. * .attr({ fill: 'red' })
  7847. * .add();
  7848. * var clipRect = renderer.clipRect(100, 100, 100, 100);
  7849. *
  7850. * // Leave only the lower right quarter visible
  7851. * circle.clip(clipRect);
  7852. *
  7853. * @function Highcharts.SVGRenderer#clipRect
  7854. *
  7855. * @param {number} [x]
  7856. *
  7857. * @param {number} [y]
  7858. *
  7859. * @param {number} [width]
  7860. *
  7861. * @param {number} [height]
  7862. *
  7863. * @return {Highcharts.ClipRectElement}
  7864. * A clipping rectangle.
  7865. */
  7866. SVGRenderer.prototype.clipRect = function (x, y, width, height) {
  7867. var wrapper,
  7868. // Add a hyphen at the end to avoid confusion in testing indexes
  7869. // -1 and -10, -11 etc (#6550)
  7870. id = uniqueKey() + '-', clipPath = this.createElement('clipPath').attr({
  7871. id: id
  7872. }).add(this.defs);
  7873. wrapper = this.rect(x, y, width, height, 0).add(clipPath);
  7874. wrapper.id = id;
  7875. wrapper.clipPath = clipPath;
  7876. wrapper.count = 0;
  7877. return wrapper;
  7878. };
  7879. /**
  7880. * Draw text. The text can contain a subset of HTML, like spans and anchors
  7881. * and some basic text styling of these. For more advanced features like
  7882. * border and background, use {@link Highcharts.SVGRenderer#label} instead.
  7883. * To update the text after render, run `text.attr({ text: 'New text' })`.
  7884. *
  7885. * @sample highcharts/members/renderer-text-on-chart/
  7886. * Annotate the chart freely
  7887. * @sample highcharts/members/renderer-on-chart/
  7888. * Annotate with a border and in response to the data
  7889. * @sample highcharts/members/renderer-text/
  7890. * Formatted text
  7891. *
  7892. * @function Highcharts.SVGRenderer#text
  7893. *
  7894. * @param {string} [str]
  7895. * The text of (subset) HTML to draw.
  7896. *
  7897. * @param {number} [x]
  7898. * The x position of the text's lower left corner.
  7899. *
  7900. * @param {number} [y]
  7901. * The y position of the text's lower left corner.
  7902. *
  7903. * @param {boolean} [useHTML=false]
  7904. * Use HTML to render the text.
  7905. *
  7906. * @return {Highcharts.SVGElement}
  7907. * The text object.
  7908. */
  7909. SVGRenderer.prototype.text = function (str, x, y, useHTML) {
  7910. // declare variables
  7911. var renderer = this,
  7912. wrapper,
  7913. attribs = {};
  7914. if (useHTML && (renderer.allowHTML || !renderer.forExport)) {
  7915. return renderer.html(str, x, y);
  7916. }
  7917. attribs.x = Math.round(x || 0); // X always needed for line-wrap logic
  7918. if (y) {
  7919. attribs.y = Math.round(y);
  7920. }
  7921. if (defined(str)) {
  7922. attribs.text = str;
  7923. }
  7924. wrapper = renderer.createElement('text')
  7925. .attr(attribs);
  7926. if (!useHTML) {
  7927. wrapper.xSetter = function (value, key, element) {
  7928. var tspans = element.getElementsByTagName('tspan'),
  7929. tspan,
  7930. parentVal = element.getAttribute(key),
  7931. i;
  7932. for (i = 0; i < tspans.length; i++) {
  7933. tspan = tspans[i];
  7934. // If the x values are equal, the tspan represents a
  7935. // linebreak
  7936. if (tspan.getAttribute(key) === parentVal) {
  7937. tspan.setAttribute(key, value);
  7938. }
  7939. }
  7940. element.setAttribute(key, value);
  7941. };
  7942. }
  7943. return wrapper;
  7944. };
  7945. /**
  7946. * Utility to return the baseline offset and total line height from the font
  7947. * size.
  7948. *
  7949. * @function Highcharts.SVGRenderer#fontMetrics
  7950. *
  7951. * @param {number|string} [fontSize]
  7952. * The current font size to inspect. If not given, the font size
  7953. * will be found from the DOM element.
  7954. *
  7955. * @param {Highcharts.SVGElement|Highcharts.SVGDOMElement} [elem]
  7956. * The element to inspect for a current font size.
  7957. *
  7958. * @return {Highcharts.FontMetricsObject}
  7959. * The font metrics.
  7960. */
  7961. SVGRenderer.prototype.fontMetrics = function (fontSize, elem) {
  7962. var lineHeight,
  7963. baseline;
  7964. if ((this.styledMode || !/px/.test(fontSize)) &&
  7965. win.getComputedStyle // old IE doesn't support it
  7966. ) {
  7967. fontSize = elem && SVGElement.prototype.getStyle.call(elem, 'font-size');
  7968. }
  7969. else {
  7970. fontSize = fontSize ||
  7971. // When the elem is a DOM element (#5932)
  7972. (elem && elem.style && elem.style.fontSize) ||
  7973. // Fall back on the renderer style default
  7974. (this.style && this.style.fontSize);
  7975. }
  7976. // Handle different units
  7977. if (/px/.test(fontSize)) {
  7978. fontSize = pInt(fontSize);
  7979. }
  7980. else {
  7981. fontSize = 12;
  7982. }
  7983. // Empirical values found by comparing font size and bounding box
  7984. // height. Applies to the default font family.
  7985. // https://jsfiddle.net/highcharts/7xvn7/
  7986. lineHeight = fontSize < 24 ? fontSize + 3 : Math.round(fontSize * 1.2);
  7987. baseline = Math.round(lineHeight * 0.8);
  7988. return {
  7989. h: lineHeight,
  7990. b: baseline,
  7991. f: fontSize
  7992. };
  7993. };
  7994. /**
  7995. * Correct X and Y positioning of a label for rotation (#1764).
  7996. *
  7997. * @private
  7998. * @function Highcharts.SVGRenderer#rotCorr
  7999. *
  8000. * @param {number} baseline
  8001. *
  8002. * @param {number} rotation
  8003. *
  8004. * @param {boolean} [alterY]
  8005. *
  8006. * @param {Highcharts.PositionObject}
  8007. */
  8008. SVGRenderer.prototype.rotCorr = function (baseline, rotation, alterY) {
  8009. var y = baseline;
  8010. if (rotation && alterY) {
  8011. y = Math.max(y * Math.cos(rotation * deg2rad), 4);
  8012. }
  8013. return {
  8014. x: (-baseline / 3) * Math.sin(rotation * deg2rad),
  8015. y: y
  8016. };
  8017. };
  8018. /**
  8019. * Compatibility function to convert the legacy one-dimensional path array
  8020. * into an array of segments.
  8021. *
  8022. * It is used in maps to parse the `path` option, and in SVGRenderer.dSetter
  8023. * to support legacy paths from demos.
  8024. *
  8025. * @private
  8026. * @function Highcharts.SVGRenderer#pathToSegments
  8027. */
  8028. SVGRenderer.prototype.pathToSegments = function (path) {
  8029. var ret = [];
  8030. var segment = [];
  8031. var commandLength = {
  8032. A: 8,
  8033. C: 7,
  8034. H: 2,
  8035. L: 3,
  8036. M: 3,
  8037. Q: 5,
  8038. S: 5,
  8039. T: 3,
  8040. V: 2
  8041. };
  8042. // Short, non-typesafe parsing of the one-dimensional array. It splits
  8043. // the path on any string. This is not type checked against the tuple
  8044. // types, but is shorter, and doesn't require specific checks for any
  8045. // command type in SVG.
  8046. for (var i = 0; i < path.length; i++) {
  8047. // Command skipped, repeat previous or insert L/l for M/m
  8048. if (isString(segment[0]) &&
  8049. isNumber(path[i]) &&
  8050. segment.length === commandLength[(segment[0].toUpperCase())]) {
  8051. path.splice(i, 0, segment[0].replace('M', 'L').replace('m', 'l'));
  8052. }
  8053. // Split on string
  8054. if (typeof path[i] === 'string') {
  8055. if (segment.length) {
  8056. ret.push(segment.slice(0));
  8057. }
  8058. segment.length = 0;
  8059. }
  8060. segment.push(path[i]);
  8061. }
  8062. ret.push(segment.slice(0));
  8063. return ret;
  8064. /*
  8065. // Fully type-safe version where each tuple type is checked. The
  8066. // downside is filesize and a lack of flexibility for unsupported
  8067. // commands
  8068. const ret: SVGPath = [],
  8069. commands = {
  8070. A: 7,
  8071. C: 6,
  8072. H: 1,
  8073. L: 2,
  8074. M: 2,
  8075. Q: 4,
  8076. S: 4,
  8077. T: 2,
  8078. V: 1,
  8079. Z: 0
  8080. };
  8081. let i = 0,
  8082. lastI = 0,
  8083. lastCommand;
  8084. while (i < path.length) {
  8085. const item = path[i];
  8086. let command;
  8087. if (typeof item === 'string') {
  8088. command = item;
  8089. i += 1;
  8090. } else {
  8091. command = lastCommand || 'M';
  8092. }
  8093. // Upper case
  8094. const commandUC = command.toUpperCase();
  8095. if (commandUC in commands) {
  8096. // No numeric parameters
  8097. if (command === 'Z' || command === 'z') {
  8098. ret.push([command]);
  8099. // One numeric parameter
  8100. } else {
  8101. const val0 = path[i];
  8102. if (typeof val0 === 'number') {
  8103. // Horizontal line to
  8104. if (command === 'H' || command === 'h') {
  8105. ret.push([command, val0]);
  8106. i += 1;
  8107. // Vertical line to
  8108. } else if (command === 'V' || command === 'v') {
  8109. ret.push([command, val0]);
  8110. i += 1;
  8111. // Two numeric parameters
  8112. } else {
  8113. const val1 = path[i + 1];
  8114. if (typeof val1 === 'number') {
  8115. // lineTo
  8116. if (command === 'L' || command === 'l') {
  8117. ret.push([command, val0, val1]);
  8118. i += 2;
  8119. // moveTo
  8120. } else if (command === 'M' || command === 'm') {
  8121. ret.push([command, val0, val1]);
  8122. i += 2;
  8123. // Smooth quadratic bezier
  8124. } else if (command === 'T' || command === 't') {
  8125. ret.push([command, val0, val1]);
  8126. i += 2;
  8127. // Four numeric parameters
  8128. } else {
  8129. const val2 = path[i + 2],
  8130. val3 = path[i + 3];
  8131. if (
  8132. typeof val2 === 'number' &&
  8133. typeof val3 === 'number'
  8134. ) {
  8135. // Quadratic bezier to
  8136. if (
  8137. command === 'Q' ||
  8138. command === 'q'
  8139. ) {
  8140. ret.push([
  8141. command,
  8142. val0,
  8143. val1,
  8144. val2,
  8145. val3
  8146. ]);
  8147. i += 4;
  8148. // Smooth cubic bezier to
  8149. } else if (
  8150. command === 'S' ||
  8151. command === 's'
  8152. ) {
  8153. ret.push([
  8154. command,
  8155. val0,
  8156. val1,
  8157. val2,
  8158. val3
  8159. ]);
  8160. i += 4;
  8161. // Six numeric parameters
  8162. } else {
  8163. const val4 = path[i + 4],
  8164. val5 = path[i + 5];
  8165. if (
  8166. typeof val4 === 'number' &&
  8167. typeof val5 === 'number'
  8168. ) {
  8169. // Curve to
  8170. if (
  8171. command === 'C' ||
  8172. command === 'c'
  8173. ) {
  8174. ret.push([
  8175. command,
  8176. val0,
  8177. val1,
  8178. val2,
  8179. val3,
  8180. val4,
  8181. val5
  8182. ]);
  8183. i += 6;
  8184. // Seven numeric parameters
  8185. } else {
  8186. const val6 = path[i + 6];
  8187. // Arc to
  8188. if (
  8189. typeof val6 ===
  8190. 'number' &&
  8191. (
  8192. command === 'A' ||
  8193. command === 'a'
  8194. )
  8195. ) {
  8196. ret.push([
  8197. command,
  8198. val0,
  8199. val1,
  8200. val2,
  8201. val3,
  8202. val4,
  8203. val5,
  8204. val6
  8205. ]);
  8206. i += 7;
  8207. }
  8208. }
  8209. }
  8210. }
  8211. }
  8212. }
  8213. }
  8214. }
  8215. }
  8216. }
  8217. }
  8218. // An unmarked command following a moveTo is a lineTo
  8219. lastCommand = command === 'M' ? 'L' : command;
  8220. if (i === lastI) {
  8221. break;
  8222. }
  8223. lastI = i;
  8224. }
  8225. return ret;
  8226. */
  8227. };
  8228. /**
  8229. * Draw a label, which is an extended text element with support for border
  8230. * and background. Highcharts creates a `g` element with a text and a `path`
  8231. * or `rect` inside, to make it behave somewhat like a HTML div. Border and
  8232. * background are set through `stroke`, `stroke-width` and `fill` attributes
  8233. * using the {@link Highcharts.SVGElement#attr|attr} method. To update the
  8234. * text after render, run `label.attr({ text: 'New text' })`.
  8235. *
  8236. * @sample highcharts/members/renderer-label-on-chart/
  8237. * A label on the chart
  8238. *
  8239. * @function Highcharts.SVGRenderer#label
  8240. *
  8241. * @param {string} str
  8242. * The initial text string or (subset) HTML to render.
  8243. *
  8244. * @param {number} x
  8245. * The x position of the label's left side.
  8246. *
  8247. * @param {number} [y]
  8248. * The y position of the label's top side or baseline, depending on
  8249. * the `baseline` parameter.
  8250. *
  8251. * @param {string} [shape='rect']
  8252. * The shape of the label's border/background, if any. Defaults to
  8253. * `rect`. Other possible values are `callout` or other shapes
  8254. * defined in {@link Highcharts.SVGRenderer#symbols}.
  8255. *
  8256. * @param {number} [anchorX]
  8257. * In case the `shape` has a pointer, like a flag, this is the
  8258. * coordinates it should be pinned to.
  8259. *
  8260. * @param {number} [anchorY]
  8261. * In case the `shape` has a pointer, like a flag, this is the
  8262. * coordinates it should be pinned to.
  8263. *
  8264. * @param {boolean} [useHTML=false]
  8265. * Wether to use HTML to render the label.
  8266. *
  8267. * @param {boolean} [baseline=false]
  8268. * Whether to position the label relative to the text baseline,
  8269. * like {@link Highcharts.SVGRenderer#text|renderer.text}, or to the
  8270. * upper border of the rectangle.
  8271. *
  8272. * @param {string} [className]
  8273. * Class name for the group.
  8274. *
  8275. * @return {Highcharts.SVGElement}
  8276. * The generated label.
  8277. */
  8278. SVGRenderer.prototype.label = function (str, x, y, shape, anchorX, anchorY, useHTML, baseline, className) {
  8279. return new SVGLabel(this, str, x, y, shape, anchorX, anchorY, useHTML, baseline, className);
  8280. };
  8281. return SVGRenderer;
  8282. }());
  8283. /**
  8284. * A pointer to the renderer's associated Element class. The VMLRenderer
  8285. * will have a pointer to VMLElement here.
  8286. *
  8287. * @name Highcharts.SVGRenderer#Element
  8288. * @type {Highcharts.SVGElement}
  8289. */
  8290. SVGRenderer.prototype.Element = SVGElement;
  8291. /**
  8292. * @private
  8293. */
  8294. SVGRenderer.prototype.SVG_NS = SVG_NS;
  8295. /**
  8296. * Dummy function for plugins, called every time the renderer is updated.
  8297. * Prior to Highcharts 5, this was used for the canvg renderer.
  8298. *
  8299. * @deprecated
  8300. * @function Highcharts.SVGRenderer#draw
  8301. */
  8302. SVGRenderer.prototype.draw = noop;
  8303. /**
  8304. * A collection of characters mapped to HTML entities. When `useHTML` on an
  8305. * element is true, these entities will be rendered correctly by HTML. In
  8306. * the SVG pseudo-HTML, they need to be unescaped back to simple characters,
  8307. * so for example `&lt;` will render as `<`.
  8308. *
  8309. * @example
  8310. * // Add support for unescaping quotes
  8311. * Highcharts.SVGRenderer.prototype.escapes['"'] = '&quot;';
  8312. *
  8313. * @name Highcharts.SVGRenderer#escapes
  8314. * @type {Highcharts.Dictionary<string>}
  8315. */
  8316. SVGRenderer.prototype.escapes = {
  8317. '&': '&amp;',
  8318. '<': '&lt;',
  8319. '>': '&gt;',
  8320. "'": '&#39;',
  8321. '"': '&quot;'
  8322. };
  8323. /**
  8324. * An extendable collection of functions for defining symbol paths.
  8325. *
  8326. * @name Highcharts.SVGRenderer#symbols
  8327. * @type {Highcharts.SymbolDictionary}
  8328. */
  8329. SVGRenderer.prototype.symbols = {
  8330. circle: function (x, y, w, h) {
  8331. // Return a full arc
  8332. return this.arc(x + w / 2, y + h / 2, w / 2, h / 2, {
  8333. start: Math.PI * 0.5,
  8334. end: Math.PI * 2.5,
  8335. open: false
  8336. });
  8337. },
  8338. square: function (x, y, w, h) {
  8339. return [
  8340. ['M', x, y],
  8341. ['L', x + w, y],
  8342. ['L', x + w, y + h],
  8343. ['L', x, y + h],
  8344. ['Z']
  8345. ];
  8346. },
  8347. triangle: function (x, y, w, h) {
  8348. return [
  8349. ['M', x + w / 2, y],
  8350. ['L', x + w, y + h],
  8351. ['L', x, y + h],
  8352. ['Z']
  8353. ];
  8354. },
  8355. 'triangle-down': function (x, y, w, h) {
  8356. return [
  8357. ['M', x, y],
  8358. ['L', x + w, y],
  8359. ['L', x + w / 2, y + h],
  8360. ['Z']
  8361. ];
  8362. },
  8363. diamond: function (x, y, w, h) {
  8364. return [
  8365. ['M', x + w / 2, y],
  8366. ['L', x + w, y + h / 2],
  8367. ['L', x + w / 2, y + h],
  8368. ['L', x, y + h / 2],
  8369. ['Z']
  8370. ];
  8371. },
  8372. arc: function (x, y, w, h, options) {
  8373. var arc = [];
  8374. if (options) {
  8375. var start = options.start || 0,
  8376. end = options.end || 0,
  8377. rx = options.r || w,
  8378. ry = options.r || h || w,
  8379. proximity = 0.001,
  8380. fullCircle = Math.abs(end - start - 2 * Math.PI) <
  8381. proximity,
  8382. // Substract a small number to prevent cos and sin of start and
  8383. // end from becoming equal on 360 arcs (related: #1561)
  8384. end = end - proximity,
  8385. innerRadius = options.innerR,
  8386. open = pick(options.open,
  8387. fullCircle),
  8388. cosStart = Math.cos(start),
  8389. sinStart = Math.sin(start),
  8390. cosEnd = Math.cos(end),
  8391. sinEnd = Math.sin(end),
  8392. // Proximity takes care of rounding errors around PI (#6971)
  8393. longArc = pick(options.longArc,
  8394. end - start - Math.PI < proximity ? 0 : 1);
  8395. arc.push([
  8396. 'M',
  8397. x + rx * cosStart,
  8398. y + ry * sinStart
  8399. ], [
  8400. 'A',
  8401. rx,
  8402. ry,
  8403. 0,
  8404. longArc,
  8405. pick(options.clockwise, 1),
  8406. x + rx * cosEnd,
  8407. y + ry * sinEnd
  8408. ]);
  8409. if (defined(innerRadius)) {
  8410. arc.push(open ?
  8411. [
  8412. 'M',
  8413. x + innerRadius * cosEnd,
  8414. y + innerRadius * sinEnd
  8415. ] : [
  8416. 'L',
  8417. x + innerRadius * cosEnd,
  8418. y + innerRadius * sinEnd
  8419. ], [
  8420. 'A',
  8421. innerRadius,
  8422. innerRadius,
  8423. 0,
  8424. longArc,
  8425. // Clockwise - opposite to the outer arc clockwise
  8426. defined(options.clockwise) ? 1 - options.clockwise : 0,
  8427. x + innerRadius * cosStart,
  8428. y + innerRadius * sinStart
  8429. ]);
  8430. }
  8431. if (!open) {
  8432. arc.push(['Z']);
  8433. }
  8434. }
  8435. return arc;
  8436. },
  8437. /**
  8438. * Callout shape used for default tooltips, also used for rounded
  8439. * rectangles in VML
  8440. */
  8441. callout: function (x, y, w, h, options) {
  8442. var arrowLength = 6,
  8443. halfDistance = 6,
  8444. r = Math.min((options && options.r) || 0,
  8445. w,
  8446. h),
  8447. safeDistance = r + halfDistance,
  8448. anchorX = options && options.anchorX || 0,
  8449. anchorY = options && options.anchorY || 0,
  8450. path;
  8451. path = [
  8452. ['M', x + r, y],
  8453. ['L', x + w - r, y],
  8454. ['C', x + w, y, x + w, y, x + w, y + r],
  8455. ['L', x + w, y + h - r],
  8456. ['C', x + w, y + h, x + w, y + h, x + w - r, y + h],
  8457. ['L', x + r, y + h],
  8458. ['C', x, y + h, x, y + h, x, y + h - r],
  8459. ['L', x, y + r],
  8460. ['C', x, y, x, y, x + r, y] // top-left corner
  8461. ];
  8462. // Anchor on right side
  8463. if (anchorX && anchorX > w) {
  8464. // Chevron
  8465. if (anchorY > y + safeDistance &&
  8466. anchorY < y + h - safeDistance) {
  8467. 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]);
  8468. // Simple connector
  8469. }
  8470. else {
  8471. path.splice(3, 1, ['L', x + w, h / 2], ['L', anchorX, anchorY], ['L', x + w, h / 2], ['L', x + w, y + h - r]);
  8472. }
  8473. // Anchor on left side
  8474. }
  8475. else if (anchorX && anchorX < 0) {
  8476. // Chevron
  8477. if (anchorY > y + safeDistance &&
  8478. anchorY < y + h - safeDistance) {
  8479. path.splice(7, 1, ['L', x, anchorY + halfDistance], ['L', x - arrowLength, anchorY], ['L', x, anchorY - halfDistance], ['L', x, y + r]);
  8480. // Simple connector
  8481. }
  8482. else {
  8483. path.splice(7, 1, ['L', x, h / 2], ['L', anchorX, anchorY], ['L', x, h / 2], ['L', x, y + r]);
  8484. }
  8485. }
  8486. else if ( // replace bottom
  8487. anchorY &&
  8488. anchorY > h &&
  8489. anchorX > x + safeDistance &&
  8490. anchorX < x + w - safeDistance) {
  8491. path.splice(5, 1, ['L', anchorX + halfDistance, y + h], ['L', anchorX, y + h + arrowLength], ['L', anchorX - halfDistance, y + h], ['L', x + r, y + h]);
  8492. }
  8493. else if ( // replace top
  8494. anchorY &&
  8495. anchorY < 0 &&
  8496. anchorX > x + safeDistance &&
  8497. anchorX < x + w - safeDistance) {
  8498. path.splice(1, 1, ['L', anchorX - halfDistance, y], ['L', anchorX, y - arrowLength], ['L', anchorX + halfDistance, y], ['L', w - r, y]);
  8499. }
  8500. return path;
  8501. }
  8502. };
  8503. H.SVGRenderer = SVGRenderer;
  8504. H.Renderer = H.SVGRenderer;
  8505. return H.Renderer;
  8506. });
  8507. _registerModule(_modules, 'Core/Renderer/HTML/HTMLElement.js', [_modules['Core/Globals.js'], _modules['Core/Renderer/SVG/SVGElement.js'], _modules['Core/Utilities.js']], function (H, SVGElement, U) {
  8508. /* *
  8509. *
  8510. * (c) 2010-2020 Torstein Honsi
  8511. *
  8512. * License: www.highcharts.com/license
  8513. *
  8514. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  8515. *
  8516. * */
  8517. var css = U.css,
  8518. defined = U.defined,
  8519. extend = U.extend,
  8520. pick = U.pick,
  8521. pInt = U.pInt;
  8522. /**
  8523. * Element placebo
  8524. * @private
  8525. */
  8526. var HTMLElement = SVGElement;
  8527. var isFirefox = H.isFirefox;
  8528. /* eslint-disable valid-jsdoc */
  8529. // Extend SvgElement for useHTML option.
  8530. extend(HTMLElement.prototype, /** @lends SVGElement.prototype */ {
  8531. /**
  8532. * Apply CSS to HTML elements. This is used in text within SVG rendering and
  8533. * by the VML renderer
  8534. *
  8535. * @private
  8536. * @function Highcharts.SVGElement#htmlCss
  8537. *
  8538. * @param {Highcharts.CSSObject} styles
  8539. *
  8540. * @return {Highcharts.SVGElement}
  8541. */
  8542. htmlCss: function (styles) {
  8543. var wrapper = this,
  8544. element = wrapper.element,
  8545. // When setting or unsetting the width style, we need to update
  8546. // transform (#8809)
  8547. isSettingWidth = (element.tagName === 'SPAN' &&
  8548. styles &&
  8549. 'width' in styles),
  8550. textWidth = pick(isSettingWidth && styles.width,
  8551. void 0),
  8552. doTransform;
  8553. if (isSettingWidth) {
  8554. delete styles.width;
  8555. wrapper.textWidth = textWidth;
  8556. doTransform = true;
  8557. }
  8558. if (styles && styles.textOverflow === 'ellipsis') {
  8559. styles.whiteSpace = 'nowrap';
  8560. styles.overflow = 'hidden';
  8561. }
  8562. wrapper.styles = extend(wrapper.styles, styles);
  8563. css(wrapper.element, styles);
  8564. // Now that all styles are applied, to the transform
  8565. if (doTransform) {
  8566. wrapper.htmlUpdateTransform();
  8567. }
  8568. return wrapper;
  8569. },
  8570. /**
  8571. * VML and useHTML method for calculating the bounding box based on offsets.
  8572. *
  8573. * @private
  8574. * @function Highcharts.SVGElement#htmlGetBBox
  8575. *
  8576. * @param {boolean} refresh
  8577. * Whether to force a fresh value from the DOM or to use the cached
  8578. * value.
  8579. *
  8580. * @return {Highcharts.BBoxObject}
  8581. * A hash containing values for x, y, width and height.
  8582. */
  8583. htmlGetBBox: function () {
  8584. var wrapper = this,
  8585. element = wrapper.element;
  8586. return {
  8587. x: element.offsetLeft,
  8588. y: element.offsetTop,
  8589. width: element.offsetWidth,
  8590. height: element.offsetHeight
  8591. };
  8592. },
  8593. /**
  8594. * VML override private method to update elements based on internal
  8595. * properties based on SVG transform.
  8596. *
  8597. * @private
  8598. * @function Highcharts.SVGElement#htmlUpdateTransform
  8599. * @return {void}
  8600. */
  8601. htmlUpdateTransform: function () {
  8602. // aligning non added elements is expensive
  8603. if (!this.added) {
  8604. this.alignOnAdd = true;
  8605. return;
  8606. }
  8607. var wrapper = this,
  8608. renderer = wrapper.renderer,
  8609. elem = wrapper.element,
  8610. translateX = wrapper.translateX || 0,
  8611. translateY = wrapper.translateY || 0,
  8612. x = wrapper.x || 0,
  8613. y = wrapper.y || 0,
  8614. align = wrapper.textAlign || 'left',
  8615. alignCorrection = {
  8616. left: 0,
  8617. center: 0.5,
  8618. right: 1
  8619. }[align],
  8620. styles = wrapper.styles,
  8621. whiteSpace = styles && styles.whiteSpace;
  8622. /**
  8623. * @private
  8624. * @return {number}
  8625. */
  8626. function getTextPxLength() {
  8627. // Reset multiline/ellipsis in order to read width (#4928,
  8628. // #5417)
  8629. css(elem, {
  8630. width: '',
  8631. whiteSpace: whiteSpace || 'nowrap'
  8632. });
  8633. return elem.offsetWidth;
  8634. }
  8635. // apply translate
  8636. css(elem, {
  8637. marginLeft: translateX,
  8638. marginTop: translateY
  8639. });
  8640. if (!renderer.styledMode && wrapper.shadows) { // used in labels/tooltip
  8641. wrapper.shadows.forEach(function (shadow) {
  8642. css(shadow, {
  8643. marginLeft: translateX + 1,
  8644. marginTop: translateY + 1
  8645. });
  8646. });
  8647. }
  8648. // apply inversion
  8649. if (wrapper.inverted) { // wrapper is a group
  8650. [].forEach.call(elem.childNodes, function (child) {
  8651. renderer.invertChild(child, elem);
  8652. });
  8653. }
  8654. if (elem.tagName === 'SPAN') {
  8655. var rotation = wrapper.rotation, baseline, textWidth = wrapper.textWidth && pInt(wrapper.textWidth), currentTextTransform = [
  8656. rotation,
  8657. align,
  8658. elem.innerHTML,
  8659. wrapper.textWidth,
  8660. wrapper.textAlign
  8661. ].join(',');
  8662. // Update textWidth. Use the memoized textPxLength if possible, to
  8663. // avoid the getTextPxLength function using elem.offsetWidth.
  8664. // Calling offsetWidth affects rendering time as it forces layout
  8665. // (#7656).
  8666. if (textWidth !== wrapper.oldTextWidth &&
  8667. ((textWidth > wrapper.oldTextWidth) ||
  8668. (wrapper.textPxLength || getTextPxLength()) > textWidth) && (
  8669. // Only set the width if the text is able to word-wrap, or
  8670. // text-overflow is ellipsis (#9537)
  8671. /[ \-]/.test(elem.textContent || elem.innerText) ||
  8672. elem.style.textOverflow === 'ellipsis')) { // #983, #1254
  8673. css(elem, {
  8674. width: textWidth + 'px',
  8675. display: 'block',
  8676. whiteSpace: whiteSpace || 'normal' // #3331
  8677. });
  8678. wrapper.oldTextWidth = textWidth;
  8679. wrapper.hasBoxWidthChanged = true; // #8159
  8680. }
  8681. else {
  8682. wrapper.hasBoxWidthChanged = false; // #8159
  8683. }
  8684. // Do the calculations and DOM access only if properties changed
  8685. if (currentTextTransform !== wrapper.cTT) {
  8686. baseline = renderer.fontMetrics(elem.style.fontSize, elem).b;
  8687. // Renderer specific handling of span rotation, but only if we
  8688. // have something to update.
  8689. if (defined(rotation) &&
  8690. ((rotation !== (wrapper.oldRotation || 0)) ||
  8691. (align !== wrapper.oldAlign))) {
  8692. wrapper.setSpanRotation(rotation, alignCorrection, baseline);
  8693. }
  8694. wrapper.getSpanCorrection(
  8695. // Avoid elem.offsetWidth if we can, it affects rendering
  8696. // time heavily (#7656)
  8697. ((!defined(rotation) && wrapper.textPxLength) || // #7920
  8698. elem.offsetWidth), baseline, alignCorrection, rotation, align);
  8699. }
  8700. // apply position with correction
  8701. css(elem, {
  8702. left: (x + (wrapper.xCorr || 0)) + 'px',
  8703. top: (y + (wrapper.yCorr || 0)) + 'px'
  8704. });
  8705. // record current text transform
  8706. wrapper.cTT = currentTextTransform;
  8707. wrapper.oldRotation = rotation;
  8708. wrapper.oldAlign = align;
  8709. }
  8710. },
  8711. /**
  8712. * Set the rotation of an individual HTML span.
  8713. *
  8714. * @private
  8715. * @function Highcharts.SVGElement#setSpanRotation
  8716. * @param {number} rotation
  8717. * @param {number} alignCorrection
  8718. * @param {number} baseline
  8719. * @return {void}
  8720. */
  8721. setSpanRotation: function (rotation, alignCorrection, baseline) {
  8722. var rotationStyle = {},
  8723. cssTransformKey = this.renderer.getTransformKey();
  8724. rotationStyle[cssTransformKey] = rotationStyle.transform =
  8725. 'rotate(' + rotation + 'deg)';
  8726. rotationStyle[cssTransformKey + (isFirefox ? 'Origin' : '-origin')] =
  8727. rotationStyle.transformOrigin =
  8728. (alignCorrection * 100) + '% ' + baseline + 'px';
  8729. css(this.element, rotationStyle);
  8730. },
  8731. /**
  8732. * Get the correction in X and Y positioning as the element is rotated.
  8733. *
  8734. * @private
  8735. * @function Highcharts.SVGElement#getSpanCorrection
  8736. * @param {number} width
  8737. * @param {number} baseline
  8738. * @param {number} alignCorrection
  8739. * @return {void}
  8740. */
  8741. getSpanCorrection: function (width, baseline, alignCorrection) {
  8742. this.xCorr = -width * alignCorrection;
  8743. this.yCorr = -baseline;
  8744. }
  8745. });
  8746. return HTMLElement;
  8747. });
  8748. _registerModule(_modules, 'Core/Renderer/HTML/HTMLRenderer.js', [_modules['Core/Globals.js'], _modules['Core/Renderer/SVG/SVGElement.js'], _modules['Core/Renderer/SVG/SVGRenderer.js'], _modules['Core/Utilities.js']], function (H, SVGElement, SVGRenderer, U) {
  8749. /* *
  8750. *
  8751. * (c) 2010-2020 Torstein Honsi
  8752. *
  8753. * License: www.highcharts.com/license
  8754. *
  8755. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  8756. *
  8757. * */
  8758. var isFirefox = H.isFirefox,
  8759. isMS = H.isMS,
  8760. isWebKit = H.isWebKit,
  8761. win = H.win;
  8762. var attr = U.attr,
  8763. createElement = U.createElement,
  8764. extend = U.extend,
  8765. pick = U.pick;
  8766. /**
  8767. * Renderer placebo
  8768. * @private
  8769. */
  8770. var HTMLRenderer = SVGRenderer;
  8771. /* eslint-disable valid-jsdoc */
  8772. // Extend SvgRenderer for useHTML option.
  8773. extend(SVGRenderer.prototype, /** @lends SVGRenderer.prototype */ {
  8774. /**
  8775. * @private
  8776. * @function Highcharts.SVGRenderer#getTransformKey
  8777. *
  8778. * @return {string}
  8779. */
  8780. getTransformKey: function () {
  8781. return isMS && !/Edge/.test(win.navigator.userAgent) ?
  8782. '-ms-transform' :
  8783. isWebKit ?
  8784. '-webkit-transform' :
  8785. isFirefox ?
  8786. 'MozTransform' :
  8787. win.opera ?
  8788. '-o-transform' :
  8789. '';
  8790. },
  8791. /**
  8792. * Create HTML text node. This is used by the VML renderer as well as the
  8793. * SVG renderer through the useHTML option.
  8794. *
  8795. * @private
  8796. * @function Highcharts.SVGRenderer#html
  8797. *
  8798. * @param {string} str
  8799. * The text of (subset) HTML to draw.
  8800. *
  8801. * @param {number} x
  8802. * The x position of the text's lower left corner.
  8803. *
  8804. * @param {number} y
  8805. * The y position of the text's lower left corner.
  8806. *
  8807. * @return {Highcharts.HTMLDOMElement}
  8808. */
  8809. html: function (str, x, y) {
  8810. var wrapper = this.createElement('span'), element = wrapper.element, renderer = wrapper.renderer, isSVG = renderer.isSVG, addSetters = function (gWrapper, style) {
  8811. // These properties are set as attributes on the SVG group, and
  8812. // as identical CSS properties on the div. (#3542)
  8813. ['opacity', 'visibility'].forEach(function (prop) {
  8814. gWrapper[prop + 'Setter'] = function (value, key, elem) {
  8815. var styleObject = gWrapper.div ?
  8816. gWrapper.div.style :
  8817. style;
  8818. SVGElement.prototype[prop + 'Setter']
  8819. .call(this, value, key, elem);
  8820. if (styleObject) {
  8821. styleObject[key] = value;
  8822. }
  8823. };
  8824. });
  8825. gWrapper.addedSetters = true;
  8826. };
  8827. // Text setter
  8828. wrapper.textSetter = function (value) {
  8829. if (value !== element.innerHTML) {
  8830. delete this.bBox;
  8831. delete this.oldTextWidth;
  8832. }
  8833. this.textStr = value;
  8834. element.innerHTML = pick(value, '');
  8835. wrapper.doTransform = true;
  8836. };
  8837. // Add setters for the element itself (#4938)
  8838. if (isSVG) { // #4938, only for HTML within SVG
  8839. addSetters(wrapper, wrapper.element.style);
  8840. }
  8841. // Various setters which rely on update transform
  8842. wrapper.xSetter =
  8843. wrapper.ySetter =
  8844. wrapper.alignSetter =
  8845. wrapper.rotationSetter =
  8846. function (value, key) {
  8847. if (key === 'align') {
  8848. // Do not overwrite the SVGElement.align method. Same as VML.
  8849. wrapper.alignValue = wrapper.textAlign = value;
  8850. }
  8851. else {
  8852. wrapper[key] = value;
  8853. }
  8854. wrapper.doTransform = true;
  8855. };
  8856. // Runs at the end of .attr()
  8857. wrapper.afterSetters = function () {
  8858. // Update transform. Do this outside the loop to prevent redundant
  8859. // updating for batch setting of attributes.
  8860. if (this.doTransform) {
  8861. this.htmlUpdateTransform();
  8862. this.doTransform = false;
  8863. }
  8864. };
  8865. // Set the default attributes
  8866. wrapper
  8867. .attr({
  8868. text: str,
  8869. x: Math.round(x),
  8870. y: Math.round(y)
  8871. })
  8872. .css({
  8873. position: 'absolute'
  8874. });
  8875. if (!renderer.styledMode) {
  8876. wrapper.css({
  8877. fontFamily: this.style.fontFamily,
  8878. fontSize: this.style.fontSize
  8879. });
  8880. }
  8881. // Keep the whiteSpace style outside the wrapper.styles collection
  8882. element.style.whiteSpace = 'nowrap';
  8883. // Use the HTML specific .css method
  8884. wrapper.css = wrapper.htmlCss;
  8885. // This is specific for HTML within SVG
  8886. if (isSVG) {
  8887. wrapper.add = function (svgGroupWrapper) {
  8888. var htmlGroup,
  8889. container = renderer.box.parentNode,
  8890. parentGroup,
  8891. parents = [];
  8892. this.parentGroup = svgGroupWrapper;
  8893. // Create a mock group to hold the HTML elements
  8894. if (svgGroupWrapper) {
  8895. htmlGroup = svgGroupWrapper.div;
  8896. if (!htmlGroup) {
  8897. // Read the parent chain into an array and read from top
  8898. // down
  8899. parentGroup = svgGroupWrapper;
  8900. while (parentGroup) {
  8901. parents.push(parentGroup);
  8902. // Move up to the next parent group
  8903. parentGroup = parentGroup.parentGroup;
  8904. }
  8905. // Ensure dynamically updating position when any parent
  8906. // is translated
  8907. parents.reverse().forEach(function (parentGroup) {
  8908. var htmlGroupStyle,
  8909. cls = attr(parentGroup.element, 'class');
  8910. /**
  8911. * Common translate setter for X and Y on the HTML
  8912. * group. Reverted the fix for #6957 du to
  8913. * positioning problems and offline export (#7254,
  8914. * #7280, #7529)
  8915. * @private
  8916. * @param {*} value
  8917. * @param {string} key
  8918. * @return {void}
  8919. */
  8920. function translateSetter(value, key) {
  8921. parentGroup[key] = value;
  8922. if (key === 'translateX') {
  8923. htmlGroupStyle.left = value + 'px';
  8924. }
  8925. else {
  8926. htmlGroupStyle.top = value + 'px';
  8927. }
  8928. parentGroup.doTransform = true;
  8929. }
  8930. // Create a HTML div and append it to the parent div
  8931. // to emulate the SVG group structure
  8932. htmlGroup =
  8933. parentGroup.div =
  8934. parentGroup.div || createElement('div', cls ? { className: cls } : void 0, {
  8935. position: 'absolute',
  8936. left: (parentGroup.translateX || 0) + 'px',
  8937. top: (parentGroup.translateY || 0) + 'px',
  8938. display: parentGroup.display,
  8939. opacity: parentGroup.opacity,
  8940. pointerEvents: (parentGroup.styles &&
  8941. parentGroup.styles.pointerEvents) // #5595
  8942. // the top group is appended to container
  8943. }, htmlGroup || container);
  8944. // Shortcut
  8945. htmlGroupStyle = htmlGroup.style;
  8946. // Set listeners to update the HTML div's position
  8947. // whenever the SVG group position is changed.
  8948. extend(parentGroup, {
  8949. // (#7287) Pass htmlGroup to use
  8950. // the related group
  8951. classSetter: (function (htmlGroup) {
  8952. return function (value) {
  8953. this.element.setAttribute('class', value);
  8954. htmlGroup.className = value;
  8955. };
  8956. }(htmlGroup)),
  8957. on: function () {
  8958. if (parents[0].div) { // #6418
  8959. wrapper.on.apply({ element: parents[0].div }, arguments);
  8960. }
  8961. return parentGroup;
  8962. },
  8963. translateXSetter: translateSetter,
  8964. translateYSetter: translateSetter
  8965. });
  8966. if (!parentGroup.addedSetters) {
  8967. addSetters(parentGroup);
  8968. }
  8969. });
  8970. }
  8971. }
  8972. else {
  8973. htmlGroup = container;
  8974. }
  8975. htmlGroup.appendChild(element);
  8976. // Shared with VML:
  8977. wrapper.added = true;
  8978. if (wrapper.alignOnAdd) {
  8979. wrapper.htmlUpdateTransform();
  8980. }
  8981. return wrapper;
  8982. };
  8983. }
  8984. return wrapper;
  8985. }
  8986. });
  8987. return HTMLRenderer;
  8988. });
  8989. _registerModule(_modules, 'Core/Axis/Tick.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  8990. /* *
  8991. *
  8992. * (c) 2010-2020 Torstein Honsi
  8993. *
  8994. * License: www.highcharts.com/license
  8995. *
  8996. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  8997. *
  8998. * */
  8999. /**
  9000. * Optional parameters for the tick.
  9001. * @private
  9002. * @interface Highcharts.TickParametersObject
  9003. */ /**
  9004. * Set category for the tick.
  9005. * @name Highcharts.TickParametersObject#category
  9006. * @type {string|undefined}
  9007. */ /**
  9008. * @name Highcharts.TickParametersObject#options
  9009. * @type {Highcharts.Dictionary<any>|undefined}
  9010. */ /**
  9011. * Set tickmarkOffset for the tick.
  9012. * @name Highcharts.TickParametersObject#tickmarkOffset
  9013. * @type {number|undefined}
  9014. */
  9015. var clamp = U.clamp,
  9016. correctFloat = U.correctFloat,
  9017. defined = U.defined,
  9018. destroyObjectProperties = U.destroyObjectProperties,
  9019. extend = U.extend,
  9020. fireEvent = U.fireEvent,
  9021. isNumber = U.isNumber,
  9022. merge = U.merge,
  9023. objectEach = U.objectEach,
  9024. pick = U.pick;
  9025. var deg2rad = H.deg2rad;
  9026. /* eslint-disable no-invalid-this, valid-jsdoc */
  9027. /**
  9028. * The Tick class.
  9029. *
  9030. * @class
  9031. * @name Highcharts.Tick
  9032. *
  9033. * @param {Highcharts.Axis} axis
  9034. * The axis of the tick.
  9035. *
  9036. * @param {number} pos
  9037. * The position of the tick on the axis in terms of axis values.
  9038. *
  9039. * @param {string} [type]
  9040. * The type of tick, either 'minor' or an empty string
  9041. *
  9042. * @param {boolean} [noLabel=false]
  9043. * Whether to disable the label or not. Defaults to false.
  9044. *
  9045. * @param {object} [parameters]
  9046. * Optional parameters for the tick.
  9047. */
  9048. var Tick = /** @class */ (function () {
  9049. /* *
  9050. *
  9051. * Constructors
  9052. *
  9053. * */
  9054. function Tick(axis, pos, type, noLabel, parameters) {
  9055. this.isNew = true;
  9056. this.isNewLabel = true;
  9057. /**
  9058. * The related axis of the tick.
  9059. * @name Highcharts.Tick#axis
  9060. * @type {Highcharts.Axis}
  9061. */
  9062. this.axis = axis;
  9063. /**
  9064. * The logical position of the tick on the axis in terms of axis values.
  9065. * @name Highcharts.Tick#pos
  9066. * @type {number}
  9067. */
  9068. this.pos = pos;
  9069. /**
  9070. * The tick type, which can be `"minor"`, or an empty string.
  9071. * @name Highcharts.Tick#type
  9072. * @type {string}
  9073. */
  9074. this.type = type || '';
  9075. this.parameters = parameters || {};
  9076. /**
  9077. * The mark offset of the tick on the axis. Usually `undefined`, numeric
  9078. * for grid axes.
  9079. * @name Highcharts.Tick#tickmarkOffset
  9080. * @type {number|undefined}
  9081. */
  9082. this.tickmarkOffset = this.parameters.tickmarkOffset;
  9083. this.options = this.parameters.options;
  9084. fireEvent(this, 'init');
  9085. if (!type && !noLabel) {
  9086. this.addLabel();
  9087. }
  9088. }
  9089. /* *
  9090. *
  9091. * Functions
  9092. *
  9093. * */
  9094. /**
  9095. * Write the tick label.
  9096. *
  9097. * @private
  9098. * @function Highcharts.Tick#addLabel
  9099. * @return {void}
  9100. */
  9101. Tick.prototype.addLabel = function () {
  9102. var tick = this,
  9103. axis = tick.axis,
  9104. options = axis.options,
  9105. chart = axis.chart,
  9106. categories = axis.categories,
  9107. log = axis.logarithmic,
  9108. names = axis.names,
  9109. pos = tick.pos,
  9110. labelOptions = pick(tick.options && tick.options.labels,
  9111. options.labels),
  9112. str,
  9113. tickPositions = axis.tickPositions,
  9114. isFirst = pos === tickPositions[0],
  9115. isLast = pos === tickPositions[tickPositions.length - 1],
  9116. value = this.parameters.category || (categories ?
  9117. pick(categories[pos],
  9118. names[pos],
  9119. pos) :
  9120. pos),
  9121. label = tick.label,
  9122. animateLabels = (!labelOptions.step || labelOptions.step === 1) &&
  9123. axis.tickInterval === 1,
  9124. tickPositionInfo = tickPositions.info,
  9125. dateTimeLabelFormat,
  9126. dateTimeLabelFormats,
  9127. i,
  9128. list;
  9129. // Set the datetime label format. If a higher rank is set for this
  9130. // position, use that. If not, use the general format.
  9131. if (axis.dateTime && tickPositionInfo) {
  9132. dateTimeLabelFormats = chart.time.resolveDTLFormat(options.dateTimeLabelFormats[(!options.grid &&
  9133. tickPositionInfo.higherRanks[pos]) ||
  9134. tickPositionInfo.unitName]);
  9135. dateTimeLabelFormat = dateTimeLabelFormats.main;
  9136. }
  9137. // set properties for access in render method
  9138. /**
  9139. * True if the tick is the first one on the axis.
  9140. * @name Highcharts.Tick#isFirst
  9141. * @readonly
  9142. * @type {boolean|undefined}
  9143. */
  9144. tick.isFirst = isFirst;
  9145. /**
  9146. * True if the tick is the last one on the axis.
  9147. * @name Highcharts.Tick#isLast
  9148. * @readonly
  9149. * @type {boolean|undefined}
  9150. */
  9151. tick.isLast = isLast;
  9152. // Get the string
  9153. tick.formatCtx = {
  9154. axis: axis,
  9155. chart: chart,
  9156. isFirst: isFirst,
  9157. isLast: isLast,
  9158. dateTimeLabelFormat: dateTimeLabelFormat,
  9159. tickPositionInfo: tickPositionInfo,
  9160. value: log ? correctFloat(log.lin2log(value)) : value,
  9161. pos: pos
  9162. };
  9163. str = axis.labelFormatter.call(tick.formatCtx, this.formatCtx);
  9164. // Set up conditional formatting based on the format list if existing.
  9165. list = dateTimeLabelFormats && dateTimeLabelFormats.list;
  9166. if (list) {
  9167. tick.shortenLabel = function () {
  9168. for (i = 0; i < list.length; i++) {
  9169. label.attr({
  9170. text: axis.labelFormatter.call(extend(tick.formatCtx, { dateTimeLabelFormat: list[i] }))
  9171. });
  9172. if (label.getBBox().width <
  9173. axis.getSlotWidth(tick) - 2 *
  9174. pick(labelOptions.padding, 5)) {
  9175. return;
  9176. }
  9177. }
  9178. label.attr({
  9179. text: ''
  9180. });
  9181. };
  9182. }
  9183. // Call only after first render
  9184. if (animateLabels && axis._addedPlotLB) {
  9185. tick.moveLabel(str, labelOptions);
  9186. }
  9187. // First call
  9188. if (!defined(label) && !tick.movedLabel) {
  9189. /**
  9190. * The rendered text label of the tick.
  9191. * @name Highcharts.Tick#label
  9192. * @type {Highcharts.SVGElement|undefined}
  9193. */
  9194. tick.label = label = tick.createLabel({ x: 0, y: 0 }, str, labelOptions);
  9195. // Base value to detect change for new calls to getBBox
  9196. tick.rotation = 0;
  9197. // update
  9198. }
  9199. else if (label && label.textStr !== str && !animateLabels) {
  9200. // When resetting text, also reset the width if dynamically set
  9201. // (#8809)
  9202. if (label.textWidth &&
  9203. !(labelOptions.style && labelOptions.style.width) &&
  9204. !label.styles.width) {
  9205. label.css({ width: null });
  9206. }
  9207. label.attr({ text: str });
  9208. label.textPxLength = label.getBBox().width;
  9209. }
  9210. };
  9211. /**
  9212. * Render and return the label of the tick.
  9213. *
  9214. * @private
  9215. * @function Highcharts.Tick#createLabel
  9216. * @param {Highcharts.PositionObject} xy
  9217. * @param {string} str
  9218. * @param {Highcharts.XAxisLabelsOptions} labelOptions
  9219. * @return {Highcharts.SVGElement|undefined}
  9220. */
  9221. Tick.prototype.createLabel = function (xy, str, labelOptions) {
  9222. var axis = this.axis,
  9223. chart = axis.chart,
  9224. label = defined(str) && labelOptions.enabled ?
  9225. chart.renderer
  9226. .text(str,
  9227. xy.x,
  9228. xy.y,
  9229. labelOptions.useHTML)
  9230. .add(axis.labelGroup) :
  9231. null;
  9232. // Un-rotated length
  9233. if (label) {
  9234. // Without position absolute, IE export sometimes is wrong
  9235. if (!chart.styledMode) {
  9236. label.css(merge(labelOptions.style));
  9237. }
  9238. label.textPxLength = label.getBBox().width;
  9239. }
  9240. return label;
  9241. };
  9242. /**
  9243. * Destructor for the tick prototype
  9244. *
  9245. * @private
  9246. * @function Highcharts.Tick#destroy
  9247. * @return {void}
  9248. */
  9249. Tick.prototype.destroy = function () {
  9250. destroyObjectProperties(this, this.axis);
  9251. };
  9252. /**
  9253. * Gets the x and y positions for ticks in terms of pixels.
  9254. *
  9255. * @private
  9256. * @function Highcharts.Tick#getPosition
  9257. *
  9258. * @param {boolean} horiz
  9259. * Whether the tick is on an horizontal axis or not.
  9260. *
  9261. * @param {number} tickPos
  9262. * Position of the tick.
  9263. *
  9264. * @param {number} tickmarkOffset
  9265. * Tickmark offset for all ticks.
  9266. *
  9267. * @param {boolean} [old]
  9268. * Whether the axis has changed or not.
  9269. *
  9270. * @return {Highcharts.PositionObject}
  9271. * The tick position.
  9272. *
  9273. * @fires Highcharts.Tick#event:afterGetPosition
  9274. */
  9275. Tick.prototype.getPosition = function (horiz, tickPos, tickmarkOffset, old) {
  9276. var axis = this.axis,
  9277. chart = axis.chart,
  9278. cHeight = (old && chart.oldChartHeight) || chart.chartHeight,
  9279. pos;
  9280. pos = {
  9281. x: horiz ?
  9282. correctFloat(axis.translate(tickPos + tickmarkOffset, null, null, old) +
  9283. axis.transB) :
  9284. (axis.left +
  9285. axis.offset +
  9286. (axis.opposite ?
  9287. (((old && chart.oldChartWidth) ||
  9288. chart.chartWidth) -
  9289. axis.right -
  9290. axis.left) :
  9291. 0)),
  9292. y: horiz ?
  9293. (cHeight -
  9294. axis.bottom +
  9295. axis.offset -
  9296. (axis.opposite ? axis.height : 0)) :
  9297. correctFloat(cHeight -
  9298. axis.translate(tickPos + tickmarkOffset, null, null, old) -
  9299. axis.transB)
  9300. };
  9301. // Chrome workaround for #10516
  9302. pos.y = clamp(pos.y, -1e5, 1e5);
  9303. fireEvent(this, 'afterGetPosition', { pos: pos });
  9304. return pos;
  9305. };
  9306. /**
  9307. * Get the x, y position of the tick label
  9308. *
  9309. * @private
  9310. * @return {Highcharts.PositionObject}
  9311. */
  9312. Tick.prototype.getLabelPosition = function (x, y, label, horiz, labelOptions, tickmarkOffset, index, step) {
  9313. var axis = this.axis,
  9314. transA = axis.transA,
  9315. reversed = ( // #7911
  9316. axis.isLinked && axis.linkedParent ?
  9317. axis.linkedParent.reversed :
  9318. axis.reversed),
  9319. staggerLines = axis.staggerLines,
  9320. rotCorr = axis.tickRotCorr || { x: 0,
  9321. y: 0 },
  9322. yOffset = labelOptions.y,
  9323. // Adjust for label alignment if we use reserveSpace: true (#5286)
  9324. labelOffsetCorrection = (!horiz && !axis.reserveSpaceDefault ?
  9325. -axis.labelOffset * (axis.labelAlign === 'center' ? 0.5 : 1) :
  9326. 0),
  9327. line,
  9328. pos = {};
  9329. if (!defined(yOffset)) {
  9330. if (axis.side === 0) {
  9331. yOffset = label.rotation ? -8 : -label.getBBox().height;
  9332. }
  9333. else if (axis.side === 2) {
  9334. yOffset = rotCorr.y + 8;
  9335. }
  9336. else {
  9337. // #3140, #3140
  9338. yOffset = Math.cos(label.rotation * deg2rad) *
  9339. (rotCorr.y - label.getBBox(false, 0).height / 2);
  9340. }
  9341. }
  9342. x = x +
  9343. labelOptions.x +
  9344. labelOffsetCorrection +
  9345. rotCorr.x -
  9346. (tickmarkOffset && horiz ?
  9347. tickmarkOffset * transA * (reversed ? -1 : 1) :
  9348. 0);
  9349. y = y + yOffset - (tickmarkOffset && !horiz ?
  9350. tickmarkOffset * transA * (reversed ? 1 : -1) : 0);
  9351. // Correct for staggered labels
  9352. if (staggerLines) {
  9353. line = (index / (step || 1) % staggerLines);
  9354. if (axis.opposite) {
  9355. line = staggerLines - line - 1;
  9356. }
  9357. y += line * (axis.labelOffset / staggerLines);
  9358. }
  9359. pos.x = x;
  9360. pos.y = Math.round(y);
  9361. fireEvent(this, 'afterGetLabelPosition', { pos: pos, tickmarkOffset: tickmarkOffset, index: index });
  9362. return pos;
  9363. };
  9364. /**
  9365. * Get the offset height or width of the label
  9366. *
  9367. * @private
  9368. * @function Highcharts.Tick#getLabelSize
  9369. * @return {number}
  9370. */
  9371. Tick.prototype.getLabelSize = function () {
  9372. return this.label ?
  9373. this.label.getBBox()[this.axis.horiz ? 'height' : 'width'] :
  9374. 0;
  9375. };
  9376. /**
  9377. * Extendible method to return the path of the marker
  9378. *
  9379. * @private
  9380. *
  9381. */
  9382. Tick.prototype.getMarkPath = function (x, y, tickLength, tickWidth, horiz, renderer) {
  9383. return renderer.crispLine([[
  9384. 'M',
  9385. x,
  9386. y
  9387. ], [
  9388. 'L',
  9389. x + (horiz ? 0 : -tickLength),
  9390. y + (horiz ? tickLength : 0)
  9391. ]], tickWidth);
  9392. };
  9393. /**
  9394. * Handle the label overflow by adjusting the labels to the left and right
  9395. * edge, or hide them if they collide into the neighbour label.
  9396. *
  9397. * @private
  9398. * @function Highcharts.Tick#handleOverflow
  9399. * @param {Highcharts.PositionObject} xy
  9400. * @return {void}
  9401. */
  9402. Tick.prototype.handleOverflow = function (xy) {
  9403. var tick = this,
  9404. axis = this.axis,
  9405. labelOptions = axis.options.labels,
  9406. pxPos = xy.x,
  9407. chartWidth = axis.chart.chartWidth,
  9408. spacing = axis.chart.spacing,
  9409. leftBound = pick(axis.labelLeft,
  9410. Math.min(axis.pos,
  9411. spacing[3])),
  9412. rightBound = pick(axis.labelRight,
  9413. Math.max(!axis.isRadial ? axis.pos + axis.len : 0,
  9414. chartWidth - spacing[1])),
  9415. label = this.label,
  9416. rotation = this.rotation,
  9417. factor = {
  9418. left: 0,
  9419. center: 0.5,
  9420. right: 1
  9421. }[axis.labelAlign || label.attr('align')],
  9422. labelWidth = label.getBBox().width,
  9423. slotWidth = axis.getSlotWidth(tick),
  9424. modifiedSlotWidth = slotWidth,
  9425. xCorrection = factor,
  9426. goRight = 1,
  9427. leftPos,
  9428. rightPos,
  9429. textWidth,
  9430. css = {};
  9431. // Check if the label overshoots the chart spacing box. If it does, move
  9432. // it. If it now overshoots the slotWidth, add ellipsis.
  9433. if (!rotation &&
  9434. pick(labelOptions.overflow, 'justify') === 'justify') {
  9435. leftPos = pxPos - factor * labelWidth;
  9436. rightPos = pxPos + (1 - factor) * labelWidth;
  9437. if (leftPos < leftBound) {
  9438. modifiedSlotWidth =
  9439. xy.x + modifiedSlotWidth * (1 - factor) - leftBound;
  9440. }
  9441. else if (rightPos > rightBound) {
  9442. modifiedSlotWidth =
  9443. rightBound - xy.x + modifiedSlotWidth * factor;
  9444. goRight = -1;
  9445. }
  9446. modifiedSlotWidth = Math.min(slotWidth, modifiedSlotWidth); // #4177
  9447. if (modifiedSlotWidth < slotWidth && axis.labelAlign === 'center') {
  9448. xy.x += (goRight *
  9449. (slotWidth -
  9450. modifiedSlotWidth -
  9451. xCorrection * (slotWidth - Math.min(labelWidth, modifiedSlotWidth))));
  9452. }
  9453. // If the label width exceeds the available space, set a text width
  9454. // to be picked up below. Also, if a width has been set before, we
  9455. // need to set a new one because the reported labelWidth will be
  9456. // limited by the box (#3938).
  9457. if (labelWidth > modifiedSlotWidth ||
  9458. (axis.autoRotation && (label.styles || {}).width)) {
  9459. textWidth = modifiedSlotWidth;
  9460. }
  9461. // Add ellipsis to prevent rotated labels to be clipped against the edge
  9462. // of the chart
  9463. }
  9464. else if (rotation < 0 &&
  9465. pxPos - factor * labelWidth < leftBound) {
  9466. textWidth = Math.round(pxPos / Math.cos(rotation * deg2rad) - leftBound);
  9467. }
  9468. else if (rotation > 0 &&
  9469. pxPos + factor * labelWidth > rightBound) {
  9470. textWidth = Math.round((chartWidth - pxPos) /
  9471. Math.cos(rotation * deg2rad));
  9472. }
  9473. if (textWidth) {
  9474. if (tick.shortenLabel) {
  9475. tick.shortenLabel();
  9476. }
  9477. else {
  9478. css.width = Math.floor(textWidth) + 'px';
  9479. if (!(labelOptions.style || {}).textOverflow) {
  9480. css.textOverflow = 'ellipsis';
  9481. }
  9482. label.css(css);
  9483. }
  9484. }
  9485. };
  9486. /**
  9487. * Try to replace the label if the same one already exists.
  9488. *
  9489. * @private
  9490. * @function Highcharts.Tick#moveLabel
  9491. * @param {string} str
  9492. * @param {Highcharts.XAxisLabelsOptions} labelOptions
  9493. *
  9494. * @return {void}
  9495. */
  9496. Tick.prototype.moveLabel = function (str, labelOptions) {
  9497. var tick = this,
  9498. label = tick.label,
  9499. moved = false,
  9500. axis = tick.axis,
  9501. labelPos,
  9502. reversed = axis.reversed,
  9503. xPos,
  9504. yPos;
  9505. if (label && label.textStr === str) {
  9506. tick.movedLabel = label;
  9507. moved = true;
  9508. delete tick.label;
  9509. }
  9510. else { // Find a label with the same string
  9511. objectEach(axis.ticks, function (currentTick) {
  9512. if (!moved &&
  9513. !currentTick.isNew &&
  9514. currentTick !== tick &&
  9515. currentTick.label &&
  9516. currentTick.label.textStr === str) {
  9517. tick.movedLabel = currentTick.label;
  9518. moved = true;
  9519. currentTick.labelPos = tick.movedLabel.xy;
  9520. delete currentTick.label;
  9521. }
  9522. });
  9523. }
  9524. // Create new label if the actual one is moved
  9525. if (!moved && (tick.labelPos || label)) {
  9526. labelPos = tick.labelPos || label.xy;
  9527. xPos = axis.horiz ?
  9528. (reversed ? 0 : axis.width + axis.left) : labelPos.x;
  9529. yPos = axis.horiz ?
  9530. labelPos.y : (reversed ? (axis.width + axis.left) : 0);
  9531. tick.movedLabel = tick.createLabel({ x: xPos, y: yPos }, str, labelOptions);
  9532. if (tick.movedLabel) {
  9533. tick.movedLabel.attr({ opacity: 0 });
  9534. }
  9535. }
  9536. };
  9537. /**
  9538. * Put everything in place
  9539. *
  9540. * @private
  9541. * @param {number} index
  9542. * @param {boolean} [old]
  9543. * Use old coordinates to prepare an animation into new position
  9544. * @param {number} [opacity]
  9545. * @return {voids}
  9546. */
  9547. Tick.prototype.render = function (index, old, opacity) {
  9548. var tick = this,
  9549. axis = tick.axis,
  9550. horiz = axis.horiz,
  9551. pos = tick.pos,
  9552. tickmarkOffset = pick(tick.tickmarkOffset,
  9553. axis.tickmarkOffset),
  9554. xy = tick.getPosition(horiz,
  9555. pos,
  9556. tickmarkOffset,
  9557. old),
  9558. x = xy.x,
  9559. y = xy.y,
  9560. reverseCrisp = ((horiz && x === axis.pos + axis.len) ||
  9561. (!horiz && y === axis.pos)) ? -1 : 1; // #1480, #1687
  9562. opacity = pick(opacity, 1);
  9563. this.isActive = true;
  9564. // Create the grid line
  9565. this.renderGridLine(old, opacity, reverseCrisp);
  9566. // create the tick mark
  9567. this.renderMark(xy, opacity, reverseCrisp);
  9568. // the label is created on init - now move it into place
  9569. this.renderLabel(xy, old, opacity, index);
  9570. tick.isNew = false;
  9571. fireEvent(this, 'afterRender');
  9572. };
  9573. /**
  9574. * Renders the gridLine.
  9575. *
  9576. * @private
  9577. * @param {boolean} old Whether or not the tick is old
  9578. * @param {number} opacity The opacity of the grid line
  9579. * @param {number} reverseCrisp Modifier for avoiding overlapping 1 or -1
  9580. * @return {void}
  9581. */
  9582. Tick.prototype.renderGridLine = function (old, opacity, reverseCrisp) {
  9583. 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'];
  9584. if (!gridLine) {
  9585. if (!axis.chart.styledMode) {
  9586. attribs.stroke = gridLineColor;
  9587. attribs['stroke-width'] = gridLineWidth;
  9588. if (dashStyle) {
  9589. attribs.dashstyle = dashStyle;
  9590. }
  9591. }
  9592. if (!type) {
  9593. attribs.zIndex = 1;
  9594. }
  9595. if (old) {
  9596. opacity = 0;
  9597. }
  9598. /**
  9599. * The rendered grid line of the tick.
  9600. * @name Highcharts.Tick#gridLine
  9601. * @type {Highcharts.SVGElement|undefined}
  9602. */
  9603. tick.gridLine = gridLine = renderer.path()
  9604. .attr(attribs)
  9605. .addClass('highcharts-' + (type ? type + '-' : '') + 'grid-line')
  9606. .add(axis.gridGroup);
  9607. }
  9608. if (gridLine) {
  9609. gridLinePath = axis.getPlotLinePath({
  9610. value: pos + tickmarkOffset,
  9611. lineWidth: gridLine.strokeWidth() * reverseCrisp,
  9612. force: 'pass',
  9613. old: old
  9614. });
  9615. // If the parameter 'old' is set, the current call will be followed
  9616. // by another call, therefore do not do any animations this time
  9617. if (gridLinePath) {
  9618. gridLine[old || tick.isNew ? 'attr' : 'animate']({
  9619. d: gridLinePath,
  9620. opacity: opacity
  9621. });
  9622. }
  9623. }
  9624. };
  9625. /**
  9626. * Renders the tick mark.
  9627. *
  9628. * @private
  9629. * @param {Highcharts.PositionObject} xy The position vector of the mark
  9630. * @param {number} opacity The opacity of the mark
  9631. * @param {number} reverseCrisp Modifier for avoiding overlapping 1 or -1
  9632. * @return {void}
  9633. */
  9634. Tick.prototype.renderMark = function (xy, opacity, reverseCrisp) {
  9635. 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
  9636. tickColor = options[tickPrefix + 'Color'];
  9637. if (tickSize) {
  9638. // negate the length
  9639. if (axis.opposite) {
  9640. tickSize[0] = -tickSize[0];
  9641. }
  9642. // First time, create it
  9643. if (isNewMark) {
  9644. /**
  9645. * The rendered mark of the tick.
  9646. * @name Highcharts.Tick#mark
  9647. * @type {Highcharts.SVGElement|undefined}
  9648. */
  9649. tick.mark = mark = renderer.path()
  9650. .addClass('highcharts-' + (type ? type + '-' : '') + 'tick')
  9651. .add(axis.axisGroup);
  9652. if (!axis.chart.styledMode) {
  9653. mark.attr({
  9654. stroke: tickColor,
  9655. 'stroke-width': tickWidth
  9656. });
  9657. }
  9658. }
  9659. mark[isNewMark ? 'attr' : 'animate']({
  9660. d: tick.getMarkPath(x, y, tickSize[0], mark.strokeWidth() * reverseCrisp, axis.horiz, renderer),
  9661. opacity: opacity
  9662. });
  9663. }
  9664. };
  9665. /**
  9666. * Renders the tick label.
  9667. * Note: The label should already be created in init(), so it should only
  9668. * have to be moved into place.
  9669. *
  9670. * @private
  9671. * @param {Highcharts.PositionObject} xy The position vector of the label
  9672. * @param {boolean} old Whether or not the tick is old
  9673. * @param {number} opacity The opacity of the label
  9674. * @param {number} index The index of the tick
  9675. * @return {void}
  9676. */
  9677. Tick.prototype.renderLabel = function (xy, old, opacity, index) {
  9678. var tick = this,
  9679. axis = tick.axis,
  9680. horiz = axis.horiz,
  9681. options = axis.options,
  9682. label = tick.label,
  9683. labelOptions = options.labels,
  9684. step = labelOptions.step,
  9685. tickmarkOffset = pick(tick.tickmarkOffset,
  9686. axis.tickmarkOffset),
  9687. show = true,
  9688. x = xy.x,
  9689. y = xy.y;
  9690. if (label && isNumber(x)) {
  9691. label.xy = xy = tick.getLabelPosition(x, y, label, horiz, labelOptions, tickmarkOffset, index, step);
  9692. // Apply show first and show last. If the tick is both first and
  9693. // last, it is a single centered tick, in which case we show the
  9694. // label anyway (#2100).
  9695. if ((tick.isFirst &&
  9696. !tick.isLast &&
  9697. !pick(options.showFirstLabel, 1)) ||
  9698. (tick.isLast &&
  9699. !tick.isFirst &&
  9700. !pick(options.showLastLabel, 1))) {
  9701. show = false;
  9702. // Handle label overflow and show or hide accordingly
  9703. }
  9704. else if (horiz &&
  9705. !labelOptions.step &&
  9706. !labelOptions.rotation &&
  9707. !old &&
  9708. opacity !== 0) {
  9709. tick.handleOverflow(xy);
  9710. }
  9711. // apply step
  9712. if (step && index % step) {
  9713. // show those indices dividable by step
  9714. show = false;
  9715. }
  9716. // Set the new position, and show or hide
  9717. if (show && isNumber(xy.y)) {
  9718. xy.opacity = opacity;
  9719. label[tick.isNewLabel ? 'attr' : 'animate'](xy);
  9720. tick.isNewLabel = false;
  9721. }
  9722. else {
  9723. label.attr('y', -9999); // #1338
  9724. tick.isNewLabel = true;
  9725. }
  9726. }
  9727. };
  9728. /**
  9729. * Replace labels with the moved ones to perform animation. Additionally
  9730. * destroy unused labels.
  9731. *
  9732. * @private
  9733. * @function Highcharts.Tick#replaceMovedLabel
  9734. * @return {void}
  9735. */
  9736. Tick.prototype.replaceMovedLabel = function () {
  9737. var tick = this,
  9738. label = tick.label,
  9739. axis = tick.axis,
  9740. reversed = axis.reversed,
  9741. x,
  9742. y;
  9743. // Animate and destroy
  9744. if (label && !tick.isNew) {
  9745. x = axis.horiz ? (reversed ? axis.left : axis.width + axis.left) : label.xy.x;
  9746. y = axis.horiz ?
  9747. label.xy.y :
  9748. (reversed ? axis.width + axis.top : axis.top);
  9749. label.animate({ x: x, y: y, opacity: 0 }, void 0, label.destroy);
  9750. delete tick.label;
  9751. }
  9752. axis.isDirty = true;
  9753. tick.label = tick.movedLabel;
  9754. delete tick.movedLabel;
  9755. };
  9756. return Tick;
  9757. }());
  9758. H.Tick = Tick;
  9759. return H.Tick;
  9760. });
  9761. _registerModule(_modules, 'Core/Time.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (Highcharts, U) {
  9762. /* *
  9763. *
  9764. * (c) 2010-2020 Torstein Honsi
  9765. *
  9766. * License: www.highcharts.com/license
  9767. *
  9768. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  9769. *
  9770. * */
  9771. /**
  9772. * Normalized interval.
  9773. *
  9774. * @interface Highcharts.TimeNormalizedObject
  9775. */ /**
  9776. * The count.
  9777. *
  9778. * @name Highcharts.TimeNormalizedObject#count
  9779. * @type {number}
  9780. */ /**
  9781. * The interval in axis values (ms).
  9782. *
  9783. * @name Highcharts.TimeNormalizedObject#unitRange
  9784. * @type {number}
  9785. */
  9786. /**
  9787. * Function of an additional date format specifier.
  9788. *
  9789. * @callback Highcharts.TimeFormatCallbackFunction
  9790. *
  9791. * @param {number} timestamp
  9792. * The time to format.
  9793. *
  9794. * @return {string}
  9795. * The formatted portion of the date.
  9796. */
  9797. /**
  9798. * Additonal time tick information.
  9799. *
  9800. * @interface Highcharts.TimeTicksInfoObject
  9801. * @extends Highcharts.TimeNormalizedObject
  9802. */ /**
  9803. * @name Highcharts.TimeTicksInfoObject#higherRanks
  9804. * @type {Array<string>}
  9805. */ /**
  9806. * @name Highcharts.TimeTicksInfoObject#totalRange
  9807. * @type {number}
  9808. */
  9809. /**
  9810. * Time ticks.
  9811. *
  9812. * @interface Highcharts.AxisTickPositionsArray
  9813. * @extends global.Array<number>
  9814. */ /**
  9815. * @name Highcharts.AxisTickPositionsArray#info
  9816. * @type {Highcharts.TimeTicksInfoObject|undefined}
  9817. */
  9818. /**
  9819. * A callback to return the time zone offset for a given datetime. It
  9820. * takes the timestamp in terms of milliseconds since January 1 1970,
  9821. * and returns the timezone offset in minutes. This provides a hook
  9822. * for drawing time based charts in specific time zones using their
  9823. * local DST crossover dates, with the help of external libraries.
  9824. *
  9825. * @callback Highcharts.TimezoneOffsetCallbackFunction
  9826. *
  9827. * @param {number} timestamp
  9828. * Timestamp in terms of milliseconds since January 1 1970.
  9829. *
  9830. * @return {number}
  9831. * Timezone offset in minutes.
  9832. */
  9833. /**
  9834. * Allows to manually load the `moment.js` library from Highcharts options
  9835. * instead of the `window`.
  9836. * In case of loading the library from a `script` tag,
  9837. * this option is not needed, it will be loaded from there by default.
  9838. *
  9839. * @type {function}
  9840. * @since 8.2.0
  9841. * @apioption time.moment
  9842. */
  9843. var defined = U.defined,
  9844. error = U.error,
  9845. extend = U.extend,
  9846. isObject = U.isObject,
  9847. merge = U.merge,
  9848. objectEach = U.objectEach,
  9849. pad = U.pad,
  9850. pick = U.pick,
  9851. splat = U.splat,
  9852. timeUnits = U.timeUnits;
  9853. var H = Highcharts,
  9854. win = H.win;
  9855. /* eslint-disable no-invalid-this, valid-jsdoc */
  9856. /**
  9857. * The Time class. Time settings are applied in general for each page using
  9858. * `Highcharts.setOptions`, or individually for each Chart item through the
  9859. * [time](https://api.highcharts.com/highcharts/time) options set.
  9860. *
  9861. * The Time object is available from {@link Highcharts.Chart#time},
  9862. * which refers to `Highcharts.time` if no individual time settings are
  9863. * applied.
  9864. *
  9865. * @example
  9866. * // Apply time settings globally
  9867. * Highcharts.setOptions({
  9868. * time: {
  9869. * timezone: 'Europe/London'
  9870. * }
  9871. * });
  9872. *
  9873. * // Apply time settings by instance
  9874. * var chart = Highcharts.chart('container', {
  9875. * time: {
  9876. * timezone: 'America/New_York'
  9877. * },
  9878. * series: [{
  9879. * data: [1, 4, 3, 5]
  9880. * }]
  9881. * });
  9882. *
  9883. * // Use the Time object
  9884. * console.log(
  9885. * 'Current time in New York',
  9886. * chart.time.dateFormat('%Y-%m-%d %H:%M:%S', Date.now())
  9887. * );
  9888. *
  9889. * @since 6.0.5
  9890. *
  9891. * @class
  9892. * @name Highcharts.Time
  9893. *
  9894. * @param {Highcharts.TimeOptions} options
  9895. * Time options as defined in [chart.options.time](/highcharts/time).
  9896. */
  9897. var Time = /** @class */ (function () {
  9898. /* *
  9899. *
  9900. * Constructors
  9901. *
  9902. * */
  9903. function Time(options) {
  9904. /* *
  9905. *
  9906. * Properties
  9907. *
  9908. * */
  9909. this.options = {};
  9910. this.useUTC = false;
  9911. this.variableTimezone = false;
  9912. this.Date = win.Date;
  9913. /**
  9914. * Get the time zone offset based on the current timezone information as
  9915. * set in the global options.
  9916. *
  9917. * @function Highcharts.Time#getTimezoneOffset
  9918. *
  9919. * @param {number} timestamp
  9920. * The JavaScript timestamp to inspect.
  9921. *
  9922. * @return {number}
  9923. * The timezone offset in minutes compared to UTC.
  9924. */
  9925. this.getTimezoneOffset = this.timezoneOffsetFunction();
  9926. this.update(options);
  9927. }
  9928. /* *
  9929. *
  9930. * Functions
  9931. *
  9932. * */
  9933. /**
  9934. * Time units used in `Time.get` and `Time.set`
  9935. *
  9936. * @typedef {"Date"|"Day"|"FullYear"|"Hours"|"Milliseconds"|"Minutes"|"Month"|"Seconds"} Highcharts.TimeUnitValue
  9937. */
  9938. /**
  9939. * Get the value of a date object in given units, and subject to the Time
  9940. * object's current timezone settings. This function corresponds directly to
  9941. * JavaScripts `Date.getXXX / Date.getUTCXXX`, so instead of calling
  9942. * `date.getHours()` or `date.getUTCHours()` we will call
  9943. * `time.get('Hours')`.
  9944. *
  9945. * @function Highcharts.Time#get
  9946. *
  9947. * @param {Highcharts.TimeUnitValue} unit
  9948. * @param {Date} date
  9949. *
  9950. * @return {number}
  9951. * The given time unit
  9952. */
  9953. Time.prototype.get = function (unit, date) {
  9954. if (this.variableTimezone || this.timezoneOffset) {
  9955. var realMs = date.getTime();
  9956. var ms = realMs - this.getTimezoneOffset(date);
  9957. date.setTime(ms); // Temporary adjust to timezone
  9958. var ret = date['getUTC' + unit]();
  9959. date.setTime(realMs); // Reset
  9960. return ret;
  9961. }
  9962. // UTC time with no timezone handling
  9963. if (this.useUTC) {
  9964. return date['getUTC' + unit]();
  9965. }
  9966. // Else, local time
  9967. return date['get' + unit]();
  9968. };
  9969. /**
  9970. * Set the value of a date object in given units, and subject to the Time
  9971. * object's current timezone settings. This function corresponds directly to
  9972. * JavaScripts `Date.setXXX / Date.setUTCXXX`, so instead of calling
  9973. * `date.setHours(0)` or `date.setUTCHours(0)` we will call
  9974. * `time.set('Hours', 0)`.
  9975. *
  9976. * @function Highcharts.Time#set
  9977. *
  9978. * @param {Highcharts.TimeUnitValue} unit
  9979. * @param {Date} date
  9980. * @param {number} value
  9981. *
  9982. * @return {number}
  9983. * The epoch milliseconds of the updated date
  9984. */
  9985. Time.prototype.set = function (unit, date, value) {
  9986. // UTC time with timezone handling
  9987. if (this.variableTimezone || this.timezoneOffset) {
  9988. // For lower order time units, just set it directly using UTC
  9989. // time
  9990. if (unit === 'Milliseconds' ||
  9991. unit === 'Seconds' ||
  9992. unit === 'Minutes') {
  9993. return date['setUTC' + unit](value);
  9994. }
  9995. // Higher order time units need to take the time zone into
  9996. // account
  9997. // Adjust by timezone
  9998. var offset = this.getTimezoneOffset(date);
  9999. var ms = date.getTime() - offset;
  10000. date.setTime(ms);
  10001. date['setUTC' + unit](value);
  10002. var newOffset = this.getTimezoneOffset(date);
  10003. ms = date.getTime() + newOffset;
  10004. return date.setTime(ms);
  10005. }
  10006. // UTC time with no timezone handling
  10007. if (this.useUTC) {
  10008. return date['setUTC' + unit](value);
  10009. }
  10010. // Else, local time
  10011. return date['set' + unit](value);
  10012. };
  10013. /**
  10014. * Update the Time object with current options. It is called internally on
  10015. * initializing Highcharts, after running `Highcharts.setOptions` and on
  10016. * `Chart.update`.
  10017. *
  10018. * @private
  10019. * @function Highcharts.Time#update
  10020. *
  10021. * @param {Highcharts.TimeOptions} options
  10022. *
  10023. * @return {void}
  10024. */
  10025. Time.prototype.update = function (options) {
  10026. var useUTC = pick(options && options.useUTC,
  10027. true),
  10028. time = this;
  10029. this.options = options = merge(true, this.options || {}, options);
  10030. // Allow using a different Date class
  10031. this.Date = options.Date || win.Date || Date;
  10032. this.useUTC = useUTC;
  10033. this.timezoneOffset = (useUTC && options.timezoneOffset);
  10034. this.getTimezoneOffset = this.timezoneOffsetFunction();
  10035. /*
  10036. * The time object has options allowing for variable time zones, meaning
  10037. * the axis ticks or series data needs to consider this.
  10038. */
  10039. this.variableTimezone = !!(!useUTC ||
  10040. options.getTimezoneOffset ||
  10041. options.timezone);
  10042. };
  10043. /**
  10044. * Make a time and returns milliseconds. Interprets the inputs as UTC time,
  10045. * local time or a specific timezone time depending on the current time
  10046. * settings.
  10047. *
  10048. * @function Highcharts.Time#makeTime
  10049. *
  10050. * @param {number} year
  10051. * The year
  10052. *
  10053. * @param {number} month
  10054. * The month. Zero-based, so January is 0.
  10055. *
  10056. * @param {number} [date=1]
  10057. * The day of the month
  10058. *
  10059. * @param {number} [hours=0]
  10060. * The hour of the day, 0-23.
  10061. *
  10062. * @param {number} [minutes=0]
  10063. * The minutes
  10064. *
  10065. * @param {number} [seconds=0]
  10066. * The seconds
  10067. *
  10068. * @return {number}
  10069. * The time in milliseconds since January 1st 1970.
  10070. */
  10071. Time.prototype.makeTime = function (year, month, date, hours, minutes, seconds) {
  10072. var d,
  10073. offset,
  10074. newOffset;
  10075. if (this.useUTC) {
  10076. d = this.Date.UTC.apply(0, arguments);
  10077. offset = this.getTimezoneOffset(d);
  10078. d += offset;
  10079. newOffset = this.getTimezoneOffset(d);
  10080. if (offset !== newOffset) {
  10081. d += newOffset - offset;
  10082. // A special case for transitioning from summer time to winter time.
  10083. // When the clock is set back, the same time is repeated twice, i.e.
  10084. // 02:30 am is repeated since the clock is set back from 3 am to
  10085. // 2 am. We need to make the same time as local Date does.
  10086. }
  10087. else if (offset - 36e5 === this.getTimezoneOffset(d - 36e5) &&
  10088. !H.isSafari) {
  10089. d -= 36e5;
  10090. }
  10091. }
  10092. else {
  10093. d = new this.Date(year, month, pick(date, 1), pick(hours, 0), pick(minutes, 0), pick(seconds, 0)).getTime();
  10094. }
  10095. return d;
  10096. };
  10097. /**
  10098. * Sets the getTimezoneOffset function. If the `timezone` option is set, a
  10099. * default getTimezoneOffset function with that timezone is returned. If
  10100. * a `getTimezoneOffset` option is defined, it is returned. If neither are
  10101. * specified, the function using the `timezoneOffset` option or 0 offset is
  10102. * returned.
  10103. *
  10104. * @private
  10105. * @function Highcharts.Time#timezoneOffsetFunction
  10106. *
  10107. * @return {Function}
  10108. * A getTimezoneOffset function
  10109. */
  10110. Time.prototype.timezoneOffsetFunction = function () {
  10111. var time = this,
  10112. options = this.options,
  10113. moment = options.moment || win.moment;
  10114. if (!this.useUTC) {
  10115. return function (timestamp) {
  10116. return new Date(timestamp.toString()).getTimezoneOffset() * 60000;
  10117. };
  10118. }
  10119. if (options.timezone) {
  10120. if (!moment) {
  10121. // getTimezoneOffset-function stays undefined because it depends
  10122. // on Moment.js
  10123. error(25);
  10124. }
  10125. else {
  10126. return function (timestamp) {
  10127. return -moment.tz(timestamp, options.timezone).utcOffset() * 60000;
  10128. };
  10129. }
  10130. }
  10131. // If not timezone is set, look for the getTimezoneOffset callback
  10132. if (this.useUTC && options.getTimezoneOffset) {
  10133. return function (timestamp) {
  10134. return options.getTimezoneOffset(timestamp.valueOf()) * 60000;
  10135. };
  10136. }
  10137. // Last, use the `timezoneOffset` option if set
  10138. return function () {
  10139. return (time.timezoneOffset || 0) * 60000;
  10140. };
  10141. };
  10142. /**
  10143. * Formats a JavaScript date timestamp (milliseconds since Jan 1st 1970)
  10144. * into a human readable date string. The available format keys are listed
  10145. * below. Additional formats can be given in the
  10146. * {@link Highcharts.dateFormats} hook.
  10147. *
  10148. * Supported format keys:
  10149. * - `%a`: Short weekday, like 'Mon'
  10150. * - `%A`: Long weekday, like 'Monday'
  10151. * - `%d`: Two digit day of the month, 01 to 31
  10152. * - `%e`: Day of the month, 1 through 31
  10153. * - `%w`: Day of the week, 0 through 6
  10154. * - `%b`: Short month, like 'Jan'
  10155. * - `%B`: Long month, like 'January'
  10156. * - `%m`: Two digit month number, 01 through 12
  10157. * - `%y`: Two digits year, like 09 for 2009
  10158. * - `%Y`: Four digits year, like 2009
  10159. * - `%H`: Two digits hours in 24h format, 00 through 23
  10160. * - `%k`: Hours in 24h format, 0 through 23
  10161. * - `%I`: Two digits hours in 12h format, 00 through 11
  10162. * - `%l`: Hours in 12h format, 1 through 12
  10163. * - `%M`: Two digits minutes, 00 through 59
  10164. * - `%p`: Upper case AM or PM
  10165. * - `%P`: Lower case AM or PM
  10166. * - `%S`: Two digits seconds, 00 through 59
  10167. * - `%L`: Milliseconds (naming from Ruby)
  10168. *
  10169. * @example
  10170. * const time = new Highcharts.Time();
  10171. * const s = time.dateFormat('%Y-%m-%d %H:%M:%S', Date.UTC(2020, 0, 1));
  10172. * console.log(s); // => 2020-01-01 00:00:00
  10173. *
  10174. * @function Highcharts.Time#dateFormat
  10175. *
  10176. * @param {string} format
  10177. * The desired format where various time representations are
  10178. * prefixed with %.
  10179. *
  10180. * @param {number} timestamp
  10181. * The JavaScript timestamp.
  10182. *
  10183. * @param {boolean} [capitalize=false]
  10184. * Upper case first letter in the return.
  10185. *
  10186. * @return {string}
  10187. * The formatted date.
  10188. */
  10189. Time.prototype.dateFormat = function (format, timestamp, capitalize) {
  10190. var _a;
  10191. if (!defined(timestamp) || isNaN(timestamp)) {
  10192. return ((_a = H.defaultOptions.lang) === null || _a === void 0 ? void 0 : _a.invalidDate) || '';
  10193. }
  10194. format = pick(format, '%Y-%m-%d %H:%M:%S');
  10195. var time = this, date = new this.Date(timestamp),
  10196. // get the basic time values
  10197. 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,
  10198. // List all format keys. Custom formats can be added from the
  10199. // outside.
  10200. replacements = extend({
  10201. // Day
  10202. // Short weekday, like 'Mon'
  10203. a: shortWeekdays ?
  10204. shortWeekdays[day] :
  10205. langWeekdays[day].substr(0, 3),
  10206. // Long weekday, like 'Monday'
  10207. A: langWeekdays[day],
  10208. // Two digit day of the month, 01 to 31
  10209. d: pad(dayOfMonth),
  10210. // Day of the month, 1 through 31
  10211. e: pad(dayOfMonth, 2, ' '),
  10212. // Day of the week, 0 through 6
  10213. w: day,
  10214. // Week (none implemented)
  10215. // 'W': weekNumber(),
  10216. // Month
  10217. // Short month, like 'Jan'
  10218. b: lang.shortMonths[month],
  10219. // Long month, like 'January'
  10220. B: lang.months[month],
  10221. // Two digit month number, 01 through 12
  10222. m: pad(month + 1),
  10223. // Month number, 1 through 12 (#8150)
  10224. o: month + 1,
  10225. // Year
  10226. // Two digits year, like 09 for 2009
  10227. y: fullYear.toString().substr(2, 2),
  10228. // Four digits year, like 2009
  10229. Y: fullYear,
  10230. // Time
  10231. // Two digits hours in 24h format, 00 through 23
  10232. H: pad(hours),
  10233. // Hours in 24h format, 0 through 23
  10234. k: hours,
  10235. // Two digits hours in 12h format, 00 through 11
  10236. I: pad((hours % 12) || 12),
  10237. // Hours in 12h format, 1 through 12
  10238. l: (hours % 12) || 12,
  10239. // Two digits minutes, 00 through 59
  10240. M: pad(this.get('Minutes', date)),
  10241. // Upper case AM or PM
  10242. p: hours < 12 ? 'AM' : 'PM',
  10243. // Lower case AM or PM
  10244. P: hours < 12 ? 'am' : 'pm',
  10245. // Two digits seconds, 00 through 59
  10246. S: pad(date.getSeconds()),
  10247. // Milliseconds (naming from Ruby)
  10248. L: pad(Math.floor(timestamp % 1000), 3)
  10249. }, H.dateFormats);
  10250. // Do the replaces
  10251. objectEach(replacements, function (val, key) {
  10252. // Regex would do it in one line, but this is faster
  10253. while (format.indexOf('%' + key) !== -1) {
  10254. format = format.replace('%' + key, typeof val === 'function' ? val.call(time, timestamp) : val);
  10255. }
  10256. });
  10257. // Optionally capitalize the string and return
  10258. return capitalize ?
  10259. (format.substr(0, 1).toUpperCase() +
  10260. format.substr(1)) :
  10261. format;
  10262. };
  10263. /**
  10264. * Resolve legacy formats of dateTimeLabelFormats (strings and arrays) into
  10265. * an object.
  10266. * @private
  10267. * @param {string|Array<T>|Highcharts.Dictionary<T>} f - General format description
  10268. * @return {Highcharts.Dictionary<T>} - The object definition
  10269. */
  10270. Time.prototype.resolveDTLFormat = function (f) {
  10271. if (!isObject(f, true)) { // check for string or array
  10272. f = splat(f);
  10273. return {
  10274. main: f[0],
  10275. from: f[1],
  10276. to: f[2]
  10277. };
  10278. }
  10279. return f;
  10280. };
  10281. /**
  10282. * Return an array with time positions distributed on round time values
  10283. * right and right after min and max. Used in datetime axes as well as for
  10284. * grouping data on a datetime axis.
  10285. *
  10286. * @function Highcharts.Time#getTimeTicks
  10287. *
  10288. * @param {Highcharts.TimeNormalizedObject} normalizedInterval
  10289. * The interval in axis values (ms) and the count
  10290. *
  10291. * @param {number} [min]
  10292. * The minimum in axis values
  10293. *
  10294. * @param {number} [max]
  10295. * The maximum in axis values
  10296. *
  10297. * @param {number} [startOfWeek=1]
  10298. *
  10299. * @return {Highcharts.AxisTickPositionsArray}
  10300. */
  10301. Time.prototype.getTimeTicks = function (normalizedInterval, min, max, startOfWeek) {
  10302. var time = this,
  10303. Date = time.Date,
  10304. tickPositions = [],
  10305. i,
  10306. higherRanks = {},
  10307. minYear, // used in months and years as a basis for Date.UTC()
  10308. // When crossing DST, use the max. Resolves #6278.
  10309. minDate = new Date(min),
  10310. interval = normalizedInterval.unitRange,
  10311. count = normalizedInterval.count || 1,
  10312. variableDayLength,
  10313. minDay;
  10314. startOfWeek = pick(startOfWeek, 1);
  10315. if (defined(min)) { // #1300
  10316. time.set('Milliseconds', minDate, interval >= timeUnits.second ?
  10317. 0 : // #3935
  10318. count * Math.floor(time.get('Milliseconds', minDate) / count)); // #3652, #3654
  10319. if (interval >= timeUnits.second) { // second
  10320. time.set('Seconds', minDate, interval >= timeUnits.minute ?
  10321. 0 : // #3935
  10322. count * Math.floor(time.get('Seconds', minDate) / count));
  10323. }
  10324. if (interval >= timeUnits.minute) { // minute
  10325. time.set('Minutes', minDate, interval >= timeUnits.hour ?
  10326. 0 :
  10327. count * Math.floor(time.get('Minutes', minDate) / count));
  10328. }
  10329. if (interval >= timeUnits.hour) { // hour
  10330. time.set('Hours', minDate, interval >= timeUnits.day ?
  10331. 0 :
  10332. count * Math.floor(time.get('Hours', minDate) / count));
  10333. }
  10334. if (interval >= timeUnits.day) { // day
  10335. time.set('Date', minDate, interval >= timeUnits.month ?
  10336. 1 :
  10337. Math.max(1, count * Math.floor(time.get('Date', minDate) / count)));
  10338. }
  10339. if (interval >= timeUnits.month) { // month
  10340. time.set('Month', minDate, interval >= timeUnits.year ? 0 :
  10341. count * Math.floor(time.get('Month', minDate) / count));
  10342. minYear = time.get('FullYear', minDate);
  10343. }
  10344. if (interval >= timeUnits.year) { // year
  10345. minYear -= minYear % count;
  10346. time.set('FullYear', minDate, minYear);
  10347. }
  10348. // week is a special case that runs outside the hierarchy
  10349. if (interval === timeUnits.week) {
  10350. // get start of current week, independent of count
  10351. minDay = time.get('Day', minDate);
  10352. time.set('Date', minDate, (time.get('Date', minDate) -
  10353. minDay + startOfWeek +
  10354. // We don't want to skip days that are before
  10355. // startOfWeek (#7051)
  10356. (minDay < startOfWeek ? -7 : 0)));
  10357. }
  10358. // Get basics for variable time spans
  10359. minYear = time.get('FullYear', minDate);
  10360. var minMonth = time.get('Month', minDate), minDateDate = time.get('Date', minDate), minHours = time.get('Hours', minDate);
  10361. // Redefine min to the floored/rounded minimum time (#7432)
  10362. min = minDate.getTime();
  10363. // Handle local timezone offset
  10364. if (time.variableTimezone) {
  10365. // Detect whether we need to take the DST crossover into
  10366. // consideration. If we're crossing over DST, the day length may
  10367. // be 23h or 25h and we need to compute the exact clock time for
  10368. // each tick instead of just adding hours. This comes at a cost,
  10369. // so first we find out if it is needed (#4951).
  10370. variableDayLength = (
  10371. // Long range, assume we're crossing over.
  10372. max - min > 4 * timeUnits.month ||
  10373. // Short range, check if min and max are in different time
  10374. // zones.
  10375. time.getTimezoneOffset(min) !==
  10376. time.getTimezoneOffset(max));
  10377. }
  10378. // Iterate and add tick positions at appropriate values
  10379. var t = minDate.getTime();
  10380. i = 1;
  10381. while (t < max) {
  10382. tickPositions.push(t);
  10383. // if the interval is years, use Date.UTC to increase years
  10384. if (interval === timeUnits.year) {
  10385. t = time.makeTime(minYear + i * count, 0);
  10386. // if the interval is months, use Date.UTC to increase months
  10387. }
  10388. else if (interval === timeUnits.month) {
  10389. t = time.makeTime(minYear, minMonth + i * count);
  10390. // if we're using global time, the interval is not fixed as it
  10391. // jumps one hour at the DST crossover
  10392. }
  10393. else if (variableDayLength &&
  10394. (interval === timeUnits.day || interval === timeUnits.week)) {
  10395. t = time.makeTime(minYear, minMonth, minDateDate +
  10396. i * count * (interval === timeUnits.day ? 1 : 7));
  10397. }
  10398. else if (variableDayLength &&
  10399. interval === timeUnits.hour &&
  10400. count > 1) {
  10401. // make sure higher ranks are preserved across DST (#6797,
  10402. // #7621)
  10403. t = time.makeTime(minYear, minMonth, minDateDate, minHours + i * count);
  10404. // else, the interval is fixed and we use simple addition
  10405. }
  10406. else {
  10407. t += interval * count;
  10408. }
  10409. i++;
  10410. }
  10411. // push the last time
  10412. tickPositions.push(t);
  10413. // Handle higher ranks. Mark new days if the time is on midnight
  10414. // (#950, #1649, #1760, #3349). Use a reasonable dropout threshold
  10415. // to prevent looping over dense data grouping (#6156).
  10416. if (interval <= timeUnits.hour && tickPositions.length < 10000) {
  10417. tickPositions.forEach(function (t) {
  10418. if (
  10419. // Speed optimization, no need to run dateFormat unless
  10420. // we're on a full or half hour
  10421. t % 1800000 === 0 &&
  10422. // Check for local or global midnight
  10423. time.dateFormat('%H%M%S%L', t) === '000000000') {
  10424. higherRanks[t] = 'day';
  10425. }
  10426. });
  10427. }
  10428. }
  10429. // record information on the chosen unit - for dynamic label formatter
  10430. tickPositions.info = extend(normalizedInterval, {
  10431. higherRanks: higherRanks,
  10432. totalRange: interval * count
  10433. });
  10434. return tickPositions;
  10435. };
  10436. return Time;
  10437. }());
  10438. H.Time = Time;
  10439. return H.Time;
  10440. });
  10441. _registerModule(_modules, 'Core/Options.js', [_modules['Core/Globals.js'], _modules['Core/Color/Color.js'], _modules['Core/Time.js'], _modules['Core/Utilities.js']], function (H, Color, Time, U) {
  10442. /* *
  10443. *
  10444. * (c) 2010-2020 Torstein Honsi
  10445. *
  10446. * License: www.highcharts.com/license
  10447. *
  10448. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  10449. *
  10450. * */
  10451. var isTouchDevice = H.isTouchDevice,
  10452. svg = H.svg;
  10453. var color = Color.parse;
  10454. var merge = U.merge;
  10455. /**
  10456. * @typedef {"plotBox"|"spacingBox"} Highcharts.ButtonRelativeToValue
  10457. */
  10458. /**
  10459. * Gets fired when a series is added to the chart after load time, using the
  10460. * `addSeries` method. Returning `false` prevents the series from being added.
  10461. *
  10462. * @callback Highcharts.ChartAddSeriesCallbackFunction
  10463. *
  10464. * @param {Highcharts.Chart} this
  10465. * The chart on which the event occured.
  10466. *
  10467. * @param {Highcharts.ChartAddSeriesEventObject} event
  10468. * The event that occured.
  10469. */
  10470. /**
  10471. * Contains common event information. Through the `options` property you can
  10472. * access the series options that were passed to the `addSeries` method.
  10473. *
  10474. * @interface Highcharts.ChartAddSeriesEventObject
  10475. */ /**
  10476. * The series options that were passed to the `addSeries` method.
  10477. * @name Highcharts.ChartAddSeriesEventObject#options
  10478. * @type {Highcharts.SeriesOptionsType}
  10479. */ /**
  10480. * Prevents the default behaviour of the event.
  10481. * @name Highcharts.ChartAddSeriesEventObject#preventDefault
  10482. * @type {Function}
  10483. */ /**
  10484. * The event target.
  10485. * @name Highcharts.ChartAddSeriesEventObject#target
  10486. * @type {Highcharts.Chart}
  10487. */ /**
  10488. * The event type.
  10489. * @name Highcharts.ChartAddSeriesEventObject#type
  10490. * @type {"addSeries"}
  10491. */
  10492. /**
  10493. * Gets fired when clicking on the plot background.
  10494. *
  10495. * @callback Highcharts.ChartClickCallbackFunction
  10496. *
  10497. * @param {Highcharts.Chart} this
  10498. * The chart on which the event occured.
  10499. *
  10500. * @param {Highcharts.PointerEventObject} event
  10501. * The event that occured.
  10502. */
  10503. /**
  10504. * Contains an axes of the clicked spot.
  10505. *
  10506. * @interface Highcharts.ChartClickEventAxisObject
  10507. */ /**
  10508. * Axis at the clicked spot.
  10509. * @name Highcharts.ChartClickEventAxisObject#axis
  10510. * @type {Highcharts.Axis}
  10511. */ /**
  10512. * Axis value at the clicked spot.
  10513. * @name Highcharts.ChartClickEventAxisObject#value
  10514. * @type {number}
  10515. */
  10516. /**
  10517. * Contains information about the clicked spot on the chart. Remember the unit
  10518. * of a datetime axis is milliseconds since 1970-01-01 00:00:00.
  10519. *
  10520. * @interface Highcharts.ChartClickEventObject
  10521. * @extends Highcharts.PointerEventObject
  10522. */ /**
  10523. * Information about the x-axis on the clicked spot.
  10524. * @name Highcharts.ChartClickEventObject#xAxis
  10525. * @type {Array<Highcharts.ChartClickEventAxisObject>}
  10526. */ /**
  10527. * Information about the y-axis on the clicked spot.
  10528. * @name Highcharts.ChartClickEventObject#yAxis
  10529. * @type {Array<Highcharts.ChartClickEventAxisObject>}
  10530. */ /**
  10531. * Information about the z-axis on the clicked spot.
  10532. * @name Highcharts.ChartClickEventObject#zAxis
  10533. * @type {Array<Highcharts.ChartClickEventAxisObject>|undefined}
  10534. */
  10535. /**
  10536. * Gets fired when the chart is finished loading.
  10537. *
  10538. * @callback Highcharts.ChartLoadCallbackFunction
  10539. *
  10540. * @param {Highcharts.Chart} this
  10541. * The chart on which the event occured.
  10542. *
  10543. * @param {global.Event} event
  10544. * The event that occured.
  10545. */
  10546. /**
  10547. * Fires when the chart is redrawn, either after a call to `chart.redraw()` or
  10548. * after an axis, series or point is modified with the `redraw` option set to
  10549. * `true`.
  10550. *
  10551. * @callback Highcharts.ChartRedrawCallbackFunction
  10552. *
  10553. * @param {Highcharts.Chart} this
  10554. * The chart on which the event occured.
  10555. *
  10556. * @param {global.Event} event
  10557. * The event that occured.
  10558. */
  10559. /**
  10560. * Gets fired after initial load of the chart (directly after the `load` event),
  10561. * and after each redraw (directly after the `redraw` event).
  10562. *
  10563. * @callback Highcharts.ChartRenderCallbackFunction
  10564. *
  10565. * @param {Highcharts.Chart} this
  10566. * The chart on which the event occured.
  10567. *
  10568. * @param {global.Event} event
  10569. * The event that occured.
  10570. */
  10571. /**
  10572. * Gets fired when an area of the chart has been selected. The default action
  10573. * for the selection event is to zoom the chart to the selected area. It can be
  10574. * prevented by calling `event.preventDefault()` or return false.
  10575. *
  10576. * @callback Highcharts.ChartSelectionCallbackFunction
  10577. *
  10578. * @param {Highcharts.Chart} this
  10579. * The chart on which the event occured.
  10580. *
  10581. * @param {global.ChartSelectionContextObject} event
  10582. * Event informations
  10583. *
  10584. * @return {boolean|undefined}
  10585. * Return false to prevent the default action, usually zoom.
  10586. */
  10587. /**
  10588. * The primary axes are `xAxis[0]` and `yAxis[0]`. Remember the unit of a
  10589. * datetime axis is milliseconds since 1970-01-01 00:00:00.
  10590. *
  10591. * @interface Highcharts.ChartSelectionContextObject
  10592. * @extends global.Event
  10593. */ /**
  10594. * Arrays containing the axes of each dimension and each axis' min and max
  10595. * values.
  10596. * @name Highcharts.ChartSelectionContextObject#xAxis
  10597. * @type {Array<Highcharts.ChartSelectionAxisContextObject>}
  10598. */ /**
  10599. * Arrays containing the axes of each dimension and each axis' min and max
  10600. * values.
  10601. * @name Highcharts.ChartSelectionContextObject#yAxis
  10602. * @type {Array<Highcharts.ChartSelectionAxisContextObject>}
  10603. */
  10604. /**
  10605. * Axis context of the selection.
  10606. *
  10607. * @interface Highcharts.ChartSelectionAxisContextObject
  10608. */ /**
  10609. * The selected Axis.
  10610. * @name Highcharts.ChartSelectionAxisContextObject#axis
  10611. * @type {Highcharts.Axis}
  10612. */ /**
  10613. * The maximum axis value, either automatic or set manually.
  10614. * @name Highcharts.ChartSelectionAxisContextObject#max
  10615. * @type {number}
  10616. */ /**
  10617. * The minimum axis value, either automatic or set manually.
  10618. * @name Highcharts.ChartSelectionAxisContextObject#min
  10619. * @type {number}
  10620. */
  10621. ''; // detach doclets above
  10622. /* ************************************************************************** *
  10623. * Handle the options *
  10624. * ************************************************************************** */
  10625. /**
  10626. * Global default settings.
  10627. *
  10628. * @name Highcharts.defaultOptions
  10629. * @type {Highcharts.Options}
  10630. */ /**
  10631. * @optionparent
  10632. */
  10633. H.defaultOptions = {
  10634. /**
  10635. * An array containing the default colors for the chart's series. When
  10636. * all colors are used, new colors are pulled from the start again.
  10637. *
  10638. * Default colors can also be set on a series or series.type basis,
  10639. * see [column.colors](#plotOptions.column.colors),
  10640. * [pie.colors](#plotOptions.pie.colors).
  10641. *
  10642. * In styled mode, the colors option doesn't exist. Instead, colors
  10643. * are defined in CSS and applied either through series or point class
  10644. * names, or through the [chart.colorCount](#chart.colorCount) option.
  10645. *
  10646. *
  10647. * ### Legacy
  10648. *
  10649. * In Highcharts 3.x, the default colors were:
  10650. * ```js
  10651. * colors: ['#2f7ed8', '#0d233a', '#8bbc21', '#910000', '#1aadce',
  10652. * '#492970', '#f28f43', '#77a1e5', '#c42525', '#a6c96a']
  10653. * ```
  10654. *
  10655. * In Highcharts 2.x, the default colors were:
  10656. * ```js
  10657. * colors: ['#4572A7', '#AA4643', '#89A54E', '#80699B', '#3D96AE',
  10658. * '#DB843D', '#92A8CD', '#A47D7C', '#B5CA92']
  10659. * ```
  10660. *
  10661. * @sample {highcharts} highcharts/chart/colors/
  10662. * Assign a global color theme
  10663. *
  10664. * @type {Array<Highcharts.ColorString>}
  10665. * @default ["#7cb5ec", "#434348", "#90ed7d", "#f7a35c", "#8085e9",
  10666. * "#f15c80", "#e4d354", "#2b908f", "#f45b5b", "#91e8e1"]
  10667. */
  10668. colors: '#7cb5ec #434348 #90ed7d #f7a35c #8085e9 #f15c80 #e4d354 #2b908f #f45b5b #91e8e1'.split(' '),
  10669. /**
  10670. * Styled mode only. Configuration object for adding SVG definitions for
  10671. * reusable elements. See [gradients, shadows and
  10672. * patterns](https://www.highcharts.com/docs/chart-design-and-style/gradients-shadows-and-patterns)
  10673. * for more information and code examples.
  10674. *
  10675. * @type {*}
  10676. * @since 5.0.0
  10677. * @apioption defs
  10678. */
  10679. /**
  10680. * @ignore-option
  10681. */
  10682. symbols: ['circle', 'diamond', 'square', 'triangle', 'triangle-down'],
  10683. /**
  10684. * The language object is global and it can't be set on each chart
  10685. * initialization. Instead, use `Highcharts.setOptions` to set it before any
  10686. * chart is initialized.
  10687. *
  10688. * ```js
  10689. * Highcharts.setOptions({
  10690. * lang: {
  10691. * months: [
  10692. * 'Janvier', 'Février', 'Mars', 'Avril',
  10693. * 'Mai', 'Juin', 'Juillet', 'Août',
  10694. * 'Septembre', 'Octobre', 'Novembre', 'Décembre'
  10695. * ],
  10696. * weekdays: [
  10697. * 'Dimanche', 'Lundi', 'Mardi', 'Mercredi',
  10698. * 'Jeudi', 'Vendredi', 'Samedi'
  10699. * ]
  10700. * }
  10701. * });
  10702. * ```
  10703. */
  10704. lang: {
  10705. /**
  10706. * The loading text that appears when the chart is set into the loading
  10707. * state following a call to `chart.showLoading`.
  10708. */
  10709. loading: 'Loading...',
  10710. /**
  10711. * An array containing the months names. Corresponds to the `%B` format
  10712. * in `Highcharts.dateFormat()`.
  10713. *
  10714. * @type {Array<string>}
  10715. * @default ["January", "February", "March", "April", "May", "June",
  10716. * "July", "August", "September", "October", "November",
  10717. * "December"]
  10718. */
  10719. months: [
  10720. 'January', 'February', 'March', 'April', 'May', 'June', 'July',
  10721. 'August', 'September', 'October', 'November', 'December'
  10722. ],
  10723. /**
  10724. * An array containing the months names in abbreviated form. Corresponds
  10725. * to the `%b` format in `Highcharts.dateFormat()`.
  10726. *
  10727. * @type {Array<string>}
  10728. * @default ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
  10729. * "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
  10730. */
  10731. shortMonths: [
  10732. 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul',
  10733. 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
  10734. ],
  10735. /**
  10736. * An array containing the weekday names.
  10737. *
  10738. * @type {Array<string>}
  10739. * @default ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
  10740. * "Friday", "Saturday"]
  10741. */
  10742. weekdays: [
  10743. 'Sunday', 'Monday', 'Tuesday', 'Wednesday',
  10744. 'Thursday', 'Friday', 'Saturday'
  10745. ],
  10746. /**
  10747. * Short week days, starting Sunday. If not specified, Highcharts uses
  10748. * the first three letters of the `lang.weekdays` option.
  10749. *
  10750. * @sample highcharts/lang/shortweekdays/
  10751. * Finnish two-letter abbreviations
  10752. *
  10753. * @type {Array<string>}
  10754. * @since 4.2.4
  10755. * @apioption lang.shortWeekdays
  10756. */
  10757. /**
  10758. * What to show in a date field for invalid dates. Defaults to an empty
  10759. * string.
  10760. *
  10761. * @type {string}
  10762. * @since 4.1.8
  10763. * @product highcharts highstock
  10764. * @apioption lang.invalidDate
  10765. */
  10766. /**
  10767. * The title appearing on hovering the zoom in button. The text itself
  10768. * defaults to "+" and can be changed in the button options.
  10769. *
  10770. * @type {string}
  10771. * @default Zoom in
  10772. * @product highmaps
  10773. * @apioption lang.zoomIn
  10774. */
  10775. /**
  10776. * The title appearing on hovering the zoom out button. The text itself
  10777. * defaults to "-" and can be changed in the button options.
  10778. *
  10779. * @type {string}
  10780. * @default Zoom out
  10781. * @product highmaps
  10782. * @apioption lang.zoomOut
  10783. */
  10784. /**
  10785. * The default decimal point used in the `Highcharts.numberFormat`
  10786. * method unless otherwise specified in the function arguments.
  10787. *
  10788. * @since 1.2.2
  10789. */
  10790. decimalPoint: '.',
  10791. /**
  10792. * [Metric prefixes](https://en.wikipedia.org/wiki/Metric_prefix) used
  10793. * to shorten high numbers in axis labels. Replacing any of the
  10794. * positions with `null` causes the full number to be written. Setting
  10795. * `numericSymbols` to `null` disables shortening altogether.
  10796. *
  10797. * @sample {highcharts} highcharts/lang/numericsymbols/
  10798. * Replacing the symbols with text
  10799. * @sample {highstock} highcharts/lang/numericsymbols/
  10800. * Replacing the symbols with text
  10801. *
  10802. * @type {Array<string>}
  10803. * @default ["k", "M", "G", "T", "P", "E"]
  10804. * @since 2.3.0
  10805. */
  10806. numericSymbols: ['k', 'M', 'G', 'T', 'P', 'E'],
  10807. /**
  10808. * The magnitude of [numericSymbols](#lang.numericSymbol) replacements.
  10809. * Use 10000 for Japanese, Korean and various Chinese locales, which
  10810. * use symbols for 10^4, 10^8 and 10^12.
  10811. *
  10812. * @sample highcharts/lang/numericsymbolmagnitude/
  10813. * 10000 magnitude for Japanese
  10814. *
  10815. * @type {number}
  10816. * @default 1000
  10817. * @since 5.0.3
  10818. * @apioption lang.numericSymbolMagnitude
  10819. */
  10820. /**
  10821. * The text for the label appearing when a chart is zoomed.
  10822. *
  10823. * @since 1.2.4
  10824. */
  10825. resetZoom: 'Reset zoom',
  10826. /**
  10827. * The tooltip title for the label appearing when a chart is zoomed.
  10828. *
  10829. * @since 1.2.4
  10830. */
  10831. resetZoomTitle: 'Reset zoom level 1:1',
  10832. /**
  10833. * The default thousands separator used in the `Highcharts.numberFormat`
  10834. * method unless otherwise specified in the function arguments. Defaults
  10835. * to a single space character, which is recommended in
  10836. * [ISO 31-0](https://en.wikipedia.org/wiki/ISO_31-0#Numbers) and works
  10837. * across Anglo-American and continental European languages.
  10838. *
  10839. * @default \u0020
  10840. * @since 1.2.2
  10841. */
  10842. thousandsSep: ' '
  10843. },
  10844. /**
  10845. * Global options that don't apply to each chart. These options, like
  10846. * the `lang` options, must be set using the `Highcharts.setOptions`
  10847. * method.
  10848. *
  10849. * ```js
  10850. * Highcharts.setOptions({
  10851. * global: {
  10852. * useUTC: false
  10853. * }
  10854. * });
  10855. * ```
  10856. */
  10857. /**
  10858. * _Canvg rendering for Android 2.x is removed as of Highcharts 5.0\.
  10859. * Use the [libURL](#exporting.libURL) option to configure exporting._
  10860. *
  10861. * The URL to the additional file to lazy load for Android 2.x devices.
  10862. * These devices don't support SVG, so we download a helper file that
  10863. * contains [canvg](https://github.com/canvg/canvg), its dependency
  10864. * rbcolor, and our own CanVG Renderer class. To avoid hotlinking to
  10865. * our site, you can install canvas-tools.js on your own server and
  10866. * change this option accordingly.
  10867. *
  10868. * @deprecated
  10869. *
  10870. * @type {string}
  10871. * @default https://code.highcharts.com/{version}/modules/canvas-tools.js
  10872. * @product highcharts highmaps
  10873. * @apioption global.canvasToolsURL
  10874. */
  10875. /**
  10876. * This option is deprecated since v6.0.5. Instead, use
  10877. * [time.useUTC](#time.useUTC) that supports individual time settings
  10878. * per chart.
  10879. *
  10880. * @deprecated
  10881. *
  10882. * @type {boolean}
  10883. * @apioption global.useUTC
  10884. */
  10885. /**
  10886. * This option is deprecated since v6.0.5. Instead, use
  10887. * [time.Date](#time.Date) that supports individual time settings
  10888. * per chart.
  10889. *
  10890. * @deprecated
  10891. *
  10892. * @type {Function}
  10893. * @product highcharts highstock
  10894. * @apioption global.Date
  10895. */
  10896. /**
  10897. * This option is deprecated since v6.0.5. Instead, use
  10898. * [time.getTimezoneOffset](#time.getTimezoneOffset) that supports
  10899. * individual time settings per chart.
  10900. *
  10901. * @deprecated
  10902. *
  10903. * @type {Function}
  10904. * @product highcharts highstock
  10905. * @apioption global.getTimezoneOffset
  10906. */
  10907. /**
  10908. * This option is deprecated since v6.0.5. Instead, use
  10909. * [time.timezone](#time.timezone) that supports individual time
  10910. * settings per chart.
  10911. *
  10912. * @deprecated
  10913. *
  10914. * @type {string}
  10915. * @product highcharts highstock
  10916. * @apioption global.timezone
  10917. */
  10918. /**
  10919. * This option is deprecated since v6.0.5. Instead, use
  10920. * [time.timezoneOffset](#time.timezoneOffset) that supports individual
  10921. * time settings per chart.
  10922. *
  10923. * @deprecated
  10924. *
  10925. * @type {number}
  10926. * @product highcharts highstock
  10927. * @apioption global.timezoneOffset
  10928. */
  10929. global: {},
  10930. /**
  10931. * Time options that can apply globally or to individual charts. These
  10932. * settings affect how `datetime` axes are laid out, how tooltips are
  10933. * formatted, how series
  10934. * [pointIntervalUnit](#plotOptions.series.pointIntervalUnit) works and how
  10935. * the Highstock range selector handles time.
  10936. *
  10937. * The common use case is that all charts in the same Highcharts object
  10938. * share the same time settings, in which case the global settings are set
  10939. * using `setOptions`.
  10940. *
  10941. * ```js
  10942. * // Apply time settings globally
  10943. * Highcharts.setOptions({
  10944. * time: {
  10945. * timezone: 'Europe/London'
  10946. * }
  10947. * });
  10948. * // Apply time settings by instance
  10949. * var chart = Highcharts.chart('container', {
  10950. * time: {
  10951. * timezone: 'America/New_York'
  10952. * },
  10953. * series: [{
  10954. * data: [1, 4, 3, 5]
  10955. * }]
  10956. * });
  10957. *
  10958. * // Use the Time object
  10959. * console.log(
  10960. * 'Current time in New York',
  10961. * chart.time.dateFormat('%Y-%m-%d %H:%M:%S', Date.now())
  10962. * );
  10963. * ```
  10964. *
  10965. * Since v6.0.5, the time options were moved from the `global` obect to the
  10966. * `time` object, and time options can be set on each individual chart.
  10967. *
  10968. * @sample {highcharts|highstock}
  10969. * highcharts/time/timezone/
  10970. * Set the timezone globally
  10971. * @sample {highcharts}
  10972. * highcharts/time/individual/
  10973. * Set the timezone per chart instance
  10974. * @sample {highstock}
  10975. * stock/time/individual/
  10976. * Set the timezone per chart instance
  10977. *
  10978. * @since 6.0.5
  10979. * @optionparent time
  10980. */
  10981. time: {
  10982. /**
  10983. * A custom `Date` class for advanced date handling. For example,
  10984. * [JDate](https://github.com/tahajahangir/jdate) can be hooked in to
  10985. * handle Jalali dates.
  10986. *
  10987. * @type {*}
  10988. * @since 4.0.4
  10989. * @product highcharts highstock gantt
  10990. */
  10991. Date: void 0,
  10992. /**
  10993. * A callback to return the time zone offset for a given datetime. It
  10994. * takes the timestamp in terms of milliseconds since January 1 1970,
  10995. * and returns the timezone offset in minutes. This provides a hook
  10996. * for drawing time based charts in specific time zones using their
  10997. * local DST crossover dates, with the help of external libraries.
  10998. *
  10999. * @see [global.timezoneOffset](#global.timezoneOffset)
  11000. *
  11001. * @sample {highcharts|highstock} highcharts/time/gettimezoneoffset/
  11002. * Use moment.js to draw Oslo time regardless of browser locale
  11003. *
  11004. * @type {Highcharts.TimezoneOffsetCallbackFunction}
  11005. * @since 4.1.0
  11006. * @product highcharts highstock gantt
  11007. */
  11008. getTimezoneOffset: void 0,
  11009. /**
  11010. * Requires [moment.js](https://momentjs.com/). If the timezone option
  11011. * is specified, it creates a default
  11012. * [getTimezoneOffset](#time.getTimezoneOffset) function that looks
  11013. * up the specified timezone in moment.js. If moment.js is not included,
  11014. * this throws a Highcharts error in the console, but does not crash the
  11015. * chart.
  11016. *
  11017. * @see [getTimezoneOffset](#time.getTimezoneOffset)
  11018. *
  11019. * @sample {highcharts|highstock} highcharts/time/timezone/
  11020. * Europe/Oslo
  11021. *
  11022. * @type {string}
  11023. * @since 5.0.7
  11024. * @product highcharts highstock gantt
  11025. */
  11026. timezone: void 0,
  11027. /**
  11028. * The timezone offset in minutes. Positive values are west, negative
  11029. * values are east of UTC, as in the ECMAScript
  11030. * [getTimezoneOffset](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset)
  11031. * method. Use this to display UTC based data in a predefined time zone.
  11032. *
  11033. * @see [time.getTimezoneOffset](#time.getTimezoneOffset)
  11034. *
  11035. * @sample {highcharts|highstock} highcharts/time/timezoneoffset/
  11036. * Timezone offset
  11037. *
  11038. * @since 3.0.8
  11039. * @product highcharts highstock gantt
  11040. */
  11041. timezoneOffset: 0,
  11042. /**
  11043. * Whether to use UTC time for axis scaling, tickmark placement and
  11044. * time display in `Highcharts.dateFormat`. Advantages of using UTC
  11045. * is that the time displays equally regardless of the user agent's
  11046. * time zone settings. Local time can be used when the data is loaded
  11047. * in real time or when correct Daylight Saving Time transitions are
  11048. * required.
  11049. *
  11050. * @sample {highcharts} highcharts/time/useutc-true/
  11051. * True by default
  11052. * @sample {highcharts} highcharts/time/useutc-false/
  11053. * False
  11054. */
  11055. useUTC: true
  11056. },
  11057. /**
  11058. * General options for the chart.
  11059. */
  11060. chart: {
  11061. /**
  11062. * Default `mapData` for all series. If set to a string, it functions
  11063. * as an index into the `Highcharts.maps` array. Otherwise it is
  11064. * interpreted as map data.
  11065. *
  11066. * @see [mapData](#series.map.mapData)
  11067. *
  11068. * @sample maps/demo/geojson
  11069. * Loading geoJSON data
  11070. * @sample maps/chart/topojson
  11071. * Loading topoJSON converted to geoJSON
  11072. *
  11073. * @type {string|Array<*>|Highcharts.GeoJSON}
  11074. * @since 5.0.0
  11075. * @product highmaps
  11076. * @apioption chart.map
  11077. */
  11078. /**
  11079. * Set lat/lon transformation definitions for the chart. If not defined,
  11080. * these are extracted from the map data.
  11081. *
  11082. * @type {*}
  11083. * @since 5.0.0
  11084. * @product highmaps
  11085. * @apioption chart.mapTransforms
  11086. */
  11087. /**
  11088. * When using multiple axis, the ticks of two or more opposite axes
  11089. * will automatically be aligned by adding ticks to the axis or axes
  11090. * with the least ticks, as if `tickAmount` were specified.
  11091. *
  11092. * This can be prevented by setting `alignTicks` to false. If the grid
  11093. * lines look messy, it's a good idea to hide them for the secondary
  11094. * axis by setting `gridLineWidth` to 0.
  11095. *
  11096. * If `startOnTick` or `endOnTick` in an Axis options are set to false,
  11097. * then the `alignTicks ` will be disabled for the Axis.
  11098. *
  11099. * Disabled for logarithmic axes.
  11100. *
  11101. * @sample {highcharts} highcharts/chart/alignticks-true/
  11102. * True by default
  11103. * @sample {highcharts} highcharts/chart/alignticks-false/
  11104. * False
  11105. * @sample {highstock} stock/chart/alignticks-true/
  11106. * True by default
  11107. * @sample {highstock} stock/chart/alignticks-false/
  11108. * False
  11109. *
  11110. * @type {boolean}
  11111. * @default true
  11112. * @product highcharts highstock gantt
  11113. * @apioption chart.alignTicks
  11114. */
  11115. /**
  11116. * Set the overall animation for all chart updating. Animation can be
  11117. * disabled throughout the chart by setting it to false here. It can
  11118. * be overridden for each individual API method as a function parameter.
  11119. * The only animation not affected by this option is the initial series
  11120. * animation, see [plotOptions.series.animation](
  11121. * #plotOptions.series.animation).
  11122. *
  11123. * The animation can either be set as a boolean or a configuration
  11124. * object. If `true`, it will use the 'swing' jQuery easing and a
  11125. * duration of 500 ms. If used as a configuration object, the following
  11126. * properties are supported:
  11127. *
  11128. * - `defer`: The animation delay time in milliseconds.
  11129. *
  11130. * - `duration`: The duration of the animation in milliseconds.
  11131. *
  11132. * - `easing`: A string reference to an easing function set on the
  11133. * `Math` object. See
  11134. * [the easing demo](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-animation-easing/).
  11135. *
  11136. * When zooming on a series with less than 100 points, the chart redraw
  11137. * will be done with animation, but in case of more data points, it is
  11138. * necessary to set this option to ensure animation on zoom.
  11139. *
  11140. * @sample {highcharts} highcharts/chart/animation-none/
  11141. * Updating with no animation
  11142. * @sample {highcharts} highcharts/chart/animation-duration/
  11143. * With a longer duration
  11144. * @sample {highcharts} highcharts/chart/animation-easing/
  11145. * With a jQuery UI easing
  11146. * @sample {highmaps} maps/chart/animation-none/
  11147. * Updating with no animation
  11148. * @sample {highmaps} maps/chart/animation-duration/
  11149. * With a longer duration
  11150. *
  11151. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  11152. * @default undefined
  11153. * @apioption chart.animation
  11154. */
  11155. /**
  11156. * A CSS class name to apply to the charts container `div`, allowing
  11157. * unique CSS styling for each chart.
  11158. *
  11159. * @type {string}
  11160. * @apioption chart.className
  11161. */
  11162. /**
  11163. * Event listeners for the chart.
  11164. *
  11165. * @apioption chart.events
  11166. */
  11167. /**
  11168. * Fires when a series is added to the chart after load time, using the
  11169. * `addSeries` method. One parameter, `event`, is passed to the
  11170. * function, containing common event information. Through
  11171. * `event.options` you can access the series options that were passed to
  11172. * the `addSeries` method. Returning false prevents the series from
  11173. * being added.
  11174. *
  11175. * @sample {highcharts} highcharts/chart/events-addseries/
  11176. * Alert on add series
  11177. * @sample {highstock} stock/chart/events-addseries/
  11178. * Alert on add series
  11179. *
  11180. * @type {Highcharts.ChartAddSeriesCallbackFunction}
  11181. * @since 1.2.0
  11182. * @context Highcharts.Chart
  11183. * @apioption chart.events.addSeries
  11184. */
  11185. /**
  11186. * Fires when clicking on the plot background. One parameter, `event`,
  11187. * is passed to the function, containing common event information.
  11188. *
  11189. * Information on the clicked spot can be found through `event.xAxis`
  11190. * and `event.yAxis`, which are arrays containing the axes of each
  11191. * dimension and each axis' value at the clicked spot. The primary axes
  11192. * are `event.xAxis[0]` and `event.yAxis[0]`. Remember the unit of a
  11193. * datetime axis is milliseconds since 1970-01-01 00:00:00.
  11194. *
  11195. * ```js
  11196. * click: function(e) {
  11197. * console.log(
  11198. * Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', e.xAxis[0].value),
  11199. * e.yAxis[0].value
  11200. * )
  11201. * }
  11202. * ```
  11203. *
  11204. * @sample {highcharts} highcharts/chart/events-click/
  11205. * Alert coordinates on click
  11206. * @sample {highcharts} highcharts/chart/events-container/
  11207. * Alternatively, attach event to container
  11208. * @sample {highstock} stock/chart/events-click/
  11209. * Alert coordinates on click
  11210. * @sample {highstock} highcharts/chart/events-container/
  11211. * Alternatively, attach event to container
  11212. * @sample {highmaps} maps/chart/events-click/
  11213. * Record coordinates on click
  11214. * @sample {highmaps} highcharts/chart/events-container/
  11215. * Alternatively, attach event to container
  11216. *
  11217. * @type {Highcharts.ChartClickCallbackFunction}
  11218. * @since 1.2.0
  11219. * @context Highcharts.Chart
  11220. * @apioption chart.events.click
  11221. */
  11222. /**
  11223. * Fires when the chart is finished loading. Since v4.2.2, it also waits
  11224. * for images to be loaded, for example from point markers. One
  11225. * parameter, `event`, is passed to the function, containing common
  11226. * event information.
  11227. *
  11228. * There is also a second parameter to the chart constructor where a
  11229. * callback function can be passed to be executed on chart.load.
  11230. *
  11231. * @sample {highcharts} highcharts/chart/events-load/
  11232. * Alert on chart load
  11233. * @sample {highstock} stock/chart/events-load/
  11234. * Alert on chart load
  11235. * @sample {highmaps} maps/chart/events-load/
  11236. * Add series on chart load
  11237. *
  11238. * @type {Highcharts.ChartLoadCallbackFunction}
  11239. * @context Highcharts.Chart
  11240. * @apioption chart.events.load
  11241. */
  11242. /**
  11243. * Fires when the chart is redrawn, either after a call to
  11244. * `chart.redraw()` or after an axis, series or point is modified with
  11245. * the `redraw` option set to `true`. One parameter, `event`, is passed
  11246. * to the function, containing common event information.
  11247. *
  11248. * @sample {highcharts} highcharts/chart/events-redraw/
  11249. * Alert on chart redraw
  11250. * @sample {highstock} stock/chart/events-redraw/
  11251. * Alert on chart redraw when adding a series or moving the
  11252. * zoomed range
  11253. * @sample {highmaps} maps/chart/events-redraw/
  11254. * Set subtitle on chart redraw
  11255. *
  11256. * @type {Highcharts.ChartRedrawCallbackFunction}
  11257. * @since 1.2.0
  11258. * @context Highcharts.Chart
  11259. * @apioption chart.events.redraw
  11260. */
  11261. /**
  11262. * Fires after initial load of the chart (directly after the `load`
  11263. * event), and after each redraw (directly after the `redraw` event).
  11264. *
  11265. * @type {Highcharts.ChartRenderCallbackFunction}
  11266. * @since 5.0.7
  11267. * @context Highcharts.Chart
  11268. * @apioption chart.events.render
  11269. */
  11270. /**
  11271. * Fires when an area of the chart has been selected. Selection is
  11272. * enabled by setting the chart's zoomType. One parameter, `event`, is
  11273. * passed to the function, containing common event information. The
  11274. * default action for the selection event is to zoom the chart to the
  11275. * selected area. It can be prevented by calling
  11276. * `event.preventDefault()` or return false.
  11277. *
  11278. * Information on the selected area can be found through `event.xAxis`
  11279. * and `event.yAxis`, which are arrays containing the axes of each
  11280. * dimension and each axis' min and max values. The primary axes are
  11281. * `event.xAxis[0]` and `event.yAxis[0]`. Remember the unit of a
  11282. * datetime axis is milliseconds since 1970-01-01 00:00:00.
  11283. *
  11284. * ```js
  11285. * selection: function(event) {
  11286. * // log the min and max of the primary, datetime x-axis
  11287. * console.log(
  11288. * Highcharts.dateFormat(
  11289. * '%Y-%m-%d %H:%M:%S',
  11290. * event.xAxis[0].min
  11291. * ),
  11292. * Highcharts.dateFormat(
  11293. * '%Y-%m-%d %H:%M:%S',
  11294. * event.xAxis[0].max
  11295. * )
  11296. * );
  11297. * // log the min and max of the y axis
  11298. * console.log(event.yAxis[0].min, event.yAxis[0].max);
  11299. * }
  11300. * ```
  11301. *
  11302. * @sample {highcharts} highcharts/chart/events-selection/
  11303. * Report on selection and reset
  11304. * @sample {highcharts} highcharts/chart/events-selection-points/
  11305. * Select a range of points through a drag selection
  11306. * @sample {highstock} stock/chart/events-selection/
  11307. * Report on selection and reset
  11308. * @sample {highstock} highcharts/chart/events-selection-points/
  11309. * Select a range of points through a drag selection
  11310. * (Highcharts)
  11311. *
  11312. * @type {Highcharts.ChartSelectionCallbackFunction}
  11313. * @apioption chart.events.selection
  11314. */
  11315. /**
  11316. * The margin between the outer edge of the chart and the plot area.
  11317. * The numbers in the array designate top, right, bottom and left
  11318. * respectively. Use the options `marginTop`, `marginRight`,
  11319. * `marginBottom` and `marginLeft` for shorthand setting of one option.
  11320. *
  11321. * By default there is no margin. The actual space is dynamically
  11322. * calculated from the offset of axis labels, axis title, title,
  11323. * subtitle and legend in addition to the `spacingTop`, `spacingRight`,
  11324. * `spacingBottom` and `spacingLeft` options.
  11325. *
  11326. * @sample {highcharts} highcharts/chart/margins-zero/
  11327. * Zero margins
  11328. * @sample {highstock} stock/chart/margin-zero/
  11329. * Zero margins
  11330. *
  11331. * @type {number|Array<number>}
  11332. * @apioption chart.margin
  11333. */
  11334. /**
  11335. * The margin between the bottom outer edge of the chart and the plot
  11336. * area. Use this to set a fixed pixel value for the margin as opposed
  11337. * to the default dynamic margin. See also `spacingBottom`.
  11338. *
  11339. * @sample {highcharts} highcharts/chart/marginbottom/
  11340. * 100px bottom margin
  11341. * @sample {highstock} stock/chart/marginbottom/
  11342. * 100px bottom margin
  11343. * @sample {highmaps} maps/chart/margin/
  11344. * 100px margins
  11345. *
  11346. * @type {number}
  11347. * @since 2.0
  11348. * @apioption chart.marginBottom
  11349. */
  11350. /**
  11351. * The margin between the left outer edge of the chart and the plot
  11352. * area. Use this to set a fixed pixel value for the margin as opposed
  11353. * to the default dynamic margin. See also `spacingLeft`.
  11354. *
  11355. * @sample {highcharts} highcharts/chart/marginleft/
  11356. * 150px left margin
  11357. * @sample {highstock} stock/chart/marginleft/
  11358. * 150px left margin
  11359. * @sample {highmaps} maps/chart/margin/
  11360. * 100px margins
  11361. *
  11362. * @type {number}
  11363. * @since 2.0
  11364. * @apioption chart.marginLeft
  11365. */
  11366. /**
  11367. * The margin between the right outer edge of the chart and the plot
  11368. * area. Use this to set a fixed pixel value for the margin as opposed
  11369. * to the default dynamic margin. See also `spacingRight`.
  11370. *
  11371. * @sample {highcharts} highcharts/chart/marginright/
  11372. * 100px right margin
  11373. * @sample {highstock} stock/chart/marginright/
  11374. * 100px right margin
  11375. * @sample {highmaps} maps/chart/margin/
  11376. * 100px margins
  11377. *
  11378. * @type {number}
  11379. * @since 2.0
  11380. * @apioption chart.marginRight
  11381. */
  11382. /**
  11383. * The margin between the top outer edge of the chart and the plot area.
  11384. * Use this to set a fixed pixel value for the margin as opposed to
  11385. * the default dynamic margin. See also `spacingTop`.
  11386. *
  11387. * @sample {highcharts} highcharts/chart/margintop/ 100px top margin
  11388. * @sample {highstock} stock/chart/margintop/
  11389. * 100px top margin
  11390. * @sample {highmaps} maps/chart/margin/
  11391. * 100px margins
  11392. *
  11393. * @type {number}
  11394. * @since 2.0
  11395. * @apioption chart.marginTop
  11396. */
  11397. /**
  11398. * Callback function to override the default function that formats all
  11399. * the numbers in the chart. Returns a string with the formatted number.
  11400. *
  11401. * @sample highcharts/members/highcharts-numberformat
  11402. * Arabic digits in Highcharts
  11403. * @type {Highcharts.NumberFormatterCallbackFunction}
  11404. * @since 8.0.0
  11405. * @apioption chart.numberFormatter
  11406. */
  11407. /**
  11408. * Allows setting a key to switch between zooming and panning. Can be
  11409. * one of `alt`, `ctrl`, `meta` (the command key on Mac and Windows
  11410. * key on Windows) or `shift`. The keys are mapped directly to the key
  11411. * properties of the click event argument (`event.altKey`,
  11412. * `event.ctrlKey`, `event.metaKey` and `event.shiftKey`).
  11413. *
  11414. * @type {string}
  11415. * @since 4.0.3
  11416. * @product highcharts gantt
  11417. * @validvalue ["alt", "ctrl", "meta", "shift"]
  11418. * @apioption chart.panKey
  11419. */
  11420. /**
  11421. * Allow panning in a chart. Best used with [panKey](#chart.panKey)
  11422. * to combine zooming and panning.
  11423. *
  11424. * On touch devices, when the [tooltip.followTouchMove](
  11425. * #tooltip.followTouchMove) option is `true` (default), panning
  11426. * requires two fingers. To allow panning with one finger, set
  11427. * `followTouchMove` to `false`.
  11428. *
  11429. * @sample {highcharts} highcharts/chart/pankey/ Zooming and panning
  11430. * @sample {highstock} stock/chart/panning/ Zooming and xy panning
  11431. *
  11432. * @product highcharts highstock gantt
  11433. * @apioption chart.panning
  11434. */
  11435. /**
  11436. * Enable or disable chart panning.
  11437. *
  11438. * @type {boolean}
  11439. * @default {highcharts} false
  11440. * @default {highstock} true
  11441. * @apioption chart.panning.enabled
  11442. */
  11443. /**
  11444. * Decides in what dimensions the user can pan the chart. Can be
  11445. * one of `x`, `y`, or `xy`.
  11446. *
  11447. * @sample {highcharts} highcharts/chart/panning-type
  11448. * Zooming and xy panning
  11449. *
  11450. * @type {string}
  11451. * @validvalue ["x", "y", "xy"]
  11452. * @default x
  11453. * @apioption chart.panning.type
  11454. */
  11455. /**
  11456. * Equivalent to [zoomType](#chart.zoomType), but for multitouch
  11457. * gestures only. By default, the `pinchType` is the same as the
  11458. * `zoomType` setting. However, pinching can be enabled separately in
  11459. * some cases, for example in stock charts where a mouse drag pans the
  11460. * chart, while pinching is enabled. When [tooltip.followTouchMove](
  11461. * #tooltip.followTouchMove) is true, pinchType only applies to
  11462. * two-finger touches.
  11463. *
  11464. * @type {string}
  11465. * @default {highcharts} undefined
  11466. * @default {highstock} x
  11467. * @since 3.0
  11468. * @product highcharts highstock gantt
  11469. * @validvalue ["x", "y", "xy"]
  11470. * @apioption chart.pinchType
  11471. */
  11472. /**
  11473. * Whether to apply styled mode. When in styled mode, no presentational
  11474. * attributes or CSS are applied to the chart SVG. Instead, CSS rules
  11475. * are required to style the chart. The default style sheet is
  11476. * available from `https://code.highcharts.com/css/highcharts.css`.
  11477. *
  11478. * @type {boolean}
  11479. * @default false
  11480. * @since 7.0
  11481. * @apioption chart.styledMode
  11482. */
  11483. styledMode: false,
  11484. /**
  11485. * The corner radius of the outer chart border.
  11486. *
  11487. * @sample {highcharts} highcharts/chart/borderradius/
  11488. * 20px radius
  11489. * @sample {highstock} stock/chart/border/
  11490. * 10px radius
  11491. * @sample {highmaps} maps/chart/border/
  11492. * Border options
  11493. *
  11494. */
  11495. borderRadius: 0,
  11496. /**
  11497. * In styled mode, this sets how many colors the class names
  11498. * should rotate between. With ten colors, series (or points) are
  11499. * given class names like `highcharts-color-0`, `highcharts-color-0`
  11500. * [...] `highcharts-color-9`. The equivalent in non-styled mode
  11501. * is to set colors using the [colors](#colors) setting.
  11502. *
  11503. * @since 5.0.0
  11504. */
  11505. colorCount: 10,
  11506. /**
  11507. * Alias of `type`.
  11508. *
  11509. * @sample {highcharts} highcharts/chart/defaultseriestype/
  11510. * Bar
  11511. *
  11512. * @deprecated
  11513. *
  11514. * @product highcharts
  11515. */
  11516. defaultSeriesType: 'line',
  11517. /**
  11518. * If true, the axes will scale to the remaining visible series once
  11519. * one series is hidden. If false, hiding and showing a series will
  11520. * not affect the axes or the other series. For stacks, once one series
  11521. * within the stack is hidden, the rest of the stack will close in
  11522. * around it even if the axis is not affected.
  11523. *
  11524. * @sample {highcharts} highcharts/chart/ignorehiddenseries-true/
  11525. * True by default
  11526. * @sample {highcharts} highcharts/chart/ignorehiddenseries-false/
  11527. * False
  11528. * @sample {highcharts} highcharts/chart/ignorehiddenseries-true-stacked/
  11529. * True with stack
  11530. * @sample {highstock} stock/chart/ignorehiddenseries-true/
  11531. * True by default
  11532. * @sample {highstock} stock/chart/ignorehiddenseries-false/
  11533. * False
  11534. *
  11535. * @since 1.2.0
  11536. * @product highcharts highstock gantt
  11537. */
  11538. ignoreHiddenSeries: true,
  11539. /**
  11540. * Whether to invert the axes so that the x axis is vertical and y axis
  11541. * is horizontal. When `true`, the x axis is [reversed](#xAxis.reversed)
  11542. * by default.
  11543. *
  11544. * @productdesc {highcharts}
  11545. * If a bar series is present in the chart, it will be inverted
  11546. * automatically. Inverting the chart doesn't have an effect if there
  11547. * are no cartesian series in the chart, or if the chart is
  11548. * [polar](#chart.polar).
  11549. *
  11550. * @sample {highcharts} highcharts/chart/inverted/
  11551. * Inverted line
  11552. * @sample {highstock} stock/navigator/inverted/
  11553. * Inverted stock chart
  11554. *
  11555. * @type {boolean}
  11556. * @default false
  11557. * @product highcharts highstock gantt
  11558. * @apioption chart.inverted
  11559. */
  11560. /**
  11561. * The distance between the outer edge of the chart and the content,
  11562. * like title or legend, or axis title and labels if present. The
  11563. * numbers in the array designate top, right, bottom and left
  11564. * respectively. Use the options spacingTop, spacingRight, spacingBottom
  11565. * and spacingLeft options for shorthand setting of one option.
  11566. *
  11567. * @type {Array<number>}
  11568. * @see [chart.margin](#chart.margin)
  11569. * @default [10, 10, 15, 10]
  11570. * @since 3.0.6
  11571. */
  11572. spacing: [10, 10, 15, 10],
  11573. /**
  11574. * The button that appears after a selection zoom, allowing the user
  11575. * to reset zoom.
  11576. */
  11577. resetZoomButton: {
  11578. /**
  11579. * What frame the button placement should be related to. Can be
  11580. * either `plotBox` or `spacingBox`.
  11581. *
  11582. * @sample {highcharts} highcharts/chart/resetzoombutton-relativeto/
  11583. * Relative to the chart
  11584. * @sample {highstock} highcharts/chart/resetzoombutton-relativeto/
  11585. * Relative to the chart
  11586. *
  11587. * @type {Highcharts.ButtonRelativeToValue}
  11588. * @default plot
  11589. * @since 2.2
  11590. * @apioption chart.resetZoomButton.relativeTo
  11591. */
  11592. /**
  11593. * A collection of attributes for the button. The object takes SVG
  11594. * attributes like `fill`, `stroke`, `stroke-width` or `r`, the
  11595. * border radius. The theme also supports `style`, a collection of
  11596. * CSS properties for the text. Equivalent attributes for the hover
  11597. * state are given in `theme.states.hover`.
  11598. *
  11599. * @sample {highcharts} highcharts/chart/resetzoombutton-theme/
  11600. * Theming the button
  11601. * @sample {highstock} highcharts/chart/resetzoombutton-theme/
  11602. * Theming the button
  11603. *
  11604. * @type {Highcharts.SVGAttributes}
  11605. * @since 2.2
  11606. */
  11607. theme: {
  11608. /** @internal */
  11609. zIndex: 6
  11610. },
  11611. /**
  11612. * The position of the button.
  11613. *
  11614. * @sample {highcharts} highcharts/chart/resetzoombutton-position/
  11615. * Above the plot area
  11616. * @sample {highstock} highcharts/chart/resetzoombutton-position/
  11617. * Above the plot area
  11618. * @sample {highmaps} highcharts/chart/resetzoombutton-position/
  11619. * Above the plot area
  11620. *
  11621. * @type {Highcharts.AlignObject}
  11622. * @since 2.2
  11623. */
  11624. position: {
  11625. /**
  11626. * The horizontal alignment of the button.
  11627. */
  11628. align: 'right',
  11629. /**
  11630. * The horizontal offset of the button.
  11631. */
  11632. x: -10,
  11633. /**
  11634. * The vertical alignment of the button.
  11635. *
  11636. * @type {Highcharts.VerticalAlignValue}
  11637. * @default top
  11638. * @apioption chart.resetZoomButton.position.verticalAlign
  11639. */
  11640. /**
  11641. * The vertical offset of the button.
  11642. */
  11643. y: 10
  11644. }
  11645. },
  11646. /**
  11647. * The pixel width of the plot area border.
  11648. *
  11649. * @sample {highcharts} highcharts/chart/plotborderwidth/
  11650. * 1px border
  11651. * @sample {highstock} stock/chart/plotborder/
  11652. * 2px border
  11653. * @sample {highmaps} maps/chart/plotborder/
  11654. * Plot border options
  11655. *
  11656. * @type {number}
  11657. * @default 0
  11658. * @apioption chart.plotBorderWidth
  11659. */
  11660. /**
  11661. * Whether to apply a drop shadow to the plot area. Requires that
  11662. * plotBackgroundColor be set. The shadow can be an object configuration
  11663. * containing `color`, `offsetX`, `offsetY`, `opacity` and `width`.
  11664. *
  11665. * @sample {highcharts} highcharts/chart/plotshadow/
  11666. * Plot shadow
  11667. * @sample {highstock} stock/chart/plotshadow/
  11668. * Plot shadow
  11669. * @sample {highmaps} maps/chart/plotborder/
  11670. * Plot border options
  11671. *
  11672. * @type {boolean|Highcharts.CSSObject}
  11673. * @default false
  11674. * @apioption chart.plotShadow
  11675. */
  11676. /**
  11677. * When true, cartesian charts like line, spline, area and column are
  11678. * transformed into the polar coordinate system. This produces _polar
  11679. * charts_, also known as _radar charts_.
  11680. *
  11681. * @sample {highcharts} highcharts/demo/polar/
  11682. * Polar chart
  11683. * @sample {highcharts} highcharts/demo/polar-wind-rose/
  11684. * Wind rose, stacked polar column chart
  11685. * @sample {highcharts} highcharts/demo/polar-spider/
  11686. * Spider web chart
  11687. * @sample {highcharts} highcharts/parallel-coordinates/polar/
  11688. * Star plot, multivariate data in a polar chart
  11689. *
  11690. * @type {boolean}
  11691. * @default false
  11692. * @since 2.3.0
  11693. * @product highcharts
  11694. * @requires highcharts-more
  11695. * @apioption chart.polar
  11696. */
  11697. /**
  11698. * Whether to reflow the chart to fit the width of the container div
  11699. * on resizing the window.
  11700. *
  11701. * @sample {highcharts} highcharts/chart/reflow-true/
  11702. * True by default
  11703. * @sample {highcharts} highcharts/chart/reflow-false/
  11704. * False
  11705. * @sample {highstock} stock/chart/reflow-true/
  11706. * True by default
  11707. * @sample {highstock} stock/chart/reflow-false/
  11708. * False
  11709. * @sample {highmaps} maps/chart/reflow-true/
  11710. * True by default
  11711. * @sample {highmaps} maps/chart/reflow-false/
  11712. * False
  11713. *
  11714. * @type {boolean}
  11715. * @default true
  11716. * @since 2.1
  11717. * @apioption chart.reflow
  11718. */
  11719. /**
  11720. * The HTML element where the chart will be rendered. If it is a string,
  11721. * the element by that id is used. The HTML element can also be passed
  11722. * by direct reference, or as the first argument of the chart
  11723. * constructor, in which case the option is not needed.
  11724. *
  11725. * @sample {highcharts} highcharts/chart/reflow-true/
  11726. * String
  11727. * @sample {highcharts} highcharts/chart/renderto-object/
  11728. * Object reference
  11729. * @sample {highcharts} highcharts/chart/renderto-jquery/
  11730. * Object reference through jQuery
  11731. * @sample {highstock} stock/chart/renderto-string/
  11732. * String
  11733. * @sample {highstock} stock/chart/renderto-object/
  11734. * Object reference
  11735. * @sample {highstock} stock/chart/renderto-jquery/
  11736. * Object reference through jQuery
  11737. *
  11738. * @type {string|Highcharts.HTMLDOMElement}
  11739. * @apioption chart.renderTo
  11740. */
  11741. /**
  11742. * The background color of the marker square when selecting (zooming
  11743. * in on) an area of the chart.
  11744. *
  11745. * @see In styled mode, the selection marker fill is set with the
  11746. * `.highcharts-selection-marker` class.
  11747. *
  11748. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  11749. * @default rgba(51,92,173,0.25)
  11750. * @since 2.1.7
  11751. * @apioption chart.selectionMarkerFill
  11752. */
  11753. /**
  11754. * Whether to apply a drop shadow to the outer chart area. Requires
  11755. * that backgroundColor be set. The shadow can be an object
  11756. * configuration containing `color`, `offsetX`, `offsetY`, `opacity` and
  11757. * `width`.
  11758. *
  11759. * @sample {highcharts} highcharts/chart/shadow/
  11760. * Shadow
  11761. * @sample {highstock} stock/chart/shadow/
  11762. * Shadow
  11763. * @sample {highmaps} maps/chart/border/
  11764. * Chart border and shadow
  11765. *
  11766. * @type {boolean|Highcharts.CSSObject}
  11767. * @default false
  11768. * @apioption chart.shadow
  11769. */
  11770. /**
  11771. * Whether to show the axes initially. This only applies to empty charts
  11772. * where series are added dynamically, as axes are automatically added
  11773. * to cartesian series.
  11774. *
  11775. * @sample {highcharts} highcharts/chart/showaxes-false/
  11776. * False by default
  11777. * @sample {highcharts} highcharts/chart/showaxes-true/
  11778. * True
  11779. *
  11780. * @type {boolean}
  11781. * @since 1.2.5
  11782. * @product highcharts gantt
  11783. * @apioption chart.showAxes
  11784. */
  11785. /**
  11786. * The space between the bottom edge of the chart and the content (plot
  11787. * area, axis title and labels, title, subtitle or legend in top
  11788. * position).
  11789. *
  11790. * @sample {highcharts} highcharts/chart/spacingbottom/
  11791. * Spacing bottom set to 100
  11792. * @sample {highstock} stock/chart/spacingbottom/
  11793. * Spacing bottom set to 100
  11794. * @sample {highmaps} maps/chart/spacing/
  11795. * Spacing 100 all around
  11796. *
  11797. * @type {number}
  11798. * @default 15
  11799. * @since 2.1
  11800. * @apioption chart.spacingBottom
  11801. */
  11802. /**
  11803. * The space between the left edge of the chart and the content (plot
  11804. * area, axis title and labels, title, subtitle or legend in top
  11805. * position).
  11806. *
  11807. * @sample {highcharts} highcharts/chart/spacingleft/
  11808. * Spacing left set to 100
  11809. * @sample {highstock} stock/chart/spacingleft/
  11810. * Spacing left set to 100
  11811. * @sample {highmaps} maps/chart/spacing/
  11812. * Spacing 100 all around
  11813. *
  11814. * @type {number}
  11815. * @default 10
  11816. * @since 2.1
  11817. * @apioption chart.spacingLeft
  11818. */
  11819. /**
  11820. * The space between the right edge of the chart and the content (plot
  11821. * area, axis title and labels, title, subtitle or legend in top
  11822. * position).
  11823. *
  11824. * @sample {highcharts} highcharts/chart/spacingright-100/
  11825. * Spacing set to 100
  11826. * @sample {highcharts} highcharts/chart/spacingright-legend/
  11827. * Legend in right position with default spacing
  11828. * @sample {highstock} stock/chart/spacingright/
  11829. * Spacing set to 100
  11830. * @sample {highmaps} maps/chart/spacing/
  11831. * Spacing 100 all around
  11832. *
  11833. * @type {number}
  11834. * @default 10
  11835. * @since 2.1
  11836. * @apioption chart.spacingRight
  11837. */
  11838. /**
  11839. * The space between the top edge of the chart and the content (plot
  11840. * area, axis title and labels, title, subtitle or legend in top
  11841. * position).
  11842. *
  11843. * @sample {highcharts} highcharts/chart/spacingtop-100/
  11844. * A top spacing of 100
  11845. * @sample {highcharts} highcharts/chart/spacingtop-10/
  11846. * Floating chart title makes the plot area align to the default
  11847. * spacingTop of 10.
  11848. * @sample {highstock} stock/chart/spacingtop/
  11849. * A top spacing of 100
  11850. * @sample {highmaps} maps/chart/spacing/
  11851. * Spacing 100 all around
  11852. *
  11853. * @type {number}
  11854. * @default 10
  11855. * @since 2.1
  11856. * @apioption chart.spacingTop
  11857. */
  11858. /**
  11859. * Additional CSS styles to apply inline to the container `div`. Note
  11860. * that since the default font styles are applied in the renderer, it
  11861. * is ignorant of the individual chart options and must be set globally.
  11862. *
  11863. * @see In styled mode, general chart styles can be set with the
  11864. * `.highcharts-root` class.
  11865. * @sample {highcharts} highcharts/chart/style-serif-font/
  11866. * Using a serif type font
  11867. * @sample {highcharts} highcharts/css/em/
  11868. * Styled mode with relative font sizes
  11869. * @sample {highstock} stock/chart/style/
  11870. * Using a serif type font
  11871. * @sample {highmaps} maps/chart/style-serif-font/
  11872. * Using a serif type font
  11873. *
  11874. * @type {Highcharts.CSSObject}
  11875. * @default {"fontFamily": "\"Lucida Grande\", \"Lucida Sans Unicode\", Verdana, Arial, Helvetica, sans-serif","fontSize":"12px"}
  11876. * @apioption chart.style
  11877. */
  11878. /**
  11879. * The default series type for the chart. Can be any of the chart types
  11880. * listed under [plotOptions](#plotOptions) and [series](#series) or can
  11881. * be a series provided by an additional module.
  11882. *
  11883. * In TypeScript this option has no effect in sense of typing and
  11884. * instead the `type` option must always be set in the series.
  11885. *
  11886. * @sample {highcharts} highcharts/chart/type-bar/
  11887. * Bar
  11888. * @sample {highstock} stock/chart/type/
  11889. * Areaspline
  11890. * @sample {highmaps} maps/chart/type-mapline/
  11891. * Mapline
  11892. *
  11893. * @type {string}
  11894. * @default {highcharts} line
  11895. * @default {highstock} line
  11896. * @default {highmaps} map
  11897. * @since 2.1.0
  11898. * @apioption chart.type
  11899. */
  11900. /**
  11901. * Decides in what dimensions the user can zoom by dragging the mouse.
  11902. * Can be one of `x`, `y` or `xy`.
  11903. *
  11904. * @see [panKey](#chart.panKey)
  11905. *
  11906. * @sample {highcharts} highcharts/chart/zoomtype-none/
  11907. * None by default
  11908. * @sample {highcharts} highcharts/chart/zoomtype-x/
  11909. * X
  11910. * @sample {highcharts} highcharts/chart/zoomtype-y/
  11911. * Y
  11912. * @sample {highcharts} highcharts/chart/zoomtype-xy/
  11913. * Xy
  11914. * @sample {highstock} stock/demo/basic-line/
  11915. * None by default
  11916. * @sample {highstock} stock/chart/zoomtype-x/
  11917. * X
  11918. * @sample {highstock} stock/chart/zoomtype-y/
  11919. * Y
  11920. * @sample {highstock} stock/chart/zoomtype-xy/
  11921. * Xy
  11922. *
  11923. * @type {string}
  11924. * @product highcharts highstock gantt
  11925. * @validvalue ["x", "y", "xy"]
  11926. * @apioption chart.zoomType
  11927. */
  11928. /**
  11929. * An explicit width for the chart. By default (when `null`) the width
  11930. * is calculated from the offset width of the containing element.
  11931. *
  11932. * @sample {highcharts} highcharts/chart/width/
  11933. * 800px wide
  11934. * @sample {highstock} stock/chart/width/
  11935. * 800px wide
  11936. * @sample {highmaps} maps/chart/size/
  11937. * Chart with explicit size
  11938. *
  11939. * @type {null|number|string}
  11940. */
  11941. width: null,
  11942. /**
  11943. * An explicit height for the chart. If a _number_, the height is
  11944. * given in pixels. If given a _percentage string_ (for example
  11945. * `'56%'`), the height is given as the percentage of the actual chart
  11946. * width. This allows for preserving the aspect ratio across responsive
  11947. * sizes.
  11948. *
  11949. * By default (when `null`) the height is calculated from the offset
  11950. * height of the containing element, or 400 pixels if the containing
  11951. * element's height is 0.
  11952. *
  11953. * @sample {highcharts} highcharts/chart/height/
  11954. * 500px height
  11955. * @sample {highstock} stock/chart/height/
  11956. * 300px height
  11957. * @sample {highmaps} maps/chart/size/
  11958. * Chart with explicit size
  11959. * @sample highcharts/chart/height-percent/
  11960. * Highcharts with percentage height
  11961. *
  11962. * @type {null|number|string}
  11963. */
  11964. height: null,
  11965. /**
  11966. * The color of the outer chart border.
  11967. *
  11968. * @see In styled mode, the stroke is set with the
  11969. * `.highcharts-background` class.
  11970. *
  11971. * @sample {highcharts} highcharts/chart/bordercolor/
  11972. * Brown border
  11973. * @sample {highstock} stock/chart/border/
  11974. * Brown border
  11975. * @sample {highmaps} maps/chart/border/
  11976. * Border options
  11977. *
  11978. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  11979. */
  11980. borderColor: '#335cad',
  11981. /**
  11982. * The pixel width of the outer chart border.
  11983. *
  11984. * @see In styled mode, the stroke is set with the
  11985. * `.highcharts-background` class.
  11986. *
  11987. * @sample {highcharts} highcharts/chart/borderwidth/
  11988. * 5px border
  11989. * @sample {highstock} stock/chart/border/
  11990. * 2px border
  11991. * @sample {highmaps} maps/chart/border/
  11992. * Border options
  11993. *
  11994. * @type {number}
  11995. * @default 0
  11996. * @apioption chart.borderWidth
  11997. */
  11998. /**
  11999. * The background color or gradient for the outer chart area.
  12000. *
  12001. * @see In styled mode, the background is set with the
  12002. * `.highcharts-background` class.
  12003. *
  12004. * @sample {highcharts} highcharts/chart/backgroundcolor-color/
  12005. * Color
  12006. * @sample {highcharts} highcharts/chart/backgroundcolor-gradient/
  12007. * Gradient
  12008. * @sample {highstock} stock/chart/backgroundcolor-color/
  12009. * Color
  12010. * @sample {highstock} stock/chart/backgroundcolor-gradient/
  12011. * Gradient
  12012. * @sample {highmaps} maps/chart/backgroundcolor-color/
  12013. * Color
  12014. * @sample {highmaps} maps/chart/backgroundcolor-gradient/
  12015. * Gradient
  12016. *
  12017. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  12018. */
  12019. backgroundColor: '#ffffff',
  12020. /**
  12021. * The background color or gradient for the plot area.
  12022. *
  12023. * @see In styled mode, the plot background is set with the
  12024. * `.highcharts-plot-background` class.
  12025. *
  12026. * @sample {highcharts} highcharts/chart/plotbackgroundcolor-color/
  12027. * Color
  12028. * @sample {highcharts} highcharts/chart/plotbackgroundcolor-gradient/
  12029. * Gradient
  12030. * @sample {highstock} stock/chart/plotbackgroundcolor-color/
  12031. * Color
  12032. * @sample {highstock} stock/chart/plotbackgroundcolor-gradient/
  12033. * Gradient
  12034. * @sample {highmaps} maps/chart/plotbackgroundcolor-color/
  12035. * Color
  12036. * @sample {highmaps} maps/chart/plotbackgroundcolor-gradient/
  12037. * Gradient
  12038. *
  12039. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  12040. * @apioption chart.plotBackgroundColor
  12041. */
  12042. /**
  12043. * The URL for an image to use as the plot background. To set an image
  12044. * as the background for the entire chart, set a CSS background image
  12045. * to the container element. Note that for the image to be applied to
  12046. * exported charts, its URL needs to be accessible by the export server.
  12047. *
  12048. * @see In styled mode, a plot background image can be set with the
  12049. * `.highcharts-plot-background` class and a [custom pattern](
  12050. * https://www.highcharts.com/docs/chart-design-and-style/
  12051. * gradients-shadows-and-patterns).
  12052. *
  12053. * @sample {highcharts} highcharts/chart/plotbackgroundimage/
  12054. * Skies
  12055. * @sample {highstock} stock/chart/plotbackgroundimage/
  12056. * Skies
  12057. *
  12058. * @type {string}
  12059. * @apioption chart.plotBackgroundImage
  12060. */
  12061. /**
  12062. * The color of the inner chart or plot area border.
  12063. *
  12064. * @see In styled mode, a plot border stroke can be set with the
  12065. * `.highcharts-plot-border` class.
  12066. *
  12067. * @sample {highcharts} highcharts/chart/plotbordercolor/
  12068. * Blue border
  12069. * @sample {highstock} stock/chart/plotborder/
  12070. * Blue border
  12071. * @sample {highmaps} maps/chart/plotborder/
  12072. * Plot border options
  12073. *
  12074. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  12075. */
  12076. plotBorderColor: '#cccccc'
  12077. },
  12078. /**
  12079. * The chart's main title.
  12080. *
  12081. * @sample {highmaps} maps/title/title/
  12082. * Title options demonstrated
  12083. */
  12084. title: {
  12085. /**
  12086. * When the title is floating, the plot area will not move to make space
  12087. * for it.
  12088. *
  12089. * @sample {highcharts} highcharts/chart/zoomtype-none/
  12090. * False by default
  12091. * @sample {highcharts} highcharts/title/floating/
  12092. * True - title on top of the plot area
  12093. * @sample {highstock} stock/chart/title-floating/
  12094. * True - title on top of the plot area
  12095. *
  12096. * @type {boolean}
  12097. * @default false
  12098. * @since 2.1
  12099. * @apioption title.floating
  12100. */
  12101. /**
  12102. * CSS styles for the title. Use this for font styling, but use `align`,
  12103. * `x` and `y` for text alignment.
  12104. *
  12105. * In styled mode, the title style is given in the `.highcharts-title`
  12106. * class.
  12107. *
  12108. * @sample {highcharts} highcharts/title/style/
  12109. * Custom color and weight
  12110. * @sample {highstock} stock/chart/title-style/
  12111. * Custom color and weight
  12112. * @sample highcharts/css/titles/
  12113. * Styled mode
  12114. *
  12115. * @type {Highcharts.CSSObject}
  12116. * @default {highcharts|highmaps} { "color": "#333333", "fontSize": "18px" }
  12117. * @default {highstock} { "color": "#333333", "fontSize": "16px" }
  12118. * @apioption title.style
  12119. */
  12120. /**
  12121. * Whether to
  12122. * [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  12123. * to render the text.
  12124. *
  12125. * @type {boolean}
  12126. * @default false
  12127. * @apioption title.useHTML
  12128. */
  12129. /**
  12130. * The vertical alignment of the title. Can be one of `"top"`,
  12131. * `"middle"` and `"bottom"`. When a value is given, the title behaves
  12132. * as if [floating](#title.floating) were `true`.
  12133. *
  12134. * @sample {highcharts} highcharts/title/verticalalign/
  12135. * Chart title in bottom right corner
  12136. * @sample {highstock} stock/chart/title-verticalalign/
  12137. * Chart title in bottom right corner
  12138. *
  12139. * @type {Highcharts.VerticalAlignValue}
  12140. * @since 2.1
  12141. * @apioption title.verticalAlign
  12142. */
  12143. /**
  12144. * The x position of the title relative to the alignment within
  12145. * `chart.spacingLeft` and `chart.spacingRight`.
  12146. *
  12147. * @sample {highcharts} highcharts/title/align/
  12148. * Aligned to the plot area (x = 70px = margin left - spacing
  12149. * left)
  12150. * @sample {highstock} stock/chart/title-align/
  12151. * Aligned to the plot area (x = 50px = margin left - spacing
  12152. * left)
  12153. *
  12154. * @type {number}
  12155. * @default 0
  12156. * @since 2.0
  12157. * @apioption title.x
  12158. */
  12159. /**
  12160. * The y position of the title relative to the alignment within
  12161. * [chart.spacingTop](#chart.spacingTop) and [chart.spacingBottom](
  12162. * #chart.spacingBottom). By default it depends on the font size.
  12163. *
  12164. * @sample {highcharts} highcharts/title/y/
  12165. * Title inside the plot area
  12166. * @sample {highstock} stock/chart/title-verticalalign/
  12167. * Chart title in bottom right corner
  12168. *
  12169. * @type {number}
  12170. * @since 2.0
  12171. * @apioption title.y
  12172. */
  12173. /**
  12174. * The title of the chart. To disable the title, set the `text` to
  12175. * `undefined`.
  12176. *
  12177. * @sample {highcharts} highcharts/title/text/
  12178. * Custom title
  12179. * @sample {highstock} stock/chart/title-text/
  12180. * Custom title
  12181. *
  12182. * @default {highcharts|highmaps} Chart title
  12183. * @default {highstock} undefined
  12184. */
  12185. text: 'Chart title',
  12186. /**
  12187. * The horizontal alignment of the title. Can be one of "left", "center"
  12188. * and "right".
  12189. *
  12190. * @sample {highcharts} highcharts/title/align/
  12191. * Aligned to the plot area (x = 70px = margin left - spacing
  12192. * left)
  12193. * @sample {highstock} stock/chart/title-align/
  12194. * Aligned to the plot area (x = 50px = margin left - spacing
  12195. * left)
  12196. *
  12197. * @type {Highcharts.AlignValue}
  12198. * @since 2.0
  12199. */
  12200. align: 'center',
  12201. /**
  12202. * The margin between the title and the plot area, or if a subtitle
  12203. * is present, the margin between the subtitle and the plot area.
  12204. *
  12205. * @sample {highcharts} highcharts/title/margin-50/
  12206. * A chart title margin of 50
  12207. * @sample {highcharts} highcharts/title/margin-subtitle/
  12208. * The same margin applied with a subtitle
  12209. * @sample {highstock} stock/chart/title-margin/
  12210. * A chart title margin of 50
  12211. *
  12212. * @since 2.1
  12213. */
  12214. margin: 15,
  12215. /**
  12216. * Adjustment made to the title width, normally to reserve space for
  12217. * the exporting burger menu.
  12218. *
  12219. * @sample highcharts/title/widthadjust/
  12220. * Wider menu, greater padding
  12221. *
  12222. * @since 4.2.5
  12223. */
  12224. widthAdjust: -44
  12225. },
  12226. /**
  12227. * The chart's subtitle. This can be used both to display a subtitle below
  12228. * the main title, and to display random text anywhere in the chart. The
  12229. * subtitle can be updated after chart initialization through the
  12230. * `Chart.setTitle` method.
  12231. *
  12232. * @sample {highmaps} maps/title/subtitle/
  12233. * Subtitle options demonstrated
  12234. */
  12235. subtitle: {
  12236. /**
  12237. * When the subtitle is floating, the plot area will not move to make
  12238. * space for it.
  12239. *
  12240. * @sample {highcharts} highcharts/subtitle/floating/
  12241. * Floating title and subtitle
  12242. * @sample {highstock} stock/chart/subtitle-footnote
  12243. * Footnote floating at bottom right of plot area
  12244. *
  12245. * @type {boolean}
  12246. * @default false
  12247. * @since 2.1
  12248. * @apioption subtitle.floating
  12249. */
  12250. /**
  12251. * CSS styles for the title.
  12252. *
  12253. * In styled mode, the subtitle style is given in the
  12254. * `.highcharts-subtitle` class.
  12255. *
  12256. * @sample {highcharts} highcharts/subtitle/style/
  12257. * Custom color and weight
  12258. * @sample {highcharts} highcharts/css/titles/
  12259. * Styled mode
  12260. * @sample {highstock} stock/chart/subtitle-style
  12261. * Custom color and weight
  12262. * @sample {highstock} highcharts/css/titles/
  12263. * Styled mode
  12264. * @sample {highmaps} highcharts/css/titles/
  12265. * Styled mode
  12266. *
  12267. * @type {Highcharts.CSSObject}
  12268. * @default {"color": "#666666"}
  12269. * @apioption subtitle.style
  12270. */
  12271. /**
  12272. * Whether to
  12273. * [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  12274. * to render the text.
  12275. *
  12276. * @type {boolean}
  12277. * @default false
  12278. * @apioption subtitle.useHTML
  12279. */
  12280. /**
  12281. * The vertical alignment of the title. Can be one of `"top"`,
  12282. * `"middle"` and `"bottom"`. When middle, the subtitle behaves as
  12283. * floating.
  12284. *
  12285. * @sample {highcharts} highcharts/subtitle/verticalalign/
  12286. * Footnote at the bottom right of plot area
  12287. * @sample {highstock} stock/chart/subtitle-footnote
  12288. * Footnote at the bottom right of plot area
  12289. *
  12290. * @type {Highcharts.VerticalAlignValue}
  12291. * @since 2.1
  12292. * @apioption subtitle.verticalAlign
  12293. */
  12294. /**
  12295. * The x position of the subtitle relative to the alignment within
  12296. * `chart.spacingLeft` and `chart.spacingRight`.
  12297. *
  12298. * @sample {highcharts} highcharts/subtitle/align/
  12299. * Footnote at right of plot area
  12300. * @sample {highstock} stock/chart/subtitle-footnote
  12301. * Footnote at the bottom right of plot area
  12302. *
  12303. * @type {number}
  12304. * @default 0
  12305. * @since 2.0
  12306. * @apioption subtitle.x
  12307. */
  12308. /**
  12309. * The y position of the subtitle relative to the alignment within
  12310. * `chart.spacingTop` and `chart.spacingBottom`. By default the subtitle
  12311. * is laid out below the title unless the title is floating.
  12312. *
  12313. * @sample {highcharts} highcharts/subtitle/verticalalign/
  12314. * Footnote at the bottom right of plot area
  12315. * @sample {highstock} stock/chart/subtitle-footnote
  12316. * Footnote at the bottom right of plot area
  12317. *
  12318. * @type {number}
  12319. * @since 2.0
  12320. * @apioption subtitle.y
  12321. */
  12322. /**
  12323. * The subtitle of the chart.
  12324. *
  12325. * @sample {highcharts|highstock} highcharts/subtitle/text/
  12326. * Custom subtitle
  12327. * @sample {highcharts|highstock} highcharts/subtitle/text-formatted/
  12328. * Formatted and linked text.
  12329. */
  12330. text: '',
  12331. /**
  12332. * The horizontal alignment of the subtitle. Can be one of "left",
  12333. * "center" and "right".
  12334. *
  12335. * @sample {highcharts} highcharts/subtitle/align/
  12336. * Footnote at right of plot area
  12337. * @sample {highstock} stock/chart/subtitle-footnote
  12338. * Footnote at bottom right of plot area
  12339. *
  12340. * @type {Highcharts.AlignValue}
  12341. * @since 2.0
  12342. */
  12343. align: 'center',
  12344. /**
  12345. * Adjustment made to the subtitle width, normally to reserve space
  12346. * for the exporting burger menu.
  12347. *
  12348. * @see [title.widthAdjust](#title.widthAdjust)
  12349. *
  12350. * @sample highcharts/title/widthadjust/
  12351. * Wider menu, greater padding
  12352. *
  12353. * @since 4.2.5
  12354. */
  12355. widthAdjust: -44
  12356. },
  12357. /**
  12358. * The chart's caption, which will render below the chart and will be part
  12359. * of exported charts. The caption can be updated after chart initialization
  12360. * through the `Chart.update` or `Chart.caption.update` methods.
  12361. *
  12362. * @sample highcharts/caption/text/
  12363. * A chart with a caption
  12364. * @since 7.2.0
  12365. */
  12366. caption: {
  12367. /**
  12368. * When the caption is floating, the plot area will not move to make
  12369. * space for it.
  12370. *
  12371. * @type {boolean}
  12372. * @default false
  12373. * @apioption caption.floating
  12374. */
  12375. /**
  12376. * The margin between the caption and the plot area.
  12377. */
  12378. margin: 15,
  12379. /**
  12380. * CSS styles for the caption.
  12381. *
  12382. * In styled mode, the caption style is given in the
  12383. * `.highcharts-caption` class.
  12384. *
  12385. * @sample {highcharts} highcharts/css/titles/
  12386. * Styled mode
  12387. *
  12388. * @type {Highcharts.CSSObject}
  12389. * @default {"color": "#666666"}
  12390. * @apioption caption.style
  12391. */
  12392. /**
  12393. * Whether to
  12394. * [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  12395. * to render the text.
  12396. *
  12397. * @type {boolean}
  12398. * @default false
  12399. * @apioption caption.useHTML
  12400. */
  12401. /**
  12402. * The x position of the caption relative to the alignment within
  12403. * `chart.spacingLeft` and `chart.spacingRight`.
  12404. *
  12405. * @type {number}
  12406. * @default 0
  12407. * @apioption caption.x
  12408. */
  12409. /**
  12410. * The y position of the caption relative to the alignment within
  12411. * `chart.spacingTop` and `chart.spacingBottom`.
  12412. *
  12413. * @type {number}
  12414. * @apioption caption.y
  12415. */
  12416. /**
  12417. * The caption text of the chart.
  12418. *
  12419. * @sample {highcharts} highcharts/caption/text/
  12420. * Custom caption
  12421. */
  12422. text: '',
  12423. /**
  12424. * The horizontal alignment of the caption. Can be one of "left",
  12425. * "center" and "right".
  12426. *
  12427. * @type {Highcharts.AlignValue}
  12428. */
  12429. align: 'left',
  12430. /**
  12431. * The vertical alignment of the caption. Can be one of `"top"`,
  12432. * `"middle"` and `"bottom"`. When middle, the caption behaves as
  12433. * floating.
  12434. *
  12435. * @type {Highcharts.VerticalAlignValue}
  12436. */
  12437. verticalAlign: 'bottom'
  12438. },
  12439. /**
  12440. * The plotOptions is a wrapper object for config objects for each series
  12441. * type. The config objects for each series can also be overridden for
  12442. * each series item as given in the series array.
  12443. *
  12444. * Configuration options for the series are given in three levels. Options
  12445. * for all series in a chart are given in the [plotOptions.series](
  12446. * #plotOptions.series) object. Then options for all series of a specific
  12447. * type are given in the plotOptions of that type, for example
  12448. * `plotOptions.line`. Next, options for one single series are given in
  12449. * [the series array](#series).
  12450. */
  12451. plotOptions: {},
  12452. /**
  12453. * HTML labels that can be positioned anywhere in the chart area.
  12454. *
  12455. * This option is deprecated since v7.1.2. Instead, use
  12456. * [annotations](#annotations) that support labels.
  12457. *
  12458. * @deprecated
  12459. * @product highcharts highstock
  12460. */
  12461. labels: {
  12462. /**
  12463. * An HTML label that can be positioned anywhere in the chart area.
  12464. *
  12465. * @deprecated
  12466. * @type {Array<*>}
  12467. * @apioption labels.items
  12468. */
  12469. /**
  12470. * Inner HTML or text for the label.
  12471. *
  12472. * @deprecated
  12473. * @type {string}
  12474. * @apioption labels.items.html
  12475. */
  12476. /**
  12477. * CSS styles for each label. To position the label, use left and top
  12478. * like this:
  12479. * ```js
  12480. * style: {
  12481. * left: '100px',
  12482. * top: '100px'
  12483. * }
  12484. * ```
  12485. *
  12486. * @deprecated
  12487. * @type {Highcharts.CSSObject}
  12488. * @apioption labels.items.style
  12489. */
  12490. /**
  12491. * Shared CSS styles for all labels.
  12492. *
  12493. * @deprecated
  12494. * @type {Highcharts.CSSObject}
  12495. * @default {"color": "#333333", "position": "absolute"}
  12496. */
  12497. style: {
  12498. /**
  12499. * @ignore-option
  12500. */
  12501. position: 'absolute',
  12502. /**
  12503. * @ignore-option
  12504. */
  12505. color: '#333333'
  12506. }
  12507. },
  12508. /**
  12509. * The legend is a box containing a symbol and name for each series
  12510. * item or point item in the chart. Each series (or points in case
  12511. * of pie charts) is represented by a symbol and its name in the legend.
  12512. *
  12513. * It is possible to override the symbol creator function and create
  12514. * [custom legend symbols](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/studies/legend-custom-symbol/).
  12515. *
  12516. * @productdesc {highmaps}
  12517. * A Highmaps legend by default contains one legend item per series, but if
  12518. * a `colorAxis` is defined, the axis will be displayed in the legend.
  12519. * Either as a gradient, or as multiple legend items for `dataClasses`.
  12520. */
  12521. legend: {
  12522. /**
  12523. * The background color of the legend.
  12524. *
  12525. * @see In styled mode, the legend background fill can be applied with
  12526. * the `.highcharts-legend-box` class.
  12527. *
  12528. * @sample {highcharts} highcharts/legend/backgroundcolor/
  12529. * Yellowish background
  12530. * @sample {highstock} stock/legend/align/
  12531. * Various legend options
  12532. * @sample {highmaps} maps/legend/border-background/
  12533. * Border and background options
  12534. *
  12535. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  12536. * @apioption legend.backgroundColor
  12537. */
  12538. /**
  12539. * The width of the drawn border around the legend.
  12540. *
  12541. * @see In styled mode, the legend border stroke width can be applied
  12542. * with the `.highcharts-legend-box` class.
  12543. *
  12544. * @sample {highcharts} highcharts/legend/borderwidth/
  12545. * 2px border width
  12546. * @sample {highstock} stock/legend/align/
  12547. * Various legend options
  12548. * @sample {highmaps} maps/legend/border-background/
  12549. * Border and background options
  12550. *
  12551. * @type {number}
  12552. * @default 0
  12553. * @apioption legend.borderWidth
  12554. */
  12555. /**
  12556. * Enable or disable the legend. There is also a series-specific option,
  12557. * [showInLegend](#plotOptions.series.showInLegend), that can hide the
  12558. * series from the legend. In some series types this is `false` by
  12559. * default, so it must set to `true` in order to show the legend for the
  12560. * series.
  12561. *
  12562. * @sample {highcharts} highcharts/legend/enabled-false/ Legend disabled
  12563. * @sample {highstock} stock/legend/align/ Various legend options
  12564. * @sample {highmaps} maps/legend/enabled-false/ Legend disabled
  12565. *
  12566. * @default {highstock} false
  12567. * @default {highmaps} true
  12568. * @default {gantt} false
  12569. */
  12570. enabled: true,
  12571. /**
  12572. * The horizontal alignment of the legend box within the chart area.
  12573. * Valid values are `left`, `center` and `right`.
  12574. *
  12575. * In the case that the legend is aligned in a corner position, the
  12576. * `layout` option will determine whether to place it above/below
  12577. * or on the side of the plot area.
  12578. *
  12579. * @sample {highcharts} highcharts/legend/align/
  12580. * Legend at the right of the chart
  12581. * @sample {highstock} stock/legend/align/
  12582. * Various legend options
  12583. * @sample {highmaps} maps/legend/alignment/
  12584. * Legend alignment
  12585. *
  12586. * @type {Highcharts.AlignValue}
  12587. * @since 2.0
  12588. */
  12589. align: 'center',
  12590. /**
  12591. * If the [layout](legend.layout) is `horizontal` and the legend items
  12592. * span over two lines or more, whether to align the items into vertical
  12593. * columns. Setting this to `false` makes room for more items, but will
  12594. * look more messy.
  12595. *
  12596. * @since 6.1.0
  12597. */
  12598. alignColumns: true,
  12599. /**
  12600. * When the legend is floating, the plot area ignores it and is allowed
  12601. * to be placed below it.
  12602. *
  12603. * @sample {highcharts} highcharts/legend/floating-false/
  12604. * False by default
  12605. * @sample {highcharts} highcharts/legend/floating-true/
  12606. * True
  12607. * @sample {highmaps} maps/legend/alignment/
  12608. * Floating legend
  12609. *
  12610. * @type {boolean}
  12611. * @default false
  12612. * @since 2.1
  12613. * @apioption legend.floating
  12614. */
  12615. /**
  12616. * The layout of the legend items. Can be one of `horizontal` or
  12617. * `vertical` or `proximate`. When `proximate`, the legend items will be
  12618. * placed as close as possible to the graphs they're representing,
  12619. * except in inverted charts or when the legend position doesn't allow
  12620. * it.
  12621. *
  12622. * @sample {highcharts} highcharts/legend/layout-horizontal/
  12623. * Horizontal by default
  12624. * @sample {highcharts} highcharts/legend/layout-vertical/
  12625. * Vertical
  12626. * @sample highcharts/legend/layout-proximate
  12627. * Labels proximate to the data
  12628. * @sample {highstock} stock/legend/layout-horizontal/
  12629. * Horizontal by default
  12630. * @sample {highmaps} maps/legend/padding-itemmargin/
  12631. * Vertical with data classes
  12632. * @sample {highmaps} maps/legend/layout-vertical/
  12633. * Vertical with color axis gradient
  12634. *
  12635. * @validvalue ["horizontal", "vertical", "proximate"]
  12636. */
  12637. layout: 'horizontal',
  12638. /**
  12639. * In a legend with horizontal layout, the itemDistance defines the
  12640. * pixel distance between each item.
  12641. *
  12642. * @sample {highcharts} highcharts/legend/layout-horizontal/
  12643. * 50px item distance
  12644. * @sample {highstock} highcharts/legend/layout-horizontal/
  12645. * 50px item distance
  12646. *
  12647. * @type {number}
  12648. * @default {highcharts} 20
  12649. * @default {highstock} 20
  12650. * @default {highmaps} 8
  12651. * @since 3.0.3
  12652. * @apioption legend.itemDistance
  12653. */
  12654. /**
  12655. * The pixel bottom margin for each legend item.
  12656. *
  12657. * @sample {highcharts|highstock} highcharts/legend/padding-itemmargin/
  12658. * Padding and item margins demonstrated
  12659. * @sample {highmaps} maps/legend/padding-itemmargin/
  12660. * Padding and item margins demonstrated
  12661. *
  12662. * @type {number}
  12663. * @default 0
  12664. * @since 2.2.0
  12665. * @apioption legend.itemMarginBottom
  12666. */
  12667. /**
  12668. * The pixel top margin for each legend item.
  12669. *
  12670. * @sample {highcharts|highstock} highcharts/legend/padding-itemmargin/
  12671. * Padding and item margins demonstrated
  12672. * @sample {highmaps} maps/legend/padding-itemmargin/
  12673. * Padding and item margins demonstrated
  12674. *
  12675. * @type {number}
  12676. * @default 0
  12677. * @since 2.2.0
  12678. * @apioption legend.itemMarginTop
  12679. */
  12680. /**
  12681. * The width for each legend item. By default the items are laid out
  12682. * successively. In a [horizontal layout](legend.layout), if the items
  12683. * are laid out across two rows or more, they will be vertically aligned
  12684. * depending on the [legend.alignColumns](legend.alignColumns) option.
  12685. *
  12686. * @sample {highcharts} highcharts/legend/itemwidth-default/
  12687. * Undefined by default
  12688. * @sample {highcharts} highcharts/legend/itemwidth-80/
  12689. * 80 for aligned legend items
  12690. *
  12691. * @type {number}
  12692. * @since 2.0
  12693. * @apioption legend.itemWidth
  12694. */
  12695. /**
  12696. * A [format string](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting)
  12697. * for each legend label. Available variables relates to properties on
  12698. * the series, or the point in case of pies.
  12699. *
  12700. * @type {string}
  12701. * @default {name}
  12702. * @since 1.3
  12703. * @apioption legend.labelFormat
  12704. */
  12705. /* eslint-disable valid-jsdoc */
  12706. /**
  12707. * Callback function to format each of the series' labels. The `this`
  12708. * keyword refers to the series object, or the point object in case of
  12709. * pie charts. By default the series or point name is printed.
  12710. *
  12711. * @productdesc {highmaps}
  12712. * In Highmaps the context can also be a data class in case of a
  12713. * `colorAxis`.
  12714. *
  12715. * @sample {highcharts} highcharts/legend/labelformatter/
  12716. * Add text
  12717. * @sample {highmaps} maps/legend/labelformatter/
  12718. * Data classes with label formatter
  12719. *
  12720. * @type {Highcharts.FormatterCallbackFunction<Point|Series>}
  12721. */
  12722. labelFormatter: function () {
  12723. /** eslint-enable valid-jsdoc */
  12724. return this.name;
  12725. },
  12726. /**
  12727. * Line height for the legend items. Deprecated as of 2.1\. Instead,
  12728. * the line height for each item can be set using
  12729. * `itemStyle.lineHeight`, and the padding between items using
  12730. * `itemMarginTop` and `itemMarginBottom`.
  12731. *
  12732. * @sample {highcharts} highcharts/legend/lineheight/
  12733. * Setting padding
  12734. *
  12735. * @deprecated
  12736. *
  12737. * @type {number}
  12738. * @default 16
  12739. * @since 2.0
  12740. * @product highcharts gantt
  12741. * @apioption legend.lineHeight
  12742. */
  12743. /**
  12744. * If the plot area sized is calculated automatically and the legend is
  12745. * not floating, the legend margin is the space between the legend and
  12746. * the axis labels or plot area.
  12747. *
  12748. * @sample {highcharts} highcharts/legend/margin-default/
  12749. * 12 pixels by default
  12750. * @sample {highcharts} highcharts/legend/margin-30/
  12751. * 30 pixels
  12752. *
  12753. * @type {number}
  12754. * @default 12
  12755. * @since 2.1
  12756. * @apioption legend.margin
  12757. */
  12758. /**
  12759. * Maximum pixel height for the legend. When the maximum height is
  12760. * extended, navigation will show.
  12761. *
  12762. * @type {number}
  12763. * @since 2.3.0
  12764. * @apioption legend.maxHeight
  12765. */
  12766. /**
  12767. * The color of the drawn border around the legend.
  12768. *
  12769. * @see In styled mode, the legend border stroke can be applied with the
  12770. * `.highcharts-legend-box` class.
  12771. *
  12772. * @sample {highcharts} highcharts/legend/bordercolor/
  12773. * Brown border
  12774. * @sample {highstock} stock/legend/align/
  12775. * Various legend options
  12776. * @sample {highmaps} maps/legend/border-background/
  12777. * Border and background options
  12778. *
  12779. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  12780. */
  12781. borderColor: '#999999',
  12782. /**
  12783. * The border corner radius of the legend.
  12784. *
  12785. * @sample {highcharts} highcharts/legend/borderradius-default/
  12786. * Square by default
  12787. * @sample {highcharts} highcharts/legend/borderradius-round/
  12788. * 5px rounded
  12789. * @sample {highmaps} maps/legend/border-background/
  12790. * Border and background options
  12791. */
  12792. borderRadius: 0,
  12793. /**
  12794. * Options for the paging or navigation appearing when the legend is
  12795. * overflown. Navigation works well on screen, but not in static
  12796. * exported images. One way of working around that is to
  12797. * [increase the chart height in
  12798. * export](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/legend/navigation-enabled-false/).
  12799. */
  12800. navigation: {
  12801. /**
  12802. * How to animate the pages when navigating up or down. A value of
  12803. * `true` applies the default navigation given in the
  12804. * `chart.animation` option. Additional options can be given as an
  12805. * object containing values for easing and duration.
  12806. *
  12807. * @sample {highcharts} highcharts/legend/navigation/
  12808. * Legend page navigation demonstrated
  12809. * @sample {highstock} highcharts/legend/navigation/
  12810. * Legend page navigation demonstrated
  12811. *
  12812. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  12813. * @default true
  12814. * @since 2.2.4
  12815. * @apioption legend.navigation.animation
  12816. */
  12817. /**
  12818. * The pixel size of the up and down arrows in the legend paging
  12819. * navigation.
  12820. *
  12821. * @sample {highcharts} highcharts/legend/navigation/
  12822. * Legend page navigation demonstrated
  12823. * @sample {highstock} highcharts/legend/navigation/
  12824. * Legend page navigation demonstrated
  12825. *
  12826. * @type {number}
  12827. * @default 12
  12828. * @since 2.2.4
  12829. * @apioption legend.navigation.arrowSize
  12830. */
  12831. /**
  12832. * Whether to enable the legend navigation. In most cases, disabling
  12833. * the navigation results in an unwanted overflow.
  12834. *
  12835. * See also the [adapt chart to legend](
  12836. * https://www.highcharts.com/products/plugin-registry/single/8/Adapt-Chart-To-Legend)
  12837. * plugin for a solution to extend the chart height to make room for
  12838. * the legend, optionally in exported charts only.
  12839. *
  12840. * @type {boolean}
  12841. * @default true
  12842. * @since 4.2.4
  12843. * @apioption legend.navigation.enabled
  12844. */
  12845. /**
  12846. * Text styles for the legend page navigation.
  12847. *
  12848. * @see In styled mode, the navigation items are styled with the
  12849. * `.highcharts-legend-navigation` class.
  12850. *
  12851. * @sample {highcharts} highcharts/legend/navigation/
  12852. * Legend page navigation demonstrated
  12853. * @sample {highstock} highcharts/legend/navigation/
  12854. * Legend page navigation demonstrated
  12855. *
  12856. * @type {Highcharts.CSSObject}
  12857. * @since 2.2.4
  12858. * @apioption legend.navigation.style
  12859. */
  12860. /**
  12861. * The color for the active up or down arrow in the legend page
  12862. * navigation.
  12863. *
  12864. * @see In styled mode, the active arrow be styled with the
  12865. * `.highcharts-legend-nav-active` class.
  12866. *
  12867. * @sample {highcharts} highcharts/legend/navigation/
  12868. * Legend page navigation demonstrated
  12869. * @sample {highstock} highcharts/legend/navigation/
  12870. * Legend page navigation demonstrated
  12871. *
  12872. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  12873. * @since 2.2.4
  12874. */
  12875. activeColor: '#003399',
  12876. /**
  12877. * The color of the inactive up or down arrow in the legend page
  12878. * navigation. .
  12879. *
  12880. * @see In styled mode, the inactive arrow be styled with the
  12881. * `.highcharts-legend-nav-inactive` class.
  12882. *
  12883. * @sample {highcharts} highcharts/legend/navigation/
  12884. * Legend page navigation demonstrated
  12885. * @sample {highstock} highcharts/legend/navigation/
  12886. * Legend page navigation demonstrated
  12887. *
  12888. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  12889. * @since 2.2.4
  12890. */
  12891. inactiveColor: '#cccccc'
  12892. },
  12893. /**
  12894. * The inner padding of the legend box.
  12895. *
  12896. * @sample {highcharts|highstock} highcharts/legend/padding-itemmargin/
  12897. * Padding and item margins demonstrated
  12898. * @sample {highmaps} maps/legend/padding-itemmargin/
  12899. * Padding and item margins demonstrated
  12900. *
  12901. * @type {number}
  12902. * @default 8
  12903. * @since 2.2.0
  12904. * @apioption legend.padding
  12905. */
  12906. /**
  12907. * Whether to reverse the order of the legend items compared to the
  12908. * order of the series or points as defined in the configuration object.
  12909. *
  12910. * @see [yAxis.reversedStacks](#yAxis.reversedStacks),
  12911. * [series.legendIndex](#series.legendIndex)
  12912. *
  12913. * @sample {highcharts} highcharts/legend/reversed/
  12914. * Stacked bar with reversed legend
  12915. *
  12916. * @type {boolean}
  12917. * @default false
  12918. * @since 1.2.5
  12919. * @apioption legend.reversed
  12920. */
  12921. /**
  12922. * Whether to show the symbol on the right side of the text rather than
  12923. * the left side. This is common in Arabic and Hebraic.
  12924. *
  12925. * @sample {highcharts} highcharts/legend/rtl/
  12926. * Symbol to the right
  12927. *
  12928. * @type {boolean}
  12929. * @default false
  12930. * @since 2.2
  12931. * @apioption legend.rtl
  12932. */
  12933. /**
  12934. * CSS styles for the legend area. In the 1.x versions the position
  12935. * of the legend area was determined by CSS. In 2.x, the position is
  12936. * determined by properties like `align`, `verticalAlign`, `x` and `y`,
  12937. * but the styles are still parsed for backwards compatibility.
  12938. *
  12939. * @deprecated
  12940. *
  12941. * @type {Highcharts.CSSObject}
  12942. * @product highcharts highstock
  12943. * @apioption legend.style
  12944. */
  12945. /**
  12946. * CSS styles for each legend item. Only a subset of CSS is supported,
  12947. * notably those options related to text. The default `textOverflow`
  12948. * property makes long texts truncate. Set it to `undefined` to wrap
  12949. * text instead. A `width` property can be added to control the text
  12950. * width.
  12951. *
  12952. * @see In styled mode, the legend items can be styled with the
  12953. * `.highcharts-legend-item` class.
  12954. *
  12955. * @sample {highcharts} highcharts/legend/itemstyle/
  12956. * Bold black text
  12957. * @sample {highmaps} maps/legend/itemstyle/
  12958. * Item text styles
  12959. *
  12960. * @type {Highcharts.CSSObject}
  12961. * @default {"color": "#333333", "cursor": "pointer", "fontSize": "12px", "fontWeight": "bold", "textOverflow": "ellipsis"}
  12962. */
  12963. itemStyle: {
  12964. /**
  12965. * @ignore
  12966. */
  12967. color: '#333333',
  12968. /**
  12969. * @ignore
  12970. */
  12971. cursor: 'pointer',
  12972. /**
  12973. * @ignore
  12974. */
  12975. fontSize: '12px',
  12976. /**
  12977. * @ignore
  12978. */
  12979. fontWeight: 'bold',
  12980. /**
  12981. * @ignore
  12982. */
  12983. textOverflow: 'ellipsis'
  12984. },
  12985. /**
  12986. * CSS styles for each legend item in hover mode. Only a subset of
  12987. * CSS is supported, notably those options related to text. Properties
  12988. * are inherited from `style` unless overridden here.
  12989. *
  12990. * @see In styled mode, the hovered legend items can be styled with
  12991. * the `.highcharts-legend-item:hover` pesudo-class.
  12992. *
  12993. * @sample {highcharts} highcharts/legend/itemhoverstyle/
  12994. * Red on hover
  12995. * @sample {highmaps} maps/legend/itemstyle/
  12996. * Item text styles
  12997. *
  12998. * @type {Highcharts.CSSObject}
  12999. * @default {"color": "#000000"}
  13000. */
  13001. itemHoverStyle: {
  13002. /**
  13003. * @ignore
  13004. */
  13005. color: '#000000'
  13006. },
  13007. /**
  13008. * CSS styles for each legend item when the corresponding series or
  13009. * point is hidden. Only a subset of CSS is supported, notably those
  13010. * options related to text. Properties are inherited from `style`
  13011. * unless overridden here.
  13012. *
  13013. * @see In styled mode, the hidden legend items can be styled with
  13014. * the `.highcharts-legend-item-hidden` class.
  13015. *
  13016. * @sample {highcharts} highcharts/legend/itemhiddenstyle/
  13017. * Darker gray color
  13018. *
  13019. * @type {Highcharts.CSSObject}
  13020. * @default {"color": "#cccccc"}
  13021. */
  13022. itemHiddenStyle: {
  13023. /**
  13024. * @ignore
  13025. */
  13026. color: '#cccccc'
  13027. },
  13028. /**
  13029. * Whether to apply a drop shadow to the legend. A `backgroundColor`
  13030. * also needs to be applied for this to take effect. The shadow can be
  13031. * an object configuration containing `color`, `offsetX`, `offsetY`,
  13032. * `opacity` and `width`.
  13033. *
  13034. * @sample {highcharts} highcharts/legend/shadow/
  13035. * White background and drop shadow
  13036. * @sample {highstock} stock/legend/align/
  13037. * Various legend options
  13038. * @sample {highmaps} maps/legend/border-background/
  13039. * Border and background options
  13040. *
  13041. * @type {boolean|Highcharts.CSSObject}
  13042. */
  13043. shadow: false,
  13044. /**
  13045. * Default styling for the checkbox next to a legend item when
  13046. * `showCheckbox` is true.
  13047. *
  13048. * @type {Highcharts.CSSObject}
  13049. * @default {"width": "13px", "height": "13px", "position":"absolute"}
  13050. */
  13051. itemCheckboxStyle: {
  13052. /**
  13053. * @ignore
  13054. */
  13055. position: 'absolute',
  13056. /**
  13057. * @ignore
  13058. */
  13059. width: '13px',
  13060. /**
  13061. * @ignore
  13062. */
  13063. height: '13px'
  13064. },
  13065. // itemWidth: undefined,
  13066. /**
  13067. * When this is true, the legend symbol width will be the same as
  13068. * the symbol height, which in turn defaults to the font size of the
  13069. * legend items.
  13070. *
  13071. * @since 5.0.0
  13072. */
  13073. squareSymbol: true,
  13074. /**
  13075. * The pixel height of the symbol for series types that use a rectangle
  13076. * in the legend. Defaults to the font size of legend items.
  13077. *
  13078. * @productdesc {highmaps}
  13079. * In Highmaps, when the symbol is the gradient of a vertical color
  13080. * axis, the height defaults to 200.
  13081. *
  13082. * @sample {highmaps} maps/legend/layout-vertical-sized/
  13083. * Sized vertical gradient
  13084. * @sample {highmaps} maps/legend/padding-itemmargin/
  13085. * No distance between data classes
  13086. *
  13087. * @type {number}
  13088. * @since 3.0.8
  13089. * @apioption legend.symbolHeight
  13090. */
  13091. /**
  13092. * The border radius of the symbol for series types that use a rectangle
  13093. * in the legend. Defaults to half the `symbolHeight`.
  13094. *
  13095. * @sample {highcharts} highcharts/legend/symbolradius/
  13096. * Round symbols
  13097. * @sample {highstock} highcharts/legend/symbolradius/
  13098. * Round symbols
  13099. * @sample {highmaps} highcharts/legend/symbolradius/
  13100. * Round symbols
  13101. *
  13102. * @type {number}
  13103. * @since 3.0.8
  13104. * @apioption legend.symbolRadius
  13105. */
  13106. /**
  13107. * The pixel width of the legend item symbol. When the `squareSymbol`
  13108. * option is set, this defaults to the `symbolHeight`, otherwise 16.
  13109. *
  13110. * @productdesc {highmaps}
  13111. * In Highmaps, when the symbol is the gradient of a horizontal color
  13112. * axis, the width defaults to 200.
  13113. *
  13114. * @sample {highcharts} highcharts/legend/symbolwidth/
  13115. * Greater symbol width and padding
  13116. * @sample {highmaps} maps/legend/padding-itemmargin/
  13117. * Padding and item margins demonstrated
  13118. * @sample {highmaps} maps/legend/layout-vertical-sized/
  13119. * Sized vertical gradient
  13120. *
  13121. * @type {number}
  13122. * @apioption legend.symbolWidth
  13123. */
  13124. /**
  13125. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  13126. * to render the legend item texts.
  13127. *
  13128. * Prior to 4.1.7, when using HTML, [legend.navigation](
  13129. * #legend.navigation) was disabled.
  13130. *
  13131. * @type {boolean}
  13132. * @default false
  13133. * @apioption legend.useHTML
  13134. */
  13135. /**
  13136. * The width of the legend box. If a number is set, it translates to
  13137. * pixels. Since v7.0.2 it allows setting a percent string of the full
  13138. * chart width, for example `40%`.
  13139. *
  13140. * Defaults to the full chart width for legends below or above the
  13141. * chart, half the chart width for legends to the left and right.
  13142. *
  13143. * @sample {highcharts} highcharts/legend/width/
  13144. * Aligned to the plot area
  13145. * @sample {highcharts} highcharts/legend/width-percent/
  13146. * A percent of the chart width
  13147. *
  13148. * @type {number|string}
  13149. * @since 2.0
  13150. * @apioption legend.width
  13151. */
  13152. /**
  13153. * The pixel padding between the legend item symbol and the legend
  13154. * item text.
  13155. *
  13156. * @sample {highcharts} highcharts/legend/symbolpadding/
  13157. * Greater symbol width and padding
  13158. */
  13159. symbolPadding: 5,
  13160. /**
  13161. * The vertical alignment of the legend box. Can be one of `top`,
  13162. * `middle` or `bottom`. Vertical position can be further determined
  13163. * by the `y` option.
  13164. *
  13165. * In the case that the legend is aligned in a corner position, the
  13166. * `layout` option will determine whether to place it above/below
  13167. * or on the side of the plot area.
  13168. *
  13169. * When the [layout](#legend.layout) option is `proximate`, the
  13170. * `verticalAlign` option doesn't apply.
  13171. *
  13172. * @sample {highcharts} highcharts/legend/verticalalign/
  13173. * Legend 100px from the top of the chart
  13174. * @sample {highstock} stock/legend/align/
  13175. * Various legend options
  13176. * @sample {highmaps} maps/legend/alignment/
  13177. * Legend alignment
  13178. *
  13179. * @type {Highcharts.VerticalAlignValue}
  13180. * @since 2.0
  13181. */
  13182. verticalAlign: 'bottom',
  13183. // width: undefined,
  13184. /**
  13185. * The x offset of the legend relative to its horizontal alignment
  13186. * `align` within chart.spacingLeft and chart.spacingRight. Negative
  13187. * x moves it to the left, positive x moves it to the right.
  13188. *
  13189. * @sample {highcharts} highcharts/legend/width/
  13190. * Aligned to the plot area
  13191. *
  13192. * @since 2.0
  13193. */
  13194. x: 0,
  13195. /**
  13196. * The vertical offset of the legend relative to it's vertical alignment
  13197. * `verticalAlign` within chart.spacingTop and chart.spacingBottom.
  13198. * Negative y moves it up, positive y moves it down.
  13199. *
  13200. * @sample {highcharts} highcharts/legend/verticalalign/
  13201. * Legend 100px from the top of the chart
  13202. * @sample {highstock} stock/legend/align/
  13203. * Various legend options
  13204. * @sample {highmaps} maps/legend/alignment/
  13205. * Legend alignment
  13206. *
  13207. * @since 2.0
  13208. */
  13209. y: 0,
  13210. /**
  13211. * A title to be added on top of the legend.
  13212. *
  13213. * @sample {highcharts} highcharts/legend/title/
  13214. * Legend title
  13215. * @sample {highmaps} maps/legend/alignment/
  13216. * Legend with title
  13217. *
  13218. * @since 3.0
  13219. */
  13220. title: {
  13221. /**
  13222. * A text or HTML string for the title.
  13223. *
  13224. * @type {string}
  13225. * @since 3.0
  13226. * @apioption legend.title.text
  13227. */
  13228. /**
  13229. * Generic CSS styles for the legend title.
  13230. *
  13231. * @see In styled mode, the legend title is styled with the
  13232. * `.highcharts-legend-title` class.
  13233. *
  13234. * @type {Highcharts.CSSObject}
  13235. * @default {"fontWeight": "bold"}
  13236. * @since 3.0
  13237. */
  13238. style: {
  13239. /**
  13240. * @ignore
  13241. */
  13242. fontWeight: 'bold'
  13243. }
  13244. }
  13245. },
  13246. /**
  13247. * The loading options control the appearance of the loading screen
  13248. * that covers the plot area on chart operations. This screen only
  13249. * appears after an explicit call to `chart.showLoading()`. It is a
  13250. * utility for developers to communicate to the end user that something
  13251. * is going on, for example while retrieving new data via an XHR connection.
  13252. * The "Loading..." text itself is not part of this configuration
  13253. * object, but part of the `lang` object.
  13254. */
  13255. loading: {
  13256. /**
  13257. * The duration in milliseconds of the fade out effect.
  13258. *
  13259. * @sample highcharts/loading/hideduration/
  13260. * Fade in and out over a second
  13261. *
  13262. * @type {number}
  13263. * @default 100
  13264. * @since 1.2.0
  13265. * @apioption loading.hideDuration
  13266. */
  13267. /**
  13268. * The duration in milliseconds of the fade in effect.
  13269. *
  13270. * @sample highcharts/loading/hideduration/
  13271. * Fade in and out over a second
  13272. *
  13273. * @type {number}
  13274. * @default 100
  13275. * @since 1.2.0
  13276. * @apioption loading.showDuration
  13277. */
  13278. /**
  13279. * CSS styles for the loading label `span`.
  13280. *
  13281. * @see In styled mode, the loading label is styled with the
  13282. * `.highcharts-loading-inner` class.
  13283. *
  13284. * @sample {highcharts|highmaps} highcharts/loading/labelstyle/
  13285. * Vertically centered
  13286. * @sample {highstock} stock/loading/general/
  13287. * Label styles
  13288. *
  13289. * @type {Highcharts.CSSObject}
  13290. * @default {"fontWeight": "bold", "position": "relative", "top": "45%"}
  13291. * @since 1.2.0
  13292. */
  13293. labelStyle: {
  13294. /**
  13295. * @ignore
  13296. */
  13297. fontWeight: 'bold',
  13298. /**
  13299. * @ignore
  13300. */
  13301. position: 'relative',
  13302. /**
  13303. * @ignore
  13304. */
  13305. top: '45%'
  13306. },
  13307. /**
  13308. * CSS styles for the loading screen that covers the plot area.
  13309. *
  13310. * In styled mode, the loading label is styled with the
  13311. * `.highcharts-loading` class.
  13312. *
  13313. * @sample {highcharts|highmaps} highcharts/loading/style/
  13314. * Gray plot area, white text
  13315. * @sample {highstock} stock/loading/general/
  13316. * Gray plot area, white text
  13317. *
  13318. * @type {Highcharts.CSSObject}
  13319. * @default {"position": "absolute", "backgroundColor": "#ffffff", "opacity": 0.5, "textAlign": "center"}
  13320. * @since 1.2.0
  13321. */
  13322. style: {
  13323. /**
  13324. * @ignore
  13325. */
  13326. position: 'absolute',
  13327. /**
  13328. * @ignore
  13329. */
  13330. backgroundColor: '#ffffff',
  13331. /**
  13332. * @ignore
  13333. */
  13334. opacity: 0.5,
  13335. /**
  13336. * @ignore
  13337. */
  13338. textAlign: 'center'
  13339. }
  13340. },
  13341. /**
  13342. * Options for the tooltip that appears when the user hovers over a
  13343. * series or point.
  13344. *
  13345. * @declare Highcharts.TooltipOptions
  13346. */
  13347. tooltip: {
  13348. /**
  13349. * The color of the tooltip border. When `undefined`, the border takes
  13350. * the color of the corresponding series or point.
  13351. *
  13352. * @sample {highcharts} highcharts/tooltip/bordercolor-default/
  13353. * Follow series by default
  13354. * @sample {highcharts} highcharts/tooltip/bordercolor-black/
  13355. * Black border
  13356. * @sample {highstock} stock/tooltip/general/
  13357. * Styled tooltip
  13358. * @sample {highmaps} maps/tooltip/background-border/
  13359. * Background and border demo
  13360. *
  13361. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  13362. * @apioption tooltip.borderColor
  13363. */
  13364. /**
  13365. * A CSS class name to apply to the tooltip's container div,
  13366. * allowing unique CSS styling for each chart.
  13367. *
  13368. * @type {string}
  13369. * @apioption tooltip.className
  13370. */
  13371. /**
  13372. * Since 4.1, the crosshair definitions are moved to the Axis object
  13373. * in order for a better separation from the tooltip. See
  13374. * [xAxis.crosshair](#xAxis.crosshair).
  13375. *
  13376. * @sample {highcharts} highcharts/tooltip/crosshairs-x/
  13377. * Enable a crosshair for the x value
  13378. *
  13379. * @deprecated
  13380. *
  13381. * @type {*}
  13382. * @default true
  13383. * @apioption tooltip.crosshairs
  13384. */
  13385. /**
  13386. * Distance from point to tooltip in pixels.
  13387. *
  13388. * @type {number}
  13389. * @default 16
  13390. * @apioption tooltip.distance
  13391. */
  13392. /**
  13393. * Whether the tooltip should follow the mouse as it moves across
  13394. * columns, pie slices and other point types with an extent.
  13395. * By default it behaves this way for pie, polygon, map, sankey
  13396. * and wordcloud series by override in the `plotOptions`
  13397. * for those series types.
  13398. *
  13399. * For touch moves to behave the same way, [followTouchMove](
  13400. * #tooltip.followTouchMove) must be `true` also.
  13401. *
  13402. * @type {boolean}
  13403. * @default {highcharts} false
  13404. * @default {highstock} false
  13405. * @default {highmaps} true
  13406. * @since 3.0
  13407. * @apioption tooltip.followPointer
  13408. */
  13409. /**
  13410. * Whether the tooltip should update as the finger moves on a touch
  13411. * device. If this is `true` and [chart.panning](#chart.panning) is
  13412. * set,`followTouchMove` will take over one-finger touches, so the user
  13413. * needs to use two fingers for zooming and panning.
  13414. *
  13415. * Note the difference to [followPointer](#tooltip.followPointer) that
  13416. * only defines the _position_ of the tooltip. If `followPointer` is
  13417. * false in for example a column series, the tooltip will show above or
  13418. * below the column, but as `followTouchMove` is true, the tooltip will
  13419. * jump from column to column as the user swipes across the plot area.
  13420. *
  13421. * @type {boolean}
  13422. * @default {highcharts} true
  13423. * @default {highstock} true
  13424. * @default {highmaps} false
  13425. * @since 3.0.1
  13426. * @apioption tooltip.followTouchMove
  13427. */
  13428. /**
  13429. * Callback function to format the text of the tooltip from scratch. In
  13430. * case of single or [shared](#tooltip.shared) tooltips, a string should
  13431. * be returned. In case of [split](#tooltip.split) tooltips, it should
  13432. * return an array where the first item is the header, and subsequent
  13433. * items are mapped to the points. Return `false` to disable tooltip for
  13434. * a specific point on series.
  13435. *
  13436. * A subset of HTML is supported. Unless `useHTML` is true, the HTML of
  13437. * the tooltip is parsed and converted to SVG, therefore this isn't a
  13438. * complete HTML renderer. The following HTML tags are supported: `b`,
  13439. * `br`, `em`, `i`, `span`, `strong`. Spans can be styled with a `style`
  13440. * attribute, but only text-related CSS, that is shared with SVG, is
  13441. * handled.
  13442. *
  13443. * The available data in the formatter differ a bit depending on whether
  13444. * the tooltip is shared or split, or belongs to a single point. In a
  13445. * shared/split tooltip, all properties except `x`, which is common for
  13446. * all points, are kept in an array, `this.points`.
  13447. *
  13448. * Available data are:
  13449. *
  13450. * - **this.percentage (not shared) /**
  13451. * **this.points[i].percentage (shared)**:
  13452. * Stacked series and pies only. The point's percentage of the total.
  13453. *
  13454. * - **this.point (not shared) / this.points[i].point (shared)**:
  13455. * The point object. The point name, if defined, is available through
  13456. * `this.point.name`.
  13457. *
  13458. * - **this.points**:
  13459. * In a shared tooltip, this is an array containing all other
  13460. * properties for each point.
  13461. *
  13462. * - **this.series (not shared) / this.points[i].series (shared)**:
  13463. * The series object. The series name is available through
  13464. * `this.series.name`.
  13465. *
  13466. * - **this.total (not shared) / this.points[i].total (shared)**:
  13467. * Stacked series only. The total value at this point's x value.
  13468. *
  13469. * - **this.x**:
  13470. * The x value. This property is the same regardless of the tooltip
  13471. * being shared or not.
  13472. *
  13473. * - **this.y (not shared) / this.points[i].y (shared)**:
  13474. * The y value.
  13475. *
  13476. * @sample {highcharts} highcharts/tooltip/formatter-simple/
  13477. * Simple string formatting
  13478. * @sample {highcharts} highcharts/tooltip/formatter-shared/
  13479. * Formatting with shared tooltip
  13480. * @sample {highcharts|highstock} highcharts/tooltip/formatter-split/
  13481. * Formatting with split tooltip
  13482. * @sample highcharts/tooltip/formatter-conditional-default/
  13483. * Extending default formatter
  13484. * @sample {highstock} stock/tooltip/formatter/
  13485. * Formatting with shared tooltip
  13486. * @sample {highmaps} maps/tooltip/formatter/
  13487. * String formatting
  13488. *
  13489. * @type {Highcharts.TooltipFormatterCallbackFunction}
  13490. * @apioption tooltip.formatter
  13491. */
  13492. /**
  13493. * Callback function to format the text of the tooltip for
  13494. * visible null points.
  13495. * Works analogously to [formatter](#tooltip.formatter).
  13496. *
  13497. * @sample highcharts/plotoptions/series-nullformat
  13498. * Format data label and tooltip for null point.
  13499. *
  13500. * @type {Highcharts.TooltipFormatterCallbackFunction}
  13501. * @apioption tooltip.nullFormatter
  13502. */
  13503. /**
  13504. * The number of milliseconds to wait until the tooltip is hidden when
  13505. * mouse out from a point or chart.
  13506. *
  13507. * @type {number}
  13508. * @default 500
  13509. * @since 3.0
  13510. * @apioption tooltip.hideDelay
  13511. */
  13512. /**
  13513. * Whether to allow the tooltip to render outside the chart's SVG
  13514. * element box. By default (`false`), the tooltip is rendered within the
  13515. * chart's SVG element, which results in the tooltip being aligned
  13516. * inside the chart area. For small charts, this may result in clipping
  13517. * or overlapping. When `true`, a separate SVG element is created and
  13518. * overlaid on the page, allowing the tooltip to be aligned inside the
  13519. * page itself.
  13520. *
  13521. * Defaults to `true` if `chart.scrollablePlotArea` is activated,
  13522. * otherwise `false`.
  13523. *
  13524. * @sample highcharts/tooltip/outside
  13525. * Small charts with tooltips outside
  13526. *
  13527. * @type {boolean|undefined}
  13528. * @default undefined
  13529. * @since 6.1.1
  13530. * @apioption tooltip.outside
  13531. */
  13532. /**
  13533. * A callback function for formatting the HTML output for a single point
  13534. * in the tooltip. Like the `pointFormat` string, but with more
  13535. * flexibility.
  13536. *
  13537. * @type {Highcharts.FormatterCallbackFunction<Highcharts.Point>}
  13538. * @since 4.1.0
  13539. * @context Highcharts.Point
  13540. * @apioption tooltip.pointFormatter
  13541. */
  13542. /**
  13543. * A callback function to place the tooltip in a default position. The
  13544. * callback receives three parameters: `labelWidth`, `labelHeight` and
  13545. * `point`, where point contains values for `plotX` and `plotY` telling
  13546. * where the reference point is in the plot area. Add `chart.plotLeft`
  13547. * and `chart.plotTop` to get the full coordinates.
  13548. *
  13549. * Since v7, when [tooltip.split](#tooltip.split) option is enabled,
  13550. * positioner is called for each of the boxes separately, including
  13551. * xAxis header. xAxis header is not a point, instead `point` argument
  13552. * contains info:
  13553. * `{ plotX: Number, plotY: Number, isHeader: Boolean }`
  13554. *
  13555. *
  13556. * The return should be an object containing x and y values, for example
  13557. * `{ x: 100, y: 100 }`.
  13558. *
  13559. * @sample {highcharts} highcharts/tooltip/positioner/
  13560. * A fixed tooltip position
  13561. * @sample {highstock} stock/tooltip/positioner/
  13562. * A fixed tooltip position on top of the chart
  13563. * @sample {highmaps} maps/tooltip/positioner/
  13564. * A fixed tooltip position
  13565. * @sample {highstock} stock/tooltip/split-positioner/
  13566. * Split tooltip with fixed positions
  13567. * @sample {highstock} stock/tooltip/positioner-scrollable-plotarea/
  13568. * Scrollable plot area combined with tooltip positioner
  13569. *
  13570. * @type {Highcharts.TooltipPositionerCallbackFunction}
  13571. * @since 2.2.4
  13572. * @apioption tooltip.positioner
  13573. */
  13574. /**
  13575. * The name of a symbol to use for the border around the tooltip. Can
  13576. * be one of: `"callout"`, `"circle"`, or `"square"`. When
  13577. * [tooltip.split](#tooltip.split)
  13578. * option is enabled, shape is applied to all boxes except header, which
  13579. * is controlled by
  13580. * [tooltip.headerShape](#tooltip.headerShape).
  13581. *
  13582. * Custom callbacks for symbol path generation can also be added to
  13583. * `Highcharts.SVGRenderer.prototype.symbols` the same way as for
  13584. * [series.marker.symbol](plotOptions.line.marker.symbol).
  13585. *
  13586. * @type {Highcharts.TooltipShapeValue}
  13587. * @default callout
  13588. * @since 4.0
  13589. * @apioption tooltip.shape
  13590. */
  13591. /**
  13592. * The name of a symbol to use for the border around the tooltip
  13593. * header. Applies only when [tooltip.split](#tooltip.split) is
  13594. * enabled.
  13595. *
  13596. * Custom callbacks for symbol path generation can also be added to
  13597. * `Highcharts.SVGRenderer.prototype.symbols` the same way as for
  13598. * [series.marker.symbol](plotOptions.line.marker.symbol).
  13599. *
  13600. * @see [tooltip.shape](#tooltip.shape)
  13601. *
  13602. * @sample {highstock} stock/tooltip/split-positioner/
  13603. * Different shapes for header and split boxes
  13604. *
  13605. * @type {Highcharts.TooltipShapeValue}
  13606. * @default callout
  13607. * @validvalue ["callout", "square"]
  13608. * @since 7.0
  13609. * @apioption tooltip.headerShape
  13610. */
  13611. /**
  13612. * When the tooltip is shared, the entire plot area will capture mouse
  13613. * movement or touch events. Tooltip texts for series types with ordered
  13614. * data (not pie, scatter, flags etc) will be shown in a single bubble.
  13615. * This is recommended for single series charts and for tablet/mobile
  13616. * optimized charts.
  13617. *
  13618. * See also [tooltip.split](#tooltip.split), that is better suited for
  13619. * charts with many series, especially line-type series. The
  13620. * `tooltip.split` option takes precedence over `tooltip.shared`.
  13621. *
  13622. * @sample {highcharts} highcharts/tooltip/shared-false/
  13623. * False by default
  13624. * @sample {highcharts} highcharts/tooltip/shared-true/
  13625. * True
  13626. * @sample {highcharts} highcharts/tooltip/shared-x-crosshair/
  13627. * True with x axis crosshair
  13628. * @sample {highcharts} highcharts/tooltip/shared-true-mixed-types/
  13629. * True with mixed series types
  13630. *
  13631. * @type {boolean}
  13632. * @default false
  13633. * @since 2.1
  13634. * @product highcharts highstock
  13635. * @apioption tooltip.shared
  13636. */
  13637. /**
  13638. * Split the tooltip into one label per series, with the header close
  13639. * to the axis. This is recommended over [shared](#tooltip.shared)
  13640. * tooltips for charts with multiple line series, generally making them
  13641. * easier to read. This option takes precedence over `tooltip.shared`.
  13642. *
  13643. * @productdesc {highstock} In Highstock, tooltips are split by default
  13644. * since v6.0.0. Stock charts typically contain multi-dimension points
  13645. * and multiple panes, making split tooltips the preferred layout over
  13646. * the previous `shared` tooltip.
  13647. *
  13648. * @sample highcharts/tooltip/split/
  13649. * Split tooltip
  13650. * @sample {highcharts|highstock} highcharts/tooltip/formatter-split/
  13651. * Split tooltip and custom formatter callback
  13652. *
  13653. * @type {boolean}
  13654. * @default {highcharts} false
  13655. * @default {highstock} true
  13656. * @since 5.0.0
  13657. * @product highcharts highstock
  13658. * @apioption tooltip.split
  13659. */
  13660. /**
  13661. * Prevents the tooltip from switching or closing, when touched or
  13662. * pointed.
  13663. *
  13664. * @sample highcharts/tooltip/stickoncontact/
  13665. * Tooltip sticks on pointer contact
  13666. *
  13667. * @type {boolean}
  13668. * @since 8.0.1
  13669. * @apioption tooltip.stickOnContact
  13670. */
  13671. /**
  13672. * Use HTML to render the contents of the tooltip instead of SVG. Using
  13673. * HTML allows advanced formatting like tables and images in the
  13674. * tooltip. It is also recommended for rtl languages as it works around
  13675. * rtl bugs in early Firefox.
  13676. *
  13677. * @sample {highcharts|highstock} highcharts/tooltip/footerformat/
  13678. * A table for value alignment
  13679. * @sample {highcharts|highstock} highcharts/tooltip/fullhtml/
  13680. * Full HTML tooltip
  13681. * @sample {highmaps} maps/tooltip/usehtml/
  13682. * Pure HTML tooltip
  13683. *
  13684. * @type {boolean}
  13685. * @default false
  13686. * @since 2.2
  13687. * @apioption tooltip.useHTML
  13688. */
  13689. /**
  13690. * How many decimals to show in each series' y value. This is
  13691. * overridable in each series' tooltip options object. The default is to
  13692. * preserve all decimals.
  13693. *
  13694. * @sample {highcharts|highstock} highcharts/tooltip/valuedecimals/
  13695. * Set decimals, prefix and suffix for the value
  13696. * @sample {highmaps} maps/tooltip/valuedecimals/
  13697. * Set decimals, prefix and suffix for the value
  13698. *
  13699. * @type {number}
  13700. * @since 2.2
  13701. * @apioption tooltip.valueDecimals
  13702. */
  13703. /**
  13704. * A string to prepend to each series' y value. Overridable in each
  13705. * series' tooltip options object.
  13706. *
  13707. * @sample {highcharts|highstock} highcharts/tooltip/valuedecimals/
  13708. * Set decimals, prefix and suffix for the value
  13709. * @sample {highmaps} maps/tooltip/valuedecimals/
  13710. * Set decimals, prefix and suffix for the value
  13711. *
  13712. * @type {string}
  13713. * @since 2.2
  13714. * @apioption tooltip.valuePrefix
  13715. */
  13716. /**
  13717. * A string to append to each series' y value. Overridable in each
  13718. * series' tooltip options object.
  13719. *
  13720. * @sample {highcharts|highstock} highcharts/tooltip/valuedecimals/
  13721. * Set decimals, prefix and suffix for the value
  13722. * @sample {highmaps} maps/tooltip/valuedecimals/
  13723. * Set decimals, prefix and suffix for the value
  13724. *
  13725. * @type {string}
  13726. * @since 2.2
  13727. * @apioption tooltip.valueSuffix
  13728. */
  13729. /**
  13730. * The format for the date in the tooltip header if the X axis is a
  13731. * datetime axis. The default is a best guess based on the smallest
  13732. * distance between points in the chart.
  13733. *
  13734. * @sample {highcharts} highcharts/tooltip/xdateformat/
  13735. * A different format
  13736. *
  13737. * @type {string}
  13738. * @product highcharts highstock gantt
  13739. * @apioption tooltip.xDateFormat
  13740. */
  13741. /**
  13742. * How many decimals to show for the `point.change` value when the
  13743. * `series.compare` option is set. This is overridable in each series'
  13744. * tooltip options object. The default is to preserve all decimals.
  13745. *
  13746. * @type {number}
  13747. * @since 1.0.1
  13748. * @product highstock
  13749. * @apioption tooltip.changeDecimals
  13750. */
  13751. /**
  13752. * Enable or disable the tooltip.
  13753. *
  13754. * @sample {highcharts} highcharts/tooltip/enabled/
  13755. * Disabled
  13756. * @sample {highcharts} highcharts/plotoptions/series-point-events-mouseover/
  13757. * Disable tooltip and show values on chart instead
  13758. */
  13759. enabled: true,
  13760. /**
  13761. * Enable or disable animation of the tooltip.
  13762. *
  13763. * @type {boolean}
  13764. * @default true
  13765. * @since 2.3.0
  13766. */
  13767. animation: svg,
  13768. /**
  13769. * The radius of the rounded border corners.
  13770. *
  13771. * @sample {highcharts} highcharts/tooltip/bordercolor-default/
  13772. * 5px by default
  13773. * @sample {highcharts} highcharts/tooltip/borderradius-0/
  13774. * Square borders
  13775. * @sample {highmaps} maps/tooltip/background-border/
  13776. * Background and border demo
  13777. */
  13778. borderRadius: 3,
  13779. /**
  13780. * For series on a datetime axes, the date format in the tooltip's
  13781. * header will by default be guessed based on the closest data points.
  13782. * This member gives the default string representations used for
  13783. * each unit. For an overview of the replacement codes, see
  13784. * [dateFormat](/class-reference/Highcharts#dateFormat).
  13785. *
  13786. * @see [xAxis.dateTimeLabelFormats](#xAxis.dateTimeLabelFormats)
  13787. *
  13788. * @type {Highcharts.Dictionary<string>}
  13789. * @product highcharts highstock gantt
  13790. */
  13791. dateTimeLabelFormats: {
  13792. /** @internal */
  13793. millisecond: '%A, %b %e, %H:%M:%S.%L',
  13794. /** @internal */
  13795. second: '%A, %b %e, %H:%M:%S',
  13796. /** @internal */
  13797. minute: '%A, %b %e, %H:%M',
  13798. /** @internal */
  13799. hour: '%A, %b %e, %H:%M',
  13800. /** @internal */
  13801. day: '%A, %b %e, %Y',
  13802. /** @internal */
  13803. week: 'Week from %A, %b %e, %Y',
  13804. /** @internal */
  13805. month: '%B %Y',
  13806. /** @internal */
  13807. year: '%Y'
  13808. },
  13809. /**
  13810. * A string to append to the tooltip format.
  13811. *
  13812. * @sample {highcharts} highcharts/tooltip/footerformat/
  13813. * A table for value alignment
  13814. * @sample {highmaps} maps/tooltip/format/
  13815. * Format demo
  13816. *
  13817. * @since 2.2
  13818. */
  13819. footerFormat: '',
  13820. /**
  13821. * Padding inside the tooltip, in pixels.
  13822. *
  13823. * @since 5.0.0
  13824. */
  13825. padding: 8,
  13826. /**
  13827. * Proximity snap for graphs or single points. It defaults to 10 for
  13828. * mouse-powered devices and 25 for touch devices.
  13829. *
  13830. * Note that in most cases the whole plot area captures the mouse
  13831. * movement, and in these cases `tooltip.snap` doesn't make sense. This
  13832. * applies when [stickyTracking](#plotOptions.series.stickyTracking)
  13833. * is `true` (default) and when the tooltip is [shared](#tooltip.shared)
  13834. * or [split](#tooltip.split).
  13835. *
  13836. * @sample {highcharts} highcharts/tooltip/bordercolor-default/
  13837. * 10 px by default
  13838. * @sample {highcharts} highcharts/tooltip/snap-50/
  13839. * 50 px on graph
  13840. *
  13841. * @type {number}
  13842. * @default 10/25
  13843. * @since 1.2.0
  13844. * @product highcharts highstock
  13845. */
  13846. snap: isTouchDevice ? 25 : 10,
  13847. /**
  13848. * The HTML of the tooltip header line. Variables are enclosed by
  13849. * curly brackets. Available variables are `point.key`, `series.name`,
  13850. * `series.color` and other members from the `point` and `series`
  13851. * objects. The `point.key` variable contains the category name, x
  13852. * value or datetime string depending on the type of axis. For datetime
  13853. * axes, the `point.key` date format can be set using
  13854. * `tooltip.xDateFormat`.
  13855. *
  13856. * @sample {highcharts} highcharts/tooltip/footerformat/
  13857. * An HTML table in the tooltip
  13858. * @sample {highstock} highcharts/tooltip/footerformat/
  13859. * An HTML table in the tooltip
  13860. * @sample {highmaps} maps/tooltip/format/
  13861. * Format demo
  13862. *
  13863. * @type {string}
  13864. * @apioption tooltip.headerFormat
  13865. */
  13866. headerFormat: '<span style="font-size: 10px">{point.key}</span><br/>',
  13867. /**
  13868. * The HTML of the null point's line in the tooltip. Works analogously
  13869. * to [pointFormat](#tooltip.pointFormat).
  13870. *
  13871. * @sample {highcharts} highcharts/plotoptions/series-nullformat
  13872. * Format data label and tooltip for null point.
  13873. *
  13874. * @type {string}
  13875. * @apioption tooltip.nullFormat
  13876. */
  13877. /**
  13878. * The HTML of the point's line in the tooltip. Variables are enclosed
  13879. * by curly brackets. Available variables are `point.x`, `point.y`,
  13880. * `series.name` and `series.color` and other properties on the same
  13881. * form. Furthermore, `point.y` can be extended by the
  13882. * `tooltip.valuePrefix` and `tooltip.valueSuffix` variables. This can
  13883. * also be overridden for each series, which makes it a good hook for
  13884. * displaying units.
  13885. *
  13886. * In styled mode, the dot is colored by a class name rather
  13887. * than the point color.
  13888. *
  13889. * @sample {highcharts} highcharts/tooltip/pointformat/
  13890. * A different point format with value suffix
  13891. * @sample {highmaps} maps/tooltip/format/
  13892. * Format demo
  13893. *
  13894. * @type {string}
  13895. * @since 2.2
  13896. * @apioption tooltip.pointFormat
  13897. */
  13898. pointFormat: '<span style="color:{point.color}">\u25CF</span> {series.name}: <b>{point.y}</b><br/>',
  13899. /**
  13900. * The background color or gradient for the tooltip.
  13901. *
  13902. * In styled mode, the stroke width is set in the
  13903. * `.highcharts-tooltip-box` class.
  13904. *
  13905. * @sample {highcharts} highcharts/tooltip/backgroundcolor-solid/
  13906. * Yellowish background
  13907. * @sample {highcharts} highcharts/tooltip/backgroundcolor-gradient/
  13908. * Gradient
  13909. * @sample {highcharts} highcharts/css/tooltip-border-background/
  13910. * Tooltip in styled mode
  13911. * @sample {highstock} stock/tooltip/general/
  13912. * Custom tooltip
  13913. * @sample {highstock} highcharts/css/tooltip-border-background/
  13914. * Tooltip in styled mode
  13915. * @sample {highmaps} maps/tooltip/background-border/
  13916. * Background and border demo
  13917. * @sample {highmaps} highcharts/css/tooltip-border-background/
  13918. * Tooltip in styled mode
  13919. *
  13920. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  13921. */
  13922. backgroundColor: color('#f7f7f7')
  13923. .setOpacity(0.85).get(),
  13924. /**
  13925. * The pixel width of the tooltip border.
  13926. *
  13927. * In styled mode, the stroke width is set in the
  13928. * `.highcharts-tooltip-box` class.
  13929. *
  13930. * @sample {highcharts} highcharts/tooltip/bordercolor-default/
  13931. * 2px by default
  13932. * @sample {highcharts} highcharts/tooltip/borderwidth/
  13933. * No border (shadow only)
  13934. * @sample {highcharts} highcharts/css/tooltip-border-background/
  13935. * Tooltip in styled mode
  13936. * @sample {highstock} stock/tooltip/general/
  13937. * Custom tooltip
  13938. * @sample {highstock} highcharts/css/tooltip-border-background/
  13939. * Tooltip in styled mode
  13940. * @sample {highmaps} maps/tooltip/background-border/
  13941. * Background and border demo
  13942. * @sample {highmaps} highcharts/css/tooltip-border-background/
  13943. * Tooltip in styled mode
  13944. */
  13945. borderWidth: 1,
  13946. /**
  13947. * Whether to apply a drop shadow to the tooltip.
  13948. *
  13949. * @sample {highcharts} highcharts/tooltip/bordercolor-default/
  13950. * True by default
  13951. * @sample {highcharts} highcharts/tooltip/shadow/
  13952. * False
  13953. * @sample {highmaps} maps/tooltip/positioner/
  13954. * Fixed tooltip position, border and shadow disabled
  13955. *
  13956. * @type {boolean|Highcharts.ShadowOptionsObject}
  13957. */
  13958. shadow: true,
  13959. /**
  13960. * CSS styles for the tooltip. The tooltip can also be styled through
  13961. * the CSS class `.highcharts-tooltip`.
  13962. *
  13963. * Note that the default `pointerEvents` style makes the tooltip ignore
  13964. * mouse events, so in order to use clickable tooltips, this value must
  13965. * be set to `auto`.
  13966. *
  13967. * @sample {highcharts} highcharts/tooltip/style/
  13968. * Greater padding, bold text
  13969. *
  13970. * @type {Highcharts.CSSObject}
  13971. */
  13972. style: {
  13973. /** @internal */
  13974. color: '#333333',
  13975. /** @internal */
  13976. cursor: 'default',
  13977. /** @internal */
  13978. fontSize: '12px',
  13979. /** @internal */
  13980. whiteSpace: 'nowrap'
  13981. }
  13982. },
  13983. /**
  13984. * Highchart by default puts a credits label in the lower right corner
  13985. * of the chart. This can be changed using these options.
  13986. */
  13987. credits: {
  13988. /**
  13989. * Credits for map source to be concatenated with conventional credit
  13990. * text. By default this is a format string that collects copyright
  13991. * information from the map if available.
  13992. *
  13993. * @see [mapTextFull](#credits.mapTextFull)
  13994. * @see [text](#credits.text)
  13995. *
  13996. * @type {string}
  13997. * @default \u00a9 <a href="{geojson.copyrightUrl}">{geojson.copyrightShort}</a>
  13998. * @since 4.2.2
  13999. * @product highmaps
  14000. * @apioption credits.mapText
  14001. */
  14002. /**
  14003. * Detailed credits for map source to be displayed on hover of credits
  14004. * text. By default this is a format string that collects copyright
  14005. * information from the map if available.
  14006. *
  14007. * @see [mapText](#credits.mapText)
  14008. * @see [text](#credits.text)
  14009. *
  14010. * @type {string}
  14011. * @default {geojson.copyright}
  14012. * @since 4.2.2
  14013. * @product highmaps
  14014. * @apioption credits.mapTextFull
  14015. */
  14016. /**
  14017. * Whether to show the credits text.
  14018. *
  14019. * @sample {highcharts} highcharts/credits/enabled-false/
  14020. * Credits disabled
  14021. * @sample {highstock} stock/credits/enabled/
  14022. * Credits disabled
  14023. * @sample {highmaps} maps/credits/enabled-false/
  14024. * Credits disabled
  14025. */
  14026. enabled: true,
  14027. /**
  14028. * The URL for the credits label.
  14029. *
  14030. * @sample {highcharts} highcharts/credits/href/
  14031. * Custom URL and text
  14032. * @sample {highmaps} maps/credits/customized/
  14033. * Custom URL and text
  14034. */
  14035. href: 'https://www.highcharts.com?credits',
  14036. /**
  14037. * Position configuration for the credits label.
  14038. *
  14039. * @sample {highcharts} highcharts/credits/position-left/
  14040. * Left aligned
  14041. * @sample {highcharts} highcharts/credits/position-left/
  14042. * Left aligned
  14043. * @sample {highmaps} maps/credits/customized/
  14044. * Left aligned
  14045. * @sample {highmaps} maps/credits/customized/
  14046. * Left aligned
  14047. *
  14048. * @type {Highcharts.AlignObject}
  14049. * @since 2.1
  14050. */
  14051. position: {
  14052. /** @internal */
  14053. align: 'right',
  14054. /** @internal */
  14055. x: -10,
  14056. /** @internal */
  14057. verticalAlign: 'bottom',
  14058. /** @internal */
  14059. y: -5
  14060. },
  14061. /**
  14062. * CSS styles for the credits label.
  14063. *
  14064. * @see In styled mode, credits styles can be set with the
  14065. * `.highcharts-credits` class.
  14066. *
  14067. * @type {Highcharts.CSSObject}
  14068. */
  14069. style: {
  14070. /** @internal */
  14071. cursor: 'pointer',
  14072. /** @internal */
  14073. color: '#999999',
  14074. /** @internal */
  14075. fontSize: '9px'
  14076. },
  14077. /**
  14078. * The text for the credits label.
  14079. *
  14080. * @productdesc {highmaps}
  14081. * If a map is loaded as GeoJSON, the text defaults to
  14082. * `Highcharts @ {map-credits}`. Otherwise, it defaults to
  14083. * `Highcharts.com`.
  14084. *
  14085. * @sample {highcharts} highcharts/credits/href/
  14086. * Custom URL and text
  14087. * @sample {highmaps} maps/credits/customized/
  14088. * Custom URL and text
  14089. */
  14090. text: 'Highcharts.com'
  14091. }
  14092. };
  14093. /* eslint-disable spaced-comment */
  14094. '';
  14095. /**
  14096. * Global `Time` object with default options. Since v6.0.5, time settings can be
  14097. * applied individually for each chart. If no individual settings apply, this
  14098. * `Time` object is shared by all instances.
  14099. *
  14100. * @name Highcharts.time
  14101. * @type {Highcharts.Time}
  14102. */
  14103. H.time = new Time(merge(H.defaultOptions.global, H.defaultOptions.time));
  14104. /**
  14105. * Formats a JavaScript date timestamp (milliseconds since Jan 1st 1970) into a
  14106. * human readable date string. The format is a subset of the formats for PHP's
  14107. * [strftime](https://www.php.net/manual/en/function.strftime.php) function.
  14108. * Additional formats can be given in the {@link Highcharts.dateFormats} hook.
  14109. *
  14110. * Since v6.0.5, all internal dates are formatted through the
  14111. * {@link Highcharts.Chart#time} instance to respect chart-level time settings.
  14112. * The `Highcharts.dateFormat` function only reflects global time settings set
  14113. * with `setOptions`.
  14114. *
  14115. * Supported format keys:
  14116. * - `%a`: Short weekday, like 'Mon'
  14117. * - `%A`: Long weekday, like 'Monday'
  14118. * - `%d`: Two digit day of the month, 01 to 31
  14119. * - `%e`: Day of the month, 1 through 31
  14120. * - `%w`: Day of the week, 0 through 6
  14121. * - `%b`: Short month, like 'Jan'
  14122. * - `%B`: Long month, like 'January'
  14123. * - `%m`: Two digit month number, 01 through 12
  14124. * - `%y`: Two digits year, like 09 for 2009
  14125. * - `%Y`: Four digits year, like 2009
  14126. * - `%H`: Two digits hours in 24h format, 00 through 23
  14127. * - `%k`: Hours in 24h format, 0 through 23
  14128. * - `%I`: Two digits hours in 12h format, 00 through 11
  14129. * - `%l`: Hours in 12h format, 1 through 12
  14130. * - `%M`: Two digits minutes, 00 through 59
  14131. * - `%p`: Upper case AM or PM
  14132. * - `%P`: Lower case AM or PM
  14133. * - `%S`: Two digits seconds, 00 through 59
  14134. * - `%L`: Milliseconds (naming from Ruby)
  14135. *
  14136. * @function Highcharts.dateFormat
  14137. *
  14138. * @param {string} format
  14139. * The desired format where various time representations are prefixed
  14140. * with `%`.
  14141. *
  14142. * @param {number} timestamp
  14143. * The JavaScript timestamp.
  14144. *
  14145. * @param {boolean} [capitalize=false]
  14146. * Upper case first letter in the return.
  14147. *
  14148. * @return {string}
  14149. * The formatted date.
  14150. */
  14151. H.dateFormat = function (format, timestamp, capitalize) {
  14152. return H.time.dateFormat(format, timestamp, capitalize);
  14153. };
  14154. var optionsModule = {
  14155. dateFormat: H.dateFormat,
  14156. defaultOptions: H.defaultOptions,
  14157. time: H.time
  14158. };
  14159. return optionsModule;
  14160. });
  14161. _registerModule(_modules, 'Core/Axis/Axis.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Color/Color.js'], _modules['Core/Globals.js'], _modules['Core/Axis/Tick.js'], _modules['Core/Utilities.js'], _modules['Core/Options.js']], function (A, Color, H, Tick, U, O) {
  14162. /* *
  14163. *
  14164. * (c) 2010-2020 Torstein Honsi
  14165. *
  14166. * License: www.highcharts.com/license
  14167. *
  14168. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  14169. *
  14170. * */
  14171. var animObject = A.animObject;
  14172. var addEvent = U.addEvent,
  14173. arrayMax = U.arrayMax,
  14174. arrayMin = U.arrayMin,
  14175. clamp = U.clamp,
  14176. correctFloat = U.correctFloat,
  14177. defined = U.defined,
  14178. destroyObjectProperties = U.destroyObjectProperties,
  14179. error = U.error,
  14180. extend = U.extend,
  14181. fireEvent = U.fireEvent,
  14182. format = U.format,
  14183. getMagnitude = U.getMagnitude,
  14184. isArray = U.isArray,
  14185. isFunction = U.isFunction,
  14186. isNumber = U.isNumber,
  14187. isString = U.isString,
  14188. merge = U.merge,
  14189. normalizeTickInterval = U.normalizeTickInterval,
  14190. objectEach = U.objectEach,
  14191. pick = U.pick,
  14192. relativeLength = U.relativeLength,
  14193. removeEvent = U.removeEvent,
  14194. splat = U.splat,
  14195. syncTimeout = U.syncTimeout;
  14196. /**
  14197. * Options for the path on the Axis to be calculated.
  14198. * @interface Highcharts.AxisPlotLinePathOptionsObject
  14199. */ /**
  14200. * Axis value.
  14201. * @name Highcharts.AxisPlotLinePathOptionsObject#value
  14202. * @type {number|undefined}
  14203. */ /**
  14204. * Line width used for calculation crisp line coordinates. Defaults to 1.
  14205. * @name Highcharts.AxisPlotLinePathOptionsObject#lineWidth
  14206. * @type {number|undefined}
  14207. */ /**
  14208. * If `false`, the function will return null when it falls outside the axis
  14209. * bounds. If `true`, the function will return a path aligned to the plot area
  14210. * sides if it falls outside. If `pass`, it will return a path outside.
  14211. * @name Highcharts.AxisPlotLinePathOptionsObject#force
  14212. * @type {string|boolean|undefined}
  14213. */ /**
  14214. * Used in Highstock. When `true`, plot paths (crosshair, plotLines, gridLines)
  14215. * will be rendered on all axes when defined on the first axis.
  14216. * @name Highcharts.AxisPlotLinePathOptionsObject#acrossPanes
  14217. * @type {boolean|undefined}
  14218. */ /**
  14219. * Use old coordinates (for resizing and rescaling).
  14220. * If not set, defaults to `false`.
  14221. * @name Highcharts.AxisPlotLinePathOptionsObject#old
  14222. * @type {boolean|undefined}
  14223. */ /**
  14224. * If given, return the plot line path of a pixel position on the axis.
  14225. * @name Highcharts.AxisPlotLinePathOptionsObject#translatedValue
  14226. * @type {number|undefined}
  14227. */ /**
  14228. * Used in Polar axes. Reverse the positions for concatenation of polygonal
  14229. * plot bands
  14230. * @name Highcharts.AxisPlotLinePathOptionsObject#reverse
  14231. * @type {boolean|undefined}
  14232. */
  14233. /**
  14234. * Options for crosshairs on axes.
  14235. *
  14236. * @product highstock
  14237. *
  14238. * @typedef {Highcharts.XAxisCrosshairOptions|Highcharts.YAxisCrosshairOptions} Highcharts.AxisCrosshairOptions
  14239. */
  14240. /**
  14241. * @typedef {"navigator"|"pan"|"rangeSelectorButton"|"rangeSelectorInput"|"scrollbar"|"traverseUpButton"|"zoom"} Highcharts.AxisExtremesTriggerValue
  14242. */
  14243. /**
  14244. * @callback Highcharts.AxisEventCallbackFunction
  14245. *
  14246. * @param {Highcharts.Axis} this
  14247. */
  14248. /**
  14249. * @callback Highcharts.AxisLabelsFormatterCallbackFunction
  14250. *
  14251. * @param {Highcharts.AxisLabelsFormatterContextObject<number>} this
  14252. *
  14253. * @param {Highcharts.AxisLabelsFormatterContextObject<string>} that
  14254. *
  14255. * @return {string}
  14256. */
  14257. /**
  14258. * @interface Highcharts.AxisLabelsFormatterContextObject<T>
  14259. */ /**
  14260. * @name Highcharts.AxisLabelsFormatterContextObject<T>#axis
  14261. * @type {Highcharts.Axis}
  14262. */ /**
  14263. * @name Highcharts.AxisLabelsFormatterContextObject<T>#chart
  14264. * @type {Highcharts.Chart}
  14265. */ /**
  14266. * @name Highcharts.AxisLabelsFormatterContextObject<T>#isFirst
  14267. * @type {boolean}
  14268. */ /**
  14269. * @name Highcharts.AxisLabelsFormatterContextObject<T>#isLast
  14270. * @type {boolean}
  14271. */ /**
  14272. * @name Highcharts.AxisLabelsFormatterContextObject<T>#pos
  14273. * @type {number}
  14274. */ /**
  14275. * This can be either a numeric value or a category string.
  14276. * @name Highcharts.AxisLabelsFormatterContextObject<T>#value
  14277. * @type {T}
  14278. */
  14279. /**
  14280. * Options for axes.
  14281. *
  14282. * @typedef {Highcharts.XAxisOptions|Highcharts.YAxisOptions|Highcharts.ZAxisOptions} Highcharts.AxisOptions
  14283. */
  14284. /**
  14285. * @callback Highcharts.AxisPointBreakEventCallbackFunction
  14286. *
  14287. * @param {Highcharts.Axis} this
  14288. *
  14289. * @param {Highcharts.AxisPointBreakEventObject} evt
  14290. */
  14291. /**
  14292. * @interface Highcharts.AxisPointBreakEventObject
  14293. */ /**
  14294. * @name Highcharts.AxisPointBreakEventObject#brk
  14295. * @type {Highcharts.Dictionary<number>}
  14296. */ /**
  14297. * @name Highcharts.AxisPointBreakEventObject#point
  14298. * @type {Highcharts.Point}
  14299. */ /**
  14300. * @name Highcharts.AxisPointBreakEventObject#preventDefault
  14301. * @type {Function}
  14302. */ /**
  14303. * @name Highcharts.AxisPointBreakEventObject#target
  14304. * @type {Highcharts.SVGElement}
  14305. */ /**
  14306. * @name Highcharts.AxisPointBreakEventObject#type
  14307. * @type {"pointBreak"|"pointInBreak"}
  14308. */
  14309. /**
  14310. * @callback Highcharts.AxisSetExtremesEventCallbackFunction
  14311. *
  14312. * @param {Highcharts.Axis} this
  14313. *
  14314. * @param {Highcharts.AxisSetExtremesEventObject} evt
  14315. */
  14316. /**
  14317. * @interface Highcharts.AxisSetExtremesEventObject
  14318. * @extends Highcharts.ExtremesObject
  14319. */ /**
  14320. * @name Highcharts.AxisSetExtremesEventObject#preventDefault
  14321. * @type {Function}
  14322. */ /**
  14323. * @name Highcharts.AxisSetExtremesEventObject#target
  14324. * @type {Highcharts.SVGElement}
  14325. */ /**
  14326. * @name Highcharts.AxisSetExtremesEventObject#trigger
  14327. * @type {Highcharts.AxisExtremesTriggerValue|string}
  14328. */ /**
  14329. * @name Highcharts.AxisSetExtremesEventObject#type
  14330. * @type {"setExtremes"}
  14331. */
  14332. /**
  14333. * @callback Highcharts.AxisTickPositionerCallbackFunction
  14334. *
  14335. * @param {Highcharts.Axis} this
  14336. *
  14337. * @return {Highcharts.AxisTickPositionsArray}
  14338. */
  14339. /**
  14340. * @interface Highcharts.AxisTickPositionsArray
  14341. * @augments Array<number>
  14342. */
  14343. /**
  14344. * @typedef {"high"|"low"|"middle"} Highcharts.AxisTitleAlignValue
  14345. */
  14346. /**
  14347. * @typedef {Highcharts.XAxisTitleOptions|Highcharts.YAxisTitleOptions|Highcharts.ZAxisTitleOptions} Highcharts.AxisTitleOptions
  14348. */
  14349. /**
  14350. * @typedef {"linear"|"logarithmic"|"datetime"|"category"|"treegrid"} Highcharts.AxisTypeValue
  14351. */
  14352. /**
  14353. * The returned object literal from the {@link Highcharts.Axis#getExtremes}
  14354. * function.
  14355. *
  14356. * @interface Highcharts.ExtremesObject
  14357. */ /**
  14358. * The maximum value of the axis' associated series.
  14359. * @name Highcharts.ExtremesObject#dataMax
  14360. * @type {number}
  14361. */ /**
  14362. * The minimum value of the axis' associated series.
  14363. * @name Highcharts.ExtremesObject#dataMin
  14364. * @type {number}
  14365. */ /**
  14366. * The maximum axis value, either automatic or set manually. If the `max` option
  14367. * is not set, `maxPadding` is 0 and `endOnTick` is false, this value will be
  14368. * the same as `dataMax`.
  14369. * @name Highcharts.ExtremesObject#max
  14370. * @type {number}
  14371. */ /**
  14372. * The minimum axis value, either automatic or set manually. If the `min` option
  14373. * is not set, `minPadding` is 0 and `startOnTick` is false, this value will be
  14374. * the same as `dataMin`.
  14375. * @name Highcharts.ExtremesObject#min
  14376. * @type {number}
  14377. */ /**
  14378. * The user defined maximum, either from the `max` option or from a zoom or
  14379. * `setExtremes` action.
  14380. * @name Highcharts.ExtremesObject#userMax
  14381. * @type {number}
  14382. */ /**
  14383. * The user defined minimum, either from the `min` option or from a zoom or
  14384. * `setExtremes` action.
  14385. * @name Highcharts.ExtremesObject#userMin
  14386. * @type {number}
  14387. */
  14388. /**
  14389. * Formatter function for the text of a crosshair label.
  14390. *
  14391. * @callback Highcharts.XAxisCrosshairLabelFormatterCallbackFunction
  14392. *
  14393. * @param {Highcharts.Axis} this
  14394. * Axis context
  14395. *
  14396. * @param {number} value
  14397. * Y value of the data point
  14398. *
  14399. * @return {string}
  14400. */
  14401. var defaultOptions = O.defaultOptions;
  14402. var deg2rad = H.deg2rad;
  14403. /**
  14404. * Create a new axis object. Called internally when instanciating a new chart or
  14405. * adding axes by {@link Highcharts.Chart#addAxis}.
  14406. *
  14407. * A chart can have from 0 axes (pie chart) to multiples. In a normal, single
  14408. * series cartesian chart, there is one X axis and one Y axis.
  14409. *
  14410. * The X axis or axes are referenced by {@link Highcharts.Chart.xAxis}, which is
  14411. * an array of Axis objects. If there is only one axis, it can be referenced
  14412. * through `chart.xAxis[0]`, and multiple axes have increasing indices. The same
  14413. * pattern goes for Y axes.
  14414. *
  14415. * If you need to get the axes from a series object, use the `series.xAxis` and
  14416. * `series.yAxis` properties. These are not arrays, as one series can only be
  14417. * associated to one X and one Y axis.
  14418. *
  14419. * A third way to reference the axis programmatically is by `id`. Add an `id` in
  14420. * the axis configuration options, and get the axis by
  14421. * {@link Highcharts.Chart#get}.
  14422. *
  14423. * Configuration options for the axes are given in options.xAxis and
  14424. * options.yAxis.
  14425. *
  14426. * @class
  14427. * @name Highcharts.Axis
  14428. *
  14429. * @param {Highcharts.Chart} chart
  14430. * The Chart instance to apply the axis on.
  14431. *
  14432. * @param {Highcharts.AxisOptions} userOptions
  14433. * Axis options.
  14434. */
  14435. var Axis = /** @class */ (function () {
  14436. /* *
  14437. *
  14438. * Constructors
  14439. *
  14440. * */
  14441. function Axis(chart, userOptions) {
  14442. this.alternateBands = void 0;
  14443. this.bottom = void 0;
  14444. this.categories = void 0;
  14445. this.chart = void 0;
  14446. this.closestPointRange = void 0;
  14447. this.coll = void 0;
  14448. this.hasNames = void 0;
  14449. this.hasVisibleSeries = void 0;
  14450. this.height = void 0;
  14451. this.isLinked = void 0;
  14452. this.labelEdge = void 0; // @todo
  14453. this.labelFormatter = void 0;
  14454. this.left = void 0;
  14455. this.len = void 0;
  14456. this.max = void 0;
  14457. this.maxLabelLength = void 0;
  14458. this.min = void 0;
  14459. this.minorTickInterval = void 0;
  14460. this.minorTicks = void 0;
  14461. this.minPixelPadding = void 0;
  14462. this.names = void 0;
  14463. this.offset = void 0;
  14464. this.oldMax = void 0;
  14465. this.oldMin = void 0;
  14466. this.options = void 0;
  14467. this.overlap = void 0;
  14468. this.paddedTicks = void 0;
  14469. this.plotLinesAndBands = void 0;
  14470. this.plotLinesAndBandsGroups = void 0;
  14471. this.pointRange = void 0;
  14472. this.pointRangePadding = void 0;
  14473. this.pos = void 0;
  14474. this.positiveValuesOnly = void 0;
  14475. this.right = void 0;
  14476. this.series = void 0;
  14477. this.side = void 0;
  14478. this.tickAmount = void 0;
  14479. this.tickInterval = void 0;
  14480. this.tickmarkOffset = void 0;
  14481. this.tickPositions = void 0;
  14482. this.tickRotCorr = void 0;
  14483. this.ticks = void 0;
  14484. this.top = void 0;
  14485. this.transA = void 0;
  14486. this.transB = void 0;
  14487. this.translationSlope = void 0;
  14488. this.userOptions = void 0;
  14489. this.visible = void 0;
  14490. this.width = void 0;
  14491. this.zoomEnabled = void 0;
  14492. this.init(chart, userOptions);
  14493. }
  14494. /* *
  14495. *
  14496. * Functions
  14497. *
  14498. * */
  14499. /**
  14500. * Overrideable function to initialize the axis.
  14501. *
  14502. * @see {@link Axis}
  14503. *
  14504. * @function Highcharts.Axis#init
  14505. *
  14506. * @param {Highcharts.Chart} chart
  14507. * The Chart instance to apply the axis on.
  14508. *
  14509. * @param {Highcharts.AxisOptions} userOptions
  14510. * Axis options.
  14511. *
  14512. * @fires Highcharts.Axis#event:afterInit
  14513. * @fires Highcharts.Axis#event:init
  14514. */
  14515. Axis.prototype.init = function (chart, userOptions) {
  14516. var isXAxis = userOptions.isX,
  14517. axis = this;
  14518. /**
  14519. * The Chart that the axis belongs to.
  14520. *
  14521. * @name Highcharts.Axis#chart
  14522. * @type {Highcharts.Chart}
  14523. */
  14524. axis.chart = chart;
  14525. /**
  14526. * Whether the axis is horizontal.
  14527. *
  14528. * @name Highcharts.Axis#horiz
  14529. * @type {boolean|undefined}
  14530. */
  14531. axis.horiz = chart.inverted && !axis.isZAxis ? !isXAxis : isXAxis;
  14532. /**
  14533. * Whether the axis is the x-axis.
  14534. *
  14535. * @name Highcharts.Axis#isXAxis
  14536. * @type {boolean|undefined}
  14537. */
  14538. axis.isXAxis = isXAxis;
  14539. /**
  14540. * The collection where the axis belongs, for example `xAxis`, `yAxis`
  14541. * or `colorAxis`. Corresponds to properties on Chart, for example
  14542. * {@link Chart.xAxis}.
  14543. *
  14544. * @name Highcharts.Axis#coll
  14545. * @type {string}
  14546. */
  14547. axis.coll = axis.coll || (isXAxis ? 'xAxis' : 'yAxis');
  14548. fireEvent(this, 'init', { userOptions: userOptions });
  14549. axis.opposite = userOptions.opposite; // needed in setOptions
  14550. /**
  14551. * The side on which the axis is rendered. 0 is top, 1 is right, 2
  14552. * is bottom and 3 is left.
  14553. *
  14554. * @name Highcharts.Axis#side
  14555. * @type {number}
  14556. */
  14557. axis.side = userOptions.side || (axis.horiz ?
  14558. (axis.opposite ? 0 : 2) : // top : bottom
  14559. (axis.opposite ? 1 : 3)); // right : left
  14560. /**
  14561. * Current options for the axis after merge of defaults and user's
  14562. * options.
  14563. *
  14564. * @name Highcharts.Axis#options
  14565. * @type {Highcharts.AxisOptions}
  14566. */
  14567. axis.setOptions(userOptions);
  14568. var options = this.options,
  14569. type = options.type;
  14570. axis.labelFormatter = (options.labels.formatter ||
  14571. // can be overwritten by dynamic format
  14572. axis.defaultLabelFormatter);
  14573. /**
  14574. * User's options for this axis without defaults.
  14575. *
  14576. * @name Highcharts.Axis#userOptions
  14577. * @type {Highcharts.AxisOptions}
  14578. */
  14579. axis.userOptions = userOptions;
  14580. axis.minPixelPadding = 0;
  14581. /**
  14582. * Whether the axis is reversed. Based on the `axis.reversed`,
  14583. * option, but inverted charts have reversed xAxis by default.
  14584. *
  14585. * @name Highcharts.Axis#reversed
  14586. * @type {boolean}
  14587. */
  14588. axis.reversed = options.reversed;
  14589. axis.visible = options.visible !== false;
  14590. axis.zoomEnabled = options.zoomEnabled !== false;
  14591. // Initial categories
  14592. axis.hasNames =
  14593. type === 'category' || options.categories === true;
  14594. /**
  14595. * If categories are present for the axis, names are used instead of
  14596. * numbers for that axis.
  14597. *
  14598. * Since Highcharts 3.0, categories can also be extracted by giving each
  14599. * point a name and setting axis type to `category`. However, if you
  14600. * have multiple series, best practice remains defining the `categories`
  14601. * array.
  14602. *
  14603. * @see [xAxis.categories](/highcharts/xAxis.categories)
  14604. *
  14605. * @name Highcharts.Axis#categories
  14606. * @type {Array<string>}
  14607. * @readonly
  14608. */
  14609. axis.categories = options.categories || axis.hasNames;
  14610. if (!axis.names) { // Preserve on update (#3830)
  14611. axis.names = [];
  14612. axis.names.keys = {};
  14613. }
  14614. // Placeholder for plotlines and plotbands groups
  14615. axis.plotLinesAndBandsGroups = {};
  14616. // Shorthand types
  14617. axis.positiveValuesOnly = !!axis.logarithmic;
  14618. // Flag, if axis is linked to another axis
  14619. axis.isLinked = defined(options.linkedTo);
  14620. /**
  14621. * List of major ticks mapped by postition on axis.
  14622. *
  14623. * @see {@link Highcharts.Tick}
  14624. *
  14625. * @name Highcharts.Axis#ticks
  14626. * @type {Highcharts.Dictionary<Highcharts.Tick>}
  14627. */
  14628. axis.ticks = {};
  14629. axis.labelEdge = [];
  14630. /**
  14631. * List of minor ticks mapped by position on the axis.
  14632. *
  14633. * @see {@link Highcharts.Tick}
  14634. *
  14635. * @name Highcharts.Axis#minorTicks
  14636. * @type {Highcharts.Dictionary<Highcharts.Tick>}
  14637. */
  14638. axis.minorTicks = {};
  14639. // List of plotLines/Bands
  14640. axis.plotLinesAndBands = [];
  14641. // Alternate bands
  14642. axis.alternateBands = {};
  14643. // Axis metrics
  14644. axis.len = 0;
  14645. axis.minRange = axis.userMinRange = options.minRange || options.maxZoom;
  14646. axis.range = options.range;
  14647. axis.offset = options.offset || 0;
  14648. /**
  14649. * The maximum value of the axis. In a logarithmic axis, this is the
  14650. * logarithm of the real value, and the real value can be obtained from
  14651. * {@link Axis#getExtremes}.
  14652. *
  14653. * @name Highcharts.Axis#max
  14654. * @type {number|null}
  14655. */
  14656. axis.max = null;
  14657. /**
  14658. * The minimum value of the axis. In a logarithmic axis, this is the
  14659. * logarithm of the real value, and the real value can be obtained from
  14660. * {@link Axis#getExtremes}.
  14661. *
  14662. * @name Highcharts.Axis#min
  14663. * @type {number|null}
  14664. */
  14665. axis.min = null;
  14666. /**
  14667. * The processed crosshair options.
  14668. *
  14669. * @name Highcharts.Axis#crosshair
  14670. * @type {boolean|Highcharts.AxisCrosshairOptions}
  14671. */
  14672. axis.crosshair = pick(options.crosshair, splat(chart.options.tooltip.crosshairs)[isXAxis ? 0 : 1], false);
  14673. var events = axis.options.events;
  14674. // Register. Don't add it again on Axis.update().
  14675. if (chart.axes.indexOf(axis) === -1) { //
  14676. if (isXAxis) { // #2713
  14677. chart.axes.splice(chart.xAxis.length, 0, axis);
  14678. }
  14679. else {
  14680. chart.axes.push(axis);
  14681. }
  14682. chart[axis.coll].push(axis);
  14683. }
  14684. /**
  14685. * All series associated to the axis.
  14686. *
  14687. * @name Highcharts.Axis#series
  14688. * @type {Array<Highcharts.Series>}
  14689. */
  14690. axis.series = axis.series || []; // populated by Series
  14691. // Reversed axis
  14692. if (chart.inverted &&
  14693. !axis.isZAxis &&
  14694. isXAxis &&
  14695. typeof axis.reversed === 'undefined') {
  14696. axis.reversed = true;
  14697. }
  14698. axis.labelRotation = axis.options.labels.rotation;
  14699. // register event listeners
  14700. objectEach(events, function (event, eventType) {
  14701. if (isFunction(event)) {
  14702. addEvent(axis, eventType, event);
  14703. }
  14704. });
  14705. fireEvent(this, 'afterInit');
  14706. };
  14707. /**
  14708. * Merge and set options.
  14709. *
  14710. * @private
  14711. * @function Highcharts.Axis#setOptions
  14712. *
  14713. * @param {Highcharts.AxisOptions} userOptions
  14714. * Axis options.
  14715. *
  14716. * @fires Highcharts.Axis#event:afterSetOptions
  14717. */
  14718. Axis.prototype.setOptions = function (userOptions) {
  14719. this.options = merge(Axis.defaultOptions, (this.coll === 'yAxis') && Axis.defaultYAxisOptions, [
  14720. Axis.defaultTopAxisOptions,
  14721. Axis.defaultRightAxisOptions,
  14722. Axis.defaultBottomAxisOptions,
  14723. Axis.defaultLeftAxisOptions
  14724. ][this.side], merge(
  14725. // if set in setOptions (#1053):
  14726. defaultOptions[this.coll], userOptions));
  14727. fireEvent(this, 'afterSetOptions', { userOptions: userOptions });
  14728. };
  14729. /**
  14730. * The default label formatter. The context is a special config object for
  14731. * the label. In apps, use the
  14732. * [labels.formatter](https://api.highcharts.com/highcharts/xAxis.labels.formatter)
  14733. * instead, except when a modification is needed.
  14734. *
  14735. * @function Highcharts.Axis#defaultLabelFormatter
  14736. *
  14737. * @param {Highcharts.AxisLabelsFormatterContextObject<number>|Highcharts.AxisLabelsFormatterContextObject<string>} this
  14738. * Formatter context of axis label.
  14739. *
  14740. * @return {string}
  14741. * The formatted label content.
  14742. */
  14743. Axis.prototype.defaultLabelFormatter = function () {
  14744. var axis = this.axis,
  14745. value = isNumber(this.value) ? this.value : NaN,
  14746. time = axis.chart.time,
  14747. categories = axis.categories,
  14748. dateTimeLabelFormat = this.dateTimeLabelFormat,
  14749. lang = defaultOptions.lang,
  14750. numericSymbols = lang.numericSymbols,
  14751. numSymMagnitude = lang.numericSymbolMagnitude || 1000,
  14752. i = numericSymbols && numericSymbols.length,
  14753. multi,
  14754. ret,
  14755. formatOption = axis.options.labels.format,
  14756. // make sure the same symbol is added for all labels on a linear
  14757. // axis
  14758. numericSymbolDetector = axis.logarithmic ?
  14759. Math.abs(value) :
  14760. axis.tickInterval;
  14761. var chart = this.chart;
  14762. var numberFormatter = chart.numberFormatter;
  14763. if (formatOption) {
  14764. ret = format(formatOption, this, chart);
  14765. }
  14766. else if (categories) {
  14767. ret = "" + this.value;
  14768. }
  14769. else if (dateTimeLabelFormat) { // datetime axis
  14770. ret = time.dateFormat(dateTimeLabelFormat, value);
  14771. }
  14772. else if (i && numericSymbolDetector >= 1000) {
  14773. // Decide whether we should add a numeric symbol like k (thousands)
  14774. // or M (millions). If we are to enable this in tooltip or other
  14775. // places as well, we can move this logic to the numberFormatter and
  14776. // enable it by a parameter.
  14777. while (i-- && typeof ret === 'undefined') {
  14778. multi = Math.pow(numSymMagnitude, i + 1);
  14779. if (
  14780. // Only accept a numeric symbol when the distance is more
  14781. // than a full unit. So for example if the symbol is k, we
  14782. // don't accept numbers like 0.5k.
  14783. numericSymbolDetector >= multi &&
  14784. // Accept one decimal before the symbol. Accepts 0.5k but
  14785. // not 0.25k. How does this work with the previous?
  14786. (value * 10) % multi === 0 &&
  14787. numericSymbols[i] !== null &&
  14788. value !== 0) { // #5480
  14789. ret = numberFormatter(value / multi, -1) + numericSymbols[i];
  14790. }
  14791. }
  14792. }
  14793. if (typeof ret === 'undefined') {
  14794. if (Math.abs(value) >= 10000) { // add thousands separators
  14795. ret = numberFormatter(value, -1);
  14796. }
  14797. else { // small numbers
  14798. ret = numberFormatter(value, -1, void 0, ''); // #2466
  14799. }
  14800. }
  14801. return ret;
  14802. };
  14803. /**
  14804. * Get the minimum and maximum for the series of each axis. The function
  14805. * analyzes the axis series and updates `this.dataMin` and `this.dataMax`.
  14806. *
  14807. * @private
  14808. * @function Highcharts.Axis#getSeriesExtremes
  14809. *
  14810. * @fires Highcharts.Axis#event:afterGetSeriesExtremes
  14811. * @fires Highcharts.Axis#event:getSeriesExtremes
  14812. */
  14813. Axis.prototype.getSeriesExtremes = function () {
  14814. var axis = this,
  14815. chart = axis.chart,
  14816. xExtremes;
  14817. fireEvent(this, 'getSeriesExtremes', null, function () {
  14818. axis.hasVisibleSeries = false;
  14819. // Reset properties in case we're redrawing (#3353)
  14820. axis.dataMin = axis.dataMax = axis.threshold = null;
  14821. axis.softThreshold = !axis.isXAxis;
  14822. if (axis.stacking) {
  14823. axis.stacking.buildStacks();
  14824. }
  14825. // loop through this axis' series
  14826. axis.series.forEach(function (series) {
  14827. if (series.visible ||
  14828. !chart.options.chart.ignoreHiddenSeries) {
  14829. var seriesOptions = series.options,
  14830. xData,
  14831. threshold = seriesOptions.threshold,
  14832. seriesDataMin,
  14833. seriesDataMax;
  14834. axis.hasVisibleSeries = true;
  14835. // Validate threshold in logarithmic axes
  14836. if (axis.positiveValuesOnly && threshold <= 0) {
  14837. threshold = null;
  14838. }
  14839. // Get dataMin and dataMax for X axes
  14840. if (axis.isXAxis) {
  14841. xData = series.xData;
  14842. if (xData.length) {
  14843. var isPositive = function (number) { return number > 0; };
  14844. xData = axis.logarithmic ?
  14845. xData.filter(axis.validatePositiveValue) :
  14846. xData;
  14847. xExtremes = series.getXExtremes(xData);
  14848. // If xData contains values which is not numbers,
  14849. // then filter them out. To prevent performance hit,
  14850. // we only do this after we have already found
  14851. // seriesDataMin because in most cases all data is
  14852. // valid. #5234.
  14853. seriesDataMin = xExtremes.min;
  14854. seriesDataMax = xExtremes.max;
  14855. if (!isNumber(seriesDataMin) &&
  14856. // #5010:
  14857. !(seriesDataMin instanceof Date)) {
  14858. xData = xData.filter(isNumber);
  14859. xExtremes = series.getXExtremes(xData);
  14860. // Do it again with valid data
  14861. seriesDataMin = xExtremes.min;
  14862. seriesDataMax = xExtremes.max;
  14863. }
  14864. if (xData.length) {
  14865. axis.dataMin = Math.min(pick(axis.dataMin, seriesDataMin), seriesDataMin);
  14866. axis.dataMax = Math.max(pick(axis.dataMax, seriesDataMax), seriesDataMax);
  14867. }
  14868. }
  14869. // Get dataMin and dataMax for Y axes, as well as handle
  14870. // stacking and processed data
  14871. }
  14872. else {
  14873. // Get this particular series extremes
  14874. var dataExtremes = series.applyExtremes();
  14875. // Get the dataMin and dataMax so far. If percentage is
  14876. // used, the min and max are always 0 and 100. If
  14877. // seriesDataMin and seriesDataMax is null, then series
  14878. // doesn't have active y data, we continue with nulls
  14879. if (isNumber(dataExtremes.dataMin)) {
  14880. seriesDataMin = dataExtremes.dataMin;
  14881. axis.dataMin = Math.min(pick(axis.dataMin, seriesDataMin), seriesDataMin);
  14882. }
  14883. if (isNumber(dataExtremes.dataMax)) {
  14884. seriesDataMax = dataExtremes.dataMax;
  14885. axis.dataMax = Math.max(pick(axis.dataMax, seriesDataMax), seriesDataMax);
  14886. }
  14887. // Adjust to threshold
  14888. if (defined(threshold)) {
  14889. axis.threshold = threshold;
  14890. }
  14891. // If any series has a hard threshold, it takes
  14892. // precedence
  14893. if (!seriesOptions.softThreshold ||
  14894. axis.positiveValuesOnly) {
  14895. axis.softThreshold = false;
  14896. }
  14897. }
  14898. }
  14899. });
  14900. });
  14901. fireEvent(this, 'afterGetSeriesExtremes');
  14902. };
  14903. /**
  14904. * Translate from axis value to pixel position on the chart, or back. Use
  14905. * the `toPixels` and `toValue` functions in applications.
  14906. *
  14907. * @private
  14908. * @function Highcharts.Axis#translate
  14909. *
  14910. * @param {number} val
  14911. * TO-DO: parameter description
  14912. *
  14913. * @param {boolean|null} [backwards]
  14914. * TO-DO: parameter description
  14915. *
  14916. * @param {boolean|null} [cvsCoord]
  14917. * TO-DO: parameter description
  14918. *
  14919. * @param {boolean|null} [old]
  14920. * TO-DO: parameter description
  14921. *
  14922. * @param {boolean} [handleLog]
  14923. * TO-DO: parameter description
  14924. *
  14925. * @param {number} [pointPlacement]
  14926. * TO-DO: parameter description
  14927. *
  14928. * @return {number|undefined}
  14929. */
  14930. Axis.prototype.translate = function (val, backwards, cvsCoord, old, handleLog, pointPlacement) {
  14931. var axis = this.linkedParent || this, // #1417
  14932. sign = 1,
  14933. cvsOffset = 0,
  14934. localA = old ? axis.oldTransA : axis.transA,
  14935. localMin = old ? axis.oldMin : axis.min,
  14936. returnValue = 0,
  14937. minPixelPadding = axis.minPixelPadding,
  14938. doPostTranslate = (axis.isOrdinal ||
  14939. axis.brokenAxis && axis.brokenAxis.hasBreaks ||
  14940. (axis.logarithmic && handleLog)) && axis.lin2val;
  14941. if (!localA) {
  14942. localA = axis.transA;
  14943. }
  14944. // In vertical axes, the canvas coordinates start from 0 at the top like
  14945. // in SVG.
  14946. if (cvsCoord) {
  14947. sign *= -1; // canvas coordinates inverts the value
  14948. cvsOffset = axis.len;
  14949. }
  14950. // Handle reversed axis
  14951. if (axis.reversed) {
  14952. sign *= -1;
  14953. cvsOffset -= sign * (axis.sector || axis.len);
  14954. }
  14955. // From pixels to value
  14956. if (backwards) { // reverse translation
  14957. val = val * sign + cvsOffset;
  14958. val -= minPixelPadding;
  14959. // from chart pixel to value:
  14960. returnValue = val / localA + localMin;
  14961. if (doPostTranslate) { // log and ordinal axes
  14962. returnValue = axis.lin2val(returnValue);
  14963. }
  14964. // From value to pixels
  14965. }
  14966. else {
  14967. if (doPostTranslate) { // log and ordinal axes
  14968. val = axis.val2lin(val);
  14969. }
  14970. returnValue = isNumber(localMin) ?
  14971. (sign * (val - localMin) * localA +
  14972. cvsOffset +
  14973. (sign * minPixelPadding) +
  14974. (isNumber(pointPlacement) ?
  14975. localA * pointPlacement :
  14976. 0)) :
  14977. void 0;
  14978. }
  14979. return returnValue;
  14980. };
  14981. /**
  14982. * Translate a value in terms of axis units into pixels within the chart.
  14983. *
  14984. * @function Highcharts.Axis#toPixels
  14985. *
  14986. * @param {number} value
  14987. * A value in terms of axis units.
  14988. *
  14989. * @param {boolean} paneCoordinates
  14990. * Whether to return the pixel coordinate relative to the chart or just the
  14991. * axis/pane itself.
  14992. *
  14993. * @return {number}
  14994. * Pixel position of the value on the chart or axis.
  14995. */
  14996. Axis.prototype.toPixels = function (value, paneCoordinates) {
  14997. return this.translate(value, false, !this.horiz, null, true) +
  14998. (paneCoordinates ? 0 : this.pos);
  14999. };
  15000. /**
  15001. * Translate a pixel position along the axis to a value in terms of axis
  15002. * units.
  15003. *
  15004. * @function Highcharts.Axis#toValue
  15005. *
  15006. * @param {number} pixel
  15007. * The pixel value coordinate.
  15008. *
  15009. * @param {boolean} [paneCoordinates=false]
  15010. * Whether the input pixel is relative to the chart or just the axis/pane
  15011. * itself.
  15012. *
  15013. * @return {number}
  15014. * The axis value.
  15015. */
  15016. Axis.prototype.toValue = function (pixel, paneCoordinates) {
  15017. return this.translate(pixel - (paneCoordinates ? 0 : this.pos), true, !this.horiz, null, true);
  15018. };
  15019. /**
  15020. * Create the path for a plot line that goes from the given value on
  15021. * this axis, across the plot to the opposite side. Also used internally for
  15022. * grid lines and crosshairs.
  15023. *
  15024. * @function Highcharts.Axis#getPlotLinePath
  15025. *
  15026. * @param {Highcharts.AxisPlotLinePathOptionsObject} options
  15027. * Options for the path.
  15028. *
  15029. * @return {Highcharts.SVGPathArray|null}
  15030. * The SVG path definition for the plot line.
  15031. */
  15032. Axis.prototype.getPlotLinePath = function (options) {
  15033. var axis = this,
  15034. chart = axis.chart,
  15035. axisLeft = axis.left,
  15036. axisTop = axis.top,
  15037. old = options.old,
  15038. value = options.value,
  15039. translatedValue = options.translatedValue,
  15040. lineWidth = options.lineWidth,
  15041. force = options.force,
  15042. x1,
  15043. y1,
  15044. x2,
  15045. y2,
  15046. cHeight = (old && chart.oldChartHeight) || chart.chartHeight,
  15047. cWidth = (old && chart.oldChartWidth) || chart.chartWidth,
  15048. skip,
  15049. transB = axis.transB,
  15050. evt;
  15051. // eslint-disable-next-line valid-jsdoc
  15052. /**
  15053. * Check if x is between a and b. If not, either move to a/b
  15054. * or skip, depending on the force parameter.
  15055. * @private
  15056. */
  15057. function between(x, a, b) {
  15058. if (force !== 'pass' && x < a || x > b) {
  15059. if (force) {
  15060. x = clamp(x, a, b);
  15061. }
  15062. else {
  15063. skip = true;
  15064. }
  15065. }
  15066. return x;
  15067. }
  15068. evt = {
  15069. value: value,
  15070. lineWidth: lineWidth,
  15071. old: old,
  15072. force: force,
  15073. acrossPanes: options.acrossPanes,
  15074. translatedValue: translatedValue
  15075. };
  15076. fireEvent(this, 'getPlotLinePath', evt, function (e) {
  15077. translatedValue = pick(translatedValue, axis.translate(value, null, null, old));
  15078. // Keep the translated value within sane bounds, and avoid Infinity
  15079. // to fail the isNumber test (#7709).
  15080. translatedValue = clamp(translatedValue, -1e5, 1e5);
  15081. x1 = x2 = Math.round(translatedValue + transB);
  15082. y1 = y2 = Math.round(cHeight - translatedValue - transB);
  15083. if (!isNumber(translatedValue)) { // no min or max
  15084. skip = true;
  15085. force = false; // #7175, don't force it when path is invalid
  15086. }
  15087. else if (axis.horiz) {
  15088. y1 = axisTop;
  15089. y2 = cHeight - axis.bottom;
  15090. x1 = x2 = between(x1, axisLeft, axisLeft + axis.width);
  15091. }
  15092. else {
  15093. x1 = axisLeft;
  15094. x2 = cWidth - axis.right;
  15095. y1 = y2 = between(y1, axisTop, axisTop + axis.height);
  15096. }
  15097. e.path = skip && !force ?
  15098. null :
  15099. chart.renderer.crispLine([['M', x1, y1], ['L', x2, y2]], lineWidth || 1);
  15100. });
  15101. return evt.path;
  15102. };
  15103. /**
  15104. * Internal function to et the tick positions of a linear axis to round
  15105. * values like whole tens or every five.
  15106. *
  15107. * @function Highcharts.Axis#getLinearTickPositions
  15108. *
  15109. * @param {number} tickInterval
  15110. * The normalized tick interval.
  15111. *
  15112. * @param {number} min
  15113. * Axis minimum.
  15114. *
  15115. * @param {number} max
  15116. * Axis maximum.
  15117. *
  15118. * @return {Array<number>}
  15119. * An array of axis values where ticks should be placed.
  15120. */
  15121. Axis.prototype.getLinearTickPositions = function (tickInterval, min, max) {
  15122. var pos,
  15123. lastPos,
  15124. roundedMin = correctFloat(Math.floor(min / tickInterval) * tickInterval),
  15125. roundedMax = correctFloat(Math.ceil(max / tickInterval) * tickInterval),
  15126. tickPositions = [],
  15127. precision;
  15128. // When the precision is higher than what we filter out in
  15129. // correctFloat, skip it (#6183).
  15130. if (correctFloat(roundedMin + tickInterval) === roundedMin) {
  15131. precision = 20;
  15132. }
  15133. // For single points, add a tick regardless of the relative position
  15134. // (#2662, #6274)
  15135. if (this.single) {
  15136. return [min];
  15137. }
  15138. // Populate the intermediate values
  15139. pos = roundedMin;
  15140. while (pos <= roundedMax) {
  15141. // Place the tick on the rounded value
  15142. tickPositions.push(pos);
  15143. // Always add the raw tickInterval, not the corrected one.
  15144. pos = correctFloat(pos + tickInterval, precision);
  15145. // If the interval is not big enough in the current min - max range
  15146. // to actually increase the loop variable, we need to break out to
  15147. // prevent endless loop. Issue #619
  15148. if (pos === lastPos) {
  15149. break;
  15150. }
  15151. // Record the last value
  15152. lastPos = pos;
  15153. }
  15154. return tickPositions;
  15155. };
  15156. /**
  15157. * Resolve the new minorTicks/minorTickInterval options into the legacy
  15158. * loosely typed minorTickInterval option.
  15159. *
  15160. * @function Highcharts.Axis#getMinorTickInterval
  15161. *
  15162. * @return {number|"auto"|null}
  15163. */
  15164. Axis.prototype.getMinorTickInterval = function () {
  15165. var options = this.options;
  15166. if (options.minorTicks === true) {
  15167. return pick(options.minorTickInterval, 'auto');
  15168. }
  15169. if (options.minorTicks === false) {
  15170. return null;
  15171. }
  15172. return options.minorTickInterval;
  15173. };
  15174. /**
  15175. * Internal function to return the minor tick positions. For logarithmic
  15176. * axes, the same logic as for major ticks is reused.
  15177. *
  15178. * @function Highcharts.Axis#getMinorTickPositions
  15179. *
  15180. * @return {Array<number>}
  15181. * An array of axis values where ticks should be placed.
  15182. */
  15183. Axis.prototype.getMinorTickPositions = function () {
  15184. var axis = this,
  15185. options = axis.options,
  15186. tickPositions = axis.tickPositions,
  15187. minorTickInterval = axis.minorTickInterval,
  15188. minorTickPositions = [],
  15189. pos,
  15190. pointRangePadding = axis.pointRangePadding || 0,
  15191. min = axis.min - pointRangePadding, // #1498
  15192. max = axis.max + pointRangePadding, // #1498
  15193. range = max - min;
  15194. // If minor ticks get too dense, they are hard to read, and may cause
  15195. // long running script. So we don't draw them.
  15196. if (range && range / minorTickInterval < axis.len / 3) { // #3875
  15197. var logarithmic_1 = axis.logarithmic;
  15198. if (logarithmic_1) {
  15199. // For each interval in the major ticks, compute the minor ticks
  15200. // separately.
  15201. this.paddedTicks.forEach(function (_pos, i, paddedTicks) {
  15202. if (i) {
  15203. minorTickPositions.push.apply(minorTickPositions, logarithmic_1.getLogTickPositions(minorTickInterval, paddedTicks[i - 1], paddedTicks[i], true));
  15204. }
  15205. });
  15206. }
  15207. else if (axis.dateTime &&
  15208. this.getMinorTickInterval() === 'auto') { // #1314
  15209. minorTickPositions = minorTickPositions.concat(axis.getTimeTicks(axis.dateTime.normalizeTimeTickInterval(minorTickInterval), min, max, options.startOfWeek));
  15210. }
  15211. else {
  15212. for (pos = min + (tickPositions[0] - min) % minorTickInterval; pos <= max; pos += minorTickInterval) {
  15213. // Very, very, tight grid lines (#5771)
  15214. if (pos === minorTickPositions[0]) {
  15215. break;
  15216. }
  15217. minorTickPositions.push(pos);
  15218. }
  15219. }
  15220. }
  15221. if (minorTickPositions.length !== 0) {
  15222. axis.trimTicks(minorTickPositions); // #3652 #3743 #1498 #6330
  15223. }
  15224. return minorTickPositions;
  15225. };
  15226. /**
  15227. * Adjust the min and max for the minimum range. Keep in mind that the
  15228. * series data is not yet processed, so we don't have information on data
  15229. * cropping and grouping, or updated `axis.pointRange` or
  15230. * `series.pointRange`. The data can't be processed until we have finally
  15231. * established min and max.
  15232. *
  15233. * @private
  15234. * @function Highcharts.Axis#adjustForMinRange
  15235. */
  15236. Axis.prototype.adjustForMinRange = function () {
  15237. var axis = this,
  15238. options = axis.options,
  15239. min = axis.min,
  15240. max = axis.max,
  15241. log = axis.logarithmic,
  15242. zoomOffset,
  15243. spaceAvailable,
  15244. closestDataRange,
  15245. i,
  15246. distance,
  15247. xData,
  15248. loopLength,
  15249. minArgs,
  15250. maxArgs,
  15251. minRange;
  15252. // Set the automatic minimum range based on the closest point distance
  15253. if (axis.isXAxis &&
  15254. typeof axis.minRange === 'undefined' &&
  15255. !log) {
  15256. if (defined(options.min) || defined(options.max)) {
  15257. axis.minRange = null; // don't do this again
  15258. }
  15259. else {
  15260. // Find the closest distance between raw data points, as opposed
  15261. // to closestPointRange that applies to processed points
  15262. // (cropped and grouped)
  15263. axis.series.forEach(function (series) {
  15264. xData = series.xData;
  15265. loopLength = series.xIncrement ? 1 : xData.length - 1;
  15266. for (i = loopLength; i > 0; i--) {
  15267. distance = xData[i] - xData[i - 1];
  15268. if (typeof closestDataRange === 'undefined' ||
  15269. distance < closestDataRange) {
  15270. closestDataRange = distance;
  15271. }
  15272. }
  15273. });
  15274. axis.minRange = Math.min(closestDataRange * 5, axis.dataMax - axis.dataMin);
  15275. }
  15276. }
  15277. // if minRange is exceeded, adjust
  15278. if (max - min < axis.minRange) {
  15279. spaceAvailable =
  15280. axis.dataMax - axis.dataMin >=
  15281. axis.minRange;
  15282. minRange = axis.minRange;
  15283. zoomOffset = (minRange - max + min) / 2;
  15284. // if min and max options have been set, don't go beyond it
  15285. minArgs = [
  15286. min - zoomOffset,
  15287. pick(options.min, min - zoomOffset)
  15288. ];
  15289. // If space is available, stay within the data range
  15290. if (spaceAvailable) {
  15291. minArgs[2] = axis.logarithmic ?
  15292. axis.logarithmic.log2lin(axis.dataMin) :
  15293. axis.dataMin;
  15294. }
  15295. min = arrayMax(minArgs);
  15296. maxArgs = [
  15297. min + minRange,
  15298. pick(options.max, min + minRange)
  15299. ];
  15300. // If space is availabe, stay within the data range
  15301. if (spaceAvailable) {
  15302. maxArgs[2] = log ?
  15303. log.log2lin(axis.dataMax) :
  15304. axis.dataMax;
  15305. }
  15306. max = arrayMin(maxArgs);
  15307. // now if the max is adjusted, adjust the min back
  15308. if (max - min < minRange) {
  15309. minArgs[0] = max - minRange;
  15310. minArgs[1] = pick(options.min, max - minRange);
  15311. min = arrayMax(minArgs);
  15312. }
  15313. }
  15314. // Record modified extremes
  15315. axis.min = min;
  15316. axis.max = max;
  15317. };
  15318. // eslint-disable-next-line valid-jsdoc
  15319. /**
  15320. * Find the closestPointRange across all series.
  15321. *
  15322. * @private
  15323. * @function Highcharts.Axis#getClosest
  15324. */
  15325. Axis.prototype.getClosest = function () {
  15326. var ret;
  15327. if (this.categories) {
  15328. ret = 1;
  15329. }
  15330. else {
  15331. this.series.forEach(function (series) {
  15332. var seriesClosest = series.closestPointRange,
  15333. visible = series.visible ||
  15334. !series.chart.options.chart.ignoreHiddenSeries;
  15335. if (!series.noSharedTooltip &&
  15336. defined(seriesClosest) &&
  15337. visible) {
  15338. ret = defined(ret) ?
  15339. Math.min(ret, seriesClosest) :
  15340. seriesClosest;
  15341. }
  15342. });
  15343. }
  15344. return ret;
  15345. };
  15346. /**
  15347. * When a point name is given and no x, search for the name in the existing
  15348. * categories, or if categories aren't provided, search names or create a
  15349. * new category (#2522).
  15350. * @private
  15351. * @function Highcharts.Axis#nameToX
  15352. *
  15353. * @param {Highcharts.Point} point
  15354. * The point to inspect.
  15355. *
  15356. * @return {number}
  15357. * The X value that the point is given.
  15358. */
  15359. Axis.prototype.nameToX = function (point) {
  15360. var explicitCategories = isArray(this.categories),
  15361. names = explicitCategories ? this.categories : this.names,
  15362. nameX = point.options.x,
  15363. x;
  15364. point.series.requireSorting = false;
  15365. if (!defined(nameX)) {
  15366. nameX = this.options.uniqueNames === false ?
  15367. point.series.autoIncrement() :
  15368. (explicitCategories ?
  15369. names.indexOf(point.name) :
  15370. pick(names.keys[point.name], -1));
  15371. }
  15372. if (nameX === -1) { // Not found in currenct categories
  15373. if (!explicitCategories) {
  15374. x = names.length;
  15375. }
  15376. }
  15377. else {
  15378. x = nameX;
  15379. }
  15380. // Write the last point's name to the names array
  15381. if (typeof x !== 'undefined') {
  15382. this.names[x] = point.name;
  15383. // Backwards mapping is much faster than array searching (#7725)
  15384. this.names.keys[point.name] = x;
  15385. }
  15386. return x;
  15387. };
  15388. /**
  15389. * When changes have been done to series data, update the axis.names.
  15390. *
  15391. * @private
  15392. * @function Highcharts.Axis#updateNames
  15393. */
  15394. Axis.prototype.updateNames = function () {
  15395. var axis = this,
  15396. names = this.names,
  15397. i = names.length;
  15398. if (i > 0) {
  15399. Object.keys(names.keys).forEach(function (key) {
  15400. delete (names.keys)[key];
  15401. });
  15402. names.length = 0;
  15403. this.minRange = this.userMinRange; // Reset
  15404. (this.series || []).forEach(function (series) {
  15405. // Reset incrementer (#5928)
  15406. series.xIncrement = null;
  15407. // When adding a series, points are not yet generated
  15408. if (!series.points || series.isDirtyData) {
  15409. // When we're updating the series with data that is longer
  15410. // than it was, and cropThreshold is passed, we need to make
  15411. // sure that the axis.max is increased _before_ running the
  15412. // premature processData. Otherwise this early iteration of
  15413. // processData will crop the points to axis.max, and the
  15414. // names array will be too short (#5857).
  15415. axis.max = Math.max(axis.max, series.xData.length - 1);
  15416. series.processData();
  15417. series.generatePoints();
  15418. }
  15419. series.data.forEach(function (point, i) {
  15420. var x;
  15421. if (point &&
  15422. point.options &&
  15423. typeof point.name !== 'undefined' // #9562
  15424. ) {
  15425. x = axis.nameToX(point);
  15426. if (typeof x !== 'undefined' && x !== point.x) {
  15427. point.x = x;
  15428. series.xData[i] = x;
  15429. }
  15430. }
  15431. });
  15432. });
  15433. }
  15434. };
  15435. /**
  15436. * Update translation information.
  15437. *
  15438. * @private
  15439. * @function Highcharts.Axis#setAxisTranslation
  15440. *
  15441. * @param {boolean} [saveOld]
  15442. * TO-DO: parameter description
  15443. *
  15444. * @fires Highcharts.Axis#event:afterSetAxisTranslation
  15445. */
  15446. Axis.prototype.setAxisTranslation = function (saveOld) {
  15447. var axis = this,
  15448. range = axis.max - axis.min,
  15449. pointRange = axis.axisPointRange || 0,
  15450. closestPointRange,
  15451. minPointOffset = 0,
  15452. pointRangePadding = 0,
  15453. linkedParent = axis.linkedParent,
  15454. ordinalCorrection,
  15455. hasCategories = !!axis.categories,
  15456. transA = axis.transA,
  15457. isXAxis = axis.isXAxis;
  15458. // Adjust translation for padding. Y axis with categories need to go
  15459. // through the same (#1784).
  15460. if (isXAxis || hasCategories || pointRange) {
  15461. // Get the closest points
  15462. closestPointRange = axis.getClosest();
  15463. if (linkedParent) {
  15464. minPointOffset = linkedParent.minPointOffset;
  15465. pointRangePadding = linkedParent.pointRangePadding;
  15466. }
  15467. else {
  15468. axis.series.forEach(function (series) {
  15469. var seriesPointRange = hasCategories ?
  15470. 1 :
  15471. (isXAxis ?
  15472. pick(series.options.pointRange,
  15473. closestPointRange, 0) :
  15474. (axis.axisPointRange || 0)), // #2806
  15475. pointPlacement = series.options.pointPlacement;
  15476. pointRange = Math.max(pointRange, seriesPointRange);
  15477. if (!axis.single || hasCategories) {
  15478. // TODO: series should internally set x- and y-
  15479. // pointPlacement to simplify this logic.
  15480. var isPointPlacementAxis = series.is('xrange') ? !isXAxis : isXAxis;
  15481. // minPointOffset is the value padding to the left of
  15482. // the axis in order to make room for points with a
  15483. // pointRange, typically columns. When the
  15484. // pointPlacement option is 'between' or 'on', this
  15485. // padding does not apply.
  15486. minPointOffset = Math.max(minPointOffset, isPointPlacementAxis && isString(pointPlacement) ?
  15487. 0 :
  15488. seriesPointRange / 2);
  15489. // Determine the total padding needed to the length of
  15490. // the axis to make room for the pointRange. If the
  15491. // series' pointPlacement is 'on', no padding is added.
  15492. pointRangePadding = Math.max(pointRangePadding, isPointPlacementAxis && pointPlacement === 'on' ?
  15493. 0 :
  15494. seriesPointRange);
  15495. }
  15496. });
  15497. }
  15498. // Record minPointOffset and pointRangePadding
  15499. ordinalCorrection = axis.ordinal && axis.ordinal.slope && closestPointRange ?
  15500. axis.ordinal.slope / closestPointRange :
  15501. 1; // #988, #1853
  15502. axis.minPointOffset = minPointOffset =
  15503. minPointOffset * ordinalCorrection;
  15504. axis.pointRangePadding =
  15505. pointRangePadding = pointRangePadding * ordinalCorrection;
  15506. // pointRange means the width reserved for each point, like in a
  15507. // column chart
  15508. axis.pointRange = Math.min(pointRange, axis.single && hasCategories ? 1 : range);
  15509. // closestPointRange means the closest distance between points. In
  15510. // columns it is mostly equal to pointRange, but in lines pointRange
  15511. // is 0 while closestPointRange is some other value
  15512. if (isXAxis) {
  15513. axis.closestPointRange = closestPointRange;
  15514. }
  15515. }
  15516. // Secondary values
  15517. if (saveOld) {
  15518. axis.oldTransA = transA;
  15519. }
  15520. axis.translationSlope = axis.transA = transA =
  15521. axis.staticScale ||
  15522. axis.len / ((range + pointRangePadding) || 1);
  15523. // Translation addend
  15524. axis.transB = axis.horiz ? axis.left : axis.bottom;
  15525. axis.minPixelPadding = transA * minPointOffset;
  15526. fireEvent(this, 'afterSetAxisTranslation');
  15527. };
  15528. /**
  15529. * @private
  15530. * @function Highcharts.Axis#minFromRange
  15531. *
  15532. * @return {number}
  15533. */
  15534. Axis.prototype.minFromRange = function () {
  15535. var axis = this;
  15536. return axis.max - axis.range;
  15537. };
  15538. /**
  15539. * Set the tick positions to round values and optionally extend the extremes
  15540. * to the nearest tick.
  15541. *
  15542. * @private
  15543. * @function Highcharts.Axis#setTickInterval
  15544. *
  15545. * @param {boolean} secondPass
  15546. * TO-DO: parameter description
  15547. *
  15548. * @fires Highcharts.Axis#event:foundExtremes
  15549. */
  15550. Axis.prototype.setTickInterval = function (secondPass) {
  15551. var axis = this,
  15552. chart = axis.chart,
  15553. log = axis.logarithmic,
  15554. options = axis.options,
  15555. isXAxis = axis.isXAxis,
  15556. isLinked = axis.isLinked,
  15557. maxPadding = options.maxPadding,
  15558. minPadding = options.minPadding,
  15559. length,
  15560. linkedParentExtremes,
  15561. tickIntervalOption = options.tickInterval,
  15562. minTickInterval,
  15563. tickPixelIntervalOption = options.tickPixelInterval,
  15564. categories = axis.categories,
  15565. threshold = isNumber(axis.threshold) ? axis.threshold : null,
  15566. softThreshold = axis.softThreshold,
  15567. thresholdMin,
  15568. thresholdMax,
  15569. hardMin,
  15570. hardMax;
  15571. if (!axis.dateTime && !categories && !isLinked) {
  15572. this.getTickAmount();
  15573. }
  15574. // Min or max set either by zooming/setExtremes or initial options
  15575. hardMin = pick(axis.userMin, options.min);
  15576. hardMax = pick(axis.userMax, options.max);
  15577. // Linked axis gets the extremes from the parent axis
  15578. if (isLinked) {
  15579. axis.linkedParent = chart[axis.coll][options.linkedTo];
  15580. linkedParentExtremes = axis.linkedParent.getExtremes();
  15581. axis.min = pick(linkedParentExtremes.min, linkedParentExtremes.dataMin);
  15582. axis.max = pick(linkedParentExtremes.max, linkedParentExtremes.dataMax);
  15583. if (options.type !== axis.linkedParent.options.type) {
  15584. // Can't link axes of different type
  15585. error(11, 1, chart);
  15586. }
  15587. // Initial min and max from the extreme data values
  15588. }
  15589. else {
  15590. // Adjust to hard threshold
  15591. if (softThreshold && defined(threshold)) {
  15592. if (axis.dataMin >= threshold) {
  15593. thresholdMin = threshold;
  15594. minPadding = 0;
  15595. }
  15596. else if (axis.dataMax <= threshold) {
  15597. thresholdMax = threshold;
  15598. maxPadding = 0;
  15599. }
  15600. }
  15601. axis.min = pick(hardMin, thresholdMin, axis.dataMin);
  15602. axis.max = pick(hardMax, thresholdMax, axis.dataMax);
  15603. }
  15604. if (log) {
  15605. if (axis.positiveValuesOnly &&
  15606. !secondPass &&
  15607. Math.min(axis.min, pick(axis.dataMin, axis.min)) <= 0) { // #978
  15608. // Can't plot negative values on log axis
  15609. error(10, 1, chart);
  15610. }
  15611. // The correctFloat cures #934, float errors on full tens. But it
  15612. // was too aggressive for #4360 because of conversion back to lin,
  15613. // therefore use precision 15.
  15614. axis.min = correctFloat(log.log2lin(axis.min), 16);
  15615. axis.max = correctFloat(log.log2lin(axis.max), 16);
  15616. }
  15617. // handle zoomed range
  15618. if (axis.range && defined(axis.max)) {
  15619. // #618, #6773:
  15620. axis.userMin = axis.min = hardMin =
  15621. Math.max(axis.dataMin, axis.minFromRange());
  15622. axis.userMax = hardMax = axis.max;
  15623. axis.range = null; // don't use it when running setExtremes
  15624. }
  15625. // Hook for Highstock Scroller. Consider combining with beforePadding.
  15626. fireEvent(axis, 'foundExtremes');
  15627. // Hook for adjusting this.min and this.max. Used by bubble series.
  15628. if (axis.beforePadding) {
  15629. axis.beforePadding();
  15630. }
  15631. // adjust min and max for the minimum range
  15632. axis.adjustForMinRange();
  15633. // Pad the values to get clear of the chart's edges. To avoid
  15634. // tickInterval taking the padding into account, we do this after
  15635. // computing tick interval (#1337).
  15636. if (!categories &&
  15637. !axis.axisPointRange &&
  15638. !(axis.stacking && axis.stacking.usePercentage) &&
  15639. !isLinked &&
  15640. defined(axis.min) &&
  15641. defined(axis.max)) {
  15642. length = axis.max - axis.min;
  15643. if (length) {
  15644. if (!defined(hardMin) && minPadding) {
  15645. axis.min -= length * minPadding;
  15646. }
  15647. if (!defined(hardMax) && maxPadding) {
  15648. axis.max += length * maxPadding;
  15649. }
  15650. }
  15651. }
  15652. // Handle options for floor, ceiling, softMin and softMax (#6359)
  15653. if (!isNumber(axis.userMin)) {
  15654. if (isNumber(options.softMin) && options.softMin < axis.min) {
  15655. axis.min = hardMin = options.softMin; // #6894
  15656. }
  15657. if (isNumber(options.floor)) {
  15658. axis.min = Math.max(axis.min, options.floor);
  15659. }
  15660. }
  15661. if (!isNumber(axis.userMax)) {
  15662. if (isNumber(options.softMax) && options.softMax > axis.max) {
  15663. axis.max = hardMax = options.softMax; // #6894
  15664. }
  15665. if (isNumber(options.ceiling)) {
  15666. axis.max = Math.min(axis.max, options.ceiling);
  15667. }
  15668. }
  15669. // When the threshold is soft, adjust the extreme value only if the data
  15670. // extreme and the padded extreme land on either side of the threshold.
  15671. // For example, a series of [0, 1, 2, 3] would make the yAxis add a tick
  15672. // for -1 because of the default minPadding and startOnTick options.
  15673. // This is prevented by the softThreshold option.
  15674. if (softThreshold && defined(axis.dataMin)) {
  15675. threshold = threshold || 0;
  15676. if (!defined(hardMin) &&
  15677. axis.min < threshold &&
  15678. axis.dataMin >= threshold) {
  15679. axis.min = axis.options.minRange ?
  15680. Math.min(threshold, axis.max -
  15681. axis.minRange) :
  15682. threshold;
  15683. }
  15684. else if (!defined(hardMax) &&
  15685. axis.max > threshold &&
  15686. axis.dataMax <= threshold) {
  15687. axis.max = axis.options.minRange ?
  15688. Math.max(threshold, axis.min +
  15689. axis.minRange) :
  15690. threshold;
  15691. }
  15692. }
  15693. // get tickInterval
  15694. if (axis.min === axis.max ||
  15695. typeof axis.min === 'undefined' ||
  15696. typeof axis.max === 'undefined') {
  15697. axis.tickInterval = 1;
  15698. }
  15699. else if (isLinked &&
  15700. !tickIntervalOption &&
  15701. tickPixelIntervalOption ===
  15702. axis.linkedParent.options.tickPixelInterval) {
  15703. axis.tickInterval = tickIntervalOption =
  15704. axis.linkedParent.tickInterval;
  15705. }
  15706. else {
  15707. axis.tickInterval = pick(tickIntervalOption, this.tickAmount ?
  15708. ((axis.max - axis.min) /
  15709. Math.max(this.tickAmount - 1, 1)) :
  15710. void 0,
  15711. // For categoried axis, 1 is default, for linear axis use
  15712. // tickPix
  15713. categories ?
  15714. 1 :
  15715. // don't let it be more than the data range
  15716. (axis.max - axis.min) *
  15717. tickPixelIntervalOption /
  15718. Math.max(axis.len, tickPixelIntervalOption));
  15719. }
  15720. // Now we're finished detecting min and max, crop and group series data.
  15721. // This is in turn needed in order to find tick positions in ordinal
  15722. // axes.
  15723. if (isXAxis && !secondPass) {
  15724. axis.series.forEach(function (series) {
  15725. series.processData(axis.min !== axis.oldMin || axis.max !== axis.oldMax);
  15726. });
  15727. }
  15728. // set the translation factor used in translate function
  15729. axis.setAxisTranslation(true);
  15730. // hook for ordinal axes and radial axes
  15731. fireEvent(this, 'initialAxisTranslation');
  15732. // In column-like charts, don't cramp in more ticks than there are
  15733. // points (#1943, #4184)
  15734. if (axis.pointRange && !tickIntervalOption) {
  15735. axis.tickInterval = Math.max(axis.pointRange, axis.tickInterval);
  15736. }
  15737. // Before normalizing the tick interval, handle minimum tick interval.
  15738. // This applies only if tickInterval is not defined.
  15739. minTickInterval = pick(options.minTickInterval,
  15740. // In datetime axes, don't go below the data interval, except when
  15741. // there are scatter-like series involved (#13369).
  15742. axis.dateTime &&
  15743. !axis.series.some(function (s) { return s.noSharedTooltip; }) ?
  15744. axis.closestPointRange : 0);
  15745. if (!tickIntervalOption && axis.tickInterval < minTickInterval) {
  15746. axis.tickInterval = minTickInterval;
  15747. }
  15748. // for linear axes, get magnitude and normalize the interval
  15749. if (!axis.dateTime && !axis.logarithmic && !tickIntervalOption) {
  15750. axis.tickInterval = normalizeTickInterval(axis.tickInterval, void 0, getMagnitude(axis.tickInterval), pick(options.allowDecimals,
  15751. // If the tick interval is greather than 0.5, avoid
  15752. // decimals, as linear axes are often used to render
  15753. // discrete values. #3363. If a tick amount is set, allow
  15754. // decimals by default, as it increases the chances for a
  15755. // good fit.
  15756. axis.tickInterval < 0.5 || this.tickAmount !== void 0), !!this.tickAmount);
  15757. }
  15758. // Prevent ticks from getting so close that we can't draw the labels
  15759. if (!this.tickAmount) {
  15760. axis.tickInterval = axis.unsquish();
  15761. }
  15762. this.setTickPositions();
  15763. };
  15764. /**
  15765. * Now we have computed the normalized tickInterval, get the tick positions.
  15766. *
  15767. * @private
  15768. * @function Highcharts.Axis#setTickPositions
  15769. *
  15770. * @fires Highcharts.Axis#event:afterSetTickPositions
  15771. */
  15772. Axis.prototype.setTickPositions = function () {
  15773. var axis = this,
  15774. options = this.options,
  15775. tickPositions,
  15776. tickPositionsOption = options.tickPositions,
  15777. minorTickIntervalOption = this.getMinorTickInterval(),
  15778. tickPositioner = options.tickPositioner,
  15779. hasVerticalPanning = this.hasVerticalPanning(),
  15780. isColorAxis = this.coll === 'colorAxis',
  15781. startOnTick = (isColorAxis || !hasVerticalPanning) && options.startOnTick,
  15782. endOnTick = (isColorAxis || !hasVerticalPanning) && options.endOnTick;
  15783. // Set the tickmarkOffset
  15784. this.tickmarkOffset = (this.categories &&
  15785. options.tickmarkPlacement === 'between' &&
  15786. this.tickInterval === 1) ? 0.5 : 0; // #3202
  15787. // get minorTickInterval
  15788. this.minorTickInterval =
  15789. minorTickIntervalOption === 'auto' &&
  15790. this.tickInterval ?
  15791. this.tickInterval / 5 :
  15792. minorTickIntervalOption;
  15793. // When there is only one point, or all points have the same value on
  15794. // this axis, then min and max are equal and tickPositions.length is 0
  15795. // or 1. In this case, add some padding in order to center the point,
  15796. // but leave it with one tick. #1337.
  15797. this.single =
  15798. this.min === this.max &&
  15799. defined(this.min) &&
  15800. !this.tickAmount &&
  15801. (
  15802. // Data is on integer (#6563)
  15803. parseInt(this.min, 10) === this.min ||
  15804. // Between integers and decimals are not allowed (#6274)
  15805. options.allowDecimals !== false);
  15806. /**
  15807. * Contains the current positions that are laid out on the axis. The
  15808. * positions are numbers in terms of axis values. In a category axis
  15809. * they are integers, in a datetime axis they are also integers, but
  15810. * designating milliseconds.
  15811. *
  15812. * This property is read only - for modifying the tick positions, use
  15813. * the `tickPositioner` callback or [axis.tickPositions(
  15814. * https://api.highcharts.com/highcharts/xAxis.tickPositions) option
  15815. * instead.
  15816. *
  15817. * @name Highcharts.Axis#tickPositions
  15818. * @type {Highcharts.AxisTickPositionsArray|undefined}
  15819. */
  15820. this.tickPositions =
  15821. // Find the tick positions. Work on a copy (#1565)
  15822. tickPositions =
  15823. (tickPositionsOption && tickPositionsOption.slice());
  15824. if (!tickPositions) {
  15825. // Too many ticks (#6405). Create a friendly warning and provide two
  15826. // ticks so at least we can show the data series.
  15827. if ((!axis.ordinal || !axis.ordinal.positions) &&
  15828. ((this.max - this.min) /
  15829. this.tickInterval >
  15830. Math.max(2 * this.len, 200))) {
  15831. tickPositions = [this.min, this.max];
  15832. error(19, false, this.chart);
  15833. }
  15834. else if (axis.dateTime) {
  15835. tickPositions = axis.getTimeTicks(axis.dateTime.normalizeTimeTickInterval(this.tickInterval, options.units), this.min, this.max, options.startOfWeek, axis.ordinal && axis.ordinal.positions, this.closestPointRange, true);
  15836. }
  15837. else if (axis.logarithmic) {
  15838. tickPositions = axis.logarithmic.getLogTickPositions(this.tickInterval, this.min, this.max);
  15839. }
  15840. else {
  15841. tickPositions = this.getLinearTickPositions(this.tickInterval, this.min, this.max);
  15842. }
  15843. // Too dense ticks, keep only the first and last (#4477)
  15844. if (tickPositions.length > this.len) {
  15845. tickPositions = [tickPositions[0], tickPositions.pop()];
  15846. // Reduce doubled value (#7339)
  15847. if (tickPositions[0] === tickPositions[1]) {
  15848. tickPositions.length = 1;
  15849. }
  15850. }
  15851. this.tickPositions = tickPositions;
  15852. // Run the tick positioner callback, that allows modifying auto tick
  15853. // positions.
  15854. if (tickPositioner) {
  15855. tickPositioner = tickPositioner.apply(axis, [this.min, this.max]);
  15856. if (tickPositioner) {
  15857. this.tickPositions = tickPositions = tickPositioner;
  15858. }
  15859. }
  15860. }
  15861. // Reset min/max or remove extremes based on start/end on tick
  15862. this.paddedTicks = tickPositions.slice(0); // Used for logarithmic minor
  15863. this.trimTicks(tickPositions, startOnTick, endOnTick);
  15864. if (!this.isLinked) {
  15865. // Substract half a unit (#2619, #2846, #2515, #3390),
  15866. // but not in case of multiple ticks (#6897)
  15867. if (this.single &&
  15868. tickPositions.length < 2 &&
  15869. !this.categories &&
  15870. !this.series.some(function (s) {
  15871. return (s.is('heatmap') && s.options.pointPlacement === 'between');
  15872. })) {
  15873. this.min -= 0.5;
  15874. this.max += 0.5;
  15875. }
  15876. if (!tickPositionsOption && !tickPositioner) {
  15877. this.adjustTickAmount();
  15878. }
  15879. }
  15880. fireEvent(this, 'afterSetTickPositions');
  15881. };
  15882. /**
  15883. * Handle startOnTick and endOnTick by either adapting to padding min/max or
  15884. * rounded min/max. Also handle single data points.
  15885. *
  15886. * @private
  15887. * @function Highcharts.Axis#trimTicks
  15888. *
  15889. * @param {Array<number>} tickPositions
  15890. * TO-DO: parameter description
  15891. *
  15892. * @param {boolean} [startOnTick]
  15893. * TO-DO: parameter description
  15894. *
  15895. * @param {boolean} [endOnTick]
  15896. * TO-DO: parameter description
  15897. */
  15898. Axis.prototype.trimTicks = function (tickPositions, startOnTick, endOnTick) {
  15899. var roundedMin = tickPositions[0],
  15900. roundedMax = tickPositions[tickPositions.length - 1],
  15901. minPointOffset = (!this.isOrdinal && this.minPointOffset) || 0; // (#12716)
  15902. fireEvent(this, 'trimTicks');
  15903. if (!this.isLinked) {
  15904. if (startOnTick && roundedMin !== -Infinity) { // #6502
  15905. this.min = roundedMin;
  15906. }
  15907. else {
  15908. while (this.min - minPointOffset > tickPositions[0]) {
  15909. tickPositions.shift();
  15910. }
  15911. }
  15912. if (endOnTick) {
  15913. this.max = roundedMax;
  15914. }
  15915. else {
  15916. while (this.max + minPointOffset <
  15917. tickPositions[tickPositions.length - 1]) {
  15918. tickPositions.pop();
  15919. }
  15920. }
  15921. // If no tick are left, set one tick in the middle (#3195)
  15922. if (tickPositions.length === 0 &&
  15923. defined(roundedMin) &&
  15924. !this.options.tickPositions) {
  15925. tickPositions.push((roundedMax + roundedMin) / 2);
  15926. }
  15927. }
  15928. };
  15929. /**
  15930. * Check if there are multiple axes in the same pane.
  15931. *
  15932. * @private
  15933. * @function Highcharts.Axis#alignToOthers
  15934. *
  15935. * @return {boolean|undefined}
  15936. * True if there are other axes.
  15937. */
  15938. Axis.prototype.alignToOthers = function () {
  15939. var axis = this,
  15940. others = // Whether there is another axis to pair with this one
  15941. {},
  15942. hasOther,
  15943. options = axis.options;
  15944. if (
  15945. // Only if alignTicks is true
  15946. this.chart.options.chart.alignTicks !== false &&
  15947. options.alignTicks !== false &&
  15948. // Disabled when startOnTick or endOnTick are false (#7604)
  15949. options.startOnTick !== false &&
  15950. options.endOnTick !== false &&
  15951. // Don't try to align ticks on a log axis, they are not evenly
  15952. // spaced (#6021)
  15953. !axis.logarithmic) {
  15954. this.chart[this.coll].forEach(function (axis) {
  15955. var otherOptions = axis.options, horiz = axis.horiz, key = [
  15956. horiz ? otherOptions.left : otherOptions.top,
  15957. otherOptions.width,
  15958. otherOptions.height,
  15959. otherOptions.pane
  15960. ].join(',');
  15961. if (axis.series.length) { // #4442
  15962. if (others[key]) {
  15963. hasOther = true; // #4201
  15964. }
  15965. else {
  15966. others[key] = 1;
  15967. }
  15968. }
  15969. });
  15970. }
  15971. return hasOther;
  15972. };
  15973. /**
  15974. * Find the max ticks of either the x and y axis collection, and record it
  15975. * in `this.tickAmount`.
  15976. *
  15977. * @private
  15978. * @function Highcharts.Axis#getTickAmount
  15979. */
  15980. Axis.prototype.getTickAmount = function () {
  15981. var axis = this,
  15982. options = this.options,
  15983. tickAmount = options.tickAmount,
  15984. tickPixelInterval = options.tickPixelInterval;
  15985. if (!defined(options.tickInterval) &&
  15986. !tickAmount && this.len < tickPixelInterval &&
  15987. !this.isRadial &&
  15988. !axis.logarithmic &&
  15989. options.startOnTick &&
  15990. options.endOnTick) {
  15991. tickAmount = 2;
  15992. }
  15993. if (!tickAmount && this.alignToOthers()) {
  15994. // Add 1 because 4 tick intervals require 5 ticks (including first
  15995. // and last)
  15996. tickAmount = Math.ceil(this.len / tickPixelInterval) + 1;
  15997. }
  15998. // For tick amounts of 2 and 3, compute five ticks and remove the
  15999. // intermediate ones. This prevents the axis from adding ticks that are
  16000. // too far away from the data extremes.
  16001. if (tickAmount < 4) {
  16002. this.finalTickAmt = tickAmount;
  16003. tickAmount = 5;
  16004. }
  16005. this.tickAmount = tickAmount;
  16006. };
  16007. /**
  16008. * When using multiple axes, adjust the number of ticks to match the highest
  16009. * number of ticks in that group.
  16010. *
  16011. * @private
  16012. * @function Highcharts.Axis#adjustTickAmount
  16013. */
  16014. Axis.prototype.adjustTickAmount = function () {
  16015. var axis = this,
  16016. axisOptions = axis.options,
  16017. tickInterval = axis.tickInterval,
  16018. tickPositions = axis.tickPositions,
  16019. tickAmount = axis.tickAmount,
  16020. finalTickAmt = axis.finalTickAmt,
  16021. currentTickAmount = tickPositions && tickPositions.length,
  16022. threshold = pick(axis.threshold,
  16023. axis.softThreshold ? 0 : null),
  16024. min,
  16025. len,
  16026. i;
  16027. if (axis.hasData()) {
  16028. if (currentTickAmount < tickAmount) {
  16029. min = axis.min;
  16030. while (tickPositions.length < tickAmount) {
  16031. // Extend evenly for both sides unless we're on the
  16032. // threshold (#3965)
  16033. if (tickPositions.length % 2 ||
  16034. min === threshold) {
  16035. // to the end
  16036. tickPositions.push(correctFloat(tickPositions[tickPositions.length - 1] +
  16037. tickInterval));
  16038. }
  16039. else {
  16040. // to the start
  16041. tickPositions.unshift(correctFloat(tickPositions[0] - tickInterval));
  16042. }
  16043. }
  16044. axis.transA *= (currentTickAmount - 1) / (tickAmount - 1);
  16045. // Do not crop when ticks are not extremes (#9841)
  16046. axis.min = axisOptions.startOnTick ?
  16047. tickPositions[0] :
  16048. Math.min(axis.min, tickPositions[0]);
  16049. axis.max = axisOptions.endOnTick ?
  16050. tickPositions[tickPositions.length - 1] :
  16051. Math.max(axis.max, tickPositions[tickPositions.length - 1]);
  16052. // We have too many ticks, run second pass to try to reduce ticks
  16053. }
  16054. else if (currentTickAmount > tickAmount) {
  16055. axis.tickInterval *= 2;
  16056. axis.setTickPositions();
  16057. }
  16058. // The finalTickAmt property is set in getTickAmount
  16059. if (defined(finalTickAmt)) {
  16060. i = len = tickPositions.length;
  16061. while (i--) {
  16062. if (
  16063. // Remove every other tick
  16064. (finalTickAmt === 3 && i % 2 === 1) ||
  16065. // Remove all but first and last
  16066. (finalTickAmt <= 2 && i > 0 && i < len - 1)) {
  16067. tickPositions.splice(i, 1);
  16068. }
  16069. }
  16070. axis.finalTickAmt = void 0;
  16071. }
  16072. }
  16073. };
  16074. /**
  16075. * Set the scale based on data min and max, user set min and max or options.
  16076. *
  16077. * @private
  16078. * @function Highcharts.Axis#setScale
  16079. *
  16080. * @fires Highcharts.Axis#event:afterSetScale
  16081. */
  16082. Axis.prototype.setScale = function () {
  16083. var axis = this,
  16084. isDirtyAxisLength,
  16085. isDirtyData = false,
  16086. isXAxisDirty = false;
  16087. axis.series.forEach(function (series) {
  16088. var _a;
  16089. isDirtyData = isDirtyData || series.isDirtyData || series.isDirty;
  16090. // When x axis is dirty, we need new data extremes for y as
  16091. // well:
  16092. isXAxisDirty = isXAxisDirty || ((_a = series.xAxis) === null || _a === void 0 ? void 0 : _a.isDirty) || false;
  16093. });
  16094. axis.oldMin = axis.min;
  16095. axis.oldMax = axis.max;
  16096. axis.oldAxisLength = axis.len;
  16097. // set the new axisLength
  16098. axis.setAxisSize();
  16099. isDirtyAxisLength = axis.len !== axis.oldAxisLength;
  16100. // do we really need to go through all this?
  16101. if (isDirtyAxisLength ||
  16102. isDirtyData ||
  16103. isXAxisDirty ||
  16104. axis.isLinked ||
  16105. axis.forceRedraw ||
  16106. axis.userMin !== axis.oldUserMin ||
  16107. axis.userMax !== axis.oldUserMax ||
  16108. axis.alignToOthers()) {
  16109. if (axis.stacking) {
  16110. axis.stacking.resetStacks();
  16111. }
  16112. axis.forceRedraw = false;
  16113. // get data extremes if needed
  16114. axis.getSeriesExtremes();
  16115. // get fixed positions based on tickInterval
  16116. axis.setTickInterval();
  16117. // record old values to decide whether a rescale is necessary later
  16118. // on (#540)
  16119. axis.oldUserMin = axis.userMin;
  16120. axis.oldUserMax = axis.userMax;
  16121. // Mark as dirty if it is not already set to dirty and extremes have
  16122. // changed. #595.
  16123. if (!axis.isDirty) {
  16124. axis.isDirty =
  16125. isDirtyAxisLength ||
  16126. axis.min !== axis.oldMin ||
  16127. axis.max !== axis.oldMax;
  16128. }
  16129. }
  16130. else if (axis.stacking) {
  16131. axis.stacking.cleanStacks();
  16132. }
  16133. // Recalculate panning state object, when the data
  16134. // has changed. It is required when vertical panning is enabled.
  16135. if (isDirtyData && axis.panningState) {
  16136. axis.panningState.isDirty = true;
  16137. }
  16138. fireEvent(this, 'afterSetScale');
  16139. };
  16140. /**
  16141. * Set the minimum and maximum of the axes after render time. If the
  16142. * `startOnTick` and `endOnTick` options are true, the minimum and maximum
  16143. * values are rounded off to the nearest tick. To prevent this, these
  16144. * options can be set to false before calling setExtremes. Also, setExtremes
  16145. * will not allow a range lower than the `minRange` option, which by default
  16146. * is the range of five points.
  16147. *
  16148. * @sample highcharts/members/axis-setextremes/
  16149. * Set extremes from a button
  16150. * @sample highcharts/members/axis-setextremes-datetime/
  16151. * Set extremes on a datetime axis
  16152. * @sample highcharts/members/axis-setextremes-off-ticks/
  16153. * Set extremes off ticks
  16154. * @sample stock/members/axis-setextremes/
  16155. * Set extremes in Highstock
  16156. * @sample maps/members/axis-setextremes/
  16157. * Set extremes in Highmaps
  16158. *
  16159. * @function Highcharts.Axis#setExtremes
  16160. *
  16161. * @param {number} [newMin]
  16162. * The new minimum value.
  16163. *
  16164. * @param {number} [newMax]
  16165. * The new maximum value.
  16166. *
  16167. * @param {boolean} [redraw=true]
  16168. * Whether to redraw the chart or wait for an explicit call to
  16169. * {@link Highcharts.Chart#redraw}
  16170. *
  16171. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  16172. * Enable or modify animations.
  16173. *
  16174. * @param {*} [eventArguments]
  16175. * Arguments to be accessed in event handler.
  16176. *
  16177. * @fires Highcharts.Axis#event:setExtremes
  16178. */
  16179. Axis.prototype.setExtremes = function (newMin, newMax, redraw, animation, eventArguments) {
  16180. var axis = this,
  16181. chart = axis.chart;
  16182. redraw = pick(redraw, true); // defaults to true
  16183. axis.series.forEach(function (serie) {
  16184. delete serie.kdTree;
  16185. });
  16186. // Extend the arguments with min and max
  16187. eventArguments = extend(eventArguments, {
  16188. min: newMin,
  16189. max: newMax
  16190. });
  16191. // Fire the event
  16192. fireEvent(axis, 'setExtremes', eventArguments, function () {
  16193. axis.userMin = newMin;
  16194. axis.userMax = newMax;
  16195. axis.eventArgs = eventArguments;
  16196. if (redraw) {
  16197. chart.redraw(animation);
  16198. }
  16199. });
  16200. };
  16201. /**
  16202. * Overridable method for zooming chart. Pulled out in a separate method to
  16203. * allow overriding in stock charts.
  16204. * @private
  16205. * @function Highcharts.Axis#zoom
  16206. *
  16207. * @param {number} newMin
  16208. * TO-DO: parameter description
  16209. *
  16210. * @param {number} newMax
  16211. * TO-DO: parameter description
  16212. *
  16213. * @return {boolean}
  16214. */
  16215. Axis.prototype.zoom = function (newMin, newMax) {
  16216. var axis = this,
  16217. dataMin = this.dataMin,
  16218. dataMax = this.dataMax,
  16219. options = this.options,
  16220. min = Math.min(dataMin,
  16221. pick(options.min,
  16222. dataMin)),
  16223. max = Math.max(dataMax,
  16224. pick(options.max,
  16225. dataMax)),
  16226. evt = {
  16227. newMin: newMin,
  16228. newMax: newMax
  16229. };
  16230. fireEvent(this, 'zoom', evt, function (e) {
  16231. // Use e.newMin and e.newMax - event handlers may have altered them
  16232. var newMin = e.newMin,
  16233. newMax = e.newMax;
  16234. if (newMin !== axis.min || newMax !== axis.max) { // #5790
  16235. // Prevent pinch zooming out of range. Check for defined is for
  16236. // #1946. #1734.
  16237. if (!axis.allowZoomOutside) {
  16238. // #6014, sometimes newMax will be smaller than min (or
  16239. // newMin will be larger than max).
  16240. if (defined(dataMin)) {
  16241. if (newMin < min) {
  16242. newMin = min;
  16243. }
  16244. if (newMin > max) {
  16245. newMin = max;
  16246. }
  16247. }
  16248. if (defined(dataMax)) {
  16249. if (newMax < min) {
  16250. newMax = min;
  16251. }
  16252. if (newMax > max) {
  16253. newMax = max;
  16254. }
  16255. }
  16256. }
  16257. // In full view, displaying the reset zoom button is not
  16258. // required
  16259. axis.displayBtn = (typeof newMin !== 'undefined' ||
  16260. typeof newMax !== 'undefined');
  16261. // Do it
  16262. axis.setExtremes(newMin, newMax, false, void 0, { trigger: 'zoom' });
  16263. }
  16264. e.zoomed = true;
  16265. });
  16266. return evt.zoomed;
  16267. };
  16268. /**
  16269. * Update the axis metrics.
  16270. *
  16271. * @private
  16272. * @function Highcharts.Axis#setAxisSize
  16273. */
  16274. Axis.prototype.setAxisSize = function () {
  16275. var chart = this.chart,
  16276. options = this.options,
  16277. // [top, right, bottom, left]
  16278. offsets = options.offsets || [0, 0, 0, 0],
  16279. horiz = this.horiz,
  16280. // Check for percentage based input values. Rounding fixes problems
  16281. // with column overflow and plot line filtering (#4898, #4899)
  16282. width = this.width = Math.round(relativeLength(pick(options.width,
  16283. chart.plotWidth - offsets[3] + offsets[1]),
  16284. chart.plotWidth)),
  16285. height = this.height = Math.round(relativeLength(pick(options.height,
  16286. chart.plotHeight - offsets[0] + offsets[2]),
  16287. chart.plotHeight)),
  16288. top = this.top = Math.round(relativeLength(pick(options.top,
  16289. chart.plotTop + offsets[0]),
  16290. chart.plotHeight,
  16291. chart.plotTop)),
  16292. left = this.left = Math.round(relativeLength(pick(options.left,
  16293. chart.plotLeft + offsets[3]),
  16294. chart.plotWidth,
  16295. chart.plotLeft));
  16296. // Expose basic values to use in Series object and navigator
  16297. this.bottom = chart.chartHeight - height - top;
  16298. this.right = chart.chartWidth - width - left;
  16299. // Direction agnostic properties
  16300. this.len = Math.max(horiz ? width : height, 0); // Math.max fixes #905
  16301. this.pos = horiz ? left : top; // distance from SVG origin
  16302. };
  16303. /**
  16304. * Get the current extremes for the axis.
  16305. *
  16306. * @sample highcharts/members/axis-getextremes/
  16307. * Report extremes by click on a button
  16308. * @sample maps/members/axis-getextremes/
  16309. * Get extremes in Highmaps
  16310. *
  16311. * @function Highcharts.Axis#getExtremes
  16312. *
  16313. * @return {Highcharts.ExtremesObject}
  16314. * An object containing extremes information.
  16315. */
  16316. Axis.prototype.getExtremes = function () {
  16317. var axis = this;
  16318. var log = axis.logarithmic;
  16319. return {
  16320. min: log ?
  16321. correctFloat(log.lin2log(axis.min)) :
  16322. axis.min,
  16323. max: log ?
  16324. correctFloat(log.lin2log(axis.max)) :
  16325. axis.max,
  16326. dataMin: axis.dataMin,
  16327. dataMax: axis.dataMax,
  16328. userMin: axis.userMin,
  16329. userMax: axis.userMax
  16330. };
  16331. };
  16332. /**
  16333. * Get the zero plane either based on zero or on the min or max value.
  16334. * Used in bar and area plots.
  16335. *
  16336. * @function Highcharts.Axis#getThreshold
  16337. *
  16338. * @param {number} threshold
  16339. * The threshold in axis values.
  16340. *
  16341. * @return {number|undefined}
  16342. * The translated threshold position in terms of pixels, and corrected to
  16343. * stay within the axis bounds.
  16344. */
  16345. Axis.prototype.getThreshold = function (threshold) {
  16346. var axis = this,
  16347. log = axis.logarithmic,
  16348. realMin = log ? log.lin2log(axis.min) : axis.min,
  16349. realMax = log ? log.lin2log(axis.max) : axis.max;
  16350. if (threshold === null || threshold === -Infinity) {
  16351. threshold = realMin;
  16352. }
  16353. else if (threshold === Infinity) {
  16354. threshold = realMax;
  16355. }
  16356. else if (realMin > threshold) {
  16357. threshold = realMin;
  16358. }
  16359. else if (realMax < threshold) {
  16360. threshold = realMax;
  16361. }
  16362. return axis.translate(threshold, 0, 1, 0, 1);
  16363. };
  16364. /**
  16365. * Compute auto alignment for the axis label based on which side the axis is
  16366. * on and the given rotation for the label.
  16367. *
  16368. * @private
  16369. * @function Highcharts.Axis#autoLabelAlign
  16370. *
  16371. * @param {number} rotation
  16372. * The rotation in degrees as set by either the `rotation` or `autoRotation`
  16373. * options.
  16374. *
  16375. * @return {Highcharts.AlignValue}
  16376. * Can be `"center"`, `"left"` or `"right"`.
  16377. */
  16378. Axis.prototype.autoLabelAlign = function (rotation) {
  16379. var angle = (pick(rotation, 0) - (this.side * 90) + 720) % 360,
  16380. evt = { align: 'center' };
  16381. fireEvent(this, 'autoLabelAlign', evt, function (e) {
  16382. if (angle > 15 && angle < 165) {
  16383. e.align = 'right';
  16384. }
  16385. else if (angle > 195 && angle < 345) {
  16386. e.align = 'left';
  16387. }
  16388. });
  16389. return evt.align;
  16390. };
  16391. /**
  16392. * Get the tick length and width for the axis based on axis options.
  16393. * @private
  16394. * @function Highcharts.Axis#tickSize
  16395. *
  16396. * @param {string} [prefix]
  16397. * 'tick' or 'minorTick'
  16398. *
  16399. * @return {Array<number,number>|undefined}
  16400. * An array of tickLength and tickWidth
  16401. */
  16402. Axis.prototype.tickSize = function (prefix) {
  16403. var options = this.options, tickLength = options[prefix === 'tick' ? 'tickLength' : 'minorTickLength'], tickWidth = pick(options[prefix === 'tick' ? 'tickWidth' : 'minorTickWidth'],
  16404. // Default to 1 on linear and datetime X axes
  16405. prefix === 'tick' && this.isXAxis && !this.categories ? 1 : 0), e, tickSize;
  16406. if (tickWidth && tickLength) {
  16407. // Negate the length
  16408. if (options[prefix + 'Position'] === 'inside') {
  16409. tickLength = -tickLength;
  16410. }
  16411. tickSize = [tickLength, tickWidth];
  16412. }
  16413. e = { tickSize: tickSize };
  16414. fireEvent(this, 'afterTickSize', e);
  16415. return e.tickSize;
  16416. };
  16417. /**
  16418. * Return the size of the labels.
  16419. *
  16420. * @private
  16421. * @function Highcharts.Axis#labelMetrics
  16422. *
  16423. * @return {Highcharts.FontMetricsObject}
  16424. */
  16425. Axis.prototype.labelMetrics = function () {
  16426. var index = this.tickPositions && this.tickPositions[0] || 0;
  16427. return this.chart.renderer.fontMetrics(this.options.labels.style &&
  16428. this.options.labels.style.fontSize, this.ticks[index] && this.ticks[index].label);
  16429. };
  16430. /**
  16431. * Prevent the ticks from getting so close we can't draw the labels. On a
  16432. * horizontal axis, this is handled by rotating the labels, removing ticks
  16433. * and adding ellipsis. On a vertical axis remove ticks and add ellipsis.
  16434. *
  16435. * @private
  16436. * @function Highcharts.Axis#unsquish
  16437. *
  16438. * @return {number}
  16439. */
  16440. Axis.prototype.unsquish = function () {
  16441. var labelOptions = this.options.labels,
  16442. horiz = this.horiz,
  16443. tickInterval = this.tickInterval,
  16444. newTickInterval = tickInterval,
  16445. slotSize = this.len / (((this.categories ? 1 : 0) +
  16446. this.max -
  16447. this.min) /
  16448. tickInterval),
  16449. rotation,
  16450. rotationOption = labelOptions.rotation,
  16451. labelMetrics = this.labelMetrics(),
  16452. step,
  16453. bestScore = Number.MAX_VALUE,
  16454. autoRotation,
  16455. range = this.max - this.min,
  16456. // Return the multiple of tickInterval that is needed to avoid
  16457. // collision
  16458. getStep = function (spaceNeeded) {
  16459. var step = spaceNeeded / (slotSize || 1);
  16460. step = step > 1 ? Math.ceil(step) : 1;
  16461. // Guard for very small or negative angles (#9835)
  16462. if (step * tickInterval > range &&
  16463. spaceNeeded !== Infinity &&
  16464. slotSize !== Infinity &&
  16465. range) {
  16466. step = Math.ceil(range / tickInterval);
  16467. }
  16468. return correctFloat(step * tickInterval);
  16469. };
  16470. if (horiz) {
  16471. autoRotation = !labelOptions.staggerLines &&
  16472. !labelOptions.step &&
  16473. ( // #3971
  16474. defined(rotationOption) ?
  16475. [rotationOption] :
  16476. slotSize < pick(labelOptions.autoRotationLimit, 80) && labelOptions.autoRotation);
  16477. if (autoRotation) {
  16478. // Loop over the given autoRotation options, and determine
  16479. // which gives the best score. The best score is that with
  16480. // the lowest number of steps and a rotation closest
  16481. // to horizontal.
  16482. autoRotation.forEach(function (rot) {
  16483. var score;
  16484. if (rot === rotationOption ||
  16485. (rot && rot >= -90 && rot <= 90)) { // #3891
  16486. step = getStep(Math.abs(labelMetrics.h / Math.sin(deg2rad * rot)));
  16487. score = step + Math.abs(rot / 360);
  16488. if (score < bestScore) {
  16489. bestScore = score;
  16490. rotation = rot;
  16491. newTickInterval = step;
  16492. }
  16493. }
  16494. });
  16495. }
  16496. }
  16497. else if (!labelOptions.step) { // #4411
  16498. newTickInterval = getStep(labelMetrics.h);
  16499. }
  16500. this.autoRotation = autoRotation;
  16501. this.labelRotation = pick(rotation, rotationOption);
  16502. return newTickInterval;
  16503. };
  16504. /**
  16505. * Get the general slot width for labels/categories on this axis. This may
  16506. * change between the pre-render (from Axis.getOffset) and the final tick
  16507. * rendering and placement.
  16508. *
  16509. * @private
  16510. * @function Highcharts.Axis#getSlotWidth
  16511. *
  16512. * @param {Highcharts.Tick} [tick] Optionally, calculate the slot width
  16513. * basing on tick label. It is used in highcharts-3d module, where the slots
  16514. * has different widths depending on perspective angles.
  16515. *
  16516. * @return {number}
  16517. * The pixel width allocated to each axis label.
  16518. */
  16519. Axis.prototype.getSlotWidth = function (tick) {
  16520. var _a;
  16521. // #5086, #1580, #1931
  16522. var chart = this.chart,
  16523. horiz = this.horiz,
  16524. labelOptions = this.options.labels,
  16525. slotCount = Math.max(this.tickPositions.length - (this.categories ? 0 : 1), 1),
  16526. marginLeft = chart.margin[3];
  16527. // Used by grid axis
  16528. if (tick && isNumber(tick.slotWidth)) { // #13221, can be 0
  16529. return tick.slotWidth;
  16530. }
  16531. if (horiz &&
  16532. labelOptions &&
  16533. (labelOptions.step || 0) < 2) {
  16534. if (labelOptions.rotation) { // #4415
  16535. return 0;
  16536. }
  16537. return ((this.staggerLines || 1) * this.len) / slotCount;
  16538. }
  16539. if (!horiz) {
  16540. // #7028
  16541. var cssWidth = (_a = labelOptions === null || labelOptions === void 0 ? void 0 : labelOptions.style) === null || _a === void 0 ? void 0 : _a.width;
  16542. if (cssWidth !== void 0) {
  16543. return parseInt(cssWidth, 10);
  16544. }
  16545. if (marginLeft) {
  16546. return marginLeft - chart.spacing[3];
  16547. }
  16548. }
  16549. // Last resort, a fraction of the available size
  16550. return chart.chartWidth * 0.33;
  16551. };
  16552. /**
  16553. * Render the axis labels and determine whether ellipsis or rotation need to
  16554. * be applied.
  16555. *
  16556. * @private
  16557. * @function Highcharts.Axis#renderUnsquish
  16558. */
  16559. Axis.prototype.renderUnsquish = function () {
  16560. var chart = this.chart,
  16561. renderer = chart.renderer,
  16562. tickPositions = this.tickPositions,
  16563. ticks = this.ticks,
  16564. labelOptions = this.options.labels,
  16565. labelStyleOptions = (labelOptions && labelOptions.style || {}),
  16566. horiz = this.horiz,
  16567. slotWidth = this.getSlotWidth(),
  16568. innerWidth = Math.max(1,
  16569. Math.round(slotWidth - 2 * (labelOptions.padding || 5))),
  16570. attr = {},
  16571. labelMetrics = this.labelMetrics(),
  16572. textOverflowOption = (labelOptions.style &&
  16573. labelOptions.style.textOverflow),
  16574. commonWidth,
  16575. commonTextOverflow,
  16576. maxLabelLength = 0,
  16577. label,
  16578. i,
  16579. pos;
  16580. // Set rotation option unless it is "auto", like in gauges
  16581. if (!isString(labelOptions.rotation)) {
  16582. // #4443:
  16583. attr.rotation = labelOptions.rotation || 0;
  16584. }
  16585. // Get the longest label length
  16586. tickPositions.forEach(function (tick) {
  16587. tick = ticks[tick];
  16588. // Replace label - sorting animation
  16589. if (tick.movedLabel) {
  16590. tick.replaceMovedLabel();
  16591. }
  16592. if (tick &&
  16593. tick.label &&
  16594. tick.label.textPxLength > maxLabelLength) {
  16595. maxLabelLength = tick.label.textPxLength;
  16596. }
  16597. });
  16598. this.maxLabelLength = maxLabelLength;
  16599. // Handle auto rotation on horizontal axis
  16600. if (this.autoRotation) {
  16601. // Apply rotation only if the label is too wide for the slot, and
  16602. // the label is wider than its height.
  16603. if (maxLabelLength > innerWidth &&
  16604. maxLabelLength > labelMetrics.h) {
  16605. attr.rotation = this.labelRotation;
  16606. }
  16607. else {
  16608. this.labelRotation = 0;
  16609. }
  16610. // Handle word-wrap or ellipsis on vertical axis
  16611. }
  16612. else if (slotWidth) {
  16613. // For word-wrap or ellipsis
  16614. commonWidth = innerWidth;
  16615. if (!textOverflowOption) {
  16616. commonTextOverflow = 'clip';
  16617. // On vertical axis, only allow word wrap if there is room
  16618. // for more lines.
  16619. i = tickPositions.length;
  16620. while (!horiz && i--) {
  16621. pos = tickPositions[i];
  16622. label = ticks[pos].label;
  16623. if (label) {
  16624. // Reset ellipsis in order to get the correct
  16625. // bounding box (#4070)
  16626. if (label.styles &&
  16627. label.styles.textOverflow === 'ellipsis') {
  16628. label.css({ textOverflow: 'clip' });
  16629. // Set the correct width in order to read
  16630. // the bounding box height (#4678, #5034)
  16631. }
  16632. else if (label.textPxLength > slotWidth) {
  16633. label.css({ width: slotWidth + 'px' });
  16634. }
  16635. if (label.getBBox().height > (this.len / tickPositions.length -
  16636. (labelMetrics.h - labelMetrics.f))) {
  16637. label.specificTextOverflow = 'ellipsis';
  16638. }
  16639. }
  16640. }
  16641. }
  16642. }
  16643. // Add ellipsis if the label length is significantly longer than ideal
  16644. if (attr.rotation) {
  16645. commonWidth = (maxLabelLength > chart.chartHeight * 0.5 ?
  16646. chart.chartHeight * 0.33 :
  16647. maxLabelLength);
  16648. if (!textOverflowOption) {
  16649. commonTextOverflow = 'ellipsis';
  16650. }
  16651. }
  16652. // Set the explicit or automatic label alignment
  16653. this.labelAlign = labelOptions.align ||
  16654. this.autoLabelAlign(this.labelRotation);
  16655. if (this.labelAlign) {
  16656. attr.align = this.labelAlign;
  16657. }
  16658. // Apply general and specific CSS
  16659. tickPositions.forEach(function (pos) {
  16660. var tick = ticks[pos],
  16661. label = tick && tick.label,
  16662. widthOption = labelStyleOptions.width,
  16663. css = {};
  16664. if (label) {
  16665. // This needs to go before the CSS in old IE (#4502)
  16666. label.attr(attr);
  16667. if (tick.shortenLabel) {
  16668. tick.shortenLabel();
  16669. }
  16670. else if (commonWidth &&
  16671. !widthOption &&
  16672. // Setting width in this case messes with the bounding box
  16673. // (#7975)
  16674. labelStyleOptions.whiteSpace !== 'nowrap' &&
  16675. (
  16676. // Speed optimizing, #7656
  16677. commonWidth < label.textPxLength ||
  16678. // Resetting CSS, #4928
  16679. label.element.tagName === 'SPAN')) {
  16680. css.width = commonWidth + 'px';
  16681. if (!textOverflowOption) {
  16682. css.textOverflow = (label.specificTextOverflow ||
  16683. commonTextOverflow);
  16684. }
  16685. label.css(css);
  16686. // Reset previously shortened label (#8210)
  16687. }
  16688. else if (label.styles &&
  16689. label.styles.width &&
  16690. !css.width &&
  16691. !widthOption) {
  16692. label.css({ width: null });
  16693. }
  16694. delete label.specificTextOverflow;
  16695. tick.rotation = attr.rotation;
  16696. }
  16697. }, this);
  16698. // Note: Why is this not part of getLabelPosition?
  16699. this.tickRotCorr = renderer.rotCorr(labelMetrics.b, this.labelRotation || 0, this.side !== 0);
  16700. };
  16701. /**
  16702. * Return true if the axis has associated data.
  16703. *
  16704. * @function Highcharts.Axis#hasData
  16705. *
  16706. * @return {boolean}
  16707. * True if the axis has associated visible series and those series have
  16708. * either valid data points or explicit `min` and `max` settings.
  16709. */
  16710. Axis.prototype.hasData = function () {
  16711. return this.series.some(function (s) {
  16712. return s.hasData();
  16713. }) ||
  16714. (this.options.showEmpty &&
  16715. defined(this.min) &&
  16716. defined(this.max));
  16717. };
  16718. /**
  16719. * Adds the title defined in axis.options.title.
  16720. *
  16721. * @function Highcharts.Axis#addTitle
  16722. *
  16723. * @param {boolean} [display]
  16724. * Whether or not to display the title.
  16725. */
  16726. Axis.prototype.addTitle = function (display) {
  16727. var axis = this,
  16728. renderer = axis.chart.renderer,
  16729. horiz = axis.horiz,
  16730. opposite = axis.opposite,
  16731. options = axis.options,
  16732. axisTitleOptions = options.title,
  16733. textAlign,
  16734. styledMode = axis.chart.styledMode;
  16735. if (!axis.axisTitle) {
  16736. textAlign = axisTitleOptions.textAlign;
  16737. if (!textAlign) {
  16738. textAlign = (horiz ? {
  16739. low: 'left',
  16740. middle: 'center',
  16741. high: 'right'
  16742. } : {
  16743. low: opposite ? 'right' : 'left',
  16744. middle: 'center',
  16745. high: opposite ? 'left' : 'right'
  16746. })[axisTitleOptions.align];
  16747. }
  16748. axis.axisTitle = renderer
  16749. .text(axisTitleOptions.text, 0, 0, axisTitleOptions.useHTML)
  16750. .attr({
  16751. zIndex: 7,
  16752. rotation: axisTitleOptions.rotation || 0,
  16753. align: textAlign
  16754. })
  16755. .addClass('highcharts-axis-title');
  16756. // #7814, don't mutate style option
  16757. if (!styledMode) {
  16758. axis.axisTitle.css(merge(axisTitleOptions.style));
  16759. }
  16760. axis.axisTitle.add(axis.axisGroup);
  16761. axis.axisTitle.isNew = true;
  16762. }
  16763. // Max width defaults to the length of the axis
  16764. if (!styledMode &&
  16765. !axisTitleOptions.style.width &&
  16766. !axis.isRadial) {
  16767. axis.axisTitle.css({
  16768. width: axis.len + 'px'
  16769. });
  16770. }
  16771. // hide or show the title depending on whether showEmpty is set
  16772. axis.axisTitle[display ? 'show' : 'hide'](display);
  16773. };
  16774. /**
  16775. * Generates a tick for initial positioning.
  16776. *
  16777. * @private
  16778. * @function Highcharts.Axis#generateTick
  16779. *
  16780. * @param {number} pos
  16781. * The tick position in axis values.
  16782. *
  16783. * @param {number} [i]
  16784. * The index of the tick in {@link Axis.tickPositions}.
  16785. */
  16786. Axis.prototype.generateTick = function (pos) {
  16787. var axis = this;
  16788. var ticks = axis.ticks;
  16789. if (!ticks[pos]) {
  16790. ticks[pos] = new Tick(axis, pos);
  16791. }
  16792. else {
  16793. ticks[pos].addLabel(); // update labels depending on tick interval
  16794. }
  16795. };
  16796. /**
  16797. * Render the tick labels to a preliminary position to get their sizes
  16798. *
  16799. * @private
  16800. * @function Highcharts.Axis#getOffset
  16801. *
  16802. * @fires Highcharts.Axis#event:afterGetOffset
  16803. */
  16804. Axis.prototype.getOffset = function () {
  16805. var axis = this,
  16806. chart = axis.chart,
  16807. renderer = chart.renderer,
  16808. options = axis.options,
  16809. tickPositions = axis.tickPositions,
  16810. ticks = axis.ticks,
  16811. horiz = axis.horiz,
  16812. side = axis.side,
  16813. invertedSide = chart.inverted &&
  16814. !axis.isZAxis ? [1, 0, 3, 2][side] : side,
  16815. hasData,
  16816. showAxis,
  16817. titleOffset = 0,
  16818. titleOffsetOption,
  16819. titleMargin = 0,
  16820. axisTitleOptions = options.title,
  16821. labelOptions = options.labels,
  16822. labelOffset = 0, // reset
  16823. labelOffsetPadded,
  16824. axisOffset = chart.axisOffset,
  16825. clipOffset = chart.clipOffset,
  16826. clip,
  16827. directionFactor = [-1, 1, 1, -1][side],
  16828. className = options.className,
  16829. axisParent = axis.axisParent, // Used in color axis
  16830. lineHeightCorrection;
  16831. // For reuse in Axis.render
  16832. hasData = axis.hasData();
  16833. axis.showAxis = showAxis = hasData || pick(options.showEmpty, true);
  16834. // Set/reset staggerLines
  16835. axis.staggerLines = axis.horiz && labelOptions.staggerLines;
  16836. // Create the axisGroup and gridGroup elements on first iteration
  16837. if (!axis.axisGroup) {
  16838. axis.gridGroup = renderer.g('grid')
  16839. .attr({ zIndex: options.gridZIndex || 1 })
  16840. .addClass('highcharts-' + this.coll.toLowerCase() + '-grid ' +
  16841. (className || ''))
  16842. .add(axisParent);
  16843. axis.axisGroup = renderer.g('axis')
  16844. .attr({ zIndex: options.zIndex || 2 })
  16845. .addClass('highcharts-' + this.coll.toLowerCase() + ' ' +
  16846. (className || ''))
  16847. .add(axisParent);
  16848. axis.labelGroup = renderer.g('axis-labels')
  16849. .attr({ zIndex: labelOptions.zIndex || 7 })
  16850. .addClass('highcharts-' + axis.coll.toLowerCase() + '-labels ' +
  16851. (className || ''))
  16852. .add(axisParent);
  16853. }
  16854. if (hasData || axis.isLinked) {
  16855. // Generate ticks
  16856. tickPositions.forEach(function (pos, i) {
  16857. // i is not used here, but may be used in overrides
  16858. axis.generateTick(pos, i);
  16859. });
  16860. axis.renderUnsquish();
  16861. // Left side must be align: right and right side must
  16862. // have align: left for labels
  16863. axis.reserveSpaceDefault = (side === 0 ||
  16864. side === 2 ||
  16865. { 1: 'left', 3: 'right' }[side] === axis.labelAlign);
  16866. if (pick(labelOptions.reserveSpace, axis.labelAlign === 'center' ? true : null, axis.reserveSpaceDefault)) {
  16867. tickPositions.forEach(function (pos) {
  16868. // get the highest offset
  16869. labelOffset = Math.max(ticks[pos].getLabelSize(), labelOffset);
  16870. });
  16871. }
  16872. if (axis.staggerLines) {
  16873. labelOffset *= axis.staggerLines;
  16874. }
  16875. axis.labelOffset = labelOffset * (axis.opposite ? -1 : 1);
  16876. }
  16877. else { // doesn't have data
  16878. objectEach(ticks, function (tick, n) {
  16879. tick.destroy();
  16880. delete ticks[n];
  16881. });
  16882. }
  16883. if (axisTitleOptions &&
  16884. axisTitleOptions.text &&
  16885. axisTitleOptions.enabled !== false) {
  16886. axis.addTitle(showAxis);
  16887. if (showAxis && axisTitleOptions.reserveSpace !== false) {
  16888. axis.titleOffset = titleOffset =
  16889. axis.axisTitle.getBBox()[horiz ? 'height' : 'width'];
  16890. titleOffsetOption = axisTitleOptions.offset;
  16891. titleMargin = defined(titleOffsetOption) ?
  16892. 0 :
  16893. pick(axisTitleOptions.margin, horiz ? 5 : 10);
  16894. }
  16895. }
  16896. // Render the axis line
  16897. axis.renderLine();
  16898. // handle automatic or user set offset
  16899. axis.offset = directionFactor * pick(options.offset, axisOffset[side] ? axisOffset[side] + (options.margin || 0) : 0);
  16900. axis.tickRotCorr = axis.tickRotCorr || { x: 0, y: 0 }; // polar
  16901. if (side === 0) {
  16902. lineHeightCorrection = -axis.labelMetrics().h;
  16903. }
  16904. else if (side === 2) {
  16905. lineHeightCorrection = axis.tickRotCorr.y;
  16906. }
  16907. else {
  16908. lineHeightCorrection = 0;
  16909. }
  16910. // Find the padded label offset
  16911. labelOffsetPadded = Math.abs(labelOffset) + titleMargin;
  16912. if (labelOffset) {
  16913. labelOffsetPadded -= lineHeightCorrection;
  16914. labelOffsetPadded += directionFactor * (horiz ?
  16915. pick(labelOptions.y, axis.tickRotCorr.y + directionFactor * 8) :
  16916. labelOptions.x);
  16917. }
  16918. axis.axisTitleMargin = pick(titleOffsetOption, labelOffsetPadded);
  16919. if (axis.getMaxLabelDimensions) {
  16920. axis.maxLabelDimensions = axis.getMaxLabelDimensions(ticks, tickPositions);
  16921. }
  16922. // Due to GridAxis.tickSize, tickSize should be calculated after ticks
  16923. // has rendered.
  16924. var tickSize = this.tickSize('tick');
  16925. axisOffset[side] = Math.max(axisOffset[side], axis.axisTitleMargin + titleOffset +
  16926. directionFactor * axis.offset, labelOffsetPadded, // #3027
  16927. tickPositions && tickPositions.length && tickSize ?
  16928. tickSize[0] + directionFactor * axis.offset :
  16929. 0 // #4866
  16930. );
  16931. // Decide the clipping needed to keep the graph inside
  16932. // the plot area and axis lines
  16933. clip = options.offset ?
  16934. 0 :
  16935. // #4308, #4371:
  16936. Math.floor(axis.axisLine.strokeWidth() / 2) * 2;
  16937. clipOffset[invertedSide] =
  16938. Math.max(clipOffset[invertedSide], clip);
  16939. fireEvent(this, 'afterGetOffset');
  16940. };
  16941. /**
  16942. * Internal function to get the path for the axis line. Extended for polar
  16943. * charts.
  16944. *
  16945. * @function Highcharts.Axis#getLinePath
  16946. *
  16947. * @param {number} lineWidth
  16948. * The line width in pixels.
  16949. *
  16950. * @return {Highcharts.SVGPathArray}
  16951. * The SVG path definition in array form.
  16952. */
  16953. Axis.prototype.getLinePath = function (lineWidth) {
  16954. var chart = this.chart,
  16955. opposite = this.opposite,
  16956. offset = this.offset,
  16957. horiz = this.horiz,
  16958. lineLeft = this.left + (opposite ? this.width : 0) + offset,
  16959. lineTop = chart.chartHeight - this.bottom -
  16960. (opposite ? this.height : 0) + offset;
  16961. if (opposite) {
  16962. lineWidth *= -1; // crispify the other way - #1480, #1687
  16963. }
  16964. return chart.renderer
  16965. .crispLine([
  16966. [
  16967. 'M',
  16968. horiz ?
  16969. this.left :
  16970. lineLeft,
  16971. horiz ?
  16972. lineTop :
  16973. this.top
  16974. ],
  16975. [
  16976. 'L',
  16977. horiz ?
  16978. chart.chartWidth - this.right :
  16979. lineLeft,
  16980. horiz ?
  16981. lineTop :
  16982. chart.chartHeight - this.bottom
  16983. ]
  16984. ], lineWidth);
  16985. };
  16986. /**
  16987. * Render the axis line. Called internally when rendering and redrawing the
  16988. * axis.
  16989. *
  16990. * @function Highcharts.Axis#renderLine
  16991. */
  16992. Axis.prototype.renderLine = function () {
  16993. if (!this.axisLine) {
  16994. this.axisLine = this.chart.renderer.path()
  16995. .addClass('highcharts-axis-line')
  16996. .add(this.axisGroup);
  16997. if (!this.chart.styledMode) {
  16998. this.axisLine.attr({
  16999. stroke: this.options.lineColor,
  17000. 'stroke-width': this.options.lineWidth,
  17001. zIndex: 7
  17002. });
  17003. }
  17004. }
  17005. };
  17006. /**
  17007. * Position the axis title.
  17008. *
  17009. * @private
  17010. * @function Highcharts.Axis#getTitlePosition
  17011. *
  17012. * @return {Highcharts.PositionObject}
  17013. * X and Y positions for the title.
  17014. */
  17015. Axis.prototype.getTitlePosition = function () {
  17016. // compute anchor points for each of the title align options
  17017. var horiz = this.horiz,
  17018. axisLeft = this.left,
  17019. axisTop = this.top,
  17020. axisLength = this.len,
  17021. axisTitleOptions = this.options.title,
  17022. margin = horiz ? axisLeft : axisTop,
  17023. opposite = this.opposite,
  17024. offset = this.offset,
  17025. xOption = axisTitleOptions.x || 0,
  17026. yOption = axisTitleOptions.y || 0,
  17027. axisTitle = this.axisTitle,
  17028. fontMetrics = this.chart.renderer.fontMetrics(axisTitleOptions.style &&
  17029. axisTitleOptions.style.fontSize,
  17030. axisTitle),
  17031. // The part of a multiline text that is below the baseline of the
  17032. // first line. Subtract 1 to preserve pixel-perfectness from the
  17033. // old behaviour (v5.0.12), where only one line was allowed.
  17034. textHeightOvershoot = Math.max(axisTitle.getBBox(null, 0).height - fontMetrics.h - 1, 0),
  17035. // the position in the length direction of the axis
  17036. alongAxis = {
  17037. low: margin + (horiz ? 0 : axisLength),
  17038. middle: margin + axisLength / 2,
  17039. high: margin + (horiz ? axisLength : 0)
  17040. }[axisTitleOptions.align],
  17041. // the position in the perpendicular direction of the axis
  17042. offAxis = (horiz ? axisTop + this.height : axisLeft) +
  17043. (horiz ? 1 : -1) * // horizontal axis reverses the margin
  17044. (opposite ? -1 : 1) * // so does opposite axes
  17045. this.axisTitleMargin +
  17046. [
  17047. -textHeightOvershoot,
  17048. textHeightOvershoot,
  17049. fontMetrics.f,
  17050. -textHeightOvershoot // left
  17051. ][this.side],
  17052. titlePosition = {
  17053. x: horiz ?
  17054. alongAxis + xOption :
  17055. offAxis + (opposite ? this.width : 0) + offset + xOption,
  17056. y: horiz ?
  17057. offAxis + yOption - (opposite ? this.height : 0) + offset :
  17058. alongAxis + yOption
  17059. };
  17060. fireEvent(this, 'afterGetTitlePosition', { titlePosition: titlePosition });
  17061. return titlePosition;
  17062. };
  17063. /**
  17064. * Render a minor tick into the given position. If a minor tick already
  17065. * exists in this position, move it.
  17066. *
  17067. * @function Highcharts.Axis#renderMinorTick
  17068. *
  17069. * @param {number} pos
  17070. * The position in axis values.
  17071. */
  17072. Axis.prototype.renderMinorTick = function (pos) {
  17073. var axis = this;
  17074. var slideInTicks = axis.chart.hasRendered && isNumber(axis.oldMin);
  17075. var minorTicks = axis.minorTicks;
  17076. if (!minorTicks[pos]) {
  17077. minorTicks[pos] = new Tick(axis, pos, 'minor');
  17078. }
  17079. // Render new ticks in old position
  17080. if (slideInTicks && minorTicks[pos].isNew) {
  17081. minorTicks[pos].render(null, true);
  17082. }
  17083. minorTicks[pos].render(null, false, 1);
  17084. };
  17085. /**
  17086. * Render a major tick into the given position. If a tick already exists
  17087. * in this position, move it.
  17088. *
  17089. * @function Highcharts.Axis#renderTick
  17090. *
  17091. * @param {number} pos
  17092. * The position in axis values.
  17093. *
  17094. * @param {number} i
  17095. * The tick index.
  17096. */
  17097. Axis.prototype.renderTick = function (pos, i) {
  17098. var _a;
  17099. var axis = this;
  17100. var isLinked = axis.isLinked;
  17101. var ticks = axis.ticks;
  17102. var slideInTicks = axis.chart.hasRendered && isNumber(axis.oldMin);
  17103. // Linked axes need an extra check to find out if
  17104. if (!isLinked ||
  17105. (pos >= axis.min && pos <= axis.max) || ((_a = axis.grid) === null || _a === void 0 ? void 0 : _a.isColumn)) {
  17106. if (!ticks[pos]) {
  17107. ticks[pos] = new Tick(axis, pos);
  17108. }
  17109. // NOTE this seems like overkill. Could be handled in tick.render by
  17110. // setting old position in attr, then set new position in animate.
  17111. // render new ticks in old position
  17112. if (slideInTicks && ticks[pos].isNew) {
  17113. // Start with negative opacity so that it is visible from
  17114. // halfway into the animation
  17115. ticks[pos].render(i, true, -1);
  17116. }
  17117. ticks[pos].render(i);
  17118. }
  17119. };
  17120. /**
  17121. * Render the axis.
  17122. *
  17123. * @private
  17124. * @function Highcharts.Axis#render
  17125. *
  17126. * @fires Highcharts.Axis#event:afterRender
  17127. */
  17128. Axis.prototype.render = function () {
  17129. var axis = this,
  17130. chart = axis.chart,
  17131. log = axis.logarithmic,
  17132. renderer = chart.renderer,
  17133. options = axis.options,
  17134. isLinked = axis.isLinked,
  17135. tickPositions = axis.tickPositions,
  17136. axisTitle = axis.axisTitle,
  17137. ticks = axis.ticks,
  17138. minorTicks = axis.minorTicks,
  17139. alternateBands = axis.alternateBands,
  17140. stackLabelOptions = options.stackLabels,
  17141. alternateGridColor = options.alternateGridColor,
  17142. tickmarkOffset = axis.tickmarkOffset,
  17143. axisLine = axis.axisLine,
  17144. showAxis = axis.showAxis,
  17145. animation = animObject(renderer.globalAnimation),
  17146. from,
  17147. to;
  17148. // Reset
  17149. axis.labelEdge.length = 0;
  17150. axis.overlap = false;
  17151. // Mark all elements inActive before we go over and mark the active ones
  17152. [ticks, minorTicks, alternateBands].forEach(function (coll) {
  17153. objectEach(coll, function (tick) {
  17154. tick.isActive = false;
  17155. });
  17156. });
  17157. // If the series has data draw the ticks. Else only the line and title
  17158. if (axis.hasData() || isLinked) {
  17159. // minor ticks
  17160. if (axis.minorTickInterval && !axis.categories) {
  17161. axis.getMinorTickPositions().forEach(function (pos) {
  17162. axis.renderMinorTick(pos);
  17163. });
  17164. }
  17165. // Major ticks. Pull out the first item and render it last so that
  17166. // we can get the position of the neighbour label. #808.
  17167. if (tickPositions.length) { // #1300
  17168. tickPositions.forEach(function (pos, i) {
  17169. axis.renderTick(pos, i);
  17170. });
  17171. // In a categorized axis, the tick marks are displayed
  17172. // between labels. So we need to add a tick mark and
  17173. // grid line at the left edge of the X axis.
  17174. if (tickmarkOffset && (axis.min === 0 || axis.single)) {
  17175. if (!ticks[-1]) {
  17176. ticks[-1] = new Tick(axis, -1, null, true);
  17177. }
  17178. ticks[-1].render(-1);
  17179. }
  17180. }
  17181. // alternate grid color
  17182. if (alternateGridColor) {
  17183. tickPositions.forEach(function (pos, i) {
  17184. to = typeof tickPositions[i + 1] !== 'undefined' ?
  17185. tickPositions[i + 1] + tickmarkOffset :
  17186. axis.max - tickmarkOffset;
  17187. if (i % 2 === 0 &&
  17188. pos < axis.max &&
  17189. to <= axis.max + (chart.polar ?
  17190. -tickmarkOffset :
  17191. tickmarkOffset)) { // #2248, #4660
  17192. if (!alternateBands[pos]) {
  17193. // Should be imported from PlotLineOrBand.js, but
  17194. // the dependency cycle with axis is a problem
  17195. alternateBands[pos] = new H.PlotLineOrBand(axis);
  17196. }
  17197. from = pos + tickmarkOffset; // #949
  17198. alternateBands[pos].options = {
  17199. from: log ? log.lin2log(from) : from,
  17200. to: log ? log.lin2log(to) : to,
  17201. color: alternateGridColor,
  17202. className: 'highcharts-alternate-grid'
  17203. };
  17204. alternateBands[pos].render();
  17205. alternateBands[pos].isActive = true;
  17206. }
  17207. });
  17208. }
  17209. // custom plot lines and bands
  17210. if (!axis._addedPlotLB) { // only first time
  17211. (options.plotLines || [])
  17212. .concat(options.plotBands || [])
  17213. .forEach(function (plotLineOptions) {
  17214. axis.addPlotBandOrLine(plotLineOptions);
  17215. });
  17216. axis._addedPlotLB = true;
  17217. }
  17218. } // end if hasData
  17219. // Remove inactive ticks
  17220. [ticks, minorTicks, alternateBands].forEach(function (coll) {
  17221. var i,
  17222. forDestruction = [],
  17223. delay = animation.duration,
  17224. destroyInactiveItems = function () {
  17225. i = forDestruction.length;
  17226. while (i--) {
  17227. // When resizing rapidly, the same items
  17228. // may be destroyed in different timeouts,
  17229. // or the may be reactivated
  17230. if (coll[forDestruction[i]] &&
  17231. !coll[forDestruction[i]].isActive) {
  17232. coll[forDestruction[i]].destroy();
  17233. delete coll[forDestruction[i]];
  17234. }
  17235. }
  17236. };
  17237. objectEach(coll, function (tick, pos) {
  17238. if (!tick.isActive) {
  17239. // Render to zero opacity
  17240. tick.render(pos, false, 0);
  17241. tick.isActive = false;
  17242. forDestruction.push(pos);
  17243. }
  17244. });
  17245. // When the objects are finished fading out, destroy them
  17246. syncTimeout(destroyInactiveItems, coll === alternateBands ||
  17247. !chart.hasRendered ||
  17248. !delay ?
  17249. 0 :
  17250. delay);
  17251. });
  17252. // Set the axis line path
  17253. if (axisLine) {
  17254. axisLine[axisLine.isPlaced ? 'animate' : 'attr']({
  17255. d: this.getLinePath(axisLine.strokeWidth())
  17256. });
  17257. axisLine.isPlaced = true;
  17258. // Show or hide the line depending on options.showEmpty
  17259. axisLine[showAxis ? 'show' : 'hide'](showAxis);
  17260. }
  17261. if (axisTitle && showAxis) {
  17262. var titleXy = axis.getTitlePosition();
  17263. if (isNumber(titleXy.y)) {
  17264. axisTitle[axisTitle.isNew ? 'attr' : 'animate'](titleXy);
  17265. axisTitle.isNew = false;
  17266. }
  17267. else {
  17268. axisTitle.attr('y', -9999);
  17269. axisTitle.isNew = true;
  17270. }
  17271. }
  17272. // Stacked totals:
  17273. if (stackLabelOptions && stackLabelOptions.enabled && axis.stacking) {
  17274. axis.stacking.renderStackTotals();
  17275. }
  17276. // End stacked totals
  17277. axis.isDirty = false;
  17278. fireEvent(this, 'afterRender');
  17279. };
  17280. /**
  17281. * Redraw the axis to reflect changes in the data or axis extremes. Called
  17282. * internally from Highcharts.Chart#redraw.
  17283. *
  17284. * @private
  17285. * @function Highcharts.Axis#redraw
  17286. */
  17287. Axis.prototype.redraw = function () {
  17288. if (this.visible) {
  17289. // render the axis
  17290. this.render();
  17291. // move plot lines and bands
  17292. this.plotLinesAndBands.forEach(function (plotLine) {
  17293. plotLine.render();
  17294. });
  17295. }
  17296. // mark associated series as dirty and ready for redraw
  17297. this.series.forEach(function (series) {
  17298. series.isDirty = true;
  17299. });
  17300. };
  17301. /**
  17302. * Returns an array of axis properties, that should be untouched during
  17303. * reinitialization.
  17304. *
  17305. * @private
  17306. * @function Highcharts.Axis#getKeepProps
  17307. *
  17308. * @return {Array<string>}
  17309. */
  17310. Axis.prototype.getKeepProps = function () {
  17311. return (this.keepProps || Axis.keepProps);
  17312. };
  17313. /**
  17314. * Destroys an Axis instance. See {@link Axis#remove} for the API endpoint
  17315. * to fully remove the axis.
  17316. *
  17317. * @private
  17318. * @function Highcharts.Axis#destroy
  17319. *
  17320. * @param {boolean} [keepEvents]
  17321. * Whether to preserve events, used internally in Axis.update.
  17322. */
  17323. Axis.prototype.destroy = function (keepEvents) {
  17324. var axis = this,
  17325. plotLinesAndBands = axis.plotLinesAndBands,
  17326. plotGroup,
  17327. i;
  17328. fireEvent(this, 'destroy', { keepEvents: keepEvents });
  17329. // Remove the events
  17330. if (!keepEvents) {
  17331. removeEvent(axis);
  17332. }
  17333. // Destroy collections
  17334. [axis.ticks, axis.minorTicks, axis.alternateBands].forEach(function (coll) {
  17335. destroyObjectProperties(coll);
  17336. });
  17337. if (plotLinesAndBands) {
  17338. i = plotLinesAndBands.length;
  17339. while (i--) { // #1975
  17340. plotLinesAndBands[i].destroy();
  17341. }
  17342. }
  17343. // Destroy elements
  17344. ['axisLine', 'axisTitle', 'axisGroup',
  17345. 'gridGroup', 'labelGroup', 'cross', 'scrollbar'].forEach(function (prop) {
  17346. if (axis[prop]) {
  17347. axis[prop] = axis[prop].destroy();
  17348. }
  17349. });
  17350. // Destroy each generated group for plotlines and plotbands
  17351. for (plotGroup in axis.plotLinesAndBandsGroups) { // eslint-disable-line guard-for-in
  17352. axis.plotLinesAndBandsGroups[plotGroup] =
  17353. axis.plotLinesAndBandsGroups[plotGroup].destroy();
  17354. }
  17355. // Delete all properties and fall back to the prototype.
  17356. objectEach(axis, function (val, key) {
  17357. if (axis.getKeepProps().indexOf(key) === -1) {
  17358. delete axis[key];
  17359. }
  17360. });
  17361. };
  17362. /**
  17363. * Internal function to draw a crosshair.
  17364. *
  17365. * @function Highcharts.Axis#drawCrosshair
  17366. *
  17367. * @param {Highcharts.PointerEventObject} [e]
  17368. * The event arguments from the modified pointer event, extended with
  17369. * `chartX` and `chartY`
  17370. *
  17371. * @param {Highcharts.Point} [point]
  17372. * The Point object if the crosshair snaps to points.
  17373. *
  17374. * @fires Highcharts.Axis#event:afterDrawCrosshair
  17375. * @fires Highcharts.Axis#event:drawCrosshair
  17376. */
  17377. Axis.prototype.drawCrosshair = function (e, point) {
  17378. var path,
  17379. options = this.crosshair,
  17380. snap = pick(options.snap,
  17381. true),
  17382. pos,
  17383. categorized,
  17384. graphic = this.cross,
  17385. crossOptions,
  17386. chart = this.chart;
  17387. fireEvent(this, 'drawCrosshair', { e: e, point: point });
  17388. // Use last available event when updating non-snapped crosshairs without
  17389. // mouse interaction (#5287)
  17390. if (!e) {
  17391. e = this.cross && this.cross.e;
  17392. }
  17393. if (
  17394. // Disabled in options
  17395. !this.crosshair ||
  17396. // Snap
  17397. ((defined(point) || !snap) === false)) {
  17398. this.hideCrosshair();
  17399. }
  17400. else {
  17401. // Get the path
  17402. if (!snap) {
  17403. pos = e &&
  17404. (this.horiz ?
  17405. e.chartX - this.pos :
  17406. this.len - e.chartY + this.pos);
  17407. }
  17408. else if (defined(point)) {
  17409. // #3834
  17410. pos = pick(this.coll !== 'colorAxis' ?
  17411. point.crosshairPos : // 3D axis extension
  17412. null, this.isXAxis ?
  17413. point.plotX :
  17414. this.len - point.plotY);
  17415. }
  17416. if (defined(pos)) {
  17417. crossOptions = {
  17418. // value, only used on radial
  17419. value: point && (this.isXAxis ?
  17420. point.x :
  17421. pick(point.stackY, point.y)),
  17422. translatedValue: pos
  17423. };
  17424. if (chart.polar) {
  17425. // Additional information required for crosshairs in
  17426. // polar chart
  17427. extend(crossOptions, {
  17428. isCrosshair: true,
  17429. chartX: e && e.chartX,
  17430. chartY: e && e.chartY,
  17431. point: point
  17432. });
  17433. }
  17434. path = this.getPlotLinePath(crossOptions) ||
  17435. null; // #3189
  17436. }
  17437. if (!defined(path)) {
  17438. this.hideCrosshair();
  17439. return;
  17440. }
  17441. categorized = this.categories && !this.isRadial;
  17442. // Draw the cross
  17443. if (!graphic) {
  17444. this.cross = graphic = chart.renderer
  17445. .path()
  17446. .addClass('highcharts-crosshair highcharts-crosshair-' +
  17447. (categorized ? 'category ' : 'thin ') +
  17448. options.className)
  17449. .attr({
  17450. zIndex: pick(options.zIndex, 2)
  17451. })
  17452. .add();
  17453. // Presentational attributes
  17454. if (!chart.styledMode) {
  17455. graphic.attr({
  17456. stroke: options.color ||
  17457. (categorized ?
  17458. Color
  17459. .parse('#ccd6eb')
  17460. .setOpacity(0.25)
  17461. .get() :
  17462. '#cccccc'),
  17463. 'stroke-width': pick(options.width, 1)
  17464. }).css({
  17465. 'pointer-events': 'none'
  17466. });
  17467. if (options.dashStyle) {
  17468. graphic.attr({
  17469. dashstyle: options.dashStyle
  17470. });
  17471. }
  17472. }
  17473. }
  17474. graphic.show().attr({
  17475. d: path
  17476. });
  17477. if (categorized && !options.width) {
  17478. graphic.attr({
  17479. 'stroke-width': this.transA
  17480. });
  17481. }
  17482. this.cross.e = e;
  17483. }
  17484. fireEvent(this, 'afterDrawCrosshair', { e: e, point: point });
  17485. };
  17486. /**
  17487. * Hide the crosshair if visible.
  17488. *
  17489. * @function Highcharts.Axis#hideCrosshair
  17490. */
  17491. Axis.prototype.hideCrosshair = function () {
  17492. if (this.cross) {
  17493. this.cross.hide();
  17494. }
  17495. fireEvent(this, 'afterHideCrosshair');
  17496. };
  17497. /**
  17498. * Check whether the chart has vertical panning ('y' or 'xy' type).
  17499. *
  17500. * @private
  17501. * @function Highcharts.Axis#hasVerticalPanning
  17502. * @return {boolean}
  17503. *
  17504. */
  17505. Axis.prototype.hasVerticalPanning = function () {
  17506. var _a,
  17507. _b;
  17508. 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) || '');
  17509. };
  17510. /**
  17511. * Check whether the given value is a positive valid axis value.
  17512. *
  17513. * @private
  17514. * @function Highcharts.Axis#validatePositiveValue
  17515. *
  17516. * @param {unknown} value
  17517. * The axis value
  17518. * @return {boolean}
  17519. *
  17520. */
  17521. Axis.prototype.validatePositiveValue = function (value) {
  17522. return isNumber(value) && value > 0;
  17523. };
  17524. /* *
  17525. *
  17526. * Static Properties
  17527. *
  17528. * */
  17529. /**
  17530. * The X axis or category axis. Normally this is the horizontal axis,
  17531. * though if the chart is inverted this is the vertical axis. In case of
  17532. * multiple axes, the xAxis node is an array of configuration objects.
  17533. *
  17534. * See the [Axis class](/class-reference/Highcharts.Axis) for programmatic
  17535. * access to the axis.
  17536. *
  17537. * @productdesc {highmaps}
  17538. * In Highmaps, the axis is hidden, but it is used behind the scenes to
  17539. * control features like zooming and panning. Zooming is in effect the same
  17540. * as setting the extremes of one of the exes.
  17541. *
  17542. * @type {*|Array<*>}
  17543. * @optionparent xAxis
  17544. *
  17545. * @private
  17546. */
  17547. Axis.defaultOptions = {
  17548. /**
  17549. * When using multiple axis, the ticks of two or more opposite axes
  17550. * will automatically be aligned by adding ticks to the axis or axes
  17551. * with the least ticks, as if `tickAmount` were specified.
  17552. *
  17553. * This can be prevented by setting `alignTicks` to false. If the grid
  17554. * lines look messy, it's a good idea to hide them for the secondary
  17555. * axis by setting `gridLineWidth` to 0.
  17556. *
  17557. * If `startOnTick` or `endOnTick` in an Axis options are set to false,
  17558. * then the `alignTicks ` will be disabled for the Axis.
  17559. *
  17560. * Disabled for logarithmic axes.
  17561. *
  17562. * @type {boolean}
  17563. * @default true
  17564. * @product highcharts highstock gantt
  17565. * @apioption xAxis.alignTicks
  17566. */
  17567. /**
  17568. * Whether to allow decimals in this axis' ticks. When counting
  17569. * integers, like persons or hits on a web page, decimals should
  17570. * be avoided in the labels.
  17571. *
  17572. * @see [minTickInterval](#xAxis.minTickInterval)
  17573. *
  17574. * @sample {highcharts|highstock} highcharts/yaxis/allowdecimals-true/
  17575. * True by default
  17576. * @sample {highcharts|highstock} highcharts/yaxis/allowdecimals-false/
  17577. * False
  17578. *
  17579. * @type {boolean}
  17580. * @default true
  17581. * @since 2.0
  17582. * @apioption xAxis.allowDecimals
  17583. */
  17584. /**
  17585. * When using an alternate grid color, a band is painted across the
  17586. * plot area between every other grid line.
  17587. *
  17588. * @sample {highcharts} highcharts/yaxis/alternategridcolor/
  17589. * Alternate grid color on the Y axis
  17590. * @sample {highstock} stock/xaxis/alternategridcolor/
  17591. * Alternate grid color on the Y axis
  17592. *
  17593. * @type {Highcharts.ColorType}
  17594. * @apioption xAxis.alternateGridColor
  17595. */
  17596. /**
  17597. * An array defining breaks in the axis, the sections defined will be
  17598. * left out and all the points shifted closer to each other.
  17599. *
  17600. * @productdesc {highcharts}
  17601. * Requires that the broken-axis.js module is loaded.
  17602. *
  17603. * @sample {highcharts} highcharts/axisbreak/break-simple/
  17604. * Simple break
  17605. * @sample {highcharts|highstock} highcharts/axisbreak/break-visualized/
  17606. * Advanced with callback
  17607. * @sample {highstock} stock/demo/intraday-breaks/
  17608. * Break on nights and weekends
  17609. *
  17610. * @type {Array<*>}
  17611. * @since 4.1.0
  17612. * @product highcharts highstock gantt
  17613. * @apioption xAxis.breaks
  17614. */
  17615. /**
  17616. * A number indicating how much space should be left between the start
  17617. * and the end of the break. The break size is given in axis units,
  17618. * so for instance on a `datetime` axis, a break size of 3600000 would
  17619. * indicate the equivalent of an hour.
  17620. *
  17621. * @type {number}
  17622. * @default 0
  17623. * @since 4.1.0
  17624. * @product highcharts highstock gantt
  17625. * @apioption xAxis.breaks.breakSize
  17626. */
  17627. /**
  17628. * The point where the break starts.
  17629. *
  17630. * @type {number}
  17631. * @since 4.1.0
  17632. * @product highcharts highstock gantt
  17633. * @apioption xAxis.breaks.from
  17634. */
  17635. /**
  17636. * Defines an interval after which the break appears again. By default
  17637. * the breaks do not repeat.
  17638. *
  17639. * @type {number}
  17640. * @default 0
  17641. * @since 4.1.0
  17642. * @product highcharts highstock gantt
  17643. * @apioption xAxis.breaks.repeat
  17644. */
  17645. /**
  17646. * The point where the break ends.
  17647. *
  17648. * @type {number}
  17649. * @since 4.1.0
  17650. * @product highcharts highstock gantt
  17651. * @apioption xAxis.breaks.to
  17652. */
  17653. /**
  17654. * If categories are present for the xAxis, names are used instead of
  17655. * numbers for that axis.
  17656. *
  17657. * Since Highcharts 3.0, categories can also
  17658. * be extracted by giving each point a [name](#series.data) and setting
  17659. * axis [type](#xAxis.type) to `category`. However, if you have multiple
  17660. * series, best practice remains defining the `categories` array.
  17661. *
  17662. * Example: `categories: ['Apples', 'Bananas', 'Oranges']`
  17663. *
  17664. * @sample {highcharts} highcharts/demo/line-labels/
  17665. * With
  17666. * @sample {highcharts} highcharts/xaxis/categories/
  17667. * Without
  17668. *
  17669. * @type {Array<string>}
  17670. * @product highcharts gantt
  17671. * @apioption xAxis.categories
  17672. */
  17673. /**
  17674. * The highest allowed value for automatically computed axis extremes.
  17675. *
  17676. * @see [floor](#xAxis.floor)
  17677. *
  17678. * @sample {highcharts|highstock} highcharts/yaxis/floor-ceiling/
  17679. * Floor and ceiling
  17680. *
  17681. * @type {number}
  17682. * @since 4.0
  17683. * @product highcharts highstock gantt
  17684. * @apioption xAxis.ceiling
  17685. */
  17686. /**
  17687. * A class name that opens for styling the axis by CSS, especially in
  17688. * Highcharts styled mode. The class name is applied to group elements
  17689. * for the grid, axis elements and labels.
  17690. *
  17691. * @sample {highcharts|highstock|highmaps} highcharts/css/axis/
  17692. * Multiple axes with separate styling
  17693. *
  17694. * @type {string}
  17695. * @since 5.0.0
  17696. * @apioption xAxis.className
  17697. */
  17698. /**
  17699. * Configure a crosshair that follows either the mouse pointer or the
  17700. * hovered point.
  17701. *
  17702. * In styled mode, the crosshairs are styled in the
  17703. * `.highcharts-crosshair`, `.highcharts-crosshair-thin` or
  17704. * `.highcharts-xaxis-category` classes.
  17705. *
  17706. * @productdesc {highstock}
  17707. * In Highstock, by default, the crosshair is enabled on the X axis and
  17708. * disabled on the Y axis.
  17709. *
  17710. * @sample {highcharts} highcharts/xaxis/crosshair-both/
  17711. * Crosshair on both axes
  17712. * @sample {highstock} stock/xaxis/crosshairs-xy/
  17713. * Crosshair on both axes
  17714. * @sample {highmaps} highcharts/xaxis/crosshair-both/
  17715. * Crosshair on both axes
  17716. *
  17717. * @declare Highcharts.AxisCrosshairOptions
  17718. * @type {boolean|*}
  17719. * @default false
  17720. * @since 4.1
  17721. * @apioption xAxis.crosshair
  17722. */
  17723. /**
  17724. * A class name for the crosshair, especially as a hook for styling.
  17725. *
  17726. * @type {string}
  17727. * @since 5.0.0
  17728. * @apioption xAxis.crosshair.className
  17729. */
  17730. /**
  17731. * The color of the crosshair. Defaults to `#cccccc` for numeric and
  17732. * datetime axes, and `rgba(204,214,235,0.25)` for category axes, where
  17733. * the crosshair by default highlights the whole category.
  17734. *
  17735. * @sample {highcharts|highstock|highmaps} highcharts/xaxis/crosshair-customized/
  17736. * Customized crosshairs
  17737. *
  17738. * @type {Highcharts.ColorType}
  17739. * @default #cccccc
  17740. * @since 4.1
  17741. * @apioption xAxis.crosshair.color
  17742. */
  17743. /**
  17744. * The dash style for the crosshair. See
  17745. * [plotOptions.series.dashStyle](#plotOptions.series.dashStyle)
  17746. * for possible values.
  17747. *
  17748. * @sample {highcharts|highmaps} highcharts/xaxis/crosshair-dotted/
  17749. * Dotted crosshair
  17750. * @sample {highstock} stock/xaxis/crosshair-dashed/
  17751. * Dashed X axis crosshair
  17752. *
  17753. * @type {Highcharts.DashStyleValue}
  17754. * @default Solid
  17755. * @since 4.1
  17756. * @apioption xAxis.crosshair.dashStyle
  17757. */
  17758. /**
  17759. * A label on the axis next to the crosshair.
  17760. *
  17761. * In styled mode, the label is styled with the
  17762. * `.highcharts-crosshair-label` class.
  17763. *
  17764. * @sample {highstock} stock/xaxis/crosshair-label/
  17765. * Crosshair labels
  17766. * @sample {highstock} highcharts/css/crosshair-label/
  17767. * Style mode
  17768. *
  17769. * @declare Highcharts.AxisCrosshairLabelOptions
  17770. * @since 2.1
  17771. * @product highstock
  17772. * @apioption xAxis.crosshair.label
  17773. */
  17774. /**
  17775. * Alignment of the label compared to the axis. Defaults to `"left"` for
  17776. * right-side axes, `"right"` for left-side axes and `"center"` for
  17777. * horizontal axes.
  17778. *
  17779. * @type {Highcharts.AlignValue}
  17780. * @since 2.1
  17781. * @product highstock
  17782. * @apioption xAxis.crosshair.label.align
  17783. */
  17784. /**
  17785. * The background color for the label. Defaults to the related series
  17786. * color, or `#666666` if that is not available.
  17787. *
  17788. * @type {Highcharts.ColorType}
  17789. * @since 2.1
  17790. * @product highstock
  17791. * @apioption xAxis.crosshair.label.backgroundColor
  17792. */
  17793. /**
  17794. * The border color for the crosshair label
  17795. *
  17796. * @type {Highcharts.ColorType}
  17797. * @since 2.1
  17798. * @product highstock
  17799. * @apioption xAxis.crosshair.label.borderColor
  17800. */
  17801. /**
  17802. * The border corner radius of the crosshair label.
  17803. *
  17804. * @type {number}
  17805. * @default 3
  17806. * @since 2.1.10
  17807. * @product highstock
  17808. * @apioption xAxis.crosshair.label.borderRadius
  17809. */
  17810. /**
  17811. * The border width for the crosshair label.
  17812. *
  17813. * @type {number}
  17814. * @default 0
  17815. * @since 2.1
  17816. * @product highstock
  17817. * @apioption xAxis.crosshair.label.borderWidth
  17818. */
  17819. /**
  17820. * Flag to enable crosshair's label.
  17821. *
  17822. * @sample {highstock} stock/xaxis/crosshairs-xy/
  17823. * Enabled label for yAxis' crosshair
  17824. *
  17825. * @type {boolean}
  17826. * @default false
  17827. * @since 2.1
  17828. * @product highstock
  17829. * @apioption xAxis.crosshair.label.enabled
  17830. */
  17831. /**
  17832. * A format string for the crosshair label. Defaults to `{value}` for
  17833. * numeric axes and `{value:%b %d, %Y}` for datetime axes.
  17834. *
  17835. * @type {string}
  17836. * @since 2.1
  17837. * @product highstock
  17838. * @apioption xAxis.crosshair.label.format
  17839. */
  17840. /**
  17841. * Formatter function for the label text.
  17842. *
  17843. * @type {Highcharts.XAxisCrosshairLabelFormatterCallbackFunction}
  17844. * @since 2.1
  17845. * @product highstock
  17846. * @apioption xAxis.crosshair.label.formatter
  17847. */
  17848. /**
  17849. * Padding inside the crosshair label.
  17850. *
  17851. * @type {number}
  17852. * @default 8
  17853. * @since 2.1
  17854. * @product highstock
  17855. * @apioption xAxis.crosshair.label.padding
  17856. */
  17857. /**
  17858. * The shape to use for the label box.
  17859. *
  17860. * @type {string}
  17861. * @default callout
  17862. * @since 2.1
  17863. * @product highstock
  17864. * @apioption xAxis.crosshair.label.shape
  17865. */
  17866. /**
  17867. * Text styles for the crosshair label.
  17868. *
  17869. * @type {Highcharts.CSSObject}
  17870. * @default {"color": "white", "fontWeight": "normal", "fontSize": "11px", "textAlign": "center"}
  17871. * @since 2.1
  17872. * @product highstock
  17873. * @apioption xAxis.crosshair.label.style
  17874. */
  17875. /**
  17876. * Whether the crosshair should snap to the point or follow the pointer
  17877. * independent of points.
  17878. *
  17879. * @sample {highcharts|highstock} highcharts/xaxis/crosshair-snap-false/
  17880. * True by default
  17881. * @sample {highmaps} maps/demo/latlon-advanced/
  17882. * Snap is false
  17883. *
  17884. * @type {boolean}
  17885. * @default true
  17886. * @since 4.1
  17887. * @apioption xAxis.crosshair.snap
  17888. */
  17889. /**
  17890. * The pixel width of the crosshair. Defaults to 1 for numeric or
  17891. * datetime axes, and for one category width for category axes.
  17892. *
  17893. * @sample {highcharts} highcharts/xaxis/crosshair-customized/
  17894. * Customized crosshairs
  17895. * @sample {highstock} highcharts/xaxis/crosshair-customized/
  17896. * Customized crosshairs
  17897. * @sample {highmaps} highcharts/xaxis/crosshair-customized/
  17898. * Customized crosshairs
  17899. *
  17900. * @type {number}
  17901. * @default 1
  17902. * @since 4.1
  17903. * @apioption xAxis.crosshair.width
  17904. */
  17905. /**
  17906. * The Z index of the crosshair. Higher Z indices allow drawing the
  17907. * crosshair on top of the series or behind the grid lines.
  17908. *
  17909. * @type {number}
  17910. * @default 2
  17911. * @since 4.1
  17912. * @apioption xAxis.crosshair.zIndex
  17913. */
  17914. /**
  17915. * Whether to zoom axis. If `chart.zoomType` is set, the option allows
  17916. * to disable zooming on an individual axis.
  17917. *
  17918. * @sample {highcharts} highcharts/xaxis/zoomenabled/
  17919. * Zoom enabled is false
  17920. *
  17921. *
  17922. * @type {boolean}
  17923. * @default enabled
  17924. * @apioption xAxis.zoomEnabled
  17925. */
  17926. /**
  17927. * For a datetime axis, the scale will automatically adjust to the
  17928. * appropriate unit. This member gives the default string
  17929. * representations used for each unit. For intermediate values,
  17930. * different units may be used, for example the `day` unit can be used
  17931. * on midnight and `hour` unit be used for intermediate values on the
  17932. * same axis.
  17933. *
  17934. * For an overview of the replacement codes, see
  17935. * [dateFormat](/class-reference/Highcharts#dateFormat).
  17936. *
  17937. * Defaults to:
  17938. * ```js
  17939. * {
  17940. * millisecond: '%H:%M:%S.%L',
  17941. * second: '%H:%M:%S',
  17942. * minute: '%H:%M',
  17943. * hour: '%H:%M',
  17944. * day: '%e. %b',
  17945. * week: '%e. %b',
  17946. * month: '%b \'%y',
  17947. * year: '%Y'
  17948. * }
  17949. * ```
  17950. *
  17951. * @sample {highcharts} highcharts/xaxis/datetimelabelformats/
  17952. * Different day format on X axis
  17953. * @sample {highstock} stock/xaxis/datetimelabelformats/
  17954. * More information in x axis labels
  17955. *
  17956. * @declare Highcharts.AxisDateTimeLabelFormatsOptions
  17957. * @product highcharts highstock gantt
  17958. */
  17959. dateTimeLabelFormats: {
  17960. /**
  17961. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  17962. * @type {string|*}
  17963. */
  17964. millisecond: {
  17965. main: '%H:%M:%S.%L',
  17966. range: false
  17967. },
  17968. /**
  17969. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  17970. * @type {string|*}
  17971. */
  17972. second: {
  17973. main: '%H:%M:%S',
  17974. range: false
  17975. },
  17976. /**
  17977. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  17978. * @type {string|*}
  17979. */
  17980. minute: {
  17981. main: '%H:%M',
  17982. range: false
  17983. },
  17984. /**
  17985. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  17986. * @type {string|*}
  17987. */
  17988. hour: {
  17989. main: '%H:%M',
  17990. range: false
  17991. },
  17992. /**
  17993. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  17994. * @type {string|*}
  17995. */
  17996. day: {
  17997. main: '%e. %b'
  17998. },
  17999. /**
  18000. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  18001. * @type {string|*}
  18002. */
  18003. week: {
  18004. main: '%e. %b'
  18005. },
  18006. /**
  18007. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  18008. * @type {string|*}
  18009. */
  18010. month: {
  18011. main: '%b \'%y'
  18012. },
  18013. /**
  18014. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  18015. * @type {string|*}
  18016. */
  18017. year: {
  18018. main: '%Y'
  18019. }
  18020. },
  18021. /**
  18022. * Whether to force the axis to end on a tick. Use this option with
  18023. * the `maxPadding` option to control the axis end.
  18024. *
  18025. * @productdesc {highstock}
  18026. * In Highstock, `endOnTick` is always `false` when the navigator
  18027. * is enabled, to prevent jumpy scrolling.
  18028. *
  18029. * @sample {highcharts} highcharts/chart/reflow-true/
  18030. * True by default
  18031. * @sample {highcharts} highcharts/yaxis/endontick/
  18032. * False
  18033. * @sample {highstock} stock/demo/basic-line/
  18034. * True by default
  18035. * @sample {highstock} stock/xaxis/endontick/
  18036. * False
  18037. *
  18038. * @since 1.2.0
  18039. */
  18040. endOnTick: false,
  18041. /**
  18042. * Event handlers for the axis.
  18043. *
  18044. * @type {*}
  18045. * @apioption xAxis.events
  18046. */
  18047. /**
  18048. * An event fired after the breaks have rendered.
  18049. *
  18050. * @see [breaks](#xAxis.breaks)
  18051. *
  18052. * @sample {highcharts} highcharts/axisbreak/break-event/
  18053. * AfterBreak Event
  18054. *
  18055. * @type {Highcharts.AxisEventCallbackFunction}
  18056. * @since 4.1.0
  18057. * @product highcharts gantt
  18058. * @apioption xAxis.events.afterBreaks
  18059. */
  18060. /**
  18061. * As opposed to the `setExtremes` event, this event fires after the
  18062. * final min and max values are computed and corrected for `minRange`.
  18063. *
  18064. * Fires when the minimum and maximum is set for the axis, either by
  18065. * calling the `.setExtremes()` method or by selecting an area in the
  18066. * chart. One parameter, `event`, is passed to the function, containing
  18067. * common event information.
  18068. *
  18069. * The new user set minimum and maximum values can be found by
  18070. * `event.min` and `event.max`. These reflect the axis minimum and
  18071. * maximum in axis values. The actual data extremes are found in
  18072. * `event.dataMin` and `event.dataMax`.
  18073. *
  18074. * @type {Highcharts.AxisSetExtremesEventCallbackFunction}
  18075. * @since 2.3
  18076. * @context Highcharts.Axis
  18077. * @apioption xAxis.events.afterSetExtremes
  18078. */
  18079. /**
  18080. * An event fired when a break from this axis occurs on a point.
  18081. *
  18082. * @see [breaks](#xAxis.breaks)
  18083. *
  18084. * @sample {highcharts} highcharts/axisbreak/break-visualized/
  18085. * Visualization of a Break
  18086. *
  18087. * @type {Highcharts.AxisPointBreakEventCallbackFunction}
  18088. * @since 4.1.0
  18089. * @product highcharts gantt
  18090. * @context Highcharts.Axis
  18091. * @apioption xAxis.events.pointBreak
  18092. */
  18093. /**
  18094. * An event fired when a point falls inside a break from this axis.
  18095. *
  18096. * @type {Highcharts.AxisPointBreakEventCallbackFunction}
  18097. * @product highcharts highstock gantt
  18098. * @context Highcharts.Axis
  18099. * @apioption xAxis.events.pointInBreak
  18100. */
  18101. /**
  18102. * Fires when the minimum and maximum is set for the axis, either by
  18103. * calling the `.setExtremes()` method or by selecting an area in the
  18104. * chart. One parameter, `event`, is passed to the function,
  18105. * containing common event information.
  18106. *
  18107. * The new user set minimum and maximum values can be found by
  18108. * `event.min` and `event.max`. These reflect the axis minimum and
  18109. * maximum in data values. When an axis is zoomed all the way out from
  18110. * the "Reset zoom" button, `event.min` and `event.max` are null, and
  18111. * the new extremes are set based on `this.dataMin` and `this.dataMax`.
  18112. *
  18113. * @sample {highstock} stock/xaxis/events-setextremes/
  18114. * Log new extremes on x axis
  18115. *
  18116. * @type {Highcharts.AxisSetExtremesEventCallbackFunction}
  18117. * @since 1.2.0
  18118. * @context Highcharts.Axis
  18119. * @apioption xAxis.events.setExtremes
  18120. */
  18121. /**
  18122. * The lowest allowed value for automatically computed axis extremes.
  18123. *
  18124. * @see [ceiling](#yAxis.ceiling)
  18125. *
  18126. * @sample {highcharts} highcharts/yaxis/floor-ceiling/
  18127. * Floor and ceiling
  18128. * @sample {highstock} stock/demo/lazy-loading/
  18129. * Prevent negative stock price on Y axis
  18130. *
  18131. * @type {number}
  18132. * @since 4.0
  18133. * @product highcharts highstock gantt
  18134. * @apioption xAxis.floor
  18135. */
  18136. /**
  18137. * The dash or dot style of the grid lines. For possible values, see
  18138. * [this demonstration](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-dashstyle-all/).
  18139. *
  18140. * @sample {highcharts} highcharts/yaxis/gridlinedashstyle/
  18141. * Long dashes
  18142. * @sample {highstock} stock/xaxis/gridlinedashstyle/
  18143. * Long dashes
  18144. *
  18145. * @type {Highcharts.DashStyleValue}
  18146. * @default Solid
  18147. * @since 1.2
  18148. * @apioption xAxis.gridLineDashStyle
  18149. */
  18150. /**
  18151. * The Z index of the grid lines.
  18152. *
  18153. * @sample {highcharts|highstock} highcharts/xaxis/gridzindex/
  18154. * A Z index of 4 renders the grid above the graph
  18155. *
  18156. * @type {number}
  18157. * @default 1
  18158. * @product highcharts highstock gantt
  18159. * @apioption xAxis.gridZIndex
  18160. */
  18161. /**
  18162. * An id for the axis. This can be used after render time to get
  18163. * a pointer to the axis object through `chart.get()`.
  18164. *
  18165. * @sample {highcharts} highcharts/xaxis/id/
  18166. * Get the object
  18167. * @sample {highstock} stock/xaxis/id/
  18168. * Get the object
  18169. *
  18170. * @type {string}
  18171. * @since 1.2.0
  18172. * @apioption xAxis.id
  18173. */
  18174. /**
  18175. * The axis labels show the number or category for each tick.
  18176. *
  18177. * Since v8.0.0: Labels are animated in categorized x-axis with
  18178. * updating data if `tickInterval` and `step` is set to 1.
  18179. *
  18180. * @productdesc {highmaps}
  18181. * X and Y axis labels are by default disabled in Highmaps, but the
  18182. * functionality is inherited from Highcharts and used on `colorAxis`,
  18183. * and can be enabled on X and Y axes too.
  18184. */
  18185. labels: {
  18186. /**
  18187. * What part of the string the given position is anchored to.
  18188. * If `left`, the left side of the string is at the axis position.
  18189. * Can be one of `"left"`, `"center"` or `"right"`. Defaults to
  18190. * an intelligent guess based on which side of the chart the axis
  18191. * is on and the rotation of the label.
  18192. *
  18193. * @see [reserveSpace](#xAxis.labels.reserveSpace)
  18194. *
  18195. * @sample {highcharts} highcharts/xaxis/labels-align-left/
  18196. * Left
  18197. * @sample {highcharts} highcharts/xaxis/labels-align-right/
  18198. * Right
  18199. * @sample {highcharts} highcharts/xaxis/labels-reservespace-true/
  18200. * Left-aligned labels on a vertical category axis
  18201. *
  18202. * @type {Highcharts.AlignValue}
  18203. * @apioption xAxis.labels.align
  18204. */
  18205. /**
  18206. * For horizontal axes, the allowed degrees of label rotation
  18207. * to prevent overlapping labels. If there is enough space,
  18208. * labels are not rotated. As the chart gets narrower, it
  18209. * will start rotating the labels -45 degrees, then remove
  18210. * every second label and try again with rotations 0 and -45 etc.
  18211. * Set it to `false` to disable rotation, which will
  18212. * cause the labels to word-wrap if possible.
  18213. *
  18214. * @sample {highcharts|highstock} highcharts/xaxis/labels-autorotation-default/
  18215. * Default auto rotation of 0 or -45
  18216. * @sample {highcharts|highstock} highcharts/xaxis/labels-autorotation-0-90/
  18217. * Custom graded auto rotation
  18218. *
  18219. * @type {Array<number>|false}
  18220. * @default [-45]
  18221. * @since 4.1.0
  18222. * @product highcharts highstock gantt
  18223. * @apioption xAxis.labels.autoRotation
  18224. */
  18225. /**
  18226. * When each category width is more than this many pixels, we don't
  18227. * apply auto rotation. Instead, we lay out the axis label with word
  18228. * wrap. A lower limit makes sense when the label contains multiple
  18229. * short words that don't extend the available horizontal space for
  18230. * each label.
  18231. *
  18232. * @sample {highcharts} highcharts/xaxis/labels-autorotationlimit/
  18233. * Lower limit
  18234. *
  18235. * @type {number}
  18236. * @default 80
  18237. * @since 4.1.5
  18238. * @product highcharts gantt
  18239. * @apioption xAxis.labels.autoRotationLimit
  18240. */
  18241. /**
  18242. * Polar charts only. The label's pixel distance from the perimeter
  18243. * of the plot area.
  18244. *
  18245. * @type {number}
  18246. * @default 15
  18247. * @product highcharts gantt
  18248. * @apioption xAxis.labels.distance
  18249. */
  18250. /**
  18251. * Enable or disable the axis labels.
  18252. *
  18253. * @sample {highcharts} highcharts/xaxis/labels-enabled/
  18254. * X axis labels disabled
  18255. * @sample {highstock} stock/xaxis/labels-enabled/
  18256. * X axis labels disabled
  18257. *
  18258. * @default {highcharts|highstock|gantt} true
  18259. * @default {highmaps} false
  18260. */
  18261. enabled: true,
  18262. /**
  18263. * A [format string](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting)
  18264. * for the axis label.
  18265. *
  18266. * @sample {highcharts|highstock} highcharts/yaxis/labels-format/
  18267. * Add units to Y axis label
  18268. *
  18269. * @type {string}
  18270. * @default {value}
  18271. * @since 3.0
  18272. * @apioption xAxis.labels.format
  18273. */
  18274. /**
  18275. * Callback JavaScript function to format the label. The value
  18276. * is given by `this.value`. Additional properties for `this` are
  18277. * `axis`, `chart`, `isFirst` and `isLast`. The value of the default
  18278. * label formatter can be retrieved by calling
  18279. * `this.axis.defaultLabelFormatter.call(this)` within the function.
  18280. *
  18281. * Defaults to:
  18282. * ```js
  18283. * function() {
  18284. * return this.value;
  18285. * }
  18286. * ```
  18287. *
  18288. * @sample {highcharts} highcharts/xaxis/labels-formatter-linked/
  18289. * Linked category names
  18290. * @sample {highcharts} highcharts/xaxis/labels-formatter-extended/
  18291. * Modified numeric labels
  18292. * @sample {highstock} stock/xaxis/labels-formatter/
  18293. * Added units on Y axis
  18294. *
  18295. * @type {Highcharts.AxisLabelsFormatterCallbackFunction}
  18296. * @apioption xAxis.labels.formatter
  18297. */
  18298. /**
  18299. * The number of pixels to indent the labels per level in a treegrid
  18300. * axis.
  18301. *
  18302. * @sample gantt/treegrid-axis/demo
  18303. * Indentation 10px by default.
  18304. * @sample gantt/treegrid-axis/indentation-0px
  18305. * Indentation set to 0px.
  18306. *
  18307. * @product gantt
  18308. */
  18309. indentation: 10,
  18310. /**
  18311. * Horizontal axis only. When `staggerLines` is not set,
  18312. * `maxStaggerLines` defines how many lines the axis is allowed to
  18313. * add to automatically avoid overlapping X labels. Set to `1` to
  18314. * disable overlap detection.
  18315. *
  18316. * @deprecated
  18317. * @type {number}
  18318. * @default 5
  18319. * @since 1.3.3
  18320. * @apioption xAxis.labels.maxStaggerLines
  18321. */
  18322. /**
  18323. * How to handle overflowing labels on horizontal axis. If set to
  18324. * `"allow"`, it will not be aligned at all. By default it
  18325. * `"justify"` labels inside the chart area. If there is room to
  18326. * move it, it will be aligned to the edge, else it will be removed.
  18327. *
  18328. * @type {string}
  18329. * @default justify
  18330. * @since 2.2.5
  18331. * @validvalue ["allow", "justify"]
  18332. * @apioption xAxis.labels.overflow
  18333. */
  18334. /**
  18335. * The pixel padding for axis labels, to ensure white space between
  18336. * them.
  18337. *
  18338. * @type {number}
  18339. * @default 5
  18340. * @product highcharts gantt
  18341. * @apioption xAxis.labels.padding
  18342. */
  18343. /**
  18344. * Whether to reserve space for the labels. By default, space is
  18345. * reserved for the labels in these cases:
  18346. *
  18347. * * On all horizontal axes.
  18348. * * On vertical axes if `label.align` is `right` on a left-side
  18349. * axis or `left` on a right-side axis.
  18350. * * On vertical axes if `label.align` is `center`.
  18351. *
  18352. * This can be turned off when for example the labels are rendered
  18353. * inside the plot area instead of outside.
  18354. *
  18355. * @see [labels.align](#xAxis.labels.align)
  18356. *
  18357. * @sample {highcharts} highcharts/xaxis/labels-reservespace/
  18358. * No reserved space, labels inside plot
  18359. * @sample {highcharts} highcharts/xaxis/labels-reservespace-true/
  18360. * Left-aligned labels on a vertical category axis
  18361. *
  18362. * @type {boolean}
  18363. * @since 4.1.10
  18364. * @product highcharts gantt
  18365. * @apioption xAxis.labels.reserveSpace
  18366. */
  18367. /**
  18368. * Rotation of the labels in degrees.
  18369. *
  18370. * @sample {highcharts} highcharts/xaxis/labels-rotation/
  18371. * X axis labels rotated 90°
  18372. *
  18373. * @type {number}
  18374. * @default 0
  18375. * @apioption xAxis.labels.rotation
  18376. */
  18377. /**
  18378. * Horizontal axes only. The number of lines to spread the labels
  18379. * over to make room or tighter labels.
  18380. *
  18381. * @sample {highcharts} highcharts/xaxis/labels-staggerlines/
  18382. * Show labels over two lines
  18383. * @sample {highstock} stock/xaxis/labels-staggerlines/
  18384. * Show labels over two lines
  18385. *
  18386. * @type {number}
  18387. * @since 2.1
  18388. * @apioption xAxis.labels.staggerLines
  18389. */
  18390. /**
  18391. * To show only every _n_'th label on the axis, set the step to _n_.
  18392. * Setting the step to 2 shows every other label.
  18393. *
  18394. * By default, the step is calculated automatically to avoid
  18395. * overlap. To prevent this, set it to 1\. This usually only
  18396. * happens on a category axis, and is often a sign that you have
  18397. * chosen the wrong axis type.
  18398. *
  18399. * Read more at
  18400. * [Axis docs](https://www.highcharts.com/docs/chart-concepts/axes)
  18401. * => What axis should I use?
  18402. *
  18403. * @sample {highcharts} highcharts/xaxis/labels-step/
  18404. * Showing only every other axis label on a categorized
  18405. * x-axis
  18406. * @sample {highcharts} highcharts/xaxis/labels-step-auto/
  18407. * Auto steps on a category axis
  18408. *
  18409. * @type {number}
  18410. * @since 2.1
  18411. * @apioption xAxis.labels.step
  18412. */
  18413. /**
  18414. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  18415. * to render the labels.
  18416. *
  18417. * @type {boolean}
  18418. * @default false
  18419. * @apioption xAxis.labels.useHTML
  18420. */
  18421. /**
  18422. * The x position offset of all labels relative to the tick
  18423. * positions on the axis.
  18424. *
  18425. * @sample {highcharts} highcharts/xaxis/labels-x/
  18426. * Y axis labels placed on grid lines
  18427. */
  18428. x: 0,
  18429. /**
  18430. * The y position offset of all labels relative to the tick
  18431. * positions on the axis. The default makes it adapt to the font
  18432. * size of the bottom axis.
  18433. *
  18434. * @sample {highcharts} highcharts/xaxis/labels-x/
  18435. * Y axis labels placed on grid lines
  18436. *
  18437. * @type {number}
  18438. * @apioption xAxis.labels.y
  18439. */
  18440. /**
  18441. * The Z index for the axis labels.
  18442. *
  18443. * @type {number}
  18444. * @default 7
  18445. * @apioption xAxis.labels.zIndex
  18446. */
  18447. /**
  18448. * CSS styles for the label. Use `whiteSpace: 'nowrap'` to prevent
  18449. * wrapping of category labels. Use `textOverflow: 'none'` to
  18450. * prevent ellipsis (dots).
  18451. *
  18452. * In styled mode, the labels are styled with the
  18453. * `.highcharts-axis-labels` class.
  18454. *
  18455. * @sample {highcharts} highcharts/xaxis/labels-style/
  18456. * Red X axis labels
  18457. *
  18458. * @type {Highcharts.CSSObject}
  18459. */
  18460. style: {
  18461. /** @internal */
  18462. color: '#666666',
  18463. /** @internal */
  18464. cursor: 'default',
  18465. /** @internal */
  18466. fontSize: '11px'
  18467. }
  18468. },
  18469. /**
  18470. * The left position as the horizontal axis. If it's a number, it is
  18471. * interpreted as pixel position relative to the chart.
  18472. *
  18473. * Since Highcharts v5.0.13: If it's a percentage string, it is
  18474. * interpreted as percentages of the plot width, offset from plot area
  18475. * left.
  18476. *
  18477. * @type {number|string}
  18478. * @product highcharts highstock
  18479. * @apioption xAxis.left
  18480. */
  18481. /**
  18482. * The top position as the vertical axis. If it's a number, it is
  18483. * interpreted as pixel position relative to the chart.
  18484. *
  18485. * Since Highcharts 2: If it's a percentage string, it is interpreted
  18486. * as percentages of the plot height, offset from plot area top.
  18487. *
  18488. * @type {number|string}
  18489. * @product highcharts highstock
  18490. * @apioption xAxis.top
  18491. */
  18492. /**
  18493. * Index of another axis that this axis is linked to. When an axis is
  18494. * linked to a master axis, it will take the same extremes as
  18495. * the master, but as assigned by min or max or by setExtremes.
  18496. * It can be used to show additional info, or to ease reading the
  18497. * chart by duplicating the scales.
  18498. *
  18499. * @sample {highcharts} highcharts/xaxis/linkedto/
  18500. * Different string formats of the same date
  18501. * @sample {highcharts} highcharts/yaxis/linkedto/
  18502. * Y values on both sides
  18503. *
  18504. * @type {number}
  18505. * @since 2.0.2
  18506. * @product highcharts highstock gantt
  18507. * @apioption xAxis.linkedTo
  18508. */
  18509. /**
  18510. * The maximum value of the axis. If `null`, the max value is
  18511. * automatically calculated.
  18512. *
  18513. * If the [endOnTick](#yAxis.endOnTick) option is true, the `max` value
  18514. * might be rounded up.
  18515. *
  18516. * If a [tickAmount](#yAxis.tickAmount) is set, the axis may be extended
  18517. * beyond the set max in order to reach the given number of ticks. The
  18518. * same may happen in a chart with multiple axes, determined by [chart.
  18519. * alignTicks](#chart), where a `tickAmount` is applied internally.
  18520. *
  18521. * @sample {highcharts} highcharts/yaxis/max-200/
  18522. * Y axis max of 200
  18523. * @sample {highcharts} highcharts/yaxis/max-logarithmic/
  18524. * Y axis max on logarithmic axis
  18525. * @sample {highstock} stock/xaxis/min-max/
  18526. * Fixed min and max on X axis
  18527. * @sample {highmaps} maps/axis/min-max/
  18528. * Pre-zoomed to a specific area
  18529. *
  18530. * @type {number|null}
  18531. * @apioption xAxis.max
  18532. */
  18533. /**
  18534. * Padding of the max value relative to the length of the axis. A
  18535. * padding of 0.05 will make a 100px axis 5px longer. This is useful
  18536. * when you don't want the highest data value to appear on the edge
  18537. * of the plot area. When the axis' `max` option is set or a max extreme
  18538. * is set using `axis.setExtremes()`, the maxPadding will be ignored.
  18539. *
  18540. * @sample {highcharts} highcharts/yaxis/maxpadding/
  18541. * Max padding of 0.25 on y axis
  18542. * @sample {highstock} stock/xaxis/minpadding-maxpadding/
  18543. * Greater min- and maxPadding
  18544. * @sample {highmaps} maps/chart/plotbackgroundcolor-gradient/
  18545. * Add some padding
  18546. *
  18547. * @default {highcharts} 0.01
  18548. * @default {highstock|highmaps} 0
  18549. * @since 1.2.0
  18550. */
  18551. maxPadding: 0.01,
  18552. /**
  18553. * Deprecated. Use `minRange` instead.
  18554. *
  18555. * @deprecated
  18556. * @type {number}
  18557. * @product highcharts highstock
  18558. * @apioption xAxis.maxZoom
  18559. */
  18560. /**
  18561. * The minimum value of the axis. If `null` the min value is
  18562. * automatically calculated.
  18563. *
  18564. * If the [startOnTick](#yAxis.startOnTick) option is true (default),
  18565. * the `min` value might be rounded down.
  18566. *
  18567. * The automatically calculated minimum value is also affected by
  18568. * [floor](#yAxis.floor), [softMin](#yAxis.softMin),
  18569. * [minPadding](#yAxis.minPadding), [minRange](#yAxis.minRange)
  18570. * as well as [series.threshold](#plotOptions.series.threshold)
  18571. * and [series.softThreshold](#plotOptions.series.softThreshold).
  18572. *
  18573. * @sample {highcharts} highcharts/yaxis/min-startontick-false/
  18574. * -50 with startOnTick to false
  18575. * @sample {highcharts} highcharts/yaxis/min-startontick-true/
  18576. * -50 with startOnTick true by default
  18577. * @sample {highstock} stock/xaxis/min-max/
  18578. * Set min and max on X axis
  18579. * @sample {highmaps} maps/axis/min-max/
  18580. * Pre-zoomed to a specific area
  18581. *
  18582. * @type {number|null}
  18583. * @apioption xAxis.min
  18584. */
  18585. /**
  18586. * The dash or dot style of the minor grid lines. For possible values,
  18587. * see [this demonstration](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-dashstyle-all/).
  18588. *
  18589. * @sample {highcharts} highcharts/yaxis/minorgridlinedashstyle/
  18590. * Long dashes on minor grid lines
  18591. * @sample {highstock} stock/xaxis/minorgridlinedashstyle/
  18592. * Long dashes on minor grid lines
  18593. *
  18594. * @type {Highcharts.DashStyleValue}
  18595. * @default Solid
  18596. * @since 1.2
  18597. * @apioption xAxis.minorGridLineDashStyle
  18598. */
  18599. /**
  18600. * Specific tick interval in axis units for the minor ticks. On a linear
  18601. * axis, if `"auto"`, the minor tick interval is calculated as a fifth
  18602. * of the tickInterval. If `null` or `undefined`, minor ticks are not
  18603. * shown.
  18604. *
  18605. * On logarithmic axes, the unit is the power of the value. For example,
  18606. * setting the minorTickInterval to 1 puts one tick on each of 0.1, 1,
  18607. * 10, 100 etc. Setting the minorTickInterval to 0.1 produces 9 ticks
  18608. * between 1 and 10, 10 and 100 etc.
  18609. *
  18610. * If user settings dictate minor ticks to become too dense, they don't
  18611. * make sense, and will be ignored to prevent performance problems.
  18612. *
  18613. * @sample {highcharts} highcharts/yaxis/minortickinterval-null/
  18614. * Null by default
  18615. * @sample {highcharts} highcharts/yaxis/minortickinterval-5/
  18616. * 5 units
  18617. * @sample {highcharts} highcharts/yaxis/minortickinterval-log-auto/
  18618. * "auto"
  18619. * @sample {highcharts} highcharts/yaxis/minortickinterval-log/
  18620. * 0.1
  18621. * @sample {highstock} stock/demo/basic-line/
  18622. * Null by default
  18623. * @sample {highstock} stock/xaxis/minortickinterval-auto/
  18624. * "auto"
  18625. *
  18626. * @type {number|string|null}
  18627. * @apioption xAxis.minorTickInterval
  18628. */
  18629. /**
  18630. * The pixel length of the minor tick marks.
  18631. *
  18632. * @sample {highcharts} highcharts/yaxis/minorticklength/
  18633. * 10px on Y axis
  18634. * @sample {highstock} stock/xaxis/minorticks/
  18635. * 10px on Y axis
  18636. */
  18637. minorTickLength: 2,
  18638. /**
  18639. * The position of the minor tick marks relative to the axis line.
  18640. * Can be one of `inside` and `outside`.
  18641. *
  18642. * @sample {highcharts} highcharts/yaxis/minortickposition-outside/
  18643. * Outside by default
  18644. * @sample {highcharts} highcharts/yaxis/minortickposition-inside/
  18645. * Inside
  18646. * @sample {highstock} stock/xaxis/minorticks/
  18647. * Inside
  18648. *
  18649. * @validvalue ["inside", "outside"]
  18650. */
  18651. minorTickPosition: 'outside',
  18652. /**
  18653. * Enable or disable minor ticks. Unless
  18654. * [minorTickInterval](#xAxis.minorTickInterval) is set, the tick
  18655. * interval is calculated as a fifth of the `tickInterval`.
  18656. *
  18657. * On a logarithmic axis, minor ticks are laid out based on a best
  18658. * guess, attempting to enter approximately 5 minor ticks between
  18659. * each major tick.
  18660. *
  18661. * Prior to v6.0.0, ticks were unabled in auto layout by setting
  18662. * `minorTickInterval` to `"auto"`.
  18663. *
  18664. * @productdesc {highcharts}
  18665. * On axes using [categories](#xAxis.categories), minor ticks are not
  18666. * supported.
  18667. *
  18668. * @sample {highcharts} highcharts/yaxis/minorticks-true/
  18669. * Enabled on linear Y axis
  18670. *
  18671. * @type {boolean}
  18672. * @default false
  18673. * @since 6.0.0
  18674. * @apioption xAxis.minorTicks
  18675. */
  18676. /**
  18677. * The pixel width of the minor tick mark.
  18678. *
  18679. * @sample {highcharts} highcharts/yaxis/minortickwidth/
  18680. * 3px width
  18681. * @sample {highstock} stock/xaxis/minorticks/
  18682. * 1px width
  18683. *
  18684. * @type {number}
  18685. * @default 0
  18686. * @apioption xAxis.minorTickWidth
  18687. */
  18688. /**
  18689. * Padding of the min value relative to the length of the axis. A
  18690. * padding of 0.05 will make a 100px axis 5px longer. This is useful
  18691. * when you don't want the lowest data value to appear on the edge
  18692. * of the plot area. When the axis' `min` option is set or a min extreme
  18693. * is set using `axis.setExtremes()`, the minPadding will be ignored.
  18694. *
  18695. * @sample {highcharts} highcharts/yaxis/minpadding/
  18696. * Min padding of 0.2
  18697. * @sample {highstock} stock/xaxis/minpadding-maxpadding/
  18698. * Greater min- and maxPadding
  18699. * @sample {highmaps} maps/chart/plotbackgroundcolor-gradient/
  18700. * Add some padding
  18701. *
  18702. * @default {highcharts} 0.01
  18703. * @default {highstock|highmaps} 0
  18704. * @since 1.2.0
  18705. * @product highcharts highstock gantt
  18706. */
  18707. minPadding: 0.01,
  18708. /**
  18709. * The minimum range to display on this axis. The entire axis will not
  18710. * be allowed to span over a smaller interval than this. For example,
  18711. * for a datetime axis the main unit is milliseconds. If minRange is
  18712. * set to 3600000, you can't zoom in more than to one hour.
  18713. *
  18714. * The default minRange for the x axis is five times the smallest
  18715. * interval between any of the data points.
  18716. *
  18717. * On a logarithmic axis, the unit for the minimum range is the power.
  18718. * So a minRange of 1 means that the axis can be zoomed to 10-100,
  18719. * 100-1000, 1000-10000 etc.
  18720. *
  18721. * **Note**: The `minPadding`, `maxPadding`, `startOnTick` and
  18722. * `endOnTick` settings also affect how the extremes of the axis
  18723. * are computed.
  18724. *
  18725. * @sample {highcharts} highcharts/xaxis/minrange/
  18726. * Minimum range of 5
  18727. * @sample {highstock} stock/xaxis/minrange/
  18728. * Max zoom of 6 months overrides user selections
  18729. * @sample {highmaps} maps/axis/minrange/
  18730. * Minimum range of 1000
  18731. *
  18732. * @type {number}
  18733. * @apioption xAxis.minRange
  18734. */
  18735. /**
  18736. * The minimum tick interval allowed in axis values. For example on
  18737. * zooming in on an axis with daily data, this can be used to prevent
  18738. * the axis from showing hours. Defaults to the closest distance between
  18739. * two points on the axis.
  18740. *
  18741. * @type {number}
  18742. * @since 2.3.0
  18743. * @apioption xAxis.minTickInterval
  18744. */
  18745. /**
  18746. * The distance in pixels from the plot area to the axis line.
  18747. * A positive offset moves the axis with it's line, labels and ticks
  18748. * away from the plot area. This is typically used when two or more
  18749. * axes are displayed on the same side of the plot. With multiple
  18750. * axes the offset is dynamically adjusted to avoid collision, this
  18751. * can be overridden by setting offset explicitly.
  18752. *
  18753. * @sample {highcharts} highcharts/yaxis/offset/
  18754. * Y axis offset of 70
  18755. * @sample {highcharts} highcharts/yaxis/offset-centered/
  18756. * Axes positioned in the center of the plot
  18757. * @sample {highstock} stock/xaxis/offset/
  18758. * Y axis offset by 70 px
  18759. *
  18760. * @type {number}
  18761. * @default 0
  18762. * @apioption xAxis.offset
  18763. */
  18764. /**
  18765. * Whether to display the axis on the opposite side of the normal. The
  18766. * normal is on the left side for vertical axes and bottom for
  18767. * horizontal, so the opposite sides will be right and top respectively.
  18768. * This is typically used with dual or multiple axes.
  18769. *
  18770. * @sample {highcharts} highcharts/yaxis/opposite/
  18771. * Secondary Y axis opposite
  18772. * @sample {highstock} stock/xaxis/opposite/
  18773. * Y axis on left side
  18774. *
  18775. * @type {boolean}
  18776. * @default {highcharts|highstock|highmaps} false
  18777. * @default {gantt} true
  18778. * @apioption xAxis.opposite
  18779. */
  18780. /**
  18781. * In an ordinal axis, the points are equally spaced in the chart
  18782. * regardless of the actual time or x distance between them. This means
  18783. * that missing data periods (e.g. nights or weekends for a stock chart)
  18784. * will not take up space in the chart.
  18785. * Having `ordinal: false` will show any gaps created by the `gapSize`
  18786. * setting proportionate to their duration.
  18787. *
  18788. * In stock charts the X axis is ordinal by default, unless
  18789. * the boost module is used and at least one of the series' data length
  18790. * exceeds the [boostThreshold](#series.line.boostThreshold).
  18791. *
  18792. * @sample {highstock} stock/xaxis/ordinal-true/
  18793. * True by default
  18794. * @sample {highstock} stock/xaxis/ordinal-false/
  18795. * False
  18796. *
  18797. * @type {boolean}
  18798. * @default true
  18799. * @since 1.1
  18800. * @product highstock
  18801. * @apioption xAxis.ordinal
  18802. */
  18803. /**
  18804. * Additional range on the right side of the xAxis. Works similar to
  18805. * `xAxis.maxPadding`, but value is set in milliseconds. Can be set for
  18806. * both main `xAxis` and the navigator's `xAxis`.
  18807. *
  18808. * @sample {highstock} stock/xaxis/overscroll/
  18809. * One minute overscroll with live data
  18810. *
  18811. * @type {number}
  18812. * @default 0
  18813. * @since 6.0.0
  18814. * @product highstock
  18815. * @apioption xAxis.overscroll
  18816. */
  18817. /**
  18818. * Refers to the index in the [panes](#panes) array. Used for circular
  18819. * gauges and polar charts. When the option is not set then first pane
  18820. * will be used.
  18821. *
  18822. * @sample highcharts/demo/gauge-vu-meter
  18823. * Two gauges with different center
  18824. *
  18825. * @type {number}
  18826. * @product highcharts
  18827. * @apioption xAxis.pane
  18828. */
  18829. /**
  18830. * The zoomed range to display when only defining one or none of `min`
  18831. * or `max`. For example, to show the latest month, a range of one month
  18832. * can be set.
  18833. *
  18834. * @sample {highstock} stock/xaxis/range/
  18835. * Setting a zoomed range when the rangeSelector is disabled
  18836. *
  18837. * @type {number}
  18838. * @product highstock
  18839. * @apioption xAxis.range
  18840. */
  18841. /**
  18842. * Whether to reverse the axis so that the highest number is closest
  18843. * to the origin. If the chart is inverted, the x axis is reversed by
  18844. * default.
  18845. *
  18846. * @sample {highcharts} highcharts/yaxis/reversed/
  18847. * Reversed Y axis
  18848. * @sample {highstock} stock/xaxis/reversed/
  18849. * Reversed Y axis
  18850. *
  18851. * @type {boolean}
  18852. * @default false
  18853. * @apioption xAxis.reversed
  18854. */
  18855. // reversed: false,
  18856. /**
  18857. * This option determines how stacks should be ordered within a group.
  18858. * For example reversed xAxis also reverses stacks, so first series
  18859. * comes last in a group. To keep order like for non-reversed xAxis
  18860. * enable this option.
  18861. *
  18862. * @sample {highcharts} highcharts/xaxis/reversedstacks/
  18863. * Reversed stacks comparison
  18864. * @sample {highstock} highcharts/xaxis/reversedstacks/
  18865. * Reversed stacks comparison
  18866. *
  18867. * @type {boolean}
  18868. * @default false
  18869. * @since 6.1.1
  18870. * @product highcharts highstock
  18871. * @apioption xAxis.reversedStacks
  18872. */
  18873. /**
  18874. * An optional scrollbar to display on the X axis in response to
  18875. * limiting the minimum and maximum of the axis values.
  18876. *
  18877. * In styled mode, all the presentational options for the scrollbar are
  18878. * replaced by the classes `.highcharts-scrollbar-thumb`,
  18879. * `.highcharts-scrollbar-arrow`, `.highcharts-scrollbar-button`,
  18880. * `.highcharts-scrollbar-rifles` and `.highcharts-scrollbar-track`.
  18881. *
  18882. * @sample {highstock} stock/yaxis/heatmap-scrollbars/
  18883. * Heatmap with both scrollbars
  18884. *
  18885. * @extends scrollbar
  18886. * @since 4.2.6
  18887. * @product highstock
  18888. * @apioption xAxis.scrollbar
  18889. */
  18890. /**
  18891. * Whether to show the axis line and title when the axis has no data.
  18892. *
  18893. * @sample {highcharts} highcharts/yaxis/showempty/
  18894. * When clicking the legend to hide series, one axis preserves
  18895. * line and title, the other doesn't
  18896. * @sample {highstock} highcharts/yaxis/showempty/
  18897. * When clicking the legend to hide series, one axis preserves
  18898. * line and title, the other doesn't
  18899. *
  18900. * @since 1.1
  18901. */
  18902. showEmpty: true,
  18903. /**
  18904. * Whether to show the first tick label.
  18905. *
  18906. * @sample {highcharts} highcharts/xaxis/showfirstlabel-false/
  18907. * Set to false on X axis
  18908. * @sample {highstock} stock/xaxis/showfirstlabel/
  18909. * Labels below plot lines on Y axis
  18910. *
  18911. * @type {boolean}
  18912. * @default true
  18913. * @apioption xAxis.showFirstLabel
  18914. */
  18915. /**
  18916. * Whether to show the last tick label. Defaults to `true` on cartesian
  18917. * charts, and `false` on polar charts.
  18918. *
  18919. * @sample {highcharts} highcharts/xaxis/showlastlabel-true/
  18920. * Set to true on X axis
  18921. * @sample {highstock} stock/xaxis/showfirstlabel/
  18922. * Labels below plot lines on Y axis
  18923. *
  18924. * @type {boolean}
  18925. * @default true
  18926. * @product highcharts highstock gantt
  18927. * @apioption xAxis.showLastLabel
  18928. */
  18929. /**
  18930. * A soft maximum for the axis. If the series data maximum is less than
  18931. * this, the axis will stay at this maximum, but if the series data
  18932. * maximum is higher, the axis will flex to show all data.
  18933. *
  18934. * @sample highcharts/yaxis/softmin-softmax/
  18935. * Soft min and max
  18936. *
  18937. * @type {number}
  18938. * @since 5.0.1
  18939. * @product highcharts highstock gantt
  18940. * @apioption xAxis.softMax
  18941. */
  18942. /**
  18943. * A soft minimum for the axis. If the series data minimum is greater
  18944. * than this, the axis will stay at this minimum, but if the series
  18945. * data minimum is lower, the axis will flex to show all data.
  18946. *
  18947. * @sample highcharts/yaxis/softmin-softmax/
  18948. * Soft min and max
  18949. *
  18950. * @type {number}
  18951. * @since 5.0.1
  18952. * @product highcharts highstock gantt
  18953. * @apioption xAxis.softMin
  18954. */
  18955. /**
  18956. * For datetime axes, this decides where to put the tick between weeks.
  18957. * 0 = Sunday, 1 = Monday.
  18958. *
  18959. * @sample {highcharts} highcharts/xaxis/startofweek-monday/
  18960. * Monday by default
  18961. * @sample {highcharts} highcharts/xaxis/startofweek-sunday/
  18962. * Sunday
  18963. * @sample {highstock} stock/xaxis/startofweek-1
  18964. * Monday by default
  18965. * @sample {highstock} stock/xaxis/startofweek-0
  18966. * Sunday
  18967. *
  18968. * @product highcharts highstock gantt
  18969. */
  18970. startOfWeek: 1,
  18971. /**
  18972. * Whether to force the axis to start on a tick. Use this option with
  18973. * the `minPadding` option to control the axis start.
  18974. *
  18975. * @productdesc {highstock}
  18976. * In Highstock, `startOnTick` is always `false` when the navigator
  18977. * is enabled, to prevent jumpy scrolling.
  18978. *
  18979. * @sample {highcharts} highcharts/xaxis/startontick-false/
  18980. * False by default
  18981. * @sample {highcharts} highcharts/xaxis/startontick-true/
  18982. * True
  18983. *
  18984. * @since 1.2.0
  18985. */
  18986. startOnTick: false,
  18987. /**
  18988. * The amount of ticks to draw on the axis. This opens up for aligning
  18989. * the ticks of multiple charts or panes within a chart. This option
  18990. * overrides the `tickPixelInterval` option.
  18991. *
  18992. * This option only has an effect on linear axes. Datetime, logarithmic
  18993. * or category axes are not affected.
  18994. *
  18995. * @sample {highcharts} highcharts/yaxis/tickamount/
  18996. * 8 ticks on Y axis
  18997. * @sample {highstock} highcharts/yaxis/tickamount/
  18998. * 8 ticks on Y axis
  18999. *
  19000. * @type {number}
  19001. * @since 4.1.0
  19002. * @product highcharts highstock gantt
  19003. * @apioption xAxis.tickAmount
  19004. */
  19005. /**
  19006. * The interval of the tick marks in axis units. When `undefined`, the
  19007. * tick interval is computed to approximately follow the
  19008. * [tickPixelInterval](#xAxis.tickPixelInterval) on linear and datetime
  19009. * axes. On categorized axes, a `undefined` tickInterval will default to
  19010. * 1, one category. Note that datetime axes are based on milliseconds,
  19011. * so for example an interval of one day is expressed as
  19012. * `24 * 3600 * 1000`.
  19013. *
  19014. * On logarithmic axes, the tickInterval is based on powers, so a
  19015. * tickInterval of 1 means one tick on each of 0.1, 1, 10, 100 etc. A
  19016. * tickInterval of 2 means a tick of 0.1, 10, 1000 etc. A tickInterval
  19017. * of 0.2 puts a tick on 0.1, 0.2, 0.4, 0.6, 0.8, 1, 2, 4, 6, 8, 10, 20,
  19018. * 40 etc.
  19019. *
  19020. *
  19021. * If the tickInterval is too dense for labels to be drawn, Highcharts
  19022. * may remove ticks.
  19023. *
  19024. * If the chart has multiple axes, the [alignTicks](#chart.alignTicks)
  19025. * option may interfere with the `tickInterval` setting.
  19026. *
  19027. * @see [tickPixelInterval](#xAxis.tickPixelInterval)
  19028. * @see [tickPositions](#xAxis.tickPositions)
  19029. * @see [tickPositioner](#xAxis.tickPositioner)
  19030. *
  19031. * @sample {highcharts} highcharts/xaxis/tickinterval-5/
  19032. * Tick interval of 5 on a linear axis
  19033. * @sample {highstock} stock/xaxis/tickinterval/
  19034. * Tick interval of 0.01 on Y axis
  19035. *
  19036. * @type {number}
  19037. * @apioption xAxis.tickInterval
  19038. */
  19039. /**
  19040. * The pixel length of the main tick marks.
  19041. *
  19042. * @sample {highcharts} highcharts/xaxis/ticklength/
  19043. * 20 px tick length on the X axis
  19044. * @sample {highstock} stock/xaxis/ticks/
  19045. * Formatted ticks on X axis
  19046. */
  19047. tickLength: 10,
  19048. /**
  19049. * If tickInterval is `null` this option sets the approximate pixel
  19050. * interval of the tick marks. Not applicable to categorized axis.
  19051. *
  19052. * The tick interval is also influenced by the [minTickInterval](
  19053. * #xAxis.minTickInterval) option, that, by default prevents ticks from
  19054. * being denser than the data points.
  19055. *
  19056. * @see [tickInterval](#xAxis.tickInterval)
  19057. * @see [tickPositioner](#xAxis.tickPositioner)
  19058. * @see [tickPositions](#xAxis.tickPositions)
  19059. *
  19060. * @sample {highcharts} highcharts/xaxis/tickpixelinterval-50/
  19061. * 50 px on X axis
  19062. * @sample {highstock} stock/xaxis/tickpixelinterval/
  19063. * 200 px on X axis
  19064. */
  19065. tickPixelInterval: 100,
  19066. /**
  19067. * For categorized axes only. If `on` the tick mark is placed in the
  19068. * center of the category, if `between` the tick mark is placed between
  19069. * categories. The default is `between` if the `tickInterval` is 1, else
  19070. * `on`.
  19071. *
  19072. * @sample {highcharts} highcharts/xaxis/tickmarkplacement-between/
  19073. * "between" by default
  19074. * @sample {highcharts} highcharts/xaxis/tickmarkplacement-on/
  19075. * "on"
  19076. *
  19077. * @product highcharts gantt
  19078. * @validvalue ["on", "between"]
  19079. */
  19080. tickmarkPlacement: 'between',
  19081. /**
  19082. * The position of the major tick marks relative to the axis line.
  19083. * Can be one of `inside` and `outside`.
  19084. *
  19085. * @sample {highcharts} highcharts/xaxis/tickposition-outside/
  19086. * "outside" by default
  19087. * @sample {highcharts} highcharts/xaxis/tickposition-inside/
  19088. * "inside"
  19089. * @sample {highstock} stock/xaxis/ticks/
  19090. * Formatted ticks on X axis
  19091. *
  19092. * @validvalue ["inside", "outside"]
  19093. */
  19094. tickPosition: 'outside',
  19095. /**
  19096. * A callback function returning array defining where the ticks are
  19097. * laid out on the axis. This overrides the default behaviour of
  19098. * [tickPixelInterval](#xAxis.tickPixelInterval) and [tickInterval](
  19099. * #xAxis.tickInterval). The automatic tick positions are accessible
  19100. * through `this.tickPositions` and can be modified by the callback.
  19101. *
  19102. * @see [tickPositions](#xAxis.tickPositions)
  19103. *
  19104. * @sample {highcharts} highcharts/xaxis/tickpositions-tickpositioner/
  19105. * Demo of tickPositions and tickPositioner
  19106. * @sample {highstock} highcharts/xaxis/tickpositions-tickpositioner/
  19107. * Demo of tickPositions and tickPositioner
  19108. *
  19109. * @type {Highcharts.AxisTickPositionerCallbackFunction}
  19110. * @apioption xAxis.tickPositioner
  19111. */
  19112. /**
  19113. * An array defining where the ticks are laid out on the axis. This
  19114. * overrides the default behaviour of [tickPixelInterval](
  19115. * #xAxis.tickPixelInterval) and [tickInterval](#xAxis.tickInterval).
  19116. *
  19117. * @see [tickPositioner](#xAxis.tickPositioner)
  19118. *
  19119. * @sample {highcharts} highcharts/xaxis/tickpositions-tickpositioner/
  19120. * Demo of tickPositions and tickPositioner
  19121. * @sample {highstock} highcharts/xaxis/tickpositions-tickpositioner/
  19122. * Demo of tickPositions and tickPositioner
  19123. *
  19124. * @type {Array<number>}
  19125. * @apioption xAxis.tickPositions
  19126. */
  19127. /**
  19128. * The pixel width of the major tick marks. Defaults to 0 on category
  19129. * axes, otherwise 1.
  19130. *
  19131. * In styled mode, the stroke width is given in the `.highcharts-tick`
  19132. * class, but in order for the element to be generated on category axes,
  19133. * the option must be explicitly set to 1.
  19134. *
  19135. * @sample {highcharts} highcharts/xaxis/tickwidth/
  19136. * 10 px width
  19137. * @sample {highcharts} highcharts/css/axis-grid/
  19138. * Styled mode
  19139. * @sample {highstock} stock/xaxis/ticks/
  19140. * Formatted ticks on X axis
  19141. * @sample {highstock} highcharts/css/axis-grid/
  19142. * Styled mode
  19143. *
  19144. * @type {undefined|number}
  19145. * @default {highstock} 1
  19146. * @default {highmaps} 0
  19147. * @apioption xAxis.tickWidth
  19148. */
  19149. /**
  19150. * The axis title, showing next to the axis line.
  19151. *
  19152. * @productdesc {highmaps}
  19153. * In Highmaps, the axis is hidden by default, but adding an axis title
  19154. * is still possible. X axis and Y axis titles will appear at the bottom
  19155. * and left by default.
  19156. */
  19157. title: {
  19158. /**
  19159. * Deprecated. Set the `text` to `null` to disable the title.
  19160. *
  19161. * @deprecated
  19162. * @type {boolean}
  19163. * @product highcharts
  19164. * @apioption xAxis.title.enabled
  19165. */
  19166. /**
  19167. * The pixel distance between the axis labels or line and the title.
  19168. * Defaults to 0 for horizontal axes, 10 for vertical
  19169. *
  19170. * @sample {highcharts} highcharts/xaxis/title-margin/
  19171. * Y axis title margin of 60
  19172. *
  19173. * @type {number}
  19174. * @apioption xAxis.title.margin
  19175. */
  19176. /**
  19177. * The distance of the axis title from the axis line. By default,
  19178. * this distance is computed from the offset width of the labels,
  19179. * the labels' distance from the axis and the title's margin.
  19180. * However when the offset option is set, it overrides all this.
  19181. *
  19182. * @sample {highcharts} highcharts/yaxis/title-offset/
  19183. * Place the axis title on top of the axis
  19184. * @sample {highstock} highcharts/yaxis/title-offset/
  19185. * Place the axis title on top of the Y axis
  19186. *
  19187. * @type {number}
  19188. * @since 2.2.0
  19189. * @apioption xAxis.title.offset
  19190. */
  19191. /**
  19192. * Whether to reserve space for the title when laying out the axis.
  19193. *
  19194. * @type {boolean}
  19195. * @default true
  19196. * @since 5.0.11
  19197. * @product highcharts highstock gantt
  19198. * @apioption xAxis.title.reserveSpace
  19199. */
  19200. /**
  19201. * The rotation of the text in degrees. 0 is horizontal, 270 is
  19202. * vertical reading from bottom to top.
  19203. *
  19204. * @sample {highcharts} highcharts/yaxis/title-offset/
  19205. * Horizontal
  19206. *
  19207. * @type {number}
  19208. * @default 0
  19209. * @apioption xAxis.title.rotation
  19210. */
  19211. /**
  19212. * The actual text of the axis title. It can contain basic HTML tags
  19213. * like `b`, `i` and `span` with style.
  19214. *
  19215. * @sample {highcharts} highcharts/xaxis/title-text/
  19216. * Custom HTML
  19217. * @sample {highstock} stock/xaxis/title-text/
  19218. * Titles for both axes
  19219. *
  19220. * @type {string|null}
  19221. * @apioption xAxis.title.text
  19222. */
  19223. /**
  19224. * Alignment of the text, can be `"left"`, `"right"` or `"center"`.
  19225. * Default alignment depends on the
  19226. * [title.align](xAxis.title.align):
  19227. *
  19228. * Horizontal axes:
  19229. * - for `align` = `"low"`, `textAlign` is set to `left`
  19230. * - for `align` = `"middle"`, `textAlign` is set to `center`
  19231. * - for `align` = `"high"`, `textAlign` is set to `right`
  19232. *
  19233. * Vertical axes:
  19234. * - for `align` = `"low"` and `opposite` = `true`, `textAlign` is
  19235. * set to `right`
  19236. * - for `align` = `"low"` and `opposite` = `false`, `textAlign` is
  19237. * set to `left`
  19238. * - for `align` = `"middle"`, `textAlign` is set to `center`
  19239. * - for `align` = `"high"` and `opposite` = `true` `textAlign` is
  19240. * set to `left`
  19241. * - for `align` = `"high"` and `opposite` = `false` `textAlign` is
  19242. * set to `right`
  19243. *
  19244. * @type {Highcharts.AlignValue}
  19245. * @apioption xAxis.title.textAlign
  19246. */
  19247. /**
  19248. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  19249. * to render the axis title.
  19250. *
  19251. * @type {boolean}
  19252. * @default false
  19253. * @product highcharts highstock gantt
  19254. * @apioption xAxis.title.useHTML
  19255. */
  19256. /**
  19257. * Horizontal pixel offset of the title position.
  19258. *
  19259. * @type {number}
  19260. * @default 0
  19261. * @since 4.1.6
  19262. * @product highcharts highstock gantt
  19263. * @apioption xAxis.title.x
  19264. */
  19265. /**
  19266. * Vertical pixel offset of the title position.
  19267. *
  19268. * @type {number}
  19269. * @product highcharts highstock gantt
  19270. * @apioption xAxis.title.y
  19271. */
  19272. /**
  19273. * Alignment of the title relative to the axis values. Possible
  19274. * values are "low", "middle" or "high".
  19275. *
  19276. * @sample {highcharts} highcharts/xaxis/title-align-low/
  19277. * "low"
  19278. * @sample {highcharts} highcharts/xaxis/title-align-center/
  19279. * "middle" by default
  19280. * @sample {highcharts} highcharts/xaxis/title-align-high/
  19281. * "high"
  19282. * @sample {highcharts} highcharts/yaxis/title-offset/
  19283. * Place the Y axis title on top of the axis
  19284. * @sample {highstock} stock/xaxis/title-align/
  19285. * Aligned to "high" value
  19286. *
  19287. * @type {Highcharts.AxisTitleAlignValue}
  19288. */
  19289. align: 'middle',
  19290. /**
  19291. * CSS styles for the title. If the title text is longer than the
  19292. * axis length, it will wrap to multiple lines by default. This can
  19293. * be customized by setting `textOverflow: 'ellipsis'`, by
  19294. * setting a specific `width` or by setting `whiteSpace: 'nowrap'`.
  19295. *
  19296. * In styled mode, the stroke width is given in the
  19297. * `.highcharts-axis-title` class.
  19298. *
  19299. * @sample {highcharts} highcharts/xaxis/title-style/
  19300. * Red
  19301. * @sample {highcharts} highcharts/css/axis/
  19302. * Styled mode
  19303. *
  19304. * @type {Highcharts.CSSObject}
  19305. */
  19306. style: {
  19307. /** @internal */
  19308. color: '#666666'
  19309. }
  19310. },
  19311. /**
  19312. * The type of axis. Can be one of `linear`, `logarithmic`, `datetime`
  19313. * or `category`. In a datetime axis, the numbers are given in
  19314. * milliseconds, and tick marks are placed on appropriate values like
  19315. * full hours or days. In a category axis, the
  19316. * [point names](#series.line.data.name) of the chart's series are used
  19317. * for categories, if not a [categories](#xAxis.categories) array is
  19318. * defined.
  19319. *
  19320. * @sample {highcharts} highcharts/xaxis/type-linear/
  19321. * Linear
  19322. * @sample {highcharts} highcharts/yaxis/type-log/
  19323. * Logarithmic
  19324. * @sample {highcharts} highcharts/yaxis/type-log-minorgrid/
  19325. * Logarithmic with minor grid lines
  19326. * @sample {highcharts} highcharts/xaxis/type-log-both/
  19327. * Logarithmic on two axes
  19328. * @sample {highcharts} highcharts/yaxis/type-log-negative/
  19329. * Logarithmic with extension to emulate negative values
  19330. *
  19331. * @type {Highcharts.AxisTypeValue}
  19332. * @product highcharts gantt
  19333. */
  19334. type: 'linear',
  19335. /**
  19336. * If there are multiple axes on the same side of the chart, the pixel
  19337. * margin between the axes. Defaults to 0 on vertical axes, 15 on
  19338. * horizontal axes.
  19339. *
  19340. * @type {number}
  19341. * @since 7.0.3
  19342. * @apioption xAxis.margin
  19343. */
  19344. /**
  19345. * Applies only when the axis `type` is `category`. When `uniqueNames`
  19346. * is true, points are placed on the X axis according to their names.
  19347. * If the same point name is repeated in the same or another series,
  19348. * the point is placed on the same X position as other points of the
  19349. * same name. When `uniqueNames` is false, the points are laid out in
  19350. * increasing X positions regardless of their names, and the X axis
  19351. * category will take the name of the last point in each position.
  19352. *
  19353. * @sample {highcharts} highcharts/xaxis/uniquenames-true/
  19354. * True by default
  19355. * @sample {highcharts} highcharts/xaxis/uniquenames-false/
  19356. * False
  19357. *
  19358. * @type {boolean}
  19359. * @default true
  19360. * @since 4.2.7
  19361. * @product highcharts gantt
  19362. * @apioption xAxis.uniqueNames
  19363. */
  19364. /**
  19365. * Datetime axis only. An array determining what time intervals the
  19366. * ticks are allowed to fall on. Each array item is an array where the
  19367. * first value is the time unit and the second value another array of
  19368. * allowed multiples.
  19369. *
  19370. * Defaults to:
  19371. * ```js
  19372. * units: [[
  19373. * 'millisecond', // unit name
  19374. * [1, 2, 5, 10, 20, 25, 50, 100, 200, 500] // allowed multiples
  19375. * ], [
  19376. * 'second',
  19377. * [1, 2, 5, 10, 15, 30]
  19378. * ], [
  19379. * 'minute',
  19380. * [1, 2, 5, 10, 15, 30]
  19381. * ], [
  19382. * 'hour',
  19383. * [1, 2, 3, 4, 6, 8, 12]
  19384. * ], [
  19385. * 'day',
  19386. * [1]
  19387. * ], [
  19388. * 'week',
  19389. * [1]
  19390. * ], [
  19391. * 'month',
  19392. * [1, 3, 6]
  19393. * ], [
  19394. * 'year',
  19395. * null
  19396. * ]]
  19397. * ```
  19398. *
  19399. * @type {Array<Array<string,(Array<number>|null)>>}
  19400. * @product highcharts highstock gantt
  19401. * @apioption xAxis.units
  19402. */
  19403. /**
  19404. * Whether axis, including axis title, line, ticks and labels, should
  19405. * be visible.
  19406. *
  19407. * @type {boolean}
  19408. * @default true
  19409. * @since 4.1.9
  19410. * @product highcharts highstock gantt
  19411. * @apioption xAxis.visible
  19412. */
  19413. /**
  19414. * Color of the minor, secondary grid lines.
  19415. *
  19416. * In styled mode, the stroke width is given in the
  19417. * `.highcharts-minor-grid-line` class.
  19418. *
  19419. * @sample {highcharts} highcharts/yaxis/minorgridlinecolor/
  19420. * Bright grey lines from Y axis
  19421. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  19422. * Styled mode
  19423. * @sample {highstock} stock/xaxis/minorgridlinecolor/
  19424. * Bright grey lines from Y axis
  19425. *
  19426. * @type {Highcharts.ColorType}
  19427. * @default #f2f2f2
  19428. */
  19429. minorGridLineColor: '#f2f2f2',
  19430. /**
  19431. * Width of the minor, secondary grid lines.
  19432. *
  19433. * In styled mode, the stroke width is given in the
  19434. * `.highcharts-grid-line` class.
  19435. *
  19436. * @sample {highcharts} highcharts/yaxis/minorgridlinewidth/
  19437. * 2px lines from Y axis
  19438. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  19439. * Styled mode
  19440. * @sample {highstock} stock/xaxis/minorgridlinewidth/
  19441. * 2px lines from Y axis
  19442. */
  19443. minorGridLineWidth: 1,
  19444. /**
  19445. * Color for the minor tick marks.
  19446. *
  19447. * @sample {highcharts} highcharts/yaxis/minortickcolor/
  19448. * Black tick marks on Y axis
  19449. * @sample {highstock} stock/xaxis/minorticks/
  19450. * Black tick marks on Y axis
  19451. *
  19452. * @type {Highcharts.ColorType}
  19453. * @default #999999
  19454. */
  19455. minorTickColor: '#999999',
  19456. /**
  19457. * The color of the line marking the axis itself.
  19458. *
  19459. * In styled mode, the line stroke is given in the
  19460. * `.highcharts-axis-line` or `.highcharts-xaxis-line` class.
  19461. *
  19462. * @productdesc {highmaps}
  19463. * In Highmaps, the axis line is hidden by default, because the axis is
  19464. * not visible by default.
  19465. *
  19466. * @sample {highcharts} highcharts/yaxis/linecolor/
  19467. * A red line on Y axis
  19468. * @sample {highcharts|highstock} highcharts/css/axis/
  19469. * Axes in styled mode
  19470. * @sample {highstock} stock/xaxis/linecolor/
  19471. * A red line on X axis
  19472. *
  19473. * @type {Highcharts.ColorType}
  19474. * @default #ccd6eb
  19475. */
  19476. lineColor: '#ccd6eb',
  19477. /**
  19478. * The width of the line marking the axis itself.
  19479. *
  19480. * In styled mode, the stroke width is given in the
  19481. * `.highcharts-axis-line` or `.highcharts-xaxis-line` class.
  19482. *
  19483. * @sample {highcharts} highcharts/yaxis/linecolor/
  19484. * A 1px line on Y axis
  19485. * @sample {highcharts|highstock} highcharts/css/axis/
  19486. * Axes in styled mode
  19487. * @sample {highstock} stock/xaxis/linewidth/
  19488. * A 2px line on X axis
  19489. *
  19490. * @default {highcharts|highstock} 1
  19491. * @default {highmaps} 0
  19492. */
  19493. lineWidth: 1,
  19494. /**
  19495. * Color of the grid lines extending the ticks across the plot area.
  19496. *
  19497. * In styled mode, the stroke is given in the `.highcharts-grid-line`
  19498. * class.
  19499. *
  19500. * @productdesc {highmaps}
  19501. * In Highmaps, the grid lines are hidden by default.
  19502. *
  19503. * @sample {highcharts} highcharts/yaxis/gridlinecolor/
  19504. * Green lines
  19505. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  19506. * Styled mode
  19507. * @sample {highstock} stock/xaxis/gridlinecolor/
  19508. * Green lines
  19509. *
  19510. * @type {Highcharts.ColorType}
  19511. * @default #e6e6e6
  19512. */
  19513. gridLineColor: '#e6e6e6',
  19514. // gridLineDashStyle: 'solid',
  19515. /**
  19516. * The width of the grid lines extending the ticks across the plot area.
  19517. *
  19518. * In styled mode, the stroke width is given in the
  19519. * `.highcharts-grid-line` class.
  19520. *
  19521. * @sample {highcharts} highcharts/yaxis/gridlinewidth/
  19522. * 2px lines
  19523. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  19524. * Styled mode
  19525. * @sample {highstock} stock/xaxis/gridlinewidth/
  19526. * 2px lines
  19527. *
  19528. * @type {number}
  19529. * @default 0
  19530. * @apioption xAxis.gridLineWidth
  19531. */
  19532. // gridLineWidth: 0,
  19533. /**
  19534. * The height as the vertical axis. If it's a number, it is
  19535. * interpreted as pixels.
  19536. *
  19537. * Since Highcharts 2: If it's a percentage string, it is interpreted
  19538. * as percentages of the total plot height.
  19539. *
  19540. * @type {number|string}
  19541. * @product highcharts highstock
  19542. * @apioption xAxis.height
  19543. */
  19544. /**
  19545. * The width as the horizontal axis. If it's a number, it is interpreted
  19546. * as pixels.
  19547. *
  19548. * Since Highcharts v5.0.13: If it's a percentage string, it is
  19549. * interpreted as percentages of the total plot width.
  19550. *
  19551. * @type {number|string}
  19552. * @product highcharts highstock
  19553. * @apioption xAxis.width
  19554. */
  19555. /**
  19556. * Color for the main tick marks.
  19557. *
  19558. * In styled mode, the stroke is given in the `.highcharts-tick`
  19559. * class.
  19560. *
  19561. * @sample {highcharts} highcharts/xaxis/tickcolor/
  19562. * Red ticks on X axis
  19563. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  19564. * Styled mode
  19565. * @sample {highstock} stock/xaxis/ticks/
  19566. * Formatted ticks on X axis
  19567. *
  19568. * @type {Highcharts.ColorType}
  19569. * @default #ccd6eb
  19570. */
  19571. tickColor: '#ccd6eb'
  19572. // tickWidth: 1
  19573. };
  19574. /**
  19575. * The Y axis or value axis. Normally this is the vertical axis,
  19576. * though if the chart is inverted this is the horizontal axis.
  19577. * In case of multiple axes, the yAxis node is an array of
  19578. * configuration objects.
  19579. *
  19580. * See [the Axis object](/class-reference/Highcharts.Axis) for programmatic
  19581. * access to the axis.
  19582. *
  19583. * @type {*|Array<*>}
  19584. * @extends xAxis
  19585. * @excluding currentDateIndicator,ordinal,overscroll
  19586. * @optionparent yAxis
  19587. *
  19588. * @private
  19589. */
  19590. Axis.defaultYAxisOptions = {
  19591. /**
  19592. * The type of axis. Can be one of `linear`, `logarithmic`, `datetime`,
  19593. * `category` or `treegrid`. Defaults to `treegrid` for Gantt charts,
  19594. * `linear` for other chart types.
  19595. *
  19596. * In a datetime axis, the numbers are given in milliseconds, and tick
  19597. * marks are placed on appropriate values, like full hours or days. In a
  19598. * category or treegrid axis, the [point names](#series.line.data.name)
  19599. * of the chart's series are used for categories, if a
  19600. * [categories](#xAxis.categories) array is not defined.
  19601. *
  19602. * @sample {highcharts} highcharts/yaxis/type-log-minorgrid/
  19603. * Logarithmic with minor grid lines
  19604. * @sample {highcharts} highcharts/yaxis/type-log-negative/
  19605. * Logarithmic with extension to emulate negative values
  19606. * @sample {gantt} gantt/treegrid-axis/demo
  19607. * Treegrid axis
  19608. *
  19609. * @type {Highcharts.AxisTypeValue}
  19610. * @default {highcharts} linear
  19611. * @default {gantt} treegrid
  19612. * @product highcharts gantt
  19613. * @apioption yAxis.type
  19614. */
  19615. /**
  19616. * The height of the Y axis. If it's a number, it is interpreted as
  19617. * pixels.
  19618. *
  19619. * Since Highcharts 2: If it's a percentage string, it is interpreted as
  19620. * percentages of the total plot height.
  19621. *
  19622. * @see [yAxis.top](#yAxis.top)
  19623. *
  19624. * @sample {highstock} stock/demo/candlestick-and-volume/
  19625. * Percentage height panes
  19626. *
  19627. * @type {number|string}
  19628. * @product highcharts highstock
  19629. * @apioption yAxis.height
  19630. */
  19631. /**
  19632. * Solid gauge only. Unless [stops](#yAxis.stops) are set, the color
  19633. * to represent the maximum value of the Y axis.
  19634. *
  19635. * @sample {highcharts} highcharts/yaxis/mincolor-maxcolor/
  19636. * Min and max colors
  19637. *
  19638. * @type {Highcharts.ColorType}
  19639. * @default #003399
  19640. * @since 4.0
  19641. * @product highcharts
  19642. * @apioption yAxis.maxColor
  19643. */
  19644. /**
  19645. * Solid gauge only. Unless [stops](#yAxis.stops) are set, the color
  19646. * to represent the minimum value of the Y axis.
  19647. *
  19648. * @sample {highcharts} highcharts/yaxis/mincolor-maxcolor/
  19649. * Min and max color
  19650. *
  19651. * @type {Highcharts.ColorType}
  19652. * @default #e6ebf5
  19653. * @since 4.0
  19654. * @product highcharts
  19655. * @apioption yAxis.minColor
  19656. */
  19657. /**
  19658. * Whether to reverse the axis so that the highest number is closest
  19659. * to the origin.
  19660. *
  19661. * @sample {highcharts} highcharts/yaxis/reversed/
  19662. * Reversed Y axis
  19663. * @sample {highstock} stock/xaxis/reversed/
  19664. * Reversed Y axis
  19665. *
  19666. * @type {boolean}
  19667. * @default {highcharts} false
  19668. * @default {highstock} false
  19669. * @default {highmaps} true
  19670. * @default {gantt} true
  19671. * @apioption yAxis.reversed
  19672. */
  19673. /**
  19674. * If `true`, the first series in a stack will be drawn on top in a
  19675. * positive, non-reversed Y axis. If `false`, the first series is in
  19676. * the base of the stack.
  19677. *
  19678. * @sample {highcharts} highcharts/yaxis/reversedstacks-false/
  19679. * Non-reversed stacks
  19680. * @sample {highstock} highcharts/yaxis/reversedstacks-false/
  19681. * Non-reversed stacks
  19682. *
  19683. * @type {boolean}
  19684. * @default true
  19685. * @since 3.0.10
  19686. * @product highcharts highstock
  19687. * @apioption yAxis.reversedStacks
  19688. */
  19689. /**
  19690. * Solid gauge series only. Color stops for the solid gauge. Use this
  19691. * in cases where a linear gradient between a `minColor` and `maxColor`
  19692. * is not sufficient. The stops is an array of tuples, where the first
  19693. * item is a float between 0 and 1 assigning the relative position in
  19694. * the gradient, and the second item is the color.
  19695. *
  19696. * For solid gauges, the Y axis also inherits the concept of
  19697. * [data classes](https://api.highcharts.com/highmaps#colorAxis.dataClasses)
  19698. * from the Highmaps color axis.
  19699. *
  19700. * @see [minColor](#yAxis.minColor)
  19701. * @see [maxColor](#yAxis.maxColor)
  19702. *
  19703. * @sample {highcharts} highcharts/demo/gauge-solid/
  19704. * True by default
  19705. *
  19706. * @type {Array<Array<number,Highcharts.ColorType>>}
  19707. * @since 4.0
  19708. * @product highcharts
  19709. * @apioption yAxis.stops
  19710. */
  19711. /**
  19712. * The pixel width of the major tick marks.
  19713. *
  19714. * @sample {highcharts} highcharts/xaxis/tickwidth/ 10 px width
  19715. * @sample {highstock} stock/xaxis/ticks/ Formatted ticks on X axis
  19716. *
  19717. * @type {number}
  19718. * @default 0
  19719. * @product highcharts highstock gantt
  19720. * @apioption yAxis.tickWidth
  19721. */
  19722. /**
  19723. * Whether to force the axis to end on a tick. Use this option with
  19724. * the `maxPadding` option to control the axis end.
  19725. *
  19726. * This option is always disabled, when panning type is
  19727. * either `y` or `xy`.
  19728. *
  19729. * @see [type](#chart.panning.type)
  19730. *
  19731. *
  19732. * @sample {highcharts} highcharts/chart/reflow-true/
  19733. * True by default
  19734. * @sample {highcharts} highcharts/yaxis/endontick/
  19735. * False
  19736. * @sample {highstock} stock/demo/basic-line/
  19737. * True by default
  19738. * @sample {highstock} stock/xaxis/endontick/
  19739. * False for Y axis
  19740. *
  19741. * @since 1.2.0
  19742. */
  19743. endOnTick: true,
  19744. /**
  19745. * Padding of the max value relative to the length of the axis. A
  19746. * padding of 0.05 will make a 100px axis 5px longer. This is useful
  19747. * when you don't want the highest data value to appear on the edge
  19748. * of the plot area. When the axis' `max` option is set or a max extreme
  19749. * is set using `axis.setExtremes()`, the maxPadding will be ignored.
  19750. *
  19751. * Also the `softThreshold` option takes precedence over `maxPadding`,
  19752. * so if the data is tangent to the threshold, `maxPadding` may not
  19753. * apply unless `softThreshold` is set to false.
  19754. *
  19755. * @sample {highcharts} highcharts/yaxis/maxpadding-02/
  19756. * Max padding of 0.2
  19757. * @sample {highstock} stock/xaxis/minpadding-maxpadding/
  19758. * Greater min- and maxPadding
  19759. *
  19760. * @since 1.2.0
  19761. * @product highcharts highstock gantt
  19762. */
  19763. maxPadding: 0.05,
  19764. /**
  19765. * Padding of the min value relative to the length of the axis. A
  19766. * padding of 0.05 will make a 100px axis 5px longer. This is useful
  19767. * when you don't want the lowest data value to appear on the edge
  19768. * of the plot area. When the axis' `min` option is set or a max extreme
  19769. * is set using `axis.setExtremes()`, the maxPadding will be ignored.
  19770. *
  19771. * Also the `softThreshold` option takes precedence over `minPadding`,
  19772. * so if the data is tangent to the threshold, `minPadding` may not
  19773. * apply unless `softThreshold` is set to false.
  19774. *
  19775. * @sample {highcharts} highcharts/yaxis/minpadding/
  19776. * Min padding of 0.2
  19777. * @sample {highstock} stock/xaxis/minpadding-maxpadding/
  19778. * Greater min- and maxPadding
  19779. *
  19780. * @since 1.2.0
  19781. * @product highcharts highstock gantt
  19782. */
  19783. minPadding: 0.05,
  19784. /**
  19785. * @productdesc {highstock}
  19786. * In Highstock 1.x, the Y axis was placed on the left side by default.
  19787. *
  19788. * @sample {highcharts} highcharts/yaxis/opposite/
  19789. * Secondary Y axis opposite
  19790. * @sample {highstock} stock/xaxis/opposite/
  19791. * Y axis on left side
  19792. *
  19793. * @type {boolean}
  19794. * @default {highstock} true
  19795. * @default {highcharts} false
  19796. * @product highstock highcharts gantt
  19797. * @apioption yAxis.opposite
  19798. */
  19799. /**
  19800. * @see [tickInterval](#xAxis.tickInterval)
  19801. * @see [tickPositioner](#xAxis.tickPositioner)
  19802. * @see [tickPositions](#xAxis.tickPositions)
  19803. */
  19804. tickPixelInterval: 72,
  19805. showLastLabel: true,
  19806. /**
  19807. * @extends xAxis.labels
  19808. */
  19809. labels: {
  19810. /**
  19811. * Angular gauges and solid gauges only.
  19812. * The label's pixel distance from the perimeter of the plot area.
  19813. *
  19814. * Since v7.1.2: If it's a percentage string, it is interpreted the
  19815. * same as [series.radius](#plotOptions.gauge.radius), so label can be
  19816. * aligned under the gauge's shape.
  19817. *
  19818. * @sample {highcharts} highcharts/yaxis/labels-distance/
  19819. * Labels centered under the arc
  19820. *
  19821. * @type {number|string}
  19822. * @default -25
  19823. * @product highcharts
  19824. * @apioption yAxis.labels.distance
  19825. */
  19826. /**
  19827. * The y position offset of all labels relative to the tick
  19828. * positions on the axis. For polar and radial axis consider the use
  19829. * of the [distance](#yAxis.labels.distance) option.
  19830. *
  19831. * @sample {highcharts} highcharts/xaxis/labels-x/
  19832. * Y axis labels placed on grid lines
  19833. *
  19834. * @type {number}
  19835. * @default {highcharts} 3
  19836. * @default {highstock} -2
  19837. * @default {highmaps} 3
  19838. * @apioption yAxis.labels.y
  19839. */
  19840. /**
  19841. * What part of the string the given position is anchored to. Can
  19842. * be one of `"left"`, `"center"` or `"right"`. The exact position
  19843. * also depends on the `labels.x` setting.
  19844. *
  19845. * Angular gauges and solid gauges defaults to `"center"`.
  19846. * Solid gauges with two labels have additional option `"auto"`
  19847. * for automatic horizontal and vertical alignment.
  19848. *
  19849. * @see [yAxis.labels.distance](#yAxis.labels.distance)
  19850. *
  19851. * @sample {highcharts} highcharts/yaxis/labels-align-left/
  19852. * Left
  19853. * @sample {highcharts} highcharts/series-solidgauge/labels-auto-aligned/
  19854. * Solid gauge labels auto aligned
  19855. *
  19856. * @type {Highcharts.AlignValue}
  19857. * @default {highcharts|highmaps} right
  19858. * @default {highstock} left
  19859. * @apioption yAxis.labels.align
  19860. */
  19861. /**
  19862. * The x position offset of all labels relative to the tick
  19863. * positions on the axis. Defaults to -15 for left axis, 15 for
  19864. * right axis.
  19865. *
  19866. * @sample {highcharts} highcharts/xaxis/labels-x/
  19867. * Y axis labels placed on grid lines
  19868. */
  19869. x: -8
  19870. },
  19871. /**
  19872. * @productdesc {highmaps}
  19873. * In Highmaps, the axis line is hidden by default, because the axis is
  19874. * not visible by default.
  19875. *
  19876. * @type {Highcharts.ColorType}
  19877. * @apioption yAxis.lineColor
  19878. */
  19879. /**
  19880. * @sample {highcharts} highcharts/yaxis/max-200/
  19881. * Y axis max of 200
  19882. * @sample {highcharts} highcharts/yaxis/max-logarithmic/
  19883. * Y axis max on logarithmic axis
  19884. * @sample {highstock} stock/yaxis/min-max/
  19885. * Fixed min and max on Y axis
  19886. * @sample {highmaps} maps/axis/min-max/
  19887. * Pre-zoomed to a specific area
  19888. *
  19889. * @apioption yAxis.max
  19890. */
  19891. /**
  19892. * @sample {highcharts} highcharts/yaxis/min-startontick-false/
  19893. * -50 with startOnTick to false
  19894. * @sample {highcharts} highcharts/yaxis/min-startontick-true/
  19895. * -50 with startOnTick true by default
  19896. * @sample {highstock} stock/yaxis/min-max/
  19897. * Fixed min and max on Y axis
  19898. * @sample {highmaps} maps/axis/min-max/
  19899. * Pre-zoomed to a specific area
  19900. *
  19901. * @apioption yAxis.min
  19902. */
  19903. /**
  19904. * An optional scrollbar to display on the Y axis in response to
  19905. * limiting the minimum an maximum of the axis values.
  19906. *
  19907. * In styled mode, all the presentational options for the scrollbar
  19908. * are replaced by the classes `.highcharts-scrollbar-thumb`,
  19909. * `.highcharts-scrollbar-arrow`, `.highcharts-scrollbar-button`,
  19910. * `.highcharts-scrollbar-rifles` and `.highcharts-scrollbar-track`.
  19911. *
  19912. * @sample {highstock} stock/yaxis/scrollbar/
  19913. * Scrollbar on the Y axis
  19914. *
  19915. * @extends scrollbar
  19916. * @since 4.2.6
  19917. * @product highstock
  19918. * @excluding height
  19919. * @apioption yAxis.scrollbar
  19920. */
  19921. /**
  19922. * Enable the scrollbar on the Y axis.
  19923. *
  19924. * @sample {highstock} stock/yaxis/scrollbar/
  19925. * Enabled on Y axis
  19926. *
  19927. * @type {boolean}
  19928. * @default false
  19929. * @since 4.2.6
  19930. * @product highstock
  19931. * @apioption yAxis.scrollbar.enabled
  19932. */
  19933. /**
  19934. * Pixel margin between the scrollbar and the axis elements.
  19935. *
  19936. * @type {number}
  19937. * @default 10
  19938. * @since 4.2.6
  19939. * @product highstock
  19940. * @apioption yAxis.scrollbar.margin
  19941. */
  19942. /**
  19943. * Whether to show the scrollbar when it is fully zoomed out at max
  19944. * range. Setting it to `false` on the Y axis makes the scrollbar stay
  19945. * hidden until the user zooms in, like common in browsers.
  19946. *
  19947. * @type {boolean}
  19948. * @default true
  19949. * @since 4.2.6
  19950. * @product highstock
  19951. * @apioption yAxis.scrollbar.showFull
  19952. */
  19953. /**
  19954. * The width of a vertical scrollbar or height of a horizontal
  19955. * scrollbar. Defaults to 20 on touch devices.
  19956. *
  19957. * @type {number}
  19958. * @default 14
  19959. * @since 4.2.6
  19960. * @product highstock
  19961. * @apioption yAxis.scrollbar.size
  19962. */
  19963. /**
  19964. * Z index of the scrollbar elements.
  19965. *
  19966. * @type {number}
  19967. * @default 3
  19968. * @since 4.2.6
  19969. * @product highstock
  19970. * @apioption yAxis.scrollbar.zIndex
  19971. */
  19972. /**
  19973. * A soft maximum for the axis. If the series data maximum is less
  19974. * than this, the axis will stay at this maximum, but if the series
  19975. * data maximum is higher, the axis will flex to show all data.
  19976. *
  19977. * **Note**: The [series.softThreshold](
  19978. * #plotOptions.series.softThreshold) option takes precedence over this
  19979. * option.
  19980. *
  19981. * @sample highcharts/yaxis/softmin-softmax/
  19982. * Soft min and max
  19983. *
  19984. * @type {number}
  19985. * @since 5.0.1
  19986. * @product highcharts highstock gantt
  19987. * @apioption yAxis.softMax
  19988. */
  19989. /**
  19990. * A soft minimum for the axis. If the series data minimum is greater
  19991. * than this, the axis will stay at this minimum, but if the series
  19992. * data minimum is lower, the axis will flex to show all data.
  19993. *
  19994. * **Note**: The [series.softThreshold](
  19995. * #plotOptions.series.softThreshold) option takes precedence over this
  19996. * option.
  19997. *
  19998. * @sample highcharts/yaxis/softmin-softmax/
  19999. * Soft min and max
  20000. *
  20001. * @type {number}
  20002. * @since 5.0.1
  20003. * @product highcharts highstock gantt
  20004. * @apioption yAxis.softMin
  20005. */
  20006. /**
  20007. * Defines the horizontal alignment of the stack total label. Can be one
  20008. * of `"left"`, `"center"` or `"right"`. The default value is calculated
  20009. * at runtime and depends on orientation and whether the stack is
  20010. * positive or negative.
  20011. *
  20012. * @sample {highcharts} highcharts/yaxis/stacklabels-align-left/
  20013. * Aligned to the left
  20014. * @sample {highcharts} highcharts/yaxis/stacklabels-align-center/
  20015. * Aligned in center
  20016. * @sample {highcharts} highcharts/yaxis/stacklabels-align-right/
  20017. * Aligned to the right
  20018. *
  20019. * @type {Highcharts.AlignValue}
  20020. * @since 2.1.5
  20021. * @product highcharts
  20022. * @apioption yAxis.stackLabels.align
  20023. */
  20024. /**
  20025. * A format string for the data label. Available variables are the same
  20026. * as for `formatter`.
  20027. *
  20028. * @type {string}
  20029. * @default {total}
  20030. * @since 3.0.2
  20031. * @product highcharts highstock
  20032. * @apioption yAxis.stackLabels.format
  20033. */
  20034. /**
  20035. * Rotation of the labels in degrees.
  20036. *
  20037. * @sample {highcharts} highcharts/yaxis/stacklabels-rotation/
  20038. * Labels rotated 45°
  20039. *
  20040. * @type {number}
  20041. * @default 0
  20042. * @since 2.1.5
  20043. * @product highcharts
  20044. * @apioption yAxis.stackLabels.rotation
  20045. */
  20046. /**
  20047. * The text alignment for the label. While `align` determines where the
  20048. * texts anchor point is placed with regards to the stack, `textAlign`
  20049. * determines how the text is aligned against its anchor point. Possible
  20050. * values are `"left"`, `"center"` and `"right"`. The default value is
  20051. * calculated at runtime and depends on orientation and whether the
  20052. * stack is positive or negative.
  20053. *
  20054. * @sample {highcharts} highcharts/yaxis/stacklabels-textalign-left/
  20055. * Label in center position but text-aligned left
  20056. *
  20057. * @type {Highcharts.AlignValue}
  20058. * @since 2.1.5
  20059. * @product highcharts
  20060. * @apioption yAxis.stackLabels.textAlign
  20061. */
  20062. /**
  20063. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  20064. * to render the labels.
  20065. *
  20066. * @type {boolean}
  20067. * @default false
  20068. * @since 3.0
  20069. * @product highcharts highstock
  20070. * @apioption yAxis.stackLabels.useHTML
  20071. */
  20072. /**
  20073. * Defines the vertical alignment of the stack total label. Can be one
  20074. * of `"top"`, `"middle"` or `"bottom"`. The default value is calculated
  20075. * at runtime and depends on orientation and whether the stack is
  20076. * positive or negative.
  20077. *
  20078. * @sample {highcharts} highcharts/yaxis/stacklabels-verticalalign-top/
  20079. * Vertically aligned top
  20080. * @sample {highcharts} highcharts/yaxis/stacklabels-verticalalign-middle/
  20081. * Vertically aligned middle
  20082. * @sample {highcharts} highcharts/yaxis/stacklabels-verticalalign-bottom/
  20083. * Vertically aligned bottom
  20084. *
  20085. * @type {Highcharts.VerticalAlignValue}
  20086. * @since 2.1.5
  20087. * @product highcharts
  20088. * @apioption yAxis.stackLabels.verticalAlign
  20089. */
  20090. /**
  20091. * The x position offset of the label relative to the left of the
  20092. * stacked bar. The default value is calculated at runtime and depends
  20093. * on orientation and whether the stack is positive or negative.
  20094. *
  20095. * @sample {highcharts} highcharts/yaxis/stacklabels-x/
  20096. * Stack total labels with x offset
  20097. *
  20098. * @type {number}
  20099. * @since 2.1.5
  20100. * @product highcharts
  20101. * @apioption yAxis.stackLabels.x
  20102. */
  20103. /**
  20104. * The y position offset of the label relative to the tick position
  20105. * on the axis. The default value is calculated at runtime and depends
  20106. * on orientation and whether the stack is positive or negative.
  20107. *
  20108. * @sample {highcharts} highcharts/yaxis/stacklabels-y/
  20109. * Stack total labels with y offset
  20110. *
  20111. * @type {number}
  20112. * @since 2.1.5
  20113. * @product highcharts
  20114. * @apioption yAxis.stackLabels.y
  20115. */
  20116. /**
  20117. * Whether to force the axis to start on a tick. Use this option with
  20118. * the `maxPadding` option to control the axis start.
  20119. *
  20120. * This option is always disabled, when panning type is
  20121. * either `y` or `xy`.
  20122. *
  20123. * @see [type](#chart.panning.type)
  20124. *
  20125. * @sample {highcharts} highcharts/xaxis/startontick-false/
  20126. * False by default
  20127. * @sample {highcharts} highcharts/xaxis/startontick-true/
  20128. * True
  20129. * @sample {highstock} stock/xaxis/endontick/
  20130. * False for Y axis
  20131. *
  20132. * @since 1.2.0
  20133. * @product highcharts highstock gantt
  20134. */
  20135. startOnTick: true,
  20136. title: {
  20137. /**
  20138. * The pixel distance between the axis labels and the title.
  20139. * Positive values are outside the axis line, negative are inside.
  20140. *
  20141. * @sample {highcharts} highcharts/xaxis/title-margin/
  20142. * Y axis title margin of 60
  20143. *
  20144. * @type {number}
  20145. * @default 40
  20146. * @apioption yAxis.title.margin
  20147. */
  20148. /**
  20149. * The rotation of the text in degrees. 0 is horizontal, 270 is
  20150. * vertical reading from bottom to top.
  20151. *
  20152. * @sample {highcharts} highcharts/yaxis/title-offset/
  20153. * Horizontal
  20154. */
  20155. rotation: 270,
  20156. /**
  20157. * The actual text of the axis title. Horizontal texts can contain
  20158. * HTML, but rotated texts are painted using vector techniques and
  20159. * must be clean text. The Y axis title is disabled by setting the
  20160. * `text` option to `undefined`.
  20161. *
  20162. * @sample {highcharts} highcharts/xaxis/title-text/
  20163. * Custom HTML
  20164. *
  20165. * @type {string|null}
  20166. * @default {highcharts} Values
  20167. * @default {highstock} undefined
  20168. * @product highcharts highstock gantt
  20169. */
  20170. text: 'Values'
  20171. },
  20172. /**
  20173. * The top position of the Y axis. If it's a number, it is interpreted
  20174. * as pixel position relative to the chart.
  20175. *
  20176. * Since Highcharts 2: If it's a percentage string, it is interpreted as
  20177. * percentages of the plot height, offset from plot area top.
  20178. *
  20179. * @see [yAxis.height](#yAxis.height)
  20180. *
  20181. * @sample {highstock} stock/demo/candlestick-and-volume/
  20182. * Percentage height panes
  20183. *
  20184. * @type {number|string}
  20185. * @product highcharts highstock
  20186. * @apioption yAxis.top
  20187. */
  20188. /**
  20189. * The stack labels show the total value for each bar in a stacked
  20190. * column or bar chart. The label will be placed on top of positive
  20191. * columns and below negative columns. In case of an inverted column
  20192. * chart or a bar chart the label is placed to the right of positive
  20193. * bars and to the left of negative bars.
  20194. *
  20195. * @product highcharts
  20196. */
  20197. stackLabels: {
  20198. /**
  20199. * Enable or disable the initial animation when a series is
  20200. * displayed for the `stackLabels`. The animation can also be set as
  20201. * a configuration object. Please note that this option only
  20202. * applies to the initial animation.
  20203. * For other animations, see [chart.animation](#chart.animation)
  20204. * and the animation parameter under the API methods.
  20205. * The following properties are supported:
  20206. *
  20207. * - `defer`: The animation delay time in milliseconds.
  20208. *
  20209. * @sample {highcharts} highcharts/plotoptions/animation-defer/
  20210. * Animation defer settings
  20211. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  20212. * @since 8.2.0
  20213. * @apioption yAxis.stackLabels.animation
  20214. */
  20215. animation: {},
  20216. /**
  20217. * The animation delay time in milliseconds.
  20218. * Set to `0` renders stackLabel immediately.
  20219. * As `undefined` inherits defer time from the [series.animation.defer](#plotOptions.series.animation.defer).
  20220. *
  20221. * @type {number}
  20222. * @since 8.2.0
  20223. * @apioption yAxis.stackLabels.animation.defer
  20224. */
  20225. /**
  20226. * Allow the stack labels to overlap.
  20227. *
  20228. * @sample {highcharts} highcharts/yaxis/stacklabels-allowoverlap-false/
  20229. * Default false
  20230. *
  20231. * @since 5.0.13
  20232. * @product highcharts
  20233. */
  20234. allowOverlap: false,
  20235. /**
  20236. * The background color or gradient for the stack label.
  20237. *
  20238. * @sample {highcharts} highcharts/yaxis/stacklabels-box/
  20239. * Stack labels box options
  20240. * @type {Highcharts.ColorType}
  20241. * @since 8.1.0
  20242. * @apioption yAxis.stackLabels.backgroundColor
  20243. */
  20244. /**
  20245. * The border color for the stack label. Defaults to `undefined`.
  20246. *
  20247. * @sample {highcharts} highcharts/yaxis/stacklabels-box/
  20248. * Stack labels box options
  20249. * @type {Highcharts.ColorType}
  20250. * @since 8.1.0
  20251. * @apioption yAxis.stackLabels.borderColor
  20252. */
  20253. /**
  20254. * The border radius in pixels for the stack label.
  20255. *
  20256. * @sample {highcharts} highcharts/yaxis/stacklabels-box/
  20257. * Stack labels box options
  20258. * @type {number}
  20259. * @default 0
  20260. * @since 8.1.0
  20261. * @apioption yAxis.stackLabels.borderRadius
  20262. */
  20263. /**
  20264. * The border width in pixels for the stack label.
  20265. *
  20266. * @sample {highcharts} highcharts/yaxis/stacklabels-box/
  20267. * Stack labels box options
  20268. * @type {number}
  20269. * @default 0
  20270. * @since 8.1.0
  20271. * @apioption yAxis.stackLabels.borderWidth
  20272. */
  20273. /**
  20274. * Enable or disable the stack total labels.
  20275. *
  20276. * @sample {highcharts} highcharts/yaxis/stacklabels-enabled/
  20277. * Enabled stack total labels
  20278. * @sample {highcharts} highcharts/yaxis/stacklabels-enabled-waterfall/
  20279. * Enabled stack labels in waterfall chart
  20280. *
  20281. * @since 2.1.5
  20282. * @product highcharts
  20283. */
  20284. enabled: false,
  20285. /**
  20286. * Whether to hide stack labels that are outside the plot area.
  20287. * By default, the stack label is moved
  20288. * inside the plot area according to the
  20289. * [overflow](/highcharts/#yAxis/stackLabels/overflow)
  20290. * option.
  20291. *
  20292. * @type {boolean}
  20293. * @since 7.1.3
  20294. */
  20295. crop: true,
  20296. /**
  20297. * How to handle stack total labels that flow outside the plot area.
  20298. * The default is set to `"justify"`,
  20299. * which aligns them inside the plot area.
  20300. * For columns and bars, this means it will be moved inside the bar.
  20301. * To display stack labels outside the plot area,
  20302. * set `crop` to `false` and `overflow` to `"allow"`.
  20303. *
  20304. * @sample highcharts/yaxis/stacklabels-overflow/
  20305. * Stack labels flows outside the plot area.
  20306. *
  20307. * @type {Highcharts.DataLabelsOverflowValue}
  20308. * @since 7.1.3
  20309. */
  20310. overflow: 'justify',
  20311. /* eslint-disable valid-jsdoc */
  20312. /**
  20313. * Callback JavaScript function to format the label. The value is
  20314. * given by `this.total`.
  20315. *
  20316. * @sample {highcharts} highcharts/yaxis/stacklabels-formatter/
  20317. * Added units to stack total value
  20318. *
  20319. * @type {Highcharts.FormatterCallbackFunction<Highcharts.StackItemObject>}
  20320. * @since 2.1.5
  20321. * @product highcharts
  20322. */
  20323. formatter: function () {
  20324. var numberFormatter = this.axis.chart.numberFormatter;
  20325. /* eslint-enable valid-jsdoc */
  20326. return numberFormatter(this.total, -1);
  20327. },
  20328. /**
  20329. * CSS styles for the label.
  20330. *
  20331. * In styled mode, the styles are set in the
  20332. * `.highcharts-stack-label` class.
  20333. *
  20334. * @sample {highcharts} highcharts/yaxis/stacklabels-style/
  20335. * Red stack total labels
  20336. *
  20337. * @type {Highcharts.CSSObject}
  20338. * @since 2.1.5
  20339. * @product highcharts
  20340. */
  20341. style: {
  20342. /** @internal */
  20343. color: '#000000',
  20344. /** @internal */
  20345. fontSize: '11px',
  20346. /** @internal */
  20347. fontWeight: 'bold',
  20348. /** @internal */
  20349. textOutline: '1px contrast'
  20350. }
  20351. },
  20352. gridLineWidth: 1,
  20353. lineWidth: 0
  20354. // tickWidth: 0
  20355. };
  20356. /**
  20357. * The Z axis or depth axis for 3D plots.
  20358. *
  20359. * See the [Axis class](/class-reference/Highcharts.Axis) for programmatic
  20360. * access to the axis.
  20361. *
  20362. * @sample {highcharts} highcharts/3d/scatter-zaxis-categories/
  20363. * Z-Axis with Categories
  20364. * @sample {highcharts} highcharts/3d/scatter-zaxis-grid/
  20365. * Z-Axis with styling
  20366. *
  20367. * @type {*|Array<*>}
  20368. * @extends xAxis
  20369. * @since 5.0.0
  20370. * @product highcharts
  20371. * @excluding breaks, crosshair, height, left, lineColor, lineWidth,
  20372. * nameToX, showEmpty, top, width
  20373. * @apioption zAxis
  20374. *
  20375. * @private
  20376. */
  20377. // This variable extends the defaultOptions for left axes.
  20378. Axis.defaultLeftAxisOptions = {
  20379. labels: {
  20380. x: -15
  20381. },
  20382. title: {
  20383. rotation: 270
  20384. }
  20385. };
  20386. // This variable extends the defaultOptions for right axes.
  20387. Axis.defaultRightAxisOptions = {
  20388. labels: {
  20389. x: 15
  20390. },
  20391. title: {
  20392. rotation: 90
  20393. }
  20394. };
  20395. // This variable extends the defaultOptions for bottom axes.
  20396. Axis.defaultBottomAxisOptions = {
  20397. labels: {
  20398. autoRotation: [-45],
  20399. x: 0
  20400. // overflow: undefined,
  20401. // staggerLines: null
  20402. },
  20403. margin: 15,
  20404. title: {
  20405. rotation: 0
  20406. }
  20407. };
  20408. // This variable extends the defaultOptions for top axes.
  20409. Axis.defaultTopAxisOptions = {
  20410. labels: {
  20411. autoRotation: [-45],
  20412. x: 0
  20413. // overflow: undefined
  20414. // staggerLines: null
  20415. },
  20416. margin: 15,
  20417. title: {
  20418. rotation: 0
  20419. }
  20420. };
  20421. // Properties to survive after destroy, needed for Axis.update (#4317,
  20422. // #5773, #5881).
  20423. Axis.keepProps = ['extKey', 'hcEvents', 'names', 'series', 'userMax', 'userMin'];
  20424. return Axis;
  20425. }());
  20426. H.Axis = Axis;
  20427. return H.Axis;
  20428. });
  20429. _registerModule(_modules, 'Core/Axis/DateTimeAxis.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Utilities.js']], function (Axis, U) {
  20430. /* *
  20431. *
  20432. * (c) 2010-2020 Torstein Honsi
  20433. *
  20434. * License: www.highcharts.com/license
  20435. *
  20436. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  20437. *
  20438. * */
  20439. var addEvent = U.addEvent,
  20440. getMagnitude = U.getMagnitude,
  20441. normalizeTickInterval = U.normalizeTickInterval,
  20442. timeUnits = U.timeUnits;
  20443. /* eslint-disable valid-jsdoc */
  20444. var DateTimeAxisAdditions = /** @class */ (function () {
  20445. /* *
  20446. *
  20447. * Constructors
  20448. *
  20449. * */
  20450. function DateTimeAxisAdditions(axis) {
  20451. this.axis = axis;
  20452. }
  20453. /* *
  20454. *
  20455. * Functions
  20456. *
  20457. * */
  20458. /**
  20459. * Get a normalized tick interval for dates. Returns a configuration object
  20460. * with unit range (interval), count and name. Used to prepare data for
  20461. * `getTimeTicks`. Previously this logic was part of getTimeTicks, but as
  20462. * `getTimeTicks` now runs of segments in stock charts, the normalizing
  20463. * logic was extracted in order to prevent it for running over again for
  20464. * each segment having the same interval. #662, #697.
  20465. * @private
  20466. */
  20467. /**
  20468. * Get a normalized tick interval for dates. Returns a configuration object
  20469. * with unit range (interval), count and name. Used to prepare data for
  20470. * `getTimeTicks`. Previously this logic was part of getTimeTicks, but as
  20471. * `getTimeTicks` now runs of segments in stock charts, the normalizing
  20472. * logic was extracted in order to prevent it for running over again for
  20473. * each segment having the same interval. #662, #697.
  20474. * @private
  20475. */
  20476. DateTimeAxisAdditions.prototype.normalizeTimeTickInterval = function (tickInterval, unitsOption) {
  20477. var units = unitsOption || [[
  20478. 'millisecond',
  20479. [1, 2, 5, 10, 20, 25, 50, 100, 200, 500] // allowed multiples
  20480. ],
  20481. [
  20482. 'second',
  20483. [1, 2, 5, 10, 15, 30]
  20484. ],
  20485. [
  20486. 'minute',
  20487. [1, 2, 5, 10, 15, 30]
  20488. ],
  20489. [
  20490. 'hour',
  20491. [1, 2, 3, 4, 6, 8, 12]
  20492. ],
  20493. [
  20494. 'day',
  20495. [1, 2]
  20496. ],
  20497. [
  20498. 'week',
  20499. [1, 2]
  20500. ],
  20501. [
  20502. 'month',
  20503. [1, 2, 3, 4, 6]
  20504. ],
  20505. [
  20506. 'year',
  20507. null
  20508. ]],
  20509. unit = units[units.length - 1], // default unit is years
  20510. interval = timeUnits[unit[0]],
  20511. multiples = unit[1],
  20512. count,
  20513. i;
  20514. // loop through the units to find the one that best fits the
  20515. // tickInterval
  20516. for (i = 0; i < units.length; i++) {
  20517. unit = units[i];
  20518. interval = timeUnits[unit[0]];
  20519. multiples = unit[1];
  20520. if (units[i + 1]) {
  20521. // lessThan is in the middle between the highest multiple and
  20522. // the next unit.
  20523. var lessThan = (interval *
  20524. multiples[multiples.length - 1] +
  20525. timeUnits[units[i + 1][0]]) / 2;
  20526. // break and keep the current unit
  20527. if (tickInterval <= lessThan) {
  20528. break;
  20529. }
  20530. }
  20531. }
  20532. // prevent 2.5 years intervals, though 25, 250 etc. are allowed
  20533. if (interval === timeUnits.year && tickInterval < 5 * interval) {
  20534. multiples = [1, 2, 5];
  20535. }
  20536. // get the count
  20537. count = normalizeTickInterval(tickInterval / interval, multiples, unit[0] === 'year' ? // #1913, #2360
  20538. Math.max(getMagnitude(tickInterval / interval), 1) :
  20539. 1);
  20540. return {
  20541. unitRange: interval,
  20542. count: count,
  20543. unitName: unit[0]
  20544. };
  20545. };
  20546. return DateTimeAxisAdditions;
  20547. }());
  20548. /**
  20549. * Date and time support for axes.
  20550. *
  20551. * @private
  20552. * @class
  20553. */
  20554. var DateTimeAxis = /** @class */ (function () {
  20555. function DateTimeAxis() {
  20556. }
  20557. /* *
  20558. *
  20559. * Static Functions
  20560. *
  20561. * */
  20562. /**
  20563. * Extends axis class with date and time support.
  20564. * @private
  20565. */
  20566. DateTimeAxis.compose = function (AxisClass) {
  20567. AxisClass.keepProps.push('dateTime');
  20568. var axisProto = AxisClass.prototype;
  20569. /**
  20570. * Set the tick positions to a time unit that makes sense, for example
  20571. * on the first of each month or on every Monday. Return an array with
  20572. * the time positions. Used in datetime axes as well as for grouping
  20573. * data on a datetime axis.
  20574. *
  20575. * @private
  20576. * @function Highcharts.Axis#getTimeTicks
  20577. *
  20578. * @param {Highcharts.TimeNormalizeObject} normalizedInterval
  20579. * The interval in axis values (ms) and thecount.
  20580. *
  20581. * @param {number} min
  20582. * The minimum in axis values.
  20583. *
  20584. * @param {number} max
  20585. * The maximum in axis values.
  20586. *
  20587. * @param {number} startOfWeek
  20588. *
  20589. * @return {Highcharts.AxisTickPositionsArray}
  20590. */
  20591. axisProto.getTimeTicks = function () {
  20592. return this.chart.time.getTimeTicks.apply(this.chart.time, arguments);
  20593. };
  20594. /* eslint-disable no-invalid-this */
  20595. addEvent(AxisClass, 'init', function (e) {
  20596. var axis = this;
  20597. var options = e.userOptions;
  20598. if (options.type !== 'datetime') {
  20599. axis.dateTime = void 0;
  20600. return;
  20601. }
  20602. if (!axis.dateTime) {
  20603. axis.dateTime = new DateTimeAxisAdditions(axis);
  20604. }
  20605. });
  20606. /* eslint-enable no-invalid-this */
  20607. };
  20608. /* *
  20609. *
  20610. * Static Properties
  20611. *
  20612. * */
  20613. DateTimeAxis.AdditionsClass = DateTimeAxisAdditions;
  20614. return DateTimeAxis;
  20615. }());
  20616. DateTimeAxis.compose(Axis);
  20617. return DateTimeAxis;
  20618. });
  20619. _registerModule(_modules, 'Core/Axis/LogarithmicAxis.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Utilities.js']], function (Axis, U) {
  20620. /* *
  20621. *
  20622. * (c) 2010-2020 Torstein Honsi
  20623. *
  20624. * License: www.highcharts.com/license
  20625. *
  20626. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  20627. *
  20628. * */
  20629. var addEvent = U.addEvent,
  20630. getMagnitude = U.getMagnitude,
  20631. normalizeTickInterval = U.normalizeTickInterval,
  20632. pick = U.pick;
  20633. /* eslint-disable valid-jsdoc */
  20634. /**
  20635. * Provides logarithmic support for axes.
  20636. *
  20637. * @private
  20638. * @class
  20639. */
  20640. var LogarithmicAxisAdditions = /** @class */ (function () {
  20641. /* *
  20642. *
  20643. * Constructors
  20644. *
  20645. * */
  20646. function LogarithmicAxisAdditions(axis) {
  20647. this.axis = axis;
  20648. }
  20649. /* *
  20650. *
  20651. * Functions
  20652. *
  20653. * */
  20654. /**
  20655. * Set the tick positions of a logarithmic axis.
  20656. */
  20657. LogarithmicAxisAdditions.prototype.getLogTickPositions = function (interval, min, max, minor) {
  20658. var log = this;
  20659. var axis = log.axis;
  20660. var axisLength = axis.len;
  20661. var options = axis.options;
  20662. // Since we use this method for both major and minor ticks,
  20663. // use a local variable and return the result
  20664. var positions = [];
  20665. // Reset
  20666. if (!minor) {
  20667. log.minorAutoInterval = void 0;
  20668. }
  20669. // First case: All ticks fall on whole logarithms: 1, 10, 100 etc.
  20670. if (interval >= 0.5) {
  20671. interval = Math.round(interval);
  20672. positions = axis.getLinearTickPositions(interval, min, max);
  20673. // Second case: We need intermediary ticks. For example
  20674. // 1, 2, 4, 6, 8, 10, 20, 40 etc.
  20675. }
  20676. else if (interval >= 0.08) {
  20677. var roundedMin = Math.floor(min),
  20678. intermediate,
  20679. i,
  20680. j,
  20681. len,
  20682. pos,
  20683. lastPos,
  20684. break2;
  20685. if (interval > 0.3) {
  20686. intermediate = [1, 2, 4];
  20687. // 0.2 equals five minor ticks per 1, 10, 100 etc
  20688. }
  20689. else if (interval > 0.15) {
  20690. intermediate = [1, 2, 4, 6, 8];
  20691. }
  20692. else { // 0.1 equals ten minor ticks per 1, 10, 100 etc
  20693. intermediate = [1, 2, 3, 4, 5, 6, 7, 8, 9];
  20694. }
  20695. for (i = roundedMin; i < max + 1 && !break2; i++) {
  20696. len = intermediate.length;
  20697. for (j = 0; j < len && !break2; j++) {
  20698. pos = log.log2lin(log.lin2log(i) * intermediate[j]);
  20699. // #1670, lastPos is #3113
  20700. if (pos > min &&
  20701. (!minor || lastPos <= max) &&
  20702. typeof lastPos !== 'undefined') {
  20703. positions.push(lastPos);
  20704. }
  20705. if (lastPos > max) {
  20706. break2 = true;
  20707. }
  20708. lastPos = pos;
  20709. }
  20710. }
  20711. // Third case: We are so deep in between whole logarithmic values that
  20712. // we might as well handle the tick positions like a linear axis. For
  20713. // example 1.01, 1.02, 1.03, 1.04.
  20714. }
  20715. else {
  20716. var realMin = log.lin2log(min),
  20717. realMax = log.lin2log(max),
  20718. tickIntervalOption = minor ?
  20719. axis.getMinorTickInterval() :
  20720. options.tickInterval,
  20721. filteredTickIntervalOption = tickIntervalOption === 'auto' ?
  20722. null :
  20723. tickIntervalOption,
  20724. tickPixelIntervalOption = options.tickPixelInterval / (minor ? 5 : 1),
  20725. totalPixelLength = minor ?
  20726. axisLength / axis.tickPositions.length :
  20727. axisLength;
  20728. interval = pick(filteredTickIntervalOption, log.minorAutoInterval, (realMax - realMin) *
  20729. tickPixelIntervalOption / (totalPixelLength || 1));
  20730. interval = normalizeTickInterval(interval, void 0, getMagnitude(interval));
  20731. positions = axis.getLinearTickPositions(interval, realMin, realMax).map(log.log2lin);
  20732. if (!minor) {
  20733. log.minorAutoInterval = interval / 5;
  20734. }
  20735. }
  20736. // Set the axis-level tickInterval variable
  20737. if (!minor) {
  20738. axis.tickInterval = interval;
  20739. }
  20740. return positions;
  20741. };
  20742. LogarithmicAxisAdditions.prototype.lin2log = function (num) {
  20743. return Math.pow(10, num);
  20744. };
  20745. LogarithmicAxisAdditions.prototype.log2lin = function (num) {
  20746. return Math.log(num) / Math.LN10;
  20747. };
  20748. return LogarithmicAxisAdditions;
  20749. }());
  20750. var LogarithmicAxis = /** @class */ (function () {
  20751. function LogarithmicAxis() {
  20752. }
  20753. /**
  20754. * Provides logarithmic support for axes.
  20755. *
  20756. * @private
  20757. */
  20758. LogarithmicAxis.compose = function (AxisClass) {
  20759. AxisClass.keepProps.push('logarithmic');
  20760. // HC <= 8 backwards compatibility, allow wrapping
  20761. // Axis.prototype.lin2log and log2lin
  20762. // @todo Remove this in next major
  20763. var axisProto = AxisClass.prototype;
  20764. var logAxisProto = LogarithmicAxisAdditions.prototype;
  20765. axisProto.log2lin = logAxisProto.log2lin;
  20766. axisProto.lin2log = logAxisProto.lin2log;
  20767. /* eslint-disable no-invalid-this */
  20768. addEvent(AxisClass, 'init', function (e) {
  20769. var axis = this;
  20770. var options = e.userOptions;
  20771. var logarithmic = axis.logarithmic;
  20772. if (options.type !== 'logarithmic') {
  20773. axis.logarithmic = void 0;
  20774. }
  20775. else {
  20776. if (!logarithmic) {
  20777. logarithmic = axis.logarithmic = new LogarithmicAxisAdditions(axis);
  20778. }
  20779. // HC <= 8 backwards compatibility, allow wrapping
  20780. // Axis.prototype.lin2log and log2lin
  20781. // @todo Remove this in next major
  20782. if (axis.log2lin !== logarithmic.log2lin) {
  20783. logarithmic.log2lin = axis.log2lin.bind(axis);
  20784. }
  20785. if (axis.lin2log !== logarithmic.lin2log) {
  20786. logarithmic.lin2log = axis.lin2log.bind(axis);
  20787. }
  20788. }
  20789. });
  20790. addEvent(AxisClass, 'afterInit', function () {
  20791. var axis = this;
  20792. var log = axis.logarithmic;
  20793. // extend logarithmic axis
  20794. if (log) {
  20795. axis.lin2val = function (num) {
  20796. return log.lin2log(num);
  20797. };
  20798. axis.val2lin = function (num) {
  20799. return log.log2lin(num);
  20800. };
  20801. }
  20802. });
  20803. };
  20804. return LogarithmicAxis;
  20805. }());
  20806. LogarithmicAxis.compose(Axis); // @todo move to factory functions
  20807. return LogarithmicAxis;
  20808. });
  20809. _registerModule(_modules, 'Core/Axis/PlotLineOrBand.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (Axis, H, U) {
  20810. /* *
  20811. *
  20812. * (c) 2010-2020 Torstein Honsi
  20813. *
  20814. * License: www.highcharts.com/license
  20815. *
  20816. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  20817. *
  20818. * */
  20819. /**
  20820. * Options for plot bands on axes.
  20821. *
  20822. * @typedef {Highcharts.XAxisPlotBandsOptions|Highcharts.YAxisPlotBandsOptions|Highcharts.ZAxisPlotBandsOptions} Highcharts.AxisPlotBandsOptions
  20823. */
  20824. /**
  20825. * Options for plot band labels on axes.
  20826. *
  20827. * @typedef {Highcharts.XAxisPlotBandsLabelOptions|Highcharts.YAxisPlotBandsLabelOptions|Highcharts.ZAxisPlotBandsLabelOptions} Highcharts.AxisPlotBandsLabelOptions
  20828. */
  20829. /**
  20830. * Options for plot lines on axes.
  20831. *
  20832. * @typedef {Highcharts.XAxisPlotLinesOptions|Highcharts.YAxisPlotLinesOptions|Highcharts.ZAxisPlotLinesOptions} Highcharts.AxisPlotLinesOptions
  20833. */
  20834. /**
  20835. * Options for plot line labels on axes.
  20836. *
  20837. * @typedef {Highcharts.XAxisPlotLinesLabelOptions|Highcharts.YAxisPlotLinesLabelOptions|Highcharts.ZAxisPlotLinesLabelOptions} Highcharts.AxisPlotLinesLabelOptions
  20838. */
  20839. var arrayMax = U.arrayMax,
  20840. arrayMin = U.arrayMin,
  20841. defined = U.defined,
  20842. destroyObjectProperties = U.destroyObjectProperties,
  20843. erase = U.erase,
  20844. extend = U.extend,
  20845. merge = U.merge,
  20846. objectEach = U.objectEach,
  20847. pick = U.pick;
  20848. /* eslint-disable no-invalid-this, valid-jsdoc */
  20849. /**
  20850. * The object wrapper for plot lines and plot bands
  20851. *
  20852. * @class
  20853. * @name Highcharts.PlotLineOrBand
  20854. *
  20855. * @param {Highcharts.Axis} axis
  20856. *
  20857. * @param {Highcharts.AxisPlotLinesOptions|Highcharts.AxisPlotBandsOptions} [options]
  20858. */
  20859. var PlotLineOrBand = /** @class */ (function () {
  20860. function PlotLineOrBand(axis, options) {
  20861. this.axis = axis;
  20862. if (options) {
  20863. this.options = options;
  20864. this.id = options.id;
  20865. }
  20866. }
  20867. /**
  20868. * Render the plot line or plot band. If it is already existing,
  20869. * move it.
  20870. *
  20871. * @private
  20872. * @function Highcharts.PlotLineOrBand#render
  20873. * @return {Highcharts.PlotLineOrBand|undefined}
  20874. */
  20875. PlotLineOrBand.prototype.render = function () {
  20876. H.fireEvent(this, 'render');
  20877. var plotLine = this,
  20878. axis = plotLine.axis,
  20879. horiz = axis.horiz,
  20880. log = axis.logarithmic,
  20881. options = plotLine.options,
  20882. optionsLabel = options.label,
  20883. label = plotLine.label,
  20884. to = options.to,
  20885. from = options.from,
  20886. value = options.value,
  20887. isBand = defined(from) && defined(to),
  20888. isLine = defined(value),
  20889. svgElem = plotLine.svgElem,
  20890. isNew = !svgElem,
  20891. path = [],
  20892. color = options.color,
  20893. zIndex = pick(options.zIndex, 0),
  20894. events = options.events,
  20895. attribs = {
  20896. 'class': 'highcharts-plot-' + (isBand ? 'band ' : 'line ') +
  20897. (options.className || '')
  20898. },
  20899. groupAttribs = {},
  20900. renderer = axis.chart.renderer,
  20901. groupName = isBand ? 'bands' : 'lines',
  20902. group;
  20903. // logarithmic conversion
  20904. if (log) {
  20905. from = log.log2lin(from);
  20906. to = log.log2lin(to);
  20907. value = log.log2lin(value);
  20908. }
  20909. // Set the presentational attributes
  20910. if (!axis.chart.styledMode) {
  20911. if (isLine) {
  20912. attribs.stroke = color || '#999999';
  20913. attribs['stroke-width'] = pick(options.width, 1);
  20914. if (options.dashStyle) {
  20915. attribs.dashstyle =
  20916. options.dashStyle;
  20917. }
  20918. }
  20919. else if (isBand) { // plot band
  20920. attribs.fill = color || '#e6ebf5';
  20921. if (options.borderWidth) {
  20922. attribs.stroke = options.borderColor;
  20923. attribs['stroke-width'] = options.borderWidth;
  20924. }
  20925. }
  20926. }
  20927. // Grouping and zIndex
  20928. groupAttribs.zIndex = zIndex;
  20929. groupName += '-' + zIndex;
  20930. group = axis.plotLinesAndBandsGroups[groupName];
  20931. if (!group) {
  20932. axis.plotLinesAndBandsGroups[groupName] = group =
  20933. renderer.g('plot-' + groupName)
  20934. .attr(groupAttribs).add();
  20935. }
  20936. // Create the path
  20937. if (isNew) {
  20938. /**
  20939. * SVG element of the plot line or band.
  20940. *
  20941. * @name Highcharts.PlotLineOrBand#svgElement
  20942. * @type {Highcharts.SVGElement}
  20943. */
  20944. plotLine.svgElem = svgElem = renderer
  20945. .path()
  20946. .attr(attribs)
  20947. .add(group);
  20948. }
  20949. // Set the path or return
  20950. if (isLine) {
  20951. path = axis.getPlotLinePath({
  20952. value: value,
  20953. lineWidth: svgElem.strokeWidth(),
  20954. acrossPanes: options.acrossPanes
  20955. });
  20956. }
  20957. else if (isBand) { // plot band
  20958. path = axis.getPlotBandPath(from, to, options);
  20959. }
  20960. else {
  20961. return;
  20962. }
  20963. // common for lines and bands
  20964. // Add events only if they were not added before.
  20965. if (!plotLine.eventsAdded && events) {
  20966. objectEach(events, function (event, eventType) {
  20967. svgElem.on(eventType, function (e) {
  20968. events[eventType].apply(plotLine, [e]);
  20969. });
  20970. });
  20971. plotLine.eventsAdded = true;
  20972. }
  20973. if ((isNew || !svgElem.d) && path && path.length) {
  20974. svgElem.attr({ d: path });
  20975. }
  20976. else if (svgElem) {
  20977. if (path) {
  20978. svgElem.show(true);
  20979. svgElem.animate({ d: path });
  20980. }
  20981. else if (svgElem.d) {
  20982. svgElem.hide();
  20983. if (label) {
  20984. plotLine.label = label = label.destroy();
  20985. }
  20986. }
  20987. }
  20988. // the plot band/line label
  20989. if (optionsLabel &&
  20990. (defined(optionsLabel.text) || defined(optionsLabel.formatter)) &&
  20991. path &&
  20992. path.length &&
  20993. axis.width > 0 &&
  20994. axis.height > 0 &&
  20995. !path.isFlat) {
  20996. // apply defaults
  20997. optionsLabel = merge({
  20998. align: horiz && isBand && 'center',
  20999. x: horiz ? !isBand && 4 : 10,
  21000. verticalAlign: !horiz && isBand && 'middle',
  21001. y: horiz ? isBand ? 16 : 10 : isBand ? 6 : -4,
  21002. rotation: horiz && !isBand && 90
  21003. }, optionsLabel);
  21004. this.renderLabel(optionsLabel, path, isBand, zIndex);
  21005. }
  21006. else if (label) { // move out of sight
  21007. label.hide();
  21008. }
  21009. // chainable
  21010. return plotLine;
  21011. };
  21012. /**
  21013. * Render and align label for plot line or band.
  21014. *
  21015. * @private
  21016. * @function Highcharts.PlotLineOrBand#renderLabel
  21017. * @param {Highcharts.AxisPlotLinesLabelOptions|Highcharts.AxisPlotBandsLabelOptions} optionsLabel
  21018. * @param {Highcharts.SVGPathArray} path
  21019. * @param {boolean} [isBand]
  21020. * @param {number} [zIndex]
  21021. * @return {void}
  21022. */
  21023. PlotLineOrBand.prototype.renderLabel = function (optionsLabel, path, isBand, zIndex) {
  21024. var plotLine = this,
  21025. label = plotLine.label,
  21026. renderer = plotLine.axis.chart.renderer,
  21027. attribs,
  21028. xBounds,
  21029. yBounds,
  21030. x,
  21031. y,
  21032. labelText;
  21033. // add the SVG element
  21034. if (!label) {
  21035. attribs = {
  21036. align: optionsLabel.textAlign || optionsLabel.align,
  21037. rotation: optionsLabel.rotation,
  21038. 'class': 'highcharts-plot-' + (isBand ? 'band' : 'line') +
  21039. '-label ' + (optionsLabel.className || '')
  21040. };
  21041. attribs.zIndex = zIndex;
  21042. labelText = this.getLabelText(optionsLabel);
  21043. /**
  21044. * SVG element of the label.
  21045. *
  21046. * @name Highcharts.PlotLineOrBand#label
  21047. * @type {Highcharts.SVGElement}
  21048. */
  21049. plotLine.label = label = renderer
  21050. .text(labelText, 0, 0, optionsLabel.useHTML)
  21051. .attr(attribs)
  21052. .add();
  21053. if (!this.axis.chart.styledMode) {
  21054. label.css(optionsLabel.style);
  21055. }
  21056. }
  21057. // get the bounding box and align the label
  21058. // #3000 changed to better handle choice between plotband or plotline
  21059. xBounds = path.xBounds ||
  21060. [path[0][1], path[1][1], (isBand ? path[2][1] : path[0][1])];
  21061. yBounds = path.yBounds ||
  21062. [path[0][2], path[1][2], (isBand ? path[2][2] : path[0][2])];
  21063. x = arrayMin(xBounds);
  21064. y = arrayMin(yBounds);
  21065. label.align(optionsLabel, false, {
  21066. x: x,
  21067. y: y,
  21068. width: arrayMax(xBounds) - x,
  21069. height: arrayMax(yBounds) - y
  21070. });
  21071. label.show(true);
  21072. };
  21073. /**
  21074. * Get label's text content.
  21075. *
  21076. * @private
  21077. * @function Highcharts.PlotLineOrBand#getLabelText
  21078. * @param {Highcharts.AxisPlotLinesLabelOptions|Highcharts.AxisPlotBandsLabelOptions} optionsLabel
  21079. * @return {string}
  21080. */
  21081. PlotLineOrBand.prototype.getLabelText = function (optionsLabel) {
  21082. return defined(optionsLabel.formatter) ?
  21083. optionsLabel.formatter
  21084. .call(this) :
  21085. optionsLabel.text;
  21086. };
  21087. /**
  21088. * Remove the plot line or band.
  21089. *
  21090. * @function Highcharts.PlotLineOrBand#destroy
  21091. * @return {void}
  21092. */
  21093. PlotLineOrBand.prototype.destroy = function () {
  21094. // remove it from the lookup
  21095. erase(this.axis.plotLinesAndBands, this);
  21096. delete this.axis;
  21097. destroyObjectProperties(this);
  21098. };
  21099. return PlotLineOrBand;
  21100. }());
  21101. /* eslint-enable no-invalid-this, valid-jsdoc */
  21102. // Object with members for extending the Axis prototype
  21103. extend(Axis.prototype, /** @lends Highcharts.Axis.prototype */ {
  21104. /**
  21105. * An array of colored bands stretching across the plot area marking an
  21106. * interval on the axis.
  21107. *
  21108. * In styled mode, the plot bands are styled by the `.highcharts-plot-band`
  21109. * class in addition to the `className` option.
  21110. *
  21111. * @productdesc {highcharts}
  21112. * In a gauge, a plot band on the Y axis (value axis) will stretch along the
  21113. * perimeter of the gauge.
  21114. *
  21115. * @type {Array<*>}
  21116. * @product highcharts highstock gantt
  21117. * @apioption xAxis.plotBands
  21118. */
  21119. /**
  21120. * Flag to decide if plotBand should be rendered across all panes.
  21121. *
  21122. * @since 7.1.2
  21123. * @product highstock
  21124. * @type {boolean}
  21125. * @default true
  21126. * @apioption xAxis.plotBands.acrossPanes
  21127. */
  21128. /**
  21129. * Border color for the plot band. Also requires `borderWidth` to be set.
  21130. *
  21131. * @type {Highcharts.ColorString}
  21132. * @apioption xAxis.plotBands.borderColor
  21133. */
  21134. /**
  21135. * Border width for the plot band. Also requires `borderColor` to be set.
  21136. *
  21137. * @type {number}
  21138. * @default 0
  21139. * @apioption xAxis.plotBands.borderWidth
  21140. */
  21141. /**
  21142. * A custom class name, in addition to the default `highcharts-plot-band`,
  21143. * to apply to each individual band.
  21144. *
  21145. * @type {string}
  21146. * @since 5.0.0
  21147. * @apioption xAxis.plotBands.className
  21148. */
  21149. /**
  21150. * The color of the plot band.
  21151. *
  21152. * @sample {highcharts} highcharts/xaxis/plotbands-color/
  21153. * Color band
  21154. * @sample {highstock} stock/xaxis/plotbands/
  21155. * Plot band on Y axis
  21156. *
  21157. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  21158. * @default #e6ebf5
  21159. * @apioption xAxis.plotBands.color
  21160. */
  21161. /**
  21162. * An object defining mouse events for the plot band. Supported properties
  21163. * are `click`, `mouseover`, `mouseout`, `mousemove`.
  21164. *
  21165. * @sample {highcharts} highcharts/xaxis/plotbands-events/
  21166. * Mouse events demonstrated
  21167. *
  21168. * @since 1.2
  21169. * @apioption xAxis.plotBands.events
  21170. */
  21171. /**
  21172. * Click event on a plot band.
  21173. *
  21174. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  21175. * @apioption xAxis.plotBands.events.click
  21176. */
  21177. /**
  21178. * Mouse move event on a plot band.
  21179. *
  21180. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  21181. * @apioption xAxis.plotBands.events.mousemove
  21182. */
  21183. /**
  21184. * Mouse out event on the corner of a plot band.
  21185. *
  21186. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  21187. * @apioption xAxis.plotBands.events.mouseout
  21188. */
  21189. /**
  21190. * Mouse over event on a plot band.
  21191. *
  21192. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  21193. * @apioption xAxis.plotBands.events.mouseover
  21194. */
  21195. /**
  21196. * The start position of the plot band in axis units.
  21197. *
  21198. * @sample {highcharts} highcharts/xaxis/plotbands-color/
  21199. * Datetime axis
  21200. * @sample {highcharts} highcharts/xaxis/plotbands-from/
  21201. * Categorized axis
  21202. * @sample {highstock} stock/xaxis/plotbands/
  21203. * Plot band on Y axis
  21204. *
  21205. * @type {number}
  21206. * @apioption xAxis.plotBands.from
  21207. */
  21208. /**
  21209. * An id used for identifying the plot band in Axis.removePlotBand.
  21210. *
  21211. * @sample {highcharts} highcharts/xaxis/plotbands-id/
  21212. * Remove plot band by id
  21213. * @sample {highstock} highcharts/xaxis/plotbands-id/
  21214. * Remove plot band by id
  21215. *
  21216. * @type {string}
  21217. * @apioption xAxis.plotBands.id
  21218. */
  21219. /**
  21220. * The end position of the plot band in axis units.
  21221. *
  21222. * @sample {highcharts} highcharts/xaxis/plotbands-color/
  21223. * Datetime axis
  21224. * @sample {highcharts} highcharts/xaxis/plotbands-from/
  21225. * Categorized axis
  21226. * @sample {highstock} stock/xaxis/plotbands/
  21227. * Plot band on Y axis
  21228. *
  21229. * @type {number}
  21230. * @apioption xAxis.plotBands.to
  21231. */
  21232. /**
  21233. * The z index of the plot band within the chart, relative to other
  21234. * elements. Using the same z index as another element may give
  21235. * unpredictable results, as the last rendered element will be on top.
  21236. * Values from 0 to 20 make sense.
  21237. *
  21238. * @sample {highcharts} highcharts/xaxis/plotbands-color/
  21239. * Behind plot lines by default
  21240. * @sample {highcharts} highcharts/xaxis/plotbands-zindex/
  21241. * Above plot lines
  21242. * @sample {highcharts} highcharts/xaxis/plotbands-zindex-above-series/
  21243. * Above plot lines and series
  21244. *
  21245. * @type {number}
  21246. * @since 1.2
  21247. * @apioption xAxis.plotBands.zIndex
  21248. */
  21249. /**
  21250. * Text labels for the plot bands
  21251. *
  21252. * @product highcharts highstock gantt
  21253. * @apioption xAxis.plotBands.label
  21254. */
  21255. /**
  21256. * Horizontal alignment of the label. Can be one of "left", "center" or
  21257. * "right".
  21258. *
  21259. * @sample {highcharts} highcharts/xaxis/plotbands-label-align/
  21260. * Aligned to the right
  21261. * @sample {highstock} stock/xaxis/plotbands-label/
  21262. * Plot band with labels
  21263. *
  21264. * @type {Highcharts.AlignValue}
  21265. * @default center
  21266. * @since 2.1
  21267. * @apioption xAxis.plotBands.label.align
  21268. */
  21269. /**
  21270. * Rotation of the text label in degrees .
  21271. *
  21272. * @sample {highcharts} highcharts/xaxis/plotbands-label-rotation/
  21273. * Vertical text
  21274. *
  21275. * @type {number}
  21276. * @default 0
  21277. * @since 2.1
  21278. * @apioption xAxis.plotBands.label.rotation
  21279. */
  21280. /**
  21281. * CSS styles for the text label.
  21282. *
  21283. * In styled mode, the labels are styled by the
  21284. * `.highcharts-plot-band-label` class.
  21285. *
  21286. * @sample {highcharts} highcharts/xaxis/plotbands-label-style/
  21287. * Blue and bold label
  21288. *
  21289. * @type {Highcharts.CSSObject}
  21290. * @since 2.1
  21291. * @apioption xAxis.plotBands.label.style
  21292. */
  21293. /**
  21294. * The string text itself. A subset of HTML is supported.
  21295. *
  21296. * @type {string}
  21297. * @since 2.1
  21298. * @apioption xAxis.plotBands.label.text
  21299. */
  21300. /**
  21301. * The text alignment for the label. While `align` determines where the
  21302. * texts anchor point is placed within the plot band, `textAlign` determines
  21303. * how the text is aligned against its anchor point. Possible values are
  21304. * "left", "center" and "right". Defaults to the same as the `align` option.
  21305. *
  21306. * @sample {highcharts} highcharts/xaxis/plotbands-label-rotation/
  21307. * Vertical text in center position but text-aligned left
  21308. *
  21309. * @type {Highcharts.AlignValue}
  21310. * @since 2.1
  21311. * @apioption xAxis.plotBands.label.textAlign
  21312. */
  21313. /**
  21314. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  21315. * to render the labels.
  21316. *
  21317. * @type {boolean}
  21318. * @default false
  21319. * @since 3.0.3
  21320. * @apioption xAxis.plotBands.label.useHTML
  21321. */
  21322. /**
  21323. * Vertical alignment of the label relative to the plot band. Can be one of
  21324. * "top", "middle" or "bottom".
  21325. *
  21326. * @sample {highcharts} highcharts/xaxis/plotbands-label-verticalalign/
  21327. * Vertically centered label
  21328. * @sample {highstock} stock/xaxis/plotbands-label/
  21329. * Plot band with labels
  21330. *
  21331. * @type {Highcharts.VerticalAlignValue}
  21332. * @default top
  21333. * @since 2.1
  21334. * @apioption xAxis.plotBands.label.verticalAlign
  21335. */
  21336. /**
  21337. * Horizontal position relative the alignment. Default varies by
  21338. * orientation.
  21339. *
  21340. * @sample {highcharts} highcharts/xaxis/plotbands-label-align/
  21341. * Aligned 10px from the right edge
  21342. * @sample {highstock} stock/xaxis/plotbands-label/
  21343. * Plot band with labels
  21344. *
  21345. * @type {number}
  21346. * @since 2.1
  21347. * @apioption xAxis.plotBands.label.x
  21348. */
  21349. /**
  21350. * Vertical position of the text baseline relative to the alignment. Default
  21351. * varies by orientation.
  21352. *
  21353. * @sample {highcharts} highcharts/xaxis/plotbands-label-y/
  21354. * Label on x axis
  21355. * @sample {highstock} stock/xaxis/plotbands-label/
  21356. * Plot band with labels
  21357. *
  21358. * @type {number}
  21359. * @since 2.1
  21360. * @apioption xAxis.plotBands.label.y
  21361. */
  21362. /**
  21363. * An array of lines stretching across the plot area, marking a specific
  21364. * value on one of the axes.
  21365. *
  21366. * In styled mode, the plot lines are styled by the
  21367. * `.highcharts-plot-line` class in addition to the `className` option.
  21368. *
  21369. * @type {Array<*>}
  21370. * @product highcharts highstock gantt
  21371. * @sample {highcharts} highcharts/xaxis/plotlines-color/
  21372. * Basic plot line
  21373. * @sample {highcharts} highcharts/series-solidgauge/labels-auto-aligned/
  21374. * Solid gauge plot line
  21375. * @apioption xAxis.plotLines
  21376. */
  21377. /**
  21378. * Flag to decide if plotLine should be rendered across all panes.
  21379. *
  21380. * @sample {highstock} stock/xaxis/plotlines-acrosspanes/
  21381. * Plot lines on different panes
  21382. *
  21383. * @since 7.1.2
  21384. * @product highstock
  21385. * @type {boolean}
  21386. * @default true
  21387. * @apioption xAxis.plotLines.acrossPanes
  21388. */
  21389. /**
  21390. * A custom class name, in addition to the default `highcharts-plot-line`,
  21391. * to apply to each individual line.
  21392. *
  21393. * @type {string}
  21394. * @since 5.0.0
  21395. * @apioption xAxis.plotLines.className
  21396. */
  21397. /**
  21398. * The color of the line.
  21399. *
  21400. * @sample {highcharts} highcharts/xaxis/plotlines-color/
  21401. * A red line from X axis
  21402. * @sample {highstock} stock/xaxis/plotlines/
  21403. * Plot line on Y axis
  21404. *
  21405. * @type {Highcharts.ColorString}
  21406. * @default #999999
  21407. * @apioption xAxis.plotLines.color
  21408. */
  21409. /**
  21410. * The dashing or dot style for the plot line. For possible values see
  21411. * [this overview](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-dashstyle-all/).
  21412. *
  21413. * @sample {highcharts} highcharts/xaxis/plotlines-dashstyle/
  21414. * Dash and dot pattern
  21415. * @sample {highstock} stock/xaxis/plotlines/
  21416. * Plot line on Y axis
  21417. *
  21418. * @type {Highcharts.DashStyleValue}
  21419. * @default Solid
  21420. * @since 1.2
  21421. * @apioption xAxis.plotLines.dashStyle
  21422. */
  21423. /**
  21424. * An object defining mouse events for the plot line. Supported
  21425. * properties are `click`, `mouseover`, `mouseout`, `mousemove`.
  21426. *
  21427. * @sample {highcharts} highcharts/xaxis/plotlines-events/
  21428. * Mouse events demonstrated
  21429. *
  21430. * @since 1.2
  21431. * @apioption xAxis.plotLines.events
  21432. */
  21433. /**
  21434. * Click event on a plot band.
  21435. *
  21436. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  21437. * @apioption xAxis.plotLines.events.click
  21438. */
  21439. /**
  21440. * Mouse move event on a plot band.
  21441. *
  21442. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  21443. * @apioption xAxis.plotLines.events.mousemove
  21444. */
  21445. /**
  21446. * Mouse out event on the corner of a plot band.
  21447. *
  21448. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  21449. * @apioption xAxis.plotLines.events.mouseout
  21450. */
  21451. /**
  21452. * Mouse over event on a plot band.
  21453. *
  21454. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  21455. * @apioption xAxis.plotLines.events.mouseover
  21456. */
  21457. /**
  21458. * An id used for identifying the plot line in Axis.removePlotLine.
  21459. *
  21460. * @sample {highcharts} highcharts/xaxis/plotlines-id/
  21461. * Remove plot line by id
  21462. *
  21463. * @type {string}
  21464. * @apioption xAxis.plotLines.id
  21465. */
  21466. /**
  21467. * The position of the line in axis units.
  21468. *
  21469. * @sample {highcharts} highcharts/xaxis/plotlines-color/
  21470. * Between two categories on X axis
  21471. * @sample {highstock} stock/xaxis/plotlines/
  21472. * Plot line on Y axis
  21473. *
  21474. * @type {number}
  21475. * @apioption xAxis.plotLines.value
  21476. */
  21477. /**
  21478. * The width or thickness of the plot line.
  21479. *
  21480. * @sample {highcharts} highcharts/xaxis/plotlines-color/
  21481. * 2px wide line from X axis
  21482. * @sample {highstock} stock/xaxis/plotlines/
  21483. * Plot line on Y axis
  21484. *
  21485. * @type {number}
  21486. * @default 2
  21487. * @apioption xAxis.plotLines.width
  21488. */
  21489. /**
  21490. * The z index of the plot line within the chart.
  21491. *
  21492. * @sample {highcharts} highcharts/xaxis/plotlines-zindex-behind/
  21493. * Behind plot lines by default
  21494. * @sample {highcharts} highcharts/xaxis/plotlines-zindex-above/
  21495. * Above plot lines
  21496. * @sample {highcharts} highcharts/xaxis/plotlines-zindex-above-all/
  21497. * Above plot lines and series
  21498. *
  21499. * @type {number}
  21500. * @since 1.2
  21501. * @apioption xAxis.plotLines.zIndex
  21502. */
  21503. /**
  21504. * Text labels for the plot bands
  21505. *
  21506. * @apioption xAxis.plotLines.label
  21507. */
  21508. /**
  21509. * Horizontal alignment of the label. Can be one of "left", "center" or
  21510. * "right".
  21511. *
  21512. * @sample {highcharts} highcharts/xaxis/plotlines-label-align-right/
  21513. * Aligned to the right
  21514. * @sample {highstock} stock/xaxis/plotlines/
  21515. * Plot line on Y axis
  21516. *
  21517. * @type {Highcharts.AlignValue}
  21518. * @default left
  21519. * @since 2.1
  21520. * @apioption xAxis.plotLines.label.align
  21521. */
  21522. /**
  21523. * Callback JavaScript function to format the label. Useful properties like
  21524. * the value of plot line or the range of plot band (`from` & `to`
  21525. * properties) can be found in `this.options` object.
  21526. *
  21527. * @sample {highcharts} highcharts/xaxis/plotlines-plotbands-label-formatter
  21528. * Label formatters for plot line and plot band.
  21529. * @type {Highcharts.FormatterCallbackFunction<Highcharts.PlotLineOrBand>}
  21530. * @apioption xAxis.plotLines.label.formatter
  21531. */
  21532. /**
  21533. * Rotation of the text label in degrees. Defaults to 0 for horizontal plot
  21534. * lines and 90 for vertical lines.
  21535. *
  21536. * @sample {highcharts} highcharts/xaxis/plotlines-label-verticalalign-middle/
  21537. * Slanted text
  21538. *
  21539. * @type {number}
  21540. * @since 2.1
  21541. * @apioption xAxis.plotLines.label.rotation
  21542. */
  21543. /**
  21544. * CSS styles for the text label.
  21545. *
  21546. * In styled mode, the labels are styled by the
  21547. * `.highcharts-plot-line-label` class.
  21548. *
  21549. * @sample {highcharts} highcharts/xaxis/plotlines-label-style/
  21550. * Blue and bold label
  21551. *
  21552. * @type {Highcharts.CSSObject}
  21553. * @since 2.1
  21554. * @apioption xAxis.plotLines.label.style
  21555. */
  21556. /**
  21557. * The text itself. A subset of HTML is supported.
  21558. *
  21559. * @type {string}
  21560. * @since 2.1
  21561. * @apioption xAxis.plotLines.label.text
  21562. */
  21563. /**
  21564. * The text alignment for the label. While `align` determines where the
  21565. * texts anchor point is placed within the plot band, `textAlign` determines
  21566. * how the text is aligned against its anchor point. Possible values are
  21567. * "left", "center" and "right". Defaults to the same as the `align` option.
  21568. *
  21569. * @sample {highcharts} highcharts/xaxis/plotlines-label-textalign/
  21570. * Text label in bottom position
  21571. *
  21572. * @type {Highcharts.AlignValue}
  21573. * @since 2.1
  21574. * @apioption xAxis.plotLines.label.textAlign
  21575. */
  21576. /**
  21577. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  21578. * to render the labels.
  21579. *
  21580. * @type {boolean}
  21581. * @default false
  21582. * @since 3.0.3
  21583. * @apioption xAxis.plotLines.label.useHTML
  21584. */
  21585. /**
  21586. * Vertical alignment of the label relative to the plot line. Can be
  21587. * one of "top", "middle" or "bottom".
  21588. *
  21589. * @sample {highcharts} highcharts/xaxis/plotlines-label-verticalalign-middle/
  21590. * Vertically centered label
  21591. *
  21592. * @type {Highcharts.VerticalAlignValue}
  21593. * @default {highcharts} top
  21594. * @default {highstock} top
  21595. * @since 2.1
  21596. * @apioption xAxis.plotLines.label.verticalAlign
  21597. */
  21598. /**
  21599. * Horizontal position relative the alignment. Default varies by
  21600. * orientation.
  21601. *
  21602. * @sample {highcharts} highcharts/xaxis/plotlines-label-align-right/
  21603. * Aligned 10px from the right edge
  21604. * @sample {highstock} stock/xaxis/plotlines/
  21605. * Plot line on Y axis
  21606. *
  21607. * @type {number}
  21608. * @since 2.1
  21609. * @apioption xAxis.plotLines.label.x
  21610. */
  21611. /**
  21612. * Vertical position of the text baseline relative to the alignment. Default
  21613. * varies by orientation.
  21614. *
  21615. * @sample {highcharts} highcharts/xaxis/plotlines-label-y/
  21616. * Label below the plot line
  21617. * @sample {highstock} stock/xaxis/plotlines/
  21618. * Plot line on Y axis
  21619. *
  21620. * @type {number}
  21621. * @since 2.1
  21622. * @apioption xAxis.plotLines.label.y
  21623. */
  21624. /**
  21625. *
  21626. * @type {Array<*>}
  21627. * @extends xAxis.plotBands
  21628. * @apioption yAxis.plotBands
  21629. */
  21630. /**
  21631. * In a gauge chart, this option determines the inner radius of the
  21632. * plot band that stretches along the perimeter. It can be given as
  21633. * a percentage string, like `"100%"`, or as a pixel number, like `100`.
  21634. * By default, the inner radius is controlled by the [thickness](
  21635. * #yAxis.plotBands.thickness) option.
  21636. *
  21637. * @sample {highcharts} highcharts/xaxis/plotbands-gauge
  21638. * Gauge plot band
  21639. *
  21640. * @type {number|string}
  21641. * @since 2.3
  21642. * @product highcharts
  21643. * @apioption yAxis.plotBands.innerRadius
  21644. */
  21645. /**
  21646. * In a gauge chart, this option determines the outer radius of the
  21647. * plot band that stretches along the perimeter. It can be given as
  21648. * a percentage string, like `"100%"`, or as a pixel number, like `100`.
  21649. *
  21650. * @sample {highcharts} highcharts/xaxis/plotbands-gauge
  21651. * Gauge plot band
  21652. *
  21653. * @type {number|string}
  21654. * @default 100%
  21655. * @since 2.3
  21656. * @product highcharts
  21657. * @apioption yAxis.plotBands.outerRadius
  21658. */
  21659. /**
  21660. * In a gauge chart, this option sets the width of the plot band
  21661. * stretching along the perimeter. It can be given as a percentage
  21662. * string, like `"10%"`, or as a pixel number, like `10`. The default
  21663. * value 10 is the same as the default [tickLength](#yAxis.tickLength),
  21664. * thus making the plot band act as a background for the tick markers.
  21665. *
  21666. * @sample {highcharts} highcharts/xaxis/plotbands-gauge
  21667. * Gauge plot band
  21668. *
  21669. * @type {number|string}
  21670. * @default 10
  21671. * @since 2.3
  21672. * @product highcharts
  21673. * @apioption yAxis.plotBands.thickness
  21674. */
  21675. /**
  21676. * @type {Array<*>}
  21677. * @extends xAxis.plotLines
  21678. * @apioption yAxis.plotLines
  21679. */
  21680. /* eslint-disable no-invalid-this, valid-jsdoc */
  21681. /**
  21682. * Internal function to create the SVG path definition for a plot band.
  21683. *
  21684. * @function Highcharts.Axis#getPlotBandPath
  21685. *
  21686. * @param {number} from
  21687. * The axis value to start from.
  21688. *
  21689. * @param {number} to
  21690. * The axis value to end on.
  21691. *
  21692. * @param {Highcharts.AxisPlotBandsOptions|Highcharts.AxisPlotLinesOptions} options
  21693. * The plotBand or plotLine configuration object.
  21694. *
  21695. * @return {Highcharts.SVGPathArray}
  21696. * The SVG path definition in array form.
  21697. */
  21698. getPlotBandPath: function (from, to, options) {
  21699. if (options === void 0) { options = this.options; }
  21700. var toPath = this.getPlotLinePath({
  21701. value: to,
  21702. force: true,
  21703. acrossPanes: options.acrossPanes
  21704. }),
  21705. path = this.getPlotLinePath({
  21706. value: from,
  21707. force: true,
  21708. acrossPanes: options.acrossPanes
  21709. }),
  21710. result = [],
  21711. i,
  21712. // #4964 check if chart is inverted or plotband is on yAxis
  21713. horiz = this.horiz,
  21714. plus = 1,
  21715. isFlat,
  21716. outside = (from < this.min && to < this.min) ||
  21717. (from > this.max && to > this.max);
  21718. if (path && toPath) {
  21719. // Flat paths don't need labels (#3836)
  21720. if (outside) {
  21721. isFlat = path.toString() === toPath.toString();
  21722. plus = 0;
  21723. }
  21724. // Go over each subpath - for panes in Highstock
  21725. for (i = 0; i < path.length; i += 2) {
  21726. var pathStart = path[i],
  21727. pathEnd = path[i + 1],
  21728. toPathStart = toPath[i],
  21729. toPathEnd = toPath[i + 1];
  21730. // Type checking all affected path segments. Consider something
  21731. // smarter.
  21732. if ((pathStart[0] === 'M' || pathStart[0] === 'L') &&
  21733. (pathEnd[0] === 'M' || pathEnd[0] === 'L') &&
  21734. (toPathStart[0] === 'M' || toPathStart[0] === 'L') &&
  21735. (toPathEnd[0] === 'M' || toPathEnd[0] === 'L')) {
  21736. // Add 1 pixel when coordinates are the same
  21737. if (horiz && toPathStart[1] === pathStart[1]) {
  21738. toPathStart[1] += plus;
  21739. toPathEnd[1] += plus;
  21740. }
  21741. else if (!horiz && toPathStart[2] === pathStart[2]) {
  21742. toPathStart[2] += plus;
  21743. toPathEnd[2] += plus;
  21744. }
  21745. result.push(['M', pathStart[1], pathStart[2]], ['L', pathEnd[1], pathEnd[2]], ['L', toPathEnd[1], toPathEnd[2]], ['L', toPathStart[1], toPathStart[2]], ['Z']);
  21746. }
  21747. result.isFlat = isFlat;
  21748. }
  21749. }
  21750. else { // outside the axis area
  21751. path = null;
  21752. }
  21753. return result;
  21754. },
  21755. /**
  21756. * Add a plot band after render time.
  21757. *
  21758. * @sample highcharts/members/axis-addplotband/
  21759. * Toggle the plot band from a button
  21760. *
  21761. * @function Highcharts.Axis#addPlotBand
  21762. *
  21763. * @param {Highcharts.AxisPlotBandsOptions} options
  21764. * A configuration object for the plot band, as defined in
  21765. * [xAxis.plotBands](https://api.highcharts.com/highcharts/xAxis.plotBands).
  21766. *
  21767. * @return {Highcharts.PlotLineOrBand|undefined}
  21768. * The added plot band.
  21769. */
  21770. addPlotBand: function (options) {
  21771. return this.addPlotBandOrLine(options, 'plotBands');
  21772. },
  21773. /**
  21774. * Add a plot line after render time.
  21775. *
  21776. * @sample highcharts/members/axis-addplotline/
  21777. * Toggle the plot line from a button
  21778. *
  21779. * @function Highcharts.Axis#addPlotLine
  21780. *
  21781. * @param {Highcharts.AxisPlotLinesOptions} options
  21782. * A configuration object for the plot line, as defined in
  21783. * [xAxis.plotLines](https://api.highcharts.com/highcharts/xAxis.plotLines).
  21784. *
  21785. * @return {Highcharts.PlotLineOrBand|undefined}
  21786. * The added plot line.
  21787. */
  21788. addPlotLine: function (options) {
  21789. return this.addPlotBandOrLine(options, 'plotLines');
  21790. },
  21791. /**
  21792. * Add a plot band or plot line after render time. Called from addPlotBand
  21793. * and addPlotLine internally.
  21794. *
  21795. * @private
  21796. * @function Highcharts.Axis#addPlotBandOrLine
  21797. *
  21798. * @param {Highcharts.AxisPlotBandsOptions|Highcharts.AxisPlotLinesOptions} options
  21799. * The plotBand or plotLine configuration object.
  21800. *
  21801. * @param {"plotBands"|"plotLines"} [coll]
  21802. *
  21803. * @return {Highcharts.PlotLineOrBand|undefined}
  21804. */
  21805. addPlotBandOrLine: function (options, coll) {
  21806. var obj = new H.PlotLineOrBand(this,
  21807. options),
  21808. userOptions = this.userOptions;
  21809. if (this.visible) {
  21810. obj = obj.render();
  21811. }
  21812. if (obj) { // #2189
  21813. // Add it to the user options for exporting and Axis.update
  21814. if (coll) {
  21815. // Workaround Microsoft/TypeScript issue #32693
  21816. var updatedOptions = (userOptions[coll] || []);
  21817. updatedOptions.push(options);
  21818. userOptions[coll] = updatedOptions;
  21819. }
  21820. this.plotLinesAndBands.push(obj);
  21821. this._addedPlotLB = true;
  21822. }
  21823. return obj;
  21824. },
  21825. /**
  21826. * Remove a plot band or plot line from the chart by id. Called internally
  21827. * from `removePlotBand` and `removePlotLine`.
  21828. *
  21829. * @private
  21830. * @function Highcharts.Axis#removePlotBandOrLine
  21831. * @param {string} id
  21832. * @return {void}
  21833. */
  21834. removePlotBandOrLine: function (id) {
  21835. var plotLinesAndBands = this.plotLinesAndBands,
  21836. options = this.options,
  21837. userOptions = this.userOptions,
  21838. i = plotLinesAndBands.length;
  21839. while (i--) {
  21840. if (plotLinesAndBands[i].id === id) {
  21841. plotLinesAndBands[i].destroy();
  21842. }
  21843. }
  21844. ([
  21845. options.plotLines || [],
  21846. userOptions.plotLines || [],
  21847. options.plotBands || [],
  21848. userOptions.plotBands || []
  21849. ]).forEach(function (arr) {
  21850. i = arr.length;
  21851. while (i--) {
  21852. if ((arr[i] || {}).id === id) {
  21853. erase(arr, arr[i]);
  21854. }
  21855. }
  21856. });
  21857. },
  21858. /**
  21859. * Remove a plot band by its id.
  21860. *
  21861. * @sample highcharts/members/axis-removeplotband/
  21862. * Remove plot band by id
  21863. * @sample highcharts/members/axis-addplotband/
  21864. * Toggle the plot band from a button
  21865. *
  21866. * @function Highcharts.Axis#removePlotBand
  21867. *
  21868. * @param {string} id
  21869. * The plot band's `id` as given in the original configuration
  21870. * object or in the `addPlotBand` option.
  21871. *
  21872. * @return {void}
  21873. */
  21874. removePlotBand: function (id) {
  21875. this.removePlotBandOrLine(id);
  21876. },
  21877. /**
  21878. * Remove a plot line by its id.
  21879. *
  21880. * @sample highcharts/xaxis/plotlines-id/
  21881. * Remove plot line by id
  21882. * @sample highcharts/members/axis-addplotline/
  21883. * Toggle the plot line from a button
  21884. *
  21885. * @function Highcharts.Axis#removePlotLine
  21886. *
  21887. * @param {string} id
  21888. * The plot line's `id` as given in the original configuration
  21889. * object or in the `addPlotLine` option.
  21890. */
  21891. removePlotLine: function (id) {
  21892. this.removePlotBandOrLine(id);
  21893. }
  21894. });
  21895. H.PlotLineOrBand = PlotLineOrBand;
  21896. return H.PlotLineOrBand;
  21897. });
  21898. _registerModule(_modules, 'Core/Tooltip.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  21899. /* *
  21900. *
  21901. * (c) 2010-2020 Torstein Honsi
  21902. *
  21903. * License: www.highcharts.com/license
  21904. *
  21905. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  21906. *
  21907. * */
  21908. var doc = H.doc;
  21909. var clamp = U.clamp,
  21910. css = U.css,
  21911. defined = U.defined,
  21912. discardElement = U.discardElement,
  21913. extend = U.extend,
  21914. fireEvent = U.fireEvent,
  21915. format = U.format,
  21916. isNumber = U.isNumber,
  21917. isString = U.isString,
  21918. merge = U.merge,
  21919. pick = U.pick,
  21920. splat = U.splat,
  21921. syncTimeout = U.syncTimeout,
  21922. timeUnits = U.timeUnits;
  21923. /**
  21924. * Callback function to format the text of the tooltip from scratch.
  21925. *
  21926. * In case of single or shared tooltips, a string should be be returned. In case
  21927. * of splitted tooltips, it should return an array where the first item is the
  21928. * header, and subsequent items are mapped to the points. Return `false` to
  21929. * disable tooltip for a specific point on series.
  21930. *
  21931. * @callback Highcharts.TooltipFormatterCallbackFunction
  21932. *
  21933. * @param {Highcharts.TooltipFormatterContextObject} this
  21934. * Context to format
  21935. *
  21936. * @param {Highcharts.Tooltip} tooltip
  21937. * The tooltip instance
  21938. *
  21939. * @return {false|string|Array<(string|null|undefined)>|null|undefined}
  21940. * Formatted text or false
  21941. */
  21942. /**
  21943. * @interface Highcharts.TooltipFormatterContextObject
  21944. */ /**
  21945. * @name Highcharts.TooltipFormatterContextObject#color
  21946. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  21947. */ /**
  21948. * @name Highcharts.TooltipFormatterContextObject#colorIndex
  21949. * @type {number|undefined}
  21950. */ /**
  21951. * @name Highcharts.TooltipFormatterContextObject#key
  21952. * @type {number}
  21953. */ /**
  21954. * @name Highcharts.TooltipFormatterContextObject#percentage
  21955. * @type {number|undefined}
  21956. */ /**
  21957. * @name Highcharts.TooltipFormatterContextObject#point
  21958. * @type {Highcharts.Point}
  21959. */ /**
  21960. * @name Highcharts.TooltipFormatterContextObject#points
  21961. * @type {Array<Highcharts.TooltipFormatterContextObject>|undefined}
  21962. */ /**
  21963. * @name Highcharts.TooltipFormatterContextObject#series
  21964. * @type {Highcharts.Series}
  21965. */ /**
  21966. * @name Highcharts.TooltipFormatterContextObject#total
  21967. * @type {number|undefined}
  21968. */ /**
  21969. * @name Highcharts.TooltipFormatterContextObject#x
  21970. * @type {number}
  21971. */ /**
  21972. * @name Highcharts.TooltipFormatterContextObject#y
  21973. * @type {number}
  21974. */
  21975. /**
  21976. * A callback function to place the tooltip in a specific position.
  21977. *
  21978. * @callback Highcharts.TooltipPositionerCallbackFunction
  21979. *
  21980. * @param {Highcharts.Tooltip} this
  21981. * Tooltip context of the callback.
  21982. *
  21983. * @param {number} labelWidth
  21984. * Width of the tooltip.
  21985. *
  21986. * @param {number} labelHeight
  21987. * Height of the tooltip.
  21988. *
  21989. * @param {Highcharts.TooltipPositionerPointObject} point
  21990. * Point information for positioning a tooltip.
  21991. *
  21992. * @return {Highcharts.PositionObject}
  21993. * New position for the tooltip.
  21994. */
  21995. /**
  21996. * Point information for positioning a tooltip.
  21997. *
  21998. * @interface Highcharts.TooltipPositionerPointObject
  21999. * @extends Highcharts.Point
  22000. */ /**
  22001. * If `tooltip.split` option is enabled and positioner is called for each of the
  22002. * boxes separately, this property indicates the call on the xAxis header, which
  22003. * is not a point itself.
  22004. * @name Highcharts.TooltipPositionerPointObject#isHeader
  22005. * @type {boolean}
  22006. */ /**
  22007. * The reference point relative to the plot area. Add chart.plotLeft to get the
  22008. * full coordinates.
  22009. * @name Highcharts.TooltipPositionerPointObject#plotX
  22010. * @type {number}
  22011. */ /**
  22012. * The reference point relative to the plot area. Add chart.plotTop to get the
  22013. * full coordinates.
  22014. * @name Highcharts.TooltipPositionerPointObject#plotY
  22015. * @type {number}
  22016. */
  22017. /**
  22018. * @typedef {"callout"|"circle"|"square"} Highcharts.TooltipShapeValue
  22019. */
  22020. ''; // separates doclets above from variables below
  22021. /* eslint-disable no-invalid-this, valid-jsdoc */
  22022. /**
  22023. * Tooltip of a chart.
  22024. *
  22025. * @class
  22026. * @name Highcharts.Tooltip
  22027. *
  22028. * @param {Highcharts.Chart} chart
  22029. * The chart instance.
  22030. *
  22031. * @param {Highcharts.TooltipOptions} options
  22032. * Tooltip options.
  22033. */
  22034. var Tooltip = /** @class */ (function () {
  22035. /* *
  22036. *
  22037. * Constructors
  22038. *
  22039. * */
  22040. function Tooltip(chart, options) {
  22041. this.container = void 0;
  22042. this.crosshairs = [];
  22043. this.distance = 0;
  22044. this.isHidden = true;
  22045. this.isSticky = false;
  22046. this.now = {};
  22047. this.options = {};
  22048. this.outside = false;
  22049. this.chart = chart;
  22050. this.init(chart, options);
  22051. }
  22052. /* *
  22053. *
  22054. * Functions
  22055. *
  22056. * */
  22057. /**
  22058. * In styled mode, apply the default filter for the tooltip drop-shadow. It
  22059. * needs to have an id specific to the chart, otherwise there will be issues
  22060. * when one tooltip adopts the filter of a different chart, specifically one
  22061. * where the container is hidden.
  22062. *
  22063. * @private
  22064. * @function Highcharts.Tooltip#applyFilter
  22065. */
  22066. Tooltip.prototype.applyFilter = function () {
  22067. var chart = this.chart;
  22068. chart.renderer.definition({
  22069. tagName: 'filter',
  22070. id: 'drop-shadow-' + chart.index,
  22071. opacity: 0.5,
  22072. children: [{
  22073. tagName: 'feGaussianBlur',
  22074. 'in': 'SourceAlpha',
  22075. stdDeviation: 1
  22076. }, {
  22077. tagName: 'feOffset',
  22078. dx: 1,
  22079. dy: 1
  22080. }, {
  22081. tagName: 'feComponentTransfer',
  22082. children: [{
  22083. tagName: 'feFuncA',
  22084. type: 'linear',
  22085. slope: 0.3
  22086. }]
  22087. }, {
  22088. tagName: 'feMerge',
  22089. children: [{
  22090. tagName: 'feMergeNode'
  22091. }, {
  22092. tagName: 'feMergeNode',
  22093. 'in': 'SourceGraphic'
  22094. }]
  22095. }]
  22096. });
  22097. chart.renderer.definition({
  22098. tagName: 'style',
  22099. textContent: '.highcharts-tooltip-' + chart.index + '{' +
  22100. 'filter:url(#drop-shadow-' + chart.index + ')' +
  22101. '}'
  22102. });
  22103. };
  22104. /**
  22105. * Build the body (lines) of the tooltip by iterating over the items and
  22106. * returning one entry for each item, abstracting this functionality allows
  22107. * to easily overwrite and extend it.
  22108. *
  22109. * @private
  22110. * @function Highcharts.Tooltip#bodyFormatter
  22111. * @param {Array<(Highcharts.Point|Highcharts.Series)>} items
  22112. * @return {Array<string>}
  22113. */
  22114. Tooltip.prototype.bodyFormatter = function (items) {
  22115. return items.map(function (item) {
  22116. var tooltipOptions = item.series.tooltipOptions;
  22117. return (tooltipOptions[(item.point.formatPrefix || 'point') + 'Formatter'] ||
  22118. item.point.tooltipFormatter).call(item.point, tooltipOptions[(item.point.formatPrefix || 'point') + 'Format'] || '');
  22119. });
  22120. };
  22121. /**
  22122. * Destroy the single tooltips in a split tooltip.
  22123. * If the tooltip is active then it is not destroyed, unless forced to.
  22124. *
  22125. * @private
  22126. * @function Highcharts.Tooltip#cleanSplit
  22127. *
  22128. * @param {boolean} [force]
  22129. * Force destroy all tooltips.
  22130. */
  22131. Tooltip.prototype.cleanSplit = function (force) {
  22132. this.chart.series.forEach(function (series) {
  22133. var tt = series && series.tt;
  22134. if (tt) {
  22135. if (!tt.isActive || force) {
  22136. series.tt = tt.destroy();
  22137. }
  22138. else {
  22139. tt.isActive = false;
  22140. }
  22141. }
  22142. });
  22143. };
  22144. /**
  22145. * In case no user defined formatter is given, this will be used. Note that
  22146. * the context here is an object holding point, series, x, y etc.
  22147. *
  22148. * @function Highcharts.Tooltip#defaultFormatter
  22149. *
  22150. * @param {Highcharts.Tooltip} tooltip
  22151. *
  22152. * @return {Array<string>}
  22153. */
  22154. Tooltip.prototype.defaultFormatter = function (tooltip) {
  22155. var items = this.points || splat(this),
  22156. s;
  22157. // Build the header
  22158. s = [tooltip.tooltipFooterHeaderFormatter(items[0])];
  22159. // build the values
  22160. s = s.concat(tooltip.bodyFormatter(items));
  22161. // footer
  22162. s.push(tooltip.tooltipFooterHeaderFormatter(items[0], true));
  22163. return s;
  22164. };
  22165. /**
  22166. * Removes and destroys the tooltip and its elements.
  22167. *
  22168. * @function Highcharts.Tooltip#destroy
  22169. */
  22170. Tooltip.prototype.destroy = function () {
  22171. // Destroy and clear local variables
  22172. if (this.label) {
  22173. this.label = this.label.destroy();
  22174. }
  22175. if (this.split && this.tt) {
  22176. this.cleanSplit(this.chart, true);
  22177. this.tt = this.tt.destroy();
  22178. }
  22179. if (this.renderer) {
  22180. this.renderer = this.renderer.destroy();
  22181. discardElement(this.container);
  22182. }
  22183. U.clearTimeout(this.hideTimer);
  22184. U.clearTimeout(this.tooltipTimeout);
  22185. };
  22186. /**
  22187. * Extendable method to get the anchor position of the tooltip
  22188. * from a point or set of points
  22189. *
  22190. * @private
  22191. * @function Highcharts.Tooltip#getAnchor
  22192. *
  22193. * @param {Highcharts.Point|Array<Highcharts.Point>} points
  22194. *
  22195. * @param {Highcharts.PointerEventObject} [mouseEvent]
  22196. *
  22197. * @return {Array<number>}
  22198. */
  22199. Tooltip.prototype.getAnchor = function (points, mouseEvent) {
  22200. var ret,
  22201. chart = this.chart,
  22202. pointer = chart.pointer,
  22203. inverted = chart.inverted,
  22204. plotTop = chart.plotTop,
  22205. plotLeft = chart.plotLeft,
  22206. plotX = 0,
  22207. plotY = 0,
  22208. yAxis,
  22209. xAxis;
  22210. points = splat(points);
  22211. // When tooltip follows mouse, relate the position to the mouse
  22212. if (this.followPointer && mouseEvent) {
  22213. if (typeof mouseEvent.chartX === 'undefined') {
  22214. mouseEvent = pointer.normalize(mouseEvent);
  22215. }
  22216. ret = [
  22217. mouseEvent.chartX - plotLeft,
  22218. mouseEvent.chartY - plotTop
  22219. ];
  22220. // Some series types use a specificly calculated tooltip position for
  22221. // each point
  22222. }
  22223. else if (points[0].tooltipPos) {
  22224. ret = points[0].tooltipPos;
  22225. // When shared, use the average position
  22226. }
  22227. else {
  22228. points.forEach(function (point) {
  22229. yAxis = point.series.yAxis;
  22230. xAxis = point.series.xAxis;
  22231. plotX += point.plotX +
  22232. (!inverted && xAxis ? xAxis.left - plotLeft : 0);
  22233. plotY += (point.plotLow ?
  22234. (point.plotLow + point.plotHigh) / 2 :
  22235. point.plotY) + (!inverted && yAxis ? yAxis.top - plotTop : 0); // #1151
  22236. });
  22237. plotX /= points.length;
  22238. plotY /= points.length;
  22239. ret = [
  22240. inverted ? chart.plotWidth - plotY : plotX,
  22241. this.shared && !inverted && points.length > 1 && mouseEvent ?
  22242. // place shared tooltip next to the mouse (#424)
  22243. mouseEvent.chartY - plotTop :
  22244. inverted ? chart.plotHeight - plotX : plotY
  22245. ];
  22246. }
  22247. return ret.map(Math.round);
  22248. };
  22249. /**
  22250. * Get the optimal date format for a point, based on a range.
  22251. *
  22252. * @private
  22253. * @function Highcharts.Tooltip#getDateFormat
  22254. *
  22255. * @param {number} range
  22256. * The time range
  22257. *
  22258. * @param {number} date
  22259. * The date of the point in question
  22260. *
  22261. * @param {number} startOfWeek
  22262. * An integer representing the first day of the week, where 0 is
  22263. * Sunday.
  22264. *
  22265. * @param {Highcharts.Dictionary<string>} dateTimeLabelFormats
  22266. * A map of time units to formats.
  22267. *
  22268. * @return {string}
  22269. * The optimal date format for a point.
  22270. */
  22271. Tooltip.prototype.getDateFormat = function (range, date, startOfWeek, dateTimeLabelFormats) {
  22272. 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 = {
  22273. millisecond: 15,
  22274. second: 12,
  22275. minute: 9,
  22276. hour: 6,
  22277. day: 3
  22278. }, lastN = 'millisecond'; // for sub-millisecond data, #4223
  22279. for (n in timeUnits) { // eslint-disable-line guard-for-in
  22280. // If the range is exactly one week and we're looking at a
  22281. // Sunday/Monday, go for the week format
  22282. if (range === timeUnits.week &&
  22283. +time.dateFormat('%w', date) === startOfWeek &&
  22284. dateStr.substr(6) === blank.substr(6)) {
  22285. n = 'week';
  22286. break;
  22287. }
  22288. // The first format that is too great for the range
  22289. if (timeUnits[n] > range) {
  22290. n = lastN;
  22291. break;
  22292. }
  22293. // If the point is placed every day at 23:59, we need to show
  22294. // the minutes as well. #2637.
  22295. if (strpos[n] &&
  22296. dateStr.substr(strpos[n]) !== blank.substr(strpos[n])) {
  22297. break;
  22298. }
  22299. // Weeks are outside the hierarchy, only apply them on
  22300. // Mondays/Sundays like in the first condition
  22301. if (n !== 'week') {
  22302. lastN = n;
  22303. }
  22304. }
  22305. if (n) {
  22306. format = time.resolveDTLFormat(dateTimeLabelFormats[n]).main;
  22307. }
  22308. return format;
  22309. };
  22310. /**
  22311. * Creates the Tooltip label element if it does not exist, then returns it.
  22312. *
  22313. * @function Highcharts.Tooltip#getLabel
  22314. * @return {Highcharts.SVGElement}
  22315. */
  22316. Tooltip.prototype.getLabel = function () {
  22317. var _a,
  22318. _b;
  22319. var tooltip = this,
  22320. renderer = this.chart.renderer,
  22321. styledMode = this.chart.styledMode,
  22322. options = this.options,
  22323. className = ('tooltip' + (defined(options.className) ?
  22324. ' ' + options.className :
  22325. '')),
  22326. pointerEvents = (((_a = options.style) === null || _a === void 0 ? void 0 : _a.pointerEvents) ||
  22327. (!this.followPointer && options.stickOnContact ? 'auto' : 'none')),
  22328. container,
  22329. set,
  22330. onMouseEnter = function () {
  22331. tooltip.inContact = true;
  22332. }, onMouseLeave = function () {
  22333. var series = tooltip.chart.hoverSeries;
  22334. tooltip.inContact = false;
  22335. if (series &&
  22336. series.onMouseOut) {
  22337. series.onMouseOut();
  22338. }
  22339. };
  22340. if (!this.label) {
  22341. if (this.outside) {
  22342. /**
  22343. * Reference to the tooltip's container, when
  22344. * [Highcharts.Tooltip#outside] is set to true, otherwise
  22345. * it's undefined.
  22346. *
  22347. * @name Highcharts.Tooltip#container
  22348. * @type {Highcharts.HTMLDOMElement|undefined}
  22349. */
  22350. this.container = container = H.doc.createElement('div');
  22351. container.className = 'highcharts-tooltip-container';
  22352. css(container, {
  22353. position: 'absolute',
  22354. top: '1px',
  22355. pointerEvents: pointerEvents,
  22356. zIndex: 3
  22357. });
  22358. H.doc.body.appendChild(container);
  22359. /**
  22360. * Reference to the tooltip's renderer, when
  22361. * [Highcharts.Tooltip#outside] is set to true, otherwise
  22362. * it's undefined.
  22363. *
  22364. * @name Highcharts.Tooltip#renderer
  22365. * @type {Highcharts.SVGRenderer|undefined}
  22366. */
  22367. 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);
  22368. }
  22369. // Create the label
  22370. if (this.split) {
  22371. this.label = renderer.g(className);
  22372. }
  22373. else {
  22374. this.label = renderer
  22375. .label('', 0, 0, options.shape || 'callout', null, null, options.useHTML, null, className)
  22376. .attr({
  22377. padding: options.padding,
  22378. r: options.borderRadius
  22379. });
  22380. if (!styledMode) {
  22381. this.label
  22382. .attr({
  22383. fill: options.backgroundColor,
  22384. 'stroke-width': options.borderWidth
  22385. })
  22386. // #2301, #2657
  22387. .css(options.style)
  22388. .css({ pointerEvents: pointerEvents })
  22389. .shadow(options.shadow);
  22390. }
  22391. }
  22392. if (styledMode) {
  22393. // Apply the drop-shadow filter
  22394. this.applyFilter();
  22395. this.label.addClass('highcharts-tooltip-' + this.chart.index);
  22396. }
  22397. // Split tooltip use updateTooltipContainer to position the tooltip
  22398. // container.
  22399. if (tooltip.outside && !tooltip.split) {
  22400. var label_1 = this.label;
  22401. var xSetter_1 = label_1.xSetter,
  22402. ySetter_1 = label_1.ySetter;
  22403. label_1.xSetter = function (value) {
  22404. xSetter_1.call(label_1, tooltip.distance);
  22405. container.style.left = value + 'px';
  22406. };
  22407. label_1.ySetter = function (value) {
  22408. ySetter_1.call(label_1, tooltip.distance);
  22409. container.style.top = value + 'px';
  22410. };
  22411. }
  22412. this.label
  22413. .on('mouseenter', onMouseEnter)
  22414. .on('mouseleave', onMouseLeave)
  22415. .attr({ zIndex: 8 })
  22416. .add();
  22417. }
  22418. return this.label;
  22419. };
  22420. /**
  22421. * Place the tooltip in a chart without spilling over
  22422. * and not covering the point it self.
  22423. *
  22424. * @private
  22425. * @function Highcharts.Tooltip#getPosition
  22426. *
  22427. * @param {number} boxWidth
  22428. *
  22429. * @param {number} boxHeight
  22430. *
  22431. * @param {Highcharts.Point} point
  22432. *
  22433. * @return {Highcharts.PositionObject}
  22434. */
  22435. Tooltip.prototype.getPosition = function (boxWidth, boxHeight, point) {
  22436. var chart = this.chart,
  22437. distance = this.distance,
  22438. ret = {},
  22439. // Don't use h if chart isn't inverted (#7242) ???
  22440. h = (chart.inverted && point.h) || 0, // #4117 ???
  22441. swapped,
  22442. outside = this.outside,
  22443. outerWidth = outside ?
  22444. // substract distance to prevent scrollbars
  22445. doc.documentElement.clientWidth - 2 * distance :
  22446. chart.chartWidth,
  22447. outerHeight = outside ?
  22448. Math.max(doc.body.scrollHeight,
  22449. doc.documentElement.scrollHeight,
  22450. doc.body.offsetHeight,
  22451. doc.documentElement.offsetHeight,
  22452. doc.documentElement.clientHeight) :
  22453. chart.chartHeight,
  22454. chartPosition = chart.pointer.getChartPosition(),
  22455. containerScaling = chart.containerScaling,
  22456. scaleX = function (val) { return ( // eslint-disable-line no-confusing-arrow
  22457. containerScaling ? val * containerScaling.scaleX : val); },
  22458. scaleY = function (val) { return ( // eslint-disable-line no-confusing-arrow
  22459. containerScaling ? val * containerScaling.scaleY : val); },
  22460. // Build parameter arrays for firstDimension()/secondDimension()
  22461. buildDimensionArray = function (dim) {
  22462. var isX = dim === 'x';
  22463. return [
  22464. dim,
  22465. isX ? outerWidth : outerHeight,
  22466. isX ? boxWidth : boxHeight
  22467. ].concat(outside ? [
  22468. // If we are using tooltip.outside, we need to scale the
  22469. // position to match scaling of the container in case there
  22470. // is a transform/zoom on the container. #11329
  22471. isX ? scaleX(boxWidth) : scaleY(boxHeight),
  22472. isX ? chartPosition.left - distance +
  22473. scaleX(point.plotX + chart.plotLeft) :
  22474. chartPosition.top - distance +
  22475. scaleY(point.plotY + chart.plotTop),
  22476. 0,
  22477. isX ? outerWidth : outerHeight
  22478. ] : [
  22479. // Not outside, no scaling is needed
  22480. isX ? boxWidth : boxHeight,
  22481. isX ? point.plotX + chart.plotLeft :
  22482. point.plotY + chart.plotTop,
  22483. isX ? chart.plotLeft : chart.plotTop,
  22484. isX ? chart.plotLeft + chart.plotWidth :
  22485. chart.plotTop + chart.plotHeight
  22486. ]);
  22487. }, first = buildDimensionArray('y'), second = buildDimensionArray('x'),
  22488. // The far side is right or bottom
  22489. preferFarSide = !this.followPointer && pick(point.ttBelow, !chart.inverted === !!point.negative), // #4984
  22490. /*
  22491. * Handle the preferred dimension. When the preferred dimension is
  22492. * tooltip on top or bottom of the point, it will look for space
  22493. * there.
  22494. *
  22495. * @private
  22496. */
  22497. firstDimension = function (dim, outerSize, innerSize, scaledInnerSize, // #11329
  22498. point, min, max) {
  22499. var scaledDist = dim === 'y' ?
  22500. scaleY(distance) : scaleX(distance),
  22501. scaleDiff = (innerSize - scaledInnerSize) / 2,
  22502. roomLeft = scaledInnerSize < point - distance,
  22503. roomRight = point + distance + scaledInnerSize < outerSize,
  22504. alignedLeft = point - scaledDist - innerSize + scaleDiff,
  22505. alignedRight = point + scaledDist - scaleDiff;
  22506. if (preferFarSide && roomRight) {
  22507. ret[dim] = alignedRight;
  22508. }
  22509. else if (!preferFarSide && roomLeft) {
  22510. ret[dim] = alignedLeft;
  22511. }
  22512. else if (roomLeft) {
  22513. ret[dim] = Math.min(max - scaledInnerSize, alignedLeft - h < 0 ? alignedLeft : alignedLeft - h);
  22514. }
  22515. else if (roomRight) {
  22516. ret[dim] = Math.max(min, alignedRight + h + innerSize > outerSize ?
  22517. alignedRight :
  22518. alignedRight + h);
  22519. }
  22520. else {
  22521. return false;
  22522. }
  22523. },
  22524. /*
  22525. * Handle the secondary dimension. If the preferred dimension is
  22526. * tooltip on top or bottom of the point, the second dimension is to
  22527. * align the tooltip above the point, trying to align center but
  22528. * allowing left or right align within the chart box.
  22529. *
  22530. * @private
  22531. */
  22532. secondDimension = function (dim, outerSize, innerSize, scaledInnerSize, // #11329
  22533. point) {
  22534. var retVal;
  22535. // Too close to the edge, return false and swap dimensions
  22536. if (point < distance || point > outerSize - distance) {
  22537. retVal = false;
  22538. // Align left/top
  22539. }
  22540. else if (point < innerSize / 2) {
  22541. ret[dim] = 1;
  22542. // Align right/bottom
  22543. }
  22544. else if (point > outerSize - scaledInnerSize / 2) {
  22545. ret[dim] = outerSize - scaledInnerSize - 2;
  22546. // Align center
  22547. }
  22548. else {
  22549. ret[dim] = point - innerSize / 2;
  22550. }
  22551. return retVal;
  22552. },
  22553. /*
  22554. * Swap the dimensions
  22555. */
  22556. swap = function (count) {
  22557. var temp = first;
  22558. first = second;
  22559. second = temp;
  22560. swapped = count;
  22561. }, run = function () {
  22562. if (firstDimension.apply(0, first) !== false) {
  22563. if (secondDimension.apply(0, second) === false &&
  22564. !swapped) {
  22565. swap(true);
  22566. run();
  22567. }
  22568. }
  22569. else if (!swapped) {
  22570. swap(true);
  22571. run();
  22572. }
  22573. else {
  22574. ret.x = ret.y = 0;
  22575. }
  22576. };
  22577. // Under these conditions, prefer the tooltip on the side of the point
  22578. if (chart.inverted || this.len > 1) {
  22579. swap();
  22580. }
  22581. run();
  22582. return ret;
  22583. };
  22584. /**
  22585. * Get the best X date format based on the closest point range on the axis.
  22586. *
  22587. * @private
  22588. * @function Highcharts.Tooltip#getXDateFormat
  22589. *
  22590. * @param {Highcharts.Point} point
  22591. *
  22592. * @param {Highcharts.TooltipOptions} options
  22593. *
  22594. * @param {Highcharts.Axis} xAxis
  22595. *
  22596. * @return {string}
  22597. */
  22598. Tooltip.prototype.getXDateFormat = function (point, options, xAxis) {
  22599. var xDateFormat,
  22600. dateTimeLabelFormats = options.dateTimeLabelFormats,
  22601. closestPointRange = xAxis && xAxis.closestPointRange;
  22602. if (closestPointRange) {
  22603. xDateFormat = this.getDateFormat(closestPointRange, point.x, xAxis.options.startOfWeek, dateTimeLabelFormats);
  22604. }
  22605. else {
  22606. xDateFormat = dateTimeLabelFormats.day;
  22607. }
  22608. return xDateFormat || dateTimeLabelFormats.year; // #2546, 2581
  22609. };
  22610. /**
  22611. * Hides the tooltip with a fade out animation.
  22612. *
  22613. * @function Highcharts.Tooltip#hide
  22614. *
  22615. * @param {number} [delay]
  22616. * The fade out in milliseconds. If no value is provided the value
  22617. * of the tooltip.hideDelay option is used. A value of 0 disables
  22618. * the fade out animation.
  22619. */
  22620. Tooltip.prototype.hide = function (delay) {
  22621. var tooltip = this;
  22622. // disallow duplicate timers (#1728, #1766)
  22623. U.clearTimeout(this.hideTimer);
  22624. delay = pick(delay, this.options.hideDelay, 500);
  22625. if (!this.isHidden) {
  22626. this.hideTimer = syncTimeout(function () {
  22627. // If there is a delay, do fadeOut with the default duration. If
  22628. // the hideDelay is 0, we assume no animation is wanted, so we
  22629. // pass 0 duration. #12994.
  22630. tooltip.getLabel().fadeOut(delay ? void 0 : delay);
  22631. tooltip.isHidden = true;
  22632. }, delay);
  22633. }
  22634. };
  22635. /**
  22636. * @private
  22637. * @function Highcharts.Tooltip#init
  22638. *
  22639. * @param {Highcharts.Chart} chart
  22640. * The chart instance.
  22641. *
  22642. * @param {Highcharts.TooltipOptions} options
  22643. * Tooltip options.
  22644. */
  22645. Tooltip.prototype.init = function (chart, options) {
  22646. /**
  22647. * Chart of the tooltip.
  22648. *
  22649. * @readonly
  22650. * @name Highcharts.Tooltip#chart
  22651. * @type {Highcharts.Chart}
  22652. */
  22653. this.chart = chart;
  22654. /**
  22655. * Used tooltip options.
  22656. *
  22657. * @readonly
  22658. * @name Highcharts.Tooltip#options
  22659. * @type {Highcharts.TooltipOptions}
  22660. */
  22661. this.options = options;
  22662. /**
  22663. * List of crosshairs.
  22664. *
  22665. * @private
  22666. * @readonly
  22667. * @name Highcharts.Tooltip#crosshairs
  22668. * @type {Array<null>}
  22669. */
  22670. this.crosshairs = [];
  22671. /**
  22672. * Current values of x and y when animating.
  22673. *
  22674. * @private
  22675. * @readonly
  22676. * @name Highcharts.Tooltip#now
  22677. * @type {Highcharts.PositionObject}
  22678. */
  22679. this.now = { x: 0, y: 0 };
  22680. /**
  22681. * Tooltips are initially hidden.
  22682. *
  22683. * @private
  22684. * @readonly
  22685. * @name Highcharts.Tooltip#isHidden
  22686. * @type {boolean}
  22687. */
  22688. this.isHidden = true;
  22689. /**
  22690. * True, if the tooltip is split into one label per series, with the
  22691. * header close to the axis.
  22692. *
  22693. * @readonly
  22694. * @name Highcharts.Tooltip#split
  22695. * @type {boolean|undefined}
  22696. */
  22697. this.split = options.split && !chart.inverted && !chart.polar;
  22698. /**
  22699. * When the tooltip is shared, the entire plot area will capture mouse
  22700. * movement or touch events.
  22701. *
  22702. * @readonly
  22703. * @name Highcharts.Tooltip#shared
  22704. * @type {boolean|undefined}
  22705. */
  22706. this.shared = options.shared || this.split;
  22707. /**
  22708. * Whether to allow the tooltip to render outside the chart's SVG
  22709. * element box. By default (false), the tooltip is rendered within the
  22710. * chart's SVG element, which results in the tooltip being aligned
  22711. * inside the chart area.
  22712. *
  22713. * @readonly
  22714. * @name Highcharts.Tooltip#outside
  22715. * @type {boolean}
  22716. *
  22717. * @todo
  22718. * Split tooltip does not support outside in the first iteration. Should
  22719. * not be too complicated to implement.
  22720. */
  22721. this.outside = pick(options.outside, Boolean(chart.scrollablePixelsX || chart.scrollablePixelsY));
  22722. };
  22723. /**
  22724. * Returns true, if the pointer is in contact with the tooltip tracker.
  22725. */
  22726. Tooltip.prototype.isStickyOnContact = function () {
  22727. return !!(!this.followPointer &&
  22728. this.options.stickOnContact &&
  22729. this.inContact);
  22730. };
  22731. /**
  22732. * Moves the tooltip with a soft animation to a new position.
  22733. *
  22734. * @private
  22735. * @function Highcharts.Tooltip#move
  22736. *
  22737. * @param {number} x
  22738. *
  22739. * @param {number} y
  22740. *
  22741. * @param {number} anchorX
  22742. *
  22743. * @param {number} anchorY
  22744. */
  22745. Tooltip.prototype.move = function (x, y, anchorX, anchorY) {
  22746. var tooltip = this,
  22747. now = tooltip.now,
  22748. animate = tooltip.options.animation !== false &&
  22749. !tooltip.isHidden &&
  22750. // When we get close to the target position, abort animation and
  22751. // land on the right place (#3056)
  22752. (Math.abs(x - now.x) > 1 || Math.abs(y - now.y) > 1),
  22753. skipAnchor = tooltip.followPointer || tooltip.len > 1;
  22754. // Get intermediate values for animation
  22755. extend(now, {
  22756. x: animate ? (2 * now.x + x) / 3 : x,
  22757. y: animate ? (now.y + y) / 2 : y,
  22758. anchorX: skipAnchor ?
  22759. void 0 :
  22760. animate ? (2 * now.anchorX + anchorX) / 3 : anchorX,
  22761. anchorY: skipAnchor ?
  22762. void 0 :
  22763. animate ? (now.anchorY + anchorY) / 2 : anchorY
  22764. });
  22765. // Move to the intermediate value
  22766. tooltip.getLabel().attr(now);
  22767. tooltip.drawTracker();
  22768. // Run on next tick of the mouse tracker
  22769. if (animate) {
  22770. // Never allow two timeouts
  22771. U.clearTimeout(this.tooltipTimeout);
  22772. // Set the fixed interval ticking for the smooth tooltip
  22773. this.tooltipTimeout = setTimeout(function () {
  22774. // The interval function may still be running during destroy,
  22775. // so check that the chart is really there before calling.
  22776. if (tooltip) {
  22777. tooltip.move(x, y, anchorX, anchorY);
  22778. }
  22779. }, 32);
  22780. }
  22781. };
  22782. /**
  22783. * Refresh the tooltip's text and position.
  22784. *
  22785. * @function Highcharts.Tooltip#refresh
  22786. *
  22787. * @param {Highcharts.Point|Array<Highcharts.Point>} pointOrPoints
  22788. * Either a point or an array of points.
  22789. *
  22790. * @param {Highcharts.PointerEventObject} [mouseEvent]
  22791. * Mouse event, that is responsible for the refresh and should be
  22792. * used for the tooltip update.
  22793. */
  22794. Tooltip.prototype.refresh = function (pointOrPoints, mouseEvent) {
  22795. var tooltip = this,
  22796. chart = this.chart,
  22797. options = tooltip.options,
  22798. x,
  22799. y,
  22800. point = pointOrPoints,
  22801. anchor,
  22802. textConfig = {},
  22803. text,
  22804. pointConfig = [],
  22805. formatter = options.formatter || tooltip.defaultFormatter,
  22806. shared = tooltip.shared,
  22807. currentSeries,
  22808. styledMode = chart.styledMode;
  22809. if (!options.enabled) {
  22810. return;
  22811. }
  22812. U.clearTimeout(this.hideTimer);
  22813. // get the reference point coordinates (pie charts use tooltipPos)
  22814. tooltip.followPointer = splat(point)[0].series.tooltipOptions
  22815. .followPointer;
  22816. anchor = tooltip.getAnchor(point, mouseEvent);
  22817. x = anchor[0];
  22818. y = anchor[1];
  22819. // shared tooltip, array is sent over
  22820. if (shared &&
  22821. !(point.series &&
  22822. point.series.noSharedTooltip)) {
  22823. chart.pointer.applyInactiveState(point);
  22824. // Now set hover state for the choosen ones:
  22825. point.forEach(function (item) {
  22826. item.setState('hover');
  22827. pointConfig.push(item.getLabelConfig());
  22828. });
  22829. textConfig = {
  22830. x: point[0].category,
  22831. y: point[0].y
  22832. };
  22833. textConfig.points = pointConfig;
  22834. point = point[0];
  22835. // single point tooltip
  22836. }
  22837. else {
  22838. textConfig = point.getLabelConfig();
  22839. }
  22840. this.len = pointConfig.length; // #6128
  22841. text = formatter.call(textConfig, tooltip);
  22842. // register the current series
  22843. currentSeries = point.series;
  22844. this.distance = pick(currentSeries.tooltipOptions.distance, 16);
  22845. // update the inner HTML
  22846. if (text === false) {
  22847. this.hide();
  22848. }
  22849. else {
  22850. // update text
  22851. if (tooltip.split) {
  22852. this.renderSplit(text, splat(pointOrPoints));
  22853. }
  22854. else {
  22855. var label = tooltip.getLabel();
  22856. // Prevent the tooltip from flowing over the chart box (#6659)
  22857. if (!options.style.width || styledMode) {
  22858. label.css({
  22859. width: this.chart.spacingBox.width + 'px'
  22860. });
  22861. }
  22862. label.attr({
  22863. text: text && text.join ?
  22864. text.join('') :
  22865. text
  22866. });
  22867. // Set the stroke color of the box to reflect the point
  22868. label.removeClass(/highcharts-color-[\d]+/g)
  22869. .addClass('highcharts-color-' +
  22870. pick(point.colorIndex, currentSeries.colorIndex));
  22871. if (!styledMode) {
  22872. label.attr({
  22873. stroke: (options.borderColor ||
  22874. point.color ||
  22875. currentSeries.color ||
  22876. '#666666')
  22877. });
  22878. }
  22879. tooltip.updatePosition({
  22880. plotX: x,
  22881. plotY: y,
  22882. negative: point.negative,
  22883. ttBelow: point.ttBelow,
  22884. h: anchor[2] || 0
  22885. });
  22886. }
  22887. // show it
  22888. if (tooltip.isHidden && tooltip.label) {
  22889. tooltip.label.attr({
  22890. opacity: 1
  22891. }).show();
  22892. }
  22893. tooltip.isHidden = false;
  22894. }
  22895. fireEvent(this, 'refresh');
  22896. };
  22897. /**
  22898. * Render the split tooltip. Loops over each point's text and adds
  22899. * a label next to the point, then uses the distribute function to
  22900. * find best non-overlapping positions.
  22901. *
  22902. * @private
  22903. * @function Highcharts.Tooltip#renderSplit
  22904. *
  22905. * @param {string|Array<(boolean|string)>} labels
  22906. *
  22907. * @param {Array<Highcharts.Point>} points
  22908. */
  22909. Tooltip.prototype.renderSplit = function (labels, points) {
  22910. var tooltip = this;
  22911. var chart = tooltip.chart,
  22912. _a = tooltip.chart,
  22913. chartWidth = _a.chartWidth,
  22914. chartHeight = _a.chartHeight,
  22915. plotHeight = _a.plotHeight,
  22916. plotLeft = _a.plotLeft,
  22917. plotTop = _a.plotTop,
  22918. pointer = _a.pointer,
  22919. ren = _a.renderer,
  22920. _b = _a.scrollablePixelsY,
  22921. scrollablePixelsY = _b === void 0 ? 0 : _b,
  22922. _c = _a.scrollingContainer,
  22923. _d = _c === void 0 ? { scrollLeft: 0,
  22924. scrollTop: 0 } : _c,
  22925. scrollLeft = _d.scrollLeft,
  22926. scrollTop = _d.scrollTop,
  22927. styledMode = _a.styledMode,
  22928. distance = tooltip.distance,
  22929. options = tooltip.options,
  22930. positioner = tooltip.options.positioner;
  22931. // The area which the tooltip should be limited to. Limit to scrollable
  22932. // plot area if enabled, otherwise limit to the chart container.
  22933. var bounds = {
  22934. left: scrollLeft,
  22935. right: scrollLeft + chartWidth,
  22936. top: scrollTop,
  22937. bottom: scrollTop + chartHeight
  22938. };
  22939. var tooltipLabel = tooltip.getLabel();
  22940. var headerTop = Boolean(chart.xAxis[0] && chart.xAxis[0].opposite);
  22941. var distributionBoxTop = plotTop + scrollTop;
  22942. var headerHeight = 0;
  22943. var adjustedPlotHeight = plotHeight - scrollablePixelsY;
  22944. /**
  22945. * Calculates the anchor position for the partial tooltip
  22946. *
  22947. * @private
  22948. * @param {Highcharts.Point} point The point related to the tooltip
  22949. * @return {object} Returns an object with anchorX and anchorY
  22950. */
  22951. function getAnchor(point) {
  22952. var isHeader = point.isHeader,
  22953. _a = point.plotX,
  22954. plotX = _a === void 0 ? 0 : _a,
  22955. _b = point.plotY,
  22956. plotY = _b === void 0 ? 0 : _b,
  22957. series = point.series;
  22958. var anchorX;
  22959. var anchorY;
  22960. if (isHeader) {
  22961. // Set anchorX to plotX
  22962. anchorX = plotLeft + plotX;
  22963. // Set anchorY to center of visible plot area.
  22964. anchorY = plotTop + plotHeight / 2;
  22965. }
  22966. else {
  22967. var xAxis = series.xAxis,
  22968. yAxis = series.yAxis;
  22969. // Set anchorX to plotX. Limit to within xAxis.
  22970. anchorX = xAxis.pos + clamp(plotX, -distance, xAxis.len + distance);
  22971. // Set anchorY, limit to the scrollable plot area
  22972. if (yAxis.pos + plotY >= scrollTop + plotTop &&
  22973. yAxis.pos + plotY <= scrollTop + plotTop + plotHeight - scrollablePixelsY) {
  22974. anchorY = yAxis.pos + plotY;
  22975. }
  22976. }
  22977. // Limit values to plot area
  22978. anchorX = clamp(anchorX, bounds.left - distance, bounds.right + distance);
  22979. return { anchorX: anchorX, anchorY: anchorY };
  22980. }
  22981. /**
  22982. * Calculates the position of the partial tooltip
  22983. *
  22984. * @private
  22985. * @param {number} anchorX The partial tooltip anchor x position
  22986. * @param {number} anchorY The partial tooltip anchor y position
  22987. * @param {boolean} isHeader Whether the partial tooltip is a header
  22988. * @param {number} boxWidth Width of the partial tooltip
  22989. * @return {Highcharts.PositionObject} Returns the partial tooltip x and
  22990. * y position
  22991. */
  22992. function defaultPositioner(anchorX, anchorY, isHeader, boxWidth, alignedLeft) {
  22993. if (alignedLeft === void 0) { alignedLeft = true; }
  22994. var y;
  22995. var x;
  22996. if (isHeader) {
  22997. y = headerTop ? 0 : adjustedPlotHeight;
  22998. x = clamp(anchorX - (boxWidth / 2), bounds.left, bounds.right - boxWidth);
  22999. }
  23000. else {
  23001. y = anchorY - distributionBoxTop;
  23002. x = alignedLeft ?
  23003. anchorX - boxWidth - distance :
  23004. anchorX + distance;
  23005. x = clamp(x, alignedLeft ? x : bounds.left, bounds.right);
  23006. }
  23007. // NOTE: y is relative to distributionBoxTop
  23008. return { x: x, y: y };
  23009. }
  23010. /**
  23011. * Updates the attributes and styling of the partial tooltip. Creates a
  23012. * new partial tooltip if it does not exists.
  23013. *
  23014. * @private
  23015. * @param {Highcharts.SVGElement|undefined} partialTooltip
  23016. * The partial tooltip to update
  23017. * @param {Highcharts.Point} point
  23018. * The point related to the partial tooltip
  23019. * @param {boolean|string} str The text for the partial tooltip
  23020. * @return {Highcharts.SVGElement} Returns the updated partial tooltip
  23021. */
  23022. function updatePartialTooltip(partialTooltip, point, str) {
  23023. var tt = partialTooltip;
  23024. var isHeader = point.isHeader,
  23025. series = point.series;
  23026. var colorClass = 'highcharts-color-' + pick(point.colorIndex, series.colorIndex, 'none');
  23027. if (!tt) {
  23028. var attribs = {
  23029. padding: options.padding,
  23030. r: options.borderRadius
  23031. };
  23032. if (!styledMode) {
  23033. attribs.fill = options.backgroundColor;
  23034. attribs['stroke-width'] = options.borderWidth;
  23035. }
  23036. tt = ren
  23037. .label('', 0, 0, (options[isHeader ? 'headerShape' : 'shape']) ||
  23038. 'callout', void 0, void 0, options.useHTML)
  23039. .addClass((isHeader ? 'highcharts-tooltip-header ' : '') +
  23040. 'highcharts-tooltip-box ' +
  23041. colorClass)
  23042. .attr(attribs)
  23043. .add(tooltipLabel);
  23044. }
  23045. tt.isActive = true;
  23046. tt.attr({
  23047. text: str
  23048. });
  23049. if (!styledMode) {
  23050. tt.css(options.style)
  23051. .shadow(options.shadow)
  23052. .attr({
  23053. stroke: (options.borderColor ||
  23054. point.color ||
  23055. series.color ||
  23056. '#333333')
  23057. });
  23058. }
  23059. return tt;
  23060. }
  23061. // Graceful degradation for legacy formatters
  23062. if (isString(labels)) {
  23063. labels = [false, labels];
  23064. }
  23065. // Create the individual labels for header and points, ignore footer
  23066. var boxes = labels.slice(0,
  23067. points.length + 1).reduce(function (boxes,
  23068. str,
  23069. i) {
  23070. if (str !== false && str !== '') {
  23071. var point = (points[i - 1] ||
  23072. {
  23073. // Item 0 is the header. Instead of this, we could also
  23074. // use the crosshair label
  23075. isHeader: true,
  23076. plotX: points[0].plotX,
  23077. plotY: plotHeight,
  23078. series: {}
  23079. });
  23080. var isHeader = point.isHeader;
  23081. // Store the tooltip label referance on the series
  23082. var owner = isHeader ? tooltip : point.series;
  23083. var tt = owner.tt = updatePartialTooltip(owner.tt,
  23084. point,
  23085. str);
  23086. // Get X position now, so we can move all to the other side in
  23087. // case of overflow
  23088. var bBox = tt.getBBox();
  23089. var boxWidth = bBox.width + tt.strokeWidth();
  23090. if (isHeader) {
  23091. headerHeight = bBox.height;
  23092. adjustedPlotHeight += headerHeight;
  23093. if (headerTop) {
  23094. distributionBoxTop -= headerHeight;
  23095. }
  23096. }
  23097. var _a = getAnchor(point),
  23098. anchorX = _a.anchorX,
  23099. anchorY = _a.anchorY;
  23100. if (typeof anchorY === 'number') {
  23101. var size = bBox.height + 1;
  23102. var boxPosition = (positioner ?
  23103. positioner.call(tooltip,
  23104. boxWidth,
  23105. size,
  23106. point) :
  23107. defaultPositioner(anchorX,
  23108. anchorY,
  23109. isHeader,
  23110. boxWidth));
  23111. boxes.push({
  23112. // 0-align to the top, 1-align to the bottom
  23113. align: positioner ? 0 : void 0,
  23114. anchorX: anchorX,
  23115. anchorY: anchorY,
  23116. boxWidth: boxWidth,
  23117. point: point,
  23118. rank: pick(boxPosition.rank, isHeader ? 1 : 0),
  23119. size: size,
  23120. target: boxPosition.y,
  23121. tt: tt,
  23122. x: boxPosition.x
  23123. });
  23124. }
  23125. else {
  23126. // Hide tooltips which anchorY is outside the visible plot
  23127. // area
  23128. tt.isActive = false;
  23129. }
  23130. }
  23131. return boxes;
  23132. }, []);
  23133. // If overflow left then align all labels to the right
  23134. if (!positioner && boxes.some(function (box) { return box.x < bounds.left; })) {
  23135. boxes = boxes.map(function (box) {
  23136. var _a = defaultPositioner(box.anchorX,
  23137. box.anchorY,
  23138. box.point.isHeader,
  23139. box.boxWidth,
  23140. false),
  23141. x = _a.x,
  23142. y = _a.y;
  23143. return extend(box, {
  23144. target: y,
  23145. x: x
  23146. });
  23147. });
  23148. }
  23149. // Clean previous run (for missing points)
  23150. tooltip.cleanSplit();
  23151. // Distribute and put in place
  23152. H.distribute(boxes, adjustedPlotHeight);
  23153. boxes.forEach(function (box) {
  23154. var anchorX = box.anchorX,
  23155. anchorY = box.anchorY,
  23156. pos = box.pos,
  23157. x = box.x;
  23158. // Put the label in place
  23159. box.tt.attr({
  23160. visibility: typeof pos === 'undefined' ? 'hidden' : 'inherit',
  23161. x: x,
  23162. /* NOTE: y should equal pos to be consistent with !split
  23163. * tooltip, but is currently relative to plotTop. Is left as is
  23164. * to avoid breaking change. Remove distributionBoxTop to make
  23165. * it consistent.
  23166. */
  23167. y: pos + distributionBoxTop,
  23168. anchorX: anchorX,
  23169. anchorY: anchorY
  23170. });
  23171. });
  23172. /* If we have a seperate tooltip container, then update the necessary
  23173. * container properties.
  23174. * Test that tooltip has its own container and renderer before executing
  23175. * the operation.
  23176. */
  23177. var container = tooltip.container,
  23178. outside = tooltip.outside,
  23179. renderer = tooltip.renderer;
  23180. if (outside && container && renderer) {
  23181. // Set container size to fit the tooltip
  23182. var _e = tooltipLabel.getBBox(),
  23183. width = _e.width,
  23184. height = _e.height,
  23185. x = _e.x,
  23186. y = _e.y;
  23187. renderer.setSize(width + x, height + y, false);
  23188. // Position the tooltip container to the chart container
  23189. var chartPosition = pointer.getChartPosition();
  23190. container.style.left = chartPosition.left + 'px';
  23191. container.style.top = chartPosition.top + 'px';
  23192. }
  23193. };
  23194. /**
  23195. * If the `stickOnContact` option is active, this will add a tracker shape.
  23196. *
  23197. * @private
  23198. * @function Highcharts.Tooltip#drawTracker
  23199. */
  23200. Tooltip.prototype.drawTracker = function () {
  23201. var tooltip = this;
  23202. if (tooltip.followPointer ||
  23203. !tooltip.options.stickOnContact) {
  23204. if (tooltip.tracker) {
  23205. tooltip.tracker.destroy();
  23206. }
  23207. return;
  23208. }
  23209. var chart = tooltip.chart;
  23210. var label = tooltip.label;
  23211. var point = chart.hoverPoint;
  23212. if (!label || !point) {
  23213. return;
  23214. }
  23215. var box = {
  23216. x: 0,
  23217. y: 0,
  23218. width: 0,
  23219. height: 0
  23220. };
  23221. // Combine anchor and tooltip
  23222. var anchorPos = this.getAnchor(point);
  23223. var labelBBox = label.getBBox();
  23224. anchorPos[0] += chart.plotLeft - label.translateX;
  23225. anchorPos[1] += chart.plotTop - label.translateY;
  23226. // When the mouse pointer is between the anchor point and the label,
  23227. // the label should stick.
  23228. box.x = Math.min(0, anchorPos[0]);
  23229. box.y = Math.min(0, anchorPos[1]);
  23230. box.width = (anchorPos[0] < 0 ?
  23231. Math.max(Math.abs(anchorPos[0]), (labelBBox.width - anchorPos[0])) :
  23232. Math.max(Math.abs(anchorPos[0]), labelBBox.width));
  23233. box.height = (anchorPos[1] < 0 ?
  23234. Math.max(Math.abs(anchorPos[1]), (labelBBox.height - Math.abs(anchorPos[1]))) :
  23235. Math.max(Math.abs(anchorPos[1]), labelBBox.height));
  23236. if (tooltip.tracker) {
  23237. tooltip.tracker.attr(box);
  23238. }
  23239. else {
  23240. tooltip.tracker = label.renderer
  23241. .rect(box)
  23242. .addClass('highcharts-tracker')
  23243. .add(label);
  23244. if (!chart.styledMode) {
  23245. tooltip.tracker.attr({
  23246. fill: 'rgba(0,0,0,0)'
  23247. });
  23248. }
  23249. }
  23250. };
  23251. /**
  23252. * @private
  23253. */
  23254. Tooltip.prototype.styledModeFormat = function (formatString) {
  23255. return formatString
  23256. .replace('style="font-size: 10px"', 'class="highcharts-header"')
  23257. .replace(/style="color:{(point|series)\.color}"/g, 'class="highcharts-color-{$1.colorIndex}"');
  23258. };
  23259. /**
  23260. * Format the footer/header of the tooltip
  23261. * #3397: abstraction to enable formatting of footer and header
  23262. *
  23263. * @private
  23264. * @function Highcharts.Tooltip#tooltipFooterHeaderFormatter
  23265. * @param {Highcharts.PointLabelObject} labelConfig
  23266. * @param {boolean} [isFooter]
  23267. * @return {string}
  23268. */
  23269. Tooltip.prototype.tooltipFooterHeaderFormatter = function (labelConfig, isFooter) {
  23270. var footOrHead = isFooter ? 'footer' : 'header',
  23271. series = labelConfig.series,
  23272. tooltipOptions = series.tooltipOptions,
  23273. xDateFormat = tooltipOptions.xDateFormat,
  23274. xAxis = series.xAxis,
  23275. isDateTime = (xAxis &&
  23276. xAxis.options.type === 'datetime' &&
  23277. isNumber(labelConfig.key)),
  23278. formatString = tooltipOptions[footOrHead + 'Format'],
  23279. e = {
  23280. isFooter: isFooter,
  23281. labelConfig: labelConfig
  23282. };
  23283. fireEvent(this, 'headerFormatter', e, function (e) {
  23284. // Guess the best date format based on the closest point distance
  23285. // (#568, #3418)
  23286. if (isDateTime && !xDateFormat) {
  23287. xDateFormat = this.getXDateFormat(labelConfig, tooltipOptions, xAxis);
  23288. }
  23289. // Insert the footer date format if any
  23290. if (isDateTime && xDateFormat) {
  23291. ((labelConfig.point && labelConfig.point.tooltipDateKeys) ||
  23292. ['key']).forEach(function (key) {
  23293. formatString = formatString.replace('{point.' + key + '}', '{point.' + key + ':' + xDateFormat + '}');
  23294. });
  23295. }
  23296. // Replace default header style with class name
  23297. if (series.chart.styledMode) {
  23298. formatString = this.styledModeFormat(formatString);
  23299. }
  23300. e.text = format(formatString, {
  23301. point: labelConfig,
  23302. series: series
  23303. }, this.chart);
  23304. });
  23305. return e.text;
  23306. };
  23307. /**
  23308. * Updates the tooltip with the provided tooltip options.
  23309. *
  23310. * @function Highcharts.Tooltip#update
  23311. *
  23312. * @param {Highcharts.TooltipOptions} options
  23313. * The tooltip options to update.
  23314. */
  23315. Tooltip.prototype.update = function (options) {
  23316. this.destroy();
  23317. // Update user options (#6218)
  23318. merge(true, this.chart.options.tooltip.userOptions, options);
  23319. this.init(this.chart, merge(true, this.options, options));
  23320. };
  23321. /**
  23322. * Find the new position and perform the move
  23323. *
  23324. * @private
  23325. * @function Highcharts.Tooltip#updatePosition
  23326. *
  23327. * @param {Highcharts.Point} point
  23328. */
  23329. Tooltip.prototype.updatePosition = function (point) {
  23330. var chart = this.chart,
  23331. pointer = chart.pointer,
  23332. label = this.getLabel(),
  23333. pos,
  23334. anchorX = point.plotX + chart.plotLeft,
  23335. anchorY = point.plotY + chart.plotTop,
  23336. pad;
  23337. // Needed for outside: true (#11688)
  23338. var chartPosition = pointer.getChartPosition();
  23339. pos = (this.options.positioner || this.getPosition).call(this, label.width, label.height, point);
  23340. // Set the renderer size dynamically to prevent document size to change
  23341. if (this.outside) {
  23342. pad = (this.options.borderWidth || 0) + 2 * this.distance;
  23343. this.renderer.setSize(label.width + pad, label.height + pad, false);
  23344. // Anchor and tooltip container need scaling if chart container has
  23345. // scale transform/css zoom. #11329.
  23346. var containerScaling = chart.containerScaling;
  23347. if (containerScaling) {
  23348. css(this.container, {
  23349. transform: "scale(" + containerScaling.scaleX + ", " + containerScaling.scaleY + ")"
  23350. });
  23351. anchorX *= containerScaling.scaleX;
  23352. anchorY *= containerScaling.scaleY;
  23353. }
  23354. anchorX += chartPosition.left - pos.x;
  23355. anchorY += chartPosition.top - pos.y;
  23356. }
  23357. // do the move
  23358. this.move(Math.round(pos.x), Math.round(pos.y || 0), // can be undefined (#3977)
  23359. anchorX, anchorY);
  23360. };
  23361. return Tooltip;
  23362. }());
  23363. H.Tooltip = Tooltip;
  23364. return H.Tooltip;
  23365. });
  23366. _registerModule(_modules, 'Core/Pointer.js', [_modules['Core/Color/Color.js'], _modules['Core/Globals.js'], _modules['Core/Tooltip.js'], _modules['Core/Utilities.js']], function (Color, H, Tooltip, U) {
  23367. /* *
  23368. *
  23369. * (c) 2010-2020 Torstein Honsi
  23370. *
  23371. * License: www.highcharts.com/license
  23372. *
  23373. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  23374. *
  23375. * */
  23376. var color = Color.parse;
  23377. var charts = H.charts,
  23378. noop = H.noop;
  23379. var addEvent = U.addEvent,
  23380. attr = U.attr,
  23381. css = U.css,
  23382. defined = U.defined,
  23383. extend = U.extend,
  23384. find = U.find,
  23385. fireEvent = U.fireEvent,
  23386. isNumber = U.isNumber,
  23387. isObject = U.isObject,
  23388. objectEach = U.objectEach,
  23389. offset = U.offset,
  23390. pick = U.pick,
  23391. splat = U.splat;
  23392. /**
  23393. * One position in relation to an axis.
  23394. *
  23395. * @interface Highcharts.PointerAxisCoordinateObject
  23396. */ /**
  23397. * Related axis.
  23398. *
  23399. * @name Highcharts.PointerAxisCoordinateObject#axis
  23400. * @type {Highcharts.Axis}
  23401. */ /**
  23402. * Axis value.
  23403. *
  23404. * @name Highcharts.PointerAxisCoordinateObject#value
  23405. * @type {number}
  23406. */
  23407. /**
  23408. * Positions in terms of axis values.
  23409. *
  23410. * @interface Highcharts.PointerAxisCoordinatesObject
  23411. */ /**
  23412. * Positions on the x-axis.
  23413. * @name Highcharts.PointerAxisCoordinatesObject#xAxis
  23414. * @type {Array<Highcharts.PointerAxisCoordinateObject>}
  23415. */ /**
  23416. * Positions on the y-axis.
  23417. * @name Highcharts.PointerAxisCoordinatesObject#yAxis
  23418. * @type {Array<Highcharts.PointerAxisCoordinateObject>}
  23419. */
  23420. /**
  23421. * Pointer coordinates.
  23422. *
  23423. * @interface Highcharts.PointerCoordinatesObject
  23424. */ /**
  23425. * @name Highcharts.PointerCoordinatesObject#chartX
  23426. * @type {number}
  23427. */ /**
  23428. * @name Highcharts.PointerCoordinatesObject#chartY
  23429. * @type {number}
  23430. */
  23431. /**
  23432. * A native browser mouse or touch event, extended with position information
  23433. * relative to the {@link Chart.container}.
  23434. *
  23435. * @interface Highcharts.PointerEventObject
  23436. * @extends global.PointerEvent
  23437. */ /**
  23438. * The X coordinate of the pointer interaction relative to the chart.
  23439. *
  23440. * @name Highcharts.PointerEventObject#chartX
  23441. * @type {number}
  23442. */ /**
  23443. * The Y coordinate of the pointer interaction relative to the chart.
  23444. *
  23445. * @name Highcharts.PointerEventObject#chartY
  23446. * @type {number}
  23447. */
  23448. /**
  23449. * Axis-specific data of a selection.
  23450. *
  23451. * @interface Highcharts.SelectDataObject
  23452. */ /**
  23453. * @name Highcharts.SelectDataObject#axis
  23454. * @type {Highcharts.Axis}
  23455. */ /**
  23456. * @name Highcharts.SelectDataObject#max
  23457. * @type {number}
  23458. */ /**
  23459. * @name Highcharts.SelectDataObject#min
  23460. * @type {number}
  23461. */
  23462. /**
  23463. * Object for select events.
  23464. *
  23465. * @interface Highcharts.SelectEventObject
  23466. */ /**
  23467. * @name Highcharts.SelectEventObject#originalEvent
  23468. * @type {global.Event}
  23469. */ /**
  23470. * @name Highcharts.SelectEventObject#xAxis
  23471. * @type {Array<Highcharts.SelectDataObject>}
  23472. */ /**
  23473. * @name Highcharts.SelectEventObject#yAxis
  23474. * @type {Array<Highcharts.SelectDataObject>}
  23475. */
  23476. ''; // detach doclets above
  23477. /* eslint-disable no-invalid-this, valid-jsdoc */
  23478. /**
  23479. * The mouse and touch tracker object. Each {@link Chart} item has one
  23480. * assosiated Pointer item that can be accessed from the {@link Chart.pointer}
  23481. * property.
  23482. *
  23483. * @class
  23484. * @name Highcharts.Pointer
  23485. *
  23486. * @param {Highcharts.Chart} chart
  23487. * The chart instance.
  23488. *
  23489. * @param {Highcharts.Options} options
  23490. * The root options object. The pointer uses options from the chart and
  23491. * tooltip structures.
  23492. */
  23493. var Pointer = /** @class */ (function () {
  23494. /* *
  23495. *
  23496. * Constructors
  23497. *
  23498. * */
  23499. function Pointer(chart, options) {
  23500. this.lastValidTouch = {};
  23501. this.pinchDown = [];
  23502. this.runChartClick = false;
  23503. this.chart = chart;
  23504. this.hasDragged = false;
  23505. this.options = options;
  23506. this.unbindContainerMouseLeave = function () { };
  23507. this.unbindContainerMouseEnter = function () { };
  23508. this.init(chart, options);
  23509. }
  23510. /* *
  23511. *
  23512. * Functions
  23513. *
  23514. * */
  23515. /**
  23516. * Set inactive state to all series that are not currently hovered,
  23517. * or, if `inactiveOtherPoints` is set to true, set inactive state to
  23518. * all points within that series.
  23519. *
  23520. * @private
  23521. * @function Highcharts.Pointer#applyInactiveState
  23522. * @param {Array<Highcharts.Point>} points
  23523. * Currently hovered points
  23524. */
  23525. Pointer.prototype.applyInactiveState = function (points) {
  23526. var activeSeries = [],
  23527. series;
  23528. // Get all active series from the hovered points
  23529. (points || []).forEach(function (item) {
  23530. series = item.series;
  23531. // Include itself
  23532. activeSeries.push(series);
  23533. // Include parent series
  23534. if (series.linkedParent) {
  23535. activeSeries.push(series.linkedParent);
  23536. }
  23537. // Include all child series
  23538. if (series.linkedSeries) {
  23539. activeSeries = activeSeries.concat(series.linkedSeries);
  23540. }
  23541. // Include navigator series
  23542. if (series.navigatorSeries) {
  23543. activeSeries.push(series.navigatorSeries);
  23544. }
  23545. });
  23546. // Now loop over all series, filtering out active series
  23547. this.chart.series.forEach(function (inactiveSeries) {
  23548. if (activeSeries.indexOf(inactiveSeries) === -1) {
  23549. // Inactive series
  23550. inactiveSeries.setState('inactive', true);
  23551. }
  23552. else if (inactiveSeries.options.inactiveOtherPoints) {
  23553. // Active series, but other points should be inactivated
  23554. inactiveSeries.setAllPointsToState('inactive');
  23555. }
  23556. });
  23557. };
  23558. /**
  23559. * Destroys the Pointer object and disconnects DOM events.
  23560. *
  23561. * @function Highcharts.Pointer#destroy
  23562. */
  23563. Pointer.prototype.destroy = function () {
  23564. var pointer = this;
  23565. if (typeof pointer.unDocMouseMove !== 'undefined') {
  23566. pointer.unDocMouseMove();
  23567. }
  23568. this.unbindContainerMouseLeave();
  23569. if (!H.chartCount) {
  23570. if (H.unbindDocumentMouseUp) {
  23571. H.unbindDocumentMouseUp = H.unbindDocumentMouseUp();
  23572. }
  23573. if (H.unbindDocumentTouchEnd) {
  23574. H.unbindDocumentTouchEnd = H.unbindDocumentTouchEnd();
  23575. }
  23576. }
  23577. // memory and CPU leak
  23578. clearInterval(pointer.tooltipTimeout);
  23579. objectEach(pointer, function (_val, prop) {
  23580. pointer[prop] = void 0;
  23581. });
  23582. };
  23583. /**
  23584. * Perform a drag operation in response to a mousemove event while the mouse
  23585. * is down.
  23586. *
  23587. * @private
  23588. * @function Highcharts.Pointer#drag
  23589. *
  23590. * @param {Highcharts.PointerEventObject} e
  23591. *
  23592. * @return {void}
  23593. */
  23594. Pointer.prototype.drag = function (e) {
  23595. var chart = this.chart,
  23596. chartOptions = chart.options.chart,
  23597. chartX = e.chartX,
  23598. chartY = e.chartY,
  23599. zoomHor = this.zoomHor,
  23600. zoomVert = this.zoomVert,
  23601. plotLeft = chart.plotLeft,
  23602. plotTop = chart.plotTop,
  23603. plotWidth = chart.plotWidth,
  23604. plotHeight = chart.plotHeight,
  23605. clickedInside,
  23606. size,
  23607. selectionMarker = this.selectionMarker,
  23608. mouseDownX = (this.mouseDownX || 0),
  23609. mouseDownY = (this.mouseDownY || 0),
  23610. panningEnabled = isObject(chartOptions.panning) ?
  23611. chartOptions.panning && chartOptions.panning.enabled :
  23612. chartOptions.panning,
  23613. panKey = (chartOptions.panKey && e[chartOptions.panKey + 'Key']);
  23614. // If the device supports both touch and mouse (like IE11), and we are
  23615. // touch-dragging inside the plot area, don't handle the mouse event.
  23616. // #4339.
  23617. if (selectionMarker && selectionMarker.touch) {
  23618. return;
  23619. }
  23620. // If the mouse is outside the plot area, adjust to cooordinates
  23621. // inside to prevent the selection marker from going outside
  23622. if (chartX < plotLeft) {
  23623. chartX = plotLeft;
  23624. }
  23625. else if (chartX > plotLeft + plotWidth) {
  23626. chartX = plotLeft + plotWidth;
  23627. }
  23628. if (chartY < plotTop) {
  23629. chartY = plotTop;
  23630. }
  23631. else if (chartY > plotTop + plotHeight) {
  23632. chartY = plotTop + plotHeight;
  23633. }
  23634. // determine if the mouse has moved more than 10px
  23635. this.hasDragged = Math.sqrt(Math.pow(mouseDownX - chartX, 2) +
  23636. Math.pow(mouseDownY - chartY, 2));
  23637. if (this.hasDragged > 10) {
  23638. clickedInside = chart.isInsidePlot(mouseDownX - plotLeft, mouseDownY - plotTop);
  23639. // make a selection
  23640. if (chart.hasCartesianSeries &&
  23641. (this.zoomX || this.zoomY) &&
  23642. clickedInside &&
  23643. !panKey) {
  23644. if (!selectionMarker) {
  23645. this.selectionMarker = selectionMarker =
  23646. chart.renderer.rect(plotLeft, plotTop, zoomHor ? 1 : plotWidth, zoomVert ? 1 : plotHeight, 0)
  23647. .attr({
  23648. 'class': 'highcharts-selection-marker',
  23649. zIndex: 7
  23650. })
  23651. .add();
  23652. if (!chart.styledMode) {
  23653. selectionMarker.attr({
  23654. fill: (chartOptions.selectionMarkerFill ||
  23655. color('#335cad')
  23656. .setOpacity(0.25).get())
  23657. });
  23658. }
  23659. }
  23660. }
  23661. // adjust the width of the selection marker
  23662. if (selectionMarker && zoomHor) {
  23663. size = chartX - mouseDownX;
  23664. selectionMarker.attr({
  23665. width: Math.abs(size),
  23666. x: (size > 0 ? 0 : size) + mouseDownX
  23667. });
  23668. }
  23669. // adjust the height of the selection marker
  23670. if (selectionMarker && zoomVert) {
  23671. size = chartY - mouseDownY;
  23672. selectionMarker.attr({
  23673. height: Math.abs(size),
  23674. y: (size > 0 ? 0 : size) + mouseDownY
  23675. });
  23676. }
  23677. // panning
  23678. if (clickedInside &&
  23679. !selectionMarker &&
  23680. panningEnabled) {
  23681. chart.pan(e, chartOptions.panning);
  23682. }
  23683. }
  23684. };
  23685. /**
  23686. * Start a drag operation.
  23687. *
  23688. * @private
  23689. * @function Highcharts.Pointer#dragStart
  23690. *
  23691. * @param {Highcharts.PointerEventObject} e
  23692. *
  23693. * @return {void}
  23694. */
  23695. Pointer.prototype.dragStart = function (e) {
  23696. var chart = this.chart;
  23697. // Record the start position
  23698. chart.mouseIsDown = e.type;
  23699. chart.cancelClick = false;
  23700. chart.mouseDownX = this.mouseDownX = e.chartX;
  23701. chart.mouseDownY = this.mouseDownY = e.chartY;
  23702. };
  23703. /**
  23704. * On mouse up or touch end across the entire document, drop the selection.
  23705. *
  23706. * @private
  23707. * @function Highcharts.Pointer#drop
  23708. *
  23709. * @param {global.Event} e
  23710. */
  23711. Pointer.prototype.drop = function (e) {
  23712. var pointer = this,
  23713. chart = this.chart,
  23714. hasPinched = this.hasPinched;
  23715. if (this.selectionMarker) {
  23716. var selectionData = {
  23717. originalEvent: e,
  23718. xAxis: [],
  23719. yAxis: []
  23720. },
  23721. selectionBox = this.selectionMarker,
  23722. selectionLeft = selectionBox.attr ?
  23723. selectionBox.attr('x') :
  23724. selectionBox.x,
  23725. selectionTop = selectionBox.attr ?
  23726. selectionBox.attr('y') :
  23727. selectionBox.y,
  23728. selectionWidth = selectionBox.attr ?
  23729. selectionBox.attr('width') :
  23730. selectionBox.width,
  23731. selectionHeight = selectionBox.attr ?
  23732. selectionBox.attr('height') :
  23733. selectionBox.height,
  23734. runZoom;
  23735. // a selection has been made
  23736. if (this.hasDragged || hasPinched) {
  23737. // record each axis' min and max
  23738. chart.axes.forEach(function (axis) {
  23739. if (axis.zoomEnabled &&
  23740. defined(axis.min) &&
  23741. (hasPinched ||
  23742. pointer[{
  23743. xAxis: 'zoomX',
  23744. yAxis: 'zoomY'
  23745. }[axis.coll]]) &&
  23746. isNumber(selectionLeft) &&
  23747. isNumber(selectionTop)) { // #859, #3569
  23748. var horiz = axis.horiz,
  23749. minPixelPadding = e.type === 'touchend' ?
  23750. axis.minPixelPadding :
  23751. 0, // #1207, #3075
  23752. selectionMin = axis.toValue((horiz ? selectionLeft : selectionTop) +
  23753. minPixelPadding),
  23754. selectionMax = axis.toValue((horiz ?
  23755. selectionLeft + selectionWidth :
  23756. selectionTop + selectionHeight) - minPixelPadding);
  23757. selectionData[axis.coll].push({
  23758. axis: axis,
  23759. // Min/max for reversed axes
  23760. min: Math.min(selectionMin, selectionMax),
  23761. max: Math.max(selectionMin, selectionMax)
  23762. });
  23763. runZoom = true;
  23764. }
  23765. });
  23766. if (runZoom) {
  23767. fireEvent(chart, 'selection', selectionData, function (args) {
  23768. chart.zoom(extend(args, hasPinched ?
  23769. { animation: false } :
  23770. null));
  23771. });
  23772. }
  23773. }
  23774. if (isNumber(chart.index)) {
  23775. this.selectionMarker = this.selectionMarker.destroy();
  23776. }
  23777. // Reset scaling preview
  23778. if (hasPinched) {
  23779. this.scaleGroups();
  23780. }
  23781. }
  23782. // Reset all. Check isNumber because it may be destroyed on mouse up
  23783. // (#877)
  23784. if (chart && isNumber(chart.index)) {
  23785. css(chart.container, { cursor: chart._cursor });
  23786. chart.cancelClick = this.hasDragged > 10; // #370
  23787. chart.mouseIsDown = this.hasDragged = this.hasPinched = false;
  23788. this.pinchDown = [];
  23789. }
  23790. };
  23791. /**
  23792. * Finds the closest point to a set of coordinates, using the k-d-tree
  23793. * algorithm.
  23794. *
  23795. * @function Highcharts.Pointer#findNearestKDPoint
  23796. *
  23797. * @param {Array<Highcharts.Series>} series
  23798. * All the series to search in.
  23799. *
  23800. * @param {boolean|undefined} shared
  23801. * Whether it is a shared tooltip or not.
  23802. *
  23803. * @param {Highcharts.PointerEventObject} e
  23804. * The pointer event object, containing chart coordinates of the
  23805. * pointer.
  23806. *
  23807. * @return {Highcharts.Point|undefined}
  23808. * The point closest to given coordinates.
  23809. */
  23810. Pointer.prototype.findNearestKDPoint = function (series, shared, e) {
  23811. var chart = this.chart;
  23812. var hoverPoint = chart.hoverPoint;
  23813. var tooltip = chart.tooltip;
  23814. if (hoverPoint &&
  23815. tooltip &&
  23816. tooltip.isStickyOnContact()) {
  23817. return hoverPoint;
  23818. }
  23819. var closest;
  23820. /** @private */
  23821. function sort(p1, p2) {
  23822. var isCloserX = p1.distX - p2.distX,
  23823. isCloser = p1.dist - p2.dist,
  23824. isAbove = (p2.series.group && p2.series.group.zIndex) -
  23825. (p1.series.group && p1.series.group.zIndex),
  23826. result;
  23827. // We have two points which are not in the same place on xAxis
  23828. // and shared tooltip:
  23829. if (isCloserX !== 0 && shared) { // #5721
  23830. result = isCloserX;
  23831. // Points are not exactly in the same place on x/yAxis:
  23832. }
  23833. else if (isCloser !== 0) {
  23834. result = isCloser;
  23835. // The same xAxis and yAxis position, sort by z-index:
  23836. }
  23837. else if (isAbove !== 0) {
  23838. result = isAbove;
  23839. // The same zIndex, sort by array index:
  23840. }
  23841. else {
  23842. result =
  23843. p1.series.index > p2.series.index ?
  23844. -1 :
  23845. 1;
  23846. }
  23847. return result;
  23848. }
  23849. series.forEach(function (s) {
  23850. var noSharedTooltip = s.noSharedTooltip && shared,
  23851. compareX = (!noSharedTooltip &&
  23852. s.options.findNearestPointBy.indexOf('y') < 0),
  23853. point = s.searchPoint(e,
  23854. compareX);
  23855. if ( // Check that we actually found a point on the series.
  23856. isObject(point, true) &&
  23857. // Use the new point if it is closer.
  23858. (!isObject(closest, true) ||
  23859. (sort(closest, point) > 0))) {
  23860. closest = point;
  23861. }
  23862. });
  23863. return closest;
  23864. };
  23865. /**
  23866. * @private
  23867. * @function Highcharts.Pointer#getChartCoordinatesFromPoint
  23868. * @param {Highcharts.Point} point
  23869. * @param {boolean} [inverted]
  23870. * @return {Highcharts.PointerCoordinatesObject|undefined}
  23871. */
  23872. Pointer.prototype.getChartCoordinatesFromPoint = function (point, inverted) {
  23873. var series = point.series,
  23874. xAxis = series.xAxis,
  23875. yAxis = series.yAxis,
  23876. plotX = pick(point.clientX,
  23877. point.plotX),
  23878. shapeArgs = point.shapeArgs;
  23879. if (xAxis && yAxis) {
  23880. return inverted ? {
  23881. chartX: xAxis.len + xAxis.pos - plotX,
  23882. chartY: yAxis.len + yAxis.pos - point.plotY
  23883. } : {
  23884. chartX: plotX + xAxis.pos,
  23885. chartY: point.plotY + yAxis.pos
  23886. };
  23887. }
  23888. if (shapeArgs && shapeArgs.x && shapeArgs.y) {
  23889. // E.g. pies do not have axes
  23890. return {
  23891. chartX: shapeArgs.x,
  23892. chartY: shapeArgs.y
  23893. };
  23894. }
  23895. };
  23896. /**
  23897. * Return the cached chartPosition if it is available on the Pointer,
  23898. * otherwise find it. Running offset is quite expensive, so it should be
  23899. * avoided when we know the chart hasn't moved.
  23900. *
  23901. * @function Highcharts.Pointer#getChartPosition
  23902. *
  23903. * @return {Highcharts.OffsetObject}
  23904. * The offset of the chart container within the page
  23905. */
  23906. Pointer.prototype.getChartPosition = function () {
  23907. return (this.chartPosition ||
  23908. (this.chartPosition = offset(this.chart.container)));
  23909. };
  23910. /**
  23911. * Get the click position in terms of axis values.
  23912. *
  23913. * @function Highcharts.Pointer#getCoordinates
  23914. *
  23915. * @param {Highcharts.PointerEventObject} e
  23916. * Pointer event, extended with `chartX` and `chartY` properties.
  23917. *
  23918. * @return {Highcharts.PointerAxisCoordinatesObject}
  23919. */
  23920. Pointer.prototype.getCoordinates = function (e) {
  23921. var coordinates = {
  23922. xAxis: [],
  23923. yAxis: []
  23924. };
  23925. this.chart.axes.forEach(function (axis) {
  23926. coordinates[axis.isXAxis ? 'xAxis' : 'yAxis'].push({
  23927. axis: axis,
  23928. value: axis.toValue(e[axis.horiz ? 'chartX' : 'chartY'])
  23929. });
  23930. });
  23931. return coordinates;
  23932. };
  23933. /**
  23934. * Calculates what is the current hovered point/points and series.
  23935. *
  23936. * @private
  23937. * @function Highcharts.Pointer#getHoverData
  23938. *
  23939. * @param {Highcharts.Point|undefined} existingHoverPoint
  23940. * The point currrently beeing hovered.
  23941. *
  23942. * @param {Highcharts.Series|undefined} existingHoverSeries
  23943. * The series currently beeing hovered.
  23944. *
  23945. * @param {Array<Highcharts.Series>} series
  23946. * All the series in the chart.
  23947. *
  23948. * @param {boolean} isDirectTouch
  23949. * Is the pointer directly hovering the point.
  23950. *
  23951. * @param {boolean|undefined} shared
  23952. * Whether it is a shared tooltip or not.
  23953. *
  23954. * @param {Highcharts.PointerEventObject} [e]
  23955. * The triggering event, containing chart coordinates of the pointer.
  23956. *
  23957. * @return {object}
  23958. * Object containing resulting hover data: hoverPoint, hoverSeries,
  23959. * and hoverPoints.
  23960. */
  23961. Pointer.prototype.getHoverData = function (existingHoverPoint, existingHoverSeries, series, isDirectTouch, shared, e) {
  23962. var hoverPoint,
  23963. hoverPoints = [],
  23964. hoverSeries = existingHoverSeries,
  23965. useExisting = !!(isDirectTouch && existingHoverPoint),
  23966. notSticky = hoverSeries && !hoverSeries.stickyTracking,
  23967. // Which series to look in for the hover point
  23968. searchSeries,
  23969. // Parameters needed for beforeGetHoverData event.
  23970. eventArgs = {
  23971. chartX: e ? e.chartX : void 0,
  23972. chartY: e ? e.chartY : void 0,
  23973. shared: shared
  23974. },
  23975. filter = function (s) {
  23976. return (s.visible &&
  23977. !(!shared && s.directTouch) && // #3821
  23978. pick(s.options.enableMouseTracking,
  23979. true));
  23980. };
  23981. // Find chart.hoverPane and update filter method in polar.
  23982. fireEvent(this, 'beforeGetHoverData', eventArgs);
  23983. searchSeries = notSticky ?
  23984. // Only search on hovered series if it has stickyTracking false
  23985. [hoverSeries] :
  23986. // Filter what series to look in.
  23987. series.filter(function (s) {
  23988. return eventArgs.filter ? eventArgs.filter(s) : filter(s) &&
  23989. s.stickyTracking;
  23990. });
  23991. // Use existing hovered point or find the one closest to coordinates.
  23992. hoverPoint = useExisting || !e ?
  23993. existingHoverPoint :
  23994. this.findNearestKDPoint(searchSeries, shared, e);
  23995. // Assign hover series
  23996. hoverSeries = hoverPoint && hoverPoint.series;
  23997. // If we have a hoverPoint, assign hoverPoints.
  23998. if (hoverPoint) {
  23999. // When tooltip is shared, it displays more than one point
  24000. if (shared && !hoverSeries.noSharedTooltip) {
  24001. searchSeries = series.filter(function (s) {
  24002. return eventArgs.filter ?
  24003. eventArgs.filter(s) : filter(s) && !s.noSharedTooltip;
  24004. });
  24005. // Get all points with the same x value as the hoverPoint
  24006. searchSeries.forEach(function (s) {
  24007. var point = find(s.points,
  24008. function (p) {
  24009. return p.x === hoverPoint.x && !p.isNull;
  24010. });
  24011. if (isObject(point)) {
  24012. /*
  24013. * Boost returns a minimal point. Convert it to a usable
  24014. * point for tooltip and states.
  24015. */
  24016. if (s.chart.isBoosting) {
  24017. point = s.getPoint(point);
  24018. }
  24019. hoverPoints.push(point);
  24020. }
  24021. });
  24022. }
  24023. else {
  24024. hoverPoints.push(hoverPoint);
  24025. }
  24026. }
  24027. // Check whether the hoverPoint is inside pane we are hovering over.
  24028. eventArgs = { hoverPoint: hoverPoint };
  24029. fireEvent(this, 'afterGetHoverData', eventArgs);
  24030. return {
  24031. hoverPoint: eventArgs.hoverPoint,
  24032. hoverSeries: hoverSeries,
  24033. hoverPoints: hoverPoints
  24034. };
  24035. };
  24036. /**
  24037. * @private
  24038. * @function Highcharts.Pointer#getPointFromEvent
  24039. *
  24040. * @param {global.Event} e
  24041. *
  24042. * @return {Highcharts.Point|undefined}
  24043. */
  24044. Pointer.prototype.getPointFromEvent = function (e) {
  24045. var target = e.target,
  24046. point;
  24047. while (target && !point) {
  24048. point = target.point;
  24049. target = target.parentNode;
  24050. }
  24051. return point;
  24052. };
  24053. /**
  24054. * @private
  24055. * @function Highcharts.Pointer#onTrackerMouseOut
  24056. *
  24057. * @param {Highcharts.PointerEventObject} e
  24058. *
  24059. * @return {void}
  24060. */
  24061. Pointer.prototype.onTrackerMouseOut = function (e) {
  24062. var chart = this.chart;
  24063. var relatedTarget = e.relatedTarget || e.toElement;
  24064. var series = chart.hoverSeries;
  24065. this.isDirectTouch = false;
  24066. if (series &&
  24067. relatedTarget &&
  24068. !series.stickyTracking &&
  24069. !this.inClass(relatedTarget, 'highcharts-tooltip') &&
  24070. (!this.inClass(relatedTarget, 'highcharts-series-' + series.index) || // #2499, #4465, #5553
  24071. !this.inClass(relatedTarget, 'highcharts-tracker'))) {
  24072. series.onMouseOut();
  24073. }
  24074. };
  24075. /**
  24076. * Utility to detect whether an element has, or has a parent with, a
  24077. * specificclass name. Used on detection of tracker objects and on deciding
  24078. * whether hovering the tooltip should cause the active series to mouse out.
  24079. *
  24080. * @function Highcharts.Pointer#inClass
  24081. *
  24082. * @param {Highcharts.SVGDOMElement|Highcharts.HTMLDOMElement} element
  24083. * The element to investigate.
  24084. *
  24085. * @param {string} className
  24086. * The class name to look for.
  24087. *
  24088. * @return {boolean|undefined}
  24089. * True if either the element or one of its parents has the given
  24090. * class name.
  24091. */
  24092. Pointer.prototype.inClass = function (element, className) {
  24093. var elemClassName;
  24094. while (element) {
  24095. elemClassName = attr(element, 'class');
  24096. if (elemClassName) {
  24097. if (elemClassName.indexOf(className) !== -1) {
  24098. return true;
  24099. }
  24100. if (elemClassName.indexOf('highcharts-container') !== -1) {
  24101. return false;
  24102. }
  24103. }
  24104. element = element.parentNode;
  24105. }
  24106. };
  24107. /**
  24108. * Initialize the Pointer.
  24109. *
  24110. * @private
  24111. * @function Highcharts.Pointer#init
  24112. *
  24113. * @param {Highcharts.Chart} chart
  24114. * The Chart instance.
  24115. *
  24116. * @param {Highcharts.Options} options
  24117. * The root options object. The pointer uses options from the chart
  24118. * and tooltip structures.
  24119. *
  24120. * @return {void}
  24121. */
  24122. Pointer.prototype.init = function (chart, options) {
  24123. // Store references
  24124. this.options = options;
  24125. this.chart = chart;
  24126. // Do we need to handle click on a touch device?
  24127. this.runChartClick =
  24128. options.chart.events &&
  24129. !!options.chart.events.click;
  24130. this.pinchDown = [];
  24131. this.lastValidTouch = {};
  24132. if (Tooltip) {
  24133. /**
  24134. * Tooltip object for points of series.
  24135. *
  24136. * @name Highcharts.Chart#tooltip
  24137. * @type {Highcharts.Tooltip}
  24138. */
  24139. chart.tooltip = new Tooltip(chart, options.tooltip);
  24140. this.followTouchMove = pick(options.tooltip.followTouchMove, true);
  24141. }
  24142. this.setDOMEvents();
  24143. };
  24144. /**
  24145. * Takes a browser event object and extends it with custom Highcharts
  24146. * properties `chartX` and `chartY` in order to work on the internal
  24147. * coordinate system.
  24148. *
  24149. * @function Highcharts.Pointer#normalize
  24150. *
  24151. * @param {global.MouseEvent|global.PointerEvent|global.TouchEvent} e
  24152. * Event object in standard browsers.
  24153. *
  24154. * @param {Highcharts.OffsetObject} [chartPosition]
  24155. * Additional chart offset.
  24156. *
  24157. * @return {Highcharts.PointerEventObject}
  24158. * A browser event with extended properties `chartX` and `chartY`.
  24159. */
  24160. Pointer.prototype.normalize = function (e, chartPosition) {
  24161. var touches = e.touches;
  24162. // iOS (#2757)
  24163. var ePos = (touches ?
  24164. touches.length ?
  24165. touches.item(0) :
  24166. (pick(// #13534
  24167. touches.changedTouches,
  24168. e.changedTouches))[0] :
  24169. e);
  24170. // Get mouse position
  24171. if (!chartPosition) {
  24172. chartPosition = this.getChartPosition();
  24173. }
  24174. var chartX = ePos.pageX - chartPosition.left,
  24175. chartY = ePos.pageY - chartPosition.top;
  24176. // #11329 - when there is scaling on a parent element, we need to take
  24177. // this into account
  24178. var containerScaling = this.chart.containerScaling;
  24179. if (containerScaling) {
  24180. chartX /= containerScaling.scaleX;
  24181. chartY /= containerScaling.scaleY;
  24182. }
  24183. return extend(e, {
  24184. chartX: Math.round(chartX),
  24185. chartY: Math.round(chartY)
  24186. });
  24187. };
  24188. /**
  24189. * @private
  24190. * @function Highcharts.Pointer#onContainerClick
  24191. */
  24192. Pointer.prototype.onContainerClick = function (e) {
  24193. var chart = this.chart;
  24194. var hoverPoint = chart.hoverPoint;
  24195. var pEvt = this.normalize(e);
  24196. var plotLeft = chart.plotLeft;
  24197. var plotTop = chart.plotTop;
  24198. if (!chart.cancelClick) {
  24199. // On tracker click, fire the series and point events. #783, #1583
  24200. if (hoverPoint &&
  24201. this.inClass(pEvt.target, 'highcharts-tracker')) {
  24202. // the series click event
  24203. fireEvent(hoverPoint.series, 'click', extend(pEvt, {
  24204. point: hoverPoint
  24205. }));
  24206. // the point click event
  24207. if (chart.hoverPoint) { // it may be destroyed (#1844)
  24208. hoverPoint.firePointEvent('click', pEvt);
  24209. }
  24210. // When clicking outside a tracker, fire a chart event
  24211. }
  24212. else {
  24213. extend(pEvt, this.getCoordinates(pEvt));
  24214. // fire a click event in the chart
  24215. if (chart.isInsidePlot((pEvt.chartX - plotLeft), (pEvt.chartY - plotTop))) {
  24216. fireEvent(chart, 'click', pEvt);
  24217. }
  24218. }
  24219. }
  24220. };
  24221. /**
  24222. * @private
  24223. * @function Highcharts.Pointer#onContainerMouseDown
  24224. *
  24225. * @param {global.MouseEvent} e
  24226. */
  24227. Pointer.prototype.onContainerMouseDown = function (e) {
  24228. var isPrimaryButton = ((e.buttons || e.button) & 1) === 1;
  24229. // Normalize before the 'if' for the legacy IE (#7850)
  24230. e = this.normalize(e);
  24231. // #11635, Firefox does not reliable fire move event after click scroll
  24232. if (H.isFirefox &&
  24233. e.button !== 0) {
  24234. this.onContainerMouseMove(e);
  24235. }
  24236. // #11635, limiting to primary button (incl. IE 8 support)
  24237. if (typeof e.button === 'undefined' ||
  24238. isPrimaryButton) {
  24239. this.zoomOption(e);
  24240. // #295, #13737 solve conflict between container drag and chart zoom
  24241. if (isPrimaryButton &&
  24242. e.preventDefault) {
  24243. e.preventDefault();
  24244. }
  24245. this.dragStart(e);
  24246. }
  24247. };
  24248. /**
  24249. * When mouse leaves the container, hide the tooltip.
  24250. *
  24251. * @private
  24252. * @function Highcharts.Pointer#onContainerMouseLeave
  24253. *
  24254. * @param {global.MouseEvent} e
  24255. *
  24256. * @return {void}
  24257. */
  24258. Pointer.prototype.onContainerMouseLeave = function (e) {
  24259. var chart = charts[pick(H.hoverChartIndex, -1)];
  24260. var tooltip = this.chart.tooltip;
  24261. e = this.normalize(e);
  24262. // #4886, MS Touch end fires mouseleave but with no related target
  24263. if (chart &&
  24264. (e.relatedTarget || e.toElement)) {
  24265. chart.pointer.reset();
  24266. // Also reset the chart position, used in #149 fix
  24267. chart.pointer.chartPosition = void 0;
  24268. }
  24269. if ( // #11635, Firefox wheel scroll does not fire out events consistently
  24270. tooltip &&
  24271. !tooltip.isHidden) {
  24272. this.reset();
  24273. }
  24274. };
  24275. /**
  24276. * When mouse enters the container, delete pointer's chartPosition.
  24277. *
  24278. * @private
  24279. * @function Highcharts.Pointer#onContainerMouseEnter
  24280. *
  24281. * @param {global.MouseEvent} e
  24282. *
  24283. * @return {void}
  24284. */
  24285. Pointer.prototype.onContainerMouseEnter = function (e) {
  24286. delete this.chartPosition;
  24287. };
  24288. /**
  24289. * The mousemove, touchmove and touchstart event handler
  24290. *
  24291. * @private
  24292. * @function Highcharts.Pointer#onContainerMouseMove
  24293. *
  24294. * @param {global.MouseEvent} e
  24295. *
  24296. * @return {void}
  24297. */
  24298. Pointer.prototype.onContainerMouseMove = function (e) {
  24299. var chart = this.chart;
  24300. var pEvt = this.normalize(e);
  24301. this.setHoverChartIndex();
  24302. // In IE8 we apparently need this returnValue set to false in order to
  24303. // avoid text being selected. But in Chrome, e.returnValue is prevented,
  24304. // plus we don't need to run e.preventDefault to prevent selected text
  24305. // in modern browsers. So we set it conditionally. Remove it when IE8 is
  24306. // no longer needed. #2251, #3224.
  24307. if (!pEvt.preventDefault) {
  24308. pEvt.returnValue = false;
  24309. }
  24310. if (chart.mouseIsDown === 'mousedown') {
  24311. this.drag(pEvt);
  24312. }
  24313. // Show the tooltip and run mouse over events (#977)
  24314. if (!chart.openMenu &&
  24315. (this.inClass(pEvt.target, 'highcharts-tracker') ||
  24316. chart.isInsidePlot((pEvt.chartX - chart.plotLeft), (pEvt.chartY - chart.plotTop)))) {
  24317. this.runPointActions(pEvt);
  24318. }
  24319. };
  24320. /**
  24321. * @private
  24322. * @function Highcharts.Pointer#onDocumentTouchEnd
  24323. *
  24324. * @param {Highcharts.PointerEventObject} e
  24325. *
  24326. * @return {void}
  24327. */
  24328. Pointer.prototype.onDocumentTouchEnd = function (e) {
  24329. if (charts[H.hoverChartIndex]) {
  24330. charts[H.hoverChartIndex].pointer.drop(e);
  24331. }
  24332. };
  24333. /**
  24334. * @private
  24335. * @function Highcharts.Pointer#onContainerTouchMove
  24336. *
  24337. * @param {Highcharts.PointerEventObject} e
  24338. *
  24339. * @return {void}
  24340. */
  24341. Pointer.prototype.onContainerTouchMove = function (e) {
  24342. this.touch(e);
  24343. };
  24344. /**
  24345. * @private
  24346. * @function Highcharts.Pointer#onContainerTouchStart
  24347. *
  24348. * @param {Highcharts.PointerEventObject} e
  24349. *
  24350. * @return {void}
  24351. */
  24352. Pointer.prototype.onContainerTouchStart = function (e) {
  24353. this.zoomOption(e);
  24354. this.touch(e, true);
  24355. };
  24356. /**
  24357. * Special handler for mouse move that will hide the tooltip when the mouse
  24358. * leaves the plotarea. Issue #149 workaround. The mouseleave event does not
  24359. * always fire.
  24360. *
  24361. * @private
  24362. * @function Highcharts.Pointer#onDocumentMouseMove
  24363. *
  24364. * @param {global.MouseEvent} e
  24365. *
  24366. * @return {void}
  24367. */
  24368. Pointer.prototype.onDocumentMouseMove = function (e) {
  24369. var chart = this.chart;
  24370. var chartPosition = this.chartPosition;
  24371. var pEvt = this.normalize(e,
  24372. chartPosition);
  24373. var tooltip = chart.tooltip;
  24374. // If we're outside, hide the tooltip
  24375. if (chartPosition &&
  24376. (!tooltip ||
  24377. !tooltip.isStickyOnContact()) &&
  24378. !chart.isInsidePlot(pEvt.chartX - chart.plotLeft, pEvt.chartY - chart.plotTop) &&
  24379. !this.inClass(pEvt.target, 'highcharts-tracker')) {
  24380. this.reset();
  24381. }
  24382. };
  24383. /**
  24384. * @private
  24385. * @function Highcharts.Pointer#onDocumentMouseUp
  24386. *
  24387. * @param {global.MouseEvent} e
  24388. *
  24389. * @return {void}
  24390. */
  24391. Pointer.prototype.onDocumentMouseUp = function (e) {
  24392. var chart = charts[pick(H.hoverChartIndex, -1)];
  24393. if (chart) {
  24394. chart.pointer.drop(e);
  24395. }
  24396. };
  24397. /**
  24398. * Handle touch events with two touches
  24399. *
  24400. * @private
  24401. * @function Highcharts.Pointer#pinch
  24402. *
  24403. * @param {Highcharts.PointerEventObject} e
  24404. *
  24405. * @return {void}
  24406. */
  24407. Pointer.prototype.pinch = function (e) {
  24408. var self = this,
  24409. chart = self.chart,
  24410. pinchDown = self.pinchDown,
  24411. touches = (e.touches || []),
  24412. touchesLength = touches.length,
  24413. lastValidTouch = self.lastValidTouch,
  24414. hasZoom = self.hasZoom,
  24415. selectionMarker = self.selectionMarker,
  24416. transform = {},
  24417. fireClickEvent = touchesLength === 1 && ((self.inClass(e.target, 'highcharts-tracker') &&
  24418. chart.runTrackerClick) ||
  24419. self.runChartClick),
  24420. clip = {};
  24421. // Don't initiate panning until the user has pinched. This prevents us
  24422. // from blocking page scrolling as users scroll down a long page
  24423. // (#4210).
  24424. if (touchesLength > 1) {
  24425. self.initiated = true;
  24426. }
  24427. // On touch devices, only proceed to trigger click if a handler is
  24428. // defined
  24429. if (hasZoom && self.initiated && !fireClickEvent && e.cancelable !== false) {
  24430. e.preventDefault();
  24431. }
  24432. // Normalize each touch
  24433. [].map.call(touches, function (e) {
  24434. return self.normalize(e);
  24435. });
  24436. // Register the touch start position
  24437. if (e.type === 'touchstart') {
  24438. [].forEach.call(touches, function (e, i) {
  24439. pinchDown[i] = { chartX: e.chartX, chartY: e.chartY };
  24440. });
  24441. lastValidTouch.x = [pinchDown[0].chartX, pinchDown[1] &&
  24442. pinchDown[1].chartX];
  24443. lastValidTouch.y = [pinchDown[0].chartY, pinchDown[1] &&
  24444. pinchDown[1].chartY];
  24445. // Identify the data bounds in pixels
  24446. chart.axes.forEach(function (axis) {
  24447. if (axis.zoomEnabled) {
  24448. var bounds = chart.bounds[axis.horiz ? 'h' : 'v'],
  24449. minPixelPadding = axis.minPixelPadding,
  24450. min = axis.toPixels(Math.min(pick(axis.options.min,
  24451. axis.dataMin),
  24452. axis.dataMin)),
  24453. max = axis.toPixels(Math.max(pick(axis.options.max,
  24454. axis.dataMax),
  24455. axis.dataMax)),
  24456. absMin = Math.min(min,
  24457. max),
  24458. absMax = Math.max(min,
  24459. max);
  24460. // Store the bounds for use in the touchmove handler
  24461. bounds.min = Math.min(axis.pos, absMin - minPixelPadding);
  24462. bounds.max = Math.max(axis.pos + axis.len, absMax + minPixelPadding);
  24463. }
  24464. });
  24465. self.res = true; // reset on next move
  24466. // Optionally move the tooltip on touchmove
  24467. }
  24468. else if (self.followTouchMove && touchesLength === 1) {
  24469. this.runPointActions(self.normalize(e));
  24470. // Event type is touchmove, handle panning and pinching
  24471. }
  24472. else if (pinchDown.length) { // can be 0 when releasing, if touchend
  24473. // fires first
  24474. // Set the marker
  24475. if (!selectionMarker) {
  24476. self.selectionMarker = selectionMarker = extend({
  24477. destroy: noop,
  24478. touch: true
  24479. }, chart.plotBox);
  24480. }
  24481. self.pinchTranslate(pinchDown, touches, transform, selectionMarker, clip, lastValidTouch);
  24482. self.hasPinched = hasZoom;
  24483. // Scale and translate the groups to provide visual feedback during
  24484. // pinching
  24485. self.scaleGroups(transform, clip);
  24486. if (self.res) {
  24487. self.res = false;
  24488. this.reset(false, 0);
  24489. }
  24490. }
  24491. };
  24492. /**
  24493. * Run translation operations
  24494. *
  24495. * @private
  24496. * @function Highcharts.Pointer#pinchTranslate
  24497. *
  24498. * @param {Array<*>} pinchDown
  24499. *
  24500. * @param {Array<Highcharts.PointerEventObject>} touches
  24501. *
  24502. * @param {*} transform
  24503. *
  24504. * @param {*} selectionMarker
  24505. *
  24506. * @param {*} clip
  24507. *
  24508. * @param {*} lastValidTouch
  24509. *
  24510. * @return {void}
  24511. */
  24512. Pointer.prototype.pinchTranslate = function (pinchDown, touches, transform, selectionMarker, clip, lastValidTouch) {
  24513. if (this.zoomHor) {
  24514. this.pinchTranslateDirection(true, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch);
  24515. }
  24516. if (this.zoomVert) {
  24517. this.pinchTranslateDirection(false, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch);
  24518. }
  24519. };
  24520. /**
  24521. * Run translation operations for each direction (horizontal and vertical)
  24522. * independently.
  24523. *
  24524. * @private
  24525. * @function Highcharts.Pointer#pinchTranslateDirection
  24526. *
  24527. * @param {boolean} horiz
  24528. *
  24529. * @param {Array<*>} pinchDown
  24530. *
  24531. * @param {Array<Highcharts.PointerEventObject>} touches
  24532. *
  24533. * @param {*} transform
  24534. *
  24535. * @param {*} selectionMarker
  24536. *
  24537. * @param {*} clip
  24538. *
  24539. * @param {*} lastValidTouch
  24540. *
  24541. * @param {number|undefined} [forcedScale=1]
  24542. *
  24543. * @return {void}
  24544. */
  24545. Pointer.prototype.pinchTranslateDirection = function (horiz, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch, forcedScale) {
  24546. 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 () {
  24547. // Don't zoom if fingers are too close on this axis
  24548. if (typeof touch1Now === 'number' &&
  24549. Math.abs(touch0Start - touch1Start) > 20) {
  24550. scale = forcedScale ||
  24551. Math.abs(touch0Now - touch1Now) /
  24552. Math.abs(touch0Start - touch1Start);
  24553. }
  24554. clipXY = ((plotLeftTop - touch0Now) / scale) + touch0Start;
  24555. selectionWH = chart['plot' + (horiz ? 'Width' : 'Height')] / scale;
  24556. };
  24557. // Set the scale, first pass
  24558. setScale();
  24559. // The clip position (x or y) is altered if out of bounds, the selection
  24560. // position is not
  24561. selectionXY = clipXY;
  24562. // Out of bounds
  24563. if (selectionXY < bounds.min) {
  24564. selectionXY = bounds.min;
  24565. outOfBounds = true;
  24566. }
  24567. else if (selectionXY + selectionWH > bounds.max) {
  24568. selectionXY = bounds.max - selectionWH;
  24569. outOfBounds = true;
  24570. }
  24571. // Is the chart dragged off its bounds, determined by dataMin and
  24572. // dataMax?
  24573. if (outOfBounds) {
  24574. // Modify the touchNow position in order to create an elastic drag
  24575. // movement. This indicates to the user that the chart is responsive
  24576. // but can't be dragged further.
  24577. touch0Now -= 0.8 * (touch0Now - lastValidTouch[xy][0]);
  24578. if (typeof touch1Now === 'number') {
  24579. touch1Now -= 0.8 * (touch1Now - lastValidTouch[xy][1]);
  24580. }
  24581. // Set the scale, second pass to adapt to the modified touchNow
  24582. // positions
  24583. setScale();
  24584. }
  24585. else {
  24586. lastValidTouch[xy] = [touch0Now, touch1Now];
  24587. }
  24588. // Set geometry for clipping, selection and transformation
  24589. if (!inverted) {
  24590. clip[xy] = clipXY - plotLeftTop;
  24591. clip[wh] = selectionWH;
  24592. }
  24593. scaleKey = inverted ? (horiz ? 'scaleY' : 'scaleX') : 'scale' + XY;
  24594. transformScale = inverted ? 1 / scale : scale;
  24595. selectionMarker[wh] = selectionWH;
  24596. selectionMarker[xy] = selectionXY;
  24597. transform[scaleKey] = scale;
  24598. transform['translate' + XY] = (transformScale * plotLeftTop) +
  24599. (touch0Now - (transformScale * touch0Start));
  24600. };
  24601. /**
  24602. * Reset the tracking by hiding the tooltip, the hover series state and the
  24603. * hover point
  24604. *
  24605. * @function Highcharts.Pointer#reset
  24606. *
  24607. * @param {boolean} [allowMove]
  24608. * Instead of destroying the tooltip altogether, allow moving it if
  24609. * possible.
  24610. *
  24611. * @param {number} [delay]
  24612. *
  24613. * @return {void}
  24614. */
  24615. Pointer.prototype.reset = function (allowMove, delay) {
  24616. var pointer = this,
  24617. chart = pointer.chart,
  24618. hoverSeries = chart.hoverSeries,
  24619. hoverPoint = chart.hoverPoint,
  24620. hoverPoints = chart.hoverPoints,
  24621. tooltip = chart.tooltip,
  24622. tooltipPoints = tooltip && tooltip.shared ?
  24623. hoverPoints :
  24624. hoverPoint;
  24625. // Check if the points have moved outside the plot area (#1003, #4736,
  24626. // #5101)
  24627. if (allowMove && tooltipPoints) {
  24628. splat(tooltipPoints).forEach(function (point) {
  24629. if (point.series.isCartesian &&
  24630. typeof point.plotX === 'undefined') {
  24631. allowMove = false;
  24632. }
  24633. });
  24634. }
  24635. // Just move the tooltip, #349
  24636. if (allowMove) {
  24637. if (tooltip && tooltipPoints && splat(tooltipPoints).length) {
  24638. tooltip.refresh(tooltipPoints);
  24639. if (tooltip.shared && hoverPoints) { // #8284
  24640. hoverPoints.forEach(function (point) {
  24641. point.setState(point.state, true);
  24642. if (point.series.isCartesian) {
  24643. if (point.series.xAxis.crosshair) {
  24644. point.series.xAxis
  24645. .drawCrosshair(null, point);
  24646. }
  24647. if (point.series.yAxis.crosshair) {
  24648. point.series.yAxis
  24649. .drawCrosshair(null, point);
  24650. }
  24651. }
  24652. });
  24653. }
  24654. else if (hoverPoint) { // #2500
  24655. hoverPoint.setState(hoverPoint.state, true);
  24656. chart.axes.forEach(function (axis) {
  24657. if (axis.crosshair &&
  24658. hoverPoint.series[axis.coll] === axis) {
  24659. axis.drawCrosshair(null, hoverPoint);
  24660. }
  24661. });
  24662. }
  24663. }
  24664. // Full reset
  24665. }
  24666. else {
  24667. if (hoverPoint) {
  24668. hoverPoint.onMouseOut();
  24669. }
  24670. if (hoverPoints) {
  24671. hoverPoints.forEach(function (point) {
  24672. point.setState();
  24673. });
  24674. }
  24675. if (hoverSeries) {
  24676. hoverSeries.onMouseOut();
  24677. }
  24678. if (tooltip) {
  24679. tooltip.hide(delay);
  24680. }
  24681. if (pointer.unDocMouseMove) {
  24682. pointer.unDocMouseMove = pointer.unDocMouseMove();
  24683. }
  24684. // Remove crosshairs
  24685. chart.axes.forEach(function (axis) {
  24686. axis.hideCrosshair();
  24687. });
  24688. pointer.hoverX = chart.hoverPoints = chart.hoverPoint = null;
  24689. }
  24690. };
  24691. /**
  24692. * With line type charts with a single tracker, get the point closest to the
  24693. * mouse. Run Point.onMouseOver and display tooltip for the point or points.
  24694. *
  24695. * @private
  24696. * @function Highcharts.Pointer#runPointActions
  24697. *
  24698. * @param {global.Event} e
  24699. *
  24700. * @param {Highcharts.PointerEventObject} [p]
  24701. *
  24702. * @return {void}
  24703. *
  24704. * @fires Highcharts.Point#event:mouseOut
  24705. * @fires Highcharts.Point#event:mouseOver
  24706. */
  24707. Pointer.prototype.runPointActions = function (e, p) {
  24708. var pointer = this,
  24709. chart = pointer.chart,
  24710. series = chart.series,
  24711. tooltip = (chart.tooltip && chart.tooltip.options.enabled ?
  24712. chart.tooltip :
  24713. void 0),
  24714. shared = (tooltip ?
  24715. tooltip.shared :
  24716. false),
  24717. hoverPoint = p || chart.hoverPoint,
  24718. hoverSeries = hoverPoint && hoverPoint.series || chart.hoverSeries,
  24719. // onMouseOver or already hovering a series with directTouch
  24720. isDirectTouch = (!e || e.type !== 'touchmove') && (!!p || ((hoverSeries && hoverSeries.directTouch) &&
  24721. pointer.isDirectTouch)),
  24722. hoverData = this.getHoverData(hoverPoint,
  24723. hoverSeries,
  24724. series,
  24725. isDirectTouch,
  24726. shared,
  24727. e),
  24728. useSharedTooltip,
  24729. followPointer,
  24730. anchor,
  24731. points;
  24732. // Update variables from hoverData.
  24733. hoverPoint = hoverData.hoverPoint;
  24734. points = hoverData.hoverPoints;
  24735. hoverSeries = hoverData.hoverSeries;
  24736. followPointer = hoverSeries && hoverSeries.tooltipOptions.followPointer;
  24737. useSharedTooltip = (shared &&
  24738. hoverSeries &&
  24739. !hoverSeries.noSharedTooltip);
  24740. // Refresh tooltip for kdpoint if new hover point or tooltip was hidden
  24741. // #3926, #4200
  24742. if (hoverPoint &&
  24743. // !(hoverSeries && hoverSeries.directTouch) &&
  24744. (hoverPoint !== chart.hoverPoint || (tooltip && tooltip.isHidden))) {
  24745. (chart.hoverPoints || []).forEach(function (p) {
  24746. if (points.indexOf(p) === -1) {
  24747. p.setState();
  24748. }
  24749. });
  24750. // Set normal state to previous series
  24751. if (chart.hoverSeries !== hoverSeries) {
  24752. hoverSeries.onMouseOver();
  24753. }
  24754. pointer.applyInactiveState(points);
  24755. // Do mouseover on all points (#3919, #3985, #4410, #5622)
  24756. (points || []).forEach(function (p) {
  24757. p.setState('hover');
  24758. });
  24759. // If tracking is on series in stead of on each point,
  24760. // fire mouseOver on hover point. // #4448
  24761. if (chart.hoverPoint) {
  24762. chart.hoverPoint.firePointEvent('mouseOut');
  24763. }
  24764. // Hover point may have been destroyed in the event handlers (#7127)
  24765. if (!hoverPoint.series) {
  24766. return;
  24767. }
  24768. /**
  24769. * Contains all hovered points.
  24770. *
  24771. * @name Highcharts.Chart#hoverPoints
  24772. * @type {Array<Highcharts.Point>|null}
  24773. */
  24774. chart.hoverPoints = points;
  24775. /**
  24776. * Contains the original hovered point.
  24777. *
  24778. * @name Highcharts.Chart#hoverPoint
  24779. * @type {Highcharts.Point|null}
  24780. */
  24781. chart.hoverPoint = hoverPoint;
  24782. /**
  24783. * Hover state should not be lost when axis is updated (#12569)
  24784. * Axis.update runs pointer.reset which uses chart.hoverPoint.state
  24785. * to apply state which does not exist in hoverPoint yet.
  24786. * The mouseOver event should be triggered when hoverPoint
  24787. * is correct.
  24788. */
  24789. hoverPoint.firePointEvent('mouseOver');
  24790. // Draw tooltip if necessary
  24791. if (tooltip) {
  24792. tooltip.refresh(useSharedTooltip ? points : hoverPoint, e);
  24793. }
  24794. // Update positions (regardless of kdpoint or hoverPoint)
  24795. }
  24796. else if (followPointer && tooltip && !tooltip.isHidden) {
  24797. anchor = tooltip.getAnchor([{}], e);
  24798. tooltip.updatePosition({ plotX: anchor[0], plotY: anchor[1] });
  24799. }
  24800. // Start the event listener to pick up the tooltip and crosshairs
  24801. if (!pointer.unDocMouseMove) {
  24802. pointer.unDocMouseMove = addEvent(chart.container.ownerDocument, 'mousemove', function (e) {
  24803. var chart = charts[H.hoverChartIndex];
  24804. if (chart) {
  24805. chart.pointer.onDocumentMouseMove(e);
  24806. }
  24807. });
  24808. }
  24809. // Issues related to crosshair #4927, #5269 #5066, #5658
  24810. chart.axes.forEach(function drawAxisCrosshair(axis) {
  24811. var snap = pick((axis.crosshair || {}).snap,
  24812. true);
  24813. var point;
  24814. if (snap) {
  24815. point = chart.hoverPoint; // #13002
  24816. if (!point || point.series[axis.coll] !== axis) {
  24817. point = find(points, function (p) {
  24818. return p.series[axis.coll] === axis;
  24819. });
  24820. }
  24821. }
  24822. // Axis has snapping crosshairs, and one of the hover points belongs
  24823. // to axis. Always call drawCrosshair when it is not snap.
  24824. if (point || !snap) {
  24825. axis.drawCrosshair(e, point);
  24826. // Axis has snapping crosshairs, but no hover point belongs to axis
  24827. }
  24828. else {
  24829. axis.hideCrosshair();
  24830. }
  24831. });
  24832. };
  24833. /**
  24834. * Scale series groups to a certain scale and translation.
  24835. *
  24836. * @private
  24837. * @function Highcharts.Pointer#scaleGroups
  24838. *
  24839. * @param {Highcharts.SeriesPlotBoxObject} [attribs]
  24840. *
  24841. * @param {boolean} [clip]
  24842. *
  24843. * @return {void}
  24844. */
  24845. Pointer.prototype.scaleGroups = function (attribs, clip) {
  24846. var chart = this.chart,
  24847. seriesAttribs;
  24848. // Scale each series
  24849. chart.series.forEach(function (series) {
  24850. seriesAttribs = attribs || series.getPlotBox(); // #1701
  24851. if (series.xAxis && series.xAxis.zoomEnabled && series.group) {
  24852. series.group.attr(seriesAttribs);
  24853. if (series.markerGroup) {
  24854. series.markerGroup.attr(seriesAttribs);
  24855. series.markerGroup.clip(clip ? chart.clipRect : null);
  24856. }
  24857. if (series.dataLabelsGroup) {
  24858. series.dataLabelsGroup.attr(seriesAttribs);
  24859. }
  24860. }
  24861. });
  24862. // Clip
  24863. chart.clipRect.attr(clip || chart.clipBox);
  24864. };
  24865. /**
  24866. * Set the JS DOM events on the container and document. This method should
  24867. * contain a one-to-one assignment between methods and their handlers. Any
  24868. * advanced logic should be moved to the handler reflecting the event's
  24869. * name.
  24870. *
  24871. * @private
  24872. * @function Highcharts.Pointer#setDOMEvents
  24873. *
  24874. * @return {void}
  24875. */
  24876. Pointer.prototype.setDOMEvents = function () {
  24877. var container = this.chart.container,
  24878. ownerDoc = container.ownerDocument;
  24879. container.onmousedown = this.onContainerMouseDown.bind(this);
  24880. container.onmousemove = this.onContainerMouseMove.bind(this);
  24881. container.onclick = this.onContainerClick.bind(this);
  24882. this.unbindContainerMouseEnter = addEvent(container, 'mouseenter', this.onContainerMouseEnter.bind(this));
  24883. this.unbindContainerMouseLeave = addEvent(container, 'mouseleave', this.onContainerMouseLeave.bind(this));
  24884. if (!H.unbindDocumentMouseUp) {
  24885. H.unbindDocumentMouseUp = addEvent(ownerDoc, 'mouseup', this.onDocumentMouseUp.bind(this));
  24886. }
  24887. if (H.hasTouch) {
  24888. addEvent(container, 'touchstart', this.onContainerTouchStart.bind(this));
  24889. addEvent(container, 'touchmove', this.onContainerTouchMove.bind(this));
  24890. if (!H.unbindDocumentTouchEnd) {
  24891. H.unbindDocumentTouchEnd = addEvent(ownerDoc, 'touchend', this.onDocumentTouchEnd.bind(this));
  24892. }
  24893. }
  24894. };
  24895. /**
  24896. * Sets the index of the hovered chart and leaves the previous hovered
  24897. * chart, to reset states like tooltip.
  24898. *
  24899. * @private
  24900. * @function Highcharts.Pointer#setHoverChartIndex
  24901. */
  24902. Pointer.prototype.setHoverChartIndex = function () {
  24903. var chart = this.chart;
  24904. var hoverChart = H.charts[pick(H.hoverChartIndex, -1)];
  24905. if (hoverChart &&
  24906. hoverChart !== chart) {
  24907. hoverChart.pointer.onContainerMouseLeave({ relatedTarget: true });
  24908. }
  24909. if (!hoverChart ||
  24910. !hoverChart.mouseIsDown) {
  24911. H.hoverChartIndex = chart.index;
  24912. }
  24913. };
  24914. /**
  24915. * General touch handler shared by touchstart and touchmove.
  24916. *
  24917. * @private
  24918. * @function Highcharts.Pointer#touch
  24919. *
  24920. * @param {Highcharts.PointerEventObject} e
  24921. *
  24922. * @param {boolean} [start]
  24923. *
  24924. * @return {void}
  24925. */
  24926. Pointer.prototype.touch = function (e, start) {
  24927. var chart = this.chart,
  24928. hasMoved,
  24929. pinchDown,
  24930. isInside;
  24931. this.setHoverChartIndex();
  24932. if (e.touches.length === 1) {
  24933. e = this.normalize(e);
  24934. isInside = chart.isInsidePlot(e.chartX - chart.plotLeft, e.chartY - chart.plotTop);
  24935. if (isInside && !chart.openMenu) {
  24936. // Run mouse events and display tooltip etc
  24937. if (start) {
  24938. this.runPointActions(e);
  24939. }
  24940. // Android fires touchmove events after the touchstart even if
  24941. // the finger hasn't moved, or moved only a pixel or two. In iOS
  24942. // however, the touchmove doesn't fire unless the finger moves
  24943. // more than ~4px. So we emulate this behaviour in Android by
  24944. // checking how much it moved, and cancelling on small
  24945. // distances. #3450.
  24946. if (e.type === 'touchmove') {
  24947. pinchDown = this.pinchDown;
  24948. hasMoved = pinchDown[0] ? Math.sqrt(// #5266
  24949. Math.pow(pinchDown[0].chartX - e.chartX, 2) +
  24950. Math.pow(pinchDown[0].chartY - e.chartY, 2)) >= 4 : false;
  24951. }
  24952. if (pick(hasMoved, true)) {
  24953. this.pinch(e);
  24954. }
  24955. }
  24956. else if (start) {
  24957. // Hide the tooltip on touching outside the plot area (#1203)
  24958. this.reset();
  24959. }
  24960. }
  24961. else if (e.touches.length === 2) {
  24962. this.pinch(e);
  24963. }
  24964. };
  24965. /**
  24966. * Resolve the zoomType option, this is reset on all touch start and mouse
  24967. * down events.
  24968. *
  24969. * @private
  24970. * @function Highcharts.Pointer#zoomOption
  24971. *
  24972. * @param {global.Event} e
  24973. * Event object.
  24974. *
  24975. * @param {void}
  24976. */
  24977. Pointer.prototype.zoomOption = function (e) {
  24978. var chart = this.chart,
  24979. options = chart.options.chart,
  24980. zoomType = options.zoomType || '',
  24981. inverted = chart.inverted,
  24982. zoomX,
  24983. zoomY;
  24984. // Look for the pinchType option
  24985. if (/touch/.test(e.type)) {
  24986. zoomType = pick(options.pinchType, zoomType);
  24987. }
  24988. this.zoomX = zoomX = /x/.test(zoomType);
  24989. this.zoomY = zoomY = /y/.test(zoomType);
  24990. this.zoomHor = (zoomX && !inverted) || (zoomY && inverted);
  24991. this.zoomVert = (zoomY && !inverted) || (zoomX && inverted);
  24992. this.hasZoom = zoomX || zoomY;
  24993. };
  24994. return Pointer;
  24995. }());
  24996. H.Pointer = Pointer;
  24997. return Pointer;
  24998. });
  24999. _registerModule(_modules, 'Core/MSPointer.js', [_modules['Core/Globals.js'], _modules['Core/Pointer.js'], _modules['Core/Utilities.js']], function (H, Pointer, U) {
  25000. /* *
  25001. *
  25002. * (c) 2010-2020 Torstein Honsi
  25003. *
  25004. * License: www.highcharts.com/license
  25005. *
  25006. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  25007. *
  25008. * */
  25009. var __extends = (this && this.__extends) || (function () {
  25010. var extendStatics = function (d,
  25011. b) {
  25012. extendStatics = Object.setPrototypeOf ||
  25013. ({ __proto__: [] } instanceof Array && function (d,
  25014. b) { d.__proto__ = b; }) ||
  25015. function (d,
  25016. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  25017. return extendStatics(d, b);
  25018. };
  25019. return function (d, b) {
  25020. extendStatics(d, b);
  25021. function __() { this.constructor = d; }
  25022. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  25023. };
  25024. })();
  25025. var charts = H.charts,
  25026. doc = H.doc,
  25027. noop = H.noop,
  25028. win = H.win;
  25029. var addEvent = U.addEvent,
  25030. css = U.css,
  25031. objectEach = U.objectEach,
  25032. removeEvent = U.removeEvent;
  25033. /* globals MSPointerEvent, PointerEvent */
  25034. // The touches object keeps track of the points being touched at all times
  25035. var touches = {};
  25036. var hasPointerEvent = !!win.PointerEvent;
  25037. /* eslint-disable valid-jsdoc */
  25038. /** @private */
  25039. function getWebkitTouches() {
  25040. var fake = [];
  25041. fake.item = function (i) {
  25042. return this[i];
  25043. };
  25044. objectEach(touches, function (touch) {
  25045. fake.push({
  25046. pageX: touch.pageX,
  25047. pageY: touch.pageY,
  25048. target: touch.target
  25049. });
  25050. });
  25051. return fake;
  25052. }
  25053. /** @private */
  25054. function translateMSPointer(e, method, wktype, func) {
  25055. var p;
  25056. if ((e.pointerType === 'touch' ||
  25057. e.pointerType === e.MSPOINTER_TYPE_TOUCH) && charts[H.hoverChartIndex]) {
  25058. func(e);
  25059. p = charts[H.hoverChartIndex].pointer;
  25060. p[method]({
  25061. type: wktype,
  25062. target: e.currentTarget,
  25063. preventDefault: noop,
  25064. touches: getWebkitTouches()
  25065. });
  25066. }
  25067. }
  25068. /** @private */
  25069. var MSPointer = /** @class */ (function (_super) {
  25070. __extends(MSPointer, _super);
  25071. function MSPointer() {
  25072. return _super !== null && _super.apply(this, arguments) || this;
  25073. }
  25074. /* *
  25075. *
  25076. * Functions
  25077. *
  25078. * */
  25079. /**
  25080. * Add or remove the MS Pointer specific events
  25081. *
  25082. * @private
  25083. * @function Highcharts.Pointer#batchMSEvents
  25084. *
  25085. * @param {Function} fn
  25086. *
  25087. * @return {void}
  25088. */
  25089. MSPointer.prototype.batchMSEvents = function (fn) {
  25090. fn(this.chart.container, hasPointerEvent ? 'pointerdown' : 'MSPointerDown', this.onContainerPointerDown);
  25091. fn(this.chart.container, hasPointerEvent ? 'pointermove' : 'MSPointerMove', this.onContainerPointerMove);
  25092. fn(doc, hasPointerEvent ? 'pointerup' : 'MSPointerUp', this.onDocumentPointerUp);
  25093. };
  25094. // Destroy MS events also
  25095. MSPointer.prototype.destroy = function () {
  25096. this.batchMSEvents(removeEvent);
  25097. _super.prototype.destroy.call(this);
  25098. };
  25099. // Disable default IE actions for pinch and such on chart element
  25100. MSPointer.prototype.init = function (chart, options) {
  25101. _super.prototype.init.call(this, chart, options);
  25102. if (this.hasZoom) { // #4014
  25103. css(chart.container, {
  25104. '-ms-touch-action': 'none',
  25105. 'touch-action': 'none'
  25106. });
  25107. }
  25108. };
  25109. /**
  25110. * @private
  25111. * @function Highcharts.Pointer#onContainerPointerDown
  25112. *
  25113. * @param {Highcharts.PointerEventObject} e
  25114. *
  25115. * @return {void}
  25116. */
  25117. MSPointer.prototype.onContainerPointerDown = function (e) {
  25118. translateMSPointer(e, 'onContainerTouchStart', 'touchstart', function (e) {
  25119. touches[e.pointerId] = {
  25120. pageX: e.pageX,
  25121. pageY: e.pageY,
  25122. target: e.currentTarget
  25123. };
  25124. });
  25125. };
  25126. /**
  25127. * @private
  25128. * @function Highcharts.Pointer#onContainerPointerMove
  25129. *
  25130. * @param {Highcharts.PointerEventObject} e
  25131. *
  25132. * @return {void}
  25133. */
  25134. MSPointer.prototype.onContainerPointerMove = function (e) {
  25135. translateMSPointer(e, 'onContainerTouchMove', 'touchmove', function (e) {
  25136. touches[e.pointerId] = ({ pageX: e.pageX, pageY: e.pageY });
  25137. if (!touches[e.pointerId].target) {
  25138. touches[e.pointerId].target = e.currentTarget;
  25139. }
  25140. });
  25141. };
  25142. /**
  25143. * @private
  25144. * @function Highcharts.Pointer#onDocumentPointerUp
  25145. *
  25146. * @param {Highcharts.PointerEventObject} e
  25147. *
  25148. * @return {void}
  25149. */
  25150. MSPointer.prototype.onDocumentPointerUp = function (e) {
  25151. translateMSPointer(e, 'onDocumentTouchEnd', 'touchend', function (e) {
  25152. delete touches[e.pointerId];
  25153. });
  25154. };
  25155. // Add IE specific touch events to chart
  25156. MSPointer.prototype.setDOMEvents = function () {
  25157. _super.prototype.setDOMEvents.call(this);
  25158. if (this.hasZoom || this.followTouchMove) {
  25159. this.batchMSEvents(addEvent);
  25160. }
  25161. };
  25162. return MSPointer;
  25163. }(Pointer));
  25164. return MSPointer;
  25165. });
  25166. _registerModule(_modules, 'Core/Legend.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (A, H, U) {
  25167. /* *
  25168. *
  25169. * (c) 2010-2020 Torstein Honsi
  25170. *
  25171. * License: www.highcharts.com/license
  25172. *
  25173. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  25174. *
  25175. * */
  25176. var animObject = A.animObject,
  25177. setAnimation = A.setAnimation;
  25178. /**
  25179. * Gets fired when the legend item belonging to a point is clicked. The default
  25180. * action is to toggle the visibility of the point. This can be prevented by
  25181. * returning `false` or calling `event.preventDefault()`.
  25182. *
  25183. * @callback Highcharts.PointLegendItemClickCallbackFunction
  25184. *
  25185. * @param {Highcharts.Point} this
  25186. * The point on which the event occured.
  25187. *
  25188. * @param {Highcharts.PointLegendItemClickEventObject} event
  25189. * The event that occured.
  25190. */
  25191. /**
  25192. * Information about the legend click event.
  25193. *
  25194. * @interface Highcharts.PointLegendItemClickEventObject
  25195. */ /**
  25196. * Related browser event.
  25197. * @name Highcharts.PointLegendItemClickEventObject#browserEvent
  25198. * @type {Highcharts.PointerEvent}
  25199. */ /**
  25200. * Prevent the default action of toggle the visibility of the point.
  25201. * @name Highcharts.PointLegendItemClickEventObject#preventDefault
  25202. * @type {Function}
  25203. */ /**
  25204. * Related point.
  25205. * @name Highcharts.PointLegendItemClickEventObject#target
  25206. * @type {Highcharts.Point}
  25207. */ /**
  25208. * Event type.
  25209. * @name Highcharts.PointLegendItemClickEventObject#type
  25210. * @type {"legendItemClick"}
  25211. */
  25212. /**
  25213. * Gets fired when the legend item belonging to a series is clicked. The default
  25214. * action is to toggle the visibility of the series. This can be prevented by
  25215. * returning `false` or calling `event.preventDefault()`.
  25216. *
  25217. * @callback Highcharts.SeriesLegendItemClickCallbackFunction
  25218. *
  25219. * @param {Highcharts.Series} this
  25220. * The series where the event occured.
  25221. *
  25222. * @param {Highcharts.SeriesLegendItemClickEventObject} event
  25223. * The event that occured.
  25224. */
  25225. /**
  25226. * Information about the legend click event.
  25227. *
  25228. * @interface Highcharts.SeriesLegendItemClickEventObject
  25229. */ /**
  25230. * Related browser event.
  25231. * @name Highcharts.SeriesLegendItemClickEventObject#browserEvent
  25232. * @type {Highcharts.PointerEvent}
  25233. */ /**
  25234. * Prevent the default action of toggle the visibility of the series.
  25235. * @name Highcharts.SeriesLegendItemClickEventObject#preventDefault
  25236. * @type {Function}
  25237. */ /**
  25238. * Related series.
  25239. * @name Highcharts.SeriesLegendItemClickEventObject#target
  25240. * @type {Highcharts.Series}
  25241. */ /**
  25242. * Event type.
  25243. * @name Highcharts.SeriesLegendItemClickEventObject#type
  25244. * @type {"legendItemClick"}
  25245. */
  25246. var addEvent = U.addEvent,
  25247. css = U.css,
  25248. defined = U.defined,
  25249. discardElement = U.discardElement,
  25250. find = U.find,
  25251. fireEvent = U.fireEvent,
  25252. format = U.format,
  25253. isNumber = U.isNumber,
  25254. merge = U.merge,
  25255. pick = U.pick,
  25256. relativeLength = U.relativeLength,
  25257. stableSort = U.stableSort,
  25258. syncTimeout = U.syncTimeout,
  25259. wrap = U.wrap;
  25260. var isFirefox = H.isFirefox,
  25261. marginNames = H.marginNames,
  25262. win = H.win;
  25263. /* eslint-disable no-invalid-this, valid-jsdoc */
  25264. /**
  25265. * The overview of the chart's series. The legend object is instanciated
  25266. * internally in the chart constructor, and is available from the `chart.legend`
  25267. * property. Each chart has only one legend.
  25268. *
  25269. * @class
  25270. * @name Highcharts.Legend
  25271. *
  25272. * @param {Highcharts.Chart} chart
  25273. * The chart instance.
  25274. *
  25275. * @param {Highcharts.LegendOptions} options
  25276. * Legend options.
  25277. */
  25278. var Legend = /** @class */ (function () {
  25279. /* *
  25280. *
  25281. * Constructors
  25282. *
  25283. * */
  25284. function Legend(chart, options) {
  25285. /* *
  25286. *
  25287. * Properties
  25288. *
  25289. * */
  25290. this.allItems = [];
  25291. this.box = void 0;
  25292. this.contentGroup = void 0;
  25293. this.display = false;
  25294. this.group = void 0;
  25295. this.initialItemY = 0;
  25296. this.itemHeight = 0;
  25297. this.itemMarginBottom = 0;
  25298. this.itemMarginTop = 0;
  25299. this.itemX = 0;
  25300. this.itemY = 0;
  25301. this.lastItemY = 0;
  25302. this.lastLineHeight = 0;
  25303. this.legendHeight = 0;
  25304. this.legendWidth = 0;
  25305. this.maxItemWidth = 0;
  25306. this.maxLegendWidth = 0;
  25307. this.offsetWidth = 0;
  25308. this.options = {};
  25309. this.padding = 0;
  25310. this.pages = [];
  25311. this.proximate = false;
  25312. this.scrollGroup = void 0;
  25313. this.symbolHeight = 0;
  25314. this.symbolWidth = 0;
  25315. this.titleHeight = 0;
  25316. this.totalItemWidth = 0;
  25317. this.widthOption = 0;
  25318. this.chart = chart;
  25319. this.init(chart, options);
  25320. }
  25321. /* *
  25322. *
  25323. * Functions
  25324. *
  25325. * */
  25326. /**
  25327. * Initialize the legend.
  25328. *
  25329. * @private
  25330. * @function Highcharts.Legend#init
  25331. *
  25332. * @param {Highcharts.Chart} chart
  25333. * The chart instance.
  25334. *
  25335. * @param {Highcharts.LegendOptions} options
  25336. * Legend options.
  25337. */
  25338. Legend.prototype.init = function (chart, options) {
  25339. /**
  25340. * Chart of this legend.
  25341. *
  25342. * @readonly
  25343. * @name Highcharts.Legend#chart
  25344. * @type {Highcharts.Chart}
  25345. */
  25346. this.chart = chart;
  25347. this.setOptions(options);
  25348. if (options.enabled) {
  25349. // Render it
  25350. this.render();
  25351. // move checkboxes
  25352. addEvent(this.chart, 'endResize', function () {
  25353. this.legend.positionCheckboxes();
  25354. });
  25355. if (this.proximate) {
  25356. this.unchartrender = addEvent(this.chart, 'render', function () {
  25357. this.legend.proximatePositions();
  25358. this.legend.positionItems();
  25359. });
  25360. }
  25361. else if (this.unchartrender) {
  25362. this.unchartrender();
  25363. }
  25364. }
  25365. };
  25366. /**
  25367. * @private
  25368. * @function Highcharts.Legend#setOptions
  25369. * @param {Highcharts.LegendOptions} options
  25370. */
  25371. Legend.prototype.setOptions = function (options) {
  25372. var padding = pick(options.padding, 8);
  25373. /**
  25374. * Legend options.
  25375. *
  25376. * @readonly
  25377. * @name Highcharts.Legend#options
  25378. * @type {Highcharts.LegendOptions}
  25379. */
  25380. this.options = options;
  25381. if (!this.chart.styledMode) {
  25382. this.itemStyle = options.itemStyle;
  25383. this.itemHiddenStyle = merge(this.itemStyle, options.itemHiddenStyle);
  25384. }
  25385. this.itemMarginTop = options.itemMarginTop || 0;
  25386. this.itemMarginBottom = options.itemMarginBottom || 0;
  25387. this.padding = padding;
  25388. this.initialItemY = padding - 5; // 5 is pixels above the text
  25389. this.symbolWidth = pick(options.symbolWidth, 16);
  25390. this.pages = [];
  25391. this.proximate = options.layout === 'proximate' && !this.chart.inverted;
  25392. this.baseline = void 0; // #12705: baseline has to be reset on every update
  25393. };
  25394. /**
  25395. * Update the legend with new options. Equivalent to running `chart.update`
  25396. * with a legend configuration option.
  25397. *
  25398. * @sample highcharts/legend/legend-update/
  25399. * Legend update
  25400. *
  25401. * @function Highcharts.Legend#update
  25402. *
  25403. * @param {Highcharts.LegendOptions} options
  25404. * Legend options.
  25405. *
  25406. * @param {boolean} [redraw=true]
  25407. * Whether to redraw the chart after the axis is altered. If doing more
  25408. * operations on the chart, it is a good idea to set redraw to false and
  25409. * call {@link Chart#redraw} after. Whether to redraw the chart.
  25410. *
  25411. * @fires Highcharts.Legends#event:afterUpdate
  25412. */
  25413. Legend.prototype.update = function (options, redraw) {
  25414. var chart = this.chart;
  25415. this.setOptions(merge(true, this.options, options));
  25416. this.destroy();
  25417. chart.isDirtyLegend = chart.isDirtyBox = true;
  25418. if (pick(redraw, true)) {
  25419. chart.redraw();
  25420. }
  25421. fireEvent(this, 'afterUpdate');
  25422. };
  25423. /**
  25424. * Set the colors for the legend item.
  25425. *
  25426. * @private
  25427. * @function Highcharts.Legend#colorizeItem
  25428. * @param {Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series} item
  25429. * A Series or Point instance
  25430. * @param {boolean} [visible=false]
  25431. * Dimmed or colored
  25432. *
  25433. * @todo
  25434. * Make events official: Fires the event `afterColorizeItem`.
  25435. */
  25436. Legend.prototype.colorizeItem = function (item, visible) {
  25437. item.legendGroup[visible ? 'removeClass' : 'addClass']('highcharts-legend-item-hidden');
  25438. if (!this.chart.styledMode) {
  25439. var legend = this,
  25440. options = legend.options,
  25441. legendItem = item.legendItem,
  25442. legendLine = item.legendLine,
  25443. legendSymbol = item.legendSymbol,
  25444. hiddenColor = legend.itemHiddenStyle.color,
  25445. textColor = visible ?
  25446. options.itemStyle.color :
  25447. hiddenColor,
  25448. symbolColor = visible ?
  25449. (item.color || hiddenColor) :
  25450. hiddenColor,
  25451. markerOptions = item.options && item.options.marker,
  25452. symbolAttr = { fill: symbolColor };
  25453. if (legendItem) {
  25454. legendItem.css({
  25455. fill: textColor,
  25456. color: textColor // #1553, oldIE
  25457. });
  25458. }
  25459. if (legendLine) {
  25460. legendLine.attr({ stroke: symbolColor });
  25461. }
  25462. if (legendSymbol) {
  25463. // Apply marker options
  25464. if (markerOptions && legendSymbol.isMarker) { // #585
  25465. symbolAttr = item.pointAttribs();
  25466. if (!visible) {
  25467. // #6769
  25468. symbolAttr.stroke = symbolAttr.fill = hiddenColor;
  25469. }
  25470. }
  25471. legendSymbol.attr(symbolAttr);
  25472. }
  25473. }
  25474. fireEvent(this, 'afterColorizeItem', { item: item, visible: visible });
  25475. };
  25476. /**
  25477. * @private
  25478. * @function Highcharts.Legend#positionItems
  25479. */
  25480. Legend.prototype.positionItems = function () {
  25481. // Now that the legend width and height are established, put the items
  25482. // in the final position
  25483. this.allItems.forEach(this.positionItem, this);
  25484. if (!this.chart.isResizing) {
  25485. this.positionCheckboxes();
  25486. }
  25487. };
  25488. /**
  25489. * Position the legend item.
  25490. *
  25491. * @private
  25492. * @function Highcharts.Legend#positionItem
  25493. * @param {Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series} item
  25494. * The item to position
  25495. */
  25496. Legend.prototype.positionItem = function (item) {
  25497. var _this = this;
  25498. var legend = this,
  25499. options = legend.options,
  25500. symbolPadding = options.symbolPadding,
  25501. ltr = !options.rtl,
  25502. legendItemPos = item._legendItemPos,
  25503. itemX = legendItemPos[0],
  25504. itemY = legendItemPos[1],
  25505. checkbox = item.checkbox,
  25506. legendGroup = item.legendGroup;
  25507. if (legendGroup && legendGroup.element) {
  25508. var attribs = {
  25509. translateX: ltr ?
  25510. itemX :
  25511. legend.legendWidth - itemX - 2 * symbolPadding - 4,
  25512. translateY: itemY
  25513. };
  25514. var complete = function () {
  25515. fireEvent(_this, 'afterPositionItem', { item: item });
  25516. };
  25517. if (defined(legendGroup.translateY)) {
  25518. legendGroup.animate(attribs, void 0, complete);
  25519. }
  25520. else {
  25521. legendGroup.attr(attribs);
  25522. complete();
  25523. }
  25524. }
  25525. if (checkbox) {
  25526. checkbox.x = itemX;
  25527. checkbox.y = itemY;
  25528. }
  25529. };
  25530. /**
  25531. * Destroy a single legend item, used internally on removing series items.
  25532. *
  25533. * @private
  25534. * @function Highcharts.Legend#destroyItem
  25535. * @param {Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series} item
  25536. * The item to remove
  25537. */
  25538. Legend.prototype.destroyItem = function (item) {
  25539. var checkbox = item.checkbox;
  25540. // destroy SVG elements
  25541. ['legendItem', 'legendLine', 'legendSymbol', 'legendGroup'].forEach(function (key) {
  25542. if (item[key]) {
  25543. item[key] = item[key].destroy();
  25544. }
  25545. });
  25546. if (checkbox) {
  25547. discardElement(item.checkbox);
  25548. }
  25549. };
  25550. /**
  25551. * Destroy the legend. Used internally. To reflow objects, `chart.redraw`
  25552. * must be called after destruction.
  25553. *
  25554. * @private
  25555. * @function Highcharts.Legend#destroy
  25556. */
  25557. Legend.prototype.destroy = function () {
  25558. /**
  25559. * @private
  25560. * @param {string} key
  25561. * @return {void}
  25562. */
  25563. function destroyItems(key) {
  25564. if (this[key]) {
  25565. this[key] = this[key].destroy();
  25566. }
  25567. }
  25568. // Destroy items
  25569. this.getAllItems().forEach(function (item) {
  25570. ['legendItem', 'legendGroup'].forEach(destroyItems, item);
  25571. });
  25572. // Destroy legend elements
  25573. [
  25574. 'clipRect',
  25575. 'up',
  25576. 'down',
  25577. 'pager',
  25578. 'nav',
  25579. 'box',
  25580. 'title',
  25581. 'group'
  25582. ].forEach(destroyItems, this);
  25583. this.display = null; // Reset in .render on update.
  25584. };
  25585. /**
  25586. * Position the checkboxes after the width is determined.
  25587. *
  25588. * @private
  25589. * @function Highcharts.Legend#positionCheckboxes
  25590. */
  25591. Legend.prototype.positionCheckboxes = function () {
  25592. var alignAttr = this.group && this.group.alignAttr,
  25593. translateY,
  25594. clipHeight = this.clipHeight || this.legendHeight,
  25595. titleHeight = this.titleHeight;
  25596. if (alignAttr) {
  25597. translateY = alignAttr.translateY;
  25598. this.allItems.forEach(function (item) {
  25599. var checkbox = item.checkbox,
  25600. top;
  25601. if (checkbox) {
  25602. top = translateY + titleHeight + checkbox.y +
  25603. (this.scrollOffset || 0) + 3;
  25604. css(checkbox, {
  25605. left: (alignAttr.translateX + item.checkboxOffset +
  25606. checkbox.x - 20) + 'px',
  25607. top: top + 'px',
  25608. display: this.proximate || (top > translateY - 6 &&
  25609. top < translateY + clipHeight - 6) ?
  25610. '' :
  25611. 'none'
  25612. });
  25613. }
  25614. }, this);
  25615. }
  25616. };
  25617. /**
  25618. * Render the legend title on top of the legend.
  25619. *
  25620. * @private
  25621. * @function Highcharts.Legend#renderTitle
  25622. */
  25623. Legend.prototype.renderTitle = function () {
  25624. var options = this.options,
  25625. padding = this.padding,
  25626. titleOptions = options.title,
  25627. titleHeight = 0,
  25628. bBox;
  25629. if (titleOptions.text) {
  25630. if (!this.title) {
  25631. /**
  25632. * SVG element of the legend title.
  25633. *
  25634. * @readonly
  25635. * @name Highcharts.Legend#title
  25636. * @type {Highcharts.SVGElement}
  25637. */
  25638. this.title = this.chart.renderer.label(titleOptions.text, padding - 3, padding - 4, null, null, null, options.useHTML, null, 'legend-title')
  25639. .attr({ zIndex: 1 });
  25640. if (!this.chart.styledMode) {
  25641. this.title.css(titleOptions.style);
  25642. }
  25643. this.title.add(this.group);
  25644. }
  25645. // Set the max title width (#7253)
  25646. if (!titleOptions.width) {
  25647. this.title.css({
  25648. width: this.maxLegendWidth + 'px'
  25649. });
  25650. }
  25651. bBox = this.title.getBBox();
  25652. titleHeight = bBox.height;
  25653. this.offsetWidth = bBox.width; // #1717
  25654. this.contentGroup.attr({ translateY: titleHeight });
  25655. }
  25656. this.titleHeight = titleHeight;
  25657. };
  25658. /**
  25659. * Set the legend item text.
  25660. *
  25661. * @function Highcharts.Legend#setText
  25662. * @param {Highcharts.Point|Highcharts.Series} item
  25663. * The item for which to update the text in the legend.
  25664. */
  25665. Legend.prototype.setText = function (item) {
  25666. var options = this.options;
  25667. item.legendItem.attr({
  25668. text: options.labelFormat ?
  25669. format(options.labelFormat, item, this.chart) :
  25670. options.labelFormatter.call(item)
  25671. });
  25672. };
  25673. /**
  25674. * Render a single specific legend item. Called internally from the `render`
  25675. * function.
  25676. *
  25677. * @private
  25678. * @function Highcharts.Legend#renderItem
  25679. * @param {Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series} item
  25680. * The item to render.
  25681. */
  25682. Legend.prototype.renderItem = function (item) {
  25683. var legend = this,
  25684. chart = legend.chart,
  25685. renderer = chart.renderer,
  25686. options = legend.options,
  25687. horizontal = options.layout === 'horizontal',
  25688. symbolWidth = legend.symbolWidth,
  25689. symbolPadding = options.symbolPadding,
  25690. itemStyle = legend.itemStyle,
  25691. itemHiddenStyle = legend.itemHiddenStyle,
  25692. itemDistance = horizontal ? pick(options.itemDistance, 20) : 0,
  25693. ltr = !options.rtl,
  25694. bBox,
  25695. li = item.legendItem,
  25696. isSeries = !item.series,
  25697. series = !isSeries && item.series.drawLegendSymbol ?
  25698. item.series :
  25699. item,
  25700. seriesOptions = series.options,
  25701. showCheckbox = legend.createCheckboxForItem &&
  25702. seriesOptions &&
  25703. seriesOptions.showCheckbox,
  25704. // full width minus text width
  25705. itemExtraWidth = symbolWidth + symbolPadding +
  25706. itemDistance + (showCheckbox ? 20 : 0),
  25707. useHTML = options.useHTML,
  25708. itemClassName = item.options.className;
  25709. if (!li) { // generate it once, later move it
  25710. // Generate the group box, a group to hold the symbol and text. Text
  25711. // is to be appended in Legend class.
  25712. item.legendGroup = renderer
  25713. .g('legend-item')
  25714. .addClass('highcharts-' + series.type + '-series ' +
  25715. 'highcharts-color-' + item.colorIndex +
  25716. (itemClassName ? ' ' + itemClassName : '') +
  25717. (isSeries ?
  25718. ' highcharts-series-' + item.index :
  25719. ''))
  25720. .attr({ zIndex: 1 })
  25721. .add(legend.scrollGroup);
  25722. // Generate the list item text and add it to the group
  25723. item.legendItem = li = renderer.text('', ltr ?
  25724. symbolWidth + symbolPadding :
  25725. -symbolPadding, legend.baseline || 0, useHTML);
  25726. if (!chart.styledMode) {
  25727. // merge to prevent modifying original (#1021)
  25728. li.css(merge(item.visible ?
  25729. itemStyle :
  25730. itemHiddenStyle));
  25731. }
  25732. li
  25733. .attr({
  25734. align: ltr ? 'left' : 'right',
  25735. zIndex: 2
  25736. })
  25737. .add(item.legendGroup);
  25738. // Get the baseline for the first item - the font size is equal for
  25739. // all
  25740. if (!legend.baseline) {
  25741. legend.fontMetrics = renderer.fontMetrics(chart.styledMode ? 12 : itemStyle.fontSize, li);
  25742. legend.baseline =
  25743. legend.fontMetrics.f + 3 + legend.itemMarginTop;
  25744. li.attr('y', legend.baseline);
  25745. }
  25746. // Draw the legend symbol inside the group box
  25747. legend.symbolHeight =
  25748. options.symbolHeight || legend.fontMetrics.f;
  25749. series.drawLegendSymbol(legend, item);
  25750. if (legend.setItemEvents) {
  25751. legend.setItemEvents(item, li, useHTML);
  25752. }
  25753. }
  25754. // Add the HTML checkbox on top
  25755. if (showCheckbox && !item.checkbox && legend.createCheckboxForItem) {
  25756. legend.createCheckboxForItem(item);
  25757. }
  25758. // Colorize the items
  25759. legend.colorizeItem(item, item.visible);
  25760. // Take care of max width and text overflow (#6659)
  25761. if (chart.styledMode || !itemStyle.width) {
  25762. li.css({
  25763. width: ((options.itemWidth ||
  25764. legend.widthOption ||
  25765. chart.spacingBox.width) - itemExtraWidth) + 'px'
  25766. });
  25767. }
  25768. // Always update the text
  25769. legend.setText(item);
  25770. // calculate the positions for the next line
  25771. bBox = li.getBBox();
  25772. item.itemWidth = item.checkboxOffset =
  25773. options.itemWidth ||
  25774. item.legendItemWidth ||
  25775. bBox.width + itemExtraWidth;
  25776. legend.maxItemWidth = Math.max(legend.maxItemWidth, item.itemWidth);
  25777. legend.totalItemWidth += item.itemWidth;
  25778. legend.itemHeight = item.itemHeight = Math.round(item.legendItemHeight || bBox.height || legend.symbolHeight);
  25779. };
  25780. /**
  25781. * Get the position of the item in the layout. We now know the
  25782. * maxItemWidth from the previous loop.
  25783. *
  25784. * @private
  25785. * @function Highcharts.Legend#layoutItem
  25786. * @param {Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series} item
  25787. */
  25788. Legend.prototype.layoutItem = function (item) {
  25789. var options = this.options,
  25790. padding = this.padding,
  25791. horizontal = options.layout === 'horizontal',
  25792. itemHeight = item.itemHeight,
  25793. itemMarginBottom = this.itemMarginBottom,
  25794. itemMarginTop = this.itemMarginTop,
  25795. itemDistance = horizontal ? pick(options.itemDistance, 20) : 0,
  25796. maxLegendWidth = this.maxLegendWidth,
  25797. itemWidth = (options.alignColumns &&
  25798. this.totalItemWidth > maxLegendWidth) ?
  25799. this.maxItemWidth :
  25800. item.itemWidth;
  25801. // If the item exceeds the width, start a new line
  25802. if (horizontal &&
  25803. this.itemX - padding + itemWidth > maxLegendWidth) {
  25804. this.itemX = padding;
  25805. if (this.lastLineHeight) { // Not for the first line (#10167)
  25806. this.itemY += (itemMarginTop +
  25807. this.lastLineHeight +
  25808. itemMarginBottom);
  25809. }
  25810. this.lastLineHeight = 0; // reset for next line (#915, #3976)
  25811. }
  25812. // Set the edge positions
  25813. this.lastItemY = itemMarginTop + this.itemY + itemMarginBottom;
  25814. this.lastLineHeight = Math.max(// #915
  25815. itemHeight, this.lastLineHeight);
  25816. // cache the position of the newly generated or reordered items
  25817. item._legendItemPos = [this.itemX, this.itemY];
  25818. // advance
  25819. if (horizontal) {
  25820. this.itemX += itemWidth;
  25821. }
  25822. else {
  25823. this.itemY +=
  25824. itemMarginTop + itemHeight + itemMarginBottom;
  25825. this.lastLineHeight = itemHeight;
  25826. }
  25827. // the width of the widest item
  25828. this.offsetWidth = this.widthOption || Math.max((horizontal ? this.itemX - padding - (item.checkbox ?
  25829. // decrease by itemDistance only when no checkbox #4853
  25830. 0 :
  25831. itemDistance) : itemWidth) + padding, this.offsetWidth);
  25832. };
  25833. /**
  25834. * Get all items, which is one item per series for most series and one
  25835. * item per point for pie series and its derivatives. Fires the event
  25836. * `afterGetAllItems`.
  25837. *
  25838. * @private
  25839. * @function Highcharts.Legend#getAllItems
  25840. * @return {Array<(Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series)>}
  25841. * The current items in the legend.
  25842. * @fires Highcharts.Legend#event:afterGetAllItems
  25843. */
  25844. Legend.prototype.getAllItems = function () {
  25845. var allItems = [];
  25846. this.chart.series.forEach(function (series) {
  25847. var seriesOptions = series && series.options;
  25848. // Handle showInLegend. If the series is linked to another series,
  25849. // defaults to false.
  25850. if (series && pick(seriesOptions.showInLegend, !defined(seriesOptions.linkedTo) ? void 0 : false, true)) {
  25851. // Use points or series for the legend item depending on
  25852. // legendType
  25853. allItems = allItems.concat(series.legendItems ||
  25854. (seriesOptions.legendType === 'point' ?
  25855. series.data :
  25856. series));
  25857. }
  25858. });
  25859. fireEvent(this, 'afterGetAllItems', { allItems: allItems });
  25860. return allItems;
  25861. };
  25862. /**
  25863. * Get a short, three letter string reflecting the alignment and layout.
  25864. *
  25865. * @private
  25866. * @function Highcharts.Legend#getAlignment
  25867. * @return {string}
  25868. * The alignment, empty string if floating
  25869. */
  25870. Legend.prototype.getAlignment = function () {
  25871. var options = this.options;
  25872. // Use the first letter of each alignment option in order to detect
  25873. // the side. (#4189 - use charAt(x) notation instead of [x] for IE7)
  25874. if (this.proximate) {
  25875. return options.align.charAt(0) + 'tv';
  25876. }
  25877. return options.floating ? '' : (options.align.charAt(0) +
  25878. options.verticalAlign.charAt(0) +
  25879. options.layout.charAt(0));
  25880. };
  25881. /**
  25882. * Adjust the chart margins by reserving space for the legend on only one
  25883. * side of the chart. If the position is set to a corner, top or bottom is
  25884. * reserved for horizontal legends and left or right for vertical ones.
  25885. *
  25886. * @private
  25887. * @function Highcharts.Legend#adjustMargins
  25888. * @param {Array<number>} margin
  25889. * @param {Array<number>} spacing
  25890. */
  25891. Legend.prototype.adjustMargins = function (margin, spacing) {
  25892. var chart = this.chart,
  25893. options = this.options,
  25894. alignment = this.getAlignment();
  25895. if (alignment) {
  25896. ([
  25897. /(lth|ct|rth)/,
  25898. /(rtv|rm|rbv)/,
  25899. /(rbh|cb|lbh)/,
  25900. /(lbv|lm|ltv)/
  25901. ]).forEach(function (alignments, side) {
  25902. if (alignments.test(alignment) && !defined(margin[side])) {
  25903. // Now we have detected on which side of the chart we should
  25904. // reserve space for the legend
  25905. chart[marginNames[side]] = Math.max(chart[marginNames[side]], (chart.legend[(side + 1) % 2 ? 'legendHeight' : 'legendWidth'] +
  25906. [1, -1, -1, 1][side] * options[(side % 2) ? 'x' : 'y'] +
  25907. pick(options.margin, 12) +
  25908. spacing[side] +
  25909. (chart.titleOffset[side] || 0)));
  25910. }
  25911. });
  25912. }
  25913. };
  25914. /**
  25915. * @private
  25916. * @function Highcharts.Legend#proximatePositions
  25917. */
  25918. Legend.prototype.proximatePositions = function () {
  25919. var chart = this.chart,
  25920. boxes = [],
  25921. alignLeft = this.options.align === 'left';
  25922. this.allItems.forEach(function (item) {
  25923. var lastPoint,
  25924. height,
  25925. useFirstPoint = alignLeft,
  25926. target,
  25927. top;
  25928. if (item.yAxis) {
  25929. if (item.xAxis.options.reversed) {
  25930. useFirstPoint = !useFirstPoint;
  25931. }
  25932. if (item.points) {
  25933. lastPoint = find(useFirstPoint ?
  25934. item.points :
  25935. item.points.slice(0).reverse(), function (item) {
  25936. return isNumber(item.plotY);
  25937. });
  25938. }
  25939. height = this.itemMarginTop +
  25940. item.legendItem.getBBox().height +
  25941. this.itemMarginBottom;
  25942. top = item.yAxis.top - chart.plotTop;
  25943. if (item.visible) {
  25944. target = lastPoint ?
  25945. lastPoint.plotY :
  25946. item.yAxis.height;
  25947. target += top - 0.3 * height;
  25948. }
  25949. else {
  25950. target = top + item.yAxis.height;
  25951. }
  25952. boxes.push({
  25953. target: target,
  25954. size: height,
  25955. item: item
  25956. });
  25957. }
  25958. }, this);
  25959. H.distribute(boxes, chart.plotHeight);
  25960. boxes.forEach(function (box) {
  25961. box.item._legendItemPos[1] =
  25962. chart.plotTop - chart.spacing[0] + box.pos;
  25963. });
  25964. };
  25965. /**
  25966. * Render the legend. This method can be called both before and after
  25967. * `chart.render`. If called after, it will only rearrange items instead
  25968. * of creating new ones. Called internally on initial render and after
  25969. * redraws.
  25970. *
  25971. * @private
  25972. * @function Highcharts.Legend#render
  25973. */
  25974. Legend.prototype.render = function () {
  25975. var legend = this,
  25976. chart = legend.chart,
  25977. renderer = chart.renderer,
  25978. legendGroup = legend.group,
  25979. allItems,
  25980. display,
  25981. legendWidth,
  25982. legendHeight,
  25983. box = legend.box,
  25984. options = legend.options,
  25985. padding = legend.padding,
  25986. allowedWidth;
  25987. legend.itemX = padding;
  25988. legend.itemY = legend.initialItemY;
  25989. legend.offsetWidth = 0;
  25990. legend.lastItemY = 0;
  25991. legend.widthOption = relativeLength(options.width, chart.spacingBox.width - padding);
  25992. // Compute how wide the legend is allowed to be
  25993. allowedWidth =
  25994. chart.spacingBox.width - 2 * padding - options.x;
  25995. if (['rm', 'lm'].indexOf(legend.getAlignment().substring(0, 2)) > -1) {
  25996. allowedWidth /= 2;
  25997. }
  25998. legend.maxLegendWidth = legend.widthOption || allowedWidth;
  25999. if (!legendGroup) {
  26000. /**
  26001. * SVG group of the legend.
  26002. *
  26003. * @readonly
  26004. * @name Highcharts.Legend#group
  26005. * @type {Highcharts.SVGElement}
  26006. */
  26007. legend.group = legendGroup = renderer.g('legend')
  26008. .attr({ zIndex: 7 })
  26009. .add();
  26010. legend.contentGroup = renderer.g()
  26011. .attr({ zIndex: 1 }) // above background
  26012. .add(legendGroup);
  26013. legend.scrollGroup = renderer.g()
  26014. .add(legend.contentGroup);
  26015. }
  26016. legend.renderTitle();
  26017. // add each series or point
  26018. allItems = legend.getAllItems();
  26019. // sort by legendIndex
  26020. stableSort(allItems, function (a, b) {
  26021. return ((a.options && a.options.legendIndex) || 0) -
  26022. ((b.options && b.options.legendIndex) || 0);
  26023. });
  26024. // reversed legend
  26025. if (options.reversed) {
  26026. allItems.reverse();
  26027. }
  26028. /**
  26029. * All items for the legend, which is an array of series for most series
  26030. * and an array of points for pie series and its derivatives.
  26031. *
  26032. * @readonly
  26033. * @name Highcharts.Legend#allItems
  26034. * @type {Array<(Highcharts.Point|Highcharts.Series)>}
  26035. */
  26036. legend.allItems = allItems;
  26037. legend.display = display = !!allItems.length;
  26038. // Render the items. First we run a loop to set the text and properties
  26039. // and read all the bounding boxes. The next loop computes the item
  26040. // positions based on the bounding boxes.
  26041. legend.lastLineHeight = 0;
  26042. legend.maxItemWidth = 0;
  26043. legend.totalItemWidth = 0;
  26044. legend.itemHeight = 0;
  26045. allItems.forEach(legend.renderItem, legend);
  26046. allItems.forEach(legend.layoutItem, legend);
  26047. // Get the box
  26048. legendWidth = (legend.widthOption || legend.offsetWidth) + padding;
  26049. legendHeight = legend.lastItemY + legend.lastLineHeight +
  26050. legend.titleHeight;
  26051. legendHeight = legend.handleOverflow(legendHeight);
  26052. legendHeight += padding;
  26053. // Draw the border and/or background
  26054. if (!box) {
  26055. /**
  26056. * SVG element of the legend box.
  26057. *
  26058. * @readonly
  26059. * @name Highcharts.Legend#box
  26060. * @type {Highcharts.SVGElement}
  26061. */
  26062. legend.box = box = renderer.rect()
  26063. .addClass('highcharts-legend-box')
  26064. .attr({
  26065. r: options.borderRadius
  26066. })
  26067. .add(legendGroup);
  26068. box.isNew = true;
  26069. }
  26070. // Presentational
  26071. if (!chart.styledMode) {
  26072. box
  26073. .attr({
  26074. stroke: options.borderColor,
  26075. 'stroke-width': options.borderWidth || 0,
  26076. fill: options.backgroundColor || 'none'
  26077. })
  26078. .shadow(options.shadow);
  26079. }
  26080. if (legendWidth > 0 && legendHeight > 0) {
  26081. box[box.isNew ? 'attr' : 'animate'](box.crisp.call({}, {
  26082. x: 0,
  26083. y: 0,
  26084. width: legendWidth,
  26085. height: legendHeight
  26086. }, box.strokeWidth()));
  26087. box.isNew = false;
  26088. }
  26089. // hide the border if no items
  26090. box[display ? 'show' : 'hide']();
  26091. // Open for responsiveness
  26092. if (chart.styledMode && legendGroup.getStyle('display') === 'none') {
  26093. legendWidth = legendHeight = 0;
  26094. }
  26095. legend.legendWidth = legendWidth;
  26096. legend.legendHeight = legendHeight;
  26097. if (display) {
  26098. legend.align();
  26099. }
  26100. if (!this.proximate) {
  26101. this.positionItems();
  26102. }
  26103. fireEvent(this, 'afterRender');
  26104. };
  26105. /**
  26106. * Align the legend to chart's box.
  26107. *
  26108. * @private
  26109. * @function Highcharts.align
  26110. * @param {Highcharts.BBoxObject} alignTo
  26111. * @return {void}
  26112. */
  26113. Legend.prototype.align = function (alignTo) {
  26114. if (alignTo === void 0) { alignTo = this.chart.spacingBox; }
  26115. var chart = this.chart,
  26116. options = this.options;
  26117. // If aligning to the top and the layout is horizontal, adjust for
  26118. // the title (#7428)
  26119. var y = alignTo.y;
  26120. if (/(lth|ct|rth)/.test(this.getAlignment()) &&
  26121. chart.titleOffset[0] > 0) {
  26122. y += chart.titleOffset[0];
  26123. }
  26124. else if (/(lbh|cb|rbh)/.test(this.getAlignment()) &&
  26125. chart.titleOffset[2] > 0) {
  26126. y -= chart.titleOffset[2];
  26127. }
  26128. if (y !== alignTo.y) {
  26129. alignTo = merge(alignTo, { y: y });
  26130. }
  26131. this.group.align(merge(options, {
  26132. width: this.legendWidth,
  26133. height: this.legendHeight,
  26134. verticalAlign: this.proximate ? 'top' : options.verticalAlign
  26135. }), true, alignTo);
  26136. };
  26137. /**
  26138. * Set up the overflow handling by adding navigation with up and down arrows
  26139. * below the legend.
  26140. *
  26141. * @private
  26142. * @function Highcharts.Legend#handleOverflow
  26143. * @param {number} legendHeight
  26144. * @return {number}
  26145. */
  26146. Legend.prototype.handleOverflow = function (legendHeight) {
  26147. var legend = this,
  26148. chart = this.chart,
  26149. renderer = chart.renderer,
  26150. options = this.options,
  26151. optionsY = options.y,
  26152. alignTop = options.verticalAlign === 'top',
  26153. padding = this.padding,
  26154. spaceHeight = (chart.spacingBox.height +
  26155. (alignTop ? -optionsY : optionsY) - padding),
  26156. maxHeight = options.maxHeight,
  26157. clipHeight,
  26158. clipRect = this.clipRect,
  26159. navOptions = options.navigation,
  26160. animation = pick(navOptions.animation,
  26161. true),
  26162. arrowSize = navOptions.arrowSize || 12,
  26163. nav = this.nav,
  26164. pages = this.pages,
  26165. lastY,
  26166. allItems = this.allItems,
  26167. clipToHeight = function (height) {
  26168. if (typeof height === 'number') {
  26169. clipRect.attr({
  26170. height: height
  26171. });
  26172. }
  26173. else if (clipRect) { // Reset (#5912)
  26174. legend.clipRect = clipRect.destroy();
  26175. legend.contentGroup.clip();
  26176. }
  26177. // useHTML
  26178. if (legend.contentGroup.div) {
  26179. legend.contentGroup.div.style.clip = height ?
  26180. 'rect(' + padding + 'px,9999px,' +
  26181. (padding + height) + 'px,0)' :
  26182. 'auto';
  26183. }
  26184. }, addTracker = function (key) {
  26185. legend[key] = renderer
  26186. .circle(0, 0, arrowSize * 1.3)
  26187. .translate(arrowSize / 2, arrowSize / 2)
  26188. .add(nav);
  26189. if (!chart.styledMode) {
  26190. legend[key].attr('fill', 'rgba(0,0,0,0.0001)');
  26191. }
  26192. return legend[key];
  26193. };
  26194. // Adjust the height
  26195. if (options.layout === 'horizontal' &&
  26196. options.verticalAlign !== 'middle' &&
  26197. !options.floating) {
  26198. spaceHeight /= 2;
  26199. }
  26200. if (maxHeight) {
  26201. spaceHeight = Math.min(spaceHeight, maxHeight);
  26202. }
  26203. // Reset the legend height and adjust the clipping rectangle
  26204. pages.length = 0;
  26205. if (legendHeight > spaceHeight &&
  26206. navOptions.enabled !== false) {
  26207. this.clipHeight = clipHeight =
  26208. Math.max(spaceHeight - 20 - this.titleHeight - padding, 0);
  26209. this.currentPage = pick(this.currentPage, 1);
  26210. this.fullHeight = legendHeight;
  26211. // Fill pages with Y positions so that the top of each a legend item
  26212. // defines the scroll top for each page (#2098)
  26213. allItems.forEach(function (item, i) {
  26214. var y = item._legendItemPos[1],
  26215. h = Math.round(item.legendItem.getBBox().height),
  26216. len = pages.length;
  26217. if (!len || (y - pages[len - 1] > clipHeight &&
  26218. (lastY || y) !== pages[len - 1])) {
  26219. pages.push(lastY || y);
  26220. len++;
  26221. }
  26222. // Keep track of which page each item is on
  26223. item.pageIx = len - 1;
  26224. if (lastY) {
  26225. allItems[i - 1].pageIx = len - 1;
  26226. }
  26227. if (i === allItems.length - 1 &&
  26228. y + h - pages[len - 1] > clipHeight &&
  26229. y !== lastY // #2617
  26230. ) {
  26231. pages.push(y);
  26232. item.pageIx = len;
  26233. }
  26234. if (y !== lastY) {
  26235. lastY = y;
  26236. }
  26237. });
  26238. // Only apply clipping if needed. Clipping causes blurred legend in
  26239. // PDF export (#1787)
  26240. if (!clipRect) {
  26241. clipRect = legend.clipRect =
  26242. renderer.clipRect(0, padding, 9999, 0);
  26243. legend.contentGroup.clip(clipRect);
  26244. }
  26245. clipToHeight(clipHeight);
  26246. // Add navigation elements
  26247. if (!nav) {
  26248. this.nav = nav = renderer.g()
  26249. .attr({ zIndex: 1 })
  26250. .add(this.group);
  26251. this.up = renderer
  26252. .symbol('triangle', 0, 0, arrowSize, arrowSize)
  26253. .add(nav);
  26254. addTracker('upTracker')
  26255. .on('click', function () {
  26256. legend.scroll(-1, animation);
  26257. });
  26258. this.pager = renderer.text('', 15, 10)
  26259. .addClass('highcharts-legend-navigation');
  26260. if (!chart.styledMode) {
  26261. this.pager.css(navOptions.style);
  26262. }
  26263. this.pager.add(nav);
  26264. this.down = renderer
  26265. .symbol('triangle-down', 0, 0, arrowSize, arrowSize)
  26266. .add(nav);
  26267. addTracker('downTracker')
  26268. .on('click', function () {
  26269. legend.scroll(1, animation);
  26270. });
  26271. }
  26272. // Set initial position
  26273. legend.scroll(0);
  26274. legendHeight = spaceHeight;
  26275. // Reset
  26276. }
  26277. else if (nav) {
  26278. clipToHeight();
  26279. this.nav = nav.destroy(); // #6322
  26280. this.scrollGroup.attr({
  26281. translateY: 1
  26282. });
  26283. this.clipHeight = 0; // #1379
  26284. }
  26285. return legendHeight;
  26286. };
  26287. /**
  26288. * Scroll the legend by a number of pages.
  26289. *
  26290. * @private
  26291. * @function Highcharts.Legend#scroll
  26292. *
  26293. * @param {number} scrollBy
  26294. * The number of pages to scroll.
  26295. *
  26296. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  26297. * Whether and how to apply animation.
  26298. *
  26299. * @return {void}
  26300. */
  26301. Legend.prototype.scroll = function (scrollBy, animation) {
  26302. var _this = this;
  26303. var chart = this.chart,
  26304. pages = this.pages,
  26305. pageCount = pages.length,
  26306. currentPage = this.currentPage + scrollBy,
  26307. clipHeight = this.clipHeight,
  26308. navOptions = this.options.navigation,
  26309. pager = this.pager,
  26310. padding = this.padding;
  26311. // When resizing while looking at the last page
  26312. if (currentPage > pageCount) {
  26313. currentPage = pageCount;
  26314. }
  26315. if (currentPage > 0) {
  26316. if (typeof animation !== 'undefined') {
  26317. setAnimation(animation, chart);
  26318. }
  26319. this.nav.attr({
  26320. translateX: padding,
  26321. translateY: clipHeight + this.padding + 7 + this.titleHeight,
  26322. visibility: 'visible'
  26323. });
  26324. [this.up, this.upTracker].forEach(function (elem) {
  26325. elem.attr({
  26326. 'class': currentPage === 1 ?
  26327. 'highcharts-legend-nav-inactive' :
  26328. 'highcharts-legend-nav-active'
  26329. });
  26330. });
  26331. pager.attr({
  26332. text: currentPage + '/' + pageCount
  26333. });
  26334. [this.down, this.downTracker].forEach(function (elem) {
  26335. elem.attr({
  26336. // adjust to text width
  26337. x: 18 + this.pager.getBBox().width,
  26338. 'class': currentPage === pageCount ?
  26339. 'highcharts-legend-nav-inactive' :
  26340. 'highcharts-legend-nav-active'
  26341. });
  26342. }, this);
  26343. if (!chart.styledMode) {
  26344. this.up
  26345. .attr({
  26346. fill: currentPage === 1 ?
  26347. navOptions.inactiveColor :
  26348. navOptions.activeColor
  26349. });
  26350. this.upTracker
  26351. .css({
  26352. cursor: currentPage === 1 ? 'default' : 'pointer'
  26353. });
  26354. this.down
  26355. .attr({
  26356. fill: currentPage === pageCount ?
  26357. navOptions.inactiveColor :
  26358. navOptions.activeColor
  26359. });
  26360. this.downTracker
  26361. .css({
  26362. cursor: currentPage === pageCount ?
  26363. 'default' :
  26364. 'pointer'
  26365. });
  26366. }
  26367. this.scrollOffset = -pages[currentPage - 1] + this.initialItemY;
  26368. this.scrollGroup.animate({
  26369. translateY: this.scrollOffset
  26370. });
  26371. this.currentPage = currentPage;
  26372. this.positionCheckboxes();
  26373. // Fire event after scroll animation is complete
  26374. var animOptions = animObject(pick(animation,
  26375. chart.renderer.globalAnimation,
  26376. true));
  26377. syncTimeout(function () {
  26378. fireEvent(_this, 'afterScroll', { currentPage: currentPage });
  26379. }, animOptions.duration);
  26380. }
  26381. };
  26382. return Legend;
  26383. }());
  26384. // Workaround for #2030, horizontal legend items not displaying in IE11 Preview,
  26385. // and for #2580, a similar drawing flaw in Firefox 26.
  26386. // Explore if there's a general cause for this. The problem may be related
  26387. // to nested group elements, as the legend item texts are within 4 group
  26388. // elements.
  26389. if (/Trident\/7\.0/.test(win.navigator && win.navigator.userAgent) ||
  26390. isFirefox) {
  26391. wrap(Legend.prototype, 'positionItem', function (proceed, item) {
  26392. var legend = this,
  26393. // If chart destroyed in sync, this is undefined (#2030)
  26394. runPositionItem = function () {
  26395. if (item._legendItemPos) {
  26396. proceed.call(legend,
  26397. item);
  26398. }
  26399. };
  26400. // Do it now, for export and to get checkbox placement
  26401. runPositionItem();
  26402. // Do it after to work around the core issue
  26403. if (!legend.bubbleLegend) {
  26404. setTimeout(runPositionItem);
  26405. }
  26406. });
  26407. }
  26408. H.Legend = Legend;
  26409. return H.Legend;
  26410. });
  26411. _registerModule(_modules, 'Core/Series/Point.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (A, H, U) {
  26412. /* *
  26413. *
  26414. * (c) 2010-2020 Torstein Honsi
  26415. *
  26416. * License: www.highcharts.com/license
  26417. *
  26418. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  26419. *
  26420. * */
  26421. var animObject = A.animObject;
  26422. var defined = U.defined,
  26423. erase = U.erase,
  26424. extend = U.extend,
  26425. fireEvent = U.fireEvent,
  26426. format = U.format,
  26427. getNestedProperty = U.getNestedProperty,
  26428. isArray = U.isArray,
  26429. isNumber = U.isNumber,
  26430. isObject = U.isObject,
  26431. syncTimeout = U.syncTimeout,
  26432. pick = U.pick,
  26433. removeEvent = U.removeEvent,
  26434. uniqueKey = U.uniqueKey;
  26435. /**
  26436. * Function callback when a series point is clicked. Return false to cancel the
  26437. * action.
  26438. *
  26439. * @callback Highcharts.PointClickCallbackFunction
  26440. *
  26441. * @param {Highcharts.Point} this
  26442. * The point where the event occured.
  26443. *
  26444. * @param {Highcharts.PointClickEventObject} event
  26445. * Event arguments.
  26446. */
  26447. /**
  26448. * Common information for a click event on a series point.
  26449. *
  26450. * @interface Highcharts.PointClickEventObject
  26451. * @extends Highcharts.PointerEventObject
  26452. */ /**
  26453. * Clicked point.
  26454. * @name Highcharts.PointClickEventObject#point
  26455. * @type {Highcharts.Point}
  26456. */
  26457. /**
  26458. * Configuration hash for the data label and tooltip formatters.
  26459. *
  26460. * @interface Highcharts.PointLabelObject
  26461. */ /**
  26462. * The point's current color.
  26463. * @name Highcharts.PointLabelObject#color
  26464. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject|undefined}
  26465. */ /**
  26466. * The point's current color index, used in styled mode instead of `color`. The
  26467. * color index is inserted in class names used for styling.
  26468. * @name Highcharts.PointLabelObject#colorIndex
  26469. * @type {number}
  26470. */ /**
  26471. * The name of the related point.
  26472. * @name Highcharts.PointLabelObject#key
  26473. * @type {string|undefined}
  26474. */ /**
  26475. * The percentage for related points in a stacked series or pies.
  26476. * @name Highcharts.PointLabelObject#percentage
  26477. * @type {number}
  26478. */ /**
  26479. * The related point. The point name, if defined, is available through
  26480. * `this.point.name`.
  26481. * @name Highcharts.PointLabelObject#point
  26482. * @type {Highcharts.Point}
  26483. */ /**
  26484. * The related series. The series name is available through `this.series.name`.
  26485. * @name Highcharts.PointLabelObject#series
  26486. * @type {Highcharts.Series}
  26487. */ /**
  26488. * The total of values in either a stack for stacked series, or a pie in a pie
  26489. * series.
  26490. * @name Highcharts.PointLabelObject#total
  26491. * @type {number|undefined}
  26492. */ /**
  26493. * For categorized axes this property holds the category name for the point. For
  26494. * other axes it holds the X value.
  26495. * @name Highcharts.PointLabelObject#x
  26496. * @type {number|string|undefined}
  26497. */ /**
  26498. * The y value of the point.
  26499. * @name Highcharts.PointLabelObject#y
  26500. * @type {number|undefined}
  26501. */
  26502. /**
  26503. * Gets fired when the mouse leaves the area close to the point.
  26504. *
  26505. * @callback Highcharts.PointMouseOutCallbackFunction
  26506. *
  26507. * @param {Highcharts.Point} this
  26508. * Point where the event occured.
  26509. *
  26510. * @param {global.PointerEvent} event
  26511. * Event that occured.
  26512. */
  26513. /**
  26514. * Gets fired when the mouse enters the area close to the point.
  26515. *
  26516. * @callback Highcharts.PointMouseOverCallbackFunction
  26517. *
  26518. * @param {Highcharts.Point} this
  26519. * Point where the event occured.
  26520. *
  26521. * @param {global.Event} event
  26522. * Event that occured.
  26523. */
  26524. /**
  26525. * The generic point options for all series.
  26526. *
  26527. * In TypeScript you have to extend `PointOptionsObject` with an additional
  26528. * declaration to allow custom data options:
  26529. *
  26530. * ```
  26531. * declare interface PointOptionsObject {
  26532. * customProperty: string;
  26533. * }
  26534. * ```
  26535. *
  26536. * @interface Highcharts.PointOptionsObject
  26537. */
  26538. /**
  26539. * Possible option types for a data point. Use `null` to indicate a gap.
  26540. *
  26541. * @typedef {number|string|Highcharts.PointOptionsObject|Array<(number|string|null)>|null} Highcharts.PointOptionsType
  26542. */
  26543. /**
  26544. * Gets fired when the point is removed using the `.remove()` method.
  26545. *
  26546. * @callback Highcharts.PointRemoveCallbackFunction
  26547. *
  26548. * @param {Highcharts.Point} this
  26549. * Point where the event occured.
  26550. *
  26551. * @param {global.Event} event
  26552. * Event that occured.
  26553. */
  26554. /**
  26555. * Possible key values for the point state options.
  26556. *
  26557. * @typedef {"hover"|"inactive"|"normal"|"select"} Highcharts.PointStateValue
  26558. */
  26559. /**
  26560. * Gets fired when the point is updated programmatically through the `.update()`
  26561. * method.
  26562. *
  26563. * @callback Highcharts.PointUpdateCallbackFunction
  26564. *
  26565. * @param {Highcharts.Point} this
  26566. * Point where the event occured.
  26567. *
  26568. * @param {Highcharts.PointUpdateEventObject} event
  26569. * Event that occured.
  26570. */
  26571. /**
  26572. * Information about the update event.
  26573. *
  26574. * @interface Highcharts.PointUpdateEventObject
  26575. * @extends global.Event
  26576. */ /**
  26577. * Options data of the update event.
  26578. * @name Highcharts.PointUpdateEventObject#options
  26579. * @type {Highcharts.PointOptionsType}
  26580. */
  26581. ''; // detach doclet above
  26582. /* eslint-disable no-invalid-this, valid-jsdoc */
  26583. /**
  26584. * The Point object. The point objects are generated from the `series.data`
  26585. * configuration objects or raw numbers. They can be accessed from the
  26586. * `Series.points` array. Other ways to instantiate points are through {@link
  26587. * Highcharts.Series#addPoint} or {@link Highcharts.Series#setData}.
  26588. *
  26589. * @class
  26590. * @name Highcharts.Point
  26591. */
  26592. var Point = /** @class */ (function () {
  26593. function Point() {
  26594. /* *
  26595. *
  26596. * Properties
  26597. *
  26598. * */
  26599. /**
  26600. * For categorized axes this property holds the category name for the
  26601. * point. For other axes it holds the X value.
  26602. *
  26603. * @name Highcharts.Point#category
  26604. * @type {string}
  26605. */
  26606. this.category = void 0;
  26607. /**
  26608. * The point's current color index, used in styled mode instead of
  26609. * `color`. The color index is inserted in class names used for styling.
  26610. *
  26611. * @name Highcharts.Point#colorIndex
  26612. * @type {number}
  26613. */
  26614. this.colorIndex = void 0;
  26615. this.formatPrefix = 'point';
  26616. this.id = void 0;
  26617. this.isNull = false;
  26618. /**
  26619. * The name of the point. The name can be given as the first position of the
  26620. * point configuration array, or as a `name` property in the configuration:
  26621. *
  26622. * @example
  26623. * // Array config
  26624. * data: [
  26625. * ['John', 1],
  26626. * ['Jane', 2]
  26627. * ]
  26628. *
  26629. * // Object config
  26630. * data: [{
  26631. * name: 'John',
  26632. * y: 1
  26633. * }, {
  26634. * name: 'Jane',
  26635. * y: 2
  26636. * }]
  26637. *
  26638. * @name Highcharts.Point#name
  26639. * @type {string}
  26640. */
  26641. this.name = void 0;
  26642. /**
  26643. * The point's options as applied in the initial configuration, or
  26644. * extended through `Point.update`.
  26645. *
  26646. * In TypeScript you have to extend `PointOptionsObject` via an
  26647. * additional interface to allow custom data options:
  26648. *
  26649. * ```
  26650. * declare interface PointOptionsObject {
  26651. * customProperty: string;
  26652. * }
  26653. * ```
  26654. *
  26655. * @name Highcharts.Point#options
  26656. * @type {Highcharts.PointOptionsObject}
  26657. */
  26658. this.options = void 0;
  26659. /**
  26660. * The percentage for points in a stacked series or pies.
  26661. *
  26662. * @name Highcharts.Point#percentage
  26663. * @type {number|undefined}
  26664. */
  26665. this.percentage = void 0;
  26666. this.selected = false;
  26667. /**
  26668. * The series object associated with the point.
  26669. *
  26670. * @name Highcharts.Point#series
  26671. * @type {Highcharts.Series}
  26672. */
  26673. this.series = void 0;
  26674. /**
  26675. * The total of values in either a stack for stacked series, or a pie in a
  26676. * pie series.
  26677. *
  26678. * @name Highcharts.Point#total
  26679. * @type {number|undefined}
  26680. */
  26681. this.total = void 0;
  26682. /**
  26683. * For certain series types, like pie charts, where individual points can
  26684. * be shown or hidden.
  26685. *
  26686. * @name Highcharts.Point#visible
  26687. * @type {boolean}
  26688. * @default true
  26689. */
  26690. this.visible = true;
  26691. this.x = void 0;
  26692. }
  26693. /* *
  26694. *
  26695. * Functions
  26696. *
  26697. * */
  26698. /**
  26699. * Animate SVG elements associated with the point.
  26700. *
  26701. * @private
  26702. * @function Highcharts.Point#animateBeforeDestroy
  26703. */
  26704. Point.prototype.animateBeforeDestroy = function () {
  26705. var point = this,
  26706. animateParams = { x: point.startXPos,
  26707. opacity: 0 },
  26708. isDataLabel,
  26709. graphicalProps = point.getGraphicalProps();
  26710. graphicalProps.singular.forEach(function (prop) {
  26711. isDataLabel = prop === 'dataLabel';
  26712. point[prop] = point[prop].animate(isDataLabel ? {
  26713. x: point[prop].startXPos,
  26714. y: point[prop].startYPos,
  26715. opacity: 0
  26716. } : animateParams);
  26717. });
  26718. graphicalProps.plural.forEach(function (plural) {
  26719. point[plural].forEach(function (item) {
  26720. if (item.element) {
  26721. item.animate(extend({ x: point.startXPos }, (item.startYPos ? {
  26722. x: item.startXPos,
  26723. y: item.startYPos
  26724. } : {})));
  26725. }
  26726. });
  26727. });
  26728. };
  26729. /**
  26730. * Apply the options containing the x and y data and possible some extra
  26731. * properties. Called on point init or from point.update.
  26732. *
  26733. * @private
  26734. * @function Highcharts.Point#applyOptions
  26735. *
  26736. * @param {Highcharts.PointOptionsType} options
  26737. * The point options as defined in series.data.
  26738. *
  26739. * @param {number} [x]
  26740. * Optionally, the x value.
  26741. *
  26742. * @return {Highcharts.Point}
  26743. * The Point instance.
  26744. */
  26745. Point.prototype.applyOptions = function (options, x) {
  26746. var point = this,
  26747. series = point.series,
  26748. pointValKey = series.options.pointValKey || series.pointValKey;
  26749. options = Point.prototype.optionsToObject.call(this, options);
  26750. // copy options directly to point
  26751. extend(point, options);
  26752. point.options = point.options ? extend(point.options, options) : options;
  26753. // Since options are copied into the Point instance, some accidental
  26754. // options must be shielded (#5681)
  26755. if (options.group) {
  26756. delete point.group;
  26757. }
  26758. if (options.dataLabels) {
  26759. delete point.dataLabels;
  26760. }
  26761. /**
  26762. * The y value of the point.
  26763. * @name Highcharts.Point#y
  26764. * @type {number|undefined}
  26765. */
  26766. // For higher dimension series types. For instance, for ranges, point.y
  26767. // is mapped to point.low.
  26768. if (pointValKey) {
  26769. point.y = Point.prototype.getNestedProperty.call(point, pointValKey);
  26770. }
  26771. point.isNull = pick(point.isValid && !point.isValid(), point.x === null || !isNumber(point.y)); // #3571, check for NaN
  26772. point.formatPrefix = point.isNull ? 'null' : 'point'; // #9233, #10874
  26773. // The point is initially selected by options (#5777)
  26774. if (point.selected) {
  26775. point.state = 'select';
  26776. }
  26777. /**
  26778. * The x value of the point.
  26779. * @name Highcharts.Point#x
  26780. * @type {number}
  26781. */
  26782. // If no x is set by now, get auto incremented value. All points must
  26783. // have an x value, however the y value can be null to create a gap in
  26784. // the series
  26785. if ('name' in point &&
  26786. typeof x === 'undefined' &&
  26787. series.xAxis &&
  26788. series.xAxis.hasNames) {
  26789. point.x = series.xAxis.nameToX(point);
  26790. }
  26791. if (typeof point.x === 'undefined' && series) {
  26792. if (typeof x === 'undefined') {
  26793. point.x = series.autoIncrement(point);
  26794. }
  26795. else {
  26796. point.x = x;
  26797. }
  26798. }
  26799. return point;
  26800. };
  26801. /**
  26802. * Destroy a point to clear memory. Its reference still stays in
  26803. * `series.data`.
  26804. *
  26805. * @private
  26806. * @function Highcharts.Point#destroy
  26807. */
  26808. Point.prototype.destroy = function () {
  26809. var point = this,
  26810. series = point.series,
  26811. chart = series.chart,
  26812. dataSorting = series.options.dataSorting,
  26813. hoverPoints = chart.hoverPoints,
  26814. globalAnimation = point.series.chart.renderer.globalAnimation,
  26815. animation = animObject(globalAnimation),
  26816. prop;
  26817. /**
  26818. * Allow to call after animation.
  26819. * @private
  26820. */
  26821. function destroyPoint() {
  26822. // Remove all events and elements
  26823. if (point.graphic || point.dataLabel || point.dataLabels) {
  26824. removeEvent(point);
  26825. point.destroyElements();
  26826. }
  26827. for (prop in point) { // eslint-disable-line guard-for-in
  26828. point[prop] = null;
  26829. }
  26830. }
  26831. if (point.legendItem) { // pies have legend items
  26832. chart.legend.destroyItem(point);
  26833. }
  26834. if (hoverPoints) {
  26835. point.setState();
  26836. erase(hoverPoints, point);
  26837. if (!hoverPoints.length) {
  26838. chart.hoverPoints = null;
  26839. }
  26840. }
  26841. if (point === chart.hoverPoint) {
  26842. point.onMouseOut();
  26843. }
  26844. // Remove properties after animation
  26845. if (!dataSorting || !dataSorting.enabled) {
  26846. destroyPoint();
  26847. }
  26848. else {
  26849. this.animateBeforeDestroy();
  26850. syncTimeout(destroyPoint, animation.duration);
  26851. }
  26852. chart.pointCount--;
  26853. };
  26854. /**
  26855. * Destroy SVG elements associated with the point.
  26856. *
  26857. * @private
  26858. * @function Highcharts.Point#destroyElements
  26859. * @param {Highcharts.Dictionary<number>} [kinds]
  26860. */
  26861. Point.prototype.destroyElements = function (kinds) {
  26862. var point = this,
  26863. props = point.getGraphicalProps(kinds);
  26864. props.singular.forEach(function (prop) {
  26865. point[prop] = point[prop].destroy();
  26866. });
  26867. props.plural.forEach(function (plural) {
  26868. point[plural].forEach(function (item) {
  26869. if (item.element) {
  26870. item.destroy();
  26871. }
  26872. });
  26873. delete point[plural];
  26874. });
  26875. };
  26876. /**
  26877. * Fire an event on the Point object.
  26878. *
  26879. * @private
  26880. * @function Highcharts.Point#firePointEvent
  26881. *
  26882. * @param {string} eventType
  26883. * Type of the event.
  26884. *
  26885. * @param {Highcharts.Dictionary<any>|Event} [eventArgs]
  26886. * Additional event arguments.
  26887. *
  26888. * @param {Highcharts.EventCallbackFunction<Highcharts.Point>|Function} [defaultFunction]
  26889. * Default event handler.
  26890. *
  26891. * @fires Highcharts.Point#event:*
  26892. */
  26893. Point.prototype.firePointEvent = function (eventType, eventArgs, defaultFunction) {
  26894. var point = this,
  26895. series = this.series,
  26896. seriesOptions = series.options;
  26897. // load event handlers on demand to save time on mouseover/out
  26898. if (seriesOptions.point.events[eventType] ||
  26899. (point.options &&
  26900. point.options.events &&
  26901. point.options.events[eventType])) {
  26902. point.importEvents();
  26903. }
  26904. // add default handler if in selection mode
  26905. if (eventType === 'click' && seriesOptions.allowPointSelect) {
  26906. defaultFunction = function (event) {
  26907. // Control key is for Windows, meta (= Cmd key) for Mac, Shift
  26908. // for Opera.
  26909. if (point.select) { // #2911
  26910. point.select(null, event.ctrlKey || event.metaKey || event.shiftKey);
  26911. }
  26912. };
  26913. }
  26914. fireEvent(point, eventType, eventArgs, defaultFunction);
  26915. };
  26916. /**
  26917. * Get the CSS class names for individual points. Used internally where the
  26918. * returned value is set on every point.
  26919. *
  26920. * @function Highcharts.Point#getClassName
  26921. *
  26922. * @return {string}
  26923. * The class names.
  26924. */
  26925. Point.prototype.getClassName = function () {
  26926. var point = this;
  26927. return 'highcharts-point' +
  26928. (point.selected ? ' highcharts-point-select' : '') +
  26929. (point.negative ? ' highcharts-negative' : '') +
  26930. (point.isNull ? ' highcharts-null-point' : '') +
  26931. (typeof point.colorIndex !== 'undefined' ?
  26932. ' highcharts-color-' + point.colorIndex : '') +
  26933. (point.options.className ? ' ' + point.options.className : '') +
  26934. (point.zone && point.zone.className ? ' ' +
  26935. point.zone.className.replace('highcharts-negative', '') : '');
  26936. };
  26937. /**
  26938. * Get props of all existing graphical point elements.
  26939. *
  26940. * @private
  26941. * @function Highcharts.Point#getGraphicalProps
  26942. * @param {Highcharts.Dictionary<number>} [kinds]
  26943. * @return {Highcharts.PointGraphicalProps}
  26944. */
  26945. Point.prototype.getGraphicalProps = function (kinds) {
  26946. var point = this,
  26947. props = [],
  26948. prop,
  26949. i,
  26950. graphicalProps = { singular: [],
  26951. plural: [] };
  26952. kinds = kinds || { graphic: 1, dataLabel: 1 };
  26953. if (kinds.graphic) {
  26954. props.push('graphic', 'shadowGroup');
  26955. }
  26956. if (kinds.dataLabel) {
  26957. props.push('dataLabel', 'dataLabelUpper', 'connector');
  26958. }
  26959. i = props.length;
  26960. while (i--) {
  26961. prop = props[i];
  26962. if (point[prop]) {
  26963. graphicalProps.singular.push(prop);
  26964. }
  26965. }
  26966. ['dataLabel', 'connector'].forEach(function (prop) {
  26967. var plural = prop + 's';
  26968. if (kinds[prop] && point[plural]) {
  26969. graphicalProps.plural.push(plural);
  26970. }
  26971. });
  26972. return graphicalProps;
  26973. };
  26974. /**
  26975. * Return the configuration hash needed for the data label and tooltip
  26976. * formatters.
  26977. *
  26978. * @function Highcharts.Point#getLabelConfig
  26979. *
  26980. * @return {Highcharts.PointLabelObject}
  26981. * Abstract object used in formatters and formats.
  26982. */
  26983. Point.prototype.getLabelConfig = function () {
  26984. return {
  26985. x: this.category,
  26986. y: this.y,
  26987. color: this.color,
  26988. colorIndex: this.colorIndex,
  26989. key: this.name || this.category,
  26990. series: this.series,
  26991. point: this,
  26992. percentage: this.percentage,
  26993. total: this.total || this.stackTotal
  26994. };
  26995. };
  26996. /**
  26997. * Returns the value of the point property for a given value.
  26998. * @private
  26999. */
  27000. Point.prototype.getNestedProperty = function (key) {
  27001. if (!key) {
  27002. return;
  27003. }
  27004. if (key.indexOf('custom.') === 0) {
  27005. return getNestedProperty(key, this.options);
  27006. }
  27007. return this[key];
  27008. };
  27009. /**
  27010. * In a series with `zones`, return the zone that the point belongs to.
  27011. *
  27012. * @function Highcharts.Point#getZone
  27013. *
  27014. * @return {Highcharts.SeriesZonesOptionsObject}
  27015. * The zone item.
  27016. */
  27017. Point.prototype.getZone = function () {
  27018. var series = this.series,
  27019. zones = series.zones,
  27020. zoneAxis = series.zoneAxis || 'y',
  27021. i = 0,
  27022. zone;
  27023. zone = zones[i];
  27024. while (this[zoneAxis] >= zone.value) {
  27025. zone = zones[++i];
  27026. }
  27027. // For resetting or reusing the point (#8100)
  27028. if (!this.nonZonedColor) {
  27029. this.nonZonedColor = this.color;
  27030. }
  27031. if (zone && zone.color && !this.options.color) {
  27032. this.color = zone.color;
  27033. }
  27034. else {
  27035. this.color = this.nonZonedColor;
  27036. }
  27037. return zone;
  27038. };
  27039. /**
  27040. * Utility to check if point has new shape type. Used in column series and
  27041. * all others that are based on column series.
  27042. *
  27043. * @return boolean|undefined
  27044. */
  27045. Point.prototype.hasNewShapeType = function () {
  27046. var point = this;
  27047. var oldShapeType = point.graphic &&
  27048. (point.graphic.symbolName || point.graphic.element.nodeName);
  27049. return oldShapeType !== this.shapeType;
  27050. };
  27051. /**
  27052. * Initialize the point. Called internally based on the `series.data`
  27053. * option.
  27054. *
  27055. * @function Highcharts.Point#init
  27056. *
  27057. * @param {Highcharts.Series} series
  27058. * The series object containing this point.
  27059. *
  27060. * @param {Highcharts.PointOptionsType} options
  27061. * The data in either number, array or object format.
  27062. *
  27063. * @param {number} [x]
  27064. * Optionally, the X value of the point.
  27065. *
  27066. * @return {Highcharts.Point}
  27067. * The Point instance.
  27068. *
  27069. * @fires Highcharts.Point#event:afterInit
  27070. */
  27071. Point.prototype.init = function (series, options, x) {
  27072. this.series = series;
  27073. this.applyOptions(options, x);
  27074. // Add a unique ID to the point if none is assigned
  27075. this.id = defined(this.id) ? this.id : uniqueKey();
  27076. this.resolveColor();
  27077. series.chart.pointCount++;
  27078. fireEvent(this, 'afterInit');
  27079. return this;
  27080. };
  27081. /**
  27082. * Transform number or array configs into objects. Also called for object
  27083. * configs. Used internally to unify the different configuration formats for
  27084. * points. For example, a simple number `10` in a line series will be
  27085. * transformed to `{ y: 10 }`, and an array config like `[1, 10]` in a
  27086. * scatter series will be transformed to `{ x: 1, y: 10 }`.
  27087. *
  27088. * @function Highcharts.Point#optionsToObject
  27089. *
  27090. * @param {Highcharts.PointOptionsType} options
  27091. * The input option.
  27092. *
  27093. * @return {Highcharts.Dictionary<*>}
  27094. * Transformed options.
  27095. */
  27096. Point.prototype.optionsToObject = function (options) {
  27097. var ret = {},
  27098. series = this.series,
  27099. keys = series.options.keys,
  27100. pointArrayMap = keys || series.pointArrayMap || ['y'],
  27101. valueCount = pointArrayMap.length,
  27102. firstItemType,
  27103. i = 0,
  27104. j = 0;
  27105. if (isNumber(options) || options === null) {
  27106. ret[pointArrayMap[0]] = options;
  27107. }
  27108. else if (isArray(options)) {
  27109. // with leading x value
  27110. if (!keys && options.length > valueCount) {
  27111. firstItemType = typeof options[0];
  27112. if (firstItemType === 'string') {
  27113. ret.name = options[0];
  27114. }
  27115. else if (firstItemType === 'number') {
  27116. ret.x = options[0];
  27117. }
  27118. i++;
  27119. }
  27120. while (j < valueCount) {
  27121. // Skip undefined positions for keys
  27122. if (!keys || typeof options[i] !== 'undefined') {
  27123. if (pointArrayMap[j].indexOf('.') > 0) {
  27124. // Handle nested keys, e.g. ['color.pattern.image']
  27125. // Avoid function call unless necessary.
  27126. Point.prototype.setNestedProperty(ret, options[i], pointArrayMap[j]);
  27127. }
  27128. else {
  27129. ret[pointArrayMap[j]] = options[i];
  27130. }
  27131. }
  27132. i++;
  27133. j++;
  27134. }
  27135. }
  27136. else if (typeof options === 'object') {
  27137. ret = options;
  27138. // This is the fastest way to detect if there are individual point
  27139. // dataLabels that need to be considered in drawDataLabels. These
  27140. // can only occur in object configs.
  27141. if (options.dataLabels) {
  27142. series._hasPointLabels = true;
  27143. }
  27144. // Same approach as above for markers
  27145. if (options.marker) {
  27146. series._hasPointMarkers = true;
  27147. }
  27148. }
  27149. return ret;
  27150. };
  27151. /**
  27152. * @private
  27153. * @function Highcharts.Point#resolveColor
  27154. * @return {void}
  27155. */
  27156. Point.prototype.resolveColor = function () {
  27157. var series = this.series,
  27158. colors,
  27159. optionsChart = series.chart.options.chart,
  27160. colorCount = optionsChart.colorCount,
  27161. styledMode = series.chart.styledMode,
  27162. colorIndex;
  27163. // remove points nonZonedColor for later recalculation
  27164. delete this.nonZonedColor;
  27165. /**
  27166. * The point's current color.
  27167. *
  27168. * @name Highcharts.Point#color
  27169. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject|undefined}
  27170. */
  27171. if (!styledMode && !this.options.color) {
  27172. this.color = series.color; // #3445
  27173. }
  27174. if (series.options.colorByPoint) {
  27175. if (!styledMode) {
  27176. colors = series.options.colors || series.chart.options.colors;
  27177. this.color = this.color || colors[series.colorCounter];
  27178. colorCount = colors.length;
  27179. }
  27180. colorIndex = series.colorCounter;
  27181. series.colorCounter++;
  27182. // loop back to zero
  27183. if (series.colorCounter === colorCount) {
  27184. series.colorCounter = 0;
  27185. }
  27186. }
  27187. else {
  27188. colorIndex = series.colorIndex;
  27189. }
  27190. this.colorIndex = pick(this.colorIndex, colorIndex);
  27191. };
  27192. /**
  27193. * Set a value in an object, on the property defined by key. The key
  27194. * supports nested properties using dot notation. The function modifies the
  27195. * input object and does not make a copy.
  27196. *
  27197. * @function Highcharts.Point#setNestedProperty<T>
  27198. *
  27199. * @param {T} object
  27200. * The object to set the value on.
  27201. *
  27202. * @param {*} value
  27203. * The value to set.
  27204. *
  27205. * @param {string} key
  27206. * Key to the property to set.
  27207. *
  27208. * @return {T}
  27209. * The modified object.
  27210. */
  27211. Point.prototype.setNestedProperty = function (object, value, key) {
  27212. var nestedKeys = key.split('.');
  27213. nestedKeys.reduce(function (result, key, i, arr) {
  27214. var isLastKey = arr.length - 1 === i;
  27215. result[key] = (isLastKey ?
  27216. value :
  27217. isObject(result[key], true) ?
  27218. result[key] :
  27219. {});
  27220. return result[key];
  27221. }, object);
  27222. return object;
  27223. };
  27224. /**
  27225. * Extendable method for formatting each point's tooltip line.
  27226. *
  27227. * @function Highcharts.Point#tooltipFormatter
  27228. *
  27229. * @param {string} pointFormat
  27230. * The point format.
  27231. *
  27232. * @return {string}
  27233. * A string to be concatenated in to the common tooltip text.
  27234. */
  27235. Point.prototype.tooltipFormatter = function (pointFormat) {
  27236. // Insert options for valueDecimals, valuePrefix, and valueSuffix
  27237. var series = this.series, seriesTooltipOptions = series.tooltipOptions, valueDecimals = pick(seriesTooltipOptions.valueDecimals, ''), valuePrefix = seriesTooltipOptions.valuePrefix || '', valueSuffix = seriesTooltipOptions.valueSuffix || '';
  27238. // Replace default point style with class name
  27239. if (series.chart.styledMode) {
  27240. pointFormat =
  27241. series.chart.tooltip.styledModeFormat(pointFormat);
  27242. }
  27243. // Loop over the point array map and replace unformatted values with
  27244. // sprintf formatting markup
  27245. (series.pointArrayMap || ['y']).forEach(function (key) {
  27246. key = '{point.' + key; // without the closing bracket
  27247. if (valuePrefix || valueSuffix) {
  27248. pointFormat = pointFormat.replace(RegExp(key + '}', 'g'), valuePrefix + key + '}' + valueSuffix);
  27249. }
  27250. pointFormat = pointFormat.replace(RegExp(key + '}', 'g'), key + ':,.' + valueDecimals + 'f}');
  27251. });
  27252. return format(pointFormat, {
  27253. point: this,
  27254. series: this.series
  27255. }, series.chart);
  27256. };
  27257. return Point;
  27258. }());
  27259. H.Point = Point;
  27260. return Point;
  27261. });
  27262. _registerModule(_modules, 'Core/Series/Series.js', [_modules['Core/Globals.js'], _modules['Core/Series/Point.js'], _modules['Core/Utilities.js']], function (H, Point, U) {
  27263. /* *
  27264. *
  27265. * (c) 2010-2020 Torstein Honsi
  27266. *
  27267. * License: www.highcharts.com/license
  27268. *
  27269. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  27270. *
  27271. * */
  27272. var error = U.error,
  27273. extendClass = U.extendClass,
  27274. fireEvent = U.fireEvent,
  27275. getOptions = U.getOptions,
  27276. isObject = U.isObject,
  27277. merge = U.merge,
  27278. objectEach = U.objectEach;
  27279. /**
  27280. * @class
  27281. * @name Highcharts.Series
  27282. */
  27283. var BaseSeries = /** @class */ (function () {
  27284. /* *
  27285. *
  27286. * Constructor
  27287. *
  27288. * */
  27289. function BaseSeries(chart, options) {
  27290. var mergedOptions = merge(BaseSeries.defaultOptions, options);
  27291. this.chart = chart;
  27292. this._i = chart.series.length;
  27293. chart.series.push(this);
  27294. this.options = mergedOptions;
  27295. this.userOptions = merge(options);
  27296. }
  27297. /* *
  27298. *
  27299. * Static Functions
  27300. *
  27301. * */
  27302. BaseSeries.addSeries = function (seriesName, seriesType) {
  27303. BaseSeries.seriesTypes[seriesName] = seriesType;
  27304. };
  27305. BaseSeries.cleanRecursively = function (toClean, reference) {
  27306. var clean = {};
  27307. objectEach(toClean, function (_val, key) {
  27308. var ob;
  27309. // Dive into objects (except DOM nodes)
  27310. if (isObject(toClean[key], true) &&
  27311. !toClean.nodeType && // #10044
  27312. reference[key]) {
  27313. ob = BaseSeries.cleanRecursively(toClean[key], reference[key]);
  27314. if (Object.keys(ob).length) {
  27315. clean[key] = ob;
  27316. }
  27317. // Arrays, primitives and DOM nodes are copied directly
  27318. }
  27319. else if (isObject(toClean[key]) ||
  27320. toClean[key] !== reference[key]) {
  27321. clean[key] = toClean[key];
  27322. }
  27323. });
  27324. return clean;
  27325. };
  27326. // eslint-disable-next-line valid-jsdoc
  27327. /**
  27328. * Internal function to initialize an individual series.
  27329. * @private
  27330. */
  27331. BaseSeries.getSeries = function (chart, options) {
  27332. if (options === void 0) { options = {}; }
  27333. var optionsChart = chart.options.chart,
  27334. type = (options.type ||
  27335. optionsChart.type ||
  27336. optionsChart.defaultSeriesType ||
  27337. ''),
  27338. Series = BaseSeries.seriesTypes[type];
  27339. // No such series type
  27340. if (!Series) {
  27341. error(17, true, chart, { missingModuleFor: type });
  27342. }
  27343. return new Series(chart, options);
  27344. };
  27345. /**
  27346. * Factory to create new series prototypes.
  27347. *
  27348. * @function Highcharts.seriesType
  27349. *
  27350. * @param {string} type
  27351. * The series type name.
  27352. *
  27353. * @param {string} parent
  27354. * The parent series type name. Use `line` to inherit from the basic
  27355. * {@link Series} object.
  27356. *
  27357. * @param {Highcharts.SeriesOptionsType|Highcharts.Dictionary<*>} options
  27358. * The additional default options that are merged with the parent's options.
  27359. *
  27360. * @param {Highcharts.Dictionary<*>} [props]
  27361. * The properties (functions and primitives) to set on the new prototype.
  27362. *
  27363. * @param {Highcharts.Dictionary<*>} [pointProps]
  27364. * Members for a series-specific extension of the {@link Point} prototype if
  27365. * needed.
  27366. *
  27367. * @return {Highcharts.Series}
  27368. * The newly created prototype as extended from {@link Series} or its
  27369. * derivatives.
  27370. */
  27371. // docs: add to API + extending Highcharts
  27372. BaseSeries.seriesType = function (type, parent, options, seriesProto, pointProto) {
  27373. var defaultOptions = getOptions().plotOptions || {},
  27374. seriesTypes = BaseSeries.seriesTypes;
  27375. parent = parent || '';
  27376. // Merge the options
  27377. defaultOptions[type] = merge(defaultOptions[parent], options);
  27378. // Create the class
  27379. BaseSeries.addSeries(type, extendClass(seriesTypes[parent] || function () { }, seriesProto));
  27380. seriesTypes[type].prototype.type = type;
  27381. // Create the point class if needed
  27382. if (pointProto) {
  27383. seriesTypes[type].prototype.pointClass =
  27384. extendClass(Point, pointProto);
  27385. }
  27386. return seriesTypes[type];
  27387. };
  27388. BaseSeries.prototype.update = function (newOptions, redraw) {
  27389. if (redraw === void 0) { redraw = true; }
  27390. var series = this;
  27391. newOptions = BaseSeries.cleanRecursively(newOptions, this.userOptions);
  27392. var newType = newOptions.type;
  27393. if (typeof newType !== 'undefined' &&
  27394. newType !== series.type) {
  27395. series = BaseSeries.getSeries(series.chart, newOptions);
  27396. }
  27397. fireEvent(series, 'update', { newOptions: newOptions });
  27398. series.userOptions = merge(newOptions);
  27399. fireEvent(series, 'afterUpdate', { newOptions: newOptions });
  27400. if (redraw) {
  27401. series.chart.redraw();
  27402. }
  27403. return series;
  27404. };
  27405. /* *
  27406. *
  27407. * Static Properties
  27408. *
  27409. * */
  27410. BaseSeries.defaultOptions = {
  27411. type: 'base'
  27412. };
  27413. BaseSeries.seriesTypes = {};
  27414. return BaseSeries;
  27415. }());
  27416. BaseSeries.prototype.pointClass = Point;
  27417. // backwards compatibility
  27418. H.seriesType = BaseSeries.seriesType;
  27419. H.seriesTypes = BaseSeries.seriesTypes;
  27420. /* *
  27421. *
  27422. * Export
  27423. *
  27424. * */
  27425. return BaseSeries;
  27426. });
  27427. _registerModule(_modules, 'Core/Chart/Chart.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Axis/Axis.js'], _modules['Core/Series/Series.js'], _modules['Core/Globals.js'], _modules['Core/Legend.js'], _modules['Core/MSPointer.js'], _modules['Core/Options.js'], _modules['Core/Pointer.js'], _modules['Core/Time.js'], _modules['Core/Utilities.js']], function (A, Axis, BaseSeries, H, Legend, MSPointer, O, Pointer, Time, U) {
  27428. /* *
  27429. *
  27430. * (c) 2010-2020 Torstein Honsi
  27431. *
  27432. * License: www.highcharts.com/license
  27433. *
  27434. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  27435. *
  27436. * */
  27437. var animate = A.animate,
  27438. animObject = A.animObject,
  27439. setAnimation = A.setAnimation;
  27440. var charts = H.charts,
  27441. doc = H.doc,
  27442. win = H.win;
  27443. var defaultOptions = O.defaultOptions;
  27444. var addEvent = U.addEvent,
  27445. attr = U.attr,
  27446. createElement = U.createElement,
  27447. css = U.css,
  27448. defined = U.defined,
  27449. discardElement = U.discardElement,
  27450. erase = U.erase,
  27451. error = U.error,
  27452. extend = U.extend,
  27453. find = U.find,
  27454. fireEvent = U.fireEvent,
  27455. getStyle = U.getStyle,
  27456. isArray = U.isArray,
  27457. isFunction = U.isFunction,
  27458. isNumber = U.isNumber,
  27459. isObject = U.isObject,
  27460. isString = U.isString,
  27461. merge = U.merge,
  27462. numberFormat = U.numberFormat,
  27463. objectEach = U.objectEach,
  27464. pick = U.pick,
  27465. pInt = U.pInt,
  27466. relativeLength = U.relativeLength,
  27467. removeEvent = U.removeEvent,
  27468. splat = U.splat,
  27469. syncTimeout = U.syncTimeout,
  27470. uniqueKey = U.uniqueKey;
  27471. /**
  27472. * Callback for chart constructors.
  27473. *
  27474. * @callback Highcharts.ChartCallbackFunction
  27475. *
  27476. * @param {Highcharts.Chart} chart
  27477. * Created chart.
  27478. */
  27479. /**
  27480. * Format a number and return a string based on input settings.
  27481. *
  27482. * @callback Highcharts.NumberFormatterCallbackFunction
  27483. *
  27484. * @param {number} number
  27485. * The input number to format.
  27486. *
  27487. * @param {number} decimals
  27488. * The amount of decimals. A value of -1 preserves the amount in the
  27489. * input number.
  27490. *
  27491. * @param {string} [decimalPoint]
  27492. * The decimal point, defaults to the one given in the lang options, or
  27493. * a dot.
  27494. *
  27495. * @param {string} [thousandsSep]
  27496. * The thousands separator, defaults to the one given in the lang
  27497. * options, or a space character.
  27498. *
  27499. * @return {string} The formatted number.
  27500. */
  27501. /**
  27502. * The chart title. The title has an `update` method that allows modifying the
  27503. * options directly or indirectly via `chart.update`.
  27504. *
  27505. * @interface Highcharts.TitleObject
  27506. * @extends Highcharts.SVGElement
  27507. */ /**
  27508. * Modify options for the title.
  27509. *
  27510. * @function Highcharts.TitleObject#update
  27511. *
  27512. * @param {Highcharts.TitleOptions} titleOptions
  27513. * Options to modify.
  27514. *
  27515. * @param {boolean} [redraw=true]
  27516. * Whether to redraw the chart after the title is altered. If doing more
  27517. * operations on the chart, it is a good idea to set redraw to false and
  27518. * call {@link Chart#redraw} after.
  27519. */
  27520. /**
  27521. * The chart subtitle. The subtitle has an `update` method that
  27522. * allows modifying the options directly or indirectly via
  27523. * `chart.update`.
  27524. *
  27525. * @interface Highcharts.SubtitleObject
  27526. * @extends Highcharts.SVGElement
  27527. */ /**
  27528. * Modify options for the subtitle.
  27529. *
  27530. * @function Highcharts.SubtitleObject#update
  27531. *
  27532. * @param {Highcharts.SubtitleOptions} subtitleOptions
  27533. * Options to modify.
  27534. *
  27535. * @param {boolean} [redraw=true]
  27536. * Whether to redraw the chart after the subtitle is altered. If doing
  27537. * more operations on the chart, it is a good idea to set redraw to false
  27538. * and call {@link Chart#redraw} after.
  27539. */
  27540. /**
  27541. * The chart caption. The caption has an `update` method that
  27542. * allows modifying the options directly or indirectly via
  27543. * `chart.update`.
  27544. *
  27545. * @interface Highcharts.CaptionObject
  27546. * @extends Highcharts.SVGElement
  27547. */ /**
  27548. * Modify options for the caption.
  27549. *
  27550. * @function Highcharts.CaptionObject#update
  27551. *
  27552. * @param {Highcharts.CaptionOptions} captionOptions
  27553. * Options to modify.
  27554. *
  27555. * @param {boolean} [redraw=true]
  27556. * Whether to redraw the chart after the caption is altered. If doing
  27557. * more operations on the chart, it is a good idea to set redraw to false
  27558. * and call {@link Chart#redraw} after.
  27559. */
  27560. var marginNames = H.marginNames;
  27561. /* eslint-disable no-invalid-this, valid-jsdoc */
  27562. /**
  27563. * The Chart class. The recommended constructor is {@link Highcharts#chart}.
  27564. *
  27565. * @example
  27566. * var chart = Highcharts.chart('container', {
  27567. * title: {
  27568. * text: 'My chart'
  27569. * },
  27570. * series: [{
  27571. * data: [1, 3, 2, 4]
  27572. * }]
  27573. * })
  27574. *
  27575. * @class
  27576. * @name Highcharts.Chart
  27577. *
  27578. * @param {string|Highcharts.HTMLDOMElement} [renderTo]
  27579. * The DOM element to render to, or its id.
  27580. *
  27581. * @param {Highcharts.Options} options
  27582. * The chart options structure.
  27583. *
  27584. * @param {Highcharts.ChartCallbackFunction} [callback]
  27585. * Function to run when the chart has loaded and and all external images
  27586. * are loaded. Defining a
  27587. * [chart.events.load](https://api.highcharts.com/highcharts/chart.events.load)
  27588. * handler is equivalent.
  27589. */
  27590. var Chart = /** @class */ (function () {
  27591. function Chart(a, b, c) {
  27592. this.axes = void 0;
  27593. this.axisOffset = void 0;
  27594. this.bounds = void 0;
  27595. this.chartHeight = void 0;
  27596. this.chartWidth = void 0;
  27597. this.clipBox = void 0;
  27598. this.colorCounter = void 0;
  27599. this.container = void 0;
  27600. this.index = void 0;
  27601. this.isResizing = void 0;
  27602. this.labelCollectors = void 0;
  27603. this.legend = void 0;
  27604. this.margin = void 0;
  27605. this.numberFormatter = void 0;
  27606. this.options = void 0;
  27607. this.plotBox = void 0;
  27608. this.plotHeight = void 0;
  27609. this.plotLeft = void 0;
  27610. this.plotTop = void 0;
  27611. this.plotWidth = void 0;
  27612. this.pointCount = void 0;
  27613. this.pointer = void 0;
  27614. this.renderer = void 0;
  27615. this.renderTo = void 0;
  27616. this.series = void 0;
  27617. this.spacing = void 0;
  27618. this.spacingBox = void 0;
  27619. this.symbolCounter = void 0;
  27620. this.time = void 0;
  27621. this.titleOffset = void 0;
  27622. this.userOptions = void 0;
  27623. this.xAxis = void 0;
  27624. this.yAxis = void 0;
  27625. this.getArgs(a, b, c);
  27626. }
  27627. /* *
  27628. *
  27629. * Functions
  27630. *
  27631. * */
  27632. /**
  27633. * Handle the arguments passed to the constructor.
  27634. *
  27635. * @private
  27636. * @function Highcharts.Chart#getArgs
  27637. *
  27638. * @param {...Array<*>} arguments
  27639. * All arguments for the constructor.
  27640. *
  27641. * @fires Highcharts.Chart#event:init
  27642. * @fires Highcharts.Chart#event:afterInit
  27643. */
  27644. Chart.prototype.getArgs = function (a, b, c) {
  27645. // Remove the optional first argument, renderTo, and
  27646. // set it on this.
  27647. if (isString(a) || a.nodeName) {
  27648. this.renderTo = a;
  27649. this.init(b, c);
  27650. }
  27651. else {
  27652. this.init(a, b);
  27653. }
  27654. };
  27655. /**
  27656. * Overridable function that initializes the chart. The constructor's
  27657. * arguments are passed on directly.
  27658. *
  27659. * @function Highcharts.Chart#init
  27660. *
  27661. * @param {Highcharts.Options} userOptions
  27662. * Custom options.
  27663. *
  27664. * @param {Function} [callback]
  27665. * Function to run when the chart has loaded and and all external
  27666. * images are loaded.
  27667. *
  27668. * @return {void}
  27669. *
  27670. * @fires Highcharts.Chart#event:init
  27671. * @fires Highcharts.Chart#event:afterInit
  27672. */
  27673. Chart.prototype.init = function (userOptions, callback) {
  27674. // Handle regular options
  27675. var options,
  27676. // skip merging data points to increase performance
  27677. seriesOptions = userOptions.series,
  27678. userPlotOptions = userOptions.plotOptions || {};
  27679. // Fire the event with a default function
  27680. fireEvent(this, 'init', { args: arguments }, function () {
  27681. userOptions.series = null;
  27682. options = merge(defaultOptions, userOptions); // do the merge
  27683. var optionsChart = options.chart || {};
  27684. // Override (by copy of user options) or clear tooltip options
  27685. // in chart.options.plotOptions (#6218)
  27686. objectEach(options.plotOptions, function (typeOptions, type) {
  27687. if (isObject(typeOptions)) { // #8766
  27688. typeOptions.tooltip = (userPlotOptions[type] && // override by copy:
  27689. merge(userPlotOptions[type].tooltip)) || void 0; // or clear
  27690. }
  27691. });
  27692. // User options have higher priority than default options
  27693. // (#6218). In case of exporting: path is changed
  27694. options.tooltip.userOptions = (userOptions.chart &&
  27695. userOptions.chart.forExport &&
  27696. userOptions.tooltip.userOptions) || userOptions.tooltip;
  27697. // set back the series data
  27698. options.series = userOptions.series = seriesOptions;
  27699. /**
  27700. * The original options given to the constructor or a chart factory
  27701. * like {@link Highcharts.chart} and {@link Highcharts.stockChart}.
  27702. *
  27703. * @name Highcharts.Chart#userOptions
  27704. * @type {Highcharts.Options}
  27705. */
  27706. this.userOptions = userOptions;
  27707. var chartEvents = optionsChart.events;
  27708. this.margin = [];
  27709. this.spacing = [];
  27710. // Pixel data bounds for touch zoom
  27711. this.bounds = { h: {}, v: {} };
  27712. // An array of functions that returns labels that should be
  27713. // considered for anti-collision
  27714. this.labelCollectors = [];
  27715. this.callback = callback;
  27716. this.isResizing = 0;
  27717. /**
  27718. * The options structure for the chart after merging
  27719. * {@link #defaultOptions} and {@link #userOptions}. It contains
  27720. * members for the sub elements like series, legend, tooltip etc.
  27721. *
  27722. * @name Highcharts.Chart#options
  27723. * @type {Highcharts.Options}
  27724. */
  27725. this.options = options;
  27726. /**
  27727. * All the axes in the chart.
  27728. *
  27729. * @see Highcharts.Chart.xAxis
  27730. * @see Highcharts.Chart.yAxis
  27731. *
  27732. * @name Highcharts.Chart#axes
  27733. * @type {Array<Highcharts.Axis>}
  27734. */
  27735. this.axes = [];
  27736. /**
  27737. * All the current series in the chart.
  27738. *
  27739. * @name Highcharts.Chart#series
  27740. * @type {Array<Highcharts.Series>}
  27741. */
  27742. this.series = [];
  27743. /**
  27744. * The `Time` object associated with the chart. Since v6.0.5,
  27745. * time settings can be applied individually for each chart. If
  27746. * no individual settings apply, the `Time` object is shared by
  27747. * all instances.
  27748. *
  27749. * @name Highcharts.Chart#time
  27750. * @type {Highcharts.Time}
  27751. */
  27752. this.time =
  27753. userOptions.time && Object.keys(userOptions.time).length ?
  27754. new Time(userOptions.time) :
  27755. H.time;
  27756. /**
  27757. * Callback function to override the default function that formats
  27758. * all the numbers in the chart. Returns a string with the formatted
  27759. * number.
  27760. *
  27761. * @name Highcharts.Chart#numberFormatter
  27762. * @type {Highcharts.NumberFormatterCallbackFunction}
  27763. */
  27764. this.numberFormatter = optionsChart.numberFormatter || numberFormat;
  27765. /**
  27766. * Whether the chart is in styled mode, meaning all presentatinoal
  27767. * attributes are avoided.
  27768. *
  27769. * @name Highcharts.Chart#styledMode
  27770. * @type {boolean}
  27771. */
  27772. this.styledMode = optionsChart.styledMode;
  27773. this.hasCartesianSeries = optionsChart.showAxes;
  27774. var chart = this;
  27775. /**
  27776. * Index position of the chart in the {@link Highcharts#charts}
  27777. * property.
  27778. *
  27779. * @name Highcharts.Chart#index
  27780. * @type {number}
  27781. * @readonly
  27782. */
  27783. chart.index = charts.length; // Add the chart to the global lookup
  27784. charts.push(chart);
  27785. H.chartCount++;
  27786. // Chart event handlers
  27787. if (chartEvents) {
  27788. objectEach(chartEvents, function (event, eventType) {
  27789. if (isFunction(event)) {
  27790. addEvent(chart, eventType, event);
  27791. }
  27792. });
  27793. }
  27794. /**
  27795. * A collection of the X axes in the chart.
  27796. *
  27797. * @name Highcharts.Chart#xAxis
  27798. * @type {Array<Highcharts.Axis>}
  27799. */
  27800. chart.xAxis = [];
  27801. /**
  27802. * A collection of the Y axes in the chart.
  27803. *
  27804. * @name Highcharts.Chart#yAxis
  27805. * @type {Array<Highcharts.Axis>}
  27806. *
  27807. * @todo
  27808. * Make events official: Fire the event `afterInit`.
  27809. */
  27810. chart.yAxis = [];
  27811. chart.pointCount = chart.colorCounter = chart.symbolCounter = 0;
  27812. // Fire after init but before first render, before axes and series
  27813. // have been initialized.
  27814. fireEvent(chart, 'afterInit');
  27815. chart.firstRender();
  27816. });
  27817. };
  27818. /**
  27819. * Internal function to unitialize an individual series.
  27820. *
  27821. * @private
  27822. * @function Highcharts.Chart#initSeries
  27823. */
  27824. Chart.prototype.initSeries = function (options) {
  27825. var chart = this,
  27826. optionsChart = chart.options.chart,
  27827. type = (options.type ||
  27828. optionsChart.type ||
  27829. optionsChart.defaultSeriesType),
  27830. series,
  27831. Constr = BaseSeries.seriesTypes[type];
  27832. // No such series type
  27833. if (!Constr) {
  27834. error(17, true, chart, { missingModuleFor: type });
  27835. }
  27836. series = new Constr(chart, options);
  27837. if (typeof series.init === 'function') {
  27838. series.init(this, options);
  27839. }
  27840. return series;
  27841. };
  27842. /**
  27843. * Internal function to set data for all series with enabled sorting.
  27844. *
  27845. * @private
  27846. * @function Highcharts.Chart#setSeriesData
  27847. */
  27848. Chart.prototype.setSeriesData = function () {
  27849. this.getSeriesOrderByLinks().forEach(function (series) {
  27850. // We need to set data for series with sorting after series init
  27851. if (!series.points && !series.data && series.enabledDataSorting) {
  27852. series.setData(series.options.data, false);
  27853. }
  27854. });
  27855. };
  27856. /**
  27857. * Sort and return chart series in order depending on the number of linked
  27858. * series.
  27859. *
  27860. * @private
  27861. * @function Highcharts.Series#getSeriesOrderByLinks
  27862. * @return {Array<Highcharts.Series>}
  27863. */
  27864. Chart.prototype.getSeriesOrderByLinks = function () {
  27865. return this.series.concat().sort(function (a, b) {
  27866. if (a.linkedSeries.length || b.linkedSeries.length) {
  27867. return b.linkedSeries.length - a.linkedSeries.length;
  27868. }
  27869. return 0;
  27870. });
  27871. };
  27872. /**
  27873. * Order all series above a given index. When series are added and ordered
  27874. * by configuration, only the last series is handled (#248, #1123, #2456,
  27875. * #6112). This function is called on series initialization and destroy.
  27876. *
  27877. * @private
  27878. * @function Highcharts.Series#orderSeries
  27879. * @param {number} [fromIndex]
  27880. * If this is given, only the series above this index are handled.
  27881. */
  27882. Chart.prototype.orderSeries = function (fromIndex) {
  27883. var series = this.series,
  27884. i = fromIndex || 0;
  27885. for (; i < series.length; i++) {
  27886. if (series[i]) {
  27887. /**
  27888. * Contains the series' index in the `Chart.series` array.
  27889. *
  27890. * @name Highcharts.Series#index
  27891. * @type {number}
  27892. * @readonly
  27893. */
  27894. series[i].index = i;
  27895. series[i].name = series[i].getName();
  27896. }
  27897. }
  27898. };
  27899. /**
  27900. * Check whether a given point is within the plot area.
  27901. *
  27902. * @function Highcharts.Chart#isInsidePlot
  27903. *
  27904. * @param {number} plotX
  27905. * Pixel x relative to the plot area.
  27906. *
  27907. * @param {number} plotY
  27908. * Pixel y relative to the plot area.
  27909. *
  27910. * @param {boolean} [inverted]
  27911. * Whether the chart is inverted.
  27912. *
  27913. * @return {boolean}
  27914. * Returns true if the given point is inside the plot area.
  27915. */
  27916. Chart.prototype.isInsidePlot = function (plotX, plotY, inverted) {
  27917. var x = inverted ? plotY : plotX,
  27918. y = inverted ? plotX : plotY,
  27919. e = {
  27920. x: x,
  27921. y: y,
  27922. isInsidePlot: x >= 0 &&
  27923. x <= this.plotWidth &&
  27924. y >= 0 &&
  27925. y <= this.plotHeight
  27926. };
  27927. fireEvent(this, 'afterIsInsidePlot', e);
  27928. return e.isInsidePlot;
  27929. };
  27930. /**
  27931. * Redraw the chart after changes have been done to the data, axis extremes
  27932. * chart size or chart elements. All methods for updating axes, series or
  27933. * points have a parameter for redrawing the chart. This is `true` by
  27934. * default. But in many cases you want to do more than one operation on the
  27935. * chart before redrawing, for example add a number of points. In those
  27936. * cases it is a waste of resources to redraw the chart for each new point
  27937. * added. So you add the points and call `chart.redraw()` after.
  27938. *
  27939. * @function Highcharts.Chart#redraw
  27940. *
  27941. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  27942. * If or how to apply animation to the redraw.
  27943. *
  27944. * @fires Highcharts.Chart#event:afterSetExtremes
  27945. * @fires Highcharts.Chart#event:beforeRedraw
  27946. * @fires Highcharts.Chart#event:predraw
  27947. * @fires Highcharts.Chart#event:redraw
  27948. * @fires Highcharts.Chart#event:render
  27949. * @fires Highcharts.Chart#event:updatedData
  27950. */
  27951. Chart.prototype.redraw = function (animation) {
  27952. fireEvent(this, 'beforeRedraw');
  27953. var chart = this,
  27954. axes = chart.axes,
  27955. series = chart.series,
  27956. pointer = chart.pointer,
  27957. legend = chart.legend,
  27958. legendUserOptions = chart.userOptions.legend,
  27959. redrawLegend = chart.isDirtyLegend,
  27960. hasStackedSeries,
  27961. hasDirtyStacks,
  27962. hasCartesianSeries = chart.hasCartesianSeries,
  27963. isDirtyBox = chart.isDirtyBox,
  27964. i,
  27965. serie,
  27966. renderer = chart.renderer,
  27967. isHiddenChart = renderer.isHidden(),
  27968. afterRedraw = [];
  27969. // Handle responsive rules, not only on resize (#6130)
  27970. if (chart.setResponsive) {
  27971. chart.setResponsive(false);
  27972. }
  27973. // Set the global animation. When chart.hasRendered is not true, the
  27974. // redraw call comes from a responsive rule and animation should not
  27975. // occur.
  27976. setAnimation(chart.hasRendered ? animation : false, chart);
  27977. if (isHiddenChart) {
  27978. chart.temporaryDisplay();
  27979. }
  27980. // Adjust title layout (reflow multiline text)
  27981. chart.layOutTitles();
  27982. // link stacked series
  27983. i = series.length;
  27984. while (i--) {
  27985. serie = series[i];
  27986. if (serie.options.stacking) {
  27987. hasStackedSeries = true;
  27988. if (serie.isDirty) {
  27989. hasDirtyStacks = true;
  27990. break;
  27991. }
  27992. }
  27993. }
  27994. if (hasDirtyStacks) { // mark others as dirty
  27995. i = series.length;
  27996. while (i--) {
  27997. serie = series[i];
  27998. if (serie.options.stacking) {
  27999. serie.isDirty = true;
  28000. }
  28001. }
  28002. }
  28003. // Handle updated data in the series
  28004. series.forEach(function (serie) {
  28005. if (serie.isDirty) {
  28006. if (serie.options.legendType === 'point') {
  28007. if (typeof serie.updateTotals === 'function') {
  28008. serie.updateTotals();
  28009. }
  28010. redrawLegend = true;
  28011. }
  28012. else if (legendUserOptions &&
  28013. (legendUserOptions.labelFormatter ||
  28014. legendUserOptions.labelFormat)) {
  28015. redrawLegend = true; // #2165
  28016. }
  28017. }
  28018. if (serie.isDirtyData) {
  28019. fireEvent(serie, 'updatedData');
  28020. }
  28021. });
  28022. // handle added or removed series
  28023. if (redrawLegend && legend && legend.options.enabled) {
  28024. // draw legend graphics
  28025. legend.render();
  28026. chart.isDirtyLegend = false;
  28027. }
  28028. // reset stacks
  28029. if (hasStackedSeries) {
  28030. chart.getStacks();
  28031. }
  28032. if (hasCartesianSeries) {
  28033. // set axes scales
  28034. axes.forEach(function (axis) {
  28035. // Don't do setScale again if we're only resizing. Regression
  28036. // #13507. But we need it after chart.update (responsive), as
  28037. // axis is initialized again (#12137).
  28038. if (!chart.isResizing || !isNumber(axis.min)) {
  28039. axis.updateNames();
  28040. axis.setScale();
  28041. }
  28042. });
  28043. }
  28044. chart.getMargins(); // #3098
  28045. if (hasCartesianSeries) {
  28046. // If one axis is dirty, all axes must be redrawn (#792, #2169)
  28047. axes.forEach(function (axis) {
  28048. if (axis.isDirty) {
  28049. isDirtyBox = true;
  28050. }
  28051. });
  28052. // redraw axes
  28053. axes.forEach(function (axis) {
  28054. // Fire 'afterSetExtremes' only if extremes are set
  28055. var key = axis.min + ',' + axis.max;
  28056. if (axis.extKey !== key) { // #821, #4452
  28057. axis.extKey = key;
  28058. // prevent a recursive call to chart.redraw() (#1119)
  28059. afterRedraw.push(function () {
  28060. fireEvent(axis, 'afterSetExtremes', extend(axis.eventArgs, axis.getExtremes())); // #747, #751
  28061. delete axis.eventArgs;
  28062. });
  28063. }
  28064. if (isDirtyBox || hasStackedSeries) {
  28065. axis.redraw();
  28066. }
  28067. });
  28068. }
  28069. // the plot areas size has changed
  28070. if (isDirtyBox) {
  28071. chart.drawChartBox();
  28072. }
  28073. // Fire an event before redrawing series, used by the boost module to
  28074. // clear previous series renderings.
  28075. fireEvent(chart, 'predraw');
  28076. // redraw affected series
  28077. series.forEach(function (serie) {
  28078. if ((isDirtyBox || serie.isDirty) && serie.visible) {
  28079. serie.redraw();
  28080. }
  28081. // Set it here, otherwise we will have unlimited 'updatedData' calls
  28082. // for a hidden series after setData(). Fixes #6012
  28083. serie.isDirtyData = false;
  28084. });
  28085. // move tooltip or reset
  28086. if (pointer) {
  28087. pointer.reset(true);
  28088. }
  28089. // redraw if canvas
  28090. renderer.draw();
  28091. // Fire the events
  28092. fireEvent(chart, 'redraw');
  28093. fireEvent(chart, 'render');
  28094. if (isHiddenChart) {
  28095. chart.temporaryDisplay(true);
  28096. }
  28097. // Fire callbacks that are put on hold until after the redraw
  28098. afterRedraw.forEach(function (callback) {
  28099. callback.call();
  28100. });
  28101. };
  28102. /**
  28103. * Get an axis, series or point object by `id` as given in the configuration
  28104. * options. Returns `undefined` if no item is found.
  28105. *
  28106. * @sample highcharts/plotoptions/series-id/
  28107. * Get series by id
  28108. *
  28109. * @function Highcharts.Chart#get
  28110. *
  28111. * @param {string} id
  28112. * The id as given in the configuration options.
  28113. *
  28114. * @return {Highcharts.Axis|Highcharts.Series|Highcharts.Point|undefined}
  28115. * The retrieved item.
  28116. */
  28117. Chart.prototype.get = function (id) {
  28118. var ret,
  28119. series = this.series,
  28120. i;
  28121. /**
  28122. * @private
  28123. * @param {Highcharts.Axis|Highcharts.Series} item
  28124. * @return {boolean}
  28125. */
  28126. function itemById(item) {
  28127. return (item.id === id ||
  28128. (item.options && item.options.id === id));
  28129. }
  28130. ret =
  28131. // Search axes
  28132. find(this.axes, itemById) ||
  28133. // Search series
  28134. find(this.series, itemById);
  28135. // Search points
  28136. for (i = 0; !ret && i < series.length; i++) {
  28137. ret = find(series[i].points || [], itemById);
  28138. }
  28139. return ret;
  28140. };
  28141. /**
  28142. * Create the Axis instances based on the config options.
  28143. *
  28144. * @private
  28145. * @function Highcharts.Chart#getAxes
  28146. * @fires Highcharts.Chart#event:afterGetAxes
  28147. * @fires Highcharts.Chart#event:getAxes
  28148. */
  28149. Chart.prototype.getAxes = function () {
  28150. var chart = this,
  28151. options = this.options,
  28152. xAxisOptions = options.xAxis = splat(options.xAxis || {}),
  28153. yAxisOptions = options.yAxis = splat(options.yAxis || {}),
  28154. optionsArray;
  28155. fireEvent(this, 'getAxes');
  28156. // make sure the options are arrays and add some members
  28157. xAxisOptions.forEach(function (axis, i) {
  28158. axis.index = i;
  28159. axis.isX = true;
  28160. });
  28161. yAxisOptions.forEach(function (axis, i) {
  28162. axis.index = i;
  28163. });
  28164. // concatenate all axis options into one array
  28165. optionsArray = xAxisOptions.concat(yAxisOptions);
  28166. optionsArray.forEach(function (axisOptions) {
  28167. new Axis(chart, axisOptions); // eslint-disable-line no-new
  28168. });
  28169. fireEvent(this, 'afterGetAxes');
  28170. };
  28171. /**
  28172. * Returns an array of all currently selected points in the chart. Points
  28173. * can be selected by clicking or programmatically by the
  28174. * {@link Highcharts.Point#select}
  28175. * function.
  28176. *
  28177. * @sample highcharts/plotoptions/series-allowpointselect-line/
  28178. * Get selected points
  28179. *
  28180. * @function Highcharts.Chart#getSelectedPoints
  28181. *
  28182. * @return {Array<Highcharts.Point>}
  28183. * The currently selected points.
  28184. */
  28185. Chart.prototype.getSelectedPoints = function () {
  28186. var points = [];
  28187. this.series.forEach(function (serie) {
  28188. // For one-to-one points inspect series.data in order to retrieve
  28189. // points outside the visible range (#6445). For grouped data,
  28190. // inspect the generated series.points.
  28191. points = points.concat(serie.getPointsCollection().filter(function (point) {
  28192. return pick(point.selectedStaging, point.selected);
  28193. }));
  28194. });
  28195. return points;
  28196. };
  28197. /**
  28198. * Returns an array of all currently selected series in the chart. Series
  28199. * can be selected either programmatically by the
  28200. * {@link Highcharts.Series#select}
  28201. * function or by checking the checkbox next to the legend item if
  28202. * [series.showCheckBox](https://api.highcharts.com/highcharts/plotOptions.series.showCheckbox)
  28203. * is true.
  28204. *
  28205. * @sample highcharts/members/chart-getselectedseries/
  28206. * Get selected series
  28207. *
  28208. * @function Highcharts.Chart#getSelectedSeries
  28209. *
  28210. * @return {Array<Highcharts.Series>}
  28211. * The currently selected series.
  28212. */
  28213. Chart.prototype.getSelectedSeries = function () {
  28214. return this.series.filter(function (serie) {
  28215. return serie.selected;
  28216. });
  28217. };
  28218. /**
  28219. * Set a new title or subtitle for the chart.
  28220. *
  28221. * @sample highcharts/members/chart-settitle/
  28222. * Set title text and styles
  28223. *
  28224. * @function Highcharts.Chart#setTitle
  28225. *
  28226. * @param {Highcharts.TitleOptions} [titleOptions]
  28227. * New title options. The title text itself is set by the
  28228. * `titleOptions.text` property.
  28229. *
  28230. * @param {Highcharts.SubtitleOptions} [subtitleOptions]
  28231. * New subtitle options. The subtitle text itself is set by the
  28232. * `subtitleOptions.text` property.
  28233. *
  28234. * @param {boolean} [redraw]
  28235. * Whether to redraw the chart or wait for a later call to
  28236. * `chart.redraw()`.
  28237. */
  28238. Chart.prototype.setTitle = function (titleOptions, subtitleOptions, redraw) {
  28239. this.applyDescription('title', titleOptions);
  28240. this.applyDescription('subtitle', subtitleOptions);
  28241. // The initial call also adds the caption. On update, chart.update will
  28242. // relay to Chart.setCaption.
  28243. this.applyDescription('caption', void 0);
  28244. this.layOutTitles(redraw);
  28245. };
  28246. /**
  28247. * Apply a title, subtitle or caption for the chart
  28248. *
  28249. * @private
  28250. * @function Highcharts.Chart#applyDescription
  28251. * @param name {string}
  28252. * Either title, subtitle or caption
  28253. * @param {Highcharts.TitleOptions|Highcharts.SubtitleOptions|Highcharts.CaptionOptions|undefined} explicitOptions
  28254. * The options to set, will be merged with default options.
  28255. */
  28256. Chart.prototype.applyDescription = function (name, explicitOptions) {
  28257. var chart = this;
  28258. // Default style
  28259. var style = name === 'title' ? {
  28260. color: '#333333',
  28261. fontSize: this.options.isStock ? '16px' : '18px' // #2944
  28262. } : {
  28263. color: '#666666'
  28264. };
  28265. // Merge default options with explicit options
  28266. var options = this.options[name] = merge(
  28267. // Default styles
  28268. (!this.styledMode && { style: style }),
  28269. this.options[name],
  28270. explicitOptions);
  28271. var elem = this[name];
  28272. if (elem && explicitOptions) {
  28273. this[name] = elem = elem.destroy(); // remove old
  28274. }
  28275. if (options && !elem) {
  28276. elem = this.renderer.text(options.text, 0, 0, options.useHTML)
  28277. .attr({
  28278. align: options.align,
  28279. 'class': 'highcharts-' + name,
  28280. zIndex: options.zIndex || 4
  28281. })
  28282. .add();
  28283. // Update methods, shortcut to Chart.setTitle, Chart.setSubtitle and
  28284. // Chart.setCaption
  28285. elem.update = function (updateOptions) {
  28286. var fn = {
  28287. title: 'setTitle',
  28288. subtitle: 'setSubtitle',
  28289. caption: 'setCaption'
  28290. }[name];
  28291. chart[fn](updateOptions);
  28292. };
  28293. // Presentational
  28294. if (!this.styledMode) {
  28295. elem.css(options.style);
  28296. }
  28297. /**
  28298. * The chart title. The title has an `update` method that allows
  28299. * modifying the options directly or indirectly via
  28300. * `chart.update`.
  28301. *
  28302. * @sample highcharts/members/title-update/
  28303. * Updating titles
  28304. *
  28305. * @name Highcharts.Chart#title
  28306. * @type {Highcharts.TitleObject}
  28307. */
  28308. /**
  28309. * The chart subtitle. The subtitle has an `update` method that
  28310. * allows modifying the options directly or indirectly via
  28311. * `chart.update`.
  28312. *
  28313. * @name Highcharts.Chart#subtitle
  28314. * @type {Highcharts.SubtitleObject}
  28315. */
  28316. this[name] = elem;
  28317. }
  28318. };
  28319. /**
  28320. * Internal function to lay out the chart title, subtitle and caption, and
  28321. * cache the full offset height for use in `getMargins`. The result is
  28322. * stored in `this.titleOffset`.
  28323. *
  28324. * @private
  28325. * @function Highcharts.Chart#layOutTitles
  28326. *
  28327. * @param {boolean} [redraw=true]
  28328. * @fires Highcharts.Chart#event:afterLayOutTitles
  28329. */
  28330. Chart.prototype.layOutTitles = function (redraw) {
  28331. var titleOffset = [0, 0, 0],
  28332. requiresDirtyBox,
  28333. renderer = this.renderer,
  28334. spacingBox = this.spacingBox;
  28335. // Lay out the title and the subtitle respectively
  28336. ['title', 'subtitle', 'caption'].forEach(function (key) {
  28337. var title = this[key], titleOptions = this.options[key], verticalAlign = titleOptions.verticalAlign || 'top', offset = key === 'title' ? -3 :
  28338. // Floating subtitle (#6574)
  28339. verticalAlign === 'top' ? titleOffset[0] + 2 : 0, titleSize, height;
  28340. if (title) {
  28341. if (!this.styledMode) {
  28342. titleSize = titleOptions.style.fontSize;
  28343. }
  28344. titleSize = renderer.fontMetrics(titleSize, title).b;
  28345. title
  28346. .css({
  28347. width: (titleOptions.width ||
  28348. spacingBox.width + (titleOptions.widthAdjust || 0)) + 'px'
  28349. });
  28350. // Skip the cache for HTML (#3481, #11666)
  28351. height = Math.round(title.getBBox(titleOptions.useHTML).height);
  28352. title.align(extend({
  28353. y: verticalAlign === 'bottom' ?
  28354. titleSize :
  28355. offset + titleSize,
  28356. height: height
  28357. }, titleOptions), false, 'spacingBox');
  28358. if (!titleOptions.floating) {
  28359. if (verticalAlign === 'top') {
  28360. titleOffset[0] = Math.ceil(titleOffset[0] +
  28361. height);
  28362. }
  28363. else if (verticalAlign === 'bottom') {
  28364. titleOffset[2] = Math.ceil(titleOffset[2] +
  28365. height);
  28366. }
  28367. }
  28368. }
  28369. }, this);
  28370. // Handle title.margin and caption.margin
  28371. if (titleOffset[0] &&
  28372. (this.options.title.verticalAlign || 'top') === 'top') {
  28373. titleOffset[0] += this.options.title.margin;
  28374. }
  28375. if (titleOffset[2] &&
  28376. this.options.caption.verticalAlign === 'bottom') {
  28377. titleOffset[2] += this.options.caption.margin;
  28378. }
  28379. requiresDirtyBox = (!this.titleOffset ||
  28380. this.titleOffset.join(',') !== titleOffset.join(','));
  28381. // Used in getMargins
  28382. this.titleOffset = titleOffset;
  28383. fireEvent(this, 'afterLayOutTitles');
  28384. if (!this.isDirtyBox && requiresDirtyBox) {
  28385. this.isDirtyBox = this.isDirtyLegend = requiresDirtyBox;
  28386. // Redraw if necessary (#2719, #2744)
  28387. if (this.hasRendered && pick(redraw, true) && this.isDirtyBox) {
  28388. this.redraw();
  28389. }
  28390. }
  28391. };
  28392. /**
  28393. * Internal function to get the chart width and height according to options
  28394. * and container size. Sets {@link Chart.chartWidth} and
  28395. * {@link Chart.chartHeight}.
  28396. *
  28397. * @private
  28398. * @function Highcharts.Chart#getChartSize
  28399. */
  28400. Chart.prototype.getChartSize = function () {
  28401. var chart = this,
  28402. optionsChart = chart.options.chart,
  28403. widthOption = optionsChart.width,
  28404. heightOption = optionsChart.height,
  28405. renderTo = chart.renderTo;
  28406. // Get inner width and height
  28407. if (!defined(widthOption)) {
  28408. chart.containerWidth = getStyle(renderTo, 'width');
  28409. }
  28410. if (!defined(heightOption)) {
  28411. chart.containerHeight = getStyle(renderTo, 'height');
  28412. }
  28413. /**
  28414. * The current pixel width of the chart.
  28415. *
  28416. * @name Highcharts.Chart#chartWidth
  28417. * @type {number}
  28418. */
  28419. chart.chartWidth = Math.max(// #1393
  28420. 0, widthOption || chart.containerWidth || 600 // #1460
  28421. );
  28422. /**
  28423. * The current pixel height of the chart.
  28424. *
  28425. * @name Highcharts.Chart#chartHeight
  28426. * @type {number}
  28427. */
  28428. chart.chartHeight = Math.max(0, relativeLength(heightOption, chart.chartWidth) ||
  28429. (chart.containerHeight > 1 ?
  28430. chart.containerHeight :
  28431. 400));
  28432. };
  28433. /**
  28434. * If the renderTo element has no offsetWidth, most likely one or more of
  28435. * its parents are hidden. Loop up the DOM tree to temporarily display the
  28436. * parents, then save the original display properties, and when the true
  28437. * size is retrieved, reset them. Used on first render and on redraws.
  28438. *
  28439. * @private
  28440. * @function Highcharts.Chart#temporaryDisplay
  28441. *
  28442. * @param {boolean} [revert]
  28443. * Revert to the saved original styles.
  28444. */
  28445. Chart.prototype.temporaryDisplay = function (revert) {
  28446. var node = this.renderTo,
  28447. tempStyle;
  28448. if (!revert) {
  28449. while (node && node.style) {
  28450. // When rendering to a detached node, it needs to be temporarily
  28451. // attached in order to read styling and bounding boxes (#5783,
  28452. // #7024).
  28453. if (!doc.body.contains(node) && !node.parentNode) {
  28454. node.hcOrigDetached = true;
  28455. doc.body.appendChild(node);
  28456. }
  28457. if (getStyle(node, 'display', false) === 'none' ||
  28458. node.hcOricDetached) {
  28459. node.hcOrigStyle = {
  28460. display: node.style.display,
  28461. height: node.style.height,
  28462. overflow: node.style.overflow
  28463. };
  28464. tempStyle = {
  28465. display: 'block',
  28466. overflow: 'hidden'
  28467. };
  28468. if (node !== this.renderTo) {
  28469. tempStyle.height = 0;
  28470. }
  28471. css(node, tempStyle);
  28472. // If it still doesn't have an offset width after setting
  28473. // display to block, it probably has an !important priority
  28474. // #2631, 6803
  28475. if (!node.offsetWidth) {
  28476. node.style.setProperty('display', 'block', 'important');
  28477. }
  28478. }
  28479. node = node.parentNode;
  28480. if (node === doc.body) {
  28481. break;
  28482. }
  28483. }
  28484. }
  28485. else {
  28486. while (node && node.style) {
  28487. if (node.hcOrigStyle) {
  28488. css(node, node.hcOrigStyle);
  28489. delete node.hcOrigStyle;
  28490. }
  28491. if (node.hcOrigDetached) {
  28492. doc.body.removeChild(node);
  28493. node.hcOrigDetached = false;
  28494. }
  28495. node = node.parentNode;
  28496. }
  28497. }
  28498. };
  28499. /**
  28500. * Set the {@link Chart.container|chart container's} class name, in
  28501. * addition to `highcharts-container`.
  28502. *
  28503. * @function Highcharts.Chart#setClassName
  28504. *
  28505. * @param {string} [className]
  28506. * The additional class name.
  28507. */
  28508. Chart.prototype.setClassName = function (className) {
  28509. this.container.className = 'highcharts-container ' + (className || '');
  28510. };
  28511. /**
  28512. * Get the containing element, determine the size and create the inner
  28513. * container div to hold the chart.
  28514. *
  28515. * @private
  28516. * @function Highcharts.Chart#afterGetContainer
  28517. * @fires Highcharts.Chart#event:afterGetContainer
  28518. */
  28519. Chart.prototype.getContainer = function () {
  28520. var chart = this,
  28521. container,
  28522. options = chart.options,
  28523. optionsChart = options.chart,
  28524. chartWidth,
  28525. chartHeight,
  28526. renderTo = chart.renderTo,
  28527. indexAttrName = 'data-highcharts-chart',
  28528. oldChartIndex,
  28529. Ren,
  28530. containerId = uniqueKey(),
  28531. containerStyle,
  28532. key;
  28533. if (!renderTo) {
  28534. chart.renderTo = renderTo =
  28535. optionsChart.renderTo;
  28536. }
  28537. if (isString(renderTo)) {
  28538. chart.renderTo = renderTo =
  28539. doc.getElementById(renderTo);
  28540. }
  28541. // Display an error if the renderTo is wrong
  28542. if (!renderTo) {
  28543. error(13, true, chart);
  28544. }
  28545. // If the container already holds a chart, destroy it. The check for
  28546. // hasRendered is there because web pages that are saved to disk from
  28547. // the browser, will preserve the data-highcharts-chart attribute and
  28548. // the SVG contents, but not an interactive chart. So in this case,
  28549. // charts[oldChartIndex] will point to the wrong chart if any (#2609).
  28550. oldChartIndex = pInt(attr(renderTo, indexAttrName));
  28551. if (isNumber(oldChartIndex) &&
  28552. charts[oldChartIndex] &&
  28553. charts[oldChartIndex].hasRendered) {
  28554. charts[oldChartIndex].destroy();
  28555. }
  28556. // Make a reference to the chart from the div
  28557. attr(renderTo, indexAttrName, chart.index);
  28558. // remove previous chart
  28559. renderTo.innerHTML = '';
  28560. // If the container doesn't have an offsetWidth, it has or is a child of
  28561. // a node that has display:none. We need to temporarily move it out to a
  28562. // visible state to determine the size, else the legend and tooltips
  28563. // won't render properly. The skipClone option is used in sparklines as
  28564. // a micro optimization, saving about 1-2 ms each chart.
  28565. if (!optionsChart.skipClone && !renderTo.offsetWidth) {
  28566. chart.temporaryDisplay();
  28567. }
  28568. // get the width and height
  28569. chart.getChartSize();
  28570. chartWidth = chart.chartWidth;
  28571. chartHeight = chart.chartHeight;
  28572. // Allow table cells and flex-boxes to shrink without the chart blocking
  28573. // them out (#6427)
  28574. css(renderTo, { overflow: 'hidden' });
  28575. // Create the inner container
  28576. if (!chart.styledMode) {
  28577. containerStyle = extend({
  28578. position: 'relative',
  28579. // needed for context menu (avoidscrollbars) and content
  28580. // overflow in IE
  28581. overflow: 'hidden',
  28582. width: chartWidth + 'px',
  28583. height: chartHeight + 'px',
  28584. textAlign: 'left',
  28585. lineHeight: 'normal',
  28586. zIndex: 0,
  28587. '-webkit-tap-highlight-color': 'rgba(0,0,0,0)',
  28588. userSelect: 'none' // #13503
  28589. }, optionsChart.style);
  28590. }
  28591. /**
  28592. * The containing HTML element of the chart. The container is
  28593. * dynamically inserted into the element given as the `renderTo`
  28594. * parameter in the {@link Highcharts#chart} constructor.
  28595. *
  28596. * @name Highcharts.Chart#container
  28597. * @type {Highcharts.HTMLDOMElement}
  28598. */
  28599. container = createElement('div', {
  28600. id: containerId
  28601. }, containerStyle, renderTo);
  28602. chart.container = container;
  28603. // cache the cursor (#1650)
  28604. chart._cursor = container.style.cursor;
  28605. // Initialize the renderer
  28606. Ren = H[optionsChart.renderer] || H.Renderer;
  28607. /**
  28608. * The renderer instance of the chart. Each chart instance has only one
  28609. * associated renderer.
  28610. *
  28611. * @name Highcharts.Chart#renderer
  28612. * @type {Highcharts.SVGRenderer}
  28613. */
  28614. chart.renderer = new Ren(container, chartWidth, chartHeight, null, optionsChart.forExport, options.exporting && options.exporting.allowHTML, chart.styledMode);
  28615. // Set the initial animation from the options
  28616. setAnimation(void 0, chart);
  28617. chart.setClassName(optionsChart.className);
  28618. if (!chart.styledMode) {
  28619. chart.renderer.setStyle(optionsChart.style);
  28620. }
  28621. else {
  28622. // Initialize definitions
  28623. for (key in options.defs) { // eslint-disable-line guard-for-in
  28624. this.renderer.definition(options.defs[key]);
  28625. }
  28626. }
  28627. // Add a reference to the charts index
  28628. chart.renderer.chartIndex = chart.index;
  28629. fireEvent(this, 'afterGetContainer');
  28630. };
  28631. /**
  28632. * Calculate margins by rendering axis labels in a preliminary position.
  28633. * Title, subtitle and legend have already been rendered at this stage, but
  28634. * will be moved into their final positions.
  28635. *
  28636. * @private
  28637. * @function Highcharts.Chart#getMargins
  28638. * @fires Highcharts.Chart#event:getMargins
  28639. */
  28640. Chart.prototype.getMargins = function (skipAxes) {
  28641. var _a = this,
  28642. spacing = _a.spacing,
  28643. margin = _a.margin,
  28644. titleOffset = _a.titleOffset;
  28645. this.resetMargins();
  28646. // Adjust for title and subtitle
  28647. if (titleOffset[0] && !defined(margin[0])) {
  28648. this.plotTop = Math.max(this.plotTop, titleOffset[0] + spacing[0]);
  28649. }
  28650. if (titleOffset[2] && !defined(margin[2])) {
  28651. this.marginBottom = Math.max(this.marginBottom, titleOffset[2] + spacing[2]);
  28652. }
  28653. // Adjust for legend
  28654. if (this.legend && this.legend.display) {
  28655. this.legend.adjustMargins(margin, spacing);
  28656. }
  28657. fireEvent(this, 'getMargins');
  28658. if (!skipAxes) {
  28659. this.getAxisMargins();
  28660. }
  28661. };
  28662. /**
  28663. * @private
  28664. * @function Highcharts.Chart#getAxisMargins
  28665. */
  28666. Chart.prototype.getAxisMargins = function () {
  28667. var chart = this,
  28668. // [top, right, bottom, left]
  28669. axisOffset = chart.axisOffset = [0, 0, 0, 0],
  28670. colorAxis = chart.colorAxis,
  28671. margin = chart.margin,
  28672. getOffset = function (axes) {
  28673. axes.forEach(function (axis) {
  28674. if (axis.visible) {
  28675. axis.getOffset();
  28676. }
  28677. });
  28678. };
  28679. // pre-render axes to get labels offset width
  28680. if (chart.hasCartesianSeries) {
  28681. getOffset(chart.axes);
  28682. }
  28683. else if (colorAxis && colorAxis.length) {
  28684. getOffset(colorAxis);
  28685. }
  28686. // Add the axis offsets
  28687. marginNames.forEach(function (m, side) {
  28688. if (!defined(margin[side])) {
  28689. chart[m] += axisOffset[side];
  28690. }
  28691. });
  28692. chart.setChartSize();
  28693. };
  28694. /**
  28695. * Reflows the chart to its container. By default, the chart reflows
  28696. * automatically to its container following a `window.resize` event, as per
  28697. * the [chart.reflow](https://api.highcharts.com/highcharts/chart.reflow)
  28698. * option. However, there are no reliable events for div resize, so if the
  28699. * container is resized without a window resize event, this must be called
  28700. * explicitly.
  28701. *
  28702. * @sample highcharts/members/chart-reflow/
  28703. * Resize div and reflow
  28704. * @sample highcharts/chart/events-container/
  28705. * Pop up and reflow
  28706. *
  28707. * @function Highcharts.Chart#reflow
  28708. *
  28709. * @param {global.Event} [e]
  28710. * Event arguments. Used primarily when the function is called
  28711. * internally as a response to window resize.
  28712. */
  28713. Chart.prototype.reflow = function (e) {
  28714. var chart = this, optionsChart = chart.options.chart, renderTo = chart.renderTo, hasUserSize = (defined(optionsChart.width) &&
  28715. defined(optionsChart.height)), width = optionsChart.width || getStyle(renderTo, 'width'), height = optionsChart.height || getStyle(renderTo, 'height'), target = e ? e.target : win;
  28716. // Width and height checks for display:none. Target is doc in IE8 and
  28717. // Opera, win in Firefox, Chrome and IE9.
  28718. if (!hasUserSize &&
  28719. !chart.isPrinting &&
  28720. width &&
  28721. height &&
  28722. (target === win || target === doc)) {
  28723. if (width !== chart.containerWidth ||
  28724. height !== chart.containerHeight) {
  28725. U.clearTimeout(chart.reflowTimeout);
  28726. // When called from window.resize, e is set, else it's called
  28727. // directly (#2224)
  28728. chart.reflowTimeout = syncTimeout(function () {
  28729. // Set size, it may have been destroyed in the meantime
  28730. // (#1257)
  28731. if (chart.container) {
  28732. chart.setSize(void 0, void 0, false);
  28733. }
  28734. }, e ? 100 : 0);
  28735. }
  28736. chart.containerWidth = width;
  28737. chart.containerHeight = height;
  28738. }
  28739. };
  28740. /**
  28741. * Toggle the event handlers necessary for auto resizing, depending on the
  28742. * `chart.reflow` option.
  28743. *
  28744. * @private
  28745. * @function Highcharts.Chart#setReflow
  28746. */
  28747. Chart.prototype.setReflow = function (reflow) {
  28748. var chart = this;
  28749. if (reflow !== false && !this.unbindReflow) {
  28750. this.unbindReflow = addEvent(win, 'resize', function (e) {
  28751. // a removed event listener still runs in Edge and IE if the
  28752. // listener was removed while the event runs, so check if the
  28753. // chart is not destroyed (#11609)
  28754. if (chart.options) {
  28755. chart.reflow(e);
  28756. }
  28757. });
  28758. addEvent(this, 'destroy', this.unbindReflow);
  28759. }
  28760. else if (reflow === false && this.unbindReflow) {
  28761. // Unbind and unset
  28762. this.unbindReflow = this.unbindReflow();
  28763. }
  28764. // The following will add listeners to re-fit the chart before and after
  28765. // printing (#2284). However it only works in WebKit. Should have worked
  28766. // in Firefox, but not supported in IE.
  28767. /*
  28768. if (win.matchMedia) {
  28769. win.matchMedia('print').addListener(function reflow() {
  28770. chart.reflow();
  28771. });
  28772. }
  28773. //*/
  28774. };
  28775. /**
  28776. * Resize the chart to a given width and height. In order to set the width
  28777. * only, the height argument may be skipped. To set the height only, pass
  28778. * `undefined` for the width.
  28779. *
  28780. * @sample highcharts/members/chart-setsize-button/
  28781. * Test resizing from buttons
  28782. * @sample highcharts/members/chart-setsize-jquery-resizable/
  28783. * Add a jQuery UI resizable
  28784. * @sample stock/members/chart-setsize/
  28785. * Highstock with UI resizable
  28786. *
  28787. * @function Highcharts.Chart#setSize
  28788. *
  28789. * @param {number|null} [width]
  28790. * The new pixel width of the chart. Since v4.2.6, the argument can
  28791. * be `undefined` in order to preserve the current value (when
  28792. * setting height only), or `null` to adapt to the width of the
  28793. * containing element.
  28794. *
  28795. * @param {number|null} [height]
  28796. * The new pixel height of the chart. Since v4.2.6, the argument can
  28797. * be `undefined` in order to preserve the current value, or `null`
  28798. * in order to adapt to the height of the containing element.
  28799. *
  28800. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  28801. * Whether and how to apply animation.
  28802. *
  28803. * @return {void}
  28804. *
  28805. * @fires Highcharts.Chart#event:endResize
  28806. * @fires Highcharts.Chart#event:resize
  28807. */
  28808. Chart.prototype.setSize = function (width, height, animation) {
  28809. var chart = this,
  28810. renderer = chart.renderer,
  28811. globalAnimation;
  28812. // Handle the isResizing counter
  28813. chart.isResizing += 1;
  28814. // set the animation for the current process
  28815. setAnimation(animation, chart);
  28816. globalAnimation = renderer.globalAnimation;
  28817. chart.oldChartHeight = chart.chartHeight;
  28818. chart.oldChartWidth = chart.chartWidth;
  28819. if (typeof width !== 'undefined') {
  28820. chart.options.chart.width = width;
  28821. }
  28822. if (typeof height !== 'undefined') {
  28823. chart.options.chart.height = height;
  28824. }
  28825. chart.getChartSize();
  28826. // Resize the container with the global animation applied if enabled
  28827. // (#2503)
  28828. if (!chart.styledMode) {
  28829. (globalAnimation ? animate : css)(chart.container, {
  28830. width: chart.chartWidth + 'px',
  28831. height: chart.chartHeight + 'px'
  28832. }, globalAnimation);
  28833. }
  28834. chart.setChartSize(true);
  28835. renderer.setSize(chart.chartWidth, chart.chartHeight, globalAnimation);
  28836. // handle axes
  28837. chart.axes.forEach(function (axis) {
  28838. axis.isDirty = true;
  28839. axis.setScale();
  28840. });
  28841. chart.isDirtyLegend = true; // force legend redraw
  28842. chart.isDirtyBox = true; // force redraw of plot and chart border
  28843. chart.layOutTitles(); // #2857
  28844. chart.getMargins();
  28845. chart.redraw(globalAnimation);
  28846. chart.oldChartHeight = null;
  28847. fireEvent(chart, 'resize');
  28848. // Fire endResize and set isResizing back. If animation is disabled,
  28849. // fire without delay
  28850. syncTimeout(function () {
  28851. if (chart) {
  28852. fireEvent(chart, 'endResize', null, function () {
  28853. chart.isResizing -= 1;
  28854. });
  28855. }
  28856. }, animObject(globalAnimation).duration);
  28857. };
  28858. /**
  28859. * Set the public chart properties. This is done before and after the
  28860. * pre-render to determine margin sizes.
  28861. *
  28862. * @private
  28863. * @function Highcharts.Chart#setChartSize
  28864. * @fires Highcharts.Chart#event:afterSetChartSize
  28865. */
  28866. Chart.prototype.setChartSize = function (skipAxes) {
  28867. var chart = this,
  28868. inverted = chart.inverted,
  28869. renderer = chart.renderer,
  28870. chartWidth = chart.chartWidth,
  28871. chartHeight = chart.chartHeight,
  28872. optionsChart = chart.options.chart,
  28873. spacing = chart.spacing,
  28874. clipOffset = chart.clipOffset,
  28875. clipX,
  28876. clipY,
  28877. plotLeft,
  28878. plotTop,
  28879. plotWidth,
  28880. plotHeight,
  28881. plotBorderWidth;
  28882. /**
  28883. * The current left position of the plot area in pixels.
  28884. *
  28885. * @name Highcharts.Chart#plotLeft
  28886. * @type {number}
  28887. */
  28888. chart.plotLeft = plotLeft = Math.round(chart.plotLeft);
  28889. /**
  28890. * The current top position of the plot area in pixels.
  28891. *
  28892. * @name Highcharts.Chart#plotTop
  28893. * @type {number}
  28894. */
  28895. chart.plotTop = plotTop = Math.round(chart.plotTop);
  28896. /**
  28897. * The current width of the plot area in pixels.
  28898. *
  28899. * @name Highcharts.Chart#plotWidth
  28900. * @type {number}
  28901. */
  28902. chart.plotWidth = plotWidth = Math.max(0, Math.round(chartWidth - plotLeft - chart.marginRight));
  28903. /**
  28904. * The current height of the plot area in pixels.
  28905. *
  28906. * @name Highcharts.Chart#plotHeight
  28907. * @type {number}
  28908. */
  28909. chart.plotHeight = plotHeight = Math.max(0, Math.round(chartHeight - plotTop - chart.marginBottom));
  28910. chart.plotSizeX = inverted ? plotHeight : plotWidth;
  28911. chart.plotSizeY = inverted ? plotWidth : plotHeight;
  28912. chart.plotBorderWidth = optionsChart.plotBorderWidth || 0;
  28913. // Set boxes used for alignment
  28914. chart.spacingBox = renderer.spacingBox = {
  28915. x: spacing[3],
  28916. y: spacing[0],
  28917. width: chartWidth - spacing[3] - spacing[1],
  28918. height: chartHeight - spacing[0] - spacing[2]
  28919. };
  28920. chart.plotBox = renderer.plotBox = {
  28921. x: plotLeft,
  28922. y: plotTop,
  28923. width: plotWidth,
  28924. height: plotHeight
  28925. };
  28926. plotBorderWidth = 2 * Math.floor(chart.plotBorderWidth / 2);
  28927. clipX = Math.ceil(Math.max(plotBorderWidth, clipOffset[3]) / 2);
  28928. clipY = Math.ceil(Math.max(plotBorderWidth, clipOffset[0]) / 2);
  28929. chart.clipBox = {
  28930. x: clipX,
  28931. y: clipY,
  28932. width: Math.floor(chart.plotSizeX -
  28933. Math.max(plotBorderWidth, clipOffset[1]) / 2 -
  28934. clipX),
  28935. height: Math.max(0, Math.floor(chart.plotSizeY -
  28936. Math.max(plotBorderWidth, clipOffset[2]) / 2 -
  28937. clipY))
  28938. };
  28939. if (!skipAxes) {
  28940. chart.axes.forEach(function (axis) {
  28941. axis.setAxisSize();
  28942. axis.setAxisTranslation();
  28943. });
  28944. }
  28945. fireEvent(chart, 'afterSetChartSize', { skipAxes: skipAxes });
  28946. };
  28947. /**
  28948. * Initial margins before auto size margins are applied.
  28949. *
  28950. * @private
  28951. * @function Highcharts.Chart#resetMargins
  28952. */
  28953. Chart.prototype.resetMargins = function () {
  28954. fireEvent(this, 'resetMargins');
  28955. var chart = this,
  28956. chartOptions = chart.options.chart;
  28957. // Create margin and spacing array
  28958. ['margin', 'spacing'].forEach(function splashArrays(target) {
  28959. var value = chartOptions[target],
  28960. values = isObject(value) ? value : [value,
  28961. value,
  28962. value,
  28963. value];
  28964. [
  28965. 'Top',
  28966. 'Right',
  28967. 'Bottom',
  28968. 'Left'
  28969. ].forEach(function (sideName, side) {
  28970. chart[target][side] = pick(chartOptions[target + sideName], values[side]);
  28971. });
  28972. });
  28973. // Set margin names like chart.plotTop, chart.plotLeft,
  28974. // chart.marginRight, chart.marginBottom.
  28975. marginNames.forEach(function (m, side) {
  28976. chart[m] = pick(chart.margin[side], chart.spacing[side]);
  28977. });
  28978. chart.axisOffset = [0, 0, 0, 0]; // top, right, bottom, left
  28979. chart.clipOffset = [0, 0, 0, 0];
  28980. };
  28981. /**
  28982. * Internal function to draw or redraw the borders and backgrounds for chart
  28983. * and plot area.
  28984. *
  28985. * @private
  28986. * @function Highcharts.Chart#drawChartBox
  28987. * @fires Highcharts.Chart#event:afterDrawChartBox
  28988. */
  28989. Chart.prototype.drawChartBox = function () {
  28990. var chart = this,
  28991. optionsChart = chart.options.chart,
  28992. renderer = chart.renderer,
  28993. chartWidth = chart.chartWidth,
  28994. chartHeight = chart.chartHeight,
  28995. chartBackground = chart.chartBackground,
  28996. plotBackground = chart.plotBackground,
  28997. plotBorder = chart.plotBorder,
  28998. chartBorderWidth,
  28999. styledMode = chart.styledMode,
  29000. plotBGImage = chart.plotBGImage,
  29001. chartBackgroundColor = optionsChart.backgroundColor,
  29002. plotBackgroundColor = optionsChart.plotBackgroundColor,
  29003. plotBackgroundImage = optionsChart.plotBackgroundImage,
  29004. mgn,
  29005. bgAttr,
  29006. plotLeft = chart.plotLeft,
  29007. plotTop = chart.plotTop,
  29008. plotWidth = chart.plotWidth,
  29009. plotHeight = chart.plotHeight,
  29010. plotBox = chart.plotBox,
  29011. clipRect = chart.clipRect,
  29012. clipBox = chart.clipBox,
  29013. verb = 'animate';
  29014. // Chart area
  29015. if (!chartBackground) {
  29016. chart.chartBackground = chartBackground = renderer.rect()
  29017. .addClass('highcharts-background')
  29018. .add();
  29019. verb = 'attr';
  29020. }
  29021. if (!styledMode) {
  29022. // Presentational
  29023. chartBorderWidth = optionsChart.borderWidth || 0;
  29024. mgn = chartBorderWidth + (optionsChart.shadow ? 8 : 0);
  29025. bgAttr = {
  29026. fill: chartBackgroundColor || 'none'
  29027. };
  29028. if (chartBorderWidth || chartBackground['stroke-width']) { // #980
  29029. bgAttr.stroke = optionsChart.borderColor;
  29030. bgAttr['stroke-width'] = chartBorderWidth;
  29031. }
  29032. chartBackground
  29033. .attr(bgAttr)
  29034. .shadow(optionsChart.shadow);
  29035. }
  29036. else {
  29037. chartBorderWidth = mgn = chartBackground.strokeWidth();
  29038. }
  29039. chartBackground[verb]({
  29040. x: mgn / 2,
  29041. y: mgn / 2,
  29042. width: chartWidth - mgn - chartBorderWidth % 2,
  29043. height: chartHeight - mgn - chartBorderWidth % 2,
  29044. r: optionsChart.borderRadius
  29045. });
  29046. // Plot background
  29047. verb = 'animate';
  29048. if (!plotBackground) {
  29049. verb = 'attr';
  29050. chart.plotBackground = plotBackground = renderer.rect()
  29051. .addClass('highcharts-plot-background')
  29052. .add();
  29053. }
  29054. plotBackground[verb](plotBox);
  29055. if (!styledMode) {
  29056. // Presentational attributes for the background
  29057. plotBackground
  29058. .attr({
  29059. fill: plotBackgroundColor || 'none'
  29060. })
  29061. .shadow(optionsChart.plotShadow);
  29062. // Create the background image
  29063. if (plotBackgroundImage) {
  29064. if (!plotBGImage) {
  29065. chart.plotBGImage = renderer.image(plotBackgroundImage, plotLeft, plotTop, plotWidth, plotHeight).add();
  29066. }
  29067. else {
  29068. if (plotBackgroundImage !== plotBGImage.attr('href')) {
  29069. plotBGImage.attr('href', plotBackgroundImage);
  29070. }
  29071. plotBGImage.animate(plotBox);
  29072. }
  29073. }
  29074. }
  29075. // Plot clip
  29076. if (!clipRect) {
  29077. chart.clipRect = renderer.clipRect(clipBox);
  29078. }
  29079. else {
  29080. clipRect.animate({
  29081. width: clipBox.width,
  29082. height: clipBox.height
  29083. });
  29084. }
  29085. // Plot area border
  29086. verb = 'animate';
  29087. if (!plotBorder) {
  29088. verb = 'attr';
  29089. chart.plotBorder = plotBorder = renderer.rect()
  29090. .addClass('highcharts-plot-border')
  29091. .attr({
  29092. zIndex: 1 // Above the grid
  29093. })
  29094. .add();
  29095. }
  29096. if (!styledMode) {
  29097. // Presentational
  29098. plotBorder.attr({
  29099. stroke: optionsChart.plotBorderColor,
  29100. 'stroke-width': optionsChart.plotBorderWidth || 0,
  29101. fill: 'none'
  29102. });
  29103. }
  29104. plotBorder[verb](plotBorder.crisp({
  29105. x: plotLeft,
  29106. y: plotTop,
  29107. width: plotWidth,
  29108. height: plotHeight
  29109. }, -plotBorder.strokeWidth())); // #3282 plotBorder should be negative;
  29110. // reset
  29111. chart.isDirtyBox = false;
  29112. fireEvent(this, 'afterDrawChartBox');
  29113. };
  29114. /**
  29115. * Detect whether a certain chart property is needed based on inspecting its
  29116. * options and series. This mainly applies to the chart.inverted property,
  29117. * and in extensions to the chart.angular and chart.polar properties.
  29118. *
  29119. * @private
  29120. * @function Highcharts.Chart#propFromSeries
  29121. * @return {void}
  29122. */
  29123. Chart.prototype.propFromSeries = function () {
  29124. var chart = this,
  29125. optionsChart = chart.options.chart,
  29126. klass,
  29127. seriesOptions = chart.options.series,
  29128. i,
  29129. value;
  29130. /**
  29131. * The flag is set to `true` if a series of the chart is inverted.
  29132. *
  29133. * @name Highcharts.Chart#inverted
  29134. * @type {boolean|undefined}
  29135. */
  29136. ['inverted', 'angular', 'polar'].forEach(function (key) {
  29137. // The default series type's class
  29138. klass = BaseSeries.seriesTypes[(optionsChart.type ||
  29139. optionsChart.defaultSeriesType)];
  29140. // Get the value from available chart-wide properties
  29141. value =
  29142. // It is set in the options:
  29143. optionsChart[key] ||
  29144. // The default series class:
  29145. (klass && klass.prototype[key]);
  29146. // requires it
  29147. // 4. Check if any the chart's series require it
  29148. i = seriesOptions && seriesOptions.length;
  29149. while (!value && i--) {
  29150. klass = BaseSeries.seriesTypes[seriesOptions[i].type];
  29151. if (klass && klass.prototype[key]) {
  29152. value = true;
  29153. }
  29154. }
  29155. // Set the chart property
  29156. chart[key] = value;
  29157. });
  29158. };
  29159. /**
  29160. * Internal function to link two or more series together, based on the
  29161. * `linkedTo` option. This is done from `Chart.render`, and after
  29162. * `Chart.addSeries` and `Series.remove`.
  29163. *
  29164. * @private
  29165. * @function Highcharts.Chart#linkSeries
  29166. * @fires Highcharts.Chart#event:afterLinkSeries
  29167. */
  29168. Chart.prototype.linkSeries = function () {
  29169. var chart = this,
  29170. chartSeries = chart.series;
  29171. // Reset links
  29172. chartSeries.forEach(function (series) {
  29173. series.linkedSeries.length = 0;
  29174. });
  29175. // Apply new links
  29176. chartSeries.forEach(function (series) {
  29177. var linkedTo = series.options.linkedTo;
  29178. if (isString(linkedTo)) {
  29179. if (linkedTo === ':previous') {
  29180. linkedTo = chart.series[series.index - 1];
  29181. }
  29182. else {
  29183. linkedTo = chart.get(linkedTo);
  29184. }
  29185. // #3341 avoid mutual linking
  29186. if (linkedTo && linkedTo.linkedParent !== series) {
  29187. linkedTo.linkedSeries.push(series);
  29188. series.linkedParent = linkedTo;
  29189. if (linkedTo.enabledDataSorting) {
  29190. series.setDataSortingOptions();
  29191. }
  29192. series.visible = pick(series.options.visible, linkedTo.options.visible, series.visible); // #3879
  29193. }
  29194. }
  29195. });
  29196. fireEvent(this, 'afterLinkSeries');
  29197. };
  29198. /**
  29199. * Render series for the chart.
  29200. *
  29201. * @private
  29202. * @function Highcharts.Chart#renderSeries
  29203. */
  29204. Chart.prototype.renderSeries = function () {
  29205. this.series.forEach(function (serie) {
  29206. serie.translate();
  29207. serie.render();
  29208. });
  29209. };
  29210. /**
  29211. * Render labels for the chart.
  29212. *
  29213. * @private
  29214. * @function Highcharts.Chart#renderLabels
  29215. */
  29216. Chart.prototype.renderLabels = function () {
  29217. var chart = this,
  29218. labels = chart.options.labels;
  29219. if (labels.items) {
  29220. labels.items.forEach(function (label) {
  29221. var style = extend(labels.style,
  29222. label.style),
  29223. x = pInt(style.left) + chart.plotLeft,
  29224. y = pInt(style.top) + chart.plotTop + 12;
  29225. // delete to prevent rewriting in IE
  29226. delete style.left;
  29227. delete style.top;
  29228. chart.renderer.text(label.html, x, y)
  29229. .attr({ zIndex: 2 })
  29230. .css(style)
  29231. .add();
  29232. });
  29233. }
  29234. };
  29235. /**
  29236. * Render all graphics for the chart. Runs internally on initialization.
  29237. *
  29238. * @private
  29239. * @function Highcharts.Chart#render
  29240. */
  29241. Chart.prototype.render = function () {
  29242. var chart = this,
  29243. axes = chart.axes,
  29244. colorAxis = chart.colorAxis,
  29245. renderer = chart.renderer,
  29246. options = chart.options,
  29247. correction = 0, // correction for X axis labels
  29248. tempWidth,
  29249. tempHeight,
  29250. redoHorizontal,
  29251. redoVertical,
  29252. renderAxes = function (axes) {
  29253. axes.forEach(function (axis) {
  29254. if (axis.visible) {
  29255. axis.render();
  29256. }
  29257. });
  29258. };
  29259. // Title
  29260. chart.setTitle();
  29261. /**
  29262. * The overview of the chart's series.
  29263. *
  29264. * @name Highcharts.Chart#legend
  29265. * @type {Highcharts.Legend}
  29266. */
  29267. chart.legend = new Legend(chart, options.legend);
  29268. // Get stacks
  29269. if (chart.getStacks) {
  29270. chart.getStacks();
  29271. }
  29272. // Get chart margins
  29273. chart.getMargins(true);
  29274. chart.setChartSize();
  29275. // Record preliminary dimensions for later comparison
  29276. tempWidth = chart.plotWidth;
  29277. axes.some(function (axis) {
  29278. if (axis.horiz &&
  29279. axis.visible &&
  29280. axis.options.labels.enabled &&
  29281. axis.series.length) {
  29282. // 21 is the most common correction for X axis labels
  29283. correction = 21;
  29284. return true;
  29285. }
  29286. });
  29287. // use Math.max to prevent negative plotHeight
  29288. chart.plotHeight = Math.max(chart.plotHeight - correction, 0);
  29289. tempHeight = chart.plotHeight;
  29290. // Get margins by pre-rendering axes
  29291. axes.forEach(function (axis) {
  29292. axis.setScale();
  29293. });
  29294. chart.getAxisMargins();
  29295. // If the plot area size has changed significantly, calculate tick
  29296. // positions again
  29297. redoHorizontal = tempWidth / chart.plotWidth > 1.1;
  29298. // Height is more sensitive, use lower threshold
  29299. redoVertical = tempHeight / chart.plotHeight > 1.05;
  29300. if (redoHorizontal || redoVertical) {
  29301. axes.forEach(function (axis) {
  29302. if ((axis.horiz && redoHorizontal) ||
  29303. (!axis.horiz && redoVertical)) {
  29304. // update to reflect the new margins
  29305. axis.setTickInterval(true);
  29306. }
  29307. });
  29308. chart.getMargins(); // second pass to check for new labels
  29309. }
  29310. // Draw the borders and backgrounds
  29311. chart.drawChartBox();
  29312. // Axes
  29313. if (chart.hasCartesianSeries) {
  29314. renderAxes(axes);
  29315. }
  29316. else if (colorAxis && colorAxis.length) {
  29317. renderAxes(colorAxis);
  29318. }
  29319. // The series
  29320. if (!chart.seriesGroup) {
  29321. chart.seriesGroup = renderer.g('series-group')
  29322. .attr({ zIndex: 3 })
  29323. .add();
  29324. }
  29325. chart.renderSeries();
  29326. // Labels
  29327. chart.renderLabels();
  29328. // Credits
  29329. chart.addCredits();
  29330. // Handle responsiveness
  29331. if (chart.setResponsive) {
  29332. chart.setResponsive();
  29333. }
  29334. // Handle scaling
  29335. chart.updateContainerScaling();
  29336. // Set flag
  29337. chart.hasRendered = true;
  29338. };
  29339. /**
  29340. * Set a new credits label for the chart.
  29341. *
  29342. * @sample highcharts/credits/credits-update/
  29343. * Add and update credits
  29344. *
  29345. * @function Highcharts.Chart#addCredits
  29346. *
  29347. * @param {Highcharts.CreditsOptions} [credits]
  29348. * A configuration object for the new credits.
  29349. */
  29350. Chart.prototype.addCredits = function (credits) {
  29351. var chart = this,
  29352. creds = merge(true,
  29353. this.options.credits,
  29354. credits);
  29355. if (creds.enabled && !this.credits) {
  29356. /**
  29357. * The chart's credits label. The label has an `update` method that
  29358. * allows setting new options as per the
  29359. * [credits options set](https://api.highcharts.com/highcharts/credits).
  29360. *
  29361. * @name Highcharts.Chart#credits
  29362. * @type {Highcharts.SVGElement}
  29363. */
  29364. this.credits = this.renderer.text(creds.text + (this.mapCredits || ''), 0, 0)
  29365. .addClass('highcharts-credits')
  29366. .on('click', function () {
  29367. if (creds.href) {
  29368. win.location.href = creds.href;
  29369. }
  29370. })
  29371. .attr({
  29372. align: creds.position.align,
  29373. zIndex: 8
  29374. });
  29375. if (!chart.styledMode) {
  29376. this.credits.css(creds.style);
  29377. }
  29378. this.credits
  29379. .add()
  29380. .align(creds.position);
  29381. // Dynamically update
  29382. this.credits.update = function (options) {
  29383. chart.credits = chart.credits.destroy();
  29384. chart.addCredits(options);
  29385. };
  29386. }
  29387. };
  29388. /**
  29389. * Handle scaling, #11329 - when there is scaling/transform on the container
  29390. * or on a parent element, we need to take this into account. We calculate
  29391. * the scaling once here and it is picked up where we need to use it
  29392. * (Pointer, Tooltip).
  29393. *
  29394. * @private
  29395. * @function Highcharts.Chart#updateContainerScaling
  29396. */
  29397. Chart.prototype.updateContainerScaling = function () {
  29398. var container = this.container;
  29399. // #13342 - tooltip was not visible in Chrome, when chart
  29400. // updates height.
  29401. if (container.offsetWidth > 2 && // #13342
  29402. container.offsetHeight > 2 && // #13342
  29403. container.getBoundingClientRect) {
  29404. var bb = container.getBoundingClientRect(),
  29405. scaleX = bb.width / container.offsetWidth,
  29406. scaleY = bb.height / container.offsetHeight;
  29407. if (scaleX !== 1 || scaleY !== 1) {
  29408. this.containerScaling = { scaleX: scaleX, scaleY: scaleY };
  29409. }
  29410. else {
  29411. delete this.containerScaling;
  29412. }
  29413. }
  29414. };
  29415. /**
  29416. * Remove the chart and purge memory. This method is called internally
  29417. * before adding a second chart into the same container, as well as on
  29418. * window unload to prevent leaks.
  29419. *
  29420. * @sample highcharts/members/chart-destroy/
  29421. * Destroy the chart from a button
  29422. * @sample stock/members/chart-destroy/
  29423. * Destroy with Highstock
  29424. *
  29425. * @function Highcharts.Chart#destroy
  29426. *
  29427. * @fires Highcharts.Chart#event:destroy
  29428. */
  29429. Chart.prototype.destroy = function () {
  29430. var chart = this,
  29431. axes = chart.axes,
  29432. series = chart.series,
  29433. container = chart.container,
  29434. i,
  29435. parentNode = container && container.parentNode;
  29436. // fire the chart.destoy event
  29437. fireEvent(chart, 'destroy');
  29438. // Delete the chart from charts lookup array
  29439. if (chart.renderer.forExport) {
  29440. erase(charts, chart); // #6569
  29441. }
  29442. else {
  29443. charts[chart.index] = void 0;
  29444. }
  29445. H.chartCount--;
  29446. chart.renderTo.removeAttribute('data-highcharts-chart');
  29447. // remove events
  29448. removeEvent(chart);
  29449. // ==== Destroy collections:
  29450. // Destroy axes
  29451. i = axes.length;
  29452. while (i--) {
  29453. axes[i] = axes[i].destroy();
  29454. }
  29455. // Destroy scroller & scroller series before destroying base series
  29456. if (this.scroller && this.scroller.destroy) {
  29457. this.scroller.destroy();
  29458. }
  29459. // Destroy each series
  29460. i = series.length;
  29461. while (i--) {
  29462. series[i] = series[i].destroy();
  29463. }
  29464. // ==== Destroy chart properties:
  29465. [
  29466. 'title', 'subtitle', 'chartBackground', 'plotBackground',
  29467. 'plotBGImage', 'plotBorder', 'seriesGroup', 'clipRect', 'credits',
  29468. 'pointer', 'rangeSelector', 'legend', 'resetZoomButton', 'tooltip',
  29469. 'renderer'
  29470. ].forEach(function (name) {
  29471. var prop = chart[name];
  29472. if (prop && prop.destroy) {
  29473. chart[name] = prop.destroy();
  29474. }
  29475. });
  29476. // Remove container and all SVG, check container as it can break in IE
  29477. // when destroyed before finished loading
  29478. if (container) {
  29479. container.innerHTML = '';
  29480. removeEvent(container);
  29481. if (parentNode) {
  29482. discardElement(container);
  29483. }
  29484. }
  29485. // clean it all up
  29486. objectEach(chart, function (val, key) {
  29487. delete chart[key];
  29488. });
  29489. };
  29490. /**
  29491. * Prepare for first rendering after all data are loaded.
  29492. *
  29493. * @private
  29494. * @function Highcharts.Chart#firstRender
  29495. * @fires Highcharts.Chart#event:beforeRender
  29496. */
  29497. Chart.prototype.firstRender = function () {
  29498. var chart = this,
  29499. options = chart.options;
  29500. // Hook for oldIE to check whether the chart is ready to render
  29501. if (chart.isReadyToRender && !chart.isReadyToRender()) {
  29502. return;
  29503. }
  29504. // Create the container
  29505. chart.getContainer();
  29506. chart.resetMargins();
  29507. chart.setChartSize();
  29508. // Set the common chart properties (mainly invert) from the given series
  29509. chart.propFromSeries();
  29510. // get axes
  29511. chart.getAxes();
  29512. // Initialize the series
  29513. (isArray(options.series) ? options.series : []).forEach(
  29514. // #9680
  29515. function (serieOptions) {
  29516. chart.initSeries(serieOptions);
  29517. });
  29518. chart.linkSeries();
  29519. chart.setSeriesData();
  29520. // Run an event after axes and series are initialized, but before
  29521. // render. At this stage, the series data is indexed and cached in the
  29522. // xData and yData arrays, so we can access those before rendering. Used
  29523. // in Highstock.
  29524. fireEvent(chart, 'beforeRender');
  29525. // depends on inverted and on margins being set
  29526. if (Pointer) {
  29527. if (!H.hasTouch && (win.PointerEvent || win.MSPointerEvent)) {
  29528. chart.pointer = new MSPointer(chart, options);
  29529. }
  29530. else {
  29531. /**
  29532. * The Pointer that keeps track of mouse and touch interaction.
  29533. *
  29534. * @memberof Highcharts.Chart
  29535. * @name pointer
  29536. * @type {Highcharts.Pointer}
  29537. * @instance
  29538. */
  29539. chart.pointer = new Pointer(chart, options);
  29540. }
  29541. }
  29542. chart.render();
  29543. // Fire the load event if there are no external images
  29544. if (!chart.renderer.imgCount && !chart.hasLoaded) {
  29545. chart.onload();
  29546. }
  29547. // If the chart was rendered outside the top container, put it back in
  29548. // (#3679)
  29549. chart.temporaryDisplay(true);
  29550. };
  29551. /**
  29552. * Internal function that runs on chart load, async if any images are loaded
  29553. * in the chart. Runs the callbacks and triggers the `load` and `render`
  29554. * events.
  29555. *
  29556. * @private
  29557. * @function Highcharts.Chart#onload
  29558. * @fires Highcharts.Chart#event:load
  29559. * @fires Highcharts.Chart#event:render
  29560. */
  29561. Chart.prototype.onload = function () {
  29562. // Run callbacks, first the ones registered by modules, then user's one
  29563. this.callbacks.concat([this.callback]).forEach(function (fn) {
  29564. // Chart destroyed in its own callback (#3600)
  29565. if (fn && typeof this.index !== 'undefined') {
  29566. fn.apply(this, [this]);
  29567. }
  29568. }, this);
  29569. fireEvent(this, 'load');
  29570. fireEvent(this, 'render');
  29571. // Set up auto resize, check for not destroyed (#6068)
  29572. if (defined(this.index)) {
  29573. this.setReflow(this.options.chart.reflow);
  29574. }
  29575. // Don't run again
  29576. this.hasLoaded = true;
  29577. };
  29578. return Chart;
  29579. }());
  29580. // Hook for adding callbacks in modules
  29581. Chart.prototype.callbacks = [];
  29582. /**
  29583. * Factory function for basic charts.
  29584. *
  29585. * @example
  29586. * // Render a chart in to div#container
  29587. * var chart = Highcharts.chart('container', {
  29588. * title: {
  29589. * text: 'My chart'
  29590. * },
  29591. * series: [{
  29592. * data: [1, 3, 2, 4]
  29593. * }]
  29594. * });
  29595. *
  29596. * @function Highcharts.chart
  29597. *
  29598. * @param {string|Highcharts.HTMLDOMElement} [renderTo]
  29599. * The DOM element to render to, or its id.
  29600. *
  29601. * @param {Highcharts.Options} options
  29602. * The chart options structure.
  29603. *
  29604. * @param {Highcharts.ChartCallbackFunction} [callback]
  29605. * Function to run when the chart has loaded and and all external images
  29606. * are loaded. Defining a
  29607. * [chart.events.load](https://api.highcharts.com/highcharts/chart.events.load)
  29608. * handler is equivalent.
  29609. *
  29610. * @return {Highcharts.Chart}
  29611. * Returns the Chart object.
  29612. */
  29613. function chart(a, b, c) {
  29614. return new Chart(a, b, c);
  29615. }
  29616. H.chart = chart;
  29617. H.Chart = Chart;
  29618. return Chart;
  29619. });
  29620. _registerModule(_modules, 'Extensions/ScrollablePlotArea.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Chart/Chart.js'], _modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (A, Chart, H, U) {
  29621. /* *
  29622. *
  29623. * (c) 2010-2020 Torstein Honsi
  29624. *
  29625. * License: www.highcharts.com/license
  29626. *
  29627. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  29628. *
  29629. * Highcharts feature to make the Y axis stay fixed when scrolling the chart
  29630. * horizontally on mobile devices. Supports left and right side axes.
  29631. */
  29632. /*
  29633. WIP on vertical scrollable plot area (#9378). To do:
  29634. - Bottom axis positioning
  29635. - Test with Gantt
  29636. - Look for size optimizing the code
  29637. - API and demos
  29638. */
  29639. var stop = A.stop;
  29640. var addEvent = U.addEvent,
  29641. createElement = U.createElement,
  29642. pick = U.pick;
  29643. /**
  29644. * Options for a scrollable plot area. This feature provides a minimum size for
  29645. * the plot area of the chart. If the size gets smaller than this, typically
  29646. * on mobile devices, a native browser scrollbar is presented. This scrollbar
  29647. * provides smooth scrolling for the contents of the plot area, whereas the
  29648. * title, legend and unaffected axes are fixed.
  29649. *
  29650. * Since v7.1.2, a scrollable plot area can be defined for either horizontal or
  29651. * vertical scrolling, depending on whether the `minWidth` or `minHeight`
  29652. * option is set.
  29653. *
  29654. * @sample highcharts/chart/scrollable-plotarea
  29655. * Scrollable plot area
  29656. * @sample highcharts/chart/scrollable-plotarea-vertical
  29657. * Vertically scrollable plot area
  29658. * @sample {gantt} highcharts/chart/scrollable-plotarea-vertical
  29659. * Gantt chart with vertically scrollable plot area
  29660. *
  29661. * @since 6.1.0
  29662. * @product highcharts gantt
  29663. * @apioption chart.scrollablePlotArea
  29664. */
  29665. /**
  29666. * The minimum height for the plot area. If it gets smaller than this, the plot
  29667. * area will become scrollable.
  29668. *
  29669. * @type {number}
  29670. * @apioption chart.scrollablePlotArea.minHeight
  29671. */
  29672. /**
  29673. * The minimum width for the plot area. If it gets smaller than this, the plot
  29674. * area will become scrollable.
  29675. *
  29676. * @type {number}
  29677. * @apioption chart.scrollablePlotArea.minWidth
  29678. */
  29679. /**
  29680. * The initial scrolling position of the scrollable plot area. Ranges from 0 to
  29681. * 1, where 0 aligns the plot area to the left and 1 aligns it to the right.
  29682. * Typically we would use 1 if the chart has right aligned Y axes.
  29683. *
  29684. * @type {number}
  29685. * @apioption chart.scrollablePlotArea.scrollPositionX
  29686. */
  29687. /**
  29688. * The initial scrolling position of the scrollable plot area. Ranges from 0 to
  29689. * 1, where 0 aligns the plot area to the top and 1 aligns it to the bottom.
  29690. *
  29691. * @type {number}
  29692. * @apioption chart.scrollablePlotArea.scrollPositionY
  29693. */
  29694. /**
  29695. * The opacity of mask applied on one of the sides of the plot
  29696. * area.
  29697. *
  29698. * @sample {highcharts} highcharts/chart/scrollable-plotarea-opacity
  29699. * Disabled opacity for the mask
  29700. *
  29701. * @type {number}
  29702. * @default 0.85
  29703. * @since 7.1.1
  29704. * @apioption chart.scrollablePlotArea.opacity
  29705. */
  29706. ''; // detach API doclets
  29707. /* eslint-disable no-invalid-this, valid-jsdoc */
  29708. addEvent(Chart, 'afterSetChartSize', function (e) {
  29709. var scrollablePlotArea = this.options.chart.scrollablePlotArea,
  29710. scrollableMinWidth = scrollablePlotArea && scrollablePlotArea.minWidth,
  29711. scrollableMinHeight = scrollablePlotArea && scrollablePlotArea.minHeight,
  29712. scrollablePixelsX,
  29713. scrollablePixelsY,
  29714. corrections;
  29715. if (!this.renderer.forExport) {
  29716. // The amount of pixels to scroll, the difference between chart
  29717. // width and scrollable width
  29718. if (scrollableMinWidth) {
  29719. this.scrollablePixelsX = scrollablePixelsX = Math.max(0, scrollableMinWidth - this.chartWidth);
  29720. if (scrollablePixelsX) {
  29721. this.plotWidth += scrollablePixelsX;
  29722. if (this.inverted) {
  29723. this.clipBox.height += scrollablePixelsX;
  29724. this.plotBox.height += scrollablePixelsX;
  29725. }
  29726. else {
  29727. this.clipBox.width += scrollablePixelsX;
  29728. this.plotBox.width += scrollablePixelsX;
  29729. }
  29730. corrections = {
  29731. // Corrections for right side
  29732. 1: { name: 'right', value: scrollablePixelsX }
  29733. };
  29734. }
  29735. // Currently we can only do either X or Y
  29736. }
  29737. else if (scrollableMinHeight) {
  29738. this.scrollablePixelsY = scrollablePixelsY = Math.max(0, scrollableMinHeight - this.chartHeight);
  29739. if (scrollablePixelsY) {
  29740. this.plotHeight += scrollablePixelsY;
  29741. if (this.inverted) {
  29742. this.clipBox.width += scrollablePixelsY;
  29743. this.plotBox.width += scrollablePixelsY;
  29744. }
  29745. else {
  29746. this.clipBox.height += scrollablePixelsY;
  29747. this.plotBox.height += scrollablePixelsY;
  29748. }
  29749. corrections = {
  29750. 2: { name: 'bottom', value: scrollablePixelsY }
  29751. };
  29752. }
  29753. }
  29754. if (corrections && !e.skipAxes) {
  29755. this.axes.forEach(function (axis) {
  29756. // For right and bottom axes, only fix the plot line length
  29757. if (corrections[axis.side]) {
  29758. // Get the plot lines right in getPlotLinePath,
  29759. // temporarily set it to the adjusted plot width.
  29760. axis.getPlotLinePath = function () {
  29761. var marginName = corrections[axis.side].name,
  29762. correctionValue = corrections[axis.side].value,
  29763. // axis.right or axis.bottom
  29764. margin = this[marginName],
  29765. path;
  29766. // Temporarily adjust
  29767. this[marginName] = margin - correctionValue;
  29768. path = H.Axis.prototype.getPlotLinePath.apply(this, arguments);
  29769. // Reset
  29770. this[marginName] = margin;
  29771. return path;
  29772. };
  29773. }
  29774. else {
  29775. // Apply the corrected plotWidth
  29776. axis.setAxisSize();
  29777. axis.setAxisTranslation();
  29778. }
  29779. });
  29780. }
  29781. }
  29782. });
  29783. addEvent(Chart, 'render', function () {
  29784. if (this.scrollablePixelsX || this.scrollablePixelsY) {
  29785. if (this.setUpScrolling) {
  29786. this.setUpScrolling();
  29787. }
  29788. this.applyFixed();
  29789. }
  29790. else if (this.fixedDiv) { // Has been in scrollable mode
  29791. this.applyFixed();
  29792. }
  29793. });
  29794. /**
  29795. * @private
  29796. * @function Highcharts.Chart#setUpScrolling
  29797. * @return {void}
  29798. */
  29799. Chart.prototype.setUpScrolling = function () {
  29800. var _this = this;
  29801. var attribs = {
  29802. WebkitOverflowScrolling: 'touch',
  29803. overflowX: 'hidden',
  29804. overflowY: 'hidden'
  29805. };
  29806. if (this.scrollablePixelsX) {
  29807. attribs.overflowX = 'auto';
  29808. }
  29809. if (this.scrollablePixelsY) {
  29810. attribs.overflowY = 'auto';
  29811. }
  29812. // Insert a container with position relative
  29813. // that scrolling and fixed container renders to (#10555)
  29814. this.scrollingParent = createElement('div', {
  29815. className: 'highcharts-scrolling-parent'
  29816. }, {
  29817. position: 'relative'
  29818. }, this.renderTo);
  29819. // Add the necessary divs to provide scrolling
  29820. this.scrollingContainer = createElement('div', {
  29821. 'className': 'highcharts-scrolling'
  29822. }, attribs, this.scrollingParent);
  29823. // On scroll, reset the chart position because it applies to the scrolled
  29824. // container
  29825. addEvent(this.scrollingContainer, 'scroll', function () {
  29826. if (_this.pointer) {
  29827. delete _this.pointer.chartPosition;
  29828. }
  29829. });
  29830. this.innerContainer = createElement('div', {
  29831. 'className': 'highcharts-inner-container'
  29832. }, null, this.scrollingContainer);
  29833. // Now move the container inside
  29834. this.innerContainer.appendChild(this.container);
  29835. // Don't run again
  29836. this.setUpScrolling = null;
  29837. };
  29838. /**
  29839. * These elements are moved over to the fixed renderer and stay fixed when the
  29840. * user scrolls the chart
  29841. * @private
  29842. */
  29843. Chart.prototype.moveFixedElements = function () {
  29844. var container = this.container,
  29845. fixedRenderer = this.fixedRenderer,
  29846. fixedSelectors = [
  29847. '.highcharts-contextbutton',
  29848. '.highcharts-credits',
  29849. '.highcharts-legend',
  29850. '.highcharts-legend-checkbox',
  29851. '.highcharts-navigator-series',
  29852. '.highcharts-navigator-xaxis',
  29853. '.highcharts-navigator-yaxis',
  29854. '.highcharts-navigator',
  29855. '.highcharts-reset-zoom',
  29856. '.highcharts-scrollbar',
  29857. '.highcharts-subtitle',
  29858. '.highcharts-title'
  29859. ],
  29860. axisClass;
  29861. if (this.scrollablePixelsX && !this.inverted) {
  29862. axisClass = '.highcharts-yaxis';
  29863. }
  29864. else if (this.scrollablePixelsX && this.inverted) {
  29865. axisClass = '.highcharts-xaxis';
  29866. }
  29867. else if (this.scrollablePixelsY && !this.inverted) {
  29868. axisClass = '.highcharts-xaxis';
  29869. }
  29870. else if (this.scrollablePixelsY && this.inverted) {
  29871. axisClass = '.highcharts-yaxis';
  29872. }
  29873. fixedSelectors.push(axisClass, axisClass + '-labels');
  29874. fixedSelectors.forEach(function (className) {
  29875. [].forEach.call(container.querySelectorAll(className), function (elem) {
  29876. (elem.namespaceURI === fixedRenderer.SVG_NS ?
  29877. fixedRenderer.box :
  29878. fixedRenderer.box.parentNode).appendChild(elem);
  29879. elem.style.pointerEvents = 'auto';
  29880. });
  29881. });
  29882. };
  29883. /**
  29884. * @private
  29885. * @function Highcharts.Chart#applyFixed
  29886. * @return {void}
  29887. */
  29888. Chart.prototype.applyFixed = function () {
  29889. var _a,
  29890. _b;
  29891. var fixedRenderer,
  29892. scrollableWidth,
  29893. scrollableHeight,
  29894. firstTime = !this.fixedDiv,
  29895. scrollableOptions = this.options.chart.scrollablePlotArea;
  29896. // First render
  29897. if (firstTime) {
  29898. this.fixedDiv = createElement('div', {
  29899. className: 'highcharts-fixed'
  29900. }, {
  29901. position: 'absolute',
  29902. overflow: 'hidden',
  29903. pointerEvents: 'none',
  29904. zIndex: 2,
  29905. top: 0
  29906. }, null, true);
  29907. (_a = this.scrollingContainer) === null || _a === void 0 ? void 0 : _a.parentNode.insertBefore(this.fixedDiv, this.scrollingContainer);
  29908. this.renderTo.style.overflow = 'visible';
  29909. this.fixedRenderer = fixedRenderer = new H.Renderer(this.fixedDiv, this.chartWidth, this.chartHeight, (_b = this.options.chart) === null || _b === void 0 ? void 0 : _b.style);
  29910. // Mask
  29911. this.scrollableMask = fixedRenderer
  29912. .path()
  29913. .attr({
  29914. fill: this.options.chart.backgroundColor || '#fff',
  29915. 'fill-opacity': pick(scrollableOptions.opacity, 0.85),
  29916. zIndex: -1
  29917. })
  29918. .addClass('highcharts-scrollable-mask')
  29919. .add();
  29920. this.moveFixedElements();
  29921. addEvent(this, 'afterShowResetZoom', this.moveFixedElements);
  29922. addEvent(this, 'afterLayOutTitles', this.moveFixedElements);
  29923. }
  29924. else {
  29925. // Set the size of the fixed renderer to the visible width
  29926. this.fixedRenderer.setSize(this.chartWidth, this.chartHeight);
  29927. }
  29928. // Increase the size of the scrollable renderer and background
  29929. scrollableWidth = this.chartWidth + (this.scrollablePixelsX || 0);
  29930. scrollableHeight = this.chartHeight + (this.scrollablePixelsY || 0);
  29931. stop(this.container);
  29932. this.container.style.width = scrollableWidth + 'px';
  29933. this.container.style.height = scrollableHeight + 'px';
  29934. this.renderer.boxWrapper.attr({
  29935. width: scrollableWidth,
  29936. height: scrollableHeight,
  29937. viewBox: [0, 0, scrollableWidth, scrollableHeight].join(' ')
  29938. });
  29939. this.chartBackground.attr({
  29940. width: scrollableWidth,
  29941. height: scrollableHeight
  29942. });
  29943. this.scrollingContainer.style.height = this.chartHeight + 'px';
  29944. // Set scroll position
  29945. if (firstTime) {
  29946. if (scrollableOptions.scrollPositionX) {
  29947. this.scrollingContainer.scrollLeft =
  29948. this.scrollablePixelsX *
  29949. scrollableOptions.scrollPositionX;
  29950. }
  29951. if (scrollableOptions.scrollPositionY) {
  29952. this.scrollingContainer.scrollTop =
  29953. this.scrollablePixelsY *
  29954. scrollableOptions.scrollPositionY;
  29955. }
  29956. }
  29957. // Mask behind the left and right side
  29958. var axisOffset = this.axisOffset,
  29959. maskTop = this.plotTop - axisOffset[0] - 1,
  29960. maskLeft = this.plotLeft - axisOffset[3] - 1,
  29961. maskBottom = this.plotTop + this.plotHeight + axisOffset[2] + 1,
  29962. maskRight = this.plotLeft + this.plotWidth + axisOffset[1] + 1,
  29963. maskPlotRight = this.plotLeft + this.plotWidth -
  29964. (this.scrollablePixelsX || 0),
  29965. maskPlotBottom = this.plotTop + this.plotHeight -
  29966. (this.scrollablePixelsY || 0),
  29967. d;
  29968. if (this.scrollablePixelsX) {
  29969. d = [
  29970. // Left side
  29971. ['M', 0, maskTop],
  29972. ['L', this.plotLeft - 1, maskTop],
  29973. ['L', this.plotLeft - 1, maskBottom],
  29974. ['L', 0, maskBottom],
  29975. ['Z'],
  29976. // Right side
  29977. ['M', maskPlotRight, maskTop],
  29978. ['L', this.chartWidth, maskTop],
  29979. ['L', this.chartWidth, maskBottom],
  29980. ['L', maskPlotRight, maskBottom],
  29981. ['Z']
  29982. ];
  29983. }
  29984. else if (this.scrollablePixelsY) {
  29985. d = [
  29986. // Top side
  29987. ['M', maskLeft, 0],
  29988. ['L', maskLeft, this.plotTop - 1],
  29989. ['L', maskRight, this.plotTop - 1],
  29990. ['L', maskRight, 0],
  29991. ['Z'],
  29992. // Bottom side
  29993. ['M', maskLeft, maskPlotBottom],
  29994. ['L', maskLeft, this.chartHeight],
  29995. ['L', maskRight, this.chartHeight],
  29996. ['L', maskRight, maskPlotBottom],
  29997. ['Z']
  29998. ];
  29999. }
  30000. else {
  30001. d = [['M', 0, 0]];
  30002. }
  30003. if (this.redrawTrigger !== 'adjustHeight') {
  30004. this.scrollableMask.attr({ d: d });
  30005. }
  30006. };
  30007. });
  30008. _registerModule(_modules, 'Core/Axis/StackingAxis.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Utilities.js']], function (A, U) {
  30009. /* *
  30010. *
  30011. * (c) 2010-2020 Torstein Honsi
  30012. *
  30013. * License: www.highcharts.com/license
  30014. *
  30015. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  30016. *
  30017. * */
  30018. var getDeferredAnimation = A.getDeferredAnimation;
  30019. var addEvent = U.addEvent,
  30020. destroyObjectProperties = U.destroyObjectProperties,
  30021. fireEvent = U.fireEvent,
  30022. objectEach = U.objectEach,
  30023. pick = U.pick;
  30024. /* eslint-disable valid-jsdoc */
  30025. /**
  30026. * Adds stacking support to axes.
  30027. * @private
  30028. * @class
  30029. */
  30030. var StackingAxisAdditions = /** @class */ (function () {
  30031. /* *
  30032. *
  30033. * Constructors
  30034. *
  30035. * */
  30036. function StackingAxisAdditions(axis) {
  30037. this.oldStacks = {};
  30038. this.stacks = {};
  30039. this.stacksTouched = 0;
  30040. this.axis = axis;
  30041. }
  30042. /* *
  30043. *
  30044. * Functions
  30045. *
  30046. * */
  30047. /**
  30048. * Build the stacks from top down
  30049. * @private
  30050. */
  30051. StackingAxisAdditions.prototype.buildStacks = function () {
  30052. var stacking = this;
  30053. var axis = stacking.axis;
  30054. var axisSeries = axis.series;
  30055. var reversedStacks = pick(axis.options.reversedStacks,
  30056. true);
  30057. var len = axisSeries.length;
  30058. var actualSeries,
  30059. i;
  30060. if (!axis.isXAxis) {
  30061. stacking.usePercentage = false;
  30062. i = len;
  30063. while (i--) {
  30064. actualSeries = axisSeries[reversedStacks ? i : len - i - 1];
  30065. actualSeries.setStackedPoints();
  30066. actualSeries.setGroupedPoints();
  30067. }
  30068. // Loop up again to compute percent and stream stack
  30069. for (i = 0; i < len; i++) {
  30070. axisSeries[i].modifyStacks();
  30071. }
  30072. fireEvent(axis, 'afterBuildStacks');
  30073. }
  30074. };
  30075. /**
  30076. * @private
  30077. */
  30078. StackingAxisAdditions.prototype.cleanStacks = function () {
  30079. var stacking = this;
  30080. var axis = stacking.axis;
  30081. var stacks;
  30082. if (!axis.isXAxis) {
  30083. if (stacking.oldStacks) {
  30084. stacks = stacking.stacks = stacking.oldStacks;
  30085. }
  30086. // reset stacks
  30087. objectEach(stacks, function (type) {
  30088. objectEach(type, function (stack) {
  30089. stack.cumulative = stack.total;
  30090. });
  30091. });
  30092. }
  30093. };
  30094. /**
  30095. * Set all the stacks to initial states and destroy unused ones.
  30096. * @private
  30097. */
  30098. StackingAxisAdditions.prototype.resetStacks = function () {
  30099. var stacking = this;
  30100. var axis = stacking.axis;
  30101. var stacks = stacking.stacks;
  30102. if (!axis.isXAxis) {
  30103. objectEach(stacks, function (type) {
  30104. objectEach(type, function (stack, key) {
  30105. // Clean up memory after point deletion (#1044, #4320)
  30106. if (stack.touched < stacking.stacksTouched) {
  30107. stack.destroy();
  30108. delete type[key];
  30109. // Reset stacks
  30110. }
  30111. else {
  30112. stack.total = null;
  30113. stack.cumulative = null;
  30114. }
  30115. });
  30116. });
  30117. }
  30118. };
  30119. /**
  30120. * @private
  30121. */
  30122. StackingAxisAdditions.prototype.renderStackTotals = function () {
  30123. var stacking = this;
  30124. var axis = stacking.axis;
  30125. var chart = axis.chart;
  30126. var renderer = chart.renderer;
  30127. var stacks = stacking.stacks;
  30128. var stackLabelsAnim = axis.options.stackLabels.animation;
  30129. var animationConfig = getDeferredAnimation(chart,
  30130. stackLabelsAnim);
  30131. var stackTotalGroup = stacking.stackTotalGroup = (stacking.stackTotalGroup ||
  30132. renderer
  30133. .g('stack-labels')
  30134. .attr({
  30135. visibility: 'visible',
  30136. zIndex: 6,
  30137. opacity: 0
  30138. })
  30139. .add());
  30140. // plotLeft/Top will change when y axis gets wider so we need to
  30141. // translate the stackTotalGroup at every render call. See bug #506
  30142. // and #516
  30143. stackTotalGroup.translate(chart.plotLeft, chart.plotTop);
  30144. // Render each stack total
  30145. objectEach(stacks, function (type) {
  30146. objectEach(type, function (stack) {
  30147. stack.render(stackTotalGroup);
  30148. });
  30149. });
  30150. stackTotalGroup.animate({
  30151. opacity: 1
  30152. }, animationConfig);
  30153. };
  30154. return StackingAxisAdditions;
  30155. }());
  30156. /**
  30157. * Axis with stacking support.
  30158. * @private
  30159. * @class
  30160. */
  30161. var StackingAxis = /** @class */ (function () {
  30162. function StackingAxis() {
  30163. }
  30164. /* *
  30165. *
  30166. * Static Functions
  30167. *
  30168. * */
  30169. /**
  30170. * Extends axis with stacking support.
  30171. * @private
  30172. */
  30173. StackingAxis.compose = function (AxisClass) {
  30174. var axisProto = AxisClass.prototype;
  30175. addEvent(AxisClass, 'init', StackingAxis.onInit);
  30176. addEvent(AxisClass, 'destroy', StackingAxis.onDestroy);
  30177. };
  30178. /**
  30179. * @private
  30180. */
  30181. StackingAxis.onDestroy = function () {
  30182. var stacking = this.stacking;
  30183. if (!stacking) {
  30184. return;
  30185. }
  30186. var stacks = stacking.stacks;
  30187. // Destroy each stack total
  30188. objectEach(stacks, function (stack, stackKey) {
  30189. destroyObjectProperties(stack);
  30190. stacks[stackKey] = null;
  30191. });
  30192. if (stacking &&
  30193. stacking.stackTotalGroup) {
  30194. stacking.stackTotalGroup.destroy();
  30195. }
  30196. };
  30197. /**
  30198. * @private
  30199. */
  30200. StackingAxis.onInit = function () {
  30201. var axis = this;
  30202. if (!axis.stacking) {
  30203. axis.stacking = new StackingAxisAdditions(axis);
  30204. }
  30205. };
  30206. return StackingAxis;
  30207. }());
  30208. return StackingAxis;
  30209. });
  30210. _registerModule(_modules, 'Mixins/LegendSymbol.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  30211. /* *
  30212. *
  30213. * (c) 2010-2020 Torstein Honsi
  30214. *
  30215. * License: www.highcharts.com/license
  30216. *
  30217. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  30218. *
  30219. * */
  30220. var merge = U.merge,
  30221. pick = U.pick;
  30222. /* eslint-disable valid-jsdoc */
  30223. /**
  30224. * Legend symbol mixin.
  30225. *
  30226. * @private
  30227. * @mixin Highcharts.LegendSymbolMixin
  30228. */
  30229. var LegendSymbolMixin = H.LegendSymbolMixin = {
  30230. /**
  30231. * Get the series' symbol in the legend
  30232. *
  30233. * @private
  30234. * @function Highcharts.LegendSymbolMixin.drawRectangle
  30235. *
  30236. * @param {Highcharts.Legend} legend
  30237. * The legend object
  30238. *
  30239. * @param {Highcharts.Point|Highcharts.Series} item
  30240. * The series (this) or point
  30241. */
  30242. drawRectangle: function (legend,
  30243. item) {
  30244. var options = legend.options,
  30245. symbolHeight = legend.symbolHeight,
  30246. square = options.squareSymbol,
  30247. symbolWidth = square ? symbolHeight : legend.symbolWidth;
  30248. item.legendSymbol = this.chart.renderer.rect(square ? (legend.symbolWidth - symbolHeight) / 2 : 0, legend.baseline - symbolHeight + 1, // #3988
  30249. symbolWidth, symbolHeight, pick(legend.options.symbolRadius, symbolHeight / 2))
  30250. .addClass('highcharts-point')
  30251. .attr({
  30252. zIndex: 3
  30253. }).add(item.legendGroup);
  30254. },
  30255. /**
  30256. * Get the series' symbol in the legend. This method should be overridable
  30257. * to create custom symbols through
  30258. * Highcharts.seriesTypes[type].prototype.drawLegendSymbols.
  30259. *
  30260. * @private
  30261. * @function Highcharts.LegendSymbolMixin.drawLineMarker
  30262. *
  30263. * @param {Highcharts.Legend} legend
  30264. * The legend object.
  30265. */
  30266. drawLineMarker: function (legend) {
  30267. var options = this.options,
  30268. markerOptions = options.marker,
  30269. radius,
  30270. legendSymbol,
  30271. symbolWidth = legend.symbolWidth,
  30272. symbolHeight = legend.symbolHeight,
  30273. generalRadius = symbolHeight / 2,
  30274. renderer = this.chart.renderer,
  30275. legendItemGroup = this.legendGroup,
  30276. verticalCenter = legend.baseline -
  30277. Math.round(legend.fontMetrics.b * 0.3),
  30278. attr = {};
  30279. // Draw the line
  30280. if (!this.chart.styledMode) {
  30281. attr = {
  30282. 'stroke-width': options.lineWidth || 0
  30283. };
  30284. if (options.dashStyle) {
  30285. attr.dashstyle = options.dashStyle;
  30286. }
  30287. }
  30288. this.legendLine = renderer
  30289. .path([
  30290. ['M', 0, verticalCenter],
  30291. ['L', symbolWidth, verticalCenter]
  30292. ])
  30293. .addClass('highcharts-graph')
  30294. .attr(attr)
  30295. .add(legendItemGroup);
  30296. // Draw the marker
  30297. if (markerOptions && markerOptions.enabled !== false && symbolWidth) {
  30298. // Do not allow the marker to be larger than the symbolHeight
  30299. radius = Math.min(pick(markerOptions.radius, generalRadius), generalRadius);
  30300. // Restrict symbol markers size
  30301. if (this.symbol.indexOf('url') === 0) {
  30302. markerOptions = merge(markerOptions, {
  30303. width: symbolHeight,
  30304. height: symbolHeight
  30305. });
  30306. radius = 0;
  30307. }
  30308. this.legendSymbol = legendSymbol = renderer.symbol(this.symbol, (symbolWidth / 2) - radius, verticalCenter - radius, 2 * radius, 2 * radius, markerOptions)
  30309. .addClass('highcharts-point')
  30310. .add(legendItemGroup);
  30311. legendSymbol.isMarker = true;
  30312. }
  30313. }
  30314. };
  30315. return LegendSymbolMixin;
  30316. });
  30317. _registerModule(_modules, 'Core/Series/CartesianSeries.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Series/Series.js'], _modules['Core/Globals.js'], _modules['Mixins/LegendSymbol.js'], _modules['Core/Options.js'], _modules['Core/Series/Point.js'], _modules['Core/Renderer/SVG/SVGElement.js'], _modules['Core/Utilities.js']], function (A, BaseSeries, H, LegendSymbolMixin, O, Point, SVGElement, U) {
  30318. /* *
  30319. *
  30320. * (c) 2010-2020 Torstein Honsi
  30321. *
  30322. * License: www.highcharts.com/license
  30323. *
  30324. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  30325. *
  30326. * */
  30327. var animObject = A.animObject;
  30328. var defaultOptions = O.defaultOptions;
  30329. var addEvent = U.addEvent,
  30330. arrayMax = U.arrayMax,
  30331. arrayMin = U.arrayMin,
  30332. clamp = U.clamp,
  30333. correctFloat = U.correctFloat,
  30334. defined = U.defined,
  30335. erase = U.erase,
  30336. error = U.error,
  30337. extend = U.extend,
  30338. find = U.find,
  30339. fireEvent = U.fireEvent,
  30340. getNestedProperty = U.getNestedProperty,
  30341. isArray = U.isArray,
  30342. isFunction = U.isFunction,
  30343. isNumber = U.isNumber,
  30344. isString = U.isString,
  30345. merge = U.merge,
  30346. objectEach = U.objectEach,
  30347. pick = U.pick,
  30348. removeEvent = U.removeEvent,
  30349. splat = U.splat,
  30350. syncTimeout = U.syncTimeout;
  30351. /**
  30352. * This is a placeholder type of the possible series options for
  30353. * [Highcharts](../highcharts/series), [Highstock](../highstock/series),
  30354. * [Highmaps](../highmaps/series), and [Gantt](../gantt/series).
  30355. *
  30356. * In TypeScript is this dynamically generated to reference all possible types
  30357. * of series options.
  30358. *
  30359. * @ignore-declaration
  30360. * @typedef {Highcharts.SeriesOptions|Highcharts.Dictionary<*>} Highcharts.SeriesOptionsType
  30361. */
  30362. /**
  30363. * Options for `dataSorting`.
  30364. *
  30365. * @interface Highcharts.DataSortingOptionsObject
  30366. * @since 8.0.0
  30367. */ /**
  30368. * Enable or disable data sorting for the series.
  30369. * @name Highcharts.DataSortingOptionsObject#enabled
  30370. * @type {boolean|undefined}
  30371. */ /**
  30372. * Whether to allow matching points by name in an update.
  30373. * @name Highcharts.DataSortingOptionsObject#matchByName
  30374. * @type {boolean|undefined}
  30375. */ /**
  30376. * Determines what data value should be used to sort by.
  30377. * @name Highcharts.DataSortingOptionsObject#sortKey
  30378. * @type {string|undefined}
  30379. */
  30380. /**
  30381. * Function callback when a series has been animated.
  30382. *
  30383. * @callback Highcharts.SeriesAfterAnimateCallbackFunction
  30384. *
  30385. * @param {Highcharts.Series} this
  30386. * The series where the event occured.
  30387. *
  30388. * @param {Highcharts.SeriesAfterAnimateEventObject} event
  30389. * Event arguments.
  30390. */
  30391. /**
  30392. * Event information regarding completed animation of a series.
  30393. *
  30394. * @interface Highcharts.SeriesAfterAnimateEventObject
  30395. */ /**
  30396. * Animated series.
  30397. * @name Highcharts.SeriesAfterAnimateEventObject#target
  30398. * @type {Highcharts.Series}
  30399. */ /**
  30400. * Event type.
  30401. * @name Highcharts.SeriesAfterAnimateEventObject#type
  30402. * @type {"afterAnimate"}
  30403. */
  30404. /**
  30405. * Function callback when the checkbox next to the series' name in the legend is
  30406. * clicked.
  30407. *
  30408. * @callback Highcharts.SeriesCheckboxClickCallbackFunction
  30409. *
  30410. * @param {Highcharts.Series} this
  30411. * The series where the event occured.
  30412. *
  30413. * @param {Highcharts.SeriesCheckboxClickEventObject} event
  30414. * Event arguments.
  30415. */
  30416. /**
  30417. * Event information regarding check of a series box.
  30418. *
  30419. * @interface Highcharts.SeriesCheckboxClickEventObject
  30420. */ /**
  30421. * Whether the box has been checked.
  30422. * @name Highcharts.SeriesCheckboxClickEventObject#checked
  30423. * @type {boolean}
  30424. */ /**
  30425. * Related series.
  30426. * @name Highcharts.SeriesCheckboxClickEventObject#item
  30427. * @type {Highcharts.Series}
  30428. */ /**
  30429. * Related series.
  30430. * @name Highcharts.SeriesCheckboxClickEventObject#target
  30431. * @type {Highcharts.Series}
  30432. */ /**
  30433. * Event type.
  30434. * @name Highcharts.SeriesCheckboxClickEventObject#type
  30435. * @type {"checkboxClick"}
  30436. */
  30437. /**
  30438. * Function callback when a series is clicked. Return false to cancel toogle
  30439. * actions.
  30440. *
  30441. * @callback Highcharts.SeriesClickCallbackFunction
  30442. *
  30443. * @param {Highcharts.Series} this
  30444. * The series where the event occured.
  30445. *
  30446. * @param {Highcharts.SeriesClickEventObject} event
  30447. * Event arguments.
  30448. */
  30449. /**
  30450. * Common information for a click event on a series.
  30451. *
  30452. * @interface Highcharts.SeriesClickEventObject
  30453. * @extends global.Event
  30454. */ /**
  30455. * Nearest point on the graph.
  30456. * @name Highcharts.SeriesClickEventObject#point
  30457. * @type {Highcharts.Point}
  30458. */
  30459. /**
  30460. * Gets fired when the series is hidden after chart generation time, either by
  30461. * clicking the legend item or by calling `.hide()`.
  30462. *
  30463. * @callback Highcharts.SeriesHideCallbackFunction
  30464. *
  30465. * @param {Highcharts.Series} this
  30466. * The series where the event occured.
  30467. *
  30468. * @param {global.Event} event
  30469. * The event that occured.
  30470. */
  30471. /**
  30472. * The SVG value used for the `stroke-linecap` and `stroke-linejoin` of a line
  30473. * graph.
  30474. *
  30475. * @typedef {"butt"|"round"|"square"|string} Highcharts.SeriesLinecapValue
  30476. */
  30477. /**
  30478. * Gets fired when the legend item belonging to the series is clicked. The
  30479. * default action is to toggle the visibility of the series. This can be
  30480. * prevented by returning `false` or calling `event.preventDefault()`.
  30481. *
  30482. * @callback Highcharts.SeriesLegendItemClickCallbackFunction
  30483. *
  30484. * @param {Highcharts.Series} this
  30485. * The series where the event occured.
  30486. *
  30487. * @param {Highcharts.SeriesLegendItemClickEventObject} event
  30488. * The event that occured.
  30489. */
  30490. /**
  30491. * Information about the event.
  30492. *
  30493. * @interface Highcharts.SeriesLegendItemClickEventObject
  30494. */ /**
  30495. * Related browser event.
  30496. * @name Highcharts.SeriesLegendItemClickEventObject#browserEvent
  30497. * @type {global.PointerEvent}
  30498. */ /**
  30499. * Prevent the default action of toggle the visibility of the series.
  30500. * @name Highcharts.SeriesLegendItemClickEventObject#preventDefault
  30501. * @type {Function}
  30502. */ /**
  30503. * Related series.
  30504. * @name Highcharts.SeriesCheckboxClickEventObject#target
  30505. * @type {Highcharts.Series}
  30506. */ /**
  30507. * Event type.
  30508. * @name Highcharts.SeriesCheckboxClickEventObject#type
  30509. * @type {"checkboxClick"}
  30510. */
  30511. /**
  30512. * Gets fired when the mouse leaves the graph.
  30513. *
  30514. * @callback Highcharts.SeriesMouseOutCallbackFunction
  30515. *
  30516. * @param {Highcharts.Series} this
  30517. * Series where the event occured.
  30518. *
  30519. * @param {global.PointerEvent} event
  30520. * Event that occured.
  30521. */
  30522. /**
  30523. * Gets fired when the mouse enters the graph.
  30524. *
  30525. * @callback Highcharts.SeriesMouseOverCallbackFunction
  30526. *
  30527. * @param {Highcharts.Series} this
  30528. * Series where the event occured.
  30529. *
  30530. * @param {global.PointerEvent} event
  30531. * Event that occured.
  30532. */
  30533. /**
  30534. * Translation and scale for the plot area of a series.
  30535. *
  30536. * @interface Highcharts.SeriesPlotBoxObject
  30537. */ /**
  30538. * @name Highcharts.SeriesPlotBoxObject#scaleX
  30539. * @type {number}
  30540. */ /**
  30541. * @name Highcharts.SeriesPlotBoxObject#scaleY
  30542. * @type {number}
  30543. */ /**
  30544. * @name Highcharts.SeriesPlotBoxObject#translateX
  30545. * @type {number}
  30546. */ /**
  30547. * @name Highcharts.SeriesPlotBoxObject#translateY
  30548. * @type {number}
  30549. */
  30550. /**
  30551. * Gets fired when the series is shown after chart generation time, either by
  30552. * clicking the legend item or by calling `.show()`.
  30553. *
  30554. * @callback Highcharts.SeriesShowCallbackFunction
  30555. *
  30556. * @param {Highcharts.Series} this
  30557. * Series where the event occured.
  30558. *
  30559. * @param {global.Event} event
  30560. * Event that occured.
  30561. */
  30562. /**
  30563. * Possible key values for the series state options.
  30564. *
  30565. * @typedef {"hover"|"inactive"|"normal"|"select"} Highcharts.SeriesStateValue
  30566. */
  30567. ''; // detach doclets above
  30568. var seriesTypes = BaseSeries.seriesTypes,
  30569. win = H.win;
  30570. /**
  30571. * This is the base series prototype that all other series types inherit from.
  30572. * A new series is initialized either through the
  30573. * [series](https://api.highcharts.com/highcharts/series)
  30574. * option structure, or after the chart is initialized, through
  30575. * {@link Highcharts.Chart#addSeries}.
  30576. *
  30577. * The object can be accessed in a number of ways. All series and point event
  30578. * handlers give a reference to the `series` object. The chart object has a
  30579. * {@link Highcharts.Chart#series|series} property that is a collection of all
  30580. * the chart's series. The point objects and axis objects also have the same
  30581. * reference.
  30582. *
  30583. * Another way to reference the series programmatically is by `id`. Add an id
  30584. * in the series configuration options, and get the series object by
  30585. * {@link Highcharts.Chart#get}.
  30586. *
  30587. * Configuration options for the series are given in three levels. Options for
  30588. * all series in a chart are given in the
  30589. * [plotOptions.series](https://api.highcharts.com/highcharts/plotOptions.series)
  30590. * object. Then options for all series of a specific type
  30591. * are given in the plotOptions of that type, for example `plotOptions.line`.
  30592. * Next, options for one single series are given in the series array, or as
  30593. * arguments to `chart.addSeries`.
  30594. *
  30595. * The data in the series is stored in various arrays.
  30596. *
  30597. * - First, `series.options.data` contains all the original config options for
  30598. * each point whether added by options or methods like `series.addPoint`.
  30599. *
  30600. * - Next, `series.data` contains those values converted to points, but in case
  30601. * the series data length exceeds the `cropThreshold`, or if the data is
  30602. * grouped, `series.data` doesn't contain all the points. It only contains the
  30603. * points that have been created on demand.
  30604. *
  30605. * - Then there's `series.points` that contains all currently visible point
  30606. * objects. In case of cropping, the cropped-away points are not part of this
  30607. * array. The `series.points` array starts at `series.cropStart` compared to
  30608. * `series.data` and `series.options.data`. If however the series data is
  30609. * grouped, these can't be correlated one to one.
  30610. *
  30611. * - `series.xData` and `series.processedXData` contain clean x values,
  30612. * equivalent to `series.data` and `series.points`.
  30613. *
  30614. * - `series.yData` and `series.processedYData` contain clean y values,
  30615. * equivalent to `series.data` and `series.points`.
  30616. *
  30617. * @class
  30618. * @name Highcharts.Series
  30619. *
  30620. * @param {Highcharts.Chart} chart
  30621. * The chart instance.
  30622. *
  30623. * @param {Highcharts.SeriesOptionsType|object} options
  30624. * The series options.
  30625. */ /**
  30626. * The line series is the base type and is therefor the series base prototype.
  30627. *
  30628. * @private
  30629. * @class
  30630. * @name Highcharts.seriesTypes.line
  30631. *
  30632. * @augments Highcharts.Series
  30633. */
  30634. var CartesianSeries = BaseSeries.seriesType('line',
  30635. /**
  30636. * Series options for specific data and the data itself. In TypeScript you
  30637. * have to cast the series options to specific series types,
  30638. to get all
  30639. * possible options for a series.
  30640. *
  30641. * @example
  30642. * // TypeScript example
  30643. * Highcharts.chart('container', {
  30644. * series: [{
  30645. * color: '#06C',
  30646. * data: [[0, 1],
  30647. [2, 3]]
  30648. * } as Highcharts.SeriesLineOptions ]
  30649. * });
  30650. *
  30651. * @type {Array<*>}
  30652. * @apioption series
  30653. */
  30654. /**
  30655. * An id for the series. This can be used after render time to get a pointer
  30656. * to the series object through `chart.get()`.
  30657. *
  30658. * @sample {highcharts} highcharts/plotoptions/series-id/
  30659. * Get series by id
  30660. *
  30661. * @type {string}
  30662. * @since 1.2.0
  30663. * @apioption series.id
  30664. */
  30665. /**
  30666. * The index of the series in the chart, affecting the internal index in the
  30667. * `chart.series` array, the visible Z index as well as the order in the
  30668. * legend.
  30669. *
  30670. * @type {number}
  30671. * @since 2.3.0
  30672. * @apioption series.index
  30673. */
  30674. /**
  30675. * The sequential index of the series in the legend.
  30676. *
  30677. * @see [legend.reversed](#legend.reversed),
  30678. * [yAxis.reversedStacks](#yAxis.reversedStacks)
  30679. *
  30680. * @sample {highcharts|highstock} highcharts/series/legendindex/
  30681. * Legend in opposite order
  30682. *
  30683. * @type {number}
  30684. * @apioption series.legendIndex
  30685. */
  30686. /**
  30687. * The name of the series as shown in the legend, tooltip etc.
  30688. *
  30689. * @sample {highcharts} highcharts/series/name/
  30690. * Series name
  30691. * @sample {highmaps} maps/demo/category-map/
  30692. * Series name
  30693. *
  30694. * @type {string}
  30695. * @apioption series.name
  30696. */
  30697. /**
  30698. * This option allows grouping series in a stacked chart. The stack option
  30699. * can be a string or anything else, as long as the grouped series' stack
  30700. * options match each other after conversion into a string.
  30701. *
  30702. * @sample {highcharts} highcharts/series/stack/
  30703. * Stacked and grouped columns
  30704. *
  30705. * @type {number|string}
  30706. * @since 2.1
  30707. * @product highcharts highstock
  30708. * @apioption series.stack
  30709. */
  30710. /**
  30711. * The type of series, for example `line` or `column`. By default, the
  30712. * series type is inherited from [chart.type](#chart.type), so unless the
  30713. * chart is a combination of series types, there is no need to set it on the
  30714. * series level.
  30715. *
  30716. * @sample {highcharts} highcharts/series/type/
  30717. * Line and column in the same chart
  30718. * @sample highcharts/series/type-dynamic/
  30719. * Dynamic types with button selector
  30720. * @sample {highmaps} maps/demo/mapline-mappoint/
  30721. * Multiple types in the same map
  30722. *
  30723. * @type {string}
  30724. * @apioption series.type
  30725. */
  30726. /**
  30727. * When using dual or multiple x axes, this number defines which xAxis the
  30728. * particular series is connected to. It refers to either the
  30729. * {@link #xAxis.id|axis id}
  30730. * or the index of the axis in the xAxis array, with 0 being the first.
  30731. *
  30732. * @type {number|string}
  30733. * @default 0
  30734. * @product highcharts highstock
  30735. * @apioption series.xAxis
  30736. */
  30737. /**
  30738. * When using dual or multiple y axes, this number defines which yAxis the
  30739. * particular series is connected to. It refers to either the
  30740. * {@link #yAxis.id|axis id}
  30741. * or the index of the axis in the yAxis array, with 0 being the first.
  30742. *
  30743. * @sample {highcharts} highcharts/series/yaxis/
  30744. * Apply the column series to the secondary Y axis
  30745. *
  30746. * @type {number|string}
  30747. * @default 0
  30748. * @product highcharts highstock
  30749. * @apioption series.yAxis
  30750. */
  30751. /**
  30752. * Define the visual z index of the series.
  30753. *
  30754. * @sample {highcharts} highcharts/plotoptions/series-zindex-default/
  30755. * With no z index, the series defined last are on top
  30756. * @sample {highcharts} highcharts/plotoptions/series-zindex/
  30757. * With a z index, the series with the highest z index is on top
  30758. * @sample {highstock} highcharts/plotoptions/series-zindex-default/
  30759. * With no z index, the series defined last are on top
  30760. * @sample {highstock} highcharts/plotoptions/series-zindex/
  30761. * With a z index, the series with the highest z index is on top
  30762. *
  30763. * @type {number}
  30764. * @product highcharts highstock
  30765. * @apioption series.zIndex
  30766. */
  30767. void 0,
  30768. /**
  30769. * General options for all series types.
  30770. *
  30771. * @optionparent plotOptions.series
  30772. */
  30773. {
  30774. /**
  30775. * The SVG value used for the `stroke-linecap` and `stroke-linejoin`
  30776. * of a line graph. Round means that lines are rounded in the ends and
  30777. * bends.
  30778. *
  30779. * @type {Highcharts.SeriesLinecapValue}
  30780. * @default round
  30781. * @since 3.0.7
  30782. * @apioption plotOptions.line.linecap
  30783. */
  30784. /**
  30785. * Pixel width of the graph line.
  30786. *
  30787. * @see In styled mode, the line stroke-width can be set with the
  30788. * `.highcharts-graph` class name.
  30789. *
  30790. * @sample {highcharts} highcharts/plotoptions/series-linewidth-general/
  30791. * On all series
  30792. * @sample {highcharts} highcharts/plotoptions/series-linewidth-specific/
  30793. * On one single series
  30794. *
  30795. * @product highcharts highstock
  30796. *
  30797. * @private
  30798. */
  30799. lineWidth: 2,
  30800. /**
  30801. * For some series, there is a limit that shuts down initial animation
  30802. * by default when the total number of points in the chart is too high.
  30803. * For example, for a column chart and its derivatives, animation does
  30804. * not run if there is more than 250 points totally. To disable this
  30805. * cap, set `animationLimit` to `Infinity`.
  30806. *
  30807. * @type {number}
  30808. * @apioption plotOptions.series.animationLimit
  30809. */
  30810. /**
  30811. * Allow this series' points to be selected by clicking on the graphic
  30812. * (columns, point markers, pie slices, map areas etc).
  30813. *
  30814. * The selected points can be handled by point select and unselect
  30815. * events, or collectively by the [getSelectedPoints
  30816. * ](/class-reference/Highcharts.Chart#getSelectedPoints) function.
  30817. *
  30818. * And alternative way of selecting points is through dragging.
  30819. *
  30820. * @sample {highcharts} highcharts/plotoptions/series-allowpointselect-line/
  30821. * Line
  30822. * @sample {highcharts} highcharts/plotoptions/series-allowpointselect-column/
  30823. * Column
  30824. * @sample {highcharts} highcharts/plotoptions/series-allowpointselect-pie/
  30825. * Pie
  30826. * @sample {highcharts} highcharts/chart/events-selection-points/
  30827. * Select a range of points through a drag selection
  30828. * @sample {highmaps} maps/plotoptions/series-allowpointselect/
  30829. * Map area
  30830. * @sample {highmaps} maps/plotoptions/mapbubble-allowpointselect/
  30831. * Map bubble
  30832. *
  30833. * @since 1.2.0
  30834. *
  30835. * @private
  30836. */
  30837. allowPointSelect: false,
  30838. /**
  30839. * When true, each point or column edge is rounded to its nearest pixel
  30840. * in order to render sharp on screen. In some cases, when there are a
  30841. * lot of densely packed columns, this leads to visible difference
  30842. * in column widths or distance between columns. In these cases,
  30843. * setting `crisp` to `false` may look better, even though each column
  30844. * is rendered blurry.
  30845. *
  30846. * @sample {highcharts} highcharts/plotoptions/column-crisp-false/
  30847. * Crisp is false
  30848. *
  30849. * @since 5.0.10
  30850. * @product highcharts highstock gantt
  30851. *
  30852. * @private
  30853. */
  30854. crisp: true,
  30855. /**
  30856. * If true, a checkbox is displayed next to the legend item to allow
  30857. * selecting the series. The state of the checkbox is determined by
  30858. * the `selected` option.
  30859. *
  30860. * @productdesc {highmaps}
  30861. * Note that if a `colorAxis` is defined, the color axis is represented
  30862. * in the legend, not the series.
  30863. *
  30864. * @sample {highcharts} highcharts/plotoptions/series-showcheckbox-true/
  30865. * Show select box
  30866. *
  30867. * @since 1.2.0
  30868. *
  30869. * @private
  30870. */
  30871. showCheckbox: false,
  30872. /**
  30873. * Enable or disable the initial animation when a series is displayed.
  30874. * The animation can also be set as a configuration object. Please
  30875. * note that this option only applies to the initial animation of the
  30876. * series itself. For other animations, see [chart.animation](
  30877. * #chart.animation) and the animation parameter under the API methods.
  30878. * The following properties are supported:
  30879. *
  30880. * - `defer`: The animation delay time in milliseconds.
  30881. *
  30882. * - `duration`: The duration of the animation in milliseconds.
  30883. *
  30884. * - `easing`: Can be a string reference to an easing function set on
  30885. * the `Math` object or a function. See the _Custom easing function_
  30886. * demo below.
  30887. *
  30888. * Due to poor performance, animation is disabled in old IE browsers
  30889. * for several chart types.
  30890. *
  30891. * @sample {highcharts} highcharts/plotoptions/series-animation-disabled/
  30892. * Animation disabled
  30893. * @sample {highcharts} highcharts/plotoptions/series-animation-slower/
  30894. * Slower animation
  30895. * @sample {highcharts} highcharts/plotoptions/series-animation-easing/
  30896. * Custom easing function
  30897. * @sample {highstock} stock/plotoptions/animation-slower/
  30898. * Slower animation
  30899. * @sample {highstock} stock/plotoptions/animation-easing/
  30900. * Custom easing function
  30901. * @sample {highmaps} maps/plotoptions/series-animation-true/
  30902. * Animation enabled on map series
  30903. * @sample {highmaps} maps/plotoptions/mapbubble-animation-false/
  30904. * Disabled on mapbubble series
  30905. *
  30906. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  30907. * @default {highcharts} true
  30908. * @default {highstock} true
  30909. * @default {highmaps} false
  30910. *
  30911. * @private
  30912. */
  30913. animation: {
  30914. /** @internal */
  30915. duration: 1000
  30916. },
  30917. /**
  30918. * @default 0
  30919. * @type {number}
  30920. * @since 8.2.0
  30921. * @apioption plotOptions.series.animation.defer
  30922. */
  30923. /**
  30924. * An additional class name to apply to the series' graphical elements.
  30925. * This option does not replace default class names of the graphical
  30926. * element.
  30927. *
  30928. * @type {string}
  30929. * @since 5.0.0
  30930. * @apioption plotOptions.series.className
  30931. */
  30932. /**
  30933. * Disable this option to allow series rendering in the whole plotting
  30934. * area.
  30935. *
  30936. * **Note:** Clipping should be always enabled when
  30937. * [chart.zoomType](#chart.zoomType) is set
  30938. *
  30939. * @sample {highcharts} highcharts/plotoptions/series-clip/
  30940. * Disabled clipping
  30941. *
  30942. * @default true
  30943. * @type {boolean}
  30944. * @since 3.0.0
  30945. * @apioption plotOptions.series.clip
  30946. */
  30947. /**
  30948. * The main color of the series. In line type series it applies to the
  30949. * line and the point markers unless otherwise specified. In bar type
  30950. * series it applies to the bars unless a color is specified per point.
  30951. * The default value is pulled from the `options.colors` array.
  30952. *
  30953. * In styled mode, the color can be defined by the
  30954. * [colorIndex](#plotOptions.series.colorIndex) option. Also, the series
  30955. * color can be set with the `.highcharts-series`,
  30956. * `.highcharts-color-{n}`, `.highcharts-{type}-series` or
  30957. * `.highcharts-series-{n}` class, or individual classes given by the
  30958. * `className` option.
  30959. *
  30960. * @productdesc {highmaps}
  30961. * In maps, the series color is rarely used, as most choropleth maps use
  30962. * the color to denote the value of each point. The series color can
  30963. * however be used in a map with multiple series holding categorized
  30964. * data.
  30965. *
  30966. * @sample {highcharts} highcharts/plotoptions/series-color-general/
  30967. * General plot option
  30968. * @sample {highcharts} highcharts/plotoptions/series-color-specific/
  30969. * One specific series
  30970. * @sample {highcharts} highcharts/plotoptions/series-color-area/
  30971. * Area color
  30972. * @sample {highcharts} highcharts/series/infographic/
  30973. * Pattern fill
  30974. * @sample {highmaps} maps/demo/category-map/
  30975. * Category map by multiple series
  30976. *
  30977. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  30978. * @apioption plotOptions.series.color
  30979. */
  30980. /**
  30981. * Styled mode only. A specific color index to use for the series, so
  30982. * its graphic representations are given the class name
  30983. * `highcharts-color-{n}`.
  30984. *
  30985. * @type {number}
  30986. * @since 5.0.0
  30987. * @apioption plotOptions.series.colorIndex
  30988. */
  30989. /**
  30990. * Whether to connect a graph line across null points, or render a gap
  30991. * between the two points on either side of the null.
  30992. *
  30993. * @sample {highcharts} highcharts/plotoptions/series-connectnulls-false/
  30994. * False by default
  30995. * @sample {highcharts} highcharts/plotoptions/series-connectnulls-true/
  30996. * True
  30997. *
  30998. * @type {boolean}
  30999. * @default false
  31000. * @product highcharts highstock
  31001. * @apioption plotOptions.series.connectNulls
  31002. */
  31003. /**
  31004. * You can set the cursor to "pointer" if you have click events attached
  31005. * to the series, to signal to the user that the points and lines can
  31006. * be clicked.
  31007. *
  31008. * In styled mode, the series cursor can be set with the same classes
  31009. * as listed under [series.color](#plotOptions.series.color).
  31010. *
  31011. * @sample {highcharts} highcharts/plotoptions/series-cursor-line/
  31012. * On line graph
  31013. * @sample {highcharts} highcharts/plotoptions/series-cursor-column/
  31014. * On columns
  31015. * @sample {highcharts} highcharts/plotoptions/series-cursor-scatter/
  31016. * On scatter markers
  31017. * @sample {highstock} stock/plotoptions/cursor/
  31018. * Pointer on a line graph
  31019. * @sample {highmaps} maps/plotoptions/series-allowpointselect/
  31020. * Map area
  31021. * @sample {highmaps} maps/plotoptions/mapbubble-allowpointselect/
  31022. * Map bubble
  31023. *
  31024. * @type {string|Highcharts.CursorValue}
  31025. * @apioption plotOptions.series.cursor
  31026. */
  31027. /**
  31028. * A reserved subspace to store options and values for customized
  31029. * functionality. Here you can add additional data for your own event
  31030. * callbacks and formatter callbacks.
  31031. *
  31032. * @sample {highcharts} highcharts/point/custom/
  31033. * Point and series with custom data
  31034. *
  31035. * @type {Highcharts.Dictionary<*>}
  31036. * @apioption plotOptions.series.custom
  31037. */
  31038. /**
  31039. * Name of the dash style to use for the graph, or for some series types
  31040. * the outline of each shape.
  31041. *
  31042. * In styled mode, the
  31043. * [stroke dash-array](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/css/series-dashstyle/)
  31044. * can be set with the same classes as listed under
  31045. * [series.color](#plotOptions.series.color).
  31046. *
  31047. * @sample {highcharts} highcharts/plotoptions/series-dashstyle-all/
  31048. * Possible values demonstrated
  31049. * @sample {highcharts} highcharts/plotoptions/series-dashstyle/
  31050. * Chart suitable for printing in black and white
  31051. * @sample {highstock} highcharts/plotoptions/series-dashstyle-all/
  31052. * Possible values demonstrated
  31053. * @sample {highmaps} highcharts/plotoptions/series-dashstyle-all/
  31054. * Possible values demonstrated
  31055. * @sample {highmaps} maps/plotoptions/series-dashstyle/
  31056. * Dotted borders on a map
  31057. *
  31058. * @type {Highcharts.DashStyleValue}
  31059. * @default Solid
  31060. * @since 2.1
  31061. * @apioption plotOptions.series.dashStyle
  31062. */
  31063. /**
  31064. * A description of the series to add to the screen reader information
  31065. * about the series.
  31066. *
  31067. * @type {string}
  31068. * @since 5.0.0
  31069. * @requires modules/accessibility
  31070. * @apioption plotOptions.series.description
  31071. */
  31072. /**
  31073. * Options for the series data sorting.
  31074. *
  31075. * @type {Highcharts.DataSortingOptionsObject}
  31076. * @since 8.0.0
  31077. * @product highcharts highstock
  31078. * @apioption plotOptions.series.dataSorting
  31079. */
  31080. /**
  31081. * Enable or disable data sorting for the series. Use [xAxis.reversed](
  31082. * #xAxis.reversed) to change the sorting order.
  31083. *
  31084. * @sample {highcharts} highcharts/datasorting/animation/
  31085. * Data sorting in scatter-3d
  31086. * @sample {highcharts} highcharts/datasorting/labels-animation/
  31087. * Axis labels animation
  31088. * @sample {highcharts} highcharts/datasorting/dependent-sorting/
  31089. * Dependent series sorting
  31090. * @sample {highcharts} highcharts/datasorting/independent-sorting/
  31091. * Independent series sorting
  31092. *
  31093. * @type {boolean}
  31094. * @since 8.0.0
  31095. * @apioption plotOptions.series.dataSorting.enabled
  31096. */
  31097. /**
  31098. * Whether to allow matching points by name in an update. If this option
  31099. * is disabled, points will be matched by order.
  31100. *
  31101. * @sample {highcharts} highcharts/datasorting/match-by-name/
  31102. * Enabled match by name
  31103. *
  31104. * @type {boolean}
  31105. * @since 8.0.0
  31106. * @apioption plotOptions.series.dataSorting.matchByName
  31107. */
  31108. /**
  31109. * Determines what data value should be used to sort by.
  31110. *
  31111. * @sample {highcharts} highcharts/datasorting/sort-key/
  31112. * Sort key as `z` value
  31113. *
  31114. * @type {string}
  31115. * @since 8.0.0
  31116. * @default y
  31117. * @apioption plotOptions.series.dataSorting.sortKey
  31118. */
  31119. /**
  31120. * Enable or disable the mouse tracking for a specific series. This
  31121. * includes point tooltips and click events on graphs and points. For
  31122. * large datasets it improves performance.
  31123. *
  31124. * @sample {highcharts} highcharts/plotoptions/series-enablemousetracking-false/
  31125. * No mouse tracking
  31126. * @sample {highmaps} maps/plotoptions/series-enablemousetracking-false/
  31127. * No mouse tracking
  31128. *
  31129. * @type {boolean}
  31130. * @default true
  31131. * @apioption plotOptions.series.enableMouseTracking
  31132. */
  31133. /**
  31134. * Whether to use the Y extremes of the total chart width or only the
  31135. * zoomed area when zooming in on parts of the X axis. By default, the
  31136. * Y axis adjusts to the min and max of the visible data. Cartesian
  31137. * series only.
  31138. *
  31139. * @type {boolean}
  31140. * @default false
  31141. * @since 4.1.6
  31142. * @product highcharts highstock gantt
  31143. * @apioption plotOptions.series.getExtremesFromAll
  31144. */
  31145. /**
  31146. * An array specifying which option maps to which key in the data point
  31147. * array. This makes it convenient to work with unstructured data arrays
  31148. * from different sources.
  31149. *
  31150. * @see [series.data](#series.line.data)
  31151. *
  31152. * @sample {highcharts|highstock} highcharts/series/data-keys/
  31153. * An extended data array with keys
  31154. * @sample {highcharts|highstock} highcharts/series/data-nested-keys/
  31155. * Nested keys used to access object properties
  31156. *
  31157. * @type {Array<string>}
  31158. * @since 4.1.6
  31159. * @apioption plotOptions.series.keys
  31160. */
  31161. /**
  31162. * The line cap used for line ends and line joins on the graph.
  31163. *
  31164. * @type {Highcharts.SeriesLinecapValue}
  31165. * @default round
  31166. * @product highcharts highstock
  31167. * @apioption plotOptions.series.linecap
  31168. */
  31169. /**
  31170. * The [id](#series.id) of another series to link to. Additionally,
  31171. * the value can be ":previous" to link to the previous series. When
  31172. * two series are linked, only the first one appears in the legend.
  31173. * Toggling the visibility of this also toggles the linked series.
  31174. *
  31175. * If master series uses data sorting and linked series does not have
  31176. * its own sorting definition, the linked series will be sorted in the
  31177. * same order as the master one.
  31178. *
  31179. * @sample {highcharts|highstock} highcharts/demo/arearange-line/
  31180. * Linked series
  31181. *
  31182. * @type {string}
  31183. * @since 3.0
  31184. * @product highcharts highstock gantt
  31185. * @apioption plotOptions.series.linkedTo
  31186. */
  31187. /**
  31188. * Options for the corresponding navigator series if `showInNavigator`
  31189. * is `true` for this series. Available options are the same as any
  31190. * series, documented at [plotOptions](#plotOptions.series) and
  31191. * [series](#series).
  31192. *
  31193. * These options are merged with options in [navigator.series](
  31194. * #navigator.series), and will take precedence if the same option is
  31195. * defined both places.
  31196. *
  31197. * @see [navigator.series](#navigator.series)
  31198. *
  31199. * @type {Highcharts.PlotSeriesOptions}
  31200. * @since 5.0.0
  31201. * @product highstock
  31202. * @apioption plotOptions.series.navigatorOptions
  31203. */
  31204. /**
  31205. * The color for the parts of the graph or points that are below the
  31206. * [threshold](#plotOptions.series.threshold). Note that `zones` takes
  31207. * precedence over the negative color. Using `negativeColor` is
  31208. * equivalent to applying a zone with value of 0.
  31209. *
  31210. * @see In styled mode, a negative color is applied by setting this option
  31211. * to `true` combined with the `.highcharts-negative` class name.
  31212. *
  31213. * @sample {highcharts} highcharts/plotoptions/series-negative-color/
  31214. * Spline, area and column
  31215. * @sample {highcharts} highcharts/plotoptions/arearange-negativecolor/
  31216. * Arearange
  31217. * @sample {highcharts} highcharts/css/series-negative-color/
  31218. * Styled mode
  31219. * @sample {highstock} highcharts/plotoptions/series-negative-color/
  31220. * Spline, area and column
  31221. * @sample {highstock} highcharts/plotoptions/arearange-negativecolor/
  31222. * Arearange
  31223. * @sample {highmaps} highcharts/plotoptions/series-negative-color/
  31224. * Spline, area and column
  31225. * @sample {highmaps} highcharts/plotoptions/arearange-negativecolor/
  31226. * Arearange
  31227. *
  31228. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  31229. * @since 3.0
  31230. * @apioption plotOptions.series.negativeColor
  31231. */
  31232. /**
  31233. * Same as
  31234. * [accessibility.pointDescriptionFormatter](#accessibility.pointDescriptionFormatter),
  31235. * but for an individual series. Overrides the chart wide configuration.
  31236. *
  31237. * @type {Function}
  31238. * @since 5.0.12
  31239. * @apioption plotOptions.series.pointDescriptionFormatter
  31240. */
  31241. /**
  31242. * If no x values are given for the points in a series, `pointInterval`
  31243. * defines the interval of the x values. For example, if a series
  31244. * contains one value every decade starting from year 0, set
  31245. * `pointInterval` to `10`. In true `datetime` axes, the `pointInterval`
  31246. * is set in milliseconds.
  31247. *
  31248. * It can be also be combined with `pointIntervalUnit` to draw irregular
  31249. * time intervals.
  31250. *
  31251. * Please note that this options applies to the _series data_, not the
  31252. * interval of the axis ticks, which is independent.
  31253. *
  31254. * @sample {highcharts} highcharts/plotoptions/series-pointstart-datetime/
  31255. * Datetime X axis
  31256. * @sample {highstock} stock/plotoptions/pointinterval-pointstart/
  31257. * Using pointStart and pointInterval
  31258. *
  31259. * @type {number}
  31260. * @default 1
  31261. * @product highcharts highstock gantt
  31262. * @apioption plotOptions.series.pointInterval
  31263. */
  31264. /**
  31265. * On datetime series, this allows for setting the
  31266. * [pointInterval](#plotOptions.series.pointInterval) to irregular time
  31267. * units, `day`, `month` and `year`. A day is usually the same as 24
  31268. * hours, but `pointIntervalUnit` also takes the DST crossover into
  31269. * consideration when dealing with local time. Combine this option with
  31270. * `pointInterval` to draw weeks, quarters, 6 months, 10 years etc.
  31271. *
  31272. * Please note that this options applies to the _series data_, not the
  31273. * interval of the axis ticks, which is independent.
  31274. *
  31275. * @sample {highcharts} highcharts/plotoptions/series-pointintervalunit/
  31276. * One point a month
  31277. * @sample {highstock} highcharts/plotoptions/series-pointintervalunit/
  31278. * One point a month
  31279. *
  31280. * @type {string}
  31281. * @since 4.1.0
  31282. * @product highcharts highstock gantt
  31283. * @validvalue ["day", "month", "year"]
  31284. * @apioption plotOptions.series.pointIntervalUnit
  31285. */
  31286. /**
  31287. * Possible values: `"on"`, `"between"`, `number`.
  31288. *
  31289. * In a column chart, when pointPlacement is `"on"`, the point will not
  31290. * create any padding of the X axis. In a polar column chart this means
  31291. * that the first column points directly north. If the pointPlacement is
  31292. * `"between"`, the columns will be laid out between ticks. This is
  31293. * useful for example for visualising an amount between two points in
  31294. * time or in a certain sector of a polar chart.
  31295. *
  31296. * Since Highcharts 3.0.2, the point placement can also be numeric,
  31297. * where 0 is on the axis value, -0.5 is between this value and the
  31298. * previous, and 0.5 is between this value and the next. Unlike the
  31299. * textual options, numeric point placement options won't affect axis
  31300. * padding.
  31301. *
  31302. * Note that pointPlacement needs a [pointRange](
  31303. * #plotOptions.series.pointRange) to work. For column series this is
  31304. * computed, but for line-type series it needs to be set.
  31305. *
  31306. * For the `xrange` series type and gantt charts, if the Y axis is a
  31307. * category axis, the `pointPlacement` applies to the Y axis rather than
  31308. * the (typically datetime) X axis.
  31309. *
  31310. * Defaults to `undefined` in cartesian charts, `"between"` in polar
  31311. * charts.
  31312. *
  31313. * @see [xAxis.tickmarkPlacement](#xAxis.tickmarkPlacement)
  31314. *
  31315. * @sample {highcharts|highstock} highcharts/plotoptions/series-pointplacement-between/
  31316. * Between in a column chart
  31317. * @sample {highcharts|highstock} highcharts/plotoptions/series-pointplacement-numeric/
  31318. * Numeric placement for custom layout
  31319. * @sample {highcharts|highstock} maps/plotoptions/heatmap-pointplacement/
  31320. * Placement in heatmap
  31321. *
  31322. * @type {string|number}
  31323. * @since 2.3.0
  31324. * @product highcharts highstock gantt
  31325. * @apioption plotOptions.series.pointPlacement
  31326. */
  31327. /**
  31328. * If no x values are given for the points in a series, pointStart
  31329. * defines on what value to start. For example, if a series contains one
  31330. * yearly value starting from 1945, set pointStart to 1945.
  31331. *
  31332. * @sample {highcharts} highcharts/plotoptions/series-pointstart-linear/
  31333. * Linear
  31334. * @sample {highcharts} highcharts/plotoptions/series-pointstart-datetime/
  31335. * Datetime
  31336. * @sample {highstock} stock/plotoptions/pointinterval-pointstart/
  31337. * Using pointStart and pointInterval
  31338. *
  31339. * @type {number}
  31340. * @default 0
  31341. * @product highcharts highstock gantt
  31342. * @apioption plotOptions.series.pointStart
  31343. */
  31344. /**
  31345. * Whether to select the series initially. If `showCheckbox` is true,
  31346. * the checkbox next to the series name in the legend will be checked
  31347. * for a selected series.
  31348. *
  31349. * @sample {highcharts} highcharts/plotoptions/series-selected/
  31350. * One out of two series selected
  31351. *
  31352. * @type {boolean}
  31353. * @default false
  31354. * @since 1.2.0
  31355. * @apioption plotOptions.series.selected
  31356. */
  31357. /**
  31358. * Whether to apply a drop shadow to the graph line. Since 2.3 the
  31359. * shadow can be an object configuration containing `color`, `offsetX`,
  31360. * `offsetY`, `opacity` and `width`.
  31361. *
  31362. * @sample {highcharts} highcharts/plotoptions/series-shadow/
  31363. * Shadow enabled
  31364. *
  31365. * @type {boolean|Highcharts.ShadowOptionsObject}
  31366. * @default false
  31367. * @apioption plotOptions.series.shadow
  31368. */
  31369. /**
  31370. * Whether to display this particular series or series type in the
  31371. * legend. Standalone series are shown in legend by default, and linked
  31372. * series are not. Since v7.2.0 it is possible to show series that use
  31373. * colorAxis by setting this option to `true`.
  31374. *
  31375. * @sample {highcharts} highcharts/plotoptions/series-showinlegend/
  31376. * One series in the legend, one hidden
  31377. *
  31378. * @type {boolean}
  31379. * @apioption plotOptions.series.showInLegend
  31380. */
  31381. /**
  31382. * Whether or not to show the series in the navigator. Takes precedence
  31383. * over [navigator.baseSeries](#navigator.baseSeries) if defined.
  31384. *
  31385. * @type {boolean}
  31386. * @since 5.0.0
  31387. * @product highstock
  31388. * @apioption plotOptions.series.showInNavigator
  31389. */
  31390. /**
  31391. * If set to `true`, the accessibility module will skip past the points
  31392. * in this series for keyboard navigation.
  31393. *
  31394. * @type {boolean}
  31395. * @since 5.0.12
  31396. * @apioption plotOptions.series.skipKeyboardNavigation
  31397. */
  31398. /**
  31399. * Whether to stack the values of each series on top of each other.
  31400. * Possible values are `undefined` to disable, `"normal"` to stack by
  31401. * value or `"percent"`.
  31402. *
  31403. * When stacking is enabled, data must be sorted
  31404. * in ascending X order.
  31405. *
  31406. * Some stacking options are related to specific series types. In the
  31407. * streamgraph series type, the stacking option is set to `"stream"`.
  31408. * The second one is `"overlap"`, which only applies to waterfall
  31409. * series.
  31410. *
  31411. * @see [yAxis.reversedStacks](#yAxis.reversedStacks)
  31412. *
  31413. * @sample {highcharts} highcharts/plotoptions/series-stacking-line/
  31414. * Line
  31415. * @sample {highcharts} highcharts/plotoptions/series-stacking-column/
  31416. * Column
  31417. * @sample {highcharts} highcharts/plotoptions/series-stacking-bar/
  31418. * Bar
  31419. * @sample {highcharts} highcharts/plotoptions/series-stacking-area/
  31420. * Area
  31421. * @sample {highcharts} highcharts/plotoptions/series-stacking-percent-line/
  31422. * Line
  31423. * @sample {highcharts} highcharts/plotoptions/series-stacking-percent-column/
  31424. * Column
  31425. * @sample {highcharts} highcharts/plotoptions/series-stacking-percent-bar/
  31426. * Bar
  31427. * @sample {highcharts} highcharts/plotoptions/series-stacking-percent-area/
  31428. * Area
  31429. * @sample {highcharts} highcharts/plotoptions/series-waterfall-with-normal-stacking
  31430. * Waterfall with normal stacking
  31431. * @sample {highcharts} highcharts/plotoptions/series-waterfall-with-overlap-stacking
  31432. * Waterfall with overlap stacking
  31433. * @sample {highstock} stock/plotoptions/stacking/
  31434. * Area
  31435. *
  31436. * @type {string}
  31437. * @product highcharts highstock
  31438. * @validvalue ["normal", "overlap", "percent", "stream"]
  31439. * @apioption plotOptions.series.stacking
  31440. */
  31441. /**
  31442. * Whether to apply steps to the line. Possible values are `left`,
  31443. * `center` and `right`.
  31444. *
  31445. * @sample {highcharts} highcharts/plotoptions/line-step/
  31446. * Different step line options
  31447. * @sample {highcharts} highcharts/plotoptions/area-step/
  31448. * Stepped, stacked area
  31449. * @sample {highstock} stock/plotoptions/line-step/
  31450. * Step line
  31451. *
  31452. * @type {string}
  31453. * @since 1.2.5
  31454. * @product highcharts highstock
  31455. * @validvalue ["left", "center", "right"]
  31456. * @apioption plotOptions.series.step
  31457. */
  31458. /**
  31459. * The threshold, also called zero level or base level. For line type
  31460. * series this is only used in conjunction with
  31461. * [negativeColor](#plotOptions.series.negativeColor).
  31462. *
  31463. * @see [softThreshold](#plotOptions.series.softThreshold).
  31464. *
  31465. * @type {number}
  31466. * @default 0
  31467. * @since 3.0
  31468. * @product highcharts highstock
  31469. * @apioption plotOptions.series.threshold
  31470. */
  31471. /**
  31472. * Set the initial visibility of the series.
  31473. *
  31474. * @sample {highcharts} highcharts/plotoptions/series-visible/
  31475. * Two series, one hidden and one visible
  31476. * @sample {highstock} stock/plotoptions/series-visibility/
  31477. * Hidden series
  31478. *
  31479. * @type {boolean}
  31480. * @default true
  31481. * @apioption plotOptions.series.visible
  31482. */
  31483. /**
  31484. * Defines the Axis on which the zones are applied.
  31485. *
  31486. * @see [zones](#plotOptions.series.zones)
  31487. *
  31488. * @sample {highcharts} highcharts/series/color-zones-zoneaxis-x/
  31489. * Zones on the X-Axis
  31490. * @sample {highstock} highcharts/series/color-zones-zoneaxis-x/
  31491. * Zones on the X-Axis
  31492. *
  31493. * @type {string}
  31494. * @default y
  31495. * @since 4.1.0
  31496. * @product highcharts highstock
  31497. * @apioption plotOptions.series.zoneAxis
  31498. */
  31499. /**
  31500. * General event handlers for the series items. These event hooks can
  31501. * also be attached to the series at run time using the
  31502. * `Highcharts.addEvent` function.
  31503. *
  31504. * @declare Highcharts.SeriesEventsOptionsObject
  31505. *
  31506. * @private
  31507. */
  31508. events: {},
  31509. /**
  31510. * Fires after the series has finished its initial animation, or in case
  31511. * animation is disabled, immediately as the series is displayed.
  31512. *
  31513. * @sample {highcharts} highcharts/plotoptions/series-events-afteranimate/
  31514. * Show label after animate
  31515. * @sample {highstock} highcharts/plotoptions/series-events-afteranimate/
  31516. * Show label after animate
  31517. *
  31518. * @type {Highcharts.SeriesAfterAnimateCallbackFunction}
  31519. * @since 4.0
  31520. * @product highcharts highstock gantt
  31521. * @context Highcharts.Series
  31522. * @apioption plotOptions.series.events.afterAnimate
  31523. */
  31524. /**
  31525. * Fires when the checkbox next to the series' name in the legend is
  31526. * clicked. One parameter, `event`, is passed to the function. The state
  31527. * of the checkbox is found by `event.checked`. The checked item is
  31528. * found by `event.item`. Return `false` to prevent the default action
  31529. * which is to toggle the select state of the series.
  31530. *
  31531. * @sample {highcharts} highcharts/plotoptions/series-events-checkboxclick/
  31532. * Alert checkbox status
  31533. *
  31534. * @type {Highcharts.SeriesCheckboxClickCallbackFunction}
  31535. * @since 1.2.0
  31536. * @context Highcharts.Series
  31537. * @apioption plotOptions.series.events.checkboxClick
  31538. */
  31539. /**
  31540. * Fires when the series is clicked. One parameter, `event`, is passed
  31541. * to the function, containing common event information. Additionally,
  31542. * `event.point` holds a pointer to the nearest point on the graph.
  31543. *
  31544. * @sample {highcharts} highcharts/plotoptions/series-events-click/
  31545. * Alert click info
  31546. * @sample {highstock} stock/plotoptions/series-events-click/
  31547. * Alert click info
  31548. * @sample {highmaps} maps/plotoptions/series-events-click/
  31549. * Display click info in subtitle
  31550. *
  31551. * @type {Highcharts.SeriesClickCallbackFunction}
  31552. * @context Highcharts.Series
  31553. * @apioption plotOptions.series.events.click
  31554. */
  31555. /**
  31556. * Fires when the series is hidden after chart generation time, either
  31557. * by clicking the legend item or by calling `.hide()`.
  31558. *
  31559. * @sample {highcharts} highcharts/plotoptions/series-events-hide/
  31560. * Alert when the series is hidden by clicking the legend item
  31561. *
  31562. * @type {Highcharts.SeriesHideCallbackFunction}
  31563. * @since 1.2.0
  31564. * @context Highcharts.Series
  31565. * @apioption plotOptions.series.events.hide
  31566. */
  31567. /**
  31568. * Fires when the legend item belonging to the series is clicked. One
  31569. * parameter, `event`, is passed to the function. The default action
  31570. * is to toggle the visibility of the series. This can be prevented
  31571. * by returning `false` or calling `event.preventDefault()`.
  31572. *
  31573. * @sample {highcharts} highcharts/plotoptions/series-events-legenditemclick/
  31574. * Confirm hiding and showing
  31575. *
  31576. * @type {Highcharts.SeriesLegendItemClickCallbackFunction}
  31577. * @context Highcharts.Series
  31578. * @apioption plotOptions.series.events.legendItemClick
  31579. */
  31580. /**
  31581. * Fires when the mouse leaves the graph. One parameter, `event`, is
  31582. * passed to the function, containing common event information. If the
  31583. * [stickyTracking](#plotOptions.series) option is true, `mouseOut`
  31584. * doesn't happen before the mouse enters another graph or leaves the
  31585. * plot area.
  31586. *
  31587. * @sample {highcharts} highcharts/plotoptions/series-events-mouseover-sticky/
  31588. * With sticky tracking by default
  31589. * @sample {highcharts} highcharts/plotoptions/series-events-mouseover-no-sticky/
  31590. * Without sticky tracking
  31591. *
  31592. * @type {Highcharts.SeriesMouseOutCallbackFunction}
  31593. * @context Highcharts.Series
  31594. * @apioption plotOptions.series.events.mouseOut
  31595. */
  31596. /**
  31597. * Fires when the mouse enters the graph. One parameter, `event`, is
  31598. * passed to the function, containing common event information.
  31599. *
  31600. * @sample {highcharts} highcharts/plotoptions/series-events-mouseover-sticky/
  31601. * With sticky tracking by default
  31602. * @sample {highcharts} highcharts/plotoptions/series-events-mouseover-no-sticky/
  31603. * Without sticky tracking
  31604. *
  31605. * @type {Highcharts.SeriesMouseOverCallbackFunction}
  31606. * @context Highcharts.Series
  31607. * @apioption plotOptions.series.events.mouseOver
  31608. */
  31609. /**
  31610. * Fires when the series is shown after chart generation time, either
  31611. * by clicking the legend item or by calling `.show()`.
  31612. *
  31613. * @sample {highcharts} highcharts/plotoptions/series-events-show/
  31614. * Alert when the series is shown by clicking the legend item.
  31615. *
  31616. * @type {Highcharts.SeriesShowCallbackFunction}
  31617. * @since 1.2.0
  31618. * @context Highcharts.Series
  31619. * @apioption plotOptions.series.events.show
  31620. */
  31621. /**
  31622. * Options for the point markers of line-like series. Properties like
  31623. * `fillColor`, `lineColor` and `lineWidth` define the visual appearance
  31624. * of the markers. Other series types, like column series, don't have
  31625. * markers, but have visual options on the series level instead.
  31626. *
  31627. * In styled mode, the markers can be styled with the
  31628. * `.highcharts-point`, `.highcharts-point-hover` and
  31629. * `.highcharts-point-select` class names.
  31630. *
  31631. * @declare Highcharts.PointMarkerOptionsObject
  31632. *
  31633. * @private
  31634. */
  31635. marker: {
  31636. /**
  31637. * Enable or disable the point marker. If `undefined`, the markers
  31638. * are hidden when the data is dense, and shown for more widespread
  31639. * data points.
  31640. *
  31641. * @sample {highcharts} highcharts/plotoptions/series-marker-enabled/
  31642. * Disabled markers
  31643. * @sample {highcharts} highcharts/plotoptions/series-marker-enabled-false/
  31644. * Disabled in normal state but enabled on hover
  31645. * @sample {highstock} stock/plotoptions/series-marker/
  31646. * Enabled markers
  31647. *
  31648. * @type {boolean}
  31649. * @default {highcharts} undefined
  31650. * @default {highstock} false
  31651. * @apioption plotOptions.series.marker.enabled
  31652. */
  31653. /**
  31654. * The threshold for how dense the point markers should be before
  31655. * they are hidden, given that `enabled` is not defined. The number
  31656. * indicates the horizontal distance between the two closest points
  31657. * in the series, as multiples of the `marker.radius`. In other
  31658. * words, the default value of 2 means points are hidden if
  31659. * overlapping horizontally.
  31660. *
  31661. * @sample highcharts/plotoptions/series-marker-enabledthreshold
  31662. * A higher threshold
  31663. *
  31664. * @since 6.0.5
  31665. */
  31666. enabledThreshold: 2,
  31667. /**
  31668. * The fill color of the point marker. When `undefined`, the series'
  31669. * or point's color is used.
  31670. *
  31671. * @sample {highcharts} highcharts/plotoptions/series-marker-fillcolor/
  31672. * White fill
  31673. *
  31674. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  31675. * @apioption plotOptions.series.marker.fillColor
  31676. */
  31677. /**
  31678. * Image markers only. Set the image width explicitly. When using
  31679. * this option, a `width` must also be set.
  31680. *
  31681. * @sample {highcharts} highcharts/plotoptions/series-marker-width-height/
  31682. * Fixed width and height
  31683. * @sample {highstock} highcharts/plotoptions/series-marker-width-height/
  31684. * Fixed width and height
  31685. *
  31686. * @type {number}
  31687. * @since 4.0.4
  31688. * @apioption plotOptions.series.marker.height
  31689. */
  31690. /**
  31691. * The color of the point marker's outline. When `undefined`, the
  31692. * series' or point's color is used.
  31693. *
  31694. * @sample {highcharts} highcharts/plotoptions/series-marker-fillcolor/
  31695. * Inherit from series color (undefined)
  31696. *
  31697. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  31698. */
  31699. lineColor: '#ffffff',
  31700. /**
  31701. * The width of the point marker's outline.
  31702. *
  31703. * @sample {highcharts} highcharts/plotoptions/series-marker-fillcolor/
  31704. * 2px blue marker
  31705. */
  31706. lineWidth: 0,
  31707. /**
  31708. * The radius of the point marker.
  31709. *
  31710. * @sample {highcharts} highcharts/plotoptions/series-marker-radius/
  31711. * Bigger markers
  31712. *
  31713. * @default {highstock} 2
  31714. */
  31715. radius: 4,
  31716. /**
  31717. * A predefined shape or symbol for the marker. When undefined, the
  31718. * symbol is pulled from options.symbols. Other possible values are
  31719. * `'circle'`, `'square'`,`'diamond'`, `'triangle'` and
  31720. * `'triangle-down'`.
  31721. *
  31722. * Additionally, the URL to a graphic can be given on this form:
  31723. * `'url(graphic.png)'`. Note that for the image to be applied to
  31724. * exported charts, its URL needs to be accessible by the export
  31725. * server.
  31726. *
  31727. * Custom callbacks for symbol path generation can also be added to
  31728. * `Highcharts.SVGRenderer.prototype.symbols`. The callback is then
  31729. * used by its method name, as shown in the demo.
  31730. *
  31731. * @sample {highcharts} highcharts/plotoptions/series-marker-symbol/
  31732. * Predefined, graphic and custom markers
  31733. * @sample {highstock} highcharts/plotoptions/series-marker-symbol/
  31734. * Predefined, graphic and custom markers
  31735. *
  31736. * @type {string}
  31737. * @apioption plotOptions.series.marker.symbol
  31738. */
  31739. /**
  31740. * Image markers only. Set the image width explicitly. When using
  31741. * this option, a `height` must also be set.
  31742. *
  31743. * @sample {highcharts} highcharts/plotoptions/series-marker-width-height/
  31744. * Fixed width and height
  31745. * @sample {highstock} highcharts/plotoptions/series-marker-width-height/
  31746. * Fixed width and height
  31747. *
  31748. * @type {number}
  31749. * @since 4.0.4
  31750. * @apioption plotOptions.series.marker.width
  31751. */
  31752. /**
  31753. * States for a single point marker.
  31754. *
  31755. * @declare Highcharts.PointStatesOptionsObject
  31756. */
  31757. states: {
  31758. /**
  31759. * The normal state of a single point marker. Currently only
  31760. * used for setting animation when returning to normal state
  31761. * from hover.
  31762. *
  31763. * @declare Highcharts.PointStatesNormalOptionsObject
  31764. */
  31765. normal: {
  31766. /**
  31767. * Animation when returning to normal state after hovering.
  31768. *
  31769. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  31770. */
  31771. animation: true
  31772. },
  31773. /**
  31774. * The hover state for a single point marker.
  31775. *
  31776. * @declare Highcharts.PointStatesHoverOptionsObject
  31777. */
  31778. hover: {
  31779. /**
  31780. * Animation when hovering over the marker.
  31781. *
  31782. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  31783. */
  31784. animation: {
  31785. /** @internal */
  31786. duration: 50
  31787. },
  31788. /**
  31789. * Enable or disable the point marker.
  31790. *
  31791. * @sample {highcharts} highcharts/plotoptions/series-marker-states-hover-enabled/
  31792. * Disabled hover state
  31793. */
  31794. enabled: true,
  31795. /**
  31796. * The fill color of the marker in hover state. When
  31797. * `undefined`, the series' or point's fillColor for normal
  31798. * state is used.
  31799. *
  31800. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  31801. * @apioption plotOptions.series.marker.states.hover.fillColor
  31802. */
  31803. /**
  31804. * The color of the point marker's outline. When
  31805. * `undefined`, the series' or point's lineColor for normal
  31806. * state is used.
  31807. *
  31808. * @sample {highcharts} highcharts/plotoptions/series-marker-states-hover-linecolor/
  31809. * White fill color, black line color
  31810. *
  31811. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  31812. * @apioption plotOptions.series.marker.states.hover.lineColor
  31813. */
  31814. /**
  31815. * The width of the point marker's outline. When
  31816. * `undefined`, the series' or point's lineWidth for normal
  31817. * state is used.
  31818. *
  31819. * @sample {highcharts} highcharts/plotoptions/series-marker-states-hover-linewidth/
  31820. * 3px line width
  31821. *
  31822. * @type {number}
  31823. * @apioption plotOptions.series.marker.states.hover.lineWidth
  31824. */
  31825. /**
  31826. * The radius of the point marker. In hover state, it
  31827. * defaults to the normal state's radius + 2 as per the
  31828. * [radiusPlus](#plotOptions.series.marker.states.hover.radiusPlus)
  31829. * option.
  31830. *
  31831. * @sample {highcharts} highcharts/plotoptions/series-marker-states-hover-radius/
  31832. * 10px radius
  31833. *
  31834. * @type {number}
  31835. * @apioption plotOptions.series.marker.states.hover.radius
  31836. */
  31837. /**
  31838. * The number of pixels to increase the radius of the
  31839. * hovered point.
  31840. *
  31841. * @sample {highcharts} highcharts/plotoptions/series-states-hover-linewidthplus/
  31842. * 5 pixels greater radius on hover
  31843. * @sample {highstock} highcharts/plotoptions/series-states-hover-linewidthplus/
  31844. * 5 pixels greater radius on hover
  31845. *
  31846. * @since 4.0.3
  31847. */
  31848. radiusPlus: 2,
  31849. /**
  31850. * The additional line width for a hovered point.
  31851. *
  31852. * @sample {highcharts} highcharts/plotoptions/series-states-hover-linewidthplus/
  31853. * 2 pixels wider on hover
  31854. * @sample {highstock} highcharts/plotoptions/series-states-hover-linewidthplus/
  31855. * 2 pixels wider on hover
  31856. *
  31857. * @since 4.0.3
  31858. */
  31859. lineWidthPlus: 1
  31860. },
  31861. /**
  31862. * The appearance of the point marker when selected. In order to
  31863. * allow a point to be selected, set the
  31864. * `series.allowPointSelect` option to true.
  31865. *
  31866. * @declare Highcharts.PointStatesSelectOptionsObject
  31867. */
  31868. select: {
  31869. /**
  31870. * Enable or disable visible feedback for selection.
  31871. *
  31872. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-enabled/
  31873. * Disabled select state
  31874. *
  31875. * @type {boolean}
  31876. * @default true
  31877. * @apioption plotOptions.series.marker.states.select.enabled
  31878. */
  31879. /**
  31880. * The radius of the point marker. In hover state, it
  31881. * defaults to the normal state's radius + 2.
  31882. *
  31883. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-radius/
  31884. * 10px radius for selected points
  31885. *
  31886. * @type {number}
  31887. * @apioption plotOptions.series.marker.states.select.radius
  31888. */
  31889. /**
  31890. * The fill color of the point marker.
  31891. *
  31892. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-fillcolor/
  31893. * Solid red discs for selected points
  31894. *
  31895. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  31896. */
  31897. fillColor: '#cccccc',
  31898. /**
  31899. * The color of the point marker's outline. When
  31900. * `undefined`, the series' or point's color is used.
  31901. *
  31902. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-linecolor/
  31903. * Red line color for selected points
  31904. *
  31905. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  31906. */
  31907. lineColor: '#000000',
  31908. /**
  31909. * The width of the point marker's outline.
  31910. *
  31911. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-linewidth/
  31912. * 3px line width for selected points
  31913. */
  31914. lineWidth: 2
  31915. }
  31916. }
  31917. },
  31918. /**
  31919. * Properties for each single point.
  31920. *
  31921. * @declare Highcharts.PlotSeriesPointOptions
  31922. *
  31923. * @private
  31924. */
  31925. point: {
  31926. /**
  31927. * Fires when a point is clicked. One parameter, `event`, is passed
  31928. * to the function, containing common event information.
  31929. *
  31930. * If the `series.allowPointSelect` option is true, the default
  31931. * action for the point's click event is to toggle the point's
  31932. * select state. Returning `false` cancels this action.
  31933. *
  31934. * @sample {highcharts} highcharts/plotoptions/series-point-events-click/
  31935. * Click marker to alert values
  31936. * @sample {highcharts} highcharts/plotoptions/series-point-events-click-column/
  31937. * Click column
  31938. * @sample {highcharts} highcharts/plotoptions/series-point-events-click-url/
  31939. * Go to URL
  31940. * @sample {highmaps} maps/plotoptions/series-point-events-click/
  31941. * Click marker to display values
  31942. * @sample {highmaps} maps/plotoptions/series-point-events-click-url/
  31943. * Go to URL
  31944. *
  31945. * @type {Highcharts.PointClickCallbackFunction}
  31946. * @context Highcharts.Point
  31947. * @apioption plotOptions.series.point.events.click
  31948. */
  31949. /**
  31950. * Fires when the mouse leaves the area close to the point. One
  31951. * parameter, `event`, is passed to the function, containing common
  31952. * event information.
  31953. *
  31954. * @sample {highcharts} highcharts/plotoptions/series-point-events-mouseover/
  31955. * Show values in the chart's corner on mouse over
  31956. *
  31957. * @type {Highcharts.PointMouseOutCallbackFunction}
  31958. * @context Highcharts.Point
  31959. * @apioption plotOptions.series.point.events.mouseOut
  31960. */
  31961. /**
  31962. * Fires when the mouse enters the area close to the point. One
  31963. * parameter, `event`, is passed to the function, containing common
  31964. * event information.
  31965. *
  31966. * @sample {highcharts} highcharts/plotoptions/series-point-events-mouseover/
  31967. * Show values in the chart's corner on mouse over
  31968. *
  31969. * @type {Highcharts.PointMouseOverCallbackFunction}
  31970. * @context Highcharts.Point
  31971. * @apioption plotOptions.series.point.events.mouseOver
  31972. */
  31973. /**
  31974. * Fires when the point is removed using the `.remove()` method. One
  31975. * parameter, `event`, is passed to the function. Returning `false`
  31976. * cancels the operation.
  31977. *
  31978. * @sample {highcharts} highcharts/plotoptions/series-point-events-remove/
  31979. * Remove point and confirm
  31980. *
  31981. * @type {Highcharts.PointRemoveCallbackFunction}
  31982. * @since 1.2.0
  31983. * @context Highcharts.Point
  31984. * @apioption plotOptions.series.point.events.remove
  31985. */
  31986. /**
  31987. * Fires when the point is selected either programmatically or
  31988. * following a click on the point. One parameter, `event`, is passed
  31989. * to the function. Returning `false` cancels the operation.
  31990. *
  31991. * @sample {highcharts} highcharts/plotoptions/series-point-events-select/
  31992. * Report the last selected point
  31993. * @sample {highmaps} maps/plotoptions/series-allowpointselect/
  31994. * Report select and unselect
  31995. *
  31996. * @type {Highcharts.PointSelectCallbackFunction}
  31997. * @since 1.2.0
  31998. * @context Highcharts.Point
  31999. * @apioption plotOptions.series.point.events.select
  32000. */
  32001. /**
  32002. * Fires when the point is unselected either programmatically or
  32003. * following a click on the point. One parameter, `event`, is passed
  32004. * to the function.
  32005. * Returning `false` cancels the operation.
  32006. *
  32007. * @sample {highcharts} highcharts/plotoptions/series-point-events-unselect/
  32008. * Report the last unselected point
  32009. * @sample {highmaps} maps/plotoptions/series-allowpointselect/
  32010. * Report select and unselect
  32011. *
  32012. * @type {Highcharts.PointUnselectCallbackFunction}
  32013. * @since 1.2.0
  32014. * @context Highcharts.Point
  32015. * @apioption plotOptions.series.point.events.unselect
  32016. */
  32017. /**
  32018. * Fires when the point is updated programmatically through the
  32019. * `.update()` method. One parameter, `event`, is passed to the
  32020. * function. The new point options can be accessed through
  32021. * `event.options`. Returning `false` cancels the operation.
  32022. *
  32023. * @sample {highcharts} highcharts/plotoptions/series-point-events-update/
  32024. * Confirm point updating
  32025. *
  32026. * @type {Highcharts.PointUpdateCallbackFunction}
  32027. * @since 1.2.0
  32028. * @context Highcharts.Point
  32029. * @apioption plotOptions.series.point.events.update
  32030. */
  32031. /**
  32032. * Events for each single point.
  32033. *
  32034. * @declare Highcharts.PointEventsOptionsObject
  32035. */
  32036. events: {}
  32037. },
  32038. /**
  32039. * Options for the series data labels, appearing next to each data
  32040. * point.
  32041. *
  32042. * Since v6.2.0, multiple data labels can be applied to each single
  32043. * point by defining them as an array of configs.
  32044. *
  32045. * In styled mode, the data labels can be styled with the
  32046. * `.highcharts-data-label-box` and `.highcharts-data-label` class names
  32047. * ([see example](https://www.highcharts.com/samples/highcharts/css/series-datalabels)).
  32048. *
  32049. * @sample {highcharts} highcharts/plotoptions/series-datalabels-enabled
  32050. * Data labels enabled
  32051. * @sample {highcharts} highcharts/plotoptions/series-datalabels-multiple
  32052. * Multiple data labels on a bar series
  32053. * @sample {highcharts} highcharts/css/series-datalabels
  32054. * Style mode example
  32055. *
  32056. * @type {*|Array<*>}
  32057. * @product highcharts highstock highmaps gantt
  32058. *
  32059. * @private
  32060. */
  32061. dataLabels: {
  32062. /**
  32063. * Enable or disable the initial animation when a series is
  32064. * displayed for the `dataLabels`. The animation can also be set as
  32065. * a configuration object. Please note that this option only
  32066. * applies to the initial animation.
  32067. * For other animations, see [chart.animation](#chart.animation)
  32068. * and the animation parameter under the API methods.
  32069. * The following properties are supported:
  32070. *
  32071. * - `defer`: The animation delay time in milliseconds.
  32072. *
  32073. * @sample {highcharts} highcharts/plotoptions/animation-defer/
  32074. * Animation defer settings
  32075. *
  32076. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  32077. * @since 8.2.0
  32078. * @apioption plotOptions.series.dataLabels.animation
  32079. */
  32080. animation: {},
  32081. /**
  32082. * The animation delay time in milliseconds.
  32083. * Set to `0` renders dataLabel immediately.
  32084. * As `undefined` inherits defer time from the [series.animation.defer](#plotOptions.series.animation.defer).
  32085. *
  32086. * @type {number}
  32087. * @since 8.2.0
  32088. * @apioption plotOptions.series.dataLabels.animation.defer
  32089. */
  32090. /**
  32091. * The alignment of the data label compared to the point. If
  32092. * `right`, the right side of the label should be touching the
  32093. * point. For points with an extent, like columns, the alignments
  32094. * also dictates how to align it inside the box, as given with the
  32095. * [inside](#plotOptions.column.dataLabels.inside)
  32096. * option. Can be one of `left`, `center` or `right`.
  32097. *
  32098. * @sample {highcharts} highcharts/plotoptions/series-datalabels-align-left/
  32099. * Left aligned
  32100. * @sample {highcharts} highcharts/plotoptions/bar-datalabels-align-inside-bar/
  32101. * Data labels inside the bar
  32102. *
  32103. * @type {Highcharts.AlignValue|null}
  32104. */
  32105. align: 'center',
  32106. /**
  32107. * Whether to allow data labels to overlap. To make the labels less
  32108. * sensitive for overlapping, the
  32109. * [dataLabels.padding](#plotOptions.series.dataLabels.padding)
  32110. * can be set to 0.
  32111. *
  32112. * @sample {highcharts} highcharts/plotoptions/series-datalabels-allowoverlap-false/
  32113. * Don't allow overlap
  32114. *
  32115. * @type {boolean}
  32116. * @default false
  32117. * @since 4.1.0
  32118. * @apioption plotOptions.series.dataLabels.allowOverlap
  32119. */
  32120. /**
  32121. * The background color or gradient for the data label.
  32122. *
  32123. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  32124. * Data labels box options
  32125. * @sample {highmaps} maps/plotoptions/series-datalabels-box/
  32126. * Data labels box options
  32127. *
  32128. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  32129. * @since 2.2.1
  32130. * @apioption plotOptions.series.dataLabels.backgroundColor
  32131. */
  32132. /**
  32133. * The border color for the data label. Defaults to `undefined`.
  32134. *
  32135. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  32136. * Data labels box options
  32137. *
  32138. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  32139. * @since 2.2.1
  32140. * @apioption plotOptions.series.dataLabels.borderColor
  32141. */
  32142. /**
  32143. * The border radius in pixels for the data label.
  32144. *
  32145. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  32146. * Data labels box options
  32147. * @sample {highmaps} maps/plotoptions/series-datalabels-box/
  32148. * Data labels box options
  32149. *
  32150. * @type {number}
  32151. * @default 0
  32152. * @since 2.2.1
  32153. * @apioption plotOptions.series.dataLabels.borderRadius
  32154. */
  32155. /**
  32156. * The border width in pixels for the data label.
  32157. *
  32158. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  32159. * Data labels box options
  32160. *
  32161. * @type {number}
  32162. * @default 0
  32163. * @since 2.2.1
  32164. * @apioption plotOptions.series.dataLabels.borderWidth
  32165. */
  32166. /**
  32167. * A class name for the data label. Particularly in styled mode,
  32168. * this can be used to give each series' or point's data label
  32169. * unique styling. In addition to this option, a default color class
  32170. * name is added so that we can give the labels a contrast text
  32171. * shadow.
  32172. *
  32173. * @sample {highcharts} highcharts/css/data-label-contrast/
  32174. * Contrast text shadow
  32175. * @sample {highcharts} highcharts/css/series-datalabels/
  32176. * Styling by CSS
  32177. *
  32178. * @type {string}
  32179. * @since 5.0.0
  32180. * @apioption plotOptions.series.dataLabels.className
  32181. */
  32182. /**
  32183. * The text color for the data labels. Defaults to `undefined`. For
  32184. * certain series types, like column or map, the data labels can be
  32185. * drawn inside the points. In this case the data label will be
  32186. * drawn with maximum contrast by default. Additionally, it will be
  32187. * given a `text-outline` style with the opposite color, to further
  32188. * increase the contrast. This can be overridden by setting the
  32189. * `text-outline` style to `none` in the `dataLabels.style` option.
  32190. *
  32191. * @sample {highcharts} highcharts/plotoptions/series-datalabels-color/
  32192. * Red data labels
  32193. * @sample {highmaps} maps/demo/color-axis/
  32194. * White data labels
  32195. *
  32196. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  32197. * @apioption plotOptions.series.dataLabels.color
  32198. */
  32199. /**
  32200. * Whether to hide data labels that are outside the plot area. By
  32201. * default, the data label is moved inside the plot area according
  32202. * to the
  32203. * [overflow](#plotOptions.series.dataLabels.overflow)
  32204. * option.
  32205. *
  32206. * @type {boolean}
  32207. * @default true
  32208. * @since 2.3.3
  32209. * @apioption plotOptions.series.dataLabels.crop
  32210. */
  32211. /**
  32212. * Whether to defer displaying the data labels until the initial
  32213. * series animation has finished. Setting to `false` renders the
  32214. * data label immediately. If set to `true` inherits the defer
  32215. * time set in [plotOptions.series.animation](#plotOptions.series.animation).
  32216. *
  32217. * @sample highcharts/plotoptions/animation-defer
  32218. * Set defer time
  32219. *
  32220. * @since 4.0.0
  32221. * @product highcharts highstock gantt
  32222. */
  32223. defer: true,
  32224. /**
  32225. * Enable or disable the data labels.
  32226. *
  32227. * @sample {highcharts} highcharts/plotoptions/series-datalabels-enabled/
  32228. * Data labels enabled
  32229. * @sample {highmaps} maps/demo/color-axis/
  32230. * Data labels enabled
  32231. *
  32232. * @type {boolean}
  32233. * @default false
  32234. * @apioption plotOptions.series.dataLabels.enabled
  32235. */
  32236. /**
  32237. * A declarative filter to control of which data labels to display.
  32238. * The declarative filter is designed for use when callback
  32239. * functions are not available, like when the chart options require
  32240. * a pure JSON structure or for use with graphical editors. For
  32241. * programmatic control, use the `formatter` instead, and return
  32242. * `undefined` to disable a single data label.
  32243. *
  32244. * @example
  32245. * filter: {
  32246. * property: 'percentage',
  32247. * operator: '>',
  32248. * value: 4
  32249. * }
  32250. *
  32251. * @sample {highcharts} highcharts/demo/pie-monochrome
  32252. * Data labels filtered by percentage
  32253. *
  32254. * @declare Highcharts.DataLabelsFilterOptionsObject
  32255. * @since 6.0.3
  32256. * @apioption plotOptions.series.dataLabels.filter
  32257. */
  32258. /**
  32259. * The operator to compare by. Can be one of `>`, `<`, `>=`, `<=`,
  32260. * `==`, and `===`.
  32261. *
  32262. * @type {string}
  32263. * @validvalue [">", "<", ">=", "<=", "==", "==="]
  32264. * @apioption plotOptions.series.dataLabels.filter.operator
  32265. */
  32266. /**
  32267. * The point property to filter by. Point options are passed
  32268. * directly to properties, additionally there are `y` value,
  32269. * `percentage` and others listed under {@link Highcharts.Point}
  32270. * members.
  32271. *
  32272. * @type {string}
  32273. * @apioption plotOptions.series.dataLabels.filter.property
  32274. */
  32275. /**
  32276. * The value to compare against.
  32277. *
  32278. * @type {number}
  32279. * @apioption plotOptions.series.dataLabels.filter.value
  32280. */
  32281. /**
  32282. * A
  32283. * [format string](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting)
  32284. * for the data label. Available variables are the same as for
  32285. * `formatter`.
  32286. *
  32287. * @sample {highcharts} highcharts/plotoptions/series-datalabels-format/
  32288. * Add a unit
  32289. * @sample {highmaps} maps/plotoptions/series-datalabels-format/
  32290. * Formatted value in the data label
  32291. *
  32292. * @type {string}
  32293. * @default y
  32294. * @default point.value
  32295. * @since 3.0
  32296. * @apioption plotOptions.series.dataLabels.format
  32297. */
  32298. // eslint-disable-next-line valid-jsdoc
  32299. /**
  32300. * Callback JavaScript function to format the data label. Note that
  32301. * if a `format` is defined, the format takes precedence and the
  32302. * formatter is ignored.
  32303. *
  32304. * @sample {highmaps} maps/plotoptions/series-datalabels-format/
  32305. * Formatted value
  32306. *
  32307. * @type {Highcharts.DataLabelsFormatterCallbackFunction}
  32308. */
  32309. formatter: function () {
  32310. var numberFormatter = this.series.chart.numberFormatter;
  32311. return typeof this.y !== 'number' ? '' : numberFormatter(this.y, -1);
  32312. },
  32313. /**
  32314. * For points with an extent, like columns or map areas, whether to
  32315. * align the data label inside the box or to the actual value point.
  32316. * Defaults to `false` in most cases, `true` in stacked columns.
  32317. *
  32318. * @type {boolean}
  32319. * @since 3.0
  32320. * @apioption plotOptions.series.dataLabels.inside
  32321. */
  32322. /**
  32323. * Format for points with the value of null. Works analogously to
  32324. * [format](#plotOptions.series.dataLabels.format). `nullFormat` can
  32325. * be applied only to series which support displaying null points.
  32326. *
  32327. * @sample {highcharts} highcharts/plotoptions/series-datalabels-format/
  32328. * Format data label and tooltip for null point.
  32329. *
  32330. * @type {boolean|string}
  32331. * @since 7.1.0
  32332. * @apioption plotOptions.series.dataLabels.nullFormat
  32333. */
  32334. /**
  32335. * Callback JavaScript function that defines formatting for points
  32336. * with the value of null. Works analogously to
  32337. * [formatter](#plotOptions.series.dataLabels.formatter).
  32338. * `nullPointFormatter` can be applied only to series which support
  32339. * displaying null points.
  32340. *
  32341. * @sample {highcharts} highcharts/plotoptions/series-datalabels-format/
  32342. * Format data label and tooltip for null point.
  32343. *
  32344. * @type {Highcharts.DataLabelsFormatterCallbackFunction}
  32345. * @since 7.1.0
  32346. * @apioption plotOptions.series.dataLabels.nullFormatter
  32347. */
  32348. /**
  32349. * How to handle data labels that flow outside the plot area. The
  32350. * default is `"justify"`, which aligns them inside the plot area.
  32351. * For columns and bars, this means it will be moved inside the bar.
  32352. * To display data labels outside the plot area, set `crop` to
  32353. * `false` and `overflow` to `"allow"`.
  32354. *
  32355. * @type {Highcharts.DataLabelsOverflowValue}
  32356. * @default justify
  32357. * @since 3.0.6
  32358. * @apioption plotOptions.series.dataLabels.overflow
  32359. */
  32360. /**
  32361. * When either the `borderWidth` or the `backgroundColor` is set,
  32362. * this is the padding within the box.
  32363. *
  32364. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  32365. * Data labels box options
  32366. * @sample {highmaps} maps/plotoptions/series-datalabels-box/
  32367. * Data labels box options
  32368. *
  32369. * @since 2.2.1
  32370. */
  32371. padding: 5,
  32372. /**
  32373. * Aligns data labels relative to points. If `center` alignment is
  32374. * not possible, it defaults to `right`.
  32375. *
  32376. * @type {Highcharts.AlignValue}
  32377. * @default center
  32378. * @apioption plotOptions.series.dataLabels.position
  32379. */
  32380. /**
  32381. * Text rotation in degrees. Note that due to a more complex
  32382. * structure, backgrounds, borders and padding will be lost on a
  32383. * rotated data label.
  32384. *
  32385. * @sample {highcharts} highcharts/plotoptions/series-datalabels-rotation/
  32386. * Vertical labels
  32387. *
  32388. * @type {number}
  32389. * @default 0
  32390. * @apioption plotOptions.series.dataLabels.rotation
  32391. */
  32392. /**
  32393. * The shadow of the box. Works best with `borderWidth` or
  32394. * `backgroundColor`. Since 2.3 the shadow can be an object
  32395. * configuration containing `color`, `offsetX`, `offsetY`, `opacity`
  32396. * and `width`.
  32397. *
  32398. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  32399. * Data labels box options
  32400. *
  32401. * @type {boolean|Highcharts.ShadowOptionsObject}
  32402. * @default false
  32403. * @since 2.2.1
  32404. * @apioption plotOptions.series.dataLabels.shadow
  32405. */
  32406. /**
  32407. * The name of a symbol to use for the border around the label.
  32408. * Symbols are predefined functions on the Renderer object.
  32409. *
  32410. * @sample {highcharts} highcharts/plotoptions/series-datalabels-shape/
  32411. * A callout for annotations
  32412. *
  32413. * @type {string}
  32414. * @default square
  32415. * @since 4.1.2
  32416. * @apioption plotOptions.series.dataLabels.shape
  32417. */
  32418. /**
  32419. * Styles for the label. The default `color` setting is
  32420. * `"contrast"`, which is a pseudo color that Highcharts picks up
  32421. * and applies the maximum contrast to the underlying point item,
  32422. * for example the bar in a bar chart.
  32423. *
  32424. * The `textOutline` is a pseudo property that applies an outline of
  32425. * the given width with the given color, which by default is the
  32426. * maximum contrast to the text. So a bright text color will result
  32427. * in a black text outline for maximum readability on a mixed
  32428. * background. In some cases, especially with grayscale text, the
  32429. * text outline doesn't work well, in which cases it can be disabled
  32430. * by setting it to `"none"`. When `useHTML` is true, the
  32431. * `textOutline` will not be picked up. In this, case, the same
  32432. * effect can be acheived through the `text-shadow` CSS property.
  32433. *
  32434. * For some series types, where each point has an extent, like for
  32435. * example tree maps, the data label may overflow the point. There
  32436. * are two strategies for handling overflow. By default, the text
  32437. * will wrap to multiple lines. The other strategy is to set
  32438. * `style.textOverflow` to `ellipsis`, which will keep the text on
  32439. * one line plus it will break inside long words.
  32440. *
  32441. * @sample {highcharts} highcharts/plotoptions/series-datalabels-style/
  32442. * Bold labels
  32443. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-overflow/
  32444. * Long labels truncated with an ellipsis in a pie
  32445. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-overflow-wrap/
  32446. * Long labels are wrapped in a pie
  32447. * @sample {highmaps} maps/demo/color-axis/
  32448. * Bold labels
  32449. *
  32450. * @type {Highcharts.CSSObject}
  32451. * @since 4.1.0
  32452. * @apioption plotOptions.series.dataLabels.style
  32453. */
  32454. style: {
  32455. /** @internal */
  32456. fontSize: '11px',
  32457. /** @internal */
  32458. fontWeight: 'bold',
  32459. /** @internal */
  32460. color: 'contrast',
  32461. /** @internal */
  32462. textOutline: '1px contrast'
  32463. },
  32464. /**
  32465. * Options for a label text which should follow marker's shape.
  32466. * Border and background are disabled for a label that follows a
  32467. * path.
  32468. *
  32469. * **Note:** Only SVG-based renderer supports this option. Setting
  32470. * `useHTML` to true will disable this option.
  32471. *
  32472. * @declare Highcharts.DataLabelsTextPathOptionsObject
  32473. * @since 7.1.0
  32474. * @apioption plotOptions.series.dataLabels.textPath
  32475. */
  32476. /**
  32477. * Presentation attributes for the text path.
  32478. *
  32479. * @type {Highcharts.SVGAttributes}
  32480. * @since 7.1.0
  32481. * @apioption plotOptions.series.dataLabels.textPath.attributes
  32482. */
  32483. /**
  32484. * Enable or disable `textPath` option for link's or marker's data
  32485. * labels.
  32486. *
  32487. * @type {boolean}
  32488. * @since 7.1.0
  32489. * @apioption plotOptions.series.dataLabels.textPath.enabled
  32490. */
  32491. /**
  32492. * Whether to
  32493. * [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  32494. * to render the labels.
  32495. *
  32496. * @type {boolean}
  32497. * @default false
  32498. * @apioption plotOptions.series.dataLabels.useHTML
  32499. */
  32500. /**
  32501. * The vertical alignment of a data label. Can be one of `top`,
  32502. * `middle` or `bottom`. The default value depends on the data, for
  32503. * instance in a column chart, the label is above positive values
  32504. * and below negative values.
  32505. *
  32506. * @type {Highcharts.VerticalAlignValue|null}
  32507. * @since 2.3.3
  32508. */
  32509. verticalAlign: 'bottom',
  32510. /**
  32511. * The x position offset of the label relative to the point in
  32512. * pixels.
  32513. *
  32514. * @sample {highcharts} highcharts/plotoptions/series-datalabels-rotation/
  32515. * Vertical and positioned
  32516. * @sample {highcharts} highcharts/plotoptions/bar-datalabels-align-inside-bar/
  32517. * Data labels inside the bar
  32518. */
  32519. x: 0,
  32520. /**
  32521. * The Z index of the data labels. The default Z index puts it above
  32522. * the series. Use a Z index of 2 to display it behind the series.
  32523. *
  32524. * @type {number}
  32525. * @default 6
  32526. * @since 2.3.5
  32527. * @apioption plotOptions.series.dataLabels.z
  32528. */
  32529. /**
  32530. * The y position offset of the label relative to the point in
  32531. * pixels.
  32532. *
  32533. * @sample {highcharts} highcharts/plotoptions/series-datalabels-rotation/
  32534. * Vertical and positioned
  32535. */
  32536. y: 0
  32537. },
  32538. /**
  32539. * When the series contains less points than the crop threshold, all
  32540. * points are drawn, even if the points fall outside the visible plot
  32541. * area at the current zoom. The advantage of drawing all points
  32542. * (including markers and columns), is that animation is performed on
  32543. * updates. On the other hand, when the series contains more points than
  32544. * the crop threshold, the series data is cropped to only contain points
  32545. * that fall within the plot area. The advantage of cropping away
  32546. * invisible points is to increase performance on large series.
  32547. *
  32548. * @since 2.2
  32549. * @product highcharts highstock
  32550. *
  32551. * @private
  32552. */
  32553. cropThreshold: 300,
  32554. /**
  32555. * Opacity of a series parts: line, fill (e.g. area) and dataLabels.
  32556. *
  32557. * @see [states.inactive.opacity](#plotOptions.series.states.inactive.opacity)
  32558. *
  32559. * @since 7.1.0
  32560. *
  32561. * @private
  32562. */
  32563. opacity: 1,
  32564. /**
  32565. * The width of each point on the x axis. For example in a column chart
  32566. * with one value each day, the pointRange would be 1 day (= 24 * 3600
  32567. * * 1000 milliseconds). This is normally computed automatically, but
  32568. * this option can be used to override the automatic value.
  32569. *
  32570. * @product highstock
  32571. *
  32572. * @private
  32573. */
  32574. pointRange: 0,
  32575. /**
  32576. * When this is true, the series will not cause the Y axis to cross
  32577. * the zero plane (or [threshold](#plotOptions.series.threshold) option)
  32578. * unless the data actually crosses the plane.
  32579. *
  32580. * For example, if `softThreshold` is `false`, a series of 0, 1, 2,
  32581. * 3 will make the Y axis show negative values according to the
  32582. * `minPadding` option. If `softThreshold` is `true`, the Y axis starts
  32583. * at 0.
  32584. *
  32585. * @since 4.1.9
  32586. * @product highcharts highstock
  32587. *
  32588. * @private
  32589. */
  32590. softThreshold: true,
  32591. /**
  32592. * @declare Highcharts.SeriesStatesOptionsObject
  32593. *
  32594. * @private
  32595. */
  32596. states: {
  32597. /**
  32598. * The normal state of a series, or for point items in column, pie
  32599. * and similar series. Currently only used for setting animation
  32600. * when returning to normal state from hover.
  32601. *
  32602. * @declare Highcharts.SeriesStatesNormalOptionsObject
  32603. */
  32604. normal: {
  32605. /**
  32606. * Animation when returning to normal state after hovering.
  32607. *
  32608. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  32609. */
  32610. animation: true
  32611. },
  32612. /**
  32613. * Options for the hovered series. These settings override the
  32614. * normal state options when a series is moused over or touched.
  32615. *
  32616. * @declare Highcharts.SeriesStatesHoverOptionsObject
  32617. */
  32618. hover: {
  32619. /**
  32620. * Enable separate styles for the hovered series to visualize
  32621. * that the user hovers either the series itself or the legend.
  32622. *
  32623. * @sample {highcharts} highcharts/plotoptions/series-states-hover-enabled/
  32624. * Line
  32625. * @sample {highcharts} highcharts/plotoptions/series-states-hover-enabled-column/
  32626. * Column
  32627. * @sample {highcharts} highcharts/plotoptions/series-states-hover-enabled-pie/
  32628. * Pie
  32629. *
  32630. * @type {boolean}
  32631. * @default true
  32632. * @since 1.2
  32633. * @apioption plotOptions.series.states.hover.enabled
  32634. */
  32635. /**
  32636. * Animation setting for hovering the graph in line-type series.
  32637. *
  32638. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  32639. * @since 5.0.8
  32640. * @product highcharts highstock
  32641. */
  32642. animation: {
  32643. /**
  32644. * The duration of the hover animation in milliseconds. By
  32645. * default the hover state animates quickly in, and slowly
  32646. * back to normal.
  32647. *
  32648. * @internal
  32649. */
  32650. duration: 50
  32651. },
  32652. /**
  32653. * Pixel width of the graph line. By default this property is
  32654. * undefined, and the `lineWidthPlus` property dictates how much
  32655. * to increase the linewidth from normal state.
  32656. *
  32657. * @sample {highcharts} highcharts/plotoptions/series-states-hover-linewidth/
  32658. * 5px line on hover
  32659. *
  32660. * @type {number}
  32661. * @product highcharts highstock
  32662. * @apioption plotOptions.series.states.hover.lineWidth
  32663. */
  32664. /**
  32665. * The additional line width for the graph of a hovered series.
  32666. *
  32667. * @sample {highcharts} highcharts/plotoptions/series-states-hover-linewidthplus/
  32668. * 5 pixels wider
  32669. * @sample {highstock} highcharts/plotoptions/series-states-hover-linewidthplus/
  32670. * 5 pixels wider
  32671. *
  32672. * @since 4.0.3
  32673. * @product highcharts highstock
  32674. */
  32675. lineWidthPlus: 1,
  32676. /**
  32677. * In Highcharts 1.0, the appearance of all markers belonging
  32678. * to the hovered series. For settings on the hover state of the
  32679. * individual point, see
  32680. * [marker.states.hover](#plotOptions.series.marker.states.hover).
  32681. *
  32682. * @deprecated
  32683. *
  32684. * @extends plotOptions.series.marker
  32685. * @excluding states
  32686. * @product highcharts highstock
  32687. */
  32688. marker: {
  32689. // lineWidth: base + 1,
  32690. // radius: base + 1
  32691. },
  32692. /**
  32693. * Options for the halo appearing around the hovered point in
  32694. * line-type series as well as outside the hovered slice in pie
  32695. * charts. By default the halo is filled by the current point or
  32696. * series color with an opacity of 0.25\. The halo can be
  32697. * disabled by setting the `halo` option to `null`.
  32698. *
  32699. * In styled mode, the halo is styled with the
  32700. * `.highcharts-halo` class, with colors inherited from
  32701. * `.highcharts-color-{n}`.
  32702. *
  32703. * @sample {highcharts} highcharts/plotoptions/halo/
  32704. * Halo options
  32705. * @sample {highstock} highcharts/plotoptions/halo/
  32706. * Halo options
  32707. *
  32708. * @declare Highcharts.SeriesStatesHoverHaloOptionsObject
  32709. * @type {null|*}
  32710. * @since 4.0
  32711. * @product highcharts highstock
  32712. */
  32713. halo: {
  32714. /**
  32715. * A collection of SVG attributes to override the appearance
  32716. * of the halo, for example `fill`, `stroke` and
  32717. * `stroke-width`.
  32718. *
  32719. * @type {Highcharts.SVGAttributes}
  32720. * @since 4.0
  32721. * @product highcharts highstock
  32722. * @apioption plotOptions.series.states.hover.halo.attributes
  32723. */
  32724. /**
  32725. * The pixel size of the halo. For point markers this is the
  32726. * radius of the halo. For pie slices it is the width of the
  32727. * halo outside the slice. For bubbles it defaults to 5 and
  32728. * is the width of the halo outside the bubble.
  32729. *
  32730. * @since 4.0
  32731. * @product highcharts highstock
  32732. */
  32733. size: 10,
  32734. /**
  32735. * Opacity for the halo unless a specific fill is overridden
  32736. * using the `attributes` setting. Note that Highcharts is
  32737. * only able to apply opacity to colors of hex or rgb(a)
  32738. * formats.
  32739. *
  32740. * @since 4.0
  32741. * @product highcharts highstock
  32742. */
  32743. opacity: 0.25
  32744. }
  32745. },
  32746. /**
  32747. * Specific options for point in selected states, after being
  32748. * selected by
  32749. * [allowPointSelect](#plotOptions.series.allowPointSelect)
  32750. * or programmatically.
  32751. *
  32752. * @sample maps/plotoptions/series-allowpointselect/
  32753. * Allow point select demo
  32754. *
  32755. * @declare Highcharts.SeriesStatesSelectOptionsObject
  32756. * @extends plotOptions.series.states.hover
  32757. * @excluding brightness
  32758. */
  32759. select: {
  32760. animation: {
  32761. /** @internal */
  32762. duration: 0
  32763. }
  32764. },
  32765. /**
  32766. * The opposite state of a hover for series.
  32767. *
  32768. * @sample highcharts/plotoptions/series-states-inactive-disabled
  32769. * Disabled inactive state
  32770. *
  32771. * @declare Highcharts.SeriesStatesInactiveOptionsObject
  32772. */
  32773. inactive: {
  32774. /**
  32775. * Enable or disable the inactive state for a series
  32776. *
  32777. * @sample highcharts/plotoptions/series-states-inactive-disabled
  32778. * Disabled inactive state
  32779. *
  32780. * @type {boolean}
  32781. * @default true
  32782. * @apioption plotOptions.series.states.inactive.enabled
  32783. */
  32784. /**
  32785. * The animation for entering the inactive state.
  32786. *
  32787. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  32788. */
  32789. animation: {
  32790. /** @internal */
  32791. duration: 50
  32792. },
  32793. /**
  32794. * Opacity of series elements (dataLabels, line, area).
  32795. *
  32796. * @type {number}
  32797. */
  32798. opacity: 0.2
  32799. }
  32800. },
  32801. /**
  32802. * Sticky tracking of mouse events. When true, the `mouseOut` event on a
  32803. * series isn't triggered until the mouse moves over another series, or
  32804. * out of the plot area. When false, the `mouseOut` event on a series is
  32805. * triggered when the mouse leaves the area around the series' graph or
  32806. * markers. This also implies the tooltip when not shared. When
  32807. * `stickyTracking` is false and `tooltip.shared` is false, the tooltip
  32808. * will be hidden when moving the mouse between series. Defaults to true
  32809. * for line and area type series, but to false for columns, pies etc.
  32810. *
  32811. * **Note:** The boost module will force this option because of
  32812. * technical limitations.
  32813. *
  32814. * @sample {highcharts} highcharts/plotoptions/series-stickytracking-true/
  32815. * True by default
  32816. * @sample {highcharts} highcharts/plotoptions/series-stickytracking-false/
  32817. * False
  32818. *
  32819. * @default {highcharts} true
  32820. * @default {highstock} true
  32821. * @default {highmaps} false
  32822. * @since 2.0
  32823. *
  32824. * @private
  32825. */
  32826. stickyTracking: true,
  32827. /**
  32828. * A configuration object for the tooltip rendering of each single
  32829. * series. Properties are inherited from [tooltip](#tooltip), but only
  32830. * the following properties can be defined on a series level.
  32831. *
  32832. * @declare Highcharts.SeriesTooltipOptionsObject
  32833. * @since 2.3
  32834. * @extends tooltip
  32835. * @excluding animation, backgroundColor, borderColor, borderRadius,
  32836. * borderWidth, className, crosshairs, enabled, formatter,
  32837. * headerShape, hideDelay, outside, padding, positioner,
  32838. * shadow, shape, shared, snap, split, stickOnContact,
  32839. * style, useHTML
  32840. * @apioption plotOptions.series.tooltip
  32841. */
  32842. /**
  32843. * When a series contains a data array that is longer than this, only
  32844. * one dimensional arrays of numbers, or two dimensional arrays with
  32845. * x and y values are allowed. Also, only the first point is tested,
  32846. * and the rest are assumed to be the same format. This saves expensive
  32847. * data checking and indexing in long series. Set it to `0` disable.
  32848. *
  32849. * Note:
  32850. * In boost mode turbo threshold is forced. Only array of numbers or
  32851. * two dimensional arrays are allowed.
  32852. *
  32853. * @since 2.2
  32854. * @product highcharts highstock gantt
  32855. *
  32856. * @private
  32857. */
  32858. turboThreshold: 1000,
  32859. /**
  32860. * An array defining zones within a series. Zones can be applied to the
  32861. * X axis, Y axis or Z axis for bubbles, according to the `zoneAxis`
  32862. * option. The zone definitions have to be in ascending order regarding
  32863. * to the value.
  32864. *
  32865. * In styled mode, the color zones are styled with the
  32866. * `.highcharts-zone-{n}` class, or custom classed from the `className`
  32867. * option
  32868. * ([view live demo](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/css/color-zones/)).
  32869. *
  32870. * @see [zoneAxis](#plotOptions.series.zoneAxis)
  32871. *
  32872. * @sample {highcharts} highcharts/series/color-zones-simple/
  32873. * Color zones
  32874. * @sample {highstock} highcharts/series/color-zones-simple/
  32875. * Color zones
  32876. *
  32877. * @declare Highcharts.SeriesZonesOptionsObject
  32878. * @type {Array<*>}
  32879. * @since 4.1.0
  32880. * @product highcharts highstock
  32881. * @apioption plotOptions.series.zones
  32882. */
  32883. /**
  32884. * Styled mode only. A custom class name for the zone.
  32885. *
  32886. * @sample highcharts/css/color-zones/
  32887. * Zones styled by class name
  32888. *
  32889. * @type {string}
  32890. * @since 5.0.0
  32891. * @apioption plotOptions.series.zones.className
  32892. */
  32893. /**
  32894. * Defines the color of the series.
  32895. *
  32896. * @see [series color](#plotOptions.series.color)
  32897. *
  32898. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  32899. * @since 4.1.0
  32900. * @product highcharts highstock
  32901. * @apioption plotOptions.series.zones.color
  32902. */
  32903. /**
  32904. * A name for the dash style to use for the graph.
  32905. *
  32906. * @see [plotOptions.series.dashStyle](#plotOptions.series.dashStyle)
  32907. *
  32908. * @sample {highcharts|highstock} highcharts/series/color-zones-dashstyle-dot/
  32909. * Dashed line indicates prognosis
  32910. *
  32911. * @type {Highcharts.DashStyleValue}
  32912. * @since 4.1.0
  32913. * @product highcharts highstock
  32914. * @apioption plotOptions.series.zones.dashStyle
  32915. */
  32916. /**
  32917. * Defines the fill color for the series (in area type series)
  32918. *
  32919. * @see [fillColor](#plotOptions.area.fillColor)
  32920. *
  32921. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  32922. * @since 4.1.0
  32923. * @product highcharts highstock
  32924. * @apioption plotOptions.series.zones.fillColor
  32925. */
  32926. /**
  32927. * The value up to where the zone extends, if undefined the zones
  32928. * stretches to the last value in the series.
  32929. *
  32930. * @type {number}
  32931. * @since 4.1.0
  32932. * @product highcharts highstock
  32933. * @apioption plotOptions.series.zones.value
  32934. */
  32935. /**
  32936. * When using dual or multiple color axes, this number defines which
  32937. * colorAxis the particular series is connected to. It refers to
  32938. * either the
  32939. * {@link #colorAxis.id|axis id}
  32940. * or the index of the axis in the colorAxis array, with 0 being the
  32941. * first. Set this option to false to prevent a series from connecting
  32942. * to the default color axis.
  32943. *
  32944. * Since v7.2.0 the option can also be an axis id or an axis index
  32945. * instead of a boolean flag.
  32946. *
  32947. * @sample highcharts/coloraxis/coloraxis-with-pie/
  32948. * Color axis with pie series
  32949. * @sample highcharts/coloraxis/multiple-coloraxis/
  32950. * Multiple color axis
  32951. *
  32952. * @type {number|string|boolean}
  32953. * @default 0
  32954. * @product highcharts highstock highmaps
  32955. * @apioption plotOptions.series.colorAxis
  32956. */
  32957. /**
  32958. * Determines what data value should be used to calculate point color
  32959. * if `colorAxis` is used. Requires to set `min` and `max` if some
  32960. * custom point property is used or if approximation for data grouping
  32961. * is set to `'sum'`.
  32962. *
  32963. * @sample highcharts/coloraxis/custom-color-key/
  32964. * Custom color key
  32965. * @sample highcharts/coloraxis/changed-default-color-key/
  32966. * Changed default color key
  32967. *
  32968. * @type {string}
  32969. * @default y
  32970. * @since 7.2.0
  32971. * @product highcharts highstock highmaps
  32972. * @apioption plotOptions.series.colorKey
  32973. */
  32974. /**
  32975. * Determines whether the series should look for the nearest point
  32976. * in both dimensions or just the x-dimension when hovering the series.
  32977. * Defaults to `'xy'` for scatter series and `'x'` for most other
  32978. * series. If the data has duplicate x-values, it is recommended to
  32979. * set this to `'xy'` to allow hovering over all points.
  32980. *
  32981. * Applies only to series types using nearest neighbor search (not
  32982. * direct hover) for tooltip.
  32983. *
  32984. * @sample {highcharts} highcharts/series/findnearestpointby/
  32985. * Different hover behaviors
  32986. * @sample {highstock} highcharts/series/findnearestpointby/
  32987. * Different hover behaviors
  32988. * @sample {highmaps} highcharts/series/findnearestpointby/
  32989. * Different hover behaviors
  32990. *
  32991. * @since 5.0.10
  32992. * @validvalue ["x", "xy"]
  32993. *
  32994. * @private
  32995. */
  32996. findNearestPointBy: 'x'
  32997. },
  32998. /* eslint-disable no-invalid-this, valid-jsdoc */
  32999. /** @lends Highcharts.Series.prototype */
  33000. {
  33001. axisTypes: ['xAxis', 'yAxis'],
  33002. coll: 'series',
  33003. colorCounter: 0,
  33004. cropShoulder: 1,
  33005. directTouch: false,
  33006. isCartesian: true,
  33007. // each point's x and y values are stored in this.xData and this.yData
  33008. parallelArrays: ['x', 'y'],
  33009. pointClass: Point,
  33010. requireSorting: true,
  33011. sorted: true,
  33012. init: function (chart, options) {
  33013. fireEvent(this, 'init', { options: options });
  33014. var series = this,
  33015. events,
  33016. chartSeries = chart.series,
  33017. lastSeries;
  33018. // A lookup over those events that are added by _options_ (not
  33019. // programmatically). These are updated through Series.update()
  33020. // (#10861).
  33021. this.eventOptions = this.eventOptions || {};
  33022. // The 'eventsToUnbind' property moved from prototype into the
  33023. // Series init to avoid reference to the same array between
  33024. // the different series and charts. #12959, #13937
  33025. this.eventsToUnbind = [];
  33026. /**
  33027. * Read only. The chart that the series belongs to.
  33028. *
  33029. * @name Highcharts.Series#chart
  33030. * @type {Highcharts.Chart}
  33031. */
  33032. series.chart = chart;
  33033. /**
  33034. * Read only. The series' type, like "line", "area", "column" etc.
  33035. * The type in the series options anc can be altered using
  33036. * {@link Series#update}.
  33037. *
  33038. * @name Highcharts.Series#type
  33039. * @type {string}
  33040. */
  33041. /**
  33042. * Read only. The series' current options. To update, use
  33043. * {@link Series#update}.
  33044. *
  33045. * @name Highcharts.Series#options
  33046. * @type {Highcharts.SeriesOptionsType}
  33047. */
  33048. series.options = options = series.setOptions(options);
  33049. series.linkedSeries = [];
  33050. // bind the axes
  33051. series.bindAxes();
  33052. // set some variables
  33053. extend(series, {
  33054. /**
  33055. * The series name as given in the options. Defaults to
  33056. * "Series {n}".
  33057. *
  33058. * @name Highcharts.Series#name
  33059. * @type {string}
  33060. */
  33061. name: options.name,
  33062. state: '',
  33063. /**
  33064. * Read only. The series' visibility state as set by {@link
  33065. * Series#show}, {@link Series#hide}, or in the initial
  33066. * configuration.
  33067. *
  33068. * @name Highcharts.Series#visible
  33069. * @type {boolean}
  33070. */
  33071. visible: options.visible !== false,
  33072. /**
  33073. * Read only. The series' selected state as set by {@link
  33074. * Highcharts.Series#select}.
  33075. *
  33076. * @name Highcharts.Series#selected
  33077. * @type {boolean}
  33078. */
  33079. selected: options.selected === true // false by default
  33080. });
  33081. // Register event listeners
  33082. events = options.events;
  33083. objectEach(events, function (event, eventType) {
  33084. if (isFunction(event)) {
  33085. // If event does not exist, or is changed by Series.update
  33086. if (series.eventOptions[eventType] !== event) {
  33087. // Remove existing if set by option
  33088. if (isFunction(series.eventOptions[eventType])) {
  33089. removeEvent(series, eventType, series.eventOptions[eventType]);
  33090. }
  33091. series.eventOptions[eventType] = event;
  33092. addEvent(series, eventType, event);
  33093. }
  33094. }
  33095. });
  33096. if ((events && events.click) ||
  33097. (options.point &&
  33098. options.point.events &&
  33099. options.point.events.click) ||
  33100. options.allowPointSelect) {
  33101. chart.runTrackerClick = true;
  33102. }
  33103. series.getColor();
  33104. series.getSymbol();
  33105. // Initialize the parallel data arrays
  33106. series.parallelArrays.forEach(function (key) {
  33107. if (!series[key + 'Data']) {
  33108. series[key + 'Data'] = [];
  33109. }
  33110. });
  33111. // Mark cartesian
  33112. if (series.isCartesian) {
  33113. chart.hasCartesianSeries = true;
  33114. }
  33115. // Get the index and register the series in the chart. The index is
  33116. // one more than the current latest series index (#5960).
  33117. if (chartSeries.length) {
  33118. lastSeries = chartSeries[chartSeries.length - 1];
  33119. }
  33120. series._i = pick(lastSeries && lastSeries._i, -1) + 1;
  33121. series.opacity = series.options.opacity;
  33122. // Insert the series and re-order all series above the insertion
  33123. // point.
  33124. chart.orderSeries(this.insert(chartSeries));
  33125. // Set options for series with sorting and set data later.
  33126. if (options.dataSorting && options.dataSorting.enabled) {
  33127. series.setDataSortingOptions();
  33128. }
  33129. else if (!series.points && !series.data) {
  33130. series.setData(options.data, false);
  33131. }
  33132. fireEvent(this, 'afterInit');
  33133. },
  33134. /**
  33135. * Check whether the series item is itself or inherits from a certain
  33136. * series type.
  33137. *
  33138. * @function Highcharts.Series#is
  33139. * @param {string} type The type of series to check for, can be either
  33140. * featured or custom series types. For example `column`, `pie`,
  33141. * `ohlc` etc.
  33142. *
  33143. * @return {boolean}
  33144. * True if this item is or inherits from the given type.
  33145. */
  33146. is: function (type) {
  33147. return seriesTypes[type] && this instanceof seriesTypes[type];
  33148. },
  33149. /**
  33150. * Insert the series in a collection with other series, either the chart
  33151. * series or yAxis series, in the correct order according to the index
  33152. * option. Used internally when adding series.
  33153. *
  33154. * @private
  33155. * @function Highcharts.Series#insert
  33156. * @param {Array<Highcharts.Series>} collection
  33157. * A collection of series, like `chart.series` or `xAxis.series`.
  33158. * @return {number}
  33159. * The index of the series in the collection.
  33160. */
  33161. insert: function (collection) {
  33162. var indexOption = this.options.index,
  33163. i;
  33164. // Insert by index option
  33165. if (isNumber(indexOption)) {
  33166. i = collection.length;
  33167. while (i--) {
  33168. // Loop down until the interted element has higher index
  33169. if (indexOption >=
  33170. pick(collection[i].options.index, collection[i]._i)) {
  33171. collection.splice(i + 1, 0, this);
  33172. break;
  33173. }
  33174. }
  33175. if (i === -1) {
  33176. collection.unshift(this);
  33177. }
  33178. i = i + 1;
  33179. // Or just push it to the end
  33180. }
  33181. else {
  33182. collection.push(this);
  33183. }
  33184. return pick(i, collection.length - 1);
  33185. },
  33186. /**
  33187. * Set the xAxis and yAxis properties of cartesian series, and register
  33188. * the series in the `axis.series` array.
  33189. *
  33190. * @private
  33191. * @function Highcharts.Series#bindAxes
  33192. * @return {void}
  33193. * @exception 18
  33194. */
  33195. bindAxes: function () {
  33196. var series = this,
  33197. seriesOptions = series.options,
  33198. chart = series.chart,
  33199. axisOptions;
  33200. fireEvent(this, 'bindAxes', null, function () {
  33201. // repeat for xAxis and yAxis
  33202. (series.axisTypes || []).forEach(function (AXIS) {
  33203. // loop through the chart's axis objects
  33204. chart[AXIS].forEach(function (axis) {
  33205. axisOptions = axis.options;
  33206. // apply if the series xAxis or yAxis option mathches
  33207. // the number of the axis, or if undefined, use the
  33208. // first axis
  33209. if (seriesOptions[AXIS] ===
  33210. axisOptions.index ||
  33211. (typeof seriesOptions[AXIS] !==
  33212. 'undefined' &&
  33213. seriesOptions[AXIS] === axisOptions.id) ||
  33214. (typeof seriesOptions[AXIS] ===
  33215. 'undefined' &&
  33216. axisOptions.index === 0)) {
  33217. // register this series in the axis.series lookup
  33218. series.insert(axis.series);
  33219. // set this series.xAxis or series.yAxis reference
  33220. /**
  33221. * Read only. The unique xAxis object associated
  33222. * with the series.
  33223. *
  33224. * @name Highcharts.Series#xAxis
  33225. * @type {Highcharts.Axis}
  33226. */
  33227. /**
  33228. * Read only. The unique yAxis object associated
  33229. * with the series.
  33230. *
  33231. * @name Highcharts.Series#yAxis
  33232. * @type {Highcharts.Axis}
  33233. */
  33234. series[AXIS] = axis;
  33235. // mark dirty for redraw
  33236. axis.isDirty = true;
  33237. }
  33238. });
  33239. // The series needs an X and an Y axis
  33240. if (!series[AXIS] &&
  33241. series.optionalAxis !== AXIS) {
  33242. error(18, true, chart);
  33243. }
  33244. });
  33245. });
  33246. fireEvent(this, 'afterBindAxes');
  33247. },
  33248. /**
  33249. * For simple series types like line and column, the data values are
  33250. * held in arrays like xData and yData for quick lookup to find extremes
  33251. * and more. For multidimensional series like bubble and map, this can
  33252. * be extended with arrays like zData and valueData by adding to the
  33253. * `series.parallelArrays` array.
  33254. *
  33255. * @private
  33256. * @function Highcharts.Series#updateParallelArrays
  33257. * @param {Highcharts.Point} point
  33258. * @param {number|string} i
  33259. * @return {void}
  33260. */
  33261. updateParallelArrays: function (point, i) {
  33262. var series = point.series,
  33263. args = arguments,
  33264. fn = isNumber(i) ?
  33265. // Insert the value in the given position
  33266. function (key) {
  33267. var val = key === 'y' && series.toYData ?
  33268. series.toYData(point) :
  33269. point[key];
  33270. series[key + 'Data'][i] = val;
  33271. } :
  33272. // Apply the method specified in i with the following
  33273. // arguments as arguments
  33274. function (key) {
  33275. Array.prototype[i].apply(series[key + 'Data'], Array.prototype.slice.call(args, 2));
  33276. };
  33277. series.parallelArrays.forEach(fn);
  33278. },
  33279. /**
  33280. * Define hasData functions for series. These return true if there
  33281. * are data points on this series within the plot area.
  33282. *
  33283. * @private
  33284. * @function Highcharts.Series#hasData
  33285. * @return {boolean}
  33286. */
  33287. hasData: function () {
  33288. return ((this.visible &&
  33289. typeof this.dataMax !== 'undefined' &&
  33290. typeof this.dataMin !== 'undefined') || ( // #3703
  33291. this.visible &&
  33292. this.yData &&
  33293. this.yData.length > 0) // #9758
  33294. );
  33295. },
  33296. /**
  33297. * Return an auto incremented x value based on the pointStart and
  33298. * pointInterval options. This is only used if an x value is not given
  33299. * for the point that calls autoIncrement.
  33300. *
  33301. * @private
  33302. * @function Highcharts.Series#autoIncrement
  33303. * @return {number}
  33304. */
  33305. autoIncrement: function () {
  33306. var options = this.options,
  33307. xIncrement = this.xIncrement,
  33308. date,
  33309. pointInterval,
  33310. pointIntervalUnit = options.pointIntervalUnit,
  33311. time = this.chart.time;
  33312. xIncrement = pick(xIncrement, options.pointStart, 0);
  33313. this.pointInterval = pointInterval = pick(this.pointInterval, options.pointInterval, 1);
  33314. // Added code for pointInterval strings
  33315. if (pointIntervalUnit) {
  33316. date = new time.Date(xIncrement);
  33317. if (pointIntervalUnit === 'day') {
  33318. time.set('Date', date, time.get('Date', date) + pointInterval);
  33319. }
  33320. else if (pointIntervalUnit === 'month') {
  33321. time.set('Month', date, time.get('Month', date) + pointInterval);
  33322. }
  33323. else if (pointIntervalUnit === 'year') {
  33324. time.set('FullYear', date, time.get('FullYear', date) + pointInterval);
  33325. }
  33326. pointInterval = date.getTime() - xIncrement;
  33327. }
  33328. this.xIncrement = xIncrement + pointInterval;
  33329. return xIncrement;
  33330. },
  33331. /**
  33332. * Internal function to set properties for series if data sorting is
  33333. * enabled.
  33334. *
  33335. * @private
  33336. * @function Highcharts.Series#setDataSortingOptions
  33337. * @return {void}
  33338. */
  33339. setDataSortingOptions: function () {
  33340. var options = this.options;
  33341. extend(this, {
  33342. requireSorting: false,
  33343. sorted: false,
  33344. enabledDataSorting: true,
  33345. allowDG: false
  33346. });
  33347. // To allow unsorted data for column series.
  33348. if (!defined(options.pointRange)) {
  33349. options.pointRange = 1;
  33350. }
  33351. },
  33352. /**
  33353. * Set the series options by merging from the options tree. Called
  33354. * internally on initializing and updating series. This function will
  33355. * not redraw the series. For API usage, use {@link Series#update}.
  33356. * @private
  33357. * @function Highcharts.Series#setOptions
  33358. * @param {Highcharts.SeriesOptionsType} itemOptions
  33359. * The series options.
  33360. * @return {Highcharts.SeriesOptionsType}
  33361. * @fires Highcharts.Series#event:afterSetOptions
  33362. */
  33363. setOptions: function (itemOptions) {
  33364. var chart = this.chart,
  33365. chartOptions = chart.options,
  33366. plotOptions = chartOptions.plotOptions,
  33367. userOptions = chart.userOptions || {},
  33368. seriesUserOptions = merge(itemOptions),
  33369. options,
  33370. zones,
  33371. zone,
  33372. styledMode = chart.styledMode,
  33373. e = {
  33374. plotOptions: plotOptions,
  33375. userOptions: seriesUserOptions
  33376. };
  33377. fireEvent(this, 'setOptions', e);
  33378. // These may be modified by the event
  33379. var typeOptions = e.plotOptions[this.type],
  33380. userPlotOptions = (userOptions.plotOptions || {});
  33381. // use copy to prevent undetected changes (#9762)
  33382. /**
  33383. * Contains series options by the user without defaults.
  33384. * @name Highcharts.Series#userOptions
  33385. * @type {Highcharts.SeriesOptionsType}
  33386. */
  33387. this.userOptions = e.userOptions;
  33388. options = merge(typeOptions, plotOptions.series,
  33389. // #3881, chart instance plotOptions[type] should trump
  33390. // plotOptions.series
  33391. userOptions.plotOptions &&
  33392. userOptions.plotOptions[this.type], seriesUserOptions);
  33393. // The tooltip options are merged between global and series specific
  33394. // options. Importance order asscendingly:
  33395. // globals: (1)tooltip, (2)plotOptions.series,
  33396. // (3)plotOptions[this.type]
  33397. // init userOptions with possible later updates: 4-6 like 1-3 and
  33398. // (7)this series options
  33399. this.tooltipOptions = merge(defaultOptions.tooltip, // 1
  33400. defaultOptions.plotOptions.series &&
  33401. defaultOptions.plotOptions.series.tooltip, // 2
  33402. defaultOptions.plotOptions[this.type].tooltip, // 3
  33403. chartOptions.tooltip.userOptions, // 4
  33404. plotOptions.series &&
  33405. plotOptions.series.tooltip, // 5
  33406. plotOptions[this.type].tooltip, // 6
  33407. seriesUserOptions.tooltip // 7
  33408. );
  33409. // When shared tooltip, stickyTracking is true by default,
  33410. // unless user says otherwise.
  33411. this.stickyTracking = pick(seriesUserOptions.stickyTracking, userPlotOptions[this.type] &&
  33412. userPlotOptions[this.type].stickyTracking, userPlotOptions.series && userPlotOptions.series.stickyTracking, (this.tooltipOptions.shared && !this.noSharedTooltip ?
  33413. true :
  33414. options.stickyTracking));
  33415. // Delete marker object if not allowed (#1125)
  33416. if (typeOptions.marker === null) {
  33417. delete options.marker;
  33418. }
  33419. // Handle color zones
  33420. this.zoneAxis = options.zoneAxis;
  33421. zones = this.zones = (options.zones || []).slice();
  33422. if ((options.negativeColor || options.negativeFillColor) &&
  33423. !options.zones) {
  33424. zone = {
  33425. value: options[this.zoneAxis + 'Threshold'] ||
  33426. options.threshold ||
  33427. 0,
  33428. className: 'highcharts-negative'
  33429. };
  33430. if (!styledMode) {
  33431. zone.color = options.negativeColor;
  33432. zone.fillColor = options.negativeFillColor;
  33433. }
  33434. zones.push(zone);
  33435. }
  33436. if (zones.length) { // Push one extra zone for the rest
  33437. if (defined(zones[zones.length - 1].value)) {
  33438. zones.push(styledMode ? {} : {
  33439. color: this.color,
  33440. fillColor: this.fillColor
  33441. });
  33442. }
  33443. }
  33444. fireEvent(this, 'afterSetOptions', { options: options });
  33445. return options;
  33446. },
  33447. /**
  33448. * Return series name in "Series {Number}" format or the one defined by
  33449. * a user. This method can be simply overridden as series name format
  33450. * can vary (e.g. technical indicators).
  33451. *
  33452. * @function Highcharts.Series#getName
  33453. * @return {string}
  33454. * The series name.
  33455. */
  33456. getName: function () {
  33457. // #4119
  33458. return pick(this.options.name, 'Series ' + (this.index + 1));
  33459. },
  33460. /**
  33461. * @private
  33462. * @function Highcharts.Series#getCyclic
  33463. * @param {string} prop
  33464. * @param {*} [value]
  33465. * @param {Highcharts.Dictionary<any>} [defaults]
  33466. * @return {void}
  33467. */
  33468. getCyclic: function (prop, value, defaults) {
  33469. 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;
  33470. if (!value) {
  33471. // Pick up either the colorIndex option, or the _colorIndex
  33472. // after Series.update()
  33473. setting = pick(userOptions[indexName], userOptions['_' + indexName]);
  33474. if (defined(setting)) { // after Series.update()
  33475. i = setting;
  33476. }
  33477. else {
  33478. // #6138
  33479. if (!chart.series.length) {
  33480. chart[counterName] = 0;
  33481. }
  33482. userOptions['_' + indexName] = i =
  33483. chart[counterName] % len;
  33484. chart[counterName] += 1;
  33485. }
  33486. if (defaults) {
  33487. value = defaults[i];
  33488. }
  33489. }
  33490. // Set the colorIndex
  33491. if (typeof i !== 'undefined') {
  33492. this[indexName] = i;
  33493. }
  33494. this[prop] = value;
  33495. },
  33496. /**
  33497. * Get the series' color based on either the options or pulled from
  33498. * global options.
  33499. *
  33500. * @private
  33501. * @function Highcharts.Series#getColor
  33502. * @return {void}
  33503. */
  33504. getColor: function () {
  33505. if (this.chart.styledMode) {
  33506. this.getCyclic('color');
  33507. }
  33508. else if (this.options.colorByPoint) {
  33509. // #4359, selected slice got series.color even when colorByPoint
  33510. // was set.
  33511. this.options.color = null;
  33512. }
  33513. else {
  33514. this.getCyclic('color', this.options.color ||
  33515. defaultOptions.plotOptions[this.type].color, this.chart.options.colors);
  33516. }
  33517. },
  33518. /**
  33519. * Get all points' instances created for this series.
  33520. *
  33521. * @private
  33522. * @function Highcharts.Series#getPointsCollection
  33523. * @return {Array<Highcharts.Point>}
  33524. */
  33525. getPointsCollection: function () {
  33526. return (this.hasGroupedData ? this.points : this.data) || [];
  33527. },
  33528. /**
  33529. * Get the series' symbol based on either the options or pulled from
  33530. * global options.
  33531. *
  33532. * @private
  33533. * @function Highcharts.Series#getSymbol
  33534. * @return {void}
  33535. */
  33536. getSymbol: function () {
  33537. var seriesMarkerOption = this.options.marker;
  33538. this.getCyclic('symbol', seriesMarkerOption.symbol, this.chart.options.symbols);
  33539. },
  33540. /**
  33541. * Finds the index of an existing point that matches the given point
  33542. * options.
  33543. *
  33544. * @private
  33545. * @function Highcharts.Series#findPointIndex
  33546. * @param {Highcharts.PointOptionsObject} optionsObject
  33547. * The options of the point.
  33548. * @param {number} fromIndex
  33549. * The index to start searching from, used for optimizing
  33550. * series with required sorting.
  33551. * @returns {number|undefined}
  33552. * Returns the index of a matching point, or undefined if no
  33553. * match is found.
  33554. */
  33555. findPointIndex: function (optionsObject, fromIndex) {
  33556. var id = optionsObject.id,
  33557. x = optionsObject.x,
  33558. oldData = this.points,
  33559. matchingPoint,
  33560. matchedById,
  33561. pointIndex,
  33562. matchKey,
  33563. dataSorting = this.options.dataSorting;
  33564. if (id) {
  33565. matchingPoint = this.chart.get(id);
  33566. }
  33567. else if (this.linkedParent || this.enabledDataSorting) {
  33568. matchKey = (dataSorting && dataSorting.matchByName) ?
  33569. 'name' : 'index';
  33570. matchingPoint = find(oldData, function (oldPoint) {
  33571. return !oldPoint.touched && oldPoint[matchKey] ===
  33572. optionsObject[matchKey];
  33573. });
  33574. // Add unmatched point as a new point
  33575. if (!matchingPoint) {
  33576. return void 0;
  33577. }
  33578. }
  33579. if (matchingPoint) {
  33580. pointIndex = matchingPoint && matchingPoint.index;
  33581. if (typeof pointIndex !== 'undefined') {
  33582. matchedById = true;
  33583. }
  33584. }
  33585. // Search for the same X in the existing data set
  33586. if (typeof pointIndex === 'undefined' && isNumber(x)) {
  33587. pointIndex = this.xData.indexOf(x, fromIndex);
  33588. }
  33589. // Reduce pointIndex if data is cropped
  33590. if (pointIndex !== -1 &&
  33591. typeof pointIndex !== 'undefined' &&
  33592. this.cropped) {
  33593. pointIndex = (pointIndex >= this.cropStart) ?
  33594. pointIndex - this.cropStart : pointIndex;
  33595. }
  33596. if (!matchedById &&
  33597. oldData[pointIndex] && oldData[pointIndex].touched) {
  33598. pointIndex = void 0;
  33599. }
  33600. return pointIndex;
  33601. },
  33602. /**
  33603. * @private
  33604. * @borrows LegendSymbolMixin.drawLineMarker as Highcharts.Series#drawLegendSymbol
  33605. */
  33606. drawLegendSymbol: LegendSymbolMixin.drawLineMarker,
  33607. /**
  33608. * Internal function called from setData. If the point count is the same
  33609. * as is was, or if there are overlapping X values, just run
  33610. * Point.update which is cheaper, allows animation, and keeps references
  33611. * to points. This also allows adding or removing points if the X-es
  33612. * don't match.
  33613. *
  33614. * @private
  33615. * @function Highcharts.Series#updateData
  33616. *
  33617. * @param {Array<Highcharts.PointOptionsType>} data
  33618. *
  33619. * @return {boolean}
  33620. */
  33621. updateData: function (data, animation) {
  33622. var options = this.options,
  33623. dataSorting = options.dataSorting,
  33624. oldData = this.points,
  33625. pointsToAdd = [],
  33626. hasUpdatedByKey,
  33627. i,
  33628. point,
  33629. lastIndex,
  33630. requireSorting = this.requireSorting,
  33631. equalLength = data.length === oldData.length,
  33632. succeeded = true;
  33633. this.xIncrement = null;
  33634. // Iterate the new data
  33635. data.forEach(function (pointOptions, i) {
  33636. var id,
  33637. x,
  33638. pointIndex,
  33639. optionsObject = (defined(pointOptions) &&
  33640. this.pointClass.prototype.optionsToObject.call({ series: this },
  33641. pointOptions)) || {};
  33642. // Get the x of the new data point
  33643. x = optionsObject.x;
  33644. id = optionsObject.id;
  33645. if (id || isNumber(x)) {
  33646. pointIndex = this.findPointIndex(optionsObject, lastIndex);
  33647. // Matching X not found
  33648. // or used already due to ununique x values (#8995),
  33649. // add point (but later)
  33650. if (pointIndex === -1 ||
  33651. typeof pointIndex === 'undefined') {
  33652. pointsToAdd.push(pointOptions);
  33653. // Matching X found, update
  33654. }
  33655. else if (oldData[pointIndex] &&
  33656. pointOptions !== options.data[pointIndex]) {
  33657. oldData[pointIndex].update(pointOptions, false, null, false);
  33658. // Mark it touched, below we will remove all points that
  33659. // are not touched.
  33660. oldData[pointIndex].touched = true;
  33661. // Speed optimize by only searching after last known
  33662. // index. Performs ~20% bettor on large data sets.
  33663. if (requireSorting) {
  33664. lastIndex = pointIndex + 1;
  33665. }
  33666. // Point exists, no changes, don't remove it
  33667. }
  33668. else if (oldData[pointIndex]) {
  33669. oldData[pointIndex].touched = true;
  33670. }
  33671. // If the length is equal and some of the nodes had a
  33672. // match in the same position, we don't want to remove
  33673. // non-matches.
  33674. if (!equalLength ||
  33675. i !== pointIndex ||
  33676. (dataSorting && dataSorting.enabled) ||
  33677. this.hasDerivedData) {
  33678. hasUpdatedByKey = true;
  33679. }
  33680. }
  33681. else {
  33682. // Gather all points that are not matched
  33683. pointsToAdd.push(pointOptions);
  33684. }
  33685. }, this);
  33686. // Remove points that don't exist in the updated data set
  33687. if (hasUpdatedByKey) {
  33688. i = oldData.length;
  33689. while (i--) {
  33690. point = oldData[i];
  33691. if (point && !point.touched && point.remove) {
  33692. point.remove(false, animation);
  33693. }
  33694. }
  33695. // If we did not find keys (ids or x-values), and the length is the
  33696. // same, update one-to-one
  33697. }
  33698. else if (equalLength && (!dataSorting || !dataSorting.enabled)) {
  33699. data.forEach(function (point, i) {
  33700. // .update doesn't exist on a linked, hidden series (#3709)
  33701. // (#10187)
  33702. if (oldData[i].update && point !== oldData[i].y) {
  33703. oldData[i].update(point, false, null, false);
  33704. }
  33705. });
  33706. // Don't add new points since those configs are used above
  33707. pointsToAdd.length = 0;
  33708. // Did not succeed in updating data
  33709. }
  33710. else {
  33711. succeeded = false;
  33712. }
  33713. oldData.forEach(function (point) {
  33714. if (point) {
  33715. point.touched = false;
  33716. }
  33717. });
  33718. if (!succeeded) {
  33719. return false;
  33720. }
  33721. // Add new points
  33722. pointsToAdd.forEach(function (point) {
  33723. this.addPoint(point, false, null, null, false);
  33724. }, this);
  33725. if (this.xIncrement === null &&
  33726. this.xData &&
  33727. this.xData.length) {
  33728. this.xIncrement = arrayMax(this.xData);
  33729. this.autoIncrement();
  33730. }
  33731. return true;
  33732. },
  33733. /**
  33734. * Apply a new set of data to the series and optionally redraw it. The
  33735. * new data array is passed by reference (except in case of
  33736. * `updatePoints`), and may later be mutated when updating the chart
  33737. * data.
  33738. *
  33739. * Note the difference in behaviour when setting the same amount of
  33740. * points, or a different amount of points, as handled by the
  33741. * `updatePoints` parameter.
  33742. *
  33743. * @sample highcharts/members/series-setdata/
  33744. * Set new data from a button
  33745. * @sample highcharts/members/series-setdata-pie/
  33746. * Set data in a pie
  33747. * @sample stock/members/series-setdata/
  33748. * Set new data in Highstock
  33749. * @sample maps/members/series-setdata/
  33750. * Set new data in Highmaps
  33751. *
  33752. * @function Highcharts.Series#setData
  33753. *
  33754. * @param {Array<Highcharts.PointOptionsType>} data
  33755. * Takes an array of data in the same format as described under
  33756. * `series.{type}.data` for the given series type, for example a
  33757. * line series would take data in the form described under
  33758. * [series.line.data](https://api.highcharts.com/highcharts/series.line.data).
  33759. *
  33760. * @param {boolean} [redraw=true]
  33761. * Whether to redraw the chart after the series is altered. If
  33762. * doing more operations on the chart, it is a good idea to set
  33763. * redraw to false and call {@link Chart#redraw} after.
  33764. *
  33765. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  33766. * When the updated data is the same length as the existing data,
  33767. * points will be updated by default, and animation visualizes
  33768. * how the points are changed. Set false to disable animation, or
  33769. * a configuration object to set duration or easing.
  33770. *
  33771. * @param {boolean} [updatePoints=true]
  33772. * When this is true, points will be updated instead of replaced
  33773. * whenever possible. This occurs a) when the updated data is the
  33774. * same length as the existing data, b) when points are matched
  33775. * by their id's, or c) when points can be matched by X values.
  33776. * This allows updating with animation and performs better. In
  33777. * this case, the original array is not passed by reference. Set
  33778. * `false` to prevent.
  33779. *
  33780. * @return {void}
  33781. */
  33782. setData: function (data, redraw, animation, updatePoints) {
  33783. var series = this,
  33784. oldData = series.points,
  33785. oldDataLength = (oldData && oldData.length) || 0,
  33786. dataLength,
  33787. options = series.options,
  33788. chart = series.chart,
  33789. dataSorting = options.dataSorting,
  33790. firstPoint = null,
  33791. xAxis = series.xAxis,
  33792. i,
  33793. turboThreshold = options.turboThreshold,
  33794. pt,
  33795. xData = this.xData,
  33796. yData = this.yData,
  33797. pointArrayMap = series.pointArrayMap,
  33798. valueCount = pointArrayMap && pointArrayMap.length,
  33799. keys = options.keys,
  33800. indexOfX = 0,
  33801. indexOfY = 1,
  33802. updatedData;
  33803. data = data || [];
  33804. dataLength = data.length;
  33805. redraw = pick(redraw, true);
  33806. if (dataSorting && dataSorting.enabled) {
  33807. data = this.sortData(data);
  33808. }
  33809. // First try to run Point.update which is cheaper, allows animation,
  33810. // and keeps references to points.
  33811. if (updatePoints !== false &&
  33812. dataLength &&
  33813. oldDataLength &&
  33814. !series.cropped &&
  33815. !series.hasGroupedData &&
  33816. series.visible &&
  33817. // Soft updating has no benefit in boost, and causes JS error
  33818. // (#8355)
  33819. !series.isSeriesBoosting) {
  33820. updatedData = this.updateData(data, animation);
  33821. }
  33822. if (!updatedData) {
  33823. // Reset properties
  33824. series.xIncrement = null;
  33825. series.colorCounter = 0; // for series with colorByPoint (#1547)
  33826. // Update parallel arrays
  33827. this.parallelArrays.forEach(function (key) {
  33828. series[key + 'Data'].length = 0;
  33829. });
  33830. // In turbo mode, only one- or twodimensional arrays of numbers
  33831. // are allowed. The first value is tested, and we assume that
  33832. // all the rest are defined the same way. Although the 'for'
  33833. // loops are similar, they are repeated inside each if-else
  33834. // conditional for max performance.
  33835. if (turboThreshold && dataLength > turboThreshold) {
  33836. firstPoint = series.getFirstValidPoint(data);
  33837. if (isNumber(firstPoint)) { // assume all points are numbers
  33838. for (i = 0; i < dataLength; i++) {
  33839. xData[i] = this.autoIncrement();
  33840. yData[i] = data[i];
  33841. }
  33842. // Assume all points are arrays when first point is
  33843. }
  33844. else if (isArray(firstPoint)) {
  33845. if (valueCount) { // [x, low, high] or [x, o, h, l, c]
  33846. for (i = 0; i < dataLength; i++) {
  33847. pt = data[i];
  33848. xData[i] = pt[0];
  33849. yData[i] =
  33850. pt.slice(1, valueCount + 1);
  33851. }
  33852. }
  33853. else { // [x, y]
  33854. if (keys) {
  33855. indexOfX = keys.indexOf('x');
  33856. indexOfY = keys.indexOf('y');
  33857. indexOfX = indexOfX >= 0 ? indexOfX : 0;
  33858. indexOfY = indexOfY >= 0 ? indexOfY : 1;
  33859. }
  33860. for (i = 0; i < dataLength; i++) {
  33861. pt = data[i];
  33862. xData[i] = pt[indexOfX];
  33863. yData[i] = pt[indexOfY];
  33864. }
  33865. }
  33866. }
  33867. else {
  33868. // Highcharts expects configs to be numbers or arrays in
  33869. // turbo mode
  33870. error(12, false, chart);
  33871. }
  33872. }
  33873. else {
  33874. for (i = 0; i < dataLength; i++) {
  33875. // stray commas in oldIE:
  33876. if (typeof data[i] !== 'undefined') {
  33877. pt = { series: series };
  33878. series.pointClass.prototype.applyOptions.apply(pt, [data[i]]);
  33879. series.updateParallelArrays(pt, i);
  33880. }
  33881. }
  33882. }
  33883. // Forgetting to cast strings to numbers is a common caveat when
  33884. // handling CSV or JSON
  33885. if (yData && isString(yData[0])) {
  33886. error(14, true, chart);
  33887. }
  33888. series.data = [];
  33889. series.options.data = series.userOptions.data = data;
  33890. // destroy old points
  33891. i = oldDataLength;
  33892. while (i--) {
  33893. if (oldData[i] && oldData[i].destroy) {
  33894. oldData[i].destroy();
  33895. }
  33896. }
  33897. // reset minRange (#878)
  33898. if (xAxis) {
  33899. xAxis.minRange = xAxis.userMinRange;
  33900. }
  33901. // redraw
  33902. series.isDirty = chart.isDirtyBox = true;
  33903. series.isDirtyData = !!oldData;
  33904. animation = false;
  33905. }
  33906. // Typically for pie series, points need to be processed and
  33907. // generated prior to rendering the legend
  33908. if (options.legendType === 'point') {
  33909. this.processData();
  33910. this.generatePoints();
  33911. }
  33912. if (redraw) {
  33913. chart.redraw(animation);
  33914. }
  33915. },
  33916. /**
  33917. * Internal function to sort series data
  33918. *
  33919. * @private
  33920. * @function Highcharts.Series#sortData
  33921. * @param {Array<Highcharts.PointOptionsType>} data
  33922. * Force data grouping.
  33923. * @return {Array<Highcharts.PointOptionsObject>}
  33924. */
  33925. sortData: function (data) {
  33926. var series = this,
  33927. options = series.options,
  33928. dataSorting = options.dataSorting,
  33929. sortKey = dataSorting.sortKey || 'y',
  33930. sortedData,
  33931. getPointOptionsObject = function (series,
  33932. pointOptions) {
  33933. return (defined(pointOptions) &&
  33934. series.pointClass.prototype.optionsToObject.call({
  33935. series: series
  33936. },
  33937. pointOptions)) || {};
  33938. };
  33939. data.forEach(function (pointOptions, i) {
  33940. data[i] = getPointOptionsObject(series, pointOptions);
  33941. data[i].index = i;
  33942. }, this);
  33943. // Sorting
  33944. sortedData = data.concat().sort(function (a, b) {
  33945. var aValue = getNestedProperty(sortKey,
  33946. a);
  33947. var bValue = getNestedProperty(sortKey,
  33948. b);
  33949. return bValue < aValue ? -1 : bValue > aValue ? 1 : 0;
  33950. });
  33951. // Set x value depending on the position in the array
  33952. sortedData.forEach(function (point, i) {
  33953. point.x = i;
  33954. }, this);
  33955. // Set the same x for linked series points if they don't have their
  33956. // own sorting
  33957. if (series.linkedSeries) {
  33958. series.linkedSeries.forEach(function (linkedSeries) {
  33959. var options = linkedSeries.options,
  33960. seriesData = options.data;
  33961. if ((!options.dataSorting ||
  33962. !options.dataSorting.enabled) &&
  33963. seriesData) {
  33964. seriesData.forEach(function (pointOptions, i) {
  33965. seriesData[i] = getPointOptionsObject(linkedSeries, pointOptions);
  33966. if (data[i]) {
  33967. seriesData[i].x = data[i].x;
  33968. seriesData[i].index = i;
  33969. }
  33970. });
  33971. linkedSeries.setData(seriesData, false);
  33972. }
  33973. });
  33974. }
  33975. return data;
  33976. },
  33977. /**
  33978. * Internal function to process the data by cropping away unused data
  33979. * points if the series is longer than the crop threshold. This saves
  33980. * computing time for large series.
  33981. *
  33982. * @private
  33983. * @function Highcharts.Series#getProcessedData
  33984. * @param {boolean} [forceExtremesFromAll]
  33985. * Force getting extremes of a total series data range.
  33986. * @return {Highcharts.SeriesProcessedDataObject}
  33987. */
  33988. getProcessedData: function (forceExtremesFromAll) {
  33989. var series = this,
  33990. // copied during slice operation:
  33991. processedXData = series.xData,
  33992. processedYData = series.yData,
  33993. dataLength = processedXData.length,
  33994. croppedData,
  33995. cropStart = 0,
  33996. cropped,
  33997. distance,
  33998. closestPointRange,
  33999. xAxis = series.xAxis,
  34000. i, // loop variable
  34001. options = series.options,
  34002. cropThreshold = options.cropThreshold,
  34003. getExtremesFromAll = forceExtremesFromAll ||
  34004. series.getExtremesFromAll ||
  34005. options.getExtremesFromAll, // #4599
  34006. isCartesian = series.isCartesian,
  34007. xExtremes,
  34008. val2lin = xAxis && xAxis.val2lin,
  34009. isLog = !!(xAxis && xAxis.logarithmic),
  34010. throwOnUnsorted = series.requireSorting,
  34011. min,
  34012. max;
  34013. if (xAxis) {
  34014. // corrected for log axis (#3053)
  34015. xExtremes = xAxis.getExtremes();
  34016. min = xExtremes.min;
  34017. max = xExtremes.max;
  34018. }
  34019. // optionally filter out points outside the plot area
  34020. if (isCartesian &&
  34021. series.sorted &&
  34022. !getExtremesFromAll &&
  34023. (!cropThreshold ||
  34024. dataLength > cropThreshold ||
  34025. series.forceCrop)) {
  34026. // it's outside current extremes
  34027. if (processedXData[dataLength - 1] < min ||
  34028. processedXData[0] > max) {
  34029. processedXData = [];
  34030. processedYData = [];
  34031. // only crop if it's actually spilling out
  34032. }
  34033. else if (series.yData && (processedXData[0] < min ||
  34034. processedXData[dataLength - 1] > max)) {
  34035. croppedData = this.cropData(series.xData, series.yData, min, max);
  34036. processedXData = croppedData.xData;
  34037. processedYData = croppedData.yData;
  34038. cropStart = croppedData.start;
  34039. cropped = true;
  34040. }
  34041. }
  34042. // Find the closest distance between processed points
  34043. i = processedXData.length || 1;
  34044. while (--i) {
  34045. distance = (isLog ?
  34046. (val2lin(processedXData[i]) -
  34047. val2lin(processedXData[i - 1])) :
  34048. (processedXData[i] -
  34049. processedXData[i - 1]));
  34050. if (distance > 0 &&
  34051. (typeof closestPointRange === 'undefined' ||
  34052. distance < closestPointRange)) {
  34053. closestPointRange = distance;
  34054. // Unsorted data is not supported by the line tooltip, as well
  34055. // as data grouping and navigation in Stock charts (#725) and
  34056. // width calculation of columns (#1900)
  34057. }
  34058. else if (distance < 0 && throwOnUnsorted) {
  34059. error(15, false, series.chart);
  34060. throwOnUnsorted = false; // Only once
  34061. }
  34062. }
  34063. return {
  34064. xData: processedXData,
  34065. yData: processedYData,
  34066. cropped: cropped,
  34067. cropStart: cropStart,
  34068. closestPointRange: closestPointRange
  34069. };
  34070. },
  34071. /**
  34072. * Internal function to apply processed data.
  34073. * In Highstock, this function is extended to provide data grouping.
  34074. *
  34075. * @private
  34076. * @function Highcharts.Series#processData
  34077. * @param {boolean} [force]
  34078. * Force data grouping.
  34079. * @return {boolean|undefined}
  34080. */
  34081. processData: function (force) {
  34082. var series = this,
  34083. xAxis = series.xAxis,
  34084. processedData;
  34085. // If the series data or axes haven't changed, don't go through
  34086. // this. Return false to pass the message on to override methods
  34087. // like in data grouping.
  34088. if (series.isCartesian &&
  34089. !series.isDirty &&
  34090. !xAxis.isDirty &&
  34091. !series.yAxis.isDirty &&
  34092. !force) {
  34093. return false;
  34094. }
  34095. processedData = series.getProcessedData();
  34096. // Record the properties
  34097. series.cropped = processedData.cropped; // undefined or true
  34098. series.cropStart = processedData.cropStart;
  34099. series.processedXData = processedData.xData;
  34100. series.processedYData = processedData.yData;
  34101. series.closestPointRange =
  34102. series.basePointRange = processedData.closestPointRange;
  34103. },
  34104. /**
  34105. * Iterate over xData and crop values between min and max. Returns
  34106. * object containing crop start/end cropped xData with corresponding
  34107. * part of yData, dataMin and dataMax within the cropped range.
  34108. *
  34109. * @private
  34110. * @function Highcharts.Series#cropData
  34111. * @param {Array<number>} xData
  34112. * @param {Array<number>} yData
  34113. * @param {number} min
  34114. * @param {number} max
  34115. * @param {number} [cropShoulder]
  34116. * @return {Highcharts.SeriesCropDataObject}
  34117. */
  34118. cropData: function (xData, yData, min, max, cropShoulder) {
  34119. var dataLength = xData.length,
  34120. cropStart = 0,
  34121. cropEnd = dataLength,
  34122. i,
  34123. j;
  34124. // line-type series need one point outside
  34125. cropShoulder = pick(cropShoulder, this.cropShoulder);
  34126. // iterate up to find slice start
  34127. for (i = 0; i < dataLength; i++) {
  34128. if (xData[i] >= min) {
  34129. cropStart = Math.max(0, i - cropShoulder);
  34130. break;
  34131. }
  34132. }
  34133. // proceed to find slice end
  34134. for (j = i; j < dataLength; j++) {
  34135. if (xData[j] > max) {
  34136. cropEnd = j + cropShoulder;
  34137. break;
  34138. }
  34139. }
  34140. return {
  34141. xData: xData.slice(cropStart, cropEnd),
  34142. yData: yData.slice(cropStart, cropEnd),
  34143. start: cropStart,
  34144. end: cropEnd
  34145. };
  34146. },
  34147. /**
  34148. * Generate the data point after the data has been processed by cropping
  34149. * away unused points and optionally grouped in Highcharts Stock.
  34150. *
  34151. * @private
  34152. * @function Highcharts.Series#generatePoints
  34153. */
  34154. generatePoints: function () {
  34155. var series = this,
  34156. options = series.options,
  34157. dataOptions = options.data,
  34158. data = series.data,
  34159. dataLength,
  34160. processedXData = series.processedXData,
  34161. processedYData = series.processedYData,
  34162. PointClass = series.pointClass,
  34163. processedDataLength = processedXData.length,
  34164. cropStart = series.cropStart || 0,
  34165. cursor,
  34166. hasGroupedData = series.hasGroupedData,
  34167. keys = options.keys,
  34168. point,
  34169. points = [],
  34170. i;
  34171. if (!data && !hasGroupedData) {
  34172. var arr = [];
  34173. arr.length = dataOptions.length;
  34174. data = series.data = arr;
  34175. }
  34176. if (keys && hasGroupedData) {
  34177. // grouped data has already applied keys (#6590)
  34178. series.options.keys = false;
  34179. }
  34180. for (i = 0; i < processedDataLength; i++) {
  34181. cursor = cropStart + i;
  34182. if (!hasGroupedData) {
  34183. point = data[cursor];
  34184. // #970:
  34185. if (!point &&
  34186. typeof dataOptions[cursor] !== 'undefined') {
  34187. data[cursor] = point = (new PointClass()).init(series, dataOptions[cursor], processedXData[i]);
  34188. }
  34189. }
  34190. else {
  34191. // splat the y data in case of ohlc data array
  34192. point = (new PointClass()).init(series, [processedXData[i]].concat(splat(processedYData[i])));
  34193. /**
  34194. * Highstock only. If a point object is created by data
  34195. * grouping, it doesn't reflect actual points in the raw
  34196. * data. In this case, the `dataGroup` property holds
  34197. * information that points back to the raw data.
  34198. *
  34199. * - `dataGroup.start` is the index of the first raw data
  34200. * point in the group.
  34201. *
  34202. * - `dataGroup.length` is the amount of points in the
  34203. * group.
  34204. *
  34205. * @product highstock
  34206. *
  34207. * @name Highcharts.Point#dataGroup
  34208. * @type {Highcharts.DataGroupingInfoObject|undefined}
  34209. */
  34210. point.dataGroup = series.groupMap[i];
  34211. if (point.dataGroup.options) {
  34212. point.options = point.dataGroup.options;
  34213. extend(point, point.dataGroup.options);
  34214. // Collision of props and options (#9770)
  34215. delete point.dataLabels;
  34216. }
  34217. }
  34218. if (point) { // #6279
  34219. /**
  34220. * Contains the point's index in the `Series.points` array.
  34221. *
  34222. * @name Highcharts.Point#index
  34223. * @type {number}
  34224. * @readonly
  34225. */
  34226. point.index = cursor; // For faster access in Point.update
  34227. points[i] = point;
  34228. }
  34229. }
  34230. // restore keys options (#6590)
  34231. series.options.keys = keys;
  34232. // Hide cropped-away points - this only runs when the number of
  34233. // points is above cropThreshold, or when swithching view from
  34234. // non-grouped data to grouped data (#637)
  34235. if (data &&
  34236. (processedDataLength !== (dataLength = data.length) ||
  34237. hasGroupedData)) {
  34238. for (i = 0; i < dataLength; i++) {
  34239. // when has grouped data, clear all points
  34240. if (i === cropStart && !hasGroupedData) {
  34241. i += processedDataLength;
  34242. }
  34243. if (data[i]) {
  34244. data[i].destroyElements();
  34245. data[i].plotX = void 0; // #1003
  34246. }
  34247. }
  34248. }
  34249. /**
  34250. * Read only. An array containing those values converted to points.
  34251. * In case the series data length exceeds the `cropThreshold`, or if
  34252. * the data is grouped, `series.data` doesn't contain all the
  34253. * points. Also, in case a series is hidden, the `data` array may be
  34254. * empty. To access raw values, `series.options.data` will always be
  34255. * up to date. `Series.data` only contains the points that have been
  34256. * created on demand. To modify the data, use
  34257. * {@link Highcharts.Series#setData} or
  34258. * {@link Highcharts.Point#update}.
  34259. *
  34260. * @see Series.points
  34261. *
  34262. * @name Highcharts.Series#data
  34263. * @type {Array<Highcharts.Point>}
  34264. */
  34265. series.data = data;
  34266. /**
  34267. * An array containing all currently visible point objects. In case
  34268. * of cropping, the cropped-away points are not part of this array.
  34269. * The `series.points` array starts at `series.cropStart` compared
  34270. * to `series.data` and `series.options.data`. If however the series
  34271. * data is grouped, these can't be correlated one to one. To modify
  34272. * the data, use {@link Highcharts.Series#setData} or
  34273. * {@link Highcharts.Point#update}.
  34274. *
  34275. * @name Highcharts.Series#points
  34276. * @type {Array<Highcharts.Point>}
  34277. */
  34278. series.points = points;
  34279. fireEvent(this, 'afterGeneratePoints');
  34280. },
  34281. /**
  34282. * Get current X extremes for the visible data.
  34283. *
  34284. * @private
  34285. * @function Highcharts.Series#getXExtremes
  34286. *
  34287. * @param {Array<number>} xData
  34288. * The data to inspect. Defaults to the current data within the
  34289. * visible range.
  34290. * @return {Highcharts.RangeObject}
  34291. */
  34292. getXExtremes: function (xData) {
  34293. return {
  34294. min: arrayMin(xData),
  34295. max: arrayMax(xData)
  34296. };
  34297. },
  34298. /**
  34299. * Calculate Y extremes for the visible data. The result is returned
  34300. * as an object with `dataMin` and `dataMax` properties.
  34301. *
  34302. * @private
  34303. * @function Highcharts.Series#getExtremes
  34304. * @param {Array<number>} [yData]
  34305. * The data to inspect. Defaults to the current data within the
  34306. * visible range.
  34307. * @param {boolean} [forceExtremesFromAll]
  34308. * Force getting extremes of a total series data range.
  34309. * @return {Highcharts.DataExtremesObject}
  34310. */
  34311. getExtremes: function (yData, forceExtremesFromAll) {
  34312. var xAxis = this.xAxis,
  34313. yAxis = this.yAxis,
  34314. xData = this.processedXData || this.xData,
  34315. yDataLength,
  34316. activeYData = [],
  34317. activeCounter = 0,
  34318. // #2117, need to compensate for log X axis
  34319. xExtremes,
  34320. xMin = 0,
  34321. xMax = 0,
  34322. validValue,
  34323. withinRange,
  34324. // Handle X outside the viewed area. This does not work with
  34325. // non-sorted data like scatter (#7639).
  34326. shoulder = this.requireSorting ? this.cropShoulder : 0,
  34327. positiveValuesOnly = yAxis ? yAxis.positiveValuesOnly : false,
  34328. x,
  34329. y,
  34330. i,
  34331. j;
  34332. yData = yData || this.stackedYData || this.processedYData || [];
  34333. yDataLength = yData.length;
  34334. if (xAxis) {
  34335. xExtremes = xAxis.getExtremes();
  34336. xMin = xExtremes.min;
  34337. xMax = xExtremes.max;
  34338. }
  34339. for (i = 0; i < yDataLength; i++) {
  34340. x = xData[i];
  34341. y = yData[i];
  34342. // For points within the visible range, including the first
  34343. // point outside the visible range (#7061), consider y extremes.
  34344. validValue = ((isNumber(y) || isArray(y)) &&
  34345. ((y.length || y > 0) || !positiveValuesOnly));
  34346. withinRange = (forceExtremesFromAll ||
  34347. this.getExtremesFromAll ||
  34348. this.options.getExtremesFromAll ||
  34349. this.cropped ||
  34350. !xAxis || // for colorAxis support
  34351. ((xData[i + shoulder] || x) >= xMin &&
  34352. (xData[i - shoulder] || x) <= xMax));
  34353. if (validValue && withinRange) {
  34354. j = y.length;
  34355. if (j) { // array, like ohlc or range data
  34356. while (j--) {
  34357. if (isNumber(y[j])) { // #7380, #11513
  34358. activeYData[activeCounter++] = y[j];
  34359. }
  34360. }
  34361. }
  34362. else {
  34363. activeYData[activeCounter++] = y;
  34364. }
  34365. }
  34366. }
  34367. var dataExtremes = {
  34368. dataMin: arrayMin(activeYData),
  34369. dataMax: arrayMax(activeYData)
  34370. };
  34371. fireEvent(this, 'afterGetExtremes', { dataExtremes: dataExtremes });
  34372. return dataExtremes;
  34373. },
  34374. /**
  34375. * Set the current data extremes as `dataMin` and `dataMax` on the
  34376. * Series item. Use this only when the series properties should be
  34377. * updated.
  34378. *
  34379. * @private
  34380. * @function Highcharts.Series#applyExtremes
  34381. * @return {void}
  34382. */
  34383. applyExtremes: function () {
  34384. var dataExtremes = this.getExtremes();
  34385. /**
  34386. * Contains the minimum value of the series' data point. Some series
  34387. * types like `networkgraph` do not support this property as they
  34388. * lack a `y`-value.
  34389. * @name Highcharts.Series#dataMin
  34390. * @type {number|undefined}
  34391. * @readonly
  34392. */
  34393. this.dataMin = dataExtremes.dataMin;
  34394. /**
  34395. * Contains the maximum value of the series' data point. Some series
  34396. * types like `networkgraph` do not support this property as they
  34397. * lack a `y`-value.
  34398. * @name Highcharts.Series#dataMax
  34399. * @type {number|undefined}
  34400. * @readonly
  34401. */
  34402. this.dataMax = dataExtremes.dataMax;
  34403. return dataExtremes;
  34404. },
  34405. /**
  34406. * Find and return the first non null point in the data
  34407. *
  34408. * @private
  34409. * @function Highcharts.Series.getFirstValidPoint
  34410. * @param {Array<Highcharts.PointOptionsType>} data
  34411. * Array of options for points
  34412. *
  34413. * @return {Highcharts.PointOptionsType}
  34414. */
  34415. getFirstValidPoint: function (data) {
  34416. var firstPoint = null,
  34417. dataLength = data.length,
  34418. i = 0;
  34419. while (firstPoint === null && i < dataLength) {
  34420. firstPoint = data[i];
  34421. i++;
  34422. }
  34423. return firstPoint;
  34424. },
  34425. /**
  34426. * Translate data points from raw data values to chart specific
  34427. * positioning data needed later in the `drawPoints` and `drawGraph`
  34428. * functions. This function can be overridden in plugins and custom
  34429. * series type implementations.
  34430. *
  34431. * @function Highcharts.Series#translate
  34432. * @return {void}
  34433. * @fires Highcharts.Series#events:translate
  34434. */
  34435. translate: function () {
  34436. if (!this.processedXData) { // hidden series
  34437. this.processData();
  34438. }
  34439. this.generatePoints();
  34440. var series = this,
  34441. options = series.options,
  34442. stacking = options.stacking,
  34443. xAxis = series.xAxis,
  34444. categories = xAxis.categories,
  34445. enabledDataSorting = series.enabledDataSorting,
  34446. yAxis = series.yAxis,
  34447. points = series.points,
  34448. dataLength = points.length,
  34449. hasModifyValue = !!series.modifyValue,
  34450. i,
  34451. pointPlacement = series.pointPlacementToXValue(), // #7860
  34452. dynamicallyPlaced = Boolean(pointPlacement),
  34453. threshold = options.threshold,
  34454. stackThreshold = options.startFromThreshold ? threshold : 0,
  34455. plotX,
  34456. lastPlotX,
  34457. stackIndicator,
  34458. zoneAxis = this.zoneAxis || 'y',
  34459. closestPointRangePx = Number.MAX_VALUE;
  34460. /**
  34461. * Plotted coordinates need to be within a limited range. Drawing
  34462. * too far outside the viewport causes various rendering issues
  34463. * (#3201, #3923, #7555).
  34464. * @private
  34465. */
  34466. function limitedRange(val) {
  34467. return clamp(val, -1e5, 1e5);
  34468. }
  34469. // Translate each point
  34470. for (i = 0; i < dataLength; i++) {
  34471. var point = points[i],
  34472. xValue = point.x,
  34473. yValue = point.y,
  34474. yBottom = point.low,
  34475. stack = stacking && yAxis.stacking && yAxis.stacking.stacks[(series.negStacks &&
  34476. yValue <
  34477. (stackThreshold ? 0 : threshold) ?
  34478. '-' :
  34479. '') + series.stackKey],
  34480. pointStack,
  34481. stackValues;
  34482. if (yAxis.positiveValuesOnly && !yAxis.validatePositiveValue(yValue) ||
  34483. xAxis.positiveValuesOnly && !xAxis.validatePositiveValue(xValue)) {
  34484. point.isNull = true;
  34485. }
  34486. // Get the plotX translation
  34487. point.plotX = plotX = correctFloat(// #5236
  34488. limitedRange(xAxis.translate(// #3923
  34489. xValue, 0, 0, 0, 1, pointPlacement, this.type === 'flags')) // #3923
  34490. );
  34491. // Calculate the bottom y value for stacked series
  34492. if (stacking &&
  34493. series.visible &&
  34494. stack &&
  34495. stack[xValue]) {
  34496. stackIndicator = series.getStackIndicator(stackIndicator, xValue, series.index);
  34497. if (!point.isNull) {
  34498. pointStack = stack[xValue];
  34499. stackValues =
  34500. pointStack.points[stackIndicator.key];
  34501. }
  34502. }
  34503. if (isArray(stackValues)) {
  34504. yBottom = stackValues[0];
  34505. yValue = stackValues[1];
  34506. if (yBottom === stackThreshold &&
  34507. stackIndicator.key ===
  34508. stack[xValue].base) {
  34509. yBottom = pick((isNumber(threshold) && threshold), yAxis.min);
  34510. }
  34511. // #1200, #1232
  34512. if (yAxis.positiveValuesOnly && yBottom <= 0) {
  34513. yBottom = null;
  34514. }
  34515. point.total = point.stackTotal = pointStack.total;
  34516. point.percentage =
  34517. pointStack.total &&
  34518. (point.y / pointStack.total * 100);
  34519. point.stackY = yValue;
  34520. // Place the stack label
  34521. // in case of variwide series (where widths of points are
  34522. // different in most cases), stack labels are positioned
  34523. // wrongly, so the call of the setOffset is omited here and
  34524. // labels are correctly positioned later, at the end of the
  34525. // variwide's translate function (#10962)
  34526. if (!series.irregularWidths) {
  34527. pointStack.setOffset(series.pointXOffset || 0, series.barW || 0);
  34528. }
  34529. }
  34530. // Set translated yBottom or remove it
  34531. point.yBottom = defined(yBottom) ?
  34532. limitedRange(yAxis.translate(yBottom, 0, 1, 0, 1)) :
  34533. null;
  34534. // general hook, used for Highstock compare mode
  34535. if (hasModifyValue) {
  34536. yValue = series.modifyValue(yValue, point);
  34537. }
  34538. // Set the the plotY value, reset it for redraws
  34539. // #3201
  34540. point.plotY = ((typeof yValue === 'number' && yValue !== Infinity) ?
  34541. limitedRange(yAxis.translate(yValue, 0, 1, 0, 1)) :
  34542. void 0);
  34543. point.isInside = this.isPointInside(point);
  34544. // Set client related positions for mouse tracking
  34545. point.clientX = dynamicallyPlaced ?
  34546. correctFloat(xAxis.translate(xValue, 0, 0, 0, 1, pointPlacement)) :
  34547. plotX; // #1514, #5383, #5518
  34548. // Negative points. For bubble charts, this means negative z
  34549. // values (#9728)
  34550. point.negative = point[zoneAxis] < (options[zoneAxis + 'Threshold'] ||
  34551. threshold ||
  34552. 0);
  34553. // some API data
  34554. point.category = (categories &&
  34555. typeof categories[point.x] !== 'undefined' ?
  34556. categories[point.x] :
  34557. point.x);
  34558. // Determine auto enabling of markers (#3635, #5099)
  34559. if (!point.isNull && point.visible !== false) {
  34560. if (typeof lastPlotX !== 'undefined') {
  34561. closestPointRangePx = Math.min(closestPointRangePx, Math.abs(plotX - lastPlotX));
  34562. }
  34563. lastPlotX = plotX;
  34564. }
  34565. // Find point zone
  34566. point.zone = (this.zones.length && point.getZone());
  34567. // Animate new points with data sorting
  34568. if (!point.graphic && series.group && enabledDataSorting) {
  34569. point.isNew = true;
  34570. }
  34571. }
  34572. series.closestPointRangePx = closestPointRangePx;
  34573. fireEvent(this, 'afterTranslate');
  34574. },
  34575. /**
  34576. * Return the series points with null points filtered out.
  34577. *
  34578. * @function Highcharts.Series#getValidPoints
  34579. *
  34580. * @param {Array<Highcharts.Point>} [points]
  34581. * The points to inspect, defaults to {@link Series.points}.
  34582. *
  34583. * @param {boolean} [insideOnly=false]
  34584. * Whether to inspect only the points that are inside the visible
  34585. * view.
  34586. *
  34587. * @param {boolean} [allowNull=false]
  34588. * Whether to allow null points to pass as valid points.
  34589. *
  34590. * @return {Array<Highcharts.Point>}
  34591. * The valid points.
  34592. */
  34593. getValidPoints: function (points, insideOnly, allowNull) {
  34594. var chart = this.chart;
  34595. // #3916, #5029, #5085
  34596. return (points || this.points || []).filter(function isValidPoint(point) {
  34597. if (insideOnly && !chart.isInsidePlot(point.plotX, point.plotY, chart.inverted)) {
  34598. return false;
  34599. }
  34600. return point.visible !== false &&
  34601. (allowNull || !point.isNull);
  34602. });
  34603. },
  34604. /**
  34605. * Get the clipping for the series. Could be called for a series to
  34606. * initiate animating the clip or to set the final clip (only width
  34607. * and x).
  34608. *
  34609. * @private
  34610. * @function Highcharts.Series#getClip
  34611. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  34612. * Initialize the animation.
  34613. * @param {boolean} [finalBox]
  34614. * Final size for the clip - end state for the animation.
  34615. * @return {Highcharts.Dictionary<number>}
  34616. */
  34617. getClipBox: function (animation, finalBox) {
  34618. var series = this,
  34619. options = series.options,
  34620. chart = series.chart,
  34621. inverted = chart.inverted,
  34622. xAxis = series.xAxis,
  34623. yAxis = xAxis && series.yAxis,
  34624. clipBox,
  34625. scrollablePlotAreaOptions = chart.options.chart.scrollablePlotArea || {};
  34626. if (animation && options.clip === false && yAxis) {
  34627. // support for not clipped series animation (#10450)
  34628. clipBox = inverted ? {
  34629. y: -chart.chartWidth + yAxis.len + yAxis.pos,
  34630. height: chart.chartWidth,
  34631. width: chart.chartHeight,
  34632. x: -chart.chartHeight + xAxis.len + xAxis.pos
  34633. } : {
  34634. y: -yAxis.pos,
  34635. height: chart.chartHeight,
  34636. width: chart.chartWidth,
  34637. x: -xAxis.pos
  34638. };
  34639. // x and width will be changed later when setting for animation
  34640. // initial state in Series.setClip
  34641. }
  34642. else {
  34643. clipBox = series.clipBox || chart.clipBox;
  34644. if (finalBox) {
  34645. clipBox.width = chart.plotSizeX;
  34646. clipBox.x = (chart.scrollablePixelsX || 0) *
  34647. (scrollablePlotAreaOptions.scrollPositionX || 0);
  34648. }
  34649. }
  34650. return !finalBox ? clipBox : {
  34651. width: clipBox.width,
  34652. x: clipBox.x
  34653. };
  34654. },
  34655. /**
  34656. * Set the clipping for the series. For animated series it is called
  34657. * twice, first to initiate animating the clip then the second time
  34658. * without the animation to set the final clip.
  34659. *
  34660. * @private
  34661. * @function Highcharts.Series#setClip
  34662. * @param {boolean|Highcharts.AnimationOptionsObject} [animation]
  34663. */
  34664. setClip: function (animation) {
  34665. var chart = this.chart, options = this.options, renderer = chart.renderer, inverted = chart.inverted, seriesClipBox = this.clipBox, clipBox = this.getClipBox(animation), sharedClipKey = this.sharedClipKey ||
  34666. [
  34667. '_sharedClip',
  34668. animation && animation.duration,
  34669. animation && animation.easing,
  34670. clipBox.height,
  34671. options.xAxis,
  34672. options.yAxis
  34673. ].join(','), // #4526
  34674. clipRect = chart[sharedClipKey], markerClipRect = chart[sharedClipKey + 'm'];
  34675. if (animation) {
  34676. clipBox.width = 0;
  34677. if (inverted) {
  34678. clipBox.x = chart.plotHeight +
  34679. (options.clip !== false ? 0 : chart.plotTop);
  34680. }
  34681. }
  34682. // If a clipping rectangle with the same properties is currently
  34683. // present in the chart, use that.
  34684. if (!clipRect) {
  34685. // When animation is set, prepare the initial positions
  34686. if (animation) {
  34687. chart[sharedClipKey + 'm'] = markerClipRect =
  34688. renderer.clipRect(
  34689. // include the width of the first marker
  34690. inverted ? chart.plotSizeX + 99 : -99, inverted ? -chart.plotLeft : -chart.plotTop, 99, inverted ? chart.chartWidth : chart.chartHeight);
  34691. }
  34692. chart[sharedClipKey] = clipRect = renderer.clipRect(clipBox);
  34693. // Create hashmap for series indexes
  34694. clipRect.count = { length: 0 };
  34695. // When the series is rendered again before starting animating, in
  34696. // compliance to a responsive rule
  34697. }
  34698. else if (!chart.hasLoaded) {
  34699. clipRect.attr(clipBox);
  34700. }
  34701. if (animation) {
  34702. if (!clipRect.count[this.index]) {
  34703. clipRect.count[this.index] = true;
  34704. clipRect.count.length += 1;
  34705. }
  34706. }
  34707. if (options.clip !== false || animation) {
  34708. this.group.clip(animation || seriesClipBox ? clipRect : chart.clipRect);
  34709. this.markerGroup.clip(markerClipRect);
  34710. this.sharedClipKey = sharedClipKey;
  34711. }
  34712. // Remove the shared clipping rectangle when all series are shown
  34713. if (!animation) {
  34714. if (clipRect.count[this.index]) {
  34715. delete clipRect.count[this.index];
  34716. clipRect.count.length -= 1;
  34717. }
  34718. if (clipRect.count.length === 0 &&
  34719. sharedClipKey &&
  34720. chart[sharedClipKey]) {
  34721. if (!seriesClipBox) {
  34722. chart[sharedClipKey] =
  34723. chart[sharedClipKey].destroy();
  34724. }
  34725. if (chart[sharedClipKey + 'm']) {
  34726. chart[sharedClipKey + 'm'] =
  34727. chart[sharedClipKey + 'm'].destroy();
  34728. }
  34729. }
  34730. }
  34731. },
  34732. /**
  34733. * Animate in the series. Called internally twice. First with the `init`
  34734. * parameter set to true, which sets up the initial state of the
  34735. * animation. Then when ready, it is called with the `init` parameter
  34736. * undefined, in order to perform the actual animation. After the
  34737. * second run, the function is removed.
  34738. *
  34739. * @function Highcharts.Series#animate
  34740. *
  34741. * @param {boolean} [init]
  34742. * Initialize the animation.
  34743. */
  34744. animate: function (init) {
  34745. var series = this,
  34746. chart = series.chart,
  34747. animation = animObject(series.options.animation),
  34748. clipRect,
  34749. sharedClipKey,
  34750. finalBox;
  34751. // Initialize the animation. Set up the clipping rectangle.
  34752. if (!chart.hasRendered) {
  34753. if (init) {
  34754. series.setClip(animation);
  34755. // Run the animation
  34756. }
  34757. else {
  34758. sharedClipKey = this.sharedClipKey;
  34759. clipRect = chart[sharedClipKey];
  34760. finalBox = series.getClipBox(animation, true);
  34761. if (clipRect) {
  34762. clipRect.animate(finalBox, animation);
  34763. }
  34764. if (chart[sharedClipKey + 'm']) {
  34765. chart[sharedClipKey + 'm'].animate({
  34766. width: finalBox.width + 99,
  34767. x: finalBox.x - (chart.inverted ? 0 : 99)
  34768. }, animation);
  34769. }
  34770. }
  34771. }
  34772. },
  34773. /**
  34774. * This runs after animation to land on the final plot clipping.
  34775. *
  34776. * @private
  34777. * @function Highcharts.Series#afterAnimate
  34778. * @fires Highcharts.Series#event:afterAnimate
  34779. */
  34780. afterAnimate: function () {
  34781. this.setClip();
  34782. fireEvent(this, 'afterAnimate');
  34783. this.finishedAnimating = true;
  34784. },
  34785. /**
  34786. * Draw the markers for line-like series types, and columns or other
  34787. * graphical representation for {@link Point} objects for other series
  34788. * types. The resulting element is typically stored as
  34789. * {@link Point.graphic}, and is created on the first call and updated
  34790. * and moved on subsequent calls.
  34791. *
  34792. * @function Highcharts.Series#drawPoints
  34793. */
  34794. drawPoints: function () {
  34795. var series = this,
  34796. points = series.points,
  34797. chart = series.chart,
  34798. i,
  34799. point,
  34800. graphic,
  34801. verb,
  34802. options = series.options,
  34803. seriesMarkerOptions = options.marker,
  34804. pointMarkerOptions,
  34805. hasPointMarker,
  34806. markerGroup = (series[series.specialGroup] ||
  34807. series.markerGroup),
  34808. xAxis = series.xAxis,
  34809. markerAttribs,
  34810. globallyEnabled = pick(seriesMarkerOptions.enabled, !xAxis || xAxis.isRadial ? true : null,
  34811. // Use larger or equal as radius is null in bubbles (#6321)
  34812. series.closestPointRangePx >= (seriesMarkerOptions.enabledThreshold *
  34813. seriesMarkerOptions.radius));
  34814. if (seriesMarkerOptions.enabled !== false ||
  34815. series._hasPointMarkers) {
  34816. for (i = 0; i < points.length; i++) {
  34817. point = points[i];
  34818. graphic = point.graphic;
  34819. verb = graphic ? 'animate' : 'attr';
  34820. pointMarkerOptions = point.marker || {};
  34821. hasPointMarker = !!point.marker;
  34822. var shouldDrawMarker = ((globallyEnabled &&
  34823. typeof pointMarkerOptions.enabled === 'undefined') || pointMarkerOptions.enabled) && !point.isNull && point.visible !== false;
  34824. // only draw the point if y is defined
  34825. if (shouldDrawMarker) {
  34826. // Shortcuts
  34827. var symbol = pick(pointMarkerOptions.symbol,
  34828. series.symbol);
  34829. markerAttribs = series.markerAttribs(point, (point.selected && 'select'));
  34830. // Set starting position for point sliding animation.
  34831. if (series.enabledDataSorting) {
  34832. point.startXPos = xAxis.reversed ?
  34833. -markerAttribs.width :
  34834. xAxis.width;
  34835. }
  34836. var isInside = point.isInside !== false;
  34837. if (graphic) { // update
  34838. // Since the marker group isn't clipped, each
  34839. // individual marker must be toggled
  34840. graphic[isInside ? 'show' : 'hide'](isInside)
  34841. .animate(markerAttribs);
  34842. }
  34843. else if (isInside &&
  34844. (markerAttribs.width > 0 || point.hasImage)) {
  34845. /**
  34846. * The graphic representation of the point.
  34847. * Typically this is a simple shape, like a `rect`
  34848. * for column charts or `path` for line markers, but
  34849. * for some complex series types like boxplot or 3D
  34850. * charts, the graphic may be a `g` element
  34851. * containing other shapes. The graphic is generated
  34852. * the first time {@link Series#drawPoints} runs,
  34853. * and updated and moved on subsequent runs.
  34854. *
  34855. * @name Point#graphic
  34856. * @type {SVGElement}
  34857. */
  34858. point.graphic = graphic = chart.renderer
  34859. .symbol(symbol, markerAttribs.x, markerAttribs.y, markerAttribs.width, markerAttribs.height, hasPointMarker ?
  34860. pointMarkerOptions :
  34861. seriesMarkerOptions)
  34862. .add(markerGroup);
  34863. // Sliding animation for new points
  34864. if (series.enabledDataSorting &&
  34865. chart.hasRendered) {
  34866. graphic.attr({
  34867. x: point.startXPos
  34868. });
  34869. verb = 'animate';
  34870. }
  34871. }
  34872. if (graphic && verb === 'animate') { // update
  34873. // Since the marker group isn't clipped, each
  34874. // individual marker must be toggled
  34875. graphic[isInside ? 'show' : 'hide'](isInside)
  34876. .animate(markerAttribs);
  34877. }
  34878. // Presentational attributes
  34879. if (graphic && !chart.styledMode) {
  34880. graphic[verb](series.pointAttribs(point, (point.selected && 'select')));
  34881. }
  34882. if (graphic) {
  34883. graphic.addClass(point.getClassName(), true);
  34884. }
  34885. }
  34886. else if (graphic) {
  34887. point.graphic = graphic.destroy(); // #1269
  34888. }
  34889. }
  34890. }
  34891. },
  34892. /**
  34893. * Get non-presentational attributes for a point. Used internally for
  34894. * both styled mode and classic. Can be overridden for different series
  34895. * types.
  34896. *
  34897. * @see Series#pointAttribs
  34898. *
  34899. * @function Highcharts.Series#markerAttribs
  34900. *
  34901. * @param {Highcharts.Point} point
  34902. * The Point to inspect.
  34903. *
  34904. * @param {string} [state]
  34905. * The state, can be either `hover`, `select` or undefined.
  34906. *
  34907. * @return {Highcharts.SVGAttributes}
  34908. * A hash containing those attributes that are not settable from
  34909. * CSS.
  34910. */
  34911. markerAttribs: function (point, state) {
  34912. var seriesOptions = this.options,
  34913. seriesMarkerOptions = seriesOptions.marker,
  34914. seriesStateOptions,
  34915. pointMarkerOptions = point.marker || {},
  34916. symbol = (pointMarkerOptions.symbol ||
  34917. seriesMarkerOptions.symbol),
  34918. pointStateOptions,
  34919. radius = pick(pointMarkerOptions.radius,
  34920. seriesMarkerOptions.radius),
  34921. attribs;
  34922. // Handle hover and select states
  34923. if (state) {
  34924. seriesStateOptions = seriesMarkerOptions.states[state];
  34925. pointStateOptions = pointMarkerOptions.states &&
  34926. pointMarkerOptions.states[state];
  34927. radius = pick(pointStateOptions && pointStateOptions.radius, seriesStateOptions && seriesStateOptions.radius, radius + (seriesStateOptions && seriesStateOptions.radiusPlus ||
  34928. 0));
  34929. }
  34930. point.hasImage = symbol && symbol.indexOf('url') === 0;
  34931. if (point.hasImage) {
  34932. radius = 0; // and subsequently width and height is not set
  34933. }
  34934. attribs = {
  34935. // Math.floor for #1843:
  34936. x: seriesOptions.crisp ?
  34937. Math.floor(point.plotX) - radius :
  34938. point.plotX - radius,
  34939. y: point.plotY - radius
  34940. };
  34941. if (radius) {
  34942. attribs.width = attribs.height = 2 * radius;
  34943. }
  34944. return attribs;
  34945. },
  34946. /**
  34947. * Internal function to get presentational attributes for each point.
  34948. * Unlike {@link Series#markerAttribs}, this function should return
  34949. * those attributes that can also be set in CSS. In styled mode,
  34950. * `pointAttribs` won't be called.
  34951. *
  34952. * @private
  34953. * @function Highcharts.Series#pointAttribs
  34954. *
  34955. * @param {Highcharts.Point} [point]
  34956. * The point instance to inspect.
  34957. *
  34958. * @param {string} [state]
  34959. * The point state, can be either `hover`, `select` or 'normal'.
  34960. * If undefined, normal state is assumed.
  34961. *
  34962. * @return {Highcharts.SVGAttributes}
  34963. * The presentational attributes to be set on the point.
  34964. */
  34965. pointAttribs: function (point, state) {
  34966. var seriesMarkerOptions = this.options.marker,
  34967. seriesStateOptions,
  34968. pointOptions = point && point.options,
  34969. pointMarkerOptions = ((pointOptions && pointOptions.marker) || {}),
  34970. pointStateOptions,
  34971. color = this.color,
  34972. pointColorOption = pointOptions && pointOptions.color,
  34973. pointColor = point && point.color,
  34974. strokeWidth = pick(pointMarkerOptions.lineWidth,
  34975. seriesMarkerOptions.lineWidth),
  34976. zoneColor = point && point.zone && point.zone.color,
  34977. fill,
  34978. stroke,
  34979. opacity = 1;
  34980. color = (pointColorOption ||
  34981. zoneColor ||
  34982. pointColor ||
  34983. color);
  34984. fill = (pointMarkerOptions.fillColor ||
  34985. seriesMarkerOptions.fillColor ||
  34986. color);
  34987. stroke = (pointMarkerOptions.lineColor ||
  34988. seriesMarkerOptions.lineColor ||
  34989. color);
  34990. // Handle hover and select states
  34991. state = state || 'normal';
  34992. if (state) {
  34993. seriesStateOptions = seriesMarkerOptions.states[state];
  34994. pointStateOptions = (pointMarkerOptions.states &&
  34995. pointMarkerOptions.states[state]) || {};
  34996. strokeWidth = pick(pointStateOptions.lineWidth, seriesStateOptions.lineWidth, strokeWidth + pick(pointStateOptions.lineWidthPlus, seriesStateOptions.lineWidthPlus, 0));
  34997. fill = (pointStateOptions.fillColor ||
  34998. seriesStateOptions.fillColor ||
  34999. fill);
  35000. stroke = (pointStateOptions.lineColor ||
  35001. seriesStateOptions.lineColor ||
  35002. stroke);
  35003. opacity = pick(pointStateOptions.opacity, seriesStateOptions.opacity, opacity);
  35004. }
  35005. return {
  35006. 'stroke': stroke,
  35007. 'stroke-width': strokeWidth,
  35008. 'fill': fill,
  35009. 'opacity': opacity
  35010. };
  35011. },
  35012. /**
  35013. * Clear DOM objects and free up memory.
  35014. *
  35015. * @private
  35016. * @function Highcharts.Series#destroy
  35017. * @param {boolean} [keepEventsForUpdate]
  35018. * @return {void}
  35019. * @fires Highcharts.Series#event:destroy
  35020. */
  35021. destroy: function (keepEventsForUpdate) {
  35022. var series = this,
  35023. chart = series.chart,
  35024. issue134 = /AppleWebKit\/533/.test(win.navigator.userAgent),
  35025. destroy,
  35026. i,
  35027. data = series.data || [],
  35028. point,
  35029. axis;
  35030. // add event hook
  35031. fireEvent(series, 'destroy');
  35032. // remove events
  35033. this.removeEvents(keepEventsForUpdate);
  35034. // erase from axes
  35035. (series.axisTypes || []).forEach(function (AXIS) {
  35036. axis = series[AXIS];
  35037. if (axis && axis.series) {
  35038. erase(axis.series, series);
  35039. axis.isDirty = axis.forceRedraw = true;
  35040. }
  35041. });
  35042. // remove legend items
  35043. if (series.legendItem) {
  35044. series.chart.legend.destroyItem(series);
  35045. }
  35046. // destroy all points with their elements
  35047. i = data.length;
  35048. while (i--) {
  35049. point = data[i];
  35050. if (point && point.destroy) {
  35051. point.destroy();
  35052. }
  35053. }
  35054. series.points = null;
  35055. // Clear the animation timeout if we are destroying the series
  35056. // during initial animation
  35057. U.clearTimeout(series.animationTimeout);
  35058. // Destroy all SVGElements associated to the series
  35059. objectEach(series, function (val, prop) {
  35060. // Survive provides a hook for not destroying
  35061. if (val instanceof SVGElement && !val.survive) {
  35062. // issue 134 workaround
  35063. destroy = issue134 && prop === 'group' ?
  35064. 'hide' :
  35065. 'destroy';
  35066. val[destroy]();
  35067. }
  35068. });
  35069. // remove from hoverSeries
  35070. if (chart.hoverSeries === series) {
  35071. chart.hoverSeries = null;
  35072. }
  35073. erase(chart.series, series);
  35074. chart.orderSeries();
  35075. // clear all members
  35076. objectEach(series, function (val, prop) {
  35077. if (!keepEventsForUpdate || prop !== 'hcEvents') {
  35078. delete series[prop];
  35079. }
  35080. });
  35081. },
  35082. /**
  35083. * Get the graph path.
  35084. *
  35085. * @private
  35086. * @function Highcharts.Series#getGraphPath
  35087. * @param {Array<Highcharts.Point>} points
  35088. * @param {boolean} [nullsAsZeroes]
  35089. * @param {boolean} [connectCliffs]
  35090. * @return {Highcharts.SVGPathArray}
  35091. */
  35092. getGraphPath: function (points, nullsAsZeroes, connectCliffs) {
  35093. var series = this,
  35094. options = series.options,
  35095. step = options.step,
  35096. reversed,
  35097. graphPath = [],
  35098. xMap = [],
  35099. gap;
  35100. points = points || series.points;
  35101. // Bottom of a stack is reversed
  35102. reversed = points.reversed;
  35103. if (reversed) {
  35104. points.reverse();
  35105. }
  35106. // Reverse the steps (#5004)
  35107. step = {
  35108. right: 1,
  35109. center: 2
  35110. }[step] || (step && 3);
  35111. if (step && reversed) {
  35112. step = 4 - step;
  35113. }
  35114. // Remove invalid points, especially in spline (#5015)
  35115. points = this.getValidPoints(points, false, !(options.connectNulls && !nullsAsZeroes && !connectCliffs));
  35116. // Build the line
  35117. points.forEach(function (point, i) {
  35118. var plotX = point.plotX,
  35119. plotY = point.plotY,
  35120. lastPoint = points[i - 1],
  35121. // the path to this point from the previous
  35122. pathToPoint;
  35123. if ((point.leftCliff || (lastPoint && lastPoint.rightCliff)) &&
  35124. !connectCliffs) {
  35125. gap = true; // ... and continue
  35126. }
  35127. // Line series, nullsAsZeroes is not handled
  35128. if (point.isNull && !defined(nullsAsZeroes) && i > 0) {
  35129. gap = !options.connectNulls;
  35130. // Area series, nullsAsZeroes is set
  35131. }
  35132. else if (point.isNull && !nullsAsZeroes) {
  35133. gap = true;
  35134. }
  35135. else {
  35136. if (i === 0 || gap) {
  35137. pathToPoint = [[
  35138. 'M',
  35139. point.plotX,
  35140. point.plotY
  35141. ]];
  35142. // Generate the spline as defined in the SplineSeries object
  35143. }
  35144. else if (series.getPointSpline) {
  35145. pathToPoint = [series.getPointSpline(points, point, i)];
  35146. }
  35147. else if (step) {
  35148. if (step === 1) { // right
  35149. pathToPoint = [[
  35150. 'L',
  35151. lastPoint.plotX,
  35152. plotY
  35153. ]];
  35154. }
  35155. else if (step === 2) { // center
  35156. pathToPoint = [[
  35157. 'L',
  35158. (lastPoint.plotX + plotX) / 2,
  35159. lastPoint.plotY
  35160. ], [
  35161. 'L',
  35162. (lastPoint.plotX + plotX) / 2,
  35163. plotY
  35164. ]];
  35165. }
  35166. else {
  35167. pathToPoint = [[
  35168. 'L',
  35169. plotX,
  35170. lastPoint.plotY
  35171. ]];
  35172. }
  35173. pathToPoint.push([
  35174. 'L',
  35175. plotX,
  35176. plotY
  35177. ]);
  35178. }
  35179. else {
  35180. // normal line to next point
  35181. pathToPoint = [[
  35182. 'L',
  35183. plotX,
  35184. plotY
  35185. ]];
  35186. }
  35187. // Prepare for animation. When step is enabled, there are
  35188. // two path nodes for each x value.
  35189. xMap.push(point.x);
  35190. if (step) {
  35191. xMap.push(point.x);
  35192. if (step === 2) { // step = center (#8073)
  35193. xMap.push(point.x);
  35194. }
  35195. }
  35196. graphPath.push.apply(graphPath, pathToPoint);
  35197. gap = false;
  35198. }
  35199. });
  35200. graphPath.xMap = xMap;
  35201. series.graphPath = graphPath;
  35202. return graphPath;
  35203. },
  35204. /**
  35205. * Draw the graph. Called internally when rendering line-like series
  35206. * types. The first time it generates the `series.graph` item and
  35207. * optionally other series-wide items like `series.area` for area
  35208. * charts. On subsequent calls these items are updated with new
  35209. * positions and attributes.
  35210. *
  35211. * @function Highcharts.Series#drawGraph
  35212. */
  35213. drawGraph: function () {
  35214. var series = this,
  35215. options = this.options,
  35216. graphPath = (this.gappedPath || this.getGraphPath).call(this),
  35217. styledMode = this.chart.styledMode,
  35218. props = [[
  35219. 'graph',
  35220. 'highcharts-graph'
  35221. ]];
  35222. // Presentational properties
  35223. if (!styledMode) {
  35224. props[0].push((options.lineColor ||
  35225. this.color ||
  35226. '#cccccc' // when colorByPoint = true
  35227. ), options.dashStyle);
  35228. }
  35229. props = series.getZonesGraphs(props);
  35230. // Draw the graph
  35231. props.forEach(function (prop, i) {
  35232. var graphKey = prop[0],
  35233. graph = series[graphKey],
  35234. verb = graph ? 'animate' : 'attr',
  35235. attribs;
  35236. if (graph) {
  35237. graph.endX = series.preventGraphAnimation ?
  35238. null :
  35239. graphPath.xMap;
  35240. graph.animate({ d: graphPath });
  35241. }
  35242. else if (graphPath.length) { // #1487
  35243. /**
  35244. * SVG element of area-based charts. Can be used for styling
  35245. * purposes. If zones are configured, this element will be
  35246. * hidden and replaced by multiple zone areas, accessible
  35247. * via `series['zone-area-x']` (where x is a number,
  35248. * starting with 0).
  35249. *
  35250. * @name Highcharts.Series#area
  35251. * @type {Highcharts.SVGElement|undefined}
  35252. */
  35253. /**
  35254. * SVG element of line-based charts. Can be used for styling
  35255. * purposes. If zones are configured, this element will be
  35256. * hidden and replaced by multiple zone lines, accessible
  35257. * via `series['zone-graph-x']` (where x is a number,
  35258. * starting with 0).
  35259. *
  35260. * @name Highcharts.Series#graph
  35261. * @type {Highcharts.SVGElement|undefined}
  35262. */
  35263. series[graphKey] = graph = series.chart.renderer
  35264. .path(graphPath)
  35265. .addClass(prop[1])
  35266. .attr({ zIndex: 1 }) // #1069
  35267. .add(series.group);
  35268. }
  35269. if (graph && !styledMode) {
  35270. attribs = {
  35271. 'stroke': prop[2],
  35272. 'stroke-width': options.lineWidth,
  35273. // Polygon series use filled graph
  35274. 'fill': (series.fillGraph && series.color) || 'none'
  35275. };
  35276. if (prop[3]) {
  35277. attribs.dashstyle = prop[3];
  35278. }
  35279. else if (options.linecap !== 'square') {
  35280. attribs['stroke-linecap'] =
  35281. attribs['stroke-linejoin'] = 'round';
  35282. }
  35283. graph[verb](attribs)
  35284. // Add shadow to normal series (0) or to first
  35285. // zone (1) #3932
  35286. .shadow((i < 2) && options.shadow);
  35287. }
  35288. // Helpers for animation
  35289. if (graph) {
  35290. graph.startX = graphPath.xMap;
  35291. graph.isArea = graphPath.isArea; // For arearange animation
  35292. }
  35293. });
  35294. },
  35295. /**
  35296. * Get zones properties for building graphs. Extendable by series with
  35297. * multiple lines within one series.
  35298. *
  35299. * @private
  35300. * @function Highcharts.Series#getZonesGraphs
  35301. *
  35302. * @param {Array<Array<string>>} props
  35303. *
  35304. * @return {Array<Array<string>>}
  35305. */
  35306. getZonesGraphs: function (props) {
  35307. // Add the zone properties if any
  35308. this.zones.forEach(function (zone, i) {
  35309. var propset = [
  35310. 'zone-graph-' + i,
  35311. 'highcharts-graph highcharts-zone-graph-' + i + ' ' +
  35312. (zone.className || '')
  35313. ];
  35314. if (!this.chart.styledMode) {
  35315. propset.push((zone.color || this.color), (zone.dashStyle || this.options.dashStyle));
  35316. }
  35317. props.push(propset);
  35318. }, this);
  35319. return props;
  35320. },
  35321. /**
  35322. * Clip the graphs into zones for colors and styling.
  35323. *
  35324. * @private
  35325. * @function Highcharts.Series#applyZones
  35326. * @return {void}
  35327. */
  35328. applyZones: function () {
  35329. var series = this,
  35330. chart = this.chart,
  35331. renderer = chart.renderer,
  35332. zones = this.zones,
  35333. translatedFrom,
  35334. translatedTo,
  35335. clips = (this.clips || []),
  35336. clipAttr,
  35337. graph = this.graph,
  35338. area = this.area,
  35339. chartSizeMax = Math.max(chart.chartWidth,
  35340. chart.chartHeight),
  35341. axis = this[(this.zoneAxis || 'y') + 'Axis'],
  35342. extremes,
  35343. reversed,
  35344. inverted = chart.inverted,
  35345. horiz,
  35346. pxRange,
  35347. pxPosMin,
  35348. pxPosMax,
  35349. ignoreZones = false,
  35350. zoneArea,
  35351. zoneGraph;
  35352. if (zones.length &&
  35353. (graph || area) &&
  35354. axis &&
  35355. typeof axis.min !== 'undefined') {
  35356. reversed = axis.reversed;
  35357. horiz = axis.horiz;
  35358. // The use of the Color Threshold assumes there are no gaps
  35359. // so it is safe to hide the original graph and area
  35360. // unless it is not waterfall series, then use showLine property
  35361. // to set lines between columns to be visible (#7862)
  35362. if (graph && !this.showLine) {
  35363. graph.hide();
  35364. }
  35365. if (area) {
  35366. area.hide();
  35367. }
  35368. // Create the clips
  35369. extremes = axis.getExtremes();
  35370. zones.forEach(function (threshold, i) {
  35371. translatedFrom = reversed ?
  35372. (horiz ? chart.plotWidth : 0) :
  35373. (horiz ? 0 : (axis.toPixels(extremes.min) || 0));
  35374. translatedFrom = clamp(pick(translatedTo, translatedFrom), 0, chartSizeMax);
  35375. translatedTo = clamp(Math.round(axis.toPixels(pick(threshold.value, extremes.max), true) || 0), 0, chartSizeMax);
  35376. if (ignoreZones) {
  35377. translatedFrom = translatedTo =
  35378. axis.toPixels(extremes.max);
  35379. }
  35380. pxRange = Math.abs(translatedFrom - translatedTo);
  35381. pxPosMin = Math.min(translatedFrom, translatedTo);
  35382. pxPosMax = Math.max(translatedFrom, translatedTo);
  35383. if (axis.isXAxis) {
  35384. clipAttr = {
  35385. x: inverted ? pxPosMax : pxPosMin,
  35386. y: 0,
  35387. width: pxRange,
  35388. height: chartSizeMax
  35389. };
  35390. if (!horiz) {
  35391. clipAttr.x = chart.plotHeight - clipAttr.x;
  35392. }
  35393. }
  35394. else {
  35395. clipAttr = {
  35396. x: 0,
  35397. y: inverted ? pxPosMax : pxPosMin,
  35398. width: chartSizeMax,
  35399. height: pxRange
  35400. };
  35401. if (horiz) {
  35402. clipAttr.y = chart.plotWidth - clipAttr.y;
  35403. }
  35404. }
  35405. // VML SUPPPORT
  35406. if (inverted && renderer.isVML) {
  35407. if (axis.isXAxis) {
  35408. clipAttr = {
  35409. x: 0,
  35410. y: reversed ? pxPosMin : pxPosMax,
  35411. height: clipAttr.width,
  35412. width: chart.chartWidth
  35413. };
  35414. }
  35415. else {
  35416. clipAttr = {
  35417. x: (clipAttr.y -
  35418. chart.plotLeft -
  35419. chart.spacingBox.x),
  35420. y: 0,
  35421. width: clipAttr.height,
  35422. height: chart.chartHeight
  35423. };
  35424. }
  35425. }
  35426. // END OF VML SUPPORT
  35427. if (clips[i]) {
  35428. clips[i].animate(clipAttr);
  35429. }
  35430. else {
  35431. clips[i] = renderer.clipRect(clipAttr);
  35432. }
  35433. // when no data, graph zone is not applied and after setData
  35434. // clip was ignored. As a result, it should be applied each
  35435. // time.
  35436. zoneArea = series['zone-area-' + i];
  35437. zoneGraph = series['zone-graph-' + i];
  35438. if (graph && zoneGraph) {
  35439. zoneGraph.clip(clips[i]);
  35440. }
  35441. if (area && zoneArea) {
  35442. zoneArea.clip(clips[i]);
  35443. }
  35444. // if this zone extends out of the axis, ignore the others
  35445. ignoreZones = threshold.value > extremes.max;
  35446. // Clear translatedTo for indicators
  35447. if (series.resetZones && translatedTo === 0) {
  35448. translatedTo = void 0;
  35449. }
  35450. });
  35451. this.clips = clips;
  35452. }
  35453. else if (series.visible) {
  35454. // If zones were removed, restore graph and area
  35455. if (graph) {
  35456. graph.show(true);
  35457. }
  35458. if (area) {
  35459. area.show(true);
  35460. }
  35461. }
  35462. },
  35463. /**
  35464. * Initialize and perform group inversion on series.group and
  35465. * series.markerGroup.
  35466. *
  35467. * @private
  35468. * @function Highcharts.Series#invertGroups
  35469. * @param {boolean} [inverted]
  35470. * @return {void}
  35471. */
  35472. invertGroups: function (inverted) {
  35473. var series = this,
  35474. chart = series.chart;
  35475. /**
  35476. * @private
  35477. */
  35478. function setInvert() {
  35479. ['group', 'markerGroup'].forEach(function (groupName) {
  35480. if (series[groupName]) {
  35481. // VML/HTML needs explicit attributes for flipping
  35482. if (chart.renderer.isVML) {
  35483. series[groupName].attr({
  35484. width: series.yAxis.len,
  35485. height: series.xAxis.len
  35486. });
  35487. }
  35488. series[groupName].width = series.yAxis.len;
  35489. series[groupName].height = series.xAxis.len;
  35490. // If inverted polar, don't invert series group
  35491. series[groupName].invert(series.isRadialSeries ? false : inverted);
  35492. }
  35493. });
  35494. }
  35495. // Pie, go away (#1736)
  35496. if (!series.xAxis) {
  35497. return;
  35498. }
  35499. // A fixed size is needed for inversion to work
  35500. series.eventsToUnbind.push(addEvent(chart, 'resize', setInvert));
  35501. // Do it now
  35502. setInvert();
  35503. // On subsequent render and redraw, just do setInvert without
  35504. // setting up events again
  35505. series.invertGroups = setInvert;
  35506. },
  35507. /**
  35508. * General abstraction for creating plot groups like series.group,
  35509. * series.dataLabelsGroup and series.markerGroup. On subsequent calls,
  35510. * the group will only be adjusted to the updated plot size.
  35511. *
  35512. * @private
  35513. * @function Highcharts.Series#plotGroup
  35514. * @param {string} prop
  35515. * @param {string} name
  35516. * @param {string} visibility
  35517. * @param {number} [zIndex]
  35518. * @param {Highcharts.SVGElement} [parent]
  35519. * @return {Highcharts.SVGElement}
  35520. */
  35521. plotGroup: function (prop, name, visibility, zIndex, parent) {
  35522. var group = this[prop],
  35523. isNew = !group,
  35524. attrs = {
  35525. visibility: visibility,
  35526. zIndex: zIndex || 0.1 // IE8 and pointer logic use this
  35527. };
  35528. // Avoid setting undefined opacity, or in styled mode
  35529. if (typeof this.opacity !== 'undefined' &&
  35530. !this.chart.styledMode && this.state !== 'inactive' // #13719
  35531. ) {
  35532. attrs.opacity = this.opacity;
  35533. }
  35534. // Generate it on first call
  35535. if (isNew) {
  35536. this[prop] = group = this.chart.renderer
  35537. .g()
  35538. .add(parent);
  35539. }
  35540. // Add the class names, and replace existing ones as response to
  35541. // Series.update (#6660)
  35542. group.addClass(('highcharts-' + name +
  35543. ' highcharts-series-' + this.index +
  35544. ' highcharts-' + this.type + '-series ' +
  35545. (defined(this.colorIndex) ?
  35546. 'highcharts-color-' + this.colorIndex + ' ' :
  35547. '') +
  35548. (this.options.className || '') +
  35549. (group.hasClass('highcharts-tracker') ?
  35550. ' highcharts-tracker' :
  35551. '')), true);
  35552. // Place it on first and subsequent (redraw) calls
  35553. group.attr(attrs)[isNew ? 'attr' : 'animate'](this.getPlotBox());
  35554. return group;
  35555. },
  35556. /**
  35557. * Get the translation and scale for the plot area of this series.
  35558. *
  35559. * @function Highcharts.Series#getPlotBox
  35560. *
  35561. * @return {Highcharts.SeriesPlotBoxObject}
  35562. */
  35563. getPlotBox: function () {
  35564. var chart = this.chart,
  35565. xAxis = this.xAxis,
  35566. yAxis = this.yAxis;
  35567. // Swap axes for inverted (#2339)
  35568. if (chart.inverted) {
  35569. xAxis = yAxis;
  35570. yAxis = this.xAxis;
  35571. }
  35572. return {
  35573. translateX: xAxis ? xAxis.left : chart.plotLeft,
  35574. translateY: yAxis ? yAxis.top : chart.plotTop,
  35575. scaleX: 1,
  35576. scaleY: 1
  35577. };
  35578. },
  35579. /**
  35580. * Removes the event handlers attached previously with addEvents.
  35581. *
  35582. * @private
  35583. * @function Highcharts.Series#removeEvents
  35584. * @param {boolean} [keepEventsForUpdate]
  35585. * @return {void}
  35586. */
  35587. removeEvents: function (keepEventsForUpdate) {
  35588. var series = this;
  35589. if (!keepEventsForUpdate) {
  35590. // remove all events
  35591. removeEvent(series);
  35592. }
  35593. else if (series.eventsToUnbind.length) {
  35594. // remove only internal events for proper update
  35595. // #12355 - solves problem with multiple destroy events
  35596. series.eventsToUnbind.forEach(function (unbind) {
  35597. unbind();
  35598. });
  35599. series.eventsToUnbind.length = 0;
  35600. }
  35601. },
  35602. /**
  35603. * Render the graph and markers. Called internally when first rendering
  35604. * and later when redrawing the chart. This function can be extended in
  35605. * plugins, but normally shouldn't be called directly.
  35606. *
  35607. * @function Highcharts.Series#render
  35608. *
  35609. * @return {void}
  35610. *
  35611. * @fires Highcharts.Series#event:afterRender
  35612. */
  35613. render: function () {
  35614. var series = this,
  35615. chart = series.chart,
  35616. group,
  35617. options = series.options,
  35618. animOptions = animObject(options.animation),
  35619. // Animation doesn't work in IE8 quirks when the group div is
  35620. // hidden, and looks bad in other oldIE
  35621. animDuration = (!series.finishedAnimating &&
  35622. chart.renderer.isSVG &&
  35623. animOptions.duration),
  35624. visibility = series.visible ? 'inherit' : 'hidden', // #2597
  35625. zIndex = options.zIndex,
  35626. hasRendered = series.hasRendered,
  35627. chartSeriesGroup = chart.seriesGroup,
  35628. inverted = chart.inverted;
  35629. fireEvent(this, 'render');
  35630. // the group
  35631. group = series.plotGroup('group', 'series', visibility, zIndex, chartSeriesGroup);
  35632. series.markerGroup = series.plotGroup('markerGroup', 'markers', visibility, zIndex, chartSeriesGroup);
  35633. // initiate the animation
  35634. if (animDuration && series.animate) {
  35635. series.animate(true);
  35636. }
  35637. // SVGRenderer needs to know this before drawing elements (#1089,
  35638. // #1795)
  35639. group.inverted = series.isCartesian || series.invertable ?
  35640. inverted : false;
  35641. // Draw the graph if any
  35642. if (series.drawGraph) {
  35643. series.drawGraph();
  35644. series.applyZones();
  35645. }
  35646. // Draw the points
  35647. if (series.visible) {
  35648. series.drawPoints();
  35649. }
  35650. /* series.points.forEach(function (point) {
  35651. if (point.redraw) {
  35652. point.redraw();
  35653. }
  35654. }); */
  35655. // Draw the data labels
  35656. if (series.drawDataLabels) {
  35657. series.drawDataLabels();
  35658. }
  35659. // In pie charts, slices are added to the DOM, but actual rendering
  35660. // is postponed until labels reserved their space
  35661. if (series.redrawPoints) {
  35662. series.redrawPoints();
  35663. }
  35664. // draw the mouse tracking area
  35665. if (series.drawTracker &&
  35666. series.options.enableMouseTracking !== false) {
  35667. series.drawTracker();
  35668. }
  35669. // Handle inverted series and tracker groups
  35670. series.invertGroups(inverted);
  35671. // Initial clipping, must be defined after inverting groups for VML.
  35672. // Applies to columns etc. (#3839).
  35673. if (options.clip !== false &&
  35674. !series.sharedClipKey &&
  35675. !hasRendered) {
  35676. group.clip(chart.clipRect);
  35677. }
  35678. // Run the animation
  35679. if (animDuration && series.animate) {
  35680. series.animate();
  35681. }
  35682. // Call the afterAnimate function on animation complete (but don't
  35683. // overwrite the animation.complete option which should be available
  35684. // to the user).
  35685. if (!hasRendered) {
  35686. // Additional time if defer is defined before afterAnimate
  35687. // will be triggered
  35688. if (animDuration && animOptions.defer) {
  35689. animDuration += animOptions.defer;
  35690. }
  35691. series.animationTimeout = syncTimeout(function () {
  35692. series.afterAnimate();
  35693. }, animDuration || 0);
  35694. }
  35695. // Means data is in accordance with what you see
  35696. series.isDirty = false;
  35697. // (See #322) series.isDirty = series.isDirtyData = false; // means
  35698. // data is in accordance with what you see
  35699. series.hasRendered = true;
  35700. fireEvent(series, 'afterRender');
  35701. },
  35702. /**
  35703. * Redraw the series. This function is called internally from
  35704. * `chart.redraw` and normally shouldn't be called directly.
  35705. *
  35706. * @private
  35707. * @function Highcharts.Series#redraw
  35708. * @return {void}
  35709. */
  35710. redraw: function () {
  35711. var series = this,
  35712. chart = series.chart,
  35713. // cache it here as it is set to false in render, but used after
  35714. wasDirty = series.isDirty || series.isDirtyData,
  35715. group = series.group,
  35716. xAxis = series.xAxis,
  35717. yAxis = series.yAxis;
  35718. // reposition on resize
  35719. if (group) {
  35720. if (chart.inverted) {
  35721. group.attr({
  35722. width: chart.plotWidth,
  35723. height: chart.plotHeight
  35724. });
  35725. }
  35726. group.animate({
  35727. translateX: pick(xAxis && xAxis.left, chart.plotLeft),
  35728. translateY: pick(yAxis && yAxis.top, chart.plotTop)
  35729. });
  35730. }
  35731. series.translate();
  35732. series.render();
  35733. if (wasDirty) { // #3868, #3945
  35734. delete this.kdTree;
  35735. }
  35736. },
  35737. kdAxisArray: ['clientX', 'plotY'],
  35738. /**
  35739. * @private
  35740. * @function Highcharts.Series#searchPoint
  35741. * @param {Highcharts.PointerEventObject} e
  35742. * @param {boolean} [compareX]
  35743. * @return {Highcharts.Point}
  35744. */
  35745. searchPoint: function (e, compareX) {
  35746. var series = this,
  35747. xAxis = series.xAxis,
  35748. yAxis = series.yAxis,
  35749. inverted = series.chart.inverted;
  35750. return this.searchKDTree({
  35751. clientX: inverted ?
  35752. xAxis.len - e.chartY + xAxis.pos :
  35753. e.chartX - xAxis.pos,
  35754. plotY: inverted ?
  35755. yAxis.len - e.chartX + yAxis.pos :
  35756. e.chartY - yAxis.pos
  35757. }, compareX, e);
  35758. },
  35759. /**
  35760. * Build the k-d-tree that is used by mouse and touch interaction to get
  35761. * the closest point. Line-like series typically have a one-dimensional
  35762. * tree where points are searched along the X axis, while scatter-like
  35763. * series typically search in two dimensions, X and Y.
  35764. *
  35765. * @private
  35766. * @function Highcharts.Series#buildKDTree
  35767. * @param {Highcharts.PointerEventObject} [e]
  35768. * @return {void}
  35769. */
  35770. buildKDTree: function (e) {
  35771. // Prevent multiple k-d-trees from being built simultaneously
  35772. // (#6235)
  35773. this.buildingKdTree = true;
  35774. var series = this,
  35775. dimensions = series.options.findNearestPointBy
  35776. .indexOf('y') > -1 ? 2 : 1;
  35777. /**
  35778. * Internal function
  35779. * @private
  35780. */
  35781. function _kdtree(points, depth, dimensions) {
  35782. var axis,
  35783. median,
  35784. length = points && points.length;
  35785. if (length) {
  35786. // alternate between the axis
  35787. axis = series.kdAxisArray[depth % dimensions];
  35788. // sort point array
  35789. points.sort(function (a, b) {
  35790. return a[axis] - b[axis];
  35791. });
  35792. median = Math.floor(length / 2);
  35793. // build and return nod
  35794. return {
  35795. point: points[median],
  35796. left: _kdtree(points.slice(0, median), depth + 1, dimensions),
  35797. right: _kdtree(points.slice(median + 1), depth + 1, dimensions)
  35798. };
  35799. }
  35800. }
  35801. /**
  35802. * Start the recursive build process with a clone of the points
  35803. * array and null points filtered out. (#3873)
  35804. * @private
  35805. */
  35806. function startRecursive() {
  35807. series.kdTree = _kdtree(series.getValidPoints(null,
  35808. // For line-type series restrict to plot area, but
  35809. // column-type series not (#3916, #4511)
  35810. !series.directTouch), dimensions, dimensions);
  35811. series.buildingKdTree = false;
  35812. }
  35813. delete series.kdTree;
  35814. // For testing tooltips, don't build async. Also if touchstart, we
  35815. // may be dealing with click events on mobile, so don't delay
  35816. // (#6817).
  35817. syncTimeout(startRecursive, series.options.kdNow || (e && e.type === 'touchstart') ? 0 : 1);
  35818. },
  35819. /**
  35820. * @private
  35821. * @function Highcharts.Series#searchKDTree
  35822. * @param {Highcharts.KDPointSearchObject} point
  35823. * @param {boolean} [compareX]
  35824. * @param {Highcharts.PointerEventObject} [e]
  35825. * @return {Highcharts.Point|undefined}
  35826. */
  35827. searchKDTree: function (point, compareX, e) {
  35828. var series = this,
  35829. kdX = this.kdAxisArray[0],
  35830. kdY = this.kdAxisArray[1],
  35831. kdComparer = compareX ? 'distX' : 'dist',
  35832. kdDimensions = series.options.findNearestPointBy
  35833. .indexOf('y') > -1 ? 2 : 1;
  35834. /**
  35835. * Set the one and two dimensional distance on the point object.
  35836. * @private
  35837. */
  35838. function setDistance(p1, p2) {
  35839. var x = (defined(p1[kdX]) &&
  35840. defined(p2[kdX])) ?
  35841. Math.pow(p1[kdX] - p2[kdX], 2) :
  35842. null,
  35843. y = (defined(p1[kdY]) &&
  35844. defined(p2[kdY])) ?
  35845. Math.pow(p1[kdY] - p2[kdY], 2) :
  35846. null,
  35847. r = (x || 0) + (y || 0);
  35848. p2.dist = defined(r) ? Math.sqrt(r) : Number.MAX_VALUE;
  35849. p2.distX = defined(x) ? Math.sqrt(x) : Number.MAX_VALUE;
  35850. }
  35851. /**
  35852. * @private
  35853. */
  35854. function _search(search, tree, depth, dimensions) {
  35855. var point = tree.point,
  35856. axis = series.kdAxisArray[depth % dimensions],
  35857. tdist,
  35858. sideA,
  35859. sideB,
  35860. ret = point,
  35861. nPoint1,
  35862. nPoint2;
  35863. setDistance(search, point);
  35864. // Pick side based on distance to splitting point
  35865. tdist = search[axis] - point[axis];
  35866. sideA = tdist < 0 ? 'left' : 'right';
  35867. sideB = tdist < 0 ? 'right' : 'left';
  35868. // End of tree
  35869. if (tree[sideA]) {
  35870. nPoint1 = _search(search, tree[sideA], depth + 1, dimensions);
  35871. ret = (nPoint1[kdComparer] <
  35872. ret[kdComparer] ?
  35873. nPoint1 :
  35874. point);
  35875. }
  35876. if (tree[sideB]) {
  35877. // compare distance to current best to splitting point to
  35878. // decide wether to check side B or not
  35879. if (Math.sqrt(tdist * tdist) < ret[kdComparer]) {
  35880. nPoint2 = _search(search, tree[sideB], depth + 1, dimensions);
  35881. ret = (nPoint2[kdComparer] <
  35882. ret[kdComparer] ?
  35883. nPoint2 :
  35884. ret);
  35885. }
  35886. }
  35887. return ret;
  35888. }
  35889. if (!this.kdTree && !this.buildingKdTree) {
  35890. this.buildKDTree(e);
  35891. }
  35892. if (this.kdTree) {
  35893. return _search(point, this.kdTree, kdDimensions, kdDimensions);
  35894. }
  35895. },
  35896. /**
  35897. * @private
  35898. * @function Highcharts.Series#pointPlacementToXValue
  35899. * @return {number}
  35900. */
  35901. pointPlacementToXValue: function () {
  35902. var _a = this,
  35903. _b = _a.options,
  35904. pointPlacement = _b.pointPlacement,
  35905. pointRange = _b.pointRange,
  35906. axis = _a.xAxis;
  35907. var factor = pointPlacement;
  35908. // Point placement is relative to each series pointRange (#5889)
  35909. if (factor === 'between') {
  35910. factor = axis.reversed ? -0.5 : 0.5; // #11955
  35911. }
  35912. return isNumber(factor) ?
  35913. factor * pick(pointRange, axis.pointRange) :
  35914. 0;
  35915. },
  35916. /**
  35917. * @private
  35918. * @function Highcharts.Series#isPointInside
  35919. * @param {Highcharts.Point} point
  35920. * @return {boolean}
  35921. */
  35922. isPointInside: function (point) {
  35923. var isInside = typeof point.plotY !== 'undefined' &&
  35924. typeof point.plotX !== 'undefined' &&
  35925. point.plotY >= 0 &&
  35926. point.plotY <= this.yAxis.len && // #3519
  35927. point.plotX >= 0 &&
  35928. point.plotX <= this.xAxis.len;
  35929. return isInside;
  35930. }
  35931. }); // end Series prototype
  35932. /**
  35933. * A line series displays information as a series of data points connected by
  35934. * straight line segments.
  35935. *
  35936. * @sample {highcharts} highcharts/demo/line-basic/
  35937. * Line chart
  35938. * @sample {highstock} stock/demo/basic-line/
  35939. * Line chart
  35940. *
  35941. * @extends plotOptions.series
  35942. * @product highcharts highstock
  35943. * @apioption plotOptions.line
  35944. */
  35945. /**
  35946. * The SVG value used for the `stroke-linecap` and `stroke-linejoin`
  35947. * of a line graph. Round means that lines are rounded in the ends and
  35948. * bends.
  35949. *
  35950. * @type {Highcharts.SeriesLinecapValue}
  35951. * @default round
  35952. * @since 3.0.7
  35953. * @apioption plotOptions.line.linecap
  35954. */
  35955. /**
  35956. * A `line` series. If the [type](#series.line.type) option is not
  35957. * specified, it is inherited from [chart.type](#chart.type).
  35958. *
  35959. * @extends series,plotOptions.line
  35960. * @excluding dataParser,dataURL
  35961. * @product highcharts highstock
  35962. * @apioption series.line
  35963. */
  35964. /**
  35965. * An array of data points for the series. For the `line` series type,
  35966. * points can be given in the following ways:
  35967. *
  35968. * 1. An array of numerical values. In this case, the numerical values will be
  35969. * interpreted as `y` options. The `x` values will be automatically
  35970. * calculated, either starting at 0 and incremented by 1, or from
  35971. * `pointStart` and `pointInterval` given in the series options. If the axis
  35972. * has categories, these will be used. Example:
  35973. * ```js
  35974. * data: [0, 5, 3, 5]
  35975. * ```
  35976. *
  35977. * 2. An array of arrays with 2 values. In this case, the values correspond to
  35978. * `x,y`. If the first value is a string, it is applied as the name of the
  35979. * point, and the `x` value is inferred.
  35980. * ```js
  35981. * data: [
  35982. * [0, 1],
  35983. * [1, 2],
  35984. * [2, 8]
  35985. * ]
  35986. * ```
  35987. *
  35988. * 3. An array of objects with named values. The following snippet shows only a
  35989. * few settings, see the complete options set below. If the total number of
  35990. * data points exceeds the series'
  35991. * [turboThreshold](#series.line.turboThreshold),
  35992. * this option is not available.
  35993. * ```js
  35994. * data: [{
  35995. * x: 1,
  35996. * y: 9,
  35997. * name: "Point2",
  35998. * color: "#00FF00"
  35999. * }, {
  36000. * x: 1,
  36001. * y: 6,
  36002. * name: "Point1",
  36003. * color: "#FF00FF"
  36004. * }]
  36005. * ```
  36006. *
  36007. * **Note:** In TypeScript you have to extend `PointOptionsObject` with an
  36008. * additional declaration to allow custom data types:
  36009. * ```ts
  36010. * declare module `highcharts` {
  36011. * interface PointOptionsObject {
  36012. * custom: Record<string, (boolean|number|string)>;
  36013. * }
  36014. * }
  36015. * ```
  36016. *
  36017. * @sample {highcharts} highcharts/chart/reflow-true/
  36018. * Numerical values
  36019. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  36020. * Arrays of numeric x and y
  36021. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  36022. * Arrays of datetime x and y
  36023. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  36024. * Arrays of point.name and y
  36025. * @sample {highcharts} highcharts/series/data-array-of-objects/
  36026. * Config objects
  36027. *
  36028. * @declare Highcharts.PointOptionsObject
  36029. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  36030. * @apioption series.line.data
  36031. */
  36032. /**
  36033. * An additional, individual class name for the data point's graphic
  36034. * representation.
  36035. *
  36036. * @type {string}
  36037. * @since 5.0.0
  36038. * @product highcharts gantt
  36039. * @apioption series.line.data.className
  36040. */
  36041. /**
  36042. * Individual color for the point. By default the color is pulled from
  36043. * the global `colors` array.
  36044. *
  36045. * In styled mode, the `color` option doesn't take effect. Instead, use
  36046. * `colorIndex`.
  36047. *
  36048. * @sample {highcharts} highcharts/point/color/
  36049. * Mark the highest point
  36050. *
  36051. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  36052. * @product highcharts highstock gantt
  36053. * @apioption series.line.data.color
  36054. */
  36055. /**
  36056. * A specific color index to use for the point, so its graphic representations
  36057. * are given the class name `highcharts-color-{n}`. In styled mode this will
  36058. * change the color of the graphic. In non-styled mode, the color by is set by
  36059. * the `fill` attribute, so the change in class name won't have a visual effect
  36060. * by default.
  36061. *
  36062. * @type {number}
  36063. * @since 5.0.0
  36064. * @product highcharts gantt
  36065. * @apioption series.line.data.colorIndex
  36066. */
  36067. /**
  36068. * A reserved subspace to store options and values for customized functionality.
  36069. * Here you can add additional data for your own event callbacks and formatter
  36070. * callbacks.
  36071. *
  36072. * @sample {highcharts} highcharts/point/custom/
  36073. * Point and series with custom data
  36074. *
  36075. * @type {Highcharts.Dictionary<*>}
  36076. * @apioption series.line.data.custom
  36077. */
  36078. /**
  36079. * Individual data label for each point. The options are the same as
  36080. * the ones for [plotOptions.series.dataLabels](
  36081. * #plotOptions.series.dataLabels).
  36082. *
  36083. * @sample highcharts/point/datalabels/
  36084. * Show a label for the last value
  36085. *
  36086. * @declare Highcharts.DataLabelsOptions
  36087. * @extends plotOptions.line.dataLabels
  36088. * @product highcharts highstock gantt
  36089. * @apioption series.line.data.dataLabels
  36090. */
  36091. /**
  36092. * A description of the point to add to the screen reader information
  36093. * about the point.
  36094. *
  36095. * @type {string}
  36096. * @since 5.0.0
  36097. * @requires modules/accessibility
  36098. * @apioption series.line.data.description
  36099. */
  36100. /**
  36101. * An id for the point. This can be used after render time to get a
  36102. * pointer to the point object through `chart.get()`.
  36103. *
  36104. * @sample {highcharts} highcharts/point/id/
  36105. * Remove an id'd point
  36106. *
  36107. * @type {string}
  36108. * @since 1.2.0
  36109. * @product highcharts highstock gantt
  36110. * @apioption series.line.data.id
  36111. */
  36112. /**
  36113. * The rank for this point's data label in case of collision. If two
  36114. * data labels are about to overlap, only the one with the highest `labelrank`
  36115. * will be drawn.
  36116. *
  36117. * @type {number}
  36118. * @apioption series.line.data.labelrank
  36119. */
  36120. /**
  36121. * The name of the point as shown in the legend, tooltip, dataLabels, etc.
  36122. *
  36123. * @see [xAxis.uniqueNames](#xAxis.uniqueNames)
  36124. *
  36125. * @sample {highcharts} highcharts/series/data-array-of-objects/
  36126. * Point names
  36127. *
  36128. * @type {string}
  36129. * @apioption series.line.data.name
  36130. */
  36131. /**
  36132. * Whether the data point is selected initially.
  36133. *
  36134. * @type {boolean}
  36135. * @default false
  36136. * @product highcharts highstock gantt
  36137. * @apioption series.line.data.selected
  36138. */
  36139. /**
  36140. * The x value of the point. For datetime axes, the X value is the timestamp
  36141. * in milliseconds since 1970.
  36142. *
  36143. * @type {number}
  36144. * @product highcharts highstock
  36145. * @apioption series.line.data.x
  36146. */
  36147. /**
  36148. * The y value of the point.
  36149. *
  36150. * @type {number|null}
  36151. * @product highcharts highstock
  36152. * @apioption series.line.data.y
  36153. */
  36154. /**
  36155. * The individual point events.
  36156. *
  36157. * @extends plotOptions.series.point.events
  36158. * @product highcharts highstock gantt
  36159. * @apioption series.line.data.events
  36160. */
  36161. /**
  36162. * Options for the point markers of line-like series.
  36163. *
  36164. * @declare Highcharts.PointMarkerOptionsObject
  36165. * @extends plotOptions.series.marker
  36166. * @product highcharts highstock
  36167. * @apioption series.line.data.marker
  36168. */
  36169. ''; // include precedent doclets in transpilat
  36170. return CartesianSeries;
  36171. });
  36172. _registerModule(_modules, 'Series/LineSeries.js', [_modules['Core/Series/CartesianSeries.js'], _modules['Core/Globals.js']], function (CartesianSeries, H) {
  36173. /* *
  36174. *
  36175. * (c) 2010-2020 Torstein Honsi
  36176. *
  36177. * License: www.highcharts.com/license
  36178. *
  36179. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  36180. *
  36181. * */
  36182. H.Series = CartesianSeries; // backwards compatibility
  36183. return H.Series;
  36184. });
  36185. _registerModule(_modules, 'Extensions/Stacking.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Chart/Chart.js'], _modules['Core/Globals.js'], _modules['Core/Axis/StackingAxis.js'], _modules['Core/Utilities.js']], function (Axis, Chart, H, StackingAxis, U) {
  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 correctFloat = U.correctFloat,
  36196. defined = U.defined,
  36197. destroyObjectProperties = U.destroyObjectProperties,
  36198. format = U.format,
  36199. isNumber = U.isNumber,
  36200. pick = U.pick;
  36201. /**
  36202. * Stack of data points
  36203. *
  36204. * @product highcharts
  36205. *
  36206. * @interface Highcharts.StackItemObject
  36207. */ /**
  36208. * Alignment settings
  36209. * @name Highcharts.StackItemObject#alignOptions
  36210. * @type {Highcharts.AlignObject}
  36211. */ /**
  36212. * Related axis
  36213. * @name Highcharts.StackItemObject#axis
  36214. * @type {Highcharts.Axis}
  36215. */ /**
  36216. * Cumulative value of the stacked data points
  36217. * @name Highcharts.StackItemObject#cumulative
  36218. * @type {number}
  36219. */ /**
  36220. * True if on the negative side
  36221. * @name Highcharts.StackItemObject#isNegative
  36222. * @type {boolean}
  36223. */ /**
  36224. * Related SVG element
  36225. * @name Highcharts.StackItemObject#label
  36226. * @type {Highcharts.SVGElement}
  36227. */ /**
  36228. * Related stack options
  36229. * @name Highcharts.StackItemObject#options
  36230. * @type {Highcharts.YAxisStackLabelsOptions}
  36231. */ /**
  36232. * Total value of the stacked data points
  36233. * @name Highcharts.StackItemObject#total
  36234. * @type {number}
  36235. */ /**
  36236. * Shared x value of the stack
  36237. * @name Highcharts.StackItemObject#x
  36238. * @type {number}
  36239. */
  36240. ''; // detached doclets above
  36241. var Series = H.Series;
  36242. /* eslint-disable no-invalid-this, valid-jsdoc */
  36243. /**
  36244. * The class for stacks. Each stack, on a specific X value and either negative
  36245. * or positive, has its own stack item.
  36246. *
  36247. * @private
  36248. * @class
  36249. * @name Highcharts.StackItem
  36250. * @param {Highcharts.Axis} axis
  36251. * @param {Highcharts.YAxisStackLabelsOptions} options
  36252. * @param {boolean} isNegative
  36253. * @param {number} x
  36254. * @param {Highcharts.OptionsStackingValue} [stackOption]
  36255. */
  36256. var StackItem = /** @class */ (function () {
  36257. function StackItem(axis, options, isNegative, x, stackOption) {
  36258. var inverted = axis.chart.inverted;
  36259. this.axis = axis;
  36260. // Tells if the stack is negative
  36261. this.isNegative = isNegative;
  36262. // Save the options to be able to style the label
  36263. this.options = options = options || {};
  36264. // Save the x value to be able to position the label later
  36265. this.x = x;
  36266. // Initialize total value
  36267. this.total = null;
  36268. // This will keep each points' extremes stored by series.index and point
  36269. // index
  36270. this.points = {};
  36271. this.hasValidPoints = false;
  36272. // Save the stack option on the series configuration object,
  36273. // and whether to treat it as percent
  36274. this.stack = stackOption;
  36275. this.leftCliff = 0;
  36276. this.rightCliff = 0;
  36277. // The align options and text align varies on whether the stack is
  36278. // negative and if the chart is inverted or not.
  36279. // First test the user supplied value, then use the dynamic.
  36280. this.alignOptions = {
  36281. align: options.align ||
  36282. (inverted ? (isNegative ? 'left' : 'right') : 'center'),
  36283. verticalAlign: options.verticalAlign ||
  36284. (inverted ? 'middle' : (isNegative ? 'bottom' : 'top')),
  36285. y: options.y,
  36286. x: options.x
  36287. };
  36288. this.textAlign = options.textAlign ||
  36289. (inverted ? (isNegative ? 'right' : 'left') : 'center');
  36290. }
  36291. /**
  36292. * @private
  36293. * @function Highcharts.StackItem#destroy
  36294. */
  36295. StackItem.prototype.destroy = function () {
  36296. destroyObjectProperties(this, this.axis);
  36297. };
  36298. /**
  36299. * Renders the stack total label and adds it to the stack label group.
  36300. *
  36301. * @private
  36302. * @function Highcharts.StackItem#render
  36303. * @param {Highcharts.SVGElement} group
  36304. */
  36305. StackItem.prototype.render = function (group) {
  36306. var chart = this.axis.chart,
  36307. options = this.options,
  36308. formatOption = options.format,
  36309. attr = {},
  36310. str = formatOption ? // format the text in the label
  36311. format(formatOption,
  36312. this,
  36313. chart) :
  36314. options.formatter.call(this);
  36315. // Change the text to reflect the new total and set visibility to hidden
  36316. // in case the serie is hidden
  36317. if (this.label) {
  36318. this.label.attr({ text: str, visibility: 'hidden' });
  36319. }
  36320. else {
  36321. // Create new label
  36322. this.label = chart.renderer
  36323. .label(str, null, null, options.shape, null, null, options.useHTML, false, 'stack-labels');
  36324. attr = {
  36325. r: options.borderRadius || 0,
  36326. text: str,
  36327. rotation: options.rotation,
  36328. padding: pick(options.padding, 5),
  36329. visibility: 'hidden' // hidden until setOffset is called
  36330. };
  36331. if (!chart.styledMode) {
  36332. attr.fill = options.backgroundColor;
  36333. attr.stroke = options.borderColor;
  36334. attr['stroke-width'] = options.borderWidth;
  36335. this.label.css(options.style);
  36336. }
  36337. this.label.attr(attr);
  36338. if (!this.label.added) {
  36339. this.label.add(group); // add to the labels-group
  36340. }
  36341. }
  36342. // Rank it higher than data labels (#8742)
  36343. this.label.labelrank = chart.plotHeight;
  36344. };
  36345. /**
  36346. * Sets the offset that the stack has from the x value and repositions the
  36347. * label.
  36348. *
  36349. * @private
  36350. * @function Highcarts.StackItem#setOffset
  36351. * @param {number} xOffset
  36352. * @param {number} xWidth
  36353. * @param {number} [boxBottom]
  36354. * @param {number} [boxTop]
  36355. * @param {number} [defaultX]
  36356. */
  36357. StackItem.prototype.setOffset = function (xOffset, xWidth, boxBottom, boxTop, defaultX) {
  36358. var stackItem = this,
  36359. axis = stackItem.axis,
  36360. chart = axis.chart,
  36361. // stack value translated mapped to chart coordinates
  36362. y = axis.translate(axis.stacking.usePercentage ?
  36363. 100 :
  36364. (boxTop ?
  36365. boxTop :
  36366. stackItem.total), 0, 0, 0, 1),
  36367. yZero = axis.translate(boxBottom ? boxBottom : 0), // stack origin
  36368. // stack height:
  36369. h = defined(y) && Math.abs(y - yZero),
  36370. // x position:
  36371. x = pick(defaultX,
  36372. chart.xAxis[0].translate(stackItem.x)) +
  36373. xOffset,
  36374. stackBox = defined(y) && stackItem.getStackBox(chart,
  36375. stackItem,
  36376. x,
  36377. y,
  36378. xWidth,
  36379. h,
  36380. axis),
  36381. label = stackItem.label,
  36382. isNegative = stackItem.isNegative,
  36383. isJustify = pick(stackItem.options.overflow, 'justify') === 'justify',
  36384. textAlign = stackItem.textAlign,
  36385. visible;
  36386. if (label && stackBox) {
  36387. var bBox = label.getBBox(),
  36388. padding = label.padding,
  36389. boxOffsetX,
  36390. boxOffsetY;
  36391. if (textAlign === 'left') {
  36392. boxOffsetX = chart.inverted ? -padding : padding;
  36393. }
  36394. else if (textAlign === 'right') {
  36395. boxOffsetX = bBox.width;
  36396. }
  36397. else {
  36398. if (chart.inverted && textAlign === 'center') {
  36399. boxOffsetX = bBox.width / 2;
  36400. }
  36401. else {
  36402. boxOffsetX = chart.inverted ?
  36403. (isNegative ? bBox.width + padding : -padding) : bBox.width / 2;
  36404. }
  36405. }
  36406. boxOffsetY = chart.inverted ?
  36407. bBox.height / 2 : (isNegative ? -padding : bBox.height);
  36408. // Reset alignOptions property after justify #12337
  36409. stackItem.alignOptions.x = pick(stackItem.options.x, 0);
  36410. stackItem.alignOptions.y = pick(stackItem.options.y, 0);
  36411. // Set the stackBox position
  36412. stackBox.x -= boxOffsetX;
  36413. stackBox.y -= boxOffsetY;
  36414. // Align the label to the box
  36415. label.align(stackItem.alignOptions, null, stackBox);
  36416. // Check if label is inside the plotArea #12294
  36417. if (chart.isInsidePlot(label.alignAttr.x + boxOffsetX - stackItem.alignOptions.x, label.alignAttr.y + boxOffsetY - stackItem.alignOptions.y)) {
  36418. label.show();
  36419. }
  36420. else {
  36421. // Move label away to avoid the overlapping issues
  36422. label.alignAttr.y = -9999;
  36423. isJustify = false;
  36424. }
  36425. if (isJustify) {
  36426. // Justify stackLabel into the stackBox
  36427. Series.prototype.justifyDataLabel.call(this.axis, label, stackItem.alignOptions, label.alignAttr, bBox, stackBox);
  36428. }
  36429. label.attr({
  36430. x: label.alignAttr.x,
  36431. y: label.alignAttr.y
  36432. });
  36433. if (pick(!isJustify && stackItem.options.crop, true)) {
  36434. visible =
  36435. isNumber(label.x) &&
  36436. isNumber(label.y) &&
  36437. chart.isInsidePlot(label.x - padding + label.width, label.y) &&
  36438. chart.isInsidePlot(label.x + padding, label.y);
  36439. if (!visible) {
  36440. label.hide();
  36441. }
  36442. }
  36443. }
  36444. };
  36445. /**
  36446. * @private
  36447. * @function Highcharts.StackItem#getStackBox
  36448. *
  36449. * @param {Highcharts.Chart} chart
  36450. *
  36451. * @param {Highcharts.StackItem} stackItem
  36452. *
  36453. * @param {number} x
  36454. *
  36455. * @param {number} y
  36456. *
  36457. * @param {number} xWidth
  36458. *
  36459. * @param {number} h
  36460. *
  36461. * @param {Highcharts.Axis} axis
  36462. *
  36463. * @return {Highcharts.BBoxObject}
  36464. */
  36465. StackItem.prototype.getStackBox = function (chart, stackItem, x, y, xWidth, h, axis) {
  36466. var reversed = stackItem.axis.reversed,
  36467. inverted = chart.inverted,
  36468. axisPos = axis.height + axis.pos -
  36469. (inverted ? chart.plotLeft : chart.plotTop),
  36470. neg = (stackItem.isNegative && !reversed) ||
  36471. (!stackItem.isNegative && reversed); // #4056
  36472. return {
  36473. x: inverted ? (neg ? y - axis.right : y - h + axis.pos - chart.plotLeft) :
  36474. x + chart.xAxis[0].transB - chart.plotLeft,
  36475. y: inverted ?
  36476. axis.height - x - xWidth :
  36477. (neg ?
  36478. (axisPos - y - h) :
  36479. axisPos - y),
  36480. width: inverted ? h : xWidth,
  36481. height: inverted ? xWidth : h
  36482. };
  36483. };
  36484. return StackItem;
  36485. }());
  36486. /**
  36487. * Generate stacks for each series and calculate stacks total values
  36488. *
  36489. * @private
  36490. * @function Highcharts.Chart#getStacks
  36491. */
  36492. Chart.prototype.getStacks = function () {
  36493. var chart = this,
  36494. inverted = chart.inverted;
  36495. // reset stacks for each yAxis
  36496. chart.yAxis.forEach(function (axis) {
  36497. if (axis.stacking && axis.stacking.stacks && axis.hasVisibleSeries) {
  36498. axis.stacking.oldStacks = axis.stacking.stacks;
  36499. }
  36500. });
  36501. chart.series.forEach(function (series) {
  36502. var xAxisOptions = series.xAxis && series.xAxis.options || {};
  36503. if (series.options.stacking &&
  36504. (series.visible === true ||
  36505. chart.options.chart.ignoreHiddenSeries === false)) {
  36506. series.stackKey = [
  36507. series.type,
  36508. pick(series.options.stack, ''),
  36509. inverted ? xAxisOptions.top : xAxisOptions.left,
  36510. inverted ? xAxisOptions.height : xAxisOptions.width
  36511. ].join(',');
  36512. }
  36513. });
  36514. };
  36515. // Stacking methods defined on the Axis prototype
  36516. StackingAxis.compose(Axis);
  36517. // Stacking methods defined for Series prototype
  36518. /**
  36519. * Set grouped points in a stack-like object. When `centerInCategory` is true,
  36520. * and `stacking` is not enabled, we need a pseudo (horizontal) stack in order
  36521. * to handle grouping of points within the same category.
  36522. *
  36523. * @private
  36524. * @function Highcharts.Series#setStackedPoints
  36525. * @return {void}
  36526. */
  36527. Series.prototype.setGroupedPoints = function () {
  36528. if (this.options.centerInCategory &&
  36529. (this.is('column') || this.is('columnrange')) &&
  36530. // With stacking enabled, we already have stacks that we can compute
  36531. // from
  36532. !this.options.stacking &&
  36533. // With only one series, we don't need to consider centerInCategory
  36534. this.chart.series.length > 1) {
  36535. Series.prototype.setStackedPoints.call(this, 'group');
  36536. }
  36537. };
  36538. /**
  36539. * Adds series' points value to corresponding stack
  36540. *
  36541. * @private
  36542. * @function Highcharts.Series#setStackedPoints
  36543. */
  36544. Series.prototype.setStackedPoints = function (stackingParam) {
  36545. var stacking = stackingParam || this.options.stacking;
  36546. if (!stacking ||
  36547. (this.visible !== true &&
  36548. this.chart.options.chart.ignoreHiddenSeries !== false)) {
  36549. return;
  36550. }
  36551. 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;
  36552. yAxis.stacking.stacksTouched += 1;
  36553. // loop over the non-null y values and read them into a local array
  36554. for (i = 0; i < yDataLength; i++) {
  36555. x = xData[i];
  36556. y = yData[i];
  36557. stackIndicator = series.getStackIndicator(stackIndicator, x, series.index);
  36558. pointKey = stackIndicator.key;
  36559. // Read stacked values into a stack based on the x value,
  36560. // the sign of y and the stack key. Stacking is also handled for null
  36561. // values (#739)
  36562. isNegative = negStacks && y < (stackThreshold ? 0 : threshold);
  36563. key = isNegative ? negKey : stackKey;
  36564. // Create empty object for this stack if it doesn't exist yet
  36565. if (!stacks[key]) {
  36566. stacks[key] =
  36567. {};
  36568. }
  36569. // Initialize StackItem for this x
  36570. if (!stacks[key][x]) {
  36571. if (oldStacks[key] &&
  36572. oldStacks[key][x]) {
  36573. stacks[key][x] = oldStacks[key][x];
  36574. stacks[key][x].total = null;
  36575. }
  36576. else {
  36577. stacks[key][x] = new StackItem(yAxis, yAxis.options.stackLabels, isNegative, x, stackOption);
  36578. }
  36579. }
  36580. // If the StackItem doesn't exist, create it first
  36581. stack = stacks[key][x];
  36582. if (y !== null) {
  36583. stack.points[pointKey] = stack.points[series.index] =
  36584. [pick(stack.cumulative, stackThreshold)];
  36585. // Record the base of the stack
  36586. if (!defined(stack.cumulative)) {
  36587. stack.base = pointKey;
  36588. }
  36589. stack.touched = yAxis.stacking.stacksTouched;
  36590. // In area charts, if there are multiple points on the same X value,
  36591. // let the area fill the full span of those points
  36592. if (stackIndicator.index > 0 && series.singleStacks === false) {
  36593. stack.points[pointKey][0] =
  36594. stack.points[series.index + ',' + x + ',0'][0];
  36595. }
  36596. // When updating to null, reset the point stack (#7493)
  36597. }
  36598. else {
  36599. stack.points[pointKey] = stack.points[series.index] =
  36600. null;
  36601. }
  36602. // Add value to the stack total
  36603. if (stacking === 'percent') {
  36604. // Percent stacked column, totals are the same for the positive and
  36605. // negative stacks
  36606. other = isNegative ? stackKey : negKey;
  36607. if (negStacks && stacks[other] && stacks[other][x]) {
  36608. other = stacks[other][x];
  36609. stack.total = other.total =
  36610. Math.max(other.total, stack.total) +
  36611. Math.abs(y) ||
  36612. 0;
  36613. // Percent stacked areas
  36614. }
  36615. else {
  36616. stack.total =
  36617. correctFloat(stack.total + (Math.abs(y) || 0));
  36618. }
  36619. }
  36620. else if (stacking === 'group') {
  36621. // In this stack, the total is the number of valid points
  36622. if (y !== null) {
  36623. stack.total = (stack.total || 0) + 1;
  36624. }
  36625. }
  36626. else {
  36627. stack.total = correctFloat(stack.total + (y || 0));
  36628. }
  36629. if (stacking === 'group') {
  36630. // This point's index within the stack, pushed to stack.points[1]
  36631. stack.cumulative = (stack.total || 1) - 1;
  36632. }
  36633. else {
  36634. stack.cumulative =
  36635. pick(stack.cumulative, stackThreshold) + (y || 0);
  36636. }
  36637. if (y !== null) {
  36638. stack.points[pointKey].push(stack.cumulative);
  36639. stackedYData[i] = stack.cumulative;
  36640. stack.hasValidPoints = true;
  36641. }
  36642. }
  36643. if (stacking === 'percent') {
  36644. yAxis.stacking.usePercentage = true;
  36645. }
  36646. if (stacking !== 'group') {
  36647. this.stackedYData = stackedYData; // To be used in getExtremes
  36648. }
  36649. // Reset old stacks
  36650. yAxis.stacking.oldStacks = {};
  36651. };
  36652. /**
  36653. * Iterate over all stacks and compute the absolute values to percent
  36654. *
  36655. * @private
  36656. * @function Highcharts.Series#modifyStacks
  36657. */
  36658. Series.prototype.modifyStacks = function () {
  36659. var series = this,
  36660. yAxis = series.yAxis,
  36661. stackKey = series.stackKey,
  36662. stacks = yAxis.stacking.stacks,
  36663. processedXData = series.processedXData,
  36664. stackIndicator,
  36665. stacking = series.options.stacking;
  36666. if (series[stacking + 'Stacker']) { // Modifier function exists
  36667. [stackKey, '-' + stackKey].forEach(function (key) {
  36668. var i = processedXData.length,
  36669. x,
  36670. stack,
  36671. pointExtremes;
  36672. while (i--) {
  36673. x = processedXData[i];
  36674. stackIndicator = series.getStackIndicator(stackIndicator, x, series.index, key);
  36675. stack = stacks[key] && stacks[key][x];
  36676. pointExtremes =
  36677. stack && stack.points[stackIndicator.key];
  36678. if (pointExtremes) {
  36679. series[stacking + 'Stacker'](pointExtremes, stack, i);
  36680. }
  36681. }
  36682. });
  36683. }
  36684. };
  36685. /**
  36686. * Modifier function for percent stacks. Blows up the stack to 100%.
  36687. *
  36688. * @private
  36689. * @function Highcharts.Series#percentStacker
  36690. * @param {Array<number>} pointExtremes
  36691. * @param {Highcharts.StackItem} stack
  36692. * @param {number} i
  36693. */
  36694. Series.prototype.percentStacker = function (pointExtremes, stack, i) {
  36695. var totalFactor = stack.total ? 100 / stack.total : 0;
  36696. // Y bottom value
  36697. pointExtremes[0] = correctFloat(pointExtremes[0] * totalFactor);
  36698. // Y value
  36699. pointExtremes[1] = correctFloat(pointExtremes[1] * totalFactor);
  36700. this.stackedYData[i] = pointExtremes[1];
  36701. };
  36702. /**
  36703. * Get stack indicator, according to it's x-value, to determine points with the
  36704. * same x-value
  36705. *
  36706. * @private
  36707. * @function Highcharts.Series#getStackIndicator
  36708. * @param {Highcharts.StackItemIndicatorObject|undefined} stackIndicator
  36709. * @param {number} x
  36710. * @param {number} index
  36711. * @param {string} [key]
  36712. * @return {Highcharts.StackItemIndicatorObject}
  36713. */
  36714. Series.prototype.getStackIndicator = function (stackIndicator, x, index, key) {
  36715. // Update stack indicator, when:
  36716. // first point in a stack || x changed || stack type (negative vs positive)
  36717. // changed:
  36718. if (!defined(stackIndicator) ||
  36719. stackIndicator.x !== x ||
  36720. (key && stackIndicator.key !== key)) {
  36721. stackIndicator = {
  36722. x: x,
  36723. index: 0,
  36724. key: key
  36725. };
  36726. }
  36727. else {
  36728. (stackIndicator).index++;
  36729. }
  36730. stackIndicator.key =
  36731. [index, x, stackIndicator.index].join(',');
  36732. return stackIndicator;
  36733. };
  36734. H.StackItem = StackItem;
  36735. return H.StackItem;
  36736. });
  36737. _registerModule(_modules, 'Core/Dynamics.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Axis/Axis.js'], _modules['Core/Series/Series.js'], _modules['Core/Chart/Chart.js'], _modules['Core/Globals.js'], _modules['Series/LineSeries.js'], _modules['Core/Options.js'], _modules['Core/Series/Point.js'], _modules['Core/Time.js'], _modules['Core/Utilities.js']], function (A, Axis, BaseSeries, Chart, H, LineSeries, O, Point, Time, U) {
  36738. /* *
  36739. *
  36740. * (c) 2010-2020 Torstein Honsi
  36741. *
  36742. * License: www.highcharts.com/license
  36743. *
  36744. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  36745. *
  36746. * */
  36747. var animate = A.animate,
  36748. setAnimation = A.setAnimation;
  36749. var seriesTypes = BaseSeries.seriesTypes;
  36750. var time = O.time;
  36751. var addEvent = U.addEvent,
  36752. createElement = U.createElement,
  36753. css = U.css,
  36754. defined = U.defined,
  36755. erase = U.erase,
  36756. error = U.error,
  36757. extend = U.extend,
  36758. fireEvent = U.fireEvent,
  36759. isArray = U.isArray,
  36760. isNumber = U.isNumber,
  36761. isObject = U.isObject,
  36762. isString = U.isString,
  36763. merge = U.merge,
  36764. objectEach = U.objectEach,
  36765. pick = U.pick,
  36766. relativeLength = U.relativeLength,
  36767. splat = U.splat;
  36768. /* eslint-disable valid-jsdoc */
  36769. /**
  36770. * Remove settings that have not changed, to avoid unnecessary rendering or
  36771. * computing (#9197).
  36772. * @private
  36773. */
  36774. H.cleanRecursively = function (newer, older) {
  36775. var result = {};
  36776. objectEach(newer, function (val, key) {
  36777. var ob;
  36778. // Dive into objects (except DOM nodes)
  36779. if (isObject(newer[key], true) &&
  36780. !newer.nodeType && // #10044
  36781. older[key]) {
  36782. ob = H.cleanRecursively(newer[key], older[key]);
  36783. if (Object.keys(ob).length) {
  36784. result[key] = ob;
  36785. }
  36786. // Arrays, primitives and DOM nodes are copied directly
  36787. }
  36788. else if (isObject(newer[key]) ||
  36789. newer[key] !== older[key]) {
  36790. result[key] = newer[key];
  36791. }
  36792. });
  36793. return result;
  36794. };
  36795. // Extend the Chart prototype for dynamic methods
  36796. extend(Chart.prototype, /** @lends Highcharts.Chart.prototype */ {
  36797. /**
  36798. * Add a series to the chart after render time. Note that this method should
  36799. * never be used when adding data synchronously at chart render time, as it
  36800. * adds expense to the calculations and rendering. When adding data at the
  36801. * same time as the chart is initialized, add the series as a configuration
  36802. * option instead. With multiple axes, the `offset` is dynamically adjusted.
  36803. *
  36804. * @sample highcharts/members/chart-addseries/
  36805. * Add a series from a button
  36806. * @sample stock/members/chart-addseries/
  36807. * Add a series in Highstock
  36808. *
  36809. * @function Highcharts.Chart#addSeries
  36810. *
  36811. * @param {Highcharts.SeriesOptionsType} options
  36812. * The config options for the series.
  36813. *
  36814. * @param {boolean} [redraw=true]
  36815. * Whether to redraw the chart after adding.
  36816. *
  36817. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  36818. * Whether to apply animation, and optionally animation
  36819. * configuration.
  36820. *
  36821. * @return {Highcharts.Series}
  36822. * The newly created series object.
  36823. *
  36824. * @fires Highcharts.Chart#event:addSeries
  36825. * @fires Highcharts.Chart#event:afterAddSeries
  36826. */
  36827. addSeries: function (options, redraw, animation) {
  36828. var series,
  36829. chart = this;
  36830. if (options) { // <- not necessary
  36831. redraw = pick(redraw, true); // defaults to true
  36832. fireEvent(chart, 'addSeries', { options: options }, function () {
  36833. series = chart.initSeries(options);
  36834. chart.isDirtyLegend = true;
  36835. chart.linkSeries();
  36836. if (series.enabledDataSorting) {
  36837. // We need to call `setData` after `linkSeries`
  36838. series.setData(options.data, false);
  36839. }
  36840. fireEvent(chart, 'afterAddSeries', { series: series });
  36841. if (redraw) {
  36842. chart.redraw(animation);
  36843. }
  36844. });
  36845. }
  36846. return series;
  36847. },
  36848. /**
  36849. * Add an axis to the chart after render time. Note that this method should
  36850. * never be used when adding data synchronously at chart render time, as it
  36851. * adds expense to the calculations and rendering. When adding data at the
  36852. * same time as the chart is initialized, add the axis as a configuration
  36853. * option instead.
  36854. *
  36855. * @sample highcharts/members/chart-addaxis/
  36856. * Add and remove axes
  36857. *
  36858. * @function Highcharts.Chart#addAxis
  36859. *
  36860. * @param {Highcharts.AxisOptions} options
  36861. * The axis options.
  36862. *
  36863. * @param {boolean} [isX=false]
  36864. * Whether it is an X axis or a value axis.
  36865. *
  36866. * @param {boolean} [redraw=true]
  36867. * Whether to redraw the chart after adding.
  36868. *
  36869. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  36870. * Whether and how to apply animation in the redraw.
  36871. *
  36872. * @return {Highcharts.Axis}
  36873. * The newly generated Axis object.
  36874. */
  36875. addAxis: function (options, isX, redraw, animation) {
  36876. return this.createAxis(isX ? 'xAxis' : 'yAxis', { axis: options, redraw: redraw, animation: animation });
  36877. },
  36878. /**
  36879. * Add a color axis to the chart after render time. Note that this method
  36880. * should never be used when adding data synchronously at chart render time,
  36881. * as it adds expense to the calculations and rendering. When adding data at
  36882. * the same time as the chart is initialized, add the axis as a
  36883. * configuration option instead.
  36884. *
  36885. * @sample highcharts/members/chart-addaxis/
  36886. * Add and remove axes
  36887. *
  36888. * @function Highcharts.Chart#addColorAxis
  36889. *
  36890. * @param {Highcharts.ColorAxisOptions} options
  36891. * The axis options.
  36892. *
  36893. * @param {boolean} [redraw=true]
  36894. * Whether to redraw the chart after adding.
  36895. *
  36896. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  36897. * Whether and how to apply animation in the redraw.
  36898. *
  36899. * @return {Highcharts.ColorAxis}
  36900. * The newly generated Axis object.
  36901. */
  36902. addColorAxis: function (options, redraw, animation) {
  36903. return this.createAxis('colorAxis', { axis: options, redraw: redraw, animation: animation });
  36904. },
  36905. /**
  36906. * Factory for creating different axis types.
  36907. *
  36908. * @private
  36909. * @function Highcharts.Chart#createAxis
  36910. *
  36911. * @param {string} type
  36912. * An axis type.
  36913. *
  36914. * @param {...Array<*>} arguments
  36915. * All arguments for the constructor.
  36916. *
  36917. * @return {Highcharts.Axis | Highcharts.ColorAxis}
  36918. * The newly generated Axis object.
  36919. */
  36920. createAxis: function (type, options) {
  36921. var chartOptions = this.options,
  36922. isColorAxis = type === 'colorAxis',
  36923. axisOptions = options.axis,
  36924. redraw = options.redraw,
  36925. animation = options.animation,
  36926. userOptions = merge(axisOptions, {
  36927. index: this[type].length,
  36928. isX: type === 'xAxis'
  36929. }),
  36930. axis;
  36931. if (isColorAxis) {
  36932. axis = new H.ColorAxis(this, userOptions);
  36933. }
  36934. else {
  36935. axis = new Axis(this, userOptions);
  36936. }
  36937. // Push the new axis options to the chart options
  36938. chartOptions[type] = splat(chartOptions[type] || {});
  36939. chartOptions[type].push(userOptions);
  36940. if (isColorAxis) {
  36941. this.isDirtyLegend = true;
  36942. // Clear before 'bindAxes' (#11924)
  36943. this.axes.forEach(function (axis) {
  36944. axis.series = [];
  36945. });
  36946. this.series.forEach(function (series) {
  36947. series.bindAxes();
  36948. series.isDirtyData = true;
  36949. });
  36950. }
  36951. if (pick(redraw, true)) {
  36952. this.redraw(animation);
  36953. }
  36954. return axis;
  36955. },
  36956. /**
  36957. * Dim the chart and show a loading text or symbol. Options for the loading
  36958. * screen are defined in {@link
  36959. * https://api.highcharts.com/highcharts/loading|the loading options}.
  36960. *
  36961. * @sample highcharts/members/chart-hideloading/
  36962. * Show and hide loading from a button
  36963. * @sample highcharts/members/chart-showloading/
  36964. * Apply different text labels
  36965. * @sample stock/members/chart-show-hide-loading/
  36966. * Toggle loading in Highstock
  36967. *
  36968. * @function Highcharts.Chart#showLoading
  36969. *
  36970. * @param {string} [str]
  36971. * An optional text to show in the loading label instead of the
  36972. * default one. The default text is set in
  36973. * [lang.loading](https://api.highcharts.com/highcharts/lang.loading).
  36974. */
  36975. showLoading: function (str) {
  36976. var chart = this,
  36977. options = chart.options,
  36978. loadingDiv = chart.loadingDiv,
  36979. loadingOptions = options.loading,
  36980. setLoadingSize = function () {
  36981. if (loadingDiv) {
  36982. css(loadingDiv, {
  36983. left: chart.plotLeft + 'px',
  36984. top: chart.plotTop + 'px',
  36985. width: chart.plotWidth + 'px',
  36986. height: chart.plotHeight + 'px'
  36987. });
  36988. }
  36989. };
  36990. // create the layer at the first call
  36991. if (!loadingDiv) {
  36992. chart.loadingDiv = loadingDiv = createElement('div', {
  36993. className: 'highcharts-loading highcharts-loading-hidden'
  36994. }, null, chart.container);
  36995. chart.loadingSpan = createElement('span', { className: 'highcharts-loading-inner' }, null, loadingDiv);
  36996. addEvent(chart, 'redraw', setLoadingSize); // #1080
  36997. }
  36998. loadingDiv.className = 'highcharts-loading';
  36999. // Update text
  37000. chart.loadingSpan.innerHTML =
  37001. pick(str, options.lang.loading, '');
  37002. if (!chart.styledMode) {
  37003. // Update visuals
  37004. css(loadingDiv, extend(loadingOptions.style, {
  37005. zIndex: 10
  37006. }));
  37007. css(chart.loadingSpan, loadingOptions.labelStyle);
  37008. // Show it
  37009. if (!chart.loadingShown) {
  37010. css(loadingDiv, {
  37011. opacity: 0,
  37012. display: ''
  37013. });
  37014. animate(loadingDiv, {
  37015. opacity: loadingOptions.style.opacity || 0.5
  37016. }, {
  37017. duration: loadingOptions.showDuration || 0
  37018. });
  37019. }
  37020. }
  37021. chart.loadingShown = true;
  37022. setLoadingSize();
  37023. },
  37024. /**
  37025. * Hide the loading layer.
  37026. *
  37027. * @see Highcharts.Chart#showLoading
  37028. *
  37029. * @sample highcharts/members/chart-hideloading/
  37030. * Show and hide loading from a button
  37031. * @sample stock/members/chart-show-hide-loading/
  37032. * Toggle loading in Highstock
  37033. *
  37034. * @function Highcharts.Chart#hideLoading
  37035. */
  37036. hideLoading: function () {
  37037. var options = this.options,
  37038. loadingDiv = this.loadingDiv;
  37039. if (loadingDiv) {
  37040. loadingDiv.className =
  37041. 'highcharts-loading highcharts-loading-hidden';
  37042. if (!this.styledMode) {
  37043. animate(loadingDiv, {
  37044. opacity: 0
  37045. }, {
  37046. duration: options.loading.hideDuration || 100,
  37047. complete: function () {
  37048. css(loadingDiv, { display: 'none' });
  37049. }
  37050. });
  37051. }
  37052. }
  37053. this.loadingShown = false;
  37054. },
  37055. /**
  37056. * These properties cause isDirtyBox to be set to true when updating. Can be
  37057. * extended from plugins.
  37058. */
  37059. propsRequireDirtyBox: [
  37060. 'backgroundColor',
  37061. 'borderColor',
  37062. 'borderWidth',
  37063. 'borderRadius',
  37064. 'plotBackgroundColor',
  37065. 'plotBackgroundImage',
  37066. 'plotBorderColor',
  37067. 'plotBorderWidth',
  37068. 'plotShadow',
  37069. 'shadow'
  37070. ],
  37071. /**
  37072. * These properties require a full reflow of chart elements, best
  37073. * implemented through running `Chart.setSize` internally (#8190).
  37074. * @type {Array}
  37075. */
  37076. propsRequireReflow: [
  37077. 'margin',
  37078. 'marginTop',
  37079. 'marginRight',
  37080. 'marginBottom',
  37081. 'marginLeft',
  37082. 'spacing',
  37083. 'spacingTop',
  37084. 'spacingRight',
  37085. 'spacingBottom',
  37086. 'spacingLeft'
  37087. ],
  37088. /**
  37089. * These properties cause all series to be updated when updating. Can be
  37090. * extended from plugins.
  37091. */
  37092. propsRequireUpdateSeries: [
  37093. 'chart.inverted',
  37094. 'chart.polar',
  37095. 'chart.ignoreHiddenSeries',
  37096. 'chart.type',
  37097. 'colors',
  37098. 'plotOptions',
  37099. 'time',
  37100. 'tooltip'
  37101. ],
  37102. /**
  37103. * These collections (arrays) implement update() methods with support for
  37104. * one-to-one option.
  37105. */
  37106. collectionsWithUpdate: [
  37107. 'xAxis',
  37108. 'yAxis',
  37109. 'zAxis',
  37110. 'series'
  37111. ],
  37112. /**
  37113. * A generic function to update any element of the chart. Elements can be
  37114. * enabled and disabled, moved, re-styled, re-formatted etc.
  37115. *
  37116. * A special case is configuration objects that take arrays, for example
  37117. * [xAxis](https://api.highcharts.com/highcharts/xAxis),
  37118. * [yAxis](https://api.highcharts.com/highcharts/yAxis) or
  37119. * [series](https://api.highcharts.com/highcharts/series). For these
  37120. * collections, an `id` option is used to map the new option set to an
  37121. * existing object. If an existing object of the same id is not found, the
  37122. * corresponding item is updated. So for example, running `chart.update`
  37123. * with a series item without an id, will cause the existing chart's series
  37124. * with the same index in the series array to be updated. When the
  37125. * `oneToOne` parameter is true, `chart.update` will also take care of
  37126. * adding and removing items from the collection. Read more under the
  37127. * parameter description below.
  37128. *
  37129. * Note that when changing series data, `chart.update` may mutate the passed
  37130. * data options.
  37131. *
  37132. * See also the
  37133. * [responsive option set](https://api.highcharts.com/highcharts/responsive).
  37134. * Switching between `responsive.rules` basically runs `chart.update` under
  37135. * the hood.
  37136. *
  37137. * @sample highcharts/members/chart-update/
  37138. * Update chart geometry
  37139. *
  37140. * @function Highcharts.Chart#update
  37141. *
  37142. * @param {Highcharts.Options} options
  37143. * A configuration object for the new chart options.
  37144. *
  37145. * @param {boolean} [redraw=true]
  37146. * Whether to redraw the chart.
  37147. *
  37148. * @param {boolean} [oneToOne=false]
  37149. * When `true`, the `series`, `xAxis`, `yAxis` and `annotations`
  37150. * collections will be updated one to one, and items will be either
  37151. * added or removed to match the new updated options. For example,
  37152. * if the chart has two series and we call `chart.update` with a
  37153. * configuration containing three series, one will be added. If we
  37154. * call `chart.update` with one series, one will be removed. Setting
  37155. * an empty `series` array will remove all series, but leaving out
  37156. * the`series` property will leave all series untouched. If the
  37157. * series have id's, the new series options will be matched by id,
  37158. * and the remaining ones removed.
  37159. *
  37160. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  37161. * Whether to apply animation, and optionally animation
  37162. * configuration.
  37163. *
  37164. * @fires Highcharts.Chart#event:update
  37165. * @fires Highcharts.Chart#event:afterUpdate
  37166. */
  37167. update: function (options, redraw, oneToOne, animation) {
  37168. var chart = this,
  37169. adders = {
  37170. credits: 'addCredits',
  37171. title: 'setTitle',
  37172. subtitle: 'setSubtitle',
  37173. caption: 'setCaption'
  37174. },
  37175. optionsChart,
  37176. updateAllAxes,
  37177. updateAllSeries,
  37178. newWidth,
  37179. newHeight,
  37180. runSetSize,
  37181. isResponsiveOptions = options.isResponsiveOptions,
  37182. itemsForRemoval = [];
  37183. fireEvent(chart, 'update', { options: options });
  37184. // If there are responsive rules in action, undo the responsive rules
  37185. // before we apply the updated options and replay the responsive rules
  37186. // on top from the chart.redraw function (#9617).
  37187. if (!isResponsiveOptions) {
  37188. chart.setResponsive(false, true);
  37189. }
  37190. options = H.cleanRecursively(options, chart.options);
  37191. merge(true, chart.userOptions, options);
  37192. // If the top-level chart option is present, some special updates are
  37193. // required
  37194. optionsChart = options.chart;
  37195. if (optionsChart) {
  37196. merge(true, chart.options.chart, optionsChart);
  37197. // Setter function
  37198. if ('className' in optionsChart) {
  37199. chart.setClassName(optionsChart.className);
  37200. }
  37201. if ('reflow' in optionsChart) {
  37202. chart.setReflow(optionsChart.reflow);
  37203. }
  37204. if ('inverted' in optionsChart ||
  37205. 'polar' in optionsChart ||
  37206. 'type' in optionsChart) {
  37207. // Parse options.chart.inverted and options.chart.polar together
  37208. // with the available series.
  37209. chart.propFromSeries();
  37210. updateAllAxes = true;
  37211. }
  37212. if ('alignTicks' in optionsChart) { // #6452
  37213. updateAllAxes = true;
  37214. }
  37215. objectEach(optionsChart, function (val, key) {
  37216. if (chart.propsRequireUpdateSeries.indexOf('chart.' + key) !==
  37217. -1) {
  37218. updateAllSeries = true;
  37219. }
  37220. // Only dirty box
  37221. if (chart.propsRequireDirtyBox.indexOf(key) !== -1) {
  37222. chart.isDirtyBox = true;
  37223. }
  37224. // Chart setSize
  37225. if (chart.propsRequireReflow.indexOf(key) !== -1) {
  37226. if (isResponsiveOptions) {
  37227. chart.isDirtyBox = true;
  37228. }
  37229. else {
  37230. runSetSize = true;
  37231. }
  37232. }
  37233. });
  37234. if (!chart.styledMode && 'style' in optionsChart) {
  37235. chart.renderer.setStyle(optionsChart.style);
  37236. }
  37237. }
  37238. // Moved up, because tooltip needs updated plotOptions (#6218)
  37239. if (!chart.styledMode && options.colors) {
  37240. this.options.colors = options.colors;
  37241. }
  37242. if (options.time) {
  37243. // Maintaining legacy global time. If the chart is instanciated
  37244. // first with global time, then updated with time options, we need
  37245. // to create a new Time instance to avoid mutating the global time
  37246. // (#10536).
  37247. if (this.time === time) {
  37248. this.time = new Time(options.time);
  37249. }
  37250. // If we're updating, the time class is different from other chart
  37251. // classes (chart.legend, chart.tooltip etc) in that it doesn't know
  37252. // about the chart. The other chart[something].update functions also
  37253. // set the chart.options[something]. For the time class however we
  37254. // need to update the chart options separately. #14230.
  37255. merge(true, chart.options.time, options.time);
  37256. }
  37257. // Some option stuctures correspond one-to-one to chart objects that
  37258. // have update methods, for example
  37259. // options.credits => chart.credits
  37260. // options.legend => chart.legend
  37261. // options.title => chart.title
  37262. // options.tooltip => chart.tooltip
  37263. // options.subtitle => chart.subtitle
  37264. // options.mapNavigation => chart.mapNavigation
  37265. // options.navigator => chart.navigator
  37266. // options.scrollbar => chart.scrollbar
  37267. objectEach(options, function (val, key) {
  37268. if (chart[key] &&
  37269. typeof chart[key].update === 'function') {
  37270. chart[key].update(val, false);
  37271. // If a one-to-one object does not exist, look for an adder function
  37272. }
  37273. else if (typeof chart[adders[key]] === 'function') {
  37274. chart[adders[key]](val);
  37275. // Else, just merge the options. For nodes like loading, noData,
  37276. // plotOptions
  37277. }
  37278. else if (key !== 'color' &&
  37279. chart.collectionsWithUpdate.indexOf(key) === -1) {
  37280. merge(true, chart.options[key], options[key]);
  37281. }
  37282. if (key !== 'chart' &&
  37283. chart.propsRequireUpdateSeries.indexOf(key) !== -1) {
  37284. updateAllSeries = true;
  37285. }
  37286. });
  37287. // Setters for collections. For axes and series, each item is referred
  37288. // by an id. If the id is not found, it defaults to the corresponding
  37289. // item in the collection, so setting one series without an id, will
  37290. // update the first series in the chart. Setting two series without
  37291. // an id will update the first and the second respectively (#6019)
  37292. // chart.update and responsive.
  37293. this.collectionsWithUpdate.forEach(function (coll) {
  37294. var indexMap;
  37295. if (options[coll]) {
  37296. // In stock charts, the navigator series are also part of the
  37297. // chart.series array, but those series should not be handled
  37298. // here (#8196).
  37299. if (coll === 'series') {
  37300. indexMap = [];
  37301. chart[coll].forEach(function (s, i) {
  37302. if (!s.options.isInternal) {
  37303. indexMap.push(pick(s.options.index, i));
  37304. }
  37305. });
  37306. }
  37307. splat(options[coll]).forEach(function (newOptions, i) {
  37308. var hasId = defined(newOptions.id);
  37309. var item;
  37310. // Match by id
  37311. if (hasId) {
  37312. item = chart.get(newOptions.id);
  37313. }
  37314. // No match by id found, match by index instead
  37315. if (!item) {
  37316. item = chart[coll][indexMap ? indexMap[i] : i];
  37317. // Check if we grabbed an item with an exising but
  37318. // different id (#13541)
  37319. if (item && hasId && defined(item.options.id)) {
  37320. item = void 0;
  37321. }
  37322. }
  37323. if (item && item.coll === coll) {
  37324. item.update(newOptions, false);
  37325. if (oneToOne) {
  37326. item.touched = true;
  37327. }
  37328. }
  37329. // If oneToOne and no matching item is found, add one
  37330. if (!item && oneToOne && chart.collectionsWithInit[coll]) {
  37331. chart.collectionsWithInit[coll][0].apply(chart,
  37332. // [newOptions, ...extraArguments, redraw=false]
  37333. [
  37334. newOptions
  37335. ].concat(
  37336. // Not all initializers require extra args
  37337. chart.collectionsWithInit[coll][1] || []).concat([
  37338. false
  37339. ])).touched = true;
  37340. }
  37341. });
  37342. // Add items for removal
  37343. if (oneToOne) {
  37344. chart[coll].forEach(function (item) {
  37345. if (!item.touched && !item.options.isInternal) {
  37346. itemsForRemoval.push(item);
  37347. }
  37348. else {
  37349. delete item.touched;
  37350. }
  37351. });
  37352. }
  37353. }
  37354. });
  37355. itemsForRemoval.forEach(function (item) {
  37356. if (item.remove) {
  37357. item.remove(false);
  37358. }
  37359. });
  37360. if (updateAllAxes) {
  37361. chart.axes.forEach(function (axis) {
  37362. axis.update({}, false);
  37363. });
  37364. }
  37365. // Certain options require the whole series structure to be thrown away
  37366. // and rebuilt
  37367. if (updateAllSeries) {
  37368. chart.getSeriesOrderByLinks().forEach(function (series) {
  37369. // Avoid removed navigator series
  37370. if (series.chart) {
  37371. series.update({}, false);
  37372. }
  37373. }, this);
  37374. }
  37375. // Update size. Redraw is forced.
  37376. newWidth = optionsChart && optionsChart.width;
  37377. newHeight = optionsChart && optionsChart.height;
  37378. if (isString(newHeight)) {
  37379. newHeight = relativeLength(newHeight, newWidth || chart.chartWidth);
  37380. }
  37381. if (
  37382. // In this case, run chart.setSize with newWidth and newHeight which
  37383. // are undefined, only for reflowing chart elements because margin
  37384. // or spacing has been set (#8190)
  37385. runSetSize ||
  37386. // In this case, the size is actually set
  37387. (isNumber(newWidth) && newWidth !== chart.chartWidth) ||
  37388. (isNumber(newHeight) && newHeight !== chart.chartHeight)) {
  37389. chart.setSize(newWidth, newHeight, animation);
  37390. }
  37391. else if (pick(redraw, true)) {
  37392. chart.redraw(animation);
  37393. }
  37394. fireEvent(chart, 'afterUpdate', {
  37395. options: options,
  37396. redraw: redraw,
  37397. animation: animation
  37398. });
  37399. },
  37400. /**
  37401. * Shortcut to set the subtitle options. This can also be done from {@link
  37402. * Chart#update} or {@link Chart#setTitle}.
  37403. *
  37404. * @function Highcharts.Chart#setSubtitle
  37405. *
  37406. * @param {Highcharts.SubtitleOptions} options
  37407. * New subtitle options. The subtitle text itself is set by the
  37408. * `options.text` property.
  37409. */
  37410. setSubtitle: function (options, redraw) {
  37411. this.applyDescription('subtitle', options);
  37412. this.layOutTitles(redraw);
  37413. },
  37414. /**
  37415. * Set the caption options. This can also be done from {@link
  37416. * Chart#update}.
  37417. *
  37418. * @function Highcharts.Chart#setCaption
  37419. *
  37420. * @param {Highcharts.CaptionOptions} options
  37421. * New caption options. The caption text itself is set by the
  37422. * `options.text` property.
  37423. */
  37424. setCaption: function (options, redraw) {
  37425. this.applyDescription('caption', options);
  37426. this.layOutTitles(redraw);
  37427. }
  37428. });
  37429. /**
  37430. * These collections (arrays) implement `Chart.addSomethig` method used in
  37431. * chart.update() to create new object in the collection. Equivalent for
  37432. * deleting is resolved by simple `Somethig.remove()`.
  37433. *
  37434. * Note: We need to define these references after initializers are bound to
  37435. * chart's prototype.
  37436. */
  37437. Chart.prototype.collectionsWithInit = {
  37438. // collectionName: [ initializingMethod, [extraArguments] ]
  37439. xAxis: [Chart.prototype.addAxis, [true]],
  37440. yAxis: [Chart.prototype.addAxis, [false]],
  37441. series: [Chart.prototype.addSeries]
  37442. };
  37443. // extend the Point prototype for dynamic methods
  37444. extend(Point.prototype, /** @lends Highcharts.Point.prototype */ {
  37445. /**
  37446. * Update point with new options (typically x/y data) and optionally redraw
  37447. * the series.
  37448. *
  37449. * @sample highcharts/members/point-update-column/
  37450. * Update column value
  37451. * @sample highcharts/members/point-update-pie/
  37452. * Update pie slice
  37453. * @sample maps/members/point-update/
  37454. * Update map area value in Highmaps
  37455. *
  37456. * @function Highcharts.Point#update
  37457. *
  37458. * @param {Highcharts.PointOptionsType} options
  37459. * The point options. Point options are handled as described under
  37460. * the `series.type.data` item for each series type. For example
  37461. * for a line series, if options is a single number, the point will
  37462. * be given that number as the marin y value. If it is an array, it
  37463. * will be interpreted as x and y values respectively. If it is an
  37464. * object, advanced options are applied.
  37465. *
  37466. * @param {boolean} [redraw=true]
  37467. * Whether to redraw the chart after the point is updated. If doing
  37468. * more operations on the chart, it is best practice to set
  37469. * `redraw` to false and call `chart.redraw()` after.
  37470. *
  37471. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  37472. * Whether to apply animation, and optionally animation
  37473. * configuration.
  37474. *
  37475. * @return {void}
  37476. *
  37477. * @fires Highcharts.Point#event:update
  37478. */
  37479. update: function (options, redraw, animation, runEvent) {
  37480. var point = this,
  37481. series = point.series,
  37482. graphic = point.graphic,
  37483. i,
  37484. chart = series.chart,
  37485. seriesOptions = series.options;
  37486. redraw = pick(redraw, true);
  37487. /**
  37488. * @private
  37489. */
  37490. function update() {
  37491. point.applyOptions(options);
  37492. // Update visuals, #4146
  37493. // Handle dummy graphic elements for a11y, #12718
  37494. var hasDummyGraphic = graphic && point.hasDummyGraphic;
  37495. var shouldDestroyGraphic = point.y === null ? !hasDummyGraphic : hasDummyGraphic;
  37496. if (graphic && shouldDestroyGraphic) {
  37497. point.graphic = graphic.destroy();
  37498. delete point.hasDummyGraphic;
  37499. }
  37500. if (isObject(options, true)) {
  37501. // Destroy so we can get new elements
  37502. if (graphic && graphic.element) {
  37503. // "null" is also a valid symbol
  37504. if (options &&
  37505. options.marker &&
  37506. typeof options.marker.symbol !== 'undefined') {
  37507. point.graphic = graphic.destroy();
  37508. }
  37509. }
  37510. if (options && options.dataLabels && point.dataLabel) {
  37511. point.dataLabel = point.dataLabel.destroy(); // #2468
  37512. }
  37513. if (point.connector) {
  37514. point.connector = point.connector.destroy(); // #7243
  37515. }
  37516. }
  37517. // record changes in the parallel arrays
  37518. i = point.index;
  37519. series.updateParallelArrays(point, i);
  37520. // Record the options to options.data. If the old or the new config
  37521. // is an object, use point options, otherwise use raw options
  37522. // (#4701, #4916).
  37523. seriesOptions.data[i] = (isObject(seriesOptions.data[i], true) ||
  37524. isObject(options, true)) ?
  37525. point.options :
  37526. pick(options, seriesOptions.data[i]);
  37527. // redraw
  37528. series.isDirty = series.isDirtyData = true;
  37529. if (!series.fixedBox && series.hasCartesianSeries) { // #1906, #2320
  37530. chart.isDirtyBox = true;
  37531. }
  37532. if (seriesOptions.legendType === 'point') { // #1831, #1885
  37533. chart.isDirtyLegend = true;
  37534. }
  37535. if (redraw) {
  37536. chart.redraw(animation);
  37537. }
  37538. }
  37539. // Fire the event with a default handler of doing the update
  37540. if (runEvent === false) { // When called from setData
  37541. update();
  37542. }
  37543. else {
  37544. point.firePointEvent('update', { options: options }, update);
  37545. }
  37546. },
  37547. /**
  37548. * Remove a point and optionally redraw the series and if necessary the axes
  37549. *
  37550. * @sample highcharts/plotoptions/series-point-events-remove/
  37551. * Remove point and confirm
  37552. * @sample highcharts/members/point-remove/
  37553. * Remove pie slice
  37554. * @sample maps/members/point-remove/
  37555. * Remove selected points in Highmaps
  37556. *
  37557. * @function Highcharts.Point#remove
  37558. *
  37559. * @param {boolean} [redraw=true]
  37560. * Whether to redraw the chart or wait for an explicit call. When
  37561. * doing more operations on the chart, for example running
  37562. * `point.remove()` in a loop, it is best practice to set `redraw`
  37563. * to false and call `chart.redraw()` after.
  37564. *
  37565. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=false]
  37566. * Whether to apply animation, and optionally animation
  37567. * configuration.
  37568. *
  37569. * @return {void}
  37570. */
  37571. remove: function (redraw, animation) {
  37572. this.series.removePoint(this.series.data.indexOf(this), redraw, animation);
  37573. }
  37574. });
  37575. // Extend the series prototype for dynamic methods
  37576. extend(LineSeries.prototype, /** @lends Series.prototype */ {
  37577. /**
  37578. * Add a point to the series after render time. The point can be added at
  37579. * the end, or by giving it an X value, to the start or in the middle of the
  37580. * series.
  37581. *
  37582. * @sample highcharts/members/series-addpoint-append/
  37583. * Append point
  37584. * @sample highcharts/members/series-addpoint-append-and-shift/
  37585. * Append and shift
  37586. * @sample highcharts/members/series-addpoint-x-and-y/
  37587. * Both X and Y values given
  37588. * @sample highcharts/members/series-addpoint-pie/
  37589. * Append pie slice
  37590. * @sample stock/members/series-addpoint/
  37591. * Append 100 points in Highstock
  37592. * @sample stock/members/series-addpoint-shift/
  37593. * Append and shift in Highstock
  37594. * @sample maps/members/series-addpoint/
  37595. * Add a point in Highmaps
  37596. *
  37597. * @function Highcharts.Series#addPoint
  37598. *
  37599. * @param {Highcharts.PointOptionsType} options
  37600. * The point options. If options is a single number, a point with
  37601. * that y value is appended to the series. If it is an array, it will
  37602. * be interpreted as x and y values respectively. If it is an
  37603. * object, advanced options as outlined under `series.data` are
  37604. * applied.
  37605. *
  37606. * @param {boolean} [redraw=true]
  37607. * Whether to redraw the chart after the point is added. When adding
  37608. * more than one point, it is highly recommended that the redraw
  37609. * option be set to false, and instead {@link Chart#redraw} is
  37610. * explicitly called after the adding of points is finished.
  37611. * Otherwise, the chart will redraw after adding each point.
  37612. *
  37613. * @param {boolean} [shift=false]
  37614. * If true, a point is shifted off the start of the series as one is
  37615. * appended to the end.
  37616. *
  37617. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  37618. * Whether to apply animation, and optionally animation
  37619. * configuration.
  37620. *
  37621. * @param {boolean} [withEvent=true]
  37622. * Used internally, whether to fire the series `addPoint` event.
  37623. *
  37624. * @return {void}
  37625. *
  37626. * @fires Highcharts.Series#event:addPoint
  37627. */
  37628. addPoint: function (options, redraw, shift, animation, withEvent) {
  37629. var series = this,
  37630. seriesOptions = series.options,
  37631. data = series.data,
  37632. chart = series.chart,
  37633. xAxis = series.xAxis,
  37634. names = xAxis && xAxis.hasNames && xAxis.names,
  37635. dataOptions = seriesOptions.data,
  37636. point,
  37637. xData = series.xData,
  37638. isInTheMiddle,
  37639. i,
  37640. x;
  37641. // Optional redraw, defaults to true
  37642. redraw = pick(redraw, true);
  37643. // Get options and push the point to xData, yData and series.options. In
  37644. // series.generatePoints the Point instance will be created on demand
  37645. // and pushed to the series.data array.
  37646. point = { series: series };
  37647. series.pointClass.prototype.applyOptions.apply(point, [options]);
  37648. x = point.x;
  37649. // Get the insertion point
  37650. i = xData.length;
  37651. if (series.requireSorting && x < xData[i - 1]) {
  37652. isInTheMiddle = true;
  37653. while (i && xData[i - 1] > x) {
  37654. i--;
  37655. }
  37656. }
  37657. // Insert undefined item
  37658. series.updateParallelArrays(point, 'splice', i, 0, 0);
  37659. // Update it
  37660. series.updateParallelArrays(point, i);
  37661. if (names && point.name) {
  37662. names[x] = point.name;
  37663. }
  37664. dataOptions.splice(i, 0, options);
  37665. if (isInTheMiddle) {
  37666. series.data.splice(i, 0, null);
  37667. series.processData();
  37668. }
  37669. // Generate points to be added to the legend (#1329)
  37670. if (seriesOptions.legendType === 'point') {
  37671. series.generatePoints();
  37672. }
  37673. // Shift the first point off the parallel arrays
  37674. if (shift) {
  37675. if (data[0] && data[0].remove) {
  37676. data[0].remove(false);
  37677. }
  37678. else {
  37679. data.shift();
  37680. series.updateParallelArrays(point, 'shift');
  37681. dataOptions.shift();
  37682. }
  37683. }
  37684. // Fire event
  37685. if (withEvent !== false) {
  37686. fireEvent(series, 'addPoint', { point: point });
  37687. }
  37688. // redraw
  37689. series.isDirty = true;
  37690. series.isDirtyData = true;
  37691. if (redraw) {
  37692. chart.redraw(animation); // Animation is set anyway on redraw, #5665
  37693. }
  37694. },
  37695. /**
  37696. * Remove a point from the series. Unlike the
  37697. * {@link Highcharts.Point#remove} method, this can also be done on a point
  37698. * that is not instanciated because it is outside the view or subject to
  37699. * Highstock data grouping.
  37700. *
  37701. * @sample highcharts/members/series-removepoint/
  37702. * Remove cropped point
  37703. *
  37704. * @function Highcharts.Series#removePoint
  37705. *
  37706. * @param {number} i
  37707. * The index of the point in the {@link Highcharts.Series.data|data}
  37708. * array.
  37709. *
  37710. * @param {boolean} [redraw=true]
  37711. * Whether to redraw the chart after the point is added. When
  37712. * removing more than one point, it is highly recommended that the
  37713. * `redraw` option be set to `false`, and instead {@link
  37714. * Highcharts.Chart#redraw} is explicitly called after the adding of
  37715. * points is finished.
  37716. *
  37717. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  37718. * Whether and optionally how the series should be animated.
  37719. *
  37720. * @return {void}
  37721. *
  37722. * @fires Highcharts.Point#event:remove
  37723. */
  37724. removePoint: function (i, redraw, animation) {
  37725. var series = this,
  37726. data = series.data,
  37727. point = data[i],
  37728. points = series.points,
  37729. chart = series.chart,
  37730. remove = function () {
  37731. if (points && points.length === data.length) { // #4935
  37732. points.splice(i, 1);
  37733. }
  37734. data.splice(i, 1);
  37735. series.options.data.splice(i, 1);
  37736. series.updateParallelArrays(point || { series: series }, 'splice', i, 1);
  37737. if (point) {
  37738. point.destroy();
  37739. }
  37740. // redraw
  37741. series.isDirty = true;
  37742. series.isDirtyData = true;
  37743. if (redraw) {
  37744. chart.redraw();
  37745. }
  37746. };
  37747. setAnimation(animation, chart);
  37748. redraw = pick(redraw, true);
  37749. // Fire the event with a default handler of removing the point
  37750. if (point) {
  37751. point.firePointEvent('remove', null, remove);
  37752. }
  37753. else {
  37754. remove();
  37755. }
  37756. },
  37757. /**
  37758. * Remove a series and optionally redraw the chart.
  37759. *
  37760. * @sample highcharts/members/series-remove/
  37761. * Remove first series from a button
  37762. *
  37763. * @function Highcharts.Series#remove
  37764. *
  37765. * @param {boolean} [redraw=true]
  37766. * Whether to redraw the chart or wait for an explicit call to
  37767. * {@link Highcharts.Chart#redraw}.
  37768. *
  37769. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  37770. * Whether to apply animation, and optionally animation
  37771. * configuration.
  37772. *
  37773. * @param {boolean} [withEvent=true]
  37774. * Used internally, whether to fire the series `remove` event.
  37775. *
  37776. * @return {void}
  37777. *
  37778. * @fires Highcharts.Series#event:remove
  37779. */
  37780. remove: function (redraw, animation, withEvent, keepEvents) {
  37781. var series = this,
  37782. chart = series.chart;
  37783. /**
  37784. * @private
  37785. */
  37786. function remove() {
  37787. // Destroy elements
  37788. series.destroy(keepEvents);
  37789. series.remove = null; // Prevent from doing again (#9097)
  37790. // Redraw
  37791. chart.isDirtyLegend = chart.isDirtyBox = true;
  37792. chart.linkSeries();
  37793. if (pick(redraw, true)) {
  37794. chart.redraw(animation);
  37795. }
  37796. }
  37797. // Fire the event with a default handler of removing the point
  37798. if (withEvent !== false) {
  37799. fireEvent(series, 'remove', null, remove);
  37800. }
  37801. else {
  37802. remove();
  37803. }
  37804. },
  37805. /**
  37806. * Update the series with a new set of options. For a clean and precise
  37807. * handling of new options, all methods and elements from the series are
  37808. * removed, and it is initialized from scratch. Therefore, this method is
  37809. * more performance expensive than some other utility methods like {@link
  37810. * Series#setData} or {@link Series#setVisible}.
  37811. *
  37812. * Note that `Series.update` may mutate the passed `data` options.
  37813. *
  37814. * @sample highcharts/members/series-update/
  37815. * Updating series options
  37816. * @sample maps/members/series-update/
  37817. * Update series options in Highmaps
  37818. *
  37819. * @function Highcharts.Series#update
  37820. *
  37821. * @param {Highcharts.SeriesOptionsType} options
  37822. * New options that will be merged with the series' existing options.
  37823. *
  37824. * @param {boolean} [redraw=true]
  37825. * Whether to redraw the chart after the series is altered. If doing
  37826. * more operations on the chart, it is a good idea to set redraw to
  37827. * false and call {@link Chart#redraw} after.
  37828. *
  37829. * @return {void}
  37830. *
  37831. * @fires Highcharts.Series#event:update
  37832. * @fires Highcharts.Series#event:afterUpdate
  37833. */
  37834. update: function (options, redraw) {
  37835. options = H.cleanRecursively(options, this.userOptions);
  37836. fireEvent(this, 'update', { options: options });
  37837. var series = this,
  37838. chart = series.chart,
  37839. // must use user options when changing type because series.options
  37840. // is merged in with type specific plotOptions
  37841. oldOptions = series.userOptions,
  37842. seriesOptions,
  37843. initialType = series.initialType || series.type,
  37844. plotOptions = chart.options.plotOptions,
  37845. newType = (options.type ||
  37846. oldOptions.type ||
  37847. chart.options.chart.type),
  37848. keepPoints = !(
  37849. // Indicators, histograms etc recalculate the data. It should be
  37850. // possible to omit this.
  37851. this.hasDerivedData ||
  37852. // New type requires new point classes
  37853. (newType && newType !== this.type) ||
  37854. // New options affecting how the data points are built
  37855. typeof options.pointStart !== 'undefined' ||
  37856. typeof options.pointInterval !== 'undefined' ||
  37857. // Changes to data grouping requires new points in new group
  37858. series.hasOptionChanged('dataGrouping') ||
  37859. series.hasOptionChanged('pointStart') ||
  37860. series.hasOptionChanged('pointInterval') ||
  37861. series.hasOptionChanged('pointIntervalUnit') ||
  37862. series.hasOptionChanged('keys')),
  37863. initialSeriesProto = seriesTypes[initialType].prototype,
  37864. n,
  37865. groups = [
  37866. 'group',
  37867. 'markerGroup',
  37868. 'dataLabelsGroup',
  37869. 'transformGroup'
  37870. ],
  37871. preserve = [
  37872. 'eventOptions',
  37873. 'navigatorSeries',
  37874. 'baseSeries'
  37875. ],
  37876. // Animation must be enabled when calling update before the initial
  37877. // animation has first run. This happens when calling update
  37878. // directly after chart initialization, or when applying responsive
  37879. // rules (#6912).
  37880. animation = series.finishedAnimating && { animation: false },
  37881. kinds = {};
  37882. if (keepPoints) {
  37883. preserve.push('data', 'isDirtyData', 'points', 'processedXData', 'processedYData', 'xIncrement', 'cropped', '_hasPointMarkers', '_hasPointLabels',
  37884. // Map specific, consider moving it to series-specific preserve-
  37885. // properties (#10617)
  37886. 'mapMap', 'mapData', 'minY', 'maxY', 'minX', 'maxX');
  37887. if (options.visible !== false) {
  37888. preserve.push('area', 'graph');
  37889. }
  37890. series.parallelArrays.forEach(function (key) {
  37891. preserve.push(key + 'Data');
  37892. });
  37893. if (options.data) {
  37894. // setData uses dataSorting options so we need to update them
  37895. // earlier
  37896. if (options.dataSorting) {
  37897. extend(series.options.dataSorting, options.dataSorting);
  37898. }
  37899. this.setData(options.data, false);
  37900. }
  37901. }
  37902. // Do the merge, with some forced options
  37903. options = merge(oldOptions, animation, {
  37904. // When oldOptions.index is null it should't be cleared.
  37905. // Otherwise navigator series will have wrong indexes (#10193).
  37906. index: typeof oldOptions.index === 'undefined' ?
  37907. series.index : oldOptions.index,
  37908. pointStart: pick(
  37909. // when updating from blank (#7933)
  37910. plotOptions && plotOptions.series && plotOptions.series.pointStart, oldOptions.pointStart,
  37911. // when updating after addPoint
  37912. series.xData[0])
  37913. }, (!keepPoints && { data: series.options.data }), options);
  37914. // Merge does not merge arrays, but replaces them. Since points were
  37915. // updated, `series.options.data` has correct merged options, use it:
  37916. if (keepPoints && options.data) {
  37917. options.data = series.options.data;
  37918. }
  37919. // Make sure preserved properties are not destroyed (#3094)
  37920. preserve = groups.concat(preserve);
  37921. preserve.forEach(function (prop) {
  37922. preserve[prop] = series[prop];
  37923. delete series[prop];
  37924. });
  37925. // Destroy the series and delete all properties. Reinsert all
  37926. // methods and properties from the new type prototype (#2270,
  37927. // #3719).
  37928. series.remove(false, null, false, true);
  37929. for (n in initialSeriesProto) { // eslint-disable-line guard-for-in
  37930. series[n] = void 0;
  37931. }
  37932. if (seriesTypes[newType || initialType]) {
  37933. extend(series, seriesTypes[newType || initialType].prototype);
  37934. }
  37935. else {
  37936. error(17, true, chart, { missingModuleFor: (newType || initialType) });
  37937. }
  37938. // Re-register groups (#3094) and other preserved properties
  37939. preserve.forEach(function (prop) {
  37940. series[prop] = preserve[prop];
  37941. });
  37942. series.init(chart, options);
  37943. // Remove particular elements of the points. Check `series.options`
  37944. // because we need to consider the options being set on plotOptions as
  37945. // well.
  37946. if (keepPoints && this.points) {
  37947. seriesOptions = series.options;
  37948. // What kind of elements to destroy
  37949. if (seriesOptions.visible === false) {
  37950. kinds.graphic = 1;
  37951. kinds.dataLabel = 1;
  37952. }
  37953. else if (!series._hasPointLabels) {
  37954. var marker = seriesOptions.marker,
  37955. dataLabels = seriesOptions.dataLabels;
  37956. if (marker && (marker.enabled === false ||
  37957. 'symbol' in marker // #10870
  37958. )) {
  37959. kinds.graphic = 1;
  37960. }
  37961. if (dataLabels &&
  37962. dataLabels.enabled === false) {
  37963. kinds.dataLabel = 1;
  37964. }
  37965. }
  37966. this.points.forEach(function (point) {
  37967. if (point && point.series) {
  37968. point.resolveColor();
  37969. // Destroy elements in order to recreate based on updated
  37970. // series options.
  37971. if (Object.keys(kinds).length) {
  37972. point.destroyElements(kinds);
  37973. }
  37974. if (seriesOptions.showInLegend === false &&
  37975. point.legendItem) {
  37976. chart.legend.destroyItem(point);
  37977. }
  37978. }
  37979. }, this);
  37980. }
  37981. series.initialType = initialType;
  37982. chart.linkSeries(); // Links are lost in series.remove (#3028)
  37983. fireEvent(this, 'afterUpdate');
  37984. if (pick(redraw, true)) {
  37985. chart.redraw(keepPoints ? void 0 : false);
  37986. }
  37987. },
  37988. /**
  37989. * Used from within series.update
  37990. *
  37991. * @private
  37992. * @function Highcharts.Series#setName
  37993. *
  37994. * @param {string} name
  37995. *
  37996. * @return {void}
  37997. */
  37998. setName: function (name) {
  37999. this.name = this.options.name = this.userOptions.name = name;
  38000. this.chart.isDirtyLegend = true;
  38001. },
  38002. /**
  38003. * Check if the option has changed.
  38004. *
  38005. * @private
  38006. * @function Highcharts.Series#hasOptionChanged
  38007. *
  38008. * @param {string} option
  38009. *
  38010. * @return {boolean}
  38011. */
  38012. hasOptionChanged: function (optionName) {
  38013. var chart = this.chart,
  38014. option = this.options[optionName],
  38015. plotOptions = chart.options.plotOptions,
  38016. oldOption = this.userOptions[optionName];
  38017. if (oldOption) {
  38018. return option !== oldOption;
  38019. }
  38020. return option !==
  38021. pick(plotOptions && plotOptions[this.type] && plotOptions[this.type][optionName], plotOptions && plotOptions.series && plotOptions.series[optionName], option);
  38022. }
  38023. });
  38024. // Extend the Axis.prototype for dynamic methods
  38025. extend(Axis.prototype, /** @lends Highcharts.Axis.prototype */ {
  38026. /**
  38027. * Update an axis object with a new set of options. The options are merged
  38028. * with the existing options, so only new or altered options need to be
  38029. * specified.
  38030. *
  38031. * @sample highcharts/members/axis-update/
  38032. * Axis update demo
  38033. *
  38034. * @function Highcharts.Axis#update
  38035. *
  38036. * @param {Highcharts.AxisOptions} options
  38037. * The new options that will be merged in with existing options on
  38038. * the axis.
  38039. *
  38040. * @param {boolean} [redraw=true]
  38041. * Whether to redraw the chart after the axis is altered. If doing
  38042. * more operations on the chart, it is a good idea to set redraw to
  38043. * false and call {@link Chart#redraw} after.
  38044. *
  38045. * @return {void}
  38046. */
  38047. update: function (options, redraw) {
  38048. var chart = this.chart,
  38049. newEvents = ((options && options.events) || {});
  38050. options = merge(this.userOptions, options);
  38051. // Color Axis is not an array,
  38052. // This change is applied in the ColorAxis wrapper
  38053. if (chart.options[this.coll].indexOf) {
  38054. // Don't use this.options.index,
  38055. // StockChart has Axes in navigator too
  38056. chart.options[this.coll][chart.options[this.coll].indexOf(this.userOptions)] = options;
  38057. }
  38058. // Remove old events, if no new exist (#8161)
  38059. objectEach(chart.options[this.coll].events, function (fn, ev) {
  38060. if (typeof newEvents[ev] === 'undefined') {
  38061. newEvents[ev] = void 0;
  38062. }
  38063. });
  38064. this.destroy(true);
  38065. this.init(chart, extend(options, { events: newEvents }));
  38066. chart.isDirtyBox = true;
  38067. if (pick(redraw, true)) {
  38068. chart.redraw();
  38069. }
  38070. },
  38071. /**
  38072. * Remove the axis from the chart.
  38073. *
  38074. * @sample highcharts/members/chart-addaxis/
  38075. * Add and remove axes
  38076. *
  38077. * @function Highcharts.Axis#remove
  38078. *
  38079. * @param {boolean} [redraw=true]
  38080. * Whether to redraw the chart following the remove.
  38081. *
  38082. * @return {void}
  38083. */
  38084. remove: function (redraw) {
  38085. var chart = this.chart,
  38086. key = this.coll, // xAxis or yAxis
  38087. axisSeries = this.series,
  38088. i = axisSeries.length;
  38089. // Remove associated series (#2687)
  38090. while (i--) {
  38091. if (axisSeries[i]) {
  38092. axisSeries[i].remove(false);
  38093. }
  38094. }
  38095. // Remove the axis
  38096. erase(chart.axes, this);
  38097. erase(chart[key], this);
  38098. if (isArray(chart.options[key])) {
  38099. chart.options[key].splice(this.options.index, 1);
  38100. }
  38101. else { // color axis, #6488
  38102. delete chart.options[key];
  38103. }
  38104. chart[key].forEach(function (axis, i) {
  38105. // Re-index, #1706, #8075
  38106. axis.options.index = axis.userOptions.index = i;
  38107. });
  38108. this.destroy();
  38109. chart.isDirtyBox = true;
  38110. if (pick(redraw, true)) {
  38111. chart.redraw();
  38112. }
  38113. },
  38114. /**
  38115. * Update the axis title by options after render time.
  38116. *
  38117. * @sample highcharts/members/axis-settitle/
  38118. * Set a new Y axis title
  38119. *
  38120. * @function Highcharts.Axis#setTitle
  38121. *
  38122. * @param {Highcharts.AxisTitleOptions} titleOptions
  38123. * The additional title options.
  38124. *
  38125. * @param {boolean} [redraw=true]
  38126. * Whether to redraw the chart after setting the title.
  38127. *
  38128. * @return {void}
  38129. */
  38130. setTitle: function (titleOptions, redraw) {
  38131. this.update({ title: titleOptions }, redraw);
  38132. },
  38133. /**
  38134. * Set new axis categories and optionally redraw.
  38135. *
  38136. * @sample highcharts/members/axis-setcategories/
  38137. * Set categories by click on a button
  38138. *
  38139. * @function Highcharts.Axis#setCategories
  38140. *
  38141. * @param {Array<string>} categories
  38142. * The new categories.
  38143. *
  38144. * @param {boolean} [redraw=true]
  38145. * Whether to redraw the chart.
  38146. *
  38147. * @return {void}
  38148. */
  38149. setCategories: function (categories, redraw) {
  38150. this.update({ categories: categories }, redraw);
  38151. }
  38152. });
  38153. });
  38154. _registerModule(_modules, 'Series/AreaSeries.js', [_modules['Core/Series/Series.js'], _modules['Core/Color/Color.js'], _modules['Core/Globals.js'], _modules['Mixins/LegendSymbol.js'], _modules['Core/Utilities.js']], function (BaseSeries, Color, H, LegendSymbolMixin, U) {
  38155. /* *
  38156. *
  38157. * (c) 2010-2020 Torstein Honsi
  38158. *
  38159. * License: www.highcharts.com/license
  38160. *
  38161. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  38162. *
  38163. * */
  38164. var color = Color.parse;
  38165. var objectEach = U.objectEach,
  38166. pick = U.pick;
  38167. var Series = H.Series;
  38168. /**
  38169. * Area series type.
  38170. *
  38171. * @private
  38172. * @class
  38173. * @name Highcharts.seriesTypes.area
  38174. *
  38175. * @augments Highcharts.Series
  38176. */
  38177. BaseSeries.seriesType('area', 'line',
  38178. /**
  38179. * The area series type.
  38180. *
  38181. * @sample {highcharts} highcharts/demo/area-basic/
  38182. * Area chart
  38183. * @sample {highstock} stock/demo/area/
  38184. * Area chart
  38185. *
  38186. * @extends plotOptions.line
  38187. * @excluding useOhlcData
  38188. * @product highcharts highstock
  38189. * @optionparent plotOptions.area
  38190. */
  38191. {
  38192. /**
  38193. * @see [fillColor](#plotOptions.area.fillColor)
  38194. * @see [fillOpacity](#plotOptions.area.fillOpacity)
  38195. *
  38196. * @apioption plotOptions.area.color
  38197. */
  38198. /**
  38199. * Fill color or gradient for the area. When `null`, the series' `color`
  38200. * is used with the series' `fillOpacity`.
  38201. *
  38202. * In styled mode, the fill color can be set with the `.highcharts-area`
  38203. * class name.
  38204. *
  38205. * @see [color](#plotOptions.area.color)
  38206. * @see [fillOpacity](#plotOptions.area.fillOpacity)
  38207. *
  38208. * @sample {highcharts} highcharts/plotoptions/area-fillcolor-default/
  38209. * Null by default
  38210. * @sample {highcharts} highcharts/plotoptions/area-fillcolor-gradient/
  38211. * Gradient
  38212. *
  38213. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  38214. * @product highcharts highstock
  38215. * @apioption plotOptions.area.fillColor
  38216. */
  38217. /**
  38218. * Fill opacity for the area. When you set an explicit `fillColor`,
  38219. * the `fillOpacity` is not applied. Instead, you should define the
  38220. * opacity in the `fillColor` with an rgba color definition. The
  38221. * `fillOpacity` setting, also the default setting, overrides the alpha
  38222. * component of the `color` setting.
  38223. *
  38224. * In styled mode, the fill opacity can be set with the
  38225. * `.highcharts-area` class name.
  38226. *
  38227. * @see [color](#plotOptions.area.color)
  38228. * @see [fillColor](#plotOptions.area.fillColor)
  38229. *
  38230. * @sample {highcharts} highcharts/plotoptions/area-fillopacity/
  38231. * Automatic fill color and fill opacity of 0.1
  38232. *
  38233. * @type {number}
  38234. * @default {highcharts} 0.75
  38235. * @default {highstock} 0.75
  38236. * @product highcharts highstock
  38237. * @apioption plotOptions.area.fillOpacity
  38238. */
  38239. /**
  38240. * A separate color for the graph line. By default the line takes the
  38241. * `color` of the series, but the lineColor setting allows setting a
  38242. * separate color for the line without altering the `fillColor`.
  38243. *
  38244. * In styled mode, the line stroke can be set with the
  38245. * `.highcharts-graph` class name.
  38246. *
  38247. * @sample {highcharts} highcharts/plotoptions/area-linecolor/
  38248. * Dark gray line
  38249. *
  38250. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  38251. * @product highcharts highstock
  38252. * @apioption plotOptions.area.lineColor
  38253. */
  38254. /**
  38255. * A separate color for the negative part of the area.
  38256. *
  38257. * In styled mode, a negative color is set with the
  38258. * `.highcharts-negative` class name.
  38259. *
  38260. * @see [negativeColor](#plotOptions.area.negativeColor)
  38261. *
  38262. * @sample {highcharts} highcharts/css/series-negative-color/
  38263. * Negative color in styled mode
  38264. *
  38265. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  38266. * @since 3.0
  38267. * @product highcharts
  38268. * @apioption plotOptions.area.negativeFillColor
  38269. */
  38270. /**
  38271. * Whether the whole area or just the line should respond to mouseover
  38272. * tooltips and other mouse or touch events.
  38273. *
  38274. * @sample {highcharts|highstock} highcharts/plotoptions/area-trackbyarea/
  38275. * Display the tooltip when the area is hovered
  38276. *
  38277. * @type {boolean}
  38278. * @default false
  38279. * @since 1.1.6
  38280. * @product highcharts highstock
  38281. * @apioption plotOptions.area.trackByArea
  38282. */
  38283. /**
  38284. * The Y axis value to serve as the base for the area, for
  38285. * distinguishing between values above and below a threshold. The area
  38286. * between the graph and the threshold is filled.
  38287. *
  38288. * * If a number is given, the Y axis will scale to the threshold.
  38289. * * If `null`, the scaling behaves like a line series with fill between
  38290. * the graph and the Y axis minimum.
  38291. * * If `Infinity` or `-Infinity`, the area between the graph and the
  38292. * corresponding Y axis extreme is filled (since v6.1.0).
  38293. *
  38294. * @sample {highcharts} highcharts/plotoptions/area-threshold/
  38295. * A threshold of 100
  38296. * @sample {highcharts} highcharts/plotoptions/area-threshold-infinity/
  38297. * A threshold of Infinity
  38298. *
  38299. * @type {number|null}
  38300. * @since 2.0
  38301. * @product highcharts highstock
  38302. */
  38303. threshold: 0
  38304. },
  38305. /* eslint-disable valid-jsdoc */
  38306. /**
  38307. * @lends seriesTypes.area.prototype
  38308. */
  38309. {
  38310. singleStacks: false,
  38311. /**
  38312. * Return an array of stacked points, where null and missing points are
  38313. * replaced by dummy points in order for gaps to be drawn correctly in
  38314. * stacks.
  38315. * @private
  38316. */
  38317. getStackPoints: function (points) {
  38318. var series = this,
  38319. segment = [],
  38320. keys = [],
  38321. xAxis = this.xAxis,
  38322. yAxis = this.yAxis,
  38323. stack = yAxis.stacking.stacks[this.stackKey],
  38324. pointMap = {},
  38325. seriesIndex = series.index,
  38326. yAxisSeries = yAxis.series,
  38327. seriesLength = yAxisSeries.length,
  38328. visibleSeries,
  38329. upOrDown = pick(yAxis.options.reversedStacks,
  38330. true) ? 1 : -1,
  38331. i;
  38332. points = points || this.points;
  38333. if (this.options.stacking) {
  38334. for (i = 0; i < points.length; i++) {
  38335. // Reset after point update (#7326)
  38336. points[i].leftNull = points[i].rightNull = void 0;
  38337. // Create a map where we can quickly look up the points by
  38338. // their X values.
  38339. pointMap[points[i].x] = points[i];
  38340. }
  38341. // Sort the keys (#1651)
  38342. objectEach(stack, function (stackX, x) {
  38343. // nulled after switching between
  38344. // grouping and not (#1651, #2336)
  38345. if (stackX.total !== null) {
  38346. keys.push(x);
  38347. }
  38348. });
  38349. keys.sort(function (a, b) {
  38350. return a - b;
  38351. });
  38352. visibleSeries = yAxisSeries.map(function (s) {
  38353. return s.visible;
  38354. });
  38355. keys.forEach(function (x, idx) {
  38356. var y = 0,
  38357. stackPoint,
  38358. stackedValues;
  38359. if (pointMap[x] && !pointMap[x].isNull) {
  38360. segment.push(pointMap[x]);
  38361. // Find left and right cliff. -1 goes left, 1 goes
  38362. // right.
  38363. [-1, 1].forEach(function (direction) {
  38364. var nullName = direction === 1 ?
  38365. 'rightNull' :
  38366. 'leftNull',
  38367. cliffName = direction === 1 ?
  38368. 'rightCliff' :
  38369. 'leftCliff',
  38370. cliff = 0,
  38371. otherStack = stack[keys[idx + direction]];
  38372. // If there is a stack next to this one,
  38373. // to the left or to the right...
  38374. if (otherStack) {
  38375. i = seriesIndex;
  38376. // Can go either up or down,
  38377. // depending on reversedStacks
  38378. while (i >= 0 && i < seriesLength) {
  38379. stackPoint = otherStack.points[i];
  38380. if (!stackPoint) {
  38381. // If the next point in this series
  38382. // is missing, mark the point
  38383. // with point.leftNull or
  38384. // point.rightNull = true.
  38385. if (i === seriesIndex) {
  38386. pointMap[x][nullName] =
  38387. true;
  38388. // If there are missing points in
  38389. // the next stack in any of the
  38390. // series below this one, we need
  38391. // to substract the missing values
  38392. // and add a hiatus to the left or
  38393. // right.
  38394. }
  38395. else if (visibleSeries[i]) {
  38396. stackedValues =
  38397. stack[x].points[i];
  38398. if (stackedValues) {
  38399. cliff -=
  38400. stackedValues[1] -
  38401. stackedValues[0];
  38402. }
  38403. }
  38404. }
  38405. // When reversedStacks is true, loop up,
  38406. // else loop down
  38407. i += upOrDown;
  38408. }
  38409. }
  38410. pointMap[x][cliffName] = cliff;
  38411. });
  38412. // There is no point for this X value in this series, so we
  38413. // insert a dummy point in order for the areas to be drawn
  38414. // correctly.
  38415. }
  38416. else {
  38417. // Loop down the stack to find the series below this
  38418. // one that has a value (#1991)
  38419. i = seriesIndex;
  38420. while (i >= 0 && i < seriesLength) {
  38421. stackPoint = stack[x].points[i];
  38422. if (stackPoint) {
  38423. y = stackPoint[1];
  38424. break;
  38425. }
  38426. // When reversedStacks is true, loop up, else loop
  38427. // down
  38428. i += upOrDown;
  38429. }
  38430. y = yAxis.translate(// #6272
  38431. y, 0, 1, 0, 1);
  38432. segment.push({
  38433. isNull: true,
  38434. plotX: xAxis.translate(// #6272
  38435. x, 0, 0, 0, 1),
  38436. x: x,
  38437. plotY: y,
  38438. yBottom: y
  38439. });
  38440. }
  38441. });
  38442. }
  38443. return segment;
  38444. },
  38445. /**
  38446. * @private
  38447. */
  38448. getGraphPath: function (points) {
  38449. 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
  38450. yAxis.getThreshold(options.threshold)), isNull, yBottom, connectNulls = pick(// #10574
  38451. options.connectNulls, stacking === 'percent'),
  38452. // To display null points in underlying stacked series, this
  38453. // series graph must be broken, and the area also fall down to
  38454. // fill the gap left by the null point. #2069
  38455. addDummyPoints = function (i, otherI, side) {
  38456. var point = points[i], stackedValues = stacking &&
  38457. stacks[point.x].points[seriesIndex], nullVal = point[side + 'Null'] || 0, cliffVal = point[side + 'Cliff'] || 0, top, bottom, isNull = true;
  38458. if (cliffVal || nullVal) {
  38459. top = (nullVal ?
  38460. stackedValues[0] :
  38461. stackedValues[1]) + cliffVal;
  38462. bottom = stackedValues[0] + cliffVal;
  38463. isNull = !!nullVal;
  38464. }
  38465. else if (!stacking &&
  38466. points[otherI] &&
  38467. points[otherI].isNull) {
  38468. top = bottom = threshold;
  38469. }
  38470. // Add to the top and bottom line of the area
  38471. if (typeof top !== 'undefined') {
  38472. graphPoints.push({
  38473. plotX: plotX,
  38474. plotY: top === null ?
  38475. translatedThreshold :
  38476. yAxis.getThreshold(top),
  38477. isNull: isNull,
  38478. isCliff: true
  38479. });
  38480. bottomPoints.push({
  38481. plotX: plotX,
  38482. plotY: bottom === null ?
  38483. translatedThreshold :
  38484. yAxis.getThreshold(bottom),
  38485. doCurve: false // #1041, gaps in areaspline areas
  38486. });
  38487. }
  38488. };
  38489. // Find what points to use
  38490. points = points || this.points;
  38491. // Fill in missing points
  38492. if (stacking) {
  38493. points = this.getStackPoints(points);
  38494. }
  38495. for (i = 0; i < points.length; i++) {
  38496. // Reset after series.update of stacking property (#12033)
  38497. if (!stacking) {
  38498. points[i].leftCliff = points[i].rightCliff =
  38499. points[i].leftNull = points[i].rightNull = void 0;
  38500. }
  38501. isNull = points[i].isNull;
  38502. plotX = pick(points[i].rectPlotX, points[i].plotX);
  38503. yBottom = stacking ? points[i].yBottom : translatedThreshold;
  38504. if (!isNull || connectNulls) {
  38505. if (!connectNulls) {
  38506. addDummyPoints(i, i - 1, 'left');
  38507. }
  38508. // Skip null point when stacking is false and connectNulls
  38509. // true
  38510. if (!(isNull && !stacking && connectNulls)) {
  38511. graphPoints.push(points[i]);
  38512. bottomPoints.push({
  38513. x: i,
  38514. plotX: plotX,
  38515. plotY: yBottom
  38516. });
  38517. }
  38518. if (!connectNulls) {
  38519. addDummyPoints(i, i + 1, 'right');
  38520. }
  38521. }
  38522. }
  38523. topPath = getGraphPath.call(this, graphPoints, true, true);
  38524. bottomPoints.reversed = true;
  38525. bottomPath = getGraphPath.call(this, bottomPoints, true, true);
  38526. var firstBottomPoint = bottomPath[0];
  38527. if (firstBottomPoint && firstBottomPoint[0] === 'M') {
  38528. bottomPath[0] = ['L', firstBottomPoint[1], firstBottomPoint[2]];
  38529. }
  38530. areaPath = topPath.concat(bottomPath);
  38531. // TODO: don't set leftCliff and rightCliff when connectNulls?
  38532. graphPath = getGraphPath
  38533. .call(this, graphPoints, false, connectNulls);
  38534. areaPath.xMap = topPath.xMap;
  38535. this.areaPath = areaPath;
  38536. return graphPath;
  38537. },
  38538. /**
  38539. * Draw the graph and the underlying area. This method calls the Series
  38540. * base function and adds the area. The areaPath is calculated in the
  38541. * getSegmentPath method called from Series.prototype.drawGraph.
  38542. * @private
  38543. */
  38544. drawGraph: function () {
  38545. // Define or reset areaPath
  38546. this.areaPath = [];
  38547. // Call the base method
  38548. Series.prototype.drawGraph.apply(this);
  38549. // Define local variables
  38550. var series = this,
  38551. areaPath = this.areaPath,
  38552. options = this.options,
  38553. zones = this.zones,
  38554. props = [[
  38555. 'area',
  38556. 'highcharts-area',
  38557. this.color,
  38558. options.fillColor
  38559. ]]; // area name, main color, fill color
  38560. zones.forEach(function (zone,
  38561. i) {
  38562. props.push([
  38563. 'zone-area-' + i,
  38564. 'highcharts-area highcharts-zone-area-' + i + ' ' +
  38565. zone.className,
  38566. zone.color || series.color,
  38567. zone.fillColor || options.fillColor
  38568. ]);
  38569. });
  38570. props.forEach(function (prop) {
  38571. var areaKey = prop[0],
  38572. area = series[areaKey],
  38573. verb = area ? 'animate' : 'attr',
  38574. attribs = {};
  38575. // Create or update the area
  38576. if (area) { // update
  38577. area.endX = series.preventGraphAnimation ?
  38578. null :
  38579. areaPath.xMap;
  38580. area.animate({ d: areaPath });
  38581. }
  38582. else { // create
  38583. attribs.zIndex = 0; // #1069
  38584. area = series[areaKey] = series.chart.renderer
  38585. .path(areaPath)
  38586. .addClass(prop[1])
  38587. .add(series.group);
  38588. area.isArea = true;
  38589. }
  38590. if (!series.chart.styledMode) {
  38591. attribs.fill = pick(prop[3], color(prop[2])
  38592. .setOpacity(pick(options.fillOpacity, 0.75))
  38593. .get());
  38594. }
  38595. area[verb](attribs);
  38596. area.startX = areaPath.xMap;
  38597. area.shiftUnit = options.step ? 2 : 1;
  38598. });
  38599. },
  38600. drawLegendSymbol: LegendSymbolMixin.drawRectangle
  38601. });
  38602. /* eslint-enable valid-jsdoc */
  38603. /**
  38604. * A `area` series. If the [type](#series.area.type) option is not
  38605. * specified, it is inherited from [chart.type](#chart.type).
  38606. *
  38607. * @extends series,plotOptions.area
  38608. * @excluding dataParser, dataURL, useOhlcData
  38609. * @product highcharts highstock
  38610. * @apioption series.area
  38611. */
  38612. /**
  38613. * @see [fillColor](#series.area.fillColor)
  38614. * @see [fillOpacity](#series.area.fillOpacity)
  38615. *
  38616. * @apioption series.area.color
  38617. */
  38618. /**
  38619. * An array of data points for the series. For the `area` series type,
  38620. * points can be given in the following ways:
  38621. *
  38622. * 1. An array of numerical values. In this case, the numerical values will be
  38623. * interpreted as `y` options. The `x` values will be automatically
  38624. * calculated, either starting at 0 and incremented by 1, or from
  38625. * `pointStart` * and `pointInterval` given in the series options. If the
  38626. * axis has categories, these will be used. Example:
  38627. * ```js
  38628. * data: [0, 5, 3, 5]
  38629. * ```
  38630. *
  38631. * 2. An array of arrays with 2 values. In this case, the values correspond to
  38632. * `x,y`. If the first value is a string, it is applied as the name of the
  38633. * point, and the `x` value is inferred.
  38634. * ```js
  38635. * data: [
  38636. * [0, 9],
  38637. * [1, 7],
  38638. * [2, 6]
  38639. * ]
  38640. * ```
  38641. *
  38642. * 3. An array of objects with named values. The following snippet shows only a
  38643. * few settings, see the complete options set below. If the total number of
  38644. * data points exceeds the series'
  38645. * [turboThreshold](#series.area.turboThreshold), this option is not
  38646. * available.
  38647. * ```js
  38648. * data: [{
  38649. * x: 1,
  38650. * y: 9,
  38651. * name: "Point2",
  38652. * color: "#00FF00"
  38653. * }, {
  38654. * x: 1,
  38655. * y: 6,
  38656. * name: "Point1",
  38657. * color: "#FF00FF"
  38658. * }]
  38659. * ```
  38660. *
  38661. * @sample {highcharts} highcharts/chart/reflow-true/
  38662. * Numerical values
  38663. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  38664. * Arrays of numeric x and y
  38665. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  38666. * Arrays of datetime x and y
  38667. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  38668. * Arrays of point.name and y
  38669. * @sample {highcharts} highcharts/series/data-array-of-objects/
  38670. * Config objects
  38671. *
  38672. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  38673. * @extends series.line.data
  38674. * @product highcharts highstock
  38675. * @apioption series.area.data
  38676. */
  38677. /**
  38678. * @see [color](#series.area.color)
  38679. * @see [fillOpacity](#series.area.fillOpacity)
  38680. *
  38681. * @apioption series.area.fillColor
  38682. */
  38683. /**
  38684. * @see [color](#series.area.color)
  38685. * @see [fillColor](#series.area.fillColor)
  38686. *
  38687. * @default {highcharts} 0.75
  38688. * @default {highstock} 0.75
  38689. * @apioption series.area.fillOpacity
  38690. */
  38691. ''; // adds doclets above to transpilat
  38692. });
  38693. _registerModule(_modules, 'Series/SplineSeries.js', [_modules['Core/Series/Series.js'], _modules['Core/Utilities.js']], function (BaseSeries, U) {
  38694. /* *
  38695. *
  38696. * (c) 2010-2020 Torstein Honsi
  38697. *
  38698. * License: www.highcharts.com/license
  38699. *
  38700. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  38701. *
  38702. * */
  38703. var pick = U.pick;
  38704. /**
  38705. * Spline series type.
  38706. *
  38707. * @private
  38708. * @class
  38709. * @name Highcharts.seriesTypes.spline
  38710. *
  38711. * @augments Highcarts.Series
  38712. */
  38713. BaseSeries.seriesType('spline', 'line',
  38714. /**
  38715. * A spline series is a special type of line series, where the segments
  38716. * between the data points are smoothed.
  38717. *
  38718. * @sample {highcharts} highcharts/demo/spline-irregular-time/
  38719. * Spline chart
  38720. * @sample {highstock} stock/demo/spline/
  38721. * Spline chart
  38722. *
  38723. * @extends plotOptions.series
  38724. * @excluding step, boostThreshold, boostBlending
  38725. * @product highcharts highstock
  38726. * @optionparent plotOptions.spline
  38727. */
  38728. {},
  38729. /**
  38730. * @lends seriesTypes.spline.prototype
  38731. */
  38732. {
  38733. /* eslint-disable valid-jsdoc */
  38734. /**
  38735. * Get the spline segment from a given point's previous neighbour to the
  38736. * given point.
  38737. *
  38738. * @private
  38739. * @function Highcharts.seriesTypes.spline#getPointSpline
  38740. *
  38741. * @param {Array<Highcharts.Point>}
  38742. *
  38743. * @param {Highcharts.Point} point
  38744. *
  38745. * @param {number} i
  38746. *
  38747. * @return {Highcharts.SVGPathArray}
  38748. */
  38749. getPointSpline: function (points, point, i) {
  38750. var
  38751. // 1 means control points midway between points, 2 means 1/3
  38752. // from the point, 3 is 1/4 etc
  38753. smoothing = 1.5,
  38754. denom = smoothing + 1,
  38755. plotX = point.plotX || 0,
  38756. plotY = point.plotY || 0,
  38757. lastPoint = points[i - 1],
  38758. nextPoint = points[i + 1],
  38759. leftContX,
  38760. leftContY,
  38761. rightContX,
  38762. rightContY,
  38763. ret;
  38764. /**
  38765. * @private
  38766. */
  38767. function doCurve(otherPoint) {
  38768. return otherPoint &&
  38769. !otherPoint.isNull &&
  38770. otherPoint.doCurve !== false &&
  38771. // #6387, area splines next to null:
  38772. !point.isCliff;
  38773. }
  38774. // Find control points
  38775. if (doCurve(lastPoint) && doCurve(nextPoint)) {
  38776. var lastX = lastPoint.plotX || 0,
  38777. lastY = lastPoint.plotY || 0,
  38778. nextX = nextPoint.plotX || 0,
  38779. nextY = nextPoint.plotY || 0,
  38780. correction = 0;
  38781. leftContX = (smoothing * plotX + lastX) / denom;
  38782. leftContY = (smoothing * plotY + lastY) / denom;
  38783. rightContX = (smoothing * plotX + nextX) / denom;
  38784. rightContY = (smoothing * plotY + nextY) / denom;
  38785. // Have the two control points make a straight line through main
  38786. // point
  38787. if (rightContX !== leftContX) { // #5016, division by zero
  38788. correction = (((rightContY - leftContY) *
  38789. (rightContX - plotX)) /
  38790. (rightContX - leftContX) + plotY - rightContY);
  38791. }
  38792. leftContY += correction;
  38793. rightContY += correction;
  38794. // to prevent false extremes, check that control points are
  38795. // between neighbouring points' y values
  38796. if (leftContY > lastY && leftContY > plotY) {
  38797. leftContY = Math.max(lastY, plotY);
  38798. // mirror of left control point
  38799. rightContY = 2 * plotY - leftContY;
  38800. }
  38801. else if (leftContY < lastY && leftContY < plotY) {
  38802. leftContY = Math.min(lastY, plotY);
  38803. rightContY = 2 * plotY - leftContY;
  38804. }
  38805. if (rightContY > nextY && rightContY > plotY) {
  38806. rightContY = Math.max(nextY, plotY);
  38807. leftContY = 2 * plotY - rightContY;
  38808. }
  38809. else if (rightContY < nextY && rightContY < plotY) {
  38810. rightContY = Math.min(nextY, plotY);
  38811. leftContY = 2 * plotY - rightContY;
  38812. }
  38813. // record for drawing in next point
  38814. point.rightContX = rightContX;
  38815. point.rightContY = rightContY;
  38816. }
  38817. // Visualize control points for debugging
  38818. /*
  38819. if (leftContX) {
  38820. this.chart.renderer.circle(
  38821. leftContX + this.chart.plotLeft,
  38822. leftContY + this.chart.plotTop,
  38823. 2
  38824. )
  38825. .attr({
  38826. stroke: 'red',
  38827. 'stroke-width': 2,
  38828. fill: 'none',
  38829. zIndex: 9
  38830. })
  38831. .add();
  38832. this.chart.renderer.path(['M', leftContX + this.chart.plotLeft,
  38833. leftContY + this.chart.plotTop,
  38834. 'L', plotX + this.chart.plotLeft, plotY + this.chart.plotTop])
  38835. .attr({
  38836. stroke: 'red',
  38837. 'stroke-width': 2,
  38838. zIndex: 9
  38839. })
  38840. .add();
  38841. }
  38842. if (rightContX) {
  38843. this.chart.renderer.circle(
  38844. rightContX + this.chart.plotLeft,
  38845. rightContY + this.chart.plotTop,
  38846. 2
  38847. )
  38848. .attr({
  38849. stroke: 'green',
  38850. 'stroke-width': 2,
  38851. fill: 'none',
  38852. zIndex: 9
  38853. })
  38854. .add();
  38855. this.chart.renderer.path(['M', rightContX + this.chart.plotLeft,
  38856. rightContY + this.chart.plotTop,
  38857. 'L', plotX + this.chart.plotLeft, plotY + this.chart.plotTop])
  38858. .attr({
  38859. stroke: 'green',
  38860. 'stroke-width': 2,
  38861. zIndex: 9
  38862. })
  38863. .add();
  38864. }
  38865. // */
  38866. ret = [
  38867. 'C',
  38868. pick(lastPoint.rightContX, lastPoint.plotX, 0),
  38869. pick(lastPoint.rightContY, lastPoint.plotY, 0),
  38870. pick(leftContX, plotX, 0),
  38871. pick(leftContY, plotY, 0),
  38872. plotX,
  38873. plotY
  38874. ];
  38875. // reset for updating series later
  38876. lastPoint.rightContX = lastPoint.rightContY = void 0;
  38877. return ret;
  38878. }
  38879. /* eslint-enable valid-jsdoc */
  38880. });
  38881. /**
  38882. * A `spline` series. If the [type](#series.spline.type) option is
  38883. * not specified, it is inherited from [chart.type](#chart.type).
  38884. *
  38885. * @extends series,plotOptions.spline
  38886. * @excluding dataParser, dataURL, step, boostThreshold, boostBlending
  38887. * @product highcharts highstock
  38888. * @apioption series.spline
  38889. */
  38890. /**
  38891. * An array of data points for the series. For the `spline` series type,
  38892. * points can be given in the following ways:
  38893. *
  38894. * 1. An array of numerical values. In this case, the numerical values will be
  38895. * interpreted as `y` options. The `x` values will be automatically
  38896. * calculated, either starting at 0 and incremented by 1, or from
  38897. * `pointStart` and `pointInterval` given in the series options. If the axis
  38898. * has categories, these will be used. Example:
  38899. * ```js
  38900. * data: [0, 5, 3, 5]
  38901. * ```
  38902. *
  38903. * 2. An array of arrays with 2 values. In this case, the values correspond to
  38904. * `x,y`. If the first value is a string, it is applied as the name of the
  38905. * point, and the `x` value is inferred.
  38906. * ```js
  38907. * data: [
  38908. * [0, 9],
  38909. * [1, 2],
  38910. * [2, 8]
  38911. * ]
  38912. * ```
  38913. *
  38914. * 3. An array of objects with named values. The following snippet shows only a
  38915. * few settings, see the complete options set below. If the total number of
  38916. * data points exceeds the series'
  38917. * [turboThreshold](#series.spline.turboThreshold),
  38918. * this option is not available.
  38919. * ```js
  38920. * data: [{
  38921. * x: 1,
  38922. * y: 9,
  38923. * name: "Point2",
  38924. * color: "#00FF00"
  38925. * }, {
  38926. * x: 1,
  38927. * y: 0,
  38928. * name: "Point1",
  38929. * color: "#FF00FF"
  38930. * }]
  38931. * ```
  38932. *
  38933. * @sample {highcharts} highcharts/chart/reflow-true/
  38934. * Numerical values
  38935. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  38936. * Arrays of numeric x and y
  38937. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  38938. * Arrays of datetime x and y
  38939. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  38940. * Arrays of point.name and y
  38941. * @sample {highcharts} highcharts/series/data-array-of-objects/
  38942. * Config objects
  38943. *
  38944. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  38945. * @extends series.line.data
  38946. * @product highcharts highstock
  38947. * @apioption series.spline.data
  38948. */
  38949. ''; // adds doclets above intro transpilat
  38950. });
  38951. _registerModule(_modules, 'Series/AreaSplineSeries.js', [_modules['Core/Series/Series.js'], _modules['Mixins/LegendSymbol.js'], _modules['Core/Options.js']], function (BaseSeries, LegendSymbolMixin, O) {
  38952. /* *
  38953. *
  38954. * (c) 2010-2020 Torstein Honsi
  38955. *
  38956. * License: www.highcharts.com/license
  38957. *
  38958. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  38959. *
  38960. * */
  38961. var defaultOptions = O.defaultOptions;
  38962. var areaProto = BaseSeries.seriesTypes.area.prototype;
  38963. /**
  38964. * AreaSpline series type.
  38965. *
  38966. * @private
  38967. * @class
  38968. * @name Highcharts.seriesTypes.areaspline
  38969. *
  38970. * @augments Highcharts.Series
  38971. */
  38972. BaseSeries.seriesType('areaspline', 'spline',
  38973. /**
  38974. * The area spline series is an area series where the graph between the
  38975. * points is smoothed into a spline.
  38976. *
  38977. * @sample {highcharts} highcharts/demo/areaspline/
  38978. * Area spline chart
  38979. * @sample {highstock} stock/demo/areaspline/
  38980. * Area spline chart
  38981. *
  38982. * @extends plotOptions.area
  38983. * @excluding step, boostThreshold, boostBlending
  38984. * @product highcharts highstock
  38985. * @apioption plotOptions.areaspline
  38986. */
  38987. /**
  38988. * @see [fillColor](#plotOptions.areaspline.fillColor)
  38989. * @see [fillOpacity](#plotOptions.areaspline.fillOpacity)
  38990. *
  38991. * @apioption plotOptions.areaspline.color
  38992. */
  38993. /**
  38994. * @see [color](#plotOptions.areaspline.color)
  38995. * @see [fillOpacity](#plotOptions.areaspline.fillOpacity)
  38996. *
  38997. * @apioption plotOptions.areaspline.fillColor
  38998. */
  38999. /**
  39000. * @see [color](#plotOptions.areaspline.color)
  39001. * @see [fillColor](#plotOptions.areaspline.fillColor)
  39002. *
  39003. * @default {highcharts} 0.75
  39004. * @default {highstock} 0.75
  39005. * @apioption plotOptions.areaspline.fillOpacity
  39006. */
  39007. defaultOptions.plotOptions.area, {
  39008. getStackPoints: areaProto.getStackPoints,
  39009. getGraphPath: areaProto.getGraphPath,
  39010. drawGraph: areaProto.drawGraph,
  39011. drawLegendSymbol: LegendSymbolMixin.drawRectangle
  39012. });
  39013. /**
  39014. * A `areaspline` series. If the [type](#series.areaspline.type) option
  39015. * is not specified, it is inherited from [chart.type](#chart.type).
  39016. *
  39017. *
  39018. * @extends series,plotOptions.areaspline
  39019. * @excluding dataParser, dataURL, step, boostThreshold, boostBlending
  39020. * @product highcharts highstock
  39021. * @apioption series.areaspline
  39022. */
  39023. /**
  39024. * @see [fillColor](#series.areaspline.fillColor)
  39025. * @see [fillOpacity](#series.areaspline.fillOpacity)
  39026. *
  39027. * @apioption series.areaspline.color
  39028. */
  39029. /**
  39030. * An array of data points for the series. For the `areaspline` series
  39031. * type, points can be given in the following ways:
  39032. *
  39033. * 1. An array of numerical values. In this case, the numerical values will be
  39034. * interpreted as `y` options. The `x` values will be automatically
  39035. * calculated, either starting at 0 and incremented by 1, or from
  39036. * `pointStart` and `pointInterval` given in the series options. If the axis
  39037. * has categories, these will be used. Example:
  39038. * ```js
  39039. * data: [0, 5, 3, 5]
  39040. * ```
  39041. *
  39042. * 2. An array of arrays with 2 values. In this case, the values correspond to
  39043. * `x,y`. If the first value is a string, it is applied as the name of the
  39044. * point, and the `x` value is inferred.
  39045. * ```js
  39046. * data: [
  39047. * [0, 10],
  39048. * [1, 9],
  39049. * [2, 3]
  39050. * ]
  39051. * ```
  39052. *
  39053. * 3. An array of objects with named values. The following snippet shows only a
  39054. * few settings, see the complete options set below. If the total number of
  39055. * data points exceeds the series'
  39056. * [turboThreshold](#series.areaspline.turboThreshold), this option is not
  39057. * available.
  39058. * ```js
  39059. * data: [{
  39060. * x: 1,
  39061. * y: 4,
  39062. * name: "Point2",
  39063. * color: "#00FF00"
  39064. * }, {
  39065. * x: 1,
  39066. * y: 4,
  39067. * name: "Point1",
  39068. * color: "#FF00FF"
  39069. * }]
  39070. * ```
  39071. *
  39072. * @sample {highcharts} highcharts/chart/reflow-true/
  39073. * Numerical values
  39074. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  39075. * Arrays of numeric x and y
  39076. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  39077. * Arrays of datetime x and y
  39078. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  39079. * Arrays of point.name and y
  39080. * @sample {highcharts} highcharts/series/data-array-of-objects/
  39081. * Config objects
  39082. *
  39083. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  39084. * @extends series.line.data
  39085. * @product highcharts highstock
  39086. * @apioption series.areaspline.data
  39087. */
  39088. /**
  39089. * @see [color](#series.areaspline.color)
  39090. * @see [fillOpacity](#series.areaspline.fillOpacity)
  39091. *
  39092. * @apioption series.areaspline.fillColor
  39093. */
  39094. /**
  39095. * @see [color](#series.areaspline.color)
  39096. * @see [fillColor](#series.areaspline.fillColor)
  39097. *
  39098. * @default {highcharts} 0.75
  39099. * @default {highstock} 0.75
  39100. * @apioption series.areaspline.fillOpacity
  39101. */
  39102. ''; // adds doclets above into transpilat
  39103. });
  39104. _registerModule(_modules, 'Series/ColumnSeries.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Series/Series.js'], _modules['Core/Color/Color.js'], _modules['Core/Globals.js'], _modules['Mixins/LegendSymbol.js'], _modules['Series/LineSeries.js'], _modules['Core/Utilities.js']], function (A, BaseSeries, Color, H, LegendSymbolMixin, LineSeries, U) {
  39105. /* *
  39106. *
  39107. * (c) 2010-2020 Torstein Honsi
  39108. *
  39109. * License: www.highcharts.com/license
  39110. *
  39111. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  39112. *
  39113. * */
  39114. var animObject = A.animObject;
  39115. var color = Color.parse;
  39116. var noop = H.noop;
  39117. var clamp = U.clamp,
  39118. defined = U.defined,
  39119. extend = U.extend,
  39120. isArray = U.isArray,
  39121. isNumber = U.isNumber,
  39122. merge = U.merge,
  39123. pick = U.pick,
  39124. objectEach = U.objectEach;
  39125. /**
  39126. * Adjusted width and x offset of the columns for grouping.
  39127. *
  39128. * @private
  39129. * @interface Highcharts.ColumnMetricsObject
  39130. */ /**
  39131. * Width of the columns.
  39132. * @name Highcharts.ColumnMetricsObject#width
  39133. * @type {number}
  39134. */ /**
  39135. * Offset of the columns.
  39136. * @name Highcharts.ColumnMetricsObject#offset
  39137. * @type {number}
  39138. */
  39139. ''; // detach doclets above
  39140. /**
  39141. * The column series type.
  39142. *
  39143. * @private
  39144. * @class
  39145. * @name Highcharts.seriesTypes.column
  39146. *
  39147. * @augments Highcharts.Series
  39148. */
  39149. var ColumnSeries = BaseSeries.seriesType('column', 'line',
  39150. /**
  39151. * Column series display one column per value along an X axis.
  39152. *
  39153. * @sample {highcharts} highcharts/demo/column-basic/
  39154. * Column chart
  39155. * @sample {highstock} stock/demo/column/
  39156. * Column chart
  39157. *
  39158. * @extends plotOptions.line
  39159. * @excluding connectEnds, connectNulls, gapSize, gapUnit, linecap,
  39160. * lineWidth, marker, step, useOhlcData
  39161. * @product highcharts highstock
  39162. * @optionparent plotOptions.column
  39163. */
  39164. {
  39165. /**
  39166. * The corner radius of the border surrounding each column or bar.
  39167. *
  39168. * @sample {highcharts} highcharts/plotoptions/column-borderradius/
  39169. * Rounded columns
  39170. *
  39171. * @product highcharts highstock gantt
  39172. *
  39173. * @private
  39174. */
  39175. borderRadius: 0,
  39176. /**
  39177. * When using automatic point colors pulled from the global
  39178. * [colors](colors) or series-specific
  39179. * [plotOptions.column.colors](series.colors) collections, this option
  39180. * determines whether the chart should receive one color per series or
  39181. * one color per point.
  39182. *
  39183. * In styled mode, the `colors` or `series.colors` arrays are not
  39184. * supported, and instead this option gives the points individual color
  39185. * class names on the form `highcharts-color-{n}`.
  39186. *
  39187. * @see [series colors](#plotOptions.column.colors)
  39188. *
  39189. * @sample {highcharts} highcharts/plotoptions/column-colorbypoint-false/
  39190. * False by default
  39191. * @sample {highcharts} highcharts/plotoptions/column-colorbypoint-true/
  39192. * True
  39193. *
  39194. * @type {boolean}
  39195. * @default false
  39196. * @since 2.0
  39197. * @product highcharts highstock gantt
  39198. * @apioption plotOptions.column.colorByPoint
  39199. */
  39200. /**
  39201. * A series specific or series type specific color set to apply instead
  39202. * of the global [colors](#colors) when [colorByPoint](
  39203. * #plotOptions.column.colorByPoint) is true.
  39204. *
  39205. * @type {Array<Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject>}
  39206. * @since 3.0
  39207. * @product highcharts highstock gantt
  39208. * @apioption plotOptions.column.colors
  39209. */
  39210. /**
  39211. * When `true`, the columns will center in the category, ignoring null
  39212. * or missing points. When `false`, space will be reserved for null or
  39213. * missing points.
  39214. *
  39215. * @sample {highcharts} highcharts/series-column/centerincategory/
  39216. * Center in category
  39217. *
  39218. * @since 8.0.1
  39219. * @product highcharts highstock gantt
  39220. *
  39221. * @private
  39222. */
  39223. centerInCategory: false,
  39224. /**
  39225. * Padding between each value groups, in x axis units.
  39226. *
  39227. * @sample {highcharts} highcharts/plotoptions/column-grouppadding-default/
  39228. * 0.2 by default
  39229. * @sample {highcharts} highcharts/plotoptions/column-grouppadding-none/
  39230. * No group padding - all columns are evenly spaced
  39231. *
  39232. * @product highcharts highstock gantt
  39233. *
  39234. * @private
  39235. */
  39236. groupPadding: 0.2,
  39237. /**
  39238. * Whether to group non-stacked columns or to let them render
  39239. * independent of each other. Non-grouped columns will be laid out
  39240. * individually and overlap each other.
  39241. *
  39242. * @sample {highcharts} highcharts/plotoptions/column-grouping-false/
  39243. * Grouping disabled
  39244. * @sample {highstock} highcharts/plotoptions/column-grouping-false/
  39245. * Grouping disabled
  39246. *
  39247. * @type {boolean}
  39248. * @default true
  39249. * @since 2.3.0
  39250. * @product highcharts highstock gantt
  39251. * @apioption plotOptions.column.grouping
  39252. */
  39253. /**
  39254. * @ignore-option
  39255. * @private
  39256. */
  39257. marker: null,
  39258. /**
  39259. * The maximum allowed pixel width for a column, translated to the
  39260. * height of a bar in a bar chart. This prevents the columns from
  39261. * becoming too wide when there is a small number of points in the
  39262. * chart.
  39263. *
  39264. * @see [pointWidth](#plotOptions.column.pointWidth)
  39265. *
  39266. * @sample {highcharts} highcharts/plotoptions/column-maxpointwidth-20/
  39267. * Limited to 50
  39268. * @sample {highstock} highcharts/plotoptions/column-maxpointwidth-20/
  39269. * Limited to 50
  39270. *
  39271. * @type {number}
  39272. * @since 4.1.8
  39273. * @product highcharts highstock gantt
  39274. * @apioption plotOptions.column.maxPointWidth
  39275. */
  39276. /**
  39277. * Padding between each column or bar, in x axis units.
  39278. *
  39279. * @sample {highcharts} highcharts/plotoptions/column-pointpadding-default/
  39280. * 0.1 by default
  39281. * @sample {highcharts} highcharts/plotoptions/column-pointpadding-025/
  39282. * 0.25
  39283. * @sample {highcharts} highcharts/plotoptions/column-pointpadding-none/
  39284. * 0 for tightly packed columns
  39285. *
  39286. * @product highcharts highstock gantt
  39287. *
  39288. * @private
  39289. */
  39290. pointPadding: 0.1,
  39291. /**
  39292. * A pixel value specifying a fixed width for each column or bar point.
  39293. * When `null`, the width is calculated from the `pointPadding` and
  39294. * `groupPadding`. The width effects the dimension that is not based on
  39295. * the point value. For column series it is the hoizontal length and for
  39296. * bar series it is the vertical length.
  39297. *
  39298. * @see [maxPointWidth](#plotOptions.column.maxPointWidth)
  39299. *
  39300. * @sample {highcharts} highcharts/plotoptions/column-pointwidth-20/
  39301. * 20px wide columns regardless of chart width or the amount of
  39302. * data points
  39303. *
  39304. * @type {number}
  39305. * @since 1.2.5
  39306. * @product highcharts highstock gantt
  39307. * @apioption plotOptions.column.pointWidth
  39308. */
  39309. /**
  39310. * A pixel value specifying a fixed width for the column or bar.
  39311. * Overrides pointWidth on the series.
  39312. *
  39313. * @see [series.pointWidth](#plotOptions.column.pointWidth)
  39314. *
  39315. * @type {number}
  39316. * @default undefined
  39317. * @since 7.0.0
  39318. * @product highcharts highstock gantt
  39319. * @apioption series.column.data.pointWidth
  39320. */
  39321. /**
  39322. * The minimal height for a column or width for a bar. By default,
  39323. * 0 values are not shown. To visualize a 0 (or close to zero) point,
  39324. * set the minimal point length to a pixel value like 3\. In stacked
  39325. * column charts, minPointLength might not be respected for tightly
  39326. * packed values.
  39327. *
  39328. * @sample {highcharts} highcharts/plotoptions/column-minpointlength/
  39329. * Zero base value
  39330. * @sample {highcharts} highcharts/plotoptions/column-minpointlength-pos-and-neg/
  39331. * Positive and negative close to zero values
  39332. *
  39333. * @product highcharts highstock gantt
  39334. *
  39335. * @private
  39336. */
  39337. minPointLength: 0,
  39338. /**
  39339. * When the series contains less points than the crop threshold, all
  39340. * points are drawn, event if the points fall outside the visible plot
  39341. * area at the current zoom. The advantage of drawing all points
  39342. * (including markers and columns), is that animation is performed on
  39343. * updates. On the other hand, when the series contains more points than
  39344. * the crop threshold, the series data is cropped to only contain points
  39345. * that fall within the plot area. The advantage of cropping away
  39346. * invisible points is to increase performance on large series.
  39347. *
  39348. * @product highcharts highstock gantt
  39349. *
  39350. * @private
  39351. */
  39352. cropThreshold: 50,
  39353. /**
  39354. * The X axis range that each point is valid for. This determines the
  39355. * width of the column. On a categorized axis, the range will be 1
  39356. * by default (one category unit). On linear and datetime axes, the
  39357. * range will be computed as the distance between the two closest data
  39358. * points.
  39359. *
  39360. * The default `null` means it is computed automatically, but this
  39361. * option can be used to override the automatic value.
  39362. *
  39363. * This option is set by default to 1 if data sorting is enabled.
  39364. *
  39365. * @sample {highcharts} highcharts/plotoptions/column-pointrange/
  39366. * Set the point range to one day on a data set with one week
  39367. * between the points
  39368. *
  39369. * @type {number|null}
  39370. * @since 2.3
  39371. * @product highcharts highstock gantt
  39372. *
  39373. * @private
  39374. */
  39375. pointRange: null,
  39376. states: {
  39377. /**
  39378. * Options for the hovered point. These settings override the normal
  39379. * state options when a point is moused over or touched.
  39380. *
  39381. * @extends plotOptions.series.states.hover
  39382. * @excluding halo, lineWidth, lineWidthPlus, marker
  39383. * @product highcharts highstock gantt
  39384. */
  39385. hover: {
  39386. /** @ignore-option */
  39387. halo: false,
  39388. /**
  39389. * A specific border color for the hovered point. Defaults to
  39390. * inherit the normal state border color.
  39391. *
  39392. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  39393. * @product highcharts gantt
  39394. * @apioption plotOptions.column.states.hover.borderColor
  39395. */
  39396. /**
  39397. * A specific color for the hovered point.
  39398. *
  39399. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  39400. * @product highcharts gantt
  39401. * @apioption plotOptions.column.states.hover.color
  39402. */
  39403. /**
  39404. * How much to brighten the point on interaction. Requires the
  39405. * main color to be defined in hex or rgb(a) format.
  39406. *
  39407. * In styled mode, the hover brightening is by default replaced
  39408. * with a fill-opacity set in the `.highcharts-point:hover`
  39409. * rule.
  39410. *
  39411. * @sample {highcharts} highcharts/plotoptions/column-states-hover-brightness/
  39412. * Brighten by 0.5
  39413. *
  39414. * @product highcharts highstock gantt
  39415. */
  39416. brightness: 0.1
  39417. },
  39418. /**
  39419. * Options for the selected point. These settings override the
  39420. * normal state options when a point is selected.
  39421. *
  39422. * @extends plotOptions.series.states.select
  39423. * @excluding halo, lineWidth, lineWidthPlus, marker
  39424. * @product highcharts highstock gantt
  39425. */
  39426. select: {
  39427. /**
  39428. * A specific color for the selected point.
  39429. *
  39430. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  39431. * @default #cccccc
  39432. * @product highcharts highstock gantt
  39433. */
  39434. color: '#cccccc',
  39435. /**
  39436. * A specific border color for the selected point.
  39437. *
  39438. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  39439. * @default #000000
  39440. * @product highcharts highstock gantt
  39441. */
  39442. borderColor: '#000000'
  39443. }
  39444. },
  39445. dataLabels: {
  39446. align: void 0,
  39447. verticalAlign: void 0,
  39448. /**
  39449. * The y position offset of the label relative to the point in
  39450. * pixels.
  39451. *
  39452. * @type {number}
  39453. */
  39454. y: void 0
  39455. },
  39456. // false doesn't work well: https://jsfiddle.net/highcharts/hz8fopan/14/
  39457. /**
  39458. * @ignore-option
  39459. * @private
  39460. */
  39461. startFromThreshold: true,
  39462. stickyTracking: false,
  39463. tooltip: {
  39464. distance: 6
  39465. },
  39466. /**
  39467. * The Y axis value to serve as the base for the columns, for
  39468. * distinguishing between values above and below a threshold. If `null`,
  39469. * the columns extend from the padding Y axis minimum.
  39470. *
  39471. * @type {number|null}
  39472. * @since 2.0
  39473. * @product highcharts
  39474. *
  39475. * @private
  39476. */
  39477. threshold: 0,
  39478. /**
  39479. * The width of the border surrounding each column or bar. Defaults to
  39480. * `1` when there is room for a border, but to `0` when the columns are
  39481. * so dense that a border would cover the next column.
  39482. *
  39483. * In styled mode, the stroke width can be set with the
  39484. * `.highcharts-point` rule.
  39485. *
  39486. * @sample {highcharts} highcharts/plotoptions/column-borderwidth/
  39487. * 2px black border
  39488. *
  39489. * @type {number}
  39490. * @default undefined
  39491. * @product highcharts highstock gantt
  39492. * @apioption plotOptions.column.borderWidth
  39493. */
  39494. /**
  39495. * The color of the border surrounding each column or bar.
  39496. *
  39497. * In styled mode, the border stroke can be set with the
  39498. * `.highcharts-point` rule.
  39499. *
  39500. * @sample {highcharts} highcharts/plotoptions/column-bordercolor/
  39501. * Dark gray border
  39502. *
  39503. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  39504. * @default #ffffff
  39505. * @product highcharts highstock gantt
  39506. *
  39507. * @private
  39508. */
  39509. borderColor: '#ffffff'
  39510. },
  39511. /**
  39512. * @lends seriesTypes.column.prototype
  39513. */
  39514. {
  39515. cropShoulder: 0,
  39516. // When tooltip is not shared, this series (and derivatives) requires
  39517. // direct touch/hover. KD-tree does not apply.
  39518. directTouch: true,
  39519. trackerGroups: ['group', 'dataLabelsGroup'],
  39520. // use separate negative stacks, unlike area stacks where a negative
  39521. // point is substracted from previous (#1910)
  39522. negStacks: true,
  39523. /* eslint-disable valid-jsdoc */
  39524. /**
  39525. * Initialize the series. Extends the basic Series.init method by
  39526. * marking other series of the same type as dirty.
  39527. *
  39528. * @private
  39529. * @function Highcharts.seriesTypes.column#init
  39530. * @return {void}
  39531. */
  39532. init: function () {
  39533. LineSeries.prototype.init.apply(this, arguments);
  39534. var series = this,
  39535. chart = series.chart;
  39536. // if the series is added dynamically, force redraw of other
  39537. // series affected by a new column
  39538. if (chart.hasRendered) {
  39539. chart.series.forEach(function (otherSeries) {
  39540. if (otherSeries.type === series.type) {
  39541. otherSeries.isDirty = true;
  39542. }
  39543. });
  39544. }
  39545. },
  39546. /**
  39547. * Return the width and x offset of the columns adjusted for grouping,
  39548. * groupPadding, pointPadding, pointWidth etc.
  39549. *
  39550. * @private
  39551. * @function Highcharts.seriesTypes.column#getColumnMetrics
  39552. * @return {Highcharts.ColumnMetricsObject}
  39553. */
  39554. getColumnMetrics: function () {
  39555. var series = this,
  39556. options = series.options,
  39557. xAxis = series.xAxis,
  39558. yAxis = series.yAxis,
  39559. reversedStacks = xAxis.options.reversedStacks,
  39560. // Keep backward compatibility: reversed xAxis had reversed
  39561. // stacks
  39562. reverseStacks = (xAxis.reversed && !reversedStacks) ||
  39563. (!xAxis.reversed && reversedStacks),
  39564. stackKey,
  39565. stackGroups = {},
  39566. columnCount = 0;
  39567. // Get the total number of column type series. This is called on
  39568. // every series. Consider moving this logic to a chart.orderStacks()
  39569. // function and call it on init, addSeries and removeSeries
  39570. if (options.grouping === false) {
  39571. columnCount = 1;
  39572. }
  39573. else {
  39574. series.chart.series.forEach(function (otherSeries) {
  39575. var otherYAxis = otherSeries.yAxis,
  39576. otherOptions = otherSeries.options,
  39577. columnIndex;
  39578. if (otherSeries.type === series.type &&
  39579. (otherSeries.visible ||
  39580. !series.chart.options.chart
  39581. .ignoreHiddenSeries) &&
  39582. yAxis.len === otherYAxis.len &&
  39583. yAxis.pos === otherYAxis.pos) { // #642, #2086
  39584. if (otherOptions.stacking && otherOptions.stacking !== 'group') {
  39585. stackKey = otherSeries.stackKey;
  39586. if (typeof stackGroups[stackKey] ===
  39587. 'undefined') {
  39588. stackGroups[stackKey] = columnCount++;
  39589. }
  39590. columnIndex = stackGroups[stackKey];
  39591. }
  39592. else if (otherOptions.grouping !== false) { // #1162
  39593. columnIndex = columnCount++;
  39594. }
  39595. otherSeries.columnIndex = columnIndex;
  39596. }
  39597. });
  39598. }
  39599. var categoryWidth = Math.min(Math.abs(xAxis.transA) * ((xAxis.ordinal && xAxis.ordinal.slope) ||
  39600. options.pointRange ||
  39601. xAxis.closestPointRange ||
  39602. xAxis.tickInterval ||
  39603. 1), // #2610
  39604. xAxis.len // #1535
  39605. ),
  39606. groupPadding = categoryWidth * options.groupPadding,
  39607. groupWidth = categoryWidth - 2 * groupPadding,
  39608. pointOffsetWidth = groupWidth / (columnCount || 1),
  39609. pointWidth = Math.min(options.maxPointWidth || xAxis.len,
  39610. pick(options.pointWidth,
  39611. pointOffsetWidth * (1 - 2 * options.pointPadding))),
  39612. pointPadding = (pointOffsetWidth - pointWidth) / 2,
  39613. // #1251, #3737
  39614. colIndex = (series.columnIndex || 0) + (reverseStacks ? 1 : 0),
  39615. pointXOffset = pointPadding +
  39616. (groupPadding +
  39617. colIndex * pointOffsetWidth -
  39618. (categoryWidth / 2)) * (reverseStacks ? -1 : 1);
  39619. // Save it for reading in linked series (Error bars particularly)
  39620. series.columnMetrics = {
  39621. width: pointWidth,
  39622. offset: pointXOffset,
  39623. paddedWidth: pointOffsetWidth,
  39624. columnCount: columnCount
  39625. };
  39626. return series.columnMetrics;
  39627. },
  39628. /**
  39629. * Make the columns crisp. The edges are rounded to the nearest full
  39630. * pixel.
  39631. *
  39632. * @private
  39633. * @function Highcharts.seriesTypes.column#crispCol
  39634. * @param {number} x
  39635. * @param {number} y
  39636. * @param {number} w
  39637. * @param {number} h
  39638. * @return {Highcharts.BBoxObject}
  39639. */
  39640. crispCol: function (x, y, w, h) {
  39641. var chart = this.chart,
  39642. borderWidth = this.borderWidth,
  39643. xCrisp = -(borderWidth % 2 ? 0.5 : 0),
  39644. yCrisp = borderWidth % 2 ? 0.5 : 1,
  39645. right,
  39646. bottom,
  39647. fromTop;
  39648. if (chart.inverted && chart.renderer.isVML) {
  39649. yCrisp += 1;
  39650. }
  39651. // Horizontal. We need to first compute the exact right edge, then
  39652. // round it and compute the width from there.
  39653. if (this.options.crisp) {
  39654. right = Math.round(x + w) + xCrisp;
  39655. x = Math.round(x) + xCrisp;
  39656. w = right - x;
  39657. }
  39658. // Vertical
  39659. bottom = Math.round(y + h) + yCrisp;
  39660. fromTop = Math.abs(y) <= 0.5 && bottom > 0.5; // #4504, #4656
  39661. y = Math.round(y) + yCrisp;
  39662. h = bottom - y;
  39663. // Top edges are exceptions
  39664. if (fromTop && h) { // #5146
  39665. y -= 1;
  39666. h += 1;
  39667. }
  39668. return {
  39669. x: x,
  39670. y: y,
  39671. width: w,
  39672. height: h
  39673. };
  39674. },
  39675. /**
  39676. * Adjust for missing columns, according to the `centerInCategory`
  39677. * option. Missing columns are either single points or stacks where the
  39678. * point or points are either missing or null.
  39679. *
  39680. * @private
  39681. * @function Highcharts.seriesTypes.column#adjustForMissingColumns
  39682. * @param {number} x
  39683. * The x coordinate of the column, left side
  39684. * @param {number} pointWidth
  39685. * The pointWidth, already computed upstream
  39686. * @param {Highcharts.ColumnPoint} point
  39687. * The point instance
  39688. * @param {Highcharts.ColumnMetricsObject} metrics
  39689. * The series-wide column metrics
  39690. * @return {number}
  39691. * The adjusted x position, or the original if not adjusted
  39692. */
  39693. adjustForMissingColumns: function (x, pointWidth, point, metrics) {
  39694. var _this = this;
  39695. var stacking = this.options.stacking;
  39696. if (!point.isNull && metrics.columnCount > 1) {
  39697. var indexInCategory_1 = 0;
  39698. var totalInCategory_1 = 0;
  39699. // Loop over all the stacks on the Y axis. When stacking is
  39700. // enabled, these are real point stacks. When stacking is not
  39701. // enabled, but `centerInCategory` is true, there is one stack
  39702. // handling the grouping of points in each category. This is
  39703. // done in the `setGroupedPoints` function.
  39704. objectEach(this.yAxis.stacking && this.yAxis.stacking.stacks, function (stack) {
  39705. if (typeof point.x === 'number') {
  39706. var stackItem = stack[point.x.toString()];
  39707. if (stackItem) {
  39708. var pointValues = stackItem.points[_this.index],
  39709. total = stackItem.total;
  39710. // If true `stacking` is enabled, count the
  39711. // total number of non-null stacks in the
  39712. // category, and note which index this point is
  39713. // within those stacks.
  39714. if (stacking) {
  39715. if (pointValues) {
  39716. indexInCategory_1 = totalInCategory_1;
  39717. }
  39718. if (stackItem.hasValidPoints) {
  39719. totalInCategory_1++;
  39720. }
  39721. // If `stacking` is not enabled, look for the
  39722. // index and total of the `group` stack.
  39723. }
  39724. else if (isArray(pointValues)) {
  39725. indexInCategory_1 = pointValues[1];
  39726. totalInCategory_1 = total || 0;
  39727. }
  39728. }
  39729. }
  39730. });
  39731. // Compute the adjusted x position
  39732. var boxWidth = (totalInCategory_1 - 1) * metrics.paddedWidth +
  39733. pointWidth;
  39734. x = (point.plotX || 0) + boxWidth / 2 - pointWidth -
  39735. indexInCategory_1 * metrics.paddedWidth;
  39736. }
  39737. return x;
  39738. },
  39739. /**
  39740. * Translate each point to the plot area coordinate system and find
  39741. * shape positions
  39742. *
  39743. * @private
  39744. * @function Highcharts.seriesTypes.column#translate
  39745. */
  39746. translate: function () {
  39747. var series = this,
  39748. chart = series.chart,
  39749. options = series.options,
  39750. dense = series.dense =
  39751. series.closestPointRange * series.xAxis.transA < 2,
  39752. borderWidth = series.borderWidth = pick(options.borderWidth,
  39753. dense ? 0 : 1 // #3635
  39754. ),
  39755. xAxis = series.xAxis,
  39756. yAxis = series.yAxis,
  39757. threshold = options.threshold,
  39758. translatedThreshold = series.translatedThreshold =
  39759. yAxis.getThreshold(threshold),
  39760. minPointLength = pick(options.minPointLength, 5),
  39761. metrics = series.getColumnMetrics(),
  39762. seriesPointWidth = metrics.width,
  39763. // postprocessed for border width
  39764. seriesBarW = series.barW =
  39765. Math.max(seriesPointWidth, 1 + 2 * borderWidth),
  39766. seriesXOffset = series.pointXOffset = metrics.offset,
  39767. dataMin = series.dataMin,
  39768. dataMax = series.dataMax;
  39769. if (chart.inverted) {
  39770. translatedThreshold -= 0.5; // #3355
  39771. }
  39772. // When the pointPadding is 0, we want the columns to be packed
  39773. // tightly, so we allow individual columns to have individual sizes.
  39774. // When pointPadding is greater, we strive for equal-width columns
  39775. // (#2694).
  39776. if (options.pointPadding) {
  39777. seriesBarW = Math.ceil(seriesBarW);
  39778. }
  39779. LineSeries.prototype.translate.apply(series);
  39780. // Record the new values
  39781. series.points.forEach(function (point) {
  39782. var yBottom = pick(point.yBottom,
  39783. translatedThreshold),
  39784. safeDistance = 999 + Math.abs(yBottom),
  39785. pointWidth = seriesPointWidth,
  39786. plotX = point.plotX || 0,
  39787. // Don't draw too far outside plot area (#1303, #2241,
  39788. // #4264)
  39789. plotY = clamp(point.plotY, -safeDistance,
  39790. yAxis.len + safeDistance),
  39791. barX = plotX + seriesXOffset,
  39792. barW = seriesBarW,
  39793. barY = Math.min(plotY,
  39794. yBottom),
  39795. up,
  39796. barH = Math.max(plotY,
  39797. yBottom) - barY;
  39798. // Handle options.minPointLength
  39799. if (minPointLength && Math.abs(barH) < minPointLength) {
  39800. barH = minPointLength;
  39801. up = (!yAxis.reversed && !point.negative) ||
  39802. (yAxis.reversed && point.negative);
  39803. // Reverse zeros if there's no positive value in the series
  39804. // in visible range (#7046)
  39805. if (isNumber(threshold) &&
  39806. isNumber(dataMax) &&
  39807. point.y === threshold &&
  39808. dataMax <= threshold &&
  39809. // and if there's room for it (#7311)
  39810. (yAxis.min || 0) < threshold &&
  39811. // if all points are the same value (i.e zero) not draw
  39812. // as negative points (#10646)
  39813. dataMin !== dataMax) {
  39814. up = !up;
  39815. }
  39816. // If stacked...
  39817. barY = (Math.abs(barY - translatedThreshold) > minPointLength ?
  39818. // ...keep position
  39819. yBottom - minPointLength :
  39820. // #1485, #4051
  39821. translatedThreshold -
  39822. (up ? minPointLength : 0));
  39823. }
  39824. // Handle point.options.pointWidth
  39825. // @todo Handle grouping/stacking too. Calculate offset properly
  39826. if (defined(point.options.pointWidth)) {
  39827. pointWidth = barW =
  39828. Math.ceil(point.options.pointWidth);
  39829. barX -= Math.round((pointWidth - seriesPointWidth) / 2);
  39830. }
  39831. // Adjust for null or missing points
  39832. if (options.centerInCategory) {
  39833. barX = series.adjustForMissingColumns(barX, pointWidth, point, metrics);
  39834. }
  39835. // Cache for access in polar
  39836. point.barX = barX;
  39837. point.pointWidth = pointWidth;
  39838. // Fix the tooltip on center of grouped columns (#1216, #424,
  39839. // #3648)
  39840. point.tooltipPos = chart.inverted ?
  39841. [
  39842. yAxis.len + yAxis.pos - chart.plotLeft - plotY,
  39843. xAxis.len + xAxis.pos - chart.plotTop - (plotX || 0) - seriesXOffset - barW / 2,
  39844. barH
  39845. ] :
  39846. [barX + barW / 2, plotY + yAxis.pos -
  39847. chart.plotTop, barH];
  39848. // Register shape type and arguments to be used in drawPoints
  39849. // Allow shapeType defined on pointClass level
  39850. point.shapeType =
  39851. series.pointClass.prototype.shapeType || 'rect';
  39852. point.shapeArgs = series.crispCol.apply(series, point.isNull ?
  39853. // #3169, drilldown from null must have a position to work
  39854. // from #6585, dataLabel should be placed on xAxis, not
  39855. // floating in the middle of the chart
  39856. [barX, translatedThreshold, barW, 0] :
  39857. [barX, barY, barW, barH]);
  39858. });
  39859. },
  39860. getSymbol: noop,
  39861. /**
  39862. * Use a solid rectangle like the area series types
  39863. *
  39864. * @private
  39865. * @function Highcharts.seriesTypes.column#drawLegendSymbol
  39866. *
  39867. * @param {Highcharts.Legend} legend
  39868. * The legend object
  39869. *
  39870. * @param {Highcharts.Series|Highcharts.Point} item
  39871. * The series (this) or point
  39872. */
  39873. drawLegendSymbol: LegendSymbolMixin.drawRectangle,
  39874. /**
  39875. * Columns have no graph
  39876. *
  39877. * @private
  39878. * @function Highcharts.seriesTypes.column#drawGraph
  39879. */
  39880. drawGraph: function () {
  39881. this.group[this.dense ? 'addClass' : 'removeClass']('highcharts-dense-data');
  39882. },
  39883. /**
  39884. * Get presentational attributes
  39885. *
  39886. * @private
  39887. * @function Highcharts.seriesTypes.column#pointAttribs
  39888. *
  39889. * @param {Highcharts.ColumnPoint} point
  39890. *
  39891. * @param {string} state
  39892. *
  39893. * @return {Highcharts.SVGAttributes}
  39894. */
  39895. pointAttribs: function (point, state) {
  39896. var options = this.options, stateOptions, ret, p2o = this.pointAttrToOptions || {}, strokeOption = p2o.stroke || 'borderColor', strokeWidthOption = p2o['stroke-width'] || 'borderWidth', fill = (point && point.color) || this.color,
  39897. // set to fill when borderColor null:
  39898. stroke = ((point && point[strokeOption]) ||
  39899. options[strokeOption] ||
  39900. this.color ||
  39901. fill), strokeWidth = (point && point[strokeWidthOption]) ||
  39902. options[strokeWidthOption] ||
  39903. this[strokeWidthOption] || 0, dashstyle = (point && point.options.dashStyle) || options.dashStyle, opacity = pick(point && point.opacity, options.opacity, 1), zone, brightness;
  39904. // Handle zone colors
  39905. if (point && this.zones.length) {
  39906. zone = point.getZone();
  39907. // When zones are present, don't use point.color (#4267).
  39908. // Changed order (#6527), added support for colorAxis (#10670)
  39909. fill = (point.options.color ||
  39910. (zone && (zone.color || point.nonZonedColor)) ||
  39911. this.color);
  39912. if (zone) {
  39913. stroke = zone.borderColor || stroke;
  39914. dashstyle = zone.dashStyle || dashstyle;
  39915. strokeWidth = zone.borderWidth || strokeWidth;
  39916. }
  39917. }
  39918. // Select or hover states
  39919. if (state && point) {
  39920. stateOptions = merge(options.states[state],
  39921. // #6401
  39922. point.options.states &&
  39923. point.options.states[state] ||
  39924. {});
  39925. brightness = stateOptions.brightness;
  39926. fill =
  39927. stateOptions.color || (typeof brightness !== 'undefined' &&
  39928. color(fill)
  39929. .brighten(stateOptions.brightness)
  39930. .get()) || fill;
  39931. stroke = stateOptions[strokeOption] || stroke;
  39932. strokeWidth =
  39933. stateOptions[strokeWidthOption] || strokeWidth;
  39934. dashstyle = stateOptions.dashStyle || dashstyle;
  39935. opacity = pick(stateOptions.opacity, opacity);
  39936. }
  39937. ret = {
  39938. fill: fill,
  39939. stroke: stroke,
  39940. 'stroke-width': strokeWidth,
  39941. opacity: opacity
  39942. };
  39943. if (dashstyle) {
  39944. ret.dashstyle = dashstyle;
  39945. }
  39946. return ret;
  39947. },
  39948. /**
  39949. * Draw the columns. For bars, the series.group is rotated, so the same
  39950. * coordinates apply for columns and bars. This method is inherited by
  39951. * scatter series.
  39952. *
  39953. * @private
  39954. * @function Highcharts.seriesTypes.column#drawPoints
  39955. */
  39956. drawPoints: function () {
  39957. var series = this,
  39958. chart = this.chart,
  39959. options = series.options,
  39960. renderer = chart.renderer,
  39961. animationLimit = options.animationLimit || 250,
  39962. shapeArgs;
  39963. // draw the columns
  39964. series.points.forEach(function (point) {
  39965. var plotY = point.plotY,
  39966. graphic = point.graphic,
  39967. hasGraphic = !!graphic,
  39968. verb = graphic && chart.pointCount < animationLimit ?
  39969. 'animate' : 'attr';
  39970. if (isNumber(plotY) && point.y !== null) {
  39971. shapeArgs = point.shapeArgs;
  39972. // When updating a series between 2d and 3d or cartesian and
  39973. // polar, the shape type changes.
  39974. if (graphic && point.hasNewShapeType()) {
  39975. graphic = graphic.destroy();
  39976. }
  39977. // Set starting position for point sliding animation.
  39978. if (series.enabledDataSorting) {
  39979. point.startXPos = series.xAxis.reversed ?
  39980. -(shapeArgs ? shapeArgs.width : 0) :
  39981. series.xAxis.width;
  39982. }
  39983. if (!graphic) {
  39984. point.graphic = graphic =
  39985. renderer[point.shapeType](shapeArgs)
  39986. .add(point.group || series.group);
  39987. if (graphic &&
  39988. series.enabledDataSorting &&
  39989. chart.hasRendered &&
  39990. chart.pointCount < animationLimit) {
  39991. graphic.attr({
  39992. x: point.startXPos
  39993. });
  39994. hasGraphic = true;
  39995. verb = 'animate';
  39996. }
  39997. }
  39998. if (graphic && hasGraphic) { // update
  39999. graphic[verb](merge(shapeArgs));
  40000. }
  40001. // Border radius is not stylable (#6900)
  40002. if (options.borderRadius) {
  40003. graphic[verb]({
  40004. r: options.borderRadius
  40005. });
  40006. }
  40007. // Presentational
  40008. if (!chart.styledMode) {
  40009. graphic[verb](series.pointAttribs(point, (point.selected && 'select')))
  40010. .shadow(point.allowShadow !== false && options.shadow, null, options.stacking && !options.borderRadius);
  40011. }
  40012. graphic.addClass(point.getClassName(), true);
  40013. }
  40014. else if (graphic) {
  40015. point.graphic = graphic.destroy(); // #1269
  40016. }
  40017. });
  40018. },
  40019. /**
  40020. * Animate the column heights one by one from zero.
  40021. *
  40022. * @private
  40023. * @function Highcharts.seriesTypes.column#animate
  40024. *
  40025. * @param {boolean} init
  40026. * Whether to initialize the animation or run it
  40027. */
  40028. animate: function (init) {
  40029. var series = this,
  40030. yAxis = this.yAxis,
  40031. options = series.options,
  40032. inverted = this.chart.inverted,
  40033. attr = {},
  40034. translateProp = inverted ? 'translateX' : 'translateY',
  40035. translateStart,
  40036. translatedThreshold;
  40037. if (init) {
  40038. attr.scaleY = 0.001;
  40039. translatedThreshold = clamp(yAxis.toPixels(options.threshold), yAxis.pos, yAxis.pos + yAxis.len);
  40040. if (inverted) {
  40041. attr.translateX = translatedThreshold - yAxis.len;
  40042. }
  40043. else {
  40044. attr.translateY = translatedThreshold;
  40045. }
  40046. // apply finnal clipping (used in Highstock) (#7083)
  40047. // animation is done by scaleY, so cliping is for panes
  40048. if (series.clipBox) {
  40049. series.setClip();
  40050. }
  40051. series.group.attr(attr);
  40052. }
  40053. else { // run the animation
  40054. translateStart = series.group.attr(translateProp);
  40055. series.group.animate({ scaleY: 1 }, extend(animObject(series.options.animation), {
  40056. // Do the scale synchronously to ensure smooth
  40057. // updating (#5030, #7228)
  40058. step: function (val, fx) {
  40059. if (series.group) {
  40060. attr[translateProp] = translateStart +
  40061. fx.pos * (yAxis.pos - translateStart);
  40062. series.group.attr(attr);
  40063. }
  40064. }
  40065. }));
  40066. }
  40067. },
  40068. /**
  40069. * Remove this series from the chart
  40070. *
  40071. * @private
  40072. * @function Highcharts.seriesTypes.column#remove
  40073. */
  40074. remove: function () {
  40075. var series = this,
  40076. chart = series.chart;
  40077. // column and bar series affects other series of the same type
  40078. // as they are either stacked or grouped
  40079. if (chart.hasRendered) {
  40080. chart.series.forEach(function (otherSeries) {
  40081. if (otherSeries.type === series.type) {
  40082. otherSeries.isDirty = true;
  40083. }
  40084. });
  40085. }
  40086. LineSeries.prototype.remove.apply(series, arguments);
  40087. }
  40088. });
  40089. /* eslint-enable valid-jsdoc */
  40090. /**
  40091. * A `column` series. If the [type](#series.column.type) option is
  40092. * not specified, it is inherited from [chart.type](#chart.type).
  40093. *
  40094. * @extends series,plotOptions.column
  40095. * @excluding connectNulls, dataParser, dataURL, gapSize, gapUnit, linecap,
  40096. * lineWidth, marker, connectEnds, step
  40097. * @product highcharts highstock
  40098. * @apioption series.column
  40099. */
  40100. /**
  40101. * An array of data points for the series. For the `column` series type,
  40102. * points can be given in the following ways:
  40103. *
  40104. * 1. An array of numerical values. In this case, the numerical values will be
  40105. * interpreted as `y` options. The `x` values will be automatically
  40106. * calculated, either starting at 0 and incremented by 1, or from
  40107. * `pointStart` and `pointInterval` given in the series options. If the axis
  40108. * has categories, these will be used. Example:
  40109. * ```js
  40110. * data: [0, 5, 3, 5]
  40111. * ```
  40112. *
  40113. * 2. An array of arrays with 2 values. In this case, the values correspond to
  40114. * `x,y`. If the first value is a string, it is applied as the name of the
  40115. * point, and the `x` value is inferred.
  40116. * ```js
  40117. * data: [
  40118. * [0, 6],
  40119. * [1, 2],
  40120. * [2, 6]
  40121. * ]
  40122. * ```
  40123. *
  40124. * 3. An array of objects with named values. The following snippet shows only a
  40125. * few settings, see the complete options set below. If the total number of
  40126. * data points exceeds the series'
  40127. * [turboThreshold](#series.column.turboThreshold), this option is not
  40128. * available.
  40129. * ```js
  40130. * data: [{
  40131. * x: 1,
  40132. * y: 9,
  40133. * name: "Point2",
  40134. * color: "#00FF00"
  40135. * }, {
  40136. * x: 1,
  40137. * y: 6,
  40138. * name: "Point1",
  40139. * color: "#FF00FF"
  40140. * }]
  40141. * ```
  40142. *
  40143. * @sample {highcharts} highcharts/chart/reflow-true/
  40144. * Numerical values
  40145. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  40146. * Arrays of numeric x and y
  40147. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  40148. * Arrays of datetime x and y
  40149. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  40150. * Arrays of point.name and y
  40151. * @sample {highcharts} highcharts/series/data-array-of-objects/
  40152. * Config objects
  40153. *
  40154. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  40155. * @extends series.line.data
  40156. * @excluding marker
  40157. * @product highcharts highstock
  40158. * @apioption series.column.data
  40159. */
  40160. /**
  40161. * The color of the border surrounding the column or bar.
  40162. *
  40163. * In styled mode, the border stroke can be set with the `.highcharts-point`
  40164. * rule.
  40165. *
  40166. * @sample {highcharts} highcharts/plotoptions/column-bordercolor/
  40167. * Dark gray border
  40168. *
  40169. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  40170. * @product highcharts highstock
  40171. * @apioption series.column.data.borderColor
  40172. */
  40173. /**
  40174. * The width of the border surrounding the column or bar.
  40175. *
  40176. * In styled mode, the stroke width can be set with the `.highcharts-point`
  40177. * rule.
  40178. *
  40179. * @sample {highcharts} highcharts/plotoptions/column-borderwidth/
  40180. * 2px black border
  40181. *
  40182. * @type {number}
  40183. * @product highcharts highstock
  40184. * @apioption series.column.data.borderWidth
  40185. */
  40186. /**
  40187. * A name for the dash style to use for the column or bar. Overrides
  40188. * dashStyle on the series.
  40189. *
  40190. * In styled mode, the stroke dash-array can be set with the same classes as
  40191. * listed under [data.color](#series.column.data.color).
  40192. *
  40193. * @see [series.pointWidth](#plotOptions.column.dashStyle)
  40194. *
  40195. * @type {Highcharts.DashStyleValue}
  40196. * @apioption series.column.data.dashStyle
  40197. */
  40198. /**
  40199. * A pixel value specifying a fixed width for the column or bar. Overrides
  40200. * pointWidth on the series. The width effects the dimension that is not based
  40201. * on the point value.
  40202. *
  40203. * @see [series.pointWidth](#plotOptions.column.pointWidth)
  40204. *
  40205. * @type {number}
  40206. * @apioption series.column.data.pointWidth
  40207. */
  40208. /**
  40209. * @excluding halo, lineWidth, lineWidthPlus, marker
  40210. * @product highcharts highstock
  40211. * @apioption series.column.states.hover
  40212. */
  40213. /**
  40214. * @excluding halo, lineWidth, lineWidthPlus, marker
  40215. * @product highcharts highstock
  40216. * @apioption series.column.states.select
  40217. */
  40218. ''; // includes above doclets in transpilat
  40219. return ColumnSeries;
  40220. });
  40221. _registerModule(_modules, 'Series/BarSeries.js', [_modules['Core/Series/Series.js']], function (Series) {
  40222. /* *
  40223. *
  40224. * (c) 2010-2020 Torstein Honsi
  40225. *
  40226. * License: www.highcharts.com/license
  40227. *
  40228. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  40229. *
  40230. * */
  40231. /**
  40232. * Bar series type.
  40233. *
  40234. * @private
  40235. * @class
  40236. * @name Highcharts.seriesTypes.bar
  40237. *
  40238. * @augments Highcharts.Series
  40239. */
  40240. Series.seriesType('bar', 'column',
  40241. /**
  40242. * A bar series is a special type of column series where the columns are
  40243. * horizontal.
  40244. *
  40245. * @sample highcharts/demo/bar-basic/
  40246. * Bar chart
  40247. *
  40248. * @extends plotOptions.column
  40249. * @product highcharts
  40250. * @apioption plotOptions.bar
  40251. */
  40252. /**
  40253. * @ignore
  40254. */
  40255. null, {
  40256. inverted: true
  40257. });
  40258. /**
  40259. * A `bar` series. If the [type](#series.bar.type) option is not specified,
  40260. * it is inherited from [chart.type](#chart.type).
  40261. *
  40262. * @extends series,plotOptions.bar
  40263. * @excluding connectNulls, dashStyle, dataParser, dataURL, gapSize, gapUnit,
  40264. * linecap, lineWidth, marker, connectEnds, step
  40265. * @product highcharts
  40266. * @apioption series.bar
  40267. */
  40268. /**
  40269. * An array of data points for the series. For the `bar` series type,
  40270. * points can be given in the following ways:
  40271. *
  40272. * 1. An array of numerical values. In this case, the numerical values will be
  40273. * interpreted as `y` options. The `x` values will be automatically
  40274. * calculated, either starting at 0 and incremented by 1, or from
  40275. * `pointStart` and `pointInterval` given in the series options. If the axis
  40276. * has categories, these will be used. Example:
  40277. * ```js
  40278. * data: [0, 5, 3, 5]
  40279. * ```
  40280. *
  40281. * 2. An array of arrays with 2 values. In this case, the values correspond to
  40282. * `x,y`. If the first value is a string, it is applied as the name of the
  40283. * point, and the `x` value is inferred.
  40284. * ```js
  40285. * data: [
  40286. * [0, 5],
  40287. * [1, 10],
  40288. * [2, 3]
  40289. * ]
  40290. * ```
  40291. *
  40292. * 3. An array of objects with named values. The following snippet shows only a
  40293. * few settings, see the complete options set below. If the total number of
  40294. * data points exceeds the series'
  40295. * [turboThreshold](#series.bar.turboThreshold), this option is not
  40296. * available.
  40297. * ```js
  40298. * data: [{
  40299. * x: 1,
  40300. * y: 1,
  40301. * name: "Point2",
  40302. * color: "#00FF00"
  40303. * }, {
  40304. * x: 1,
  40305. * y: 10,
  40306. * name: "Point1",
  40307. * color: "#FF00FF"
  40308. * }]
  40309. * ```
  40310. *
  40311. * @sample {highcharts} highcharts/chart/reflow-true/
  40312. * Numerical values
  40313. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  40314. * Arrays of numeric x and y
  40315. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  40316. * Arrays of datetime x and y
  40317. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  40318. * Arrays of point.name and y
  40319. * @sample {highcharts} highcharts/series/data-array-of-objects/
  40320. * Config objects
  40321. *
  40322. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  40323. * @extends series.column.data
  40324. * @product highcharts
  40325. * @apioption series.bar.data
  40326. */
  40327. /**
  40328. * @excluding halo,lineWidth,lineWidthPlus,marker
  40329. * @product highcharts highstock
  40330. * @apioption series.bar.states.hover
  40331. */
  40332. /**
  40333. * @excluding halo,lineWidth,lineWidthPlus,marker
  40334. * @product highcharts highstock
  40335. * @apioption series.bar.states.select
  40336. */
  40337. ''; // gets doclets above into transpilat
  40338. });
  40339. _registerModule(_modules, 'Series/ScatterSeries.js', [_modules['Core/Series/Series.js'], _modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (BaseSeries, H, U) {
  40340. /* *
  40341. *
  40342. * (c) 2010-2020 Torstein Honsi
  40343. *
  40344. * License: www.highcharts.com/license
  40345. *
  40346. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  40347. *
  40348. * */
  40349. var addEvent = U.addEvent;
  40350. var Series = H.Series;
  40351. /**
  40352. * Scatter series type.
  40353. *
  40354. * @private
  40355. * @class
  40356. * @name Highcharts.seriesTypes.scatter
  40357. *
  40358. * @augments Highcharts.Series
  40359. */
  40360. BaseSeries.seriesType('scatter', 'line',
  40361. /**
  40362. * A scatter plot uses cartesian coordinates to display values for two
  40363. * variables for a set of data.
  40364. *
  40365. * @sample {highcharts} highcharts/demo/scatter/
  40366. * Scatter plot
  40367. *
  40368. * @extends plotOptions.line
  40369. * @excluding cropThreshold, pointPlacement, shadow, useOhlcData
  40370. * @product highcharts highstock
  40371. * @optionparent plotOptions.scatter
  40372. */
  40373. {
  40374. /**
  40375. * The width of the line connecting the data points.
  40376. *
  40377. * @sample {highcharts} highcharts/plotoptions/scatter-linewidth-none/
  40378. * 0 by default
  40379. * @sample {highcharts} highcharts/plotoptions/scatter-linewidth-1/
  40380. * 1px
  40381. *
  40382. * @product highcharts highstock
  40383. */
  40384. lineWidth: 0,
  40385. findNearestPointBy: 'xy',
  40386. /**
  40387. * Apply a jitter effect for the rendered markers. When plotting
  40388. * discrete values, a little random noise may help telling the points
  40389. * apart. The jitter setting applies a random displacement of up to `n`
  40390. * axis units in either direction. So for example on a horizontal X
  40391. * axis, setting the `jitter.x` to 0.24 will render the point in a
  40392. * random position between 0.24 units to the left and 0.24 units to the
  40393. * right of the true axis position. On a category axis, setting it to
  40394. * 0.5 will fill up the bin and make the data appear continuous.
  40395. *
  40396. * When rendered on top of a box plot or a column series, a jitter value
  40397. * of 0.24 will correspond to the underlying series' default
  40398. * [groupPadding](
  40399. * https://api.highcharts.com/highcharts/plotOptions.column.groupPadding)
  40400. * and [pointPadding](
  40401. * https://api.highcharts.com/highcharts/plotOptions.column.pointPadding)
  40402. * settings.
  40403. *
  40404. * @sample {highcharts} highcharts/series-scatter/jitter
  40405. * Jitter on a scatter plot
  40406. *
  40407. * @sample {highcharts} highcharts/series-scatter/jitter-boxplot
  40408. * Jittered scatter plot on top of a box plot
  40409. *
  40410. * @product highcharts highstock
  40411. * @since 7.0.2
  40412. */
  40413. jitter: {
  40414. /**
  40415. * The maximal X offset for the random jitter effect.
  40416. */
  40417. x: 0,
  40418. /**
  40419. * The maximal Y offset for the random jitter effect.
  40420. */
  40421. y: 0
  40422. },
  40423. marker: {
  40424. enabled: true // Overrides auto-enabling in line series (#3647)
  40425. },
  40426. /**
  40427. * Sticky tracking of mouse events. When true, the `mouseOut` event
  40428. * on a series isn't triggered until the mouse moves over another
  40429. * series, or out of the plot area. When false, the `mouseOut` event on
  40430. * a series is triggered when the mouse leaves the area around the
  40431. * series' graph or markers. This also implies the tooltip. When
  40432. * `stickyTracking` is false and `tooltip.shared` is false, the tooltip
  40433. * will be hidden when moving the mouse between series.
  40434. *
  40435. * @type {boolean}
  40436. * @default false
  40437. * @product highcharts highstock
  40438. * @apioption plotOptions.scatter.stickyTracking
  40439. */
  40440. /**
  40441. * A configuration object for the tooltip rendering of each single
  40442. * series. Properties are inherited from [tooltip](#tooltip).
  40443. * Overridable properties are `headerFormat`, `pointFormat`,
  40444. * `yDecimals`, `xDateFormat`, `yPrefix` and `ySuffix`. Unlike other
  40445. * series, in a scatter plot the series.name by default shows in the
  40446. * headerFormat and point.x and point.y in the pointFormat.
  40447. *
  40448. * @product highcharts highstock
  40449. */
  40450. tooltip: {
  40451. headerFormat: '<span style="color:{point.color}">\u25CF</span> ' +
  40452. '<span style="font-size: 10px"> {series.name}</span><br/>',
  40453. pointFormat: 'x: <b>{point.x}</b><br/>y: <b>{point.y}</b><br/>'
  40454. }
  40455. // Prototype members
  40456. }, {
  40457. sorted: false,
  40458. requireSorting: false,
  40459. noSharedTooltip: true,
  40460. trackerGroups: ['group', 'markerGroup', 'dataLabelsGroup'],
  40461. takeOrdinalPosition: false,
  40462. /* eslint-disable valid-jsdoc */
  40463. /**
  40464. * @private
  40465. * @function Highcharts.seriesTypes.scatter#drawGraph
  40466. */
  40467. drawGraph: function () {
  40468. if (this.options.lineWidth ||
  40469. // In case we have a graph from before and we update the line
  40470. // width to 0 (#13816)
  40471. (this.options.lineWidth === 0 &&
  40472. this.graph &&
  40473. this.graph.strokeWidth())) {
  40474. Series.prototype.drawGraph.call(this);
  40475. }
  40476. },
  40477. // Optionally add the jitter effect
  40478. applyJitter: function () {
  40479. var series = this,
  40480. jitter = this.options.jitter,
  40481. len = this.points.length;
  40482. /**
  40483. * Return a repeatable, pseudo-random number based on an integer
  40484. * seed.
  40485. * @private
  40486. */
  40487. function unrandom(seed) {
  40488. var rand = Math.sin(seed) * 10000;
  40489. return rand - Math.floor(rand);
  40490. }
  40491. if (jitter) {
  40492. this.points.forEach(function (point, i) {
  40493. ['x', 'y'].forEach(function (dim, j) {
  40494. var axis,
  40495. plotProp = 'plot' + dim.toUpperCase(),
  40496. min,
  40497. max,
  40498. translatedJitter;
  40499. if (jitter[dim] && !point.isNull) {
  40500. axis = series[dim + 'Axis'];
  40501. translatedJitter =
  40502. jitter[dim] * axis.transA;
  40503. if (axis && !axis.isLog) {
  40504. // Identify the outer bounds of the jitter range
  40505. min = Math.max(0, point[plotProp] - translatedJitter);
  40506. max = Math.min(axis.len, point[plotProp] + translatedJitter);
  40507. // Find a random position within this range
  40508. point[plotProp] = min +
  40509. (max - min) * unrandom(i + j * len);
  40510. // Update clientX for the tooltip k-d-tree
  40511. if (dim === 'x') {
  40512. point.clientX = point.plotX;
  40513. }
  40514. }
  40515. }
  40516. });
  40517. });
  40518. }
  40519. }
  40520. /* eslint-enable valid-jsdoc */
  40521. });
  40522. /* eslint-disable no-invalid-this */
  40523. addEvent(Series, 'afterTranslate', function () {
  40524. if (this.applyJitter) {
  40525. this.applyJitter();
  40526. }
  40527. });
  40528. /* eslint-enable no-invalid-this */
  40529. /**
  40530. * A `scatter` series. If the [type](#series.scatter.type) option is
  40531. * not specified, it is inherited from [chart.type](#chart.type).
  40532. *
  40533. * @extends series,plotOptions.scatter
  40534. * @excluding cropThreshold, dataParser, dataURL, useOhlcData
  40535. * @product highcharts highstock
  40536. * @apioption series.scatter
  40537. */
  40538. /**
  40539. * An array of data points for the series. For the `scatter` series
  40540. * type, points can be given in the following ways:
  40541. *
  40542. * 1. An array of numerical values. In this case, the numerical values will be
  40543. * interpreted as `y` options. The `x` values will be automatically
  40544. * calculated, either starting at 0 and incremented by 1, or from
  40545. * `pointStart` and `pointInterval` given in the series options. If the axis
  40546. * has categories, these will be used. Example:
  40547. * ```js
  40548. * data: [0, 5, 3, 5]
  40549. * ```
  40550. *
  40551. * 2. An array of arrays with 2 values. In this case, the values correspond to
  40552. * `x,y`. If the first value is a string, it is applied as the name of the
  40553. * point, and the `x` value is inferred.
  40554. * ```js
  40555. * data: [
  40556. * [0, 0],
  40557. * [1, 8],
  40558. * [2, 9]
  40559. * ]
  40560. * ```
  40561. *
  40562. * 3. An array of objects with named values. The following snippet shows only a
  40563. * few settings, see the complete options set below. If the total number of
  40564. * data points exceeds the series'
  40565. * [turboThreshold](#series.scatter.turboThreshold), this option is not
  40566. * available.
  40567. * ```js
  40568. * data: [{
  40569. * x: 1,
  40570. * y: 2,
  40571. * name: "Point2",
  40572. * color: "#00FF00"
  40573. * }, {
  40574. * x: 1,
  40575. * y: 4,
  40576. * name: "Point1",
  40577. * color: "#FF00FF"
  40578. * }]
  40579. * ```
  40580. *
  40581. * @sample {highcharts} highcharts/chart/reflow-true/
  40582. * Numerical values
  40583. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  40584. * Arrays of numeric x and y
  40585. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  40586. * Arrays of datetime x and y
  40587. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  40588. * Arrays of point.name and y
  40589. * @sample {highcharts} highcharts/series/data-array-of-objects/
  40590. * Config objects
  40591. *
  40592. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  40593. * @extends series.line.data
  40594. * @product highcharts highstock
  40595. * @apioption series.scatter.data
  40596. */
  40597. ''; // adds doclets above to transpilat
  40598. });
  40599. _registerModule(_modules, 'Mixins/CenteredSeries.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  40600. /* *
  40601. *
  40602. * (c) 2010-2020 Torstein Honsi
  40603. *
  40604. * License: www.highcharts.com/license
  40605. *
  40606. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  40607. *
  40608. * */
  40609. /**
  40610. * @private
  40611. * @interface Highcharts.RadianAngles
  40612. */ /**
  40613. * @name Highcharts.RadianAngles#end
  40614. * @type {number}
  40615. */ /**
  40616. * @name Highcharts.RadianAngles#start
  40617. * @type {number}
  40618. */
  40619. var isNumber = U.isNumber,
  40620. pick = U.pick,
  40621. relativeLength = U.relativeLength;
  40622. var deg2rad = H.deg2rad;
  40623. /* eslint-disable valid-jsdoc */
  40624. /**
  40625. * @private
  40626. * @mixin Highcharts.CenteredSeriesMixin
  40627. */
  40628. var centeredSeriesMixin = H.CenteredSeriesMixin = {
  40629. /**
  40630. * Get the center of the pie based on the size and center options relative
  40631. * to the plot area. Borrowed by the polar and gauge series types.
  40632. *
  40633. * @private
  40634. * @function Highcharts.CenteredSeriesMixin.getCenter
  40635. *
  40636. * @return {Array<number>}
  40637. */
  40638. getCenter: function () {
  40639. var options = this.options,
  40640. chart = this.chart,
  40641. slicingRoom = 2 * (options.slicedOffset || 0),
  40642. handleSlicingRoom,
  40643. plotWidth = chart.plotWidth - 2 * slicingRoom,
  40644. plotHeight = chart.plotHeight - 2 * slicingRoom,
  40645. centerOption = options.center,
  40646. smallestSize = Math.min(plotWidth,
  40647. plotHeight),
  40648. size = options.size,
  40649. innerSize = options.innerSize || 0,
  40650. positions,
  40651. i,
  40652. value;
  40653. if (typeof size === 'string') {
  40654. size = parseFloat(size);
  40655. }
  40656. if (typeof innerSize === 'string') {
  40657. innerSize = parseFloat(innerSize);
  40658. }
  40659. positions = [
  40660. pick(centerOption[0], '50%'),
  40661. pick(centerOption[1], '50%'),
  40662. // Prevent from negative values
  40663. pick(size && size < 0 ? void 0 : options.size, '100%'),
  40664. pick(innerSize && innerSize < 0 ? void 0 : options.innerSize || 0, '0%')
  40665. ];
  40666. // No need for inner size in angular (gauges) series but still required
  40667. // for pie series
  40668. if (chart.angular && !(this instanceof H.Series)) {
  40669. positions[3] = 0;
  40670. }
  40671. for (i = 0; i < 4; ++i) {
  40672. value = positions[i];
  40673. handleSlicingRoom = i < 2 || (i === 2 && /%$/.test(value));
  40674. // i == 0: centerX, relative to width
  40675. // i == 1: centerY, relative to height
  40676. // i == 2: size, relative to smallestSize
  40677. // i == 3: innerSize, relative to size
  40678. positions[i] = relativeLength(value, [plotWidth, plotHeight, smallestSize, positions[2]][i]) + (handleSlicingRoom ? slicingRoom : 0);
  40679. }
  40680. // innerSize cannot be larger than size (#3632)
  40681. if (positions[3] > positions[2]) {
  40682. positions[3] = positions[2];
  40683. }
  40684. return positions;
  40685. },
  40686. /**
  40687. * getStartAndEndRadians - Calculates start and end angles in radians.
  40688. * Used in series types such as pie and sunburst.
  40689. *
  40690. * @private
  40691. * @function Highcharts.CenteredSeriesMixin.getStartAndEndRadians
  40692. *
  40693. * @param {number} [start]
  40694. * Start angle in degrees.
  40695. *
  40696. * @param {number} [end]
  40697. * Start angle in degrees.
  40698. *
  40699. * @return {Highcharts.RadianAngles}
  40700. * Returns an object containing start and end angles as radians.
  40701. */
  40702. getStartAndEndRadians: function (start, end) {
  40703. var startAngle = isNumber(start) ? start : 0, // must be a number
  40704. endAngle = ((isNumber(end) && // must be a number
  40705. end > startAngle && // must be larger than the start angle
  40706. // difference must be less than 360 degrees
  40707. (end - startAngle) < 360) ?
  40708. end :
  40709. startAngle + 360),
  40710. correction = -90;
  40711. return {
  40712. start: deg2rad * (startAngle + correction),
  40713. end: deg2rad * (endAngle + correction)
  40714. };
  40715. }
  40716. };
  40717. return centeredSeriesMixin;
  40718. });
  40719. _registerModule(_modules, 'Series/PieSeries.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Series/Series.js'], _modules['Mixins/CenteredSeries.js'], _modules['Core/Globals.js'], _modules['Mixins/LegendSymbol.js'], _modules['Series/LineSeries.js'], _modules['Core/Series/Point.js'], _modules['Core/Renderer/SVG/SVGRenderer.js'], _modules['Core/Utilities.js']], function (A, BaseSeries, CenteredSeriesMixin, H, LegendSymbolMixin, LineSeries, Point, SVGRenderer, U) {
  40720. /* *
  40721. *
  40722. * (c) 2010-2020 Torstein Honsi
  40723. *
  40724. * License: www.highcharts.com/license
  40725. *
  40726. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  40727. *
  40728. * */
  40729. var setAnimation = A.setAnimation;
  40730. var getStartAndEndRadians = CenteredSeriesMixin.getStartAndEndRadians;
  40731. var noop = H.noop;
  40732. var addEvent = U.addEvent,
  40733. clamp = U.clamp,
  40734. defined = U.defined,
  40735. fireEvent = U.fireEvent,
  40736. isNumber = U.isNumber,
  40737. merge = U.merge,
  40738. pick = U.pick,
  40739. relativeLength = U.relativeLength;
  40740. /**
  40741. * Pie series type.
  40742. *
  40743. * @private
  40744. * @class
  40745. * @name Highcharts.seriesTypes.pie
  40746. *
  40747. * @augments Highcharts.Series
  40748. */
  40749. BaseSeries.seriesType('pie', 'line',
  40750. /**
  40751. * A pie chart is a circular graphic which is divided into slices to
  40752. * illustrate numerical proportion.
  40753. *
  40754. * @sample highcharts/demo/pie-basic/
  40755. * Pie chart
  40756. *
  40757. * @extends plotOptions.line
  40758. * @excluding animationLimit, boostThreshold, connectEnds, connectNulls,
  40759. * cropThreshold, dashStyle, dataSorting, dragDrop,
  40760. * findNearestPointBy, getExtremesFromAll, label, lineWidth,
  40761. * marker, negativeColor, pointInterval, pointIntervalUnit,
  40762. * pointPlacement, pointStart, softThreshold, stacking, step,
  40763. * threshold, turboThreshold, zoneAxis, zones, dataSorting,
  40764. * boostBlending
  40765. * @product highcharts
  40766. * @optionparent plotOptions.pie
  40767. */
  40768. {
  40769. /**
  40770. * @excluding legendItemClick
  40771. * @apioption plotOptions.pie.events
  40772. */
  40773. /**
  40774. * Fires when the checkbox next to the point name in the legend is
  40775. * clicked. One parameter, event, is passed to the function. The state
  40776. * of the checkbox is found by event.checked. The checked item is found
  40777. * by event.item. Return false to prevent the default action which is to
  40778. * toggle the select state of the series.
  40779. *
  40780. * @sample {highcharts} highcharts/plotoptions/series-events-checkboxclick/
  40781. * Alert checkbox status
  40782. *
  40783. * @type {Function}
  40784. * @since 1.2.0
  40785. * @product highcharts
  40786. * @context Highcharts.Point
  40787. * @apioption plotOptions.pie.events.checkboxClick
  40788. */
  40789. /**
  40790. * Fires when the legend item belonging to the pie point (slice) is
  40791. * clicked. The `this` keyword refers to the point itself. One
  40792. * parameter, `event`, is passed to the function, containing common
  40793. * event information. The default action is to toggle the visibility of
  40794. * the point. This can be prevented by calling `event.preventDefault()`.
  40795. *
  40796. * @sample {highcharts} highcharts/plotoptions/pie-point-events-legenditemclick/
  40797. * Confirm toggle visibility
  40798. *
  40799. * @type {Highcharts.PointLegendItemClickCallbackFunction}
  40800. * @since 1.2.0
  40801. * @product highcharts
  40802. * @apioption plotOptions.pie.point.events.legendItemClick
  40803. */
  40804. /**
  40805. * The center of the pie chart relative to the plot area. Can be
  40806. * percentages or pixel values. The default behaviour (as of 3.0) is to
  40807. * center the pie so that all slices and data labels are within the plot
  40808. * area. As a consequence, the pie may actually jump around in a chart
  40809. * with dynamic values, as the data labels move. In that case, the
  40810. * center should be explicitly set, for example to `["50%", "50%"]`.
  40811. *
  40812. * @sample {highcharts} highcharts/plotoptions/pie-center/
  40813. * Centered at 100, 100
  40814. *
  40815. * @type {Array<(number|string|null),(number|string|null)>}
  40816. * @default [null, null]
  40817. * @product highcharts
  40818. *
  40819. * @private
  40820. */
  40821. center: [null, null],
  40822. /**
  40823. * The color of the pie series. A pie series is represented as an empty
  40824. * circle if the total sum of its values is 0. Use this property to
  40825. * define the color of its border.
  40826. *
  40827. * In styled mode, the color can be defined by the
  40828. * [colorIndex](#plotOptions.series.colorIndex) option. Also, the series
  40829. * color can be set with the `.highcharts-series`,
  40830. * `.highcharts-color-{n}`, `.highcharts-{type}-series` or
  40831. * `.highcharts-series-{n}` class, or individual classes given by the
  40832. * `className` option.
  40833. *
  40834. * @sample {highcharts} highcharts/plotoptions/pie-emptyseries/
  40835. * Empty pie series
  40836. *
  40837. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  40838. * @default #cccccc
  40839. * @apioption plotOptions.pie.color
  40840. */
  40841. /**
  40842. * @product highcharts
  40843. *
  40844. * @private
  40845. */
  40846. clip: false,
  40847. /**
  40848. * @ignore-option
  40849. *
  40850. * @private
  40851. */
  40852. colorByPoint: true,
  40853. /**
  40854. * A series specific or series type specific color set to use instead
  40855. * of the global [colors](#colors).
  40856. *
  40857. * @sample {highcharts} highcharts/demo/pie-monochrome/
  40858. * Set default colors for all pies
  40859. *
  40860. * @type {Array<Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject>}
  40861. * @since 3.0
  40862. * @product highcharts
  40863. * @apioption plotOptions.pie.colors
  40864. */
  40865. /**
  40866. * @declare Highcharts.SeriesPieDataLabelsOptionsObject
  40867. * @extends plotOptions.series.dataLabels
  40868. * @excluding align, allowOverlap, inside, staggerLines, step
  40869. * @private
  40870. */
  40871. dataLabels: {
  40872. /**
  40873. * Alignment method for data labels. Possible values are:
  40874. *
  40875. * - `toPlotEdges`: Each label touches the nearest vertical edge of
  40876. * the plot area.
  40877. *
  40878. * - `connectors`: Connectors have the same x position and the
  40879. * widest label of each half (left & right) touches the nearest
  40880. * vertical edge of the plot area.
  40881. *
  40882. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-alignto-connectors/
  40883. * alignTo: connectors
  40884. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-alignto-plotedges/
  40885. * alignTo: plotEdges
  40886. *
  40887. * @type {string}
  40888. * @since 7.0.0
  40889. * @product highcharts
  40890. * @apioption plotOptions.pie.dataLabels.alignTo
  40891. */
  40892. allowOverlap: true,
  40893. /**
  40894. * The color of the line connecting the data label to the pie slice.
  40895. * The default color is the same as the point's color.
  40896. *
  40897. * In styled mode, the connector stroke is given in the
  40898. * `.highcharts-data-label-connector` class.
  40899. *
  40900. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorcolor/
  40901. * Blue connectors
  40902. * @sample {highcharts} highcharts/css/pie-point/
  40903. * Styled connectors
  40904. *
  40905. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  40906. * @since 2.1
  40907. * @product highcharts
  40908. * @apioption plotOptions.pie.dataLabels.connectorColor
  40909. */
  40910. /**
  40911. * The distance from the data label to the connector. Note that
  40912. * data labels also have a default `padding`, so in order for the
  40913. * connector to touch the text, the `padding` must also be 0.
  40914. *
  40915. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorpadding/
  40916. * No padding
  40917. *
  40918. * @since 2.1
  40919. * @product highcharts
  40920. */
  40921. connectorPadding: 5,
  40922. /**
  40923. * Specifies the method that is used to generate the connector path.
  40924. * Highcharts provides 3 built-in connector shapes: `'fixedOffset'`
  40925. * (default), `'straight'` and `'crookedLine'`. Using
  40926. * `'crookedLine'` has the most sense (in most of the cases) when
  40927. * `'alignTo'` is set.
  40928. *
  40929. * Users can provide their own method by passing a function instead
  40930. * of a String. 3 arguments are passed to the callback:
  40931. *
  40932. * - Object that holds the information about the coordinates of the
  40933. * label (`x` & `y` properties) and how the label is located in
  40934. * relation to the pie (`alignment` property). `alignment` can by
  40935. * one of the following:
  40936. * `'left'` (pie on the left side of the data label),
  40937. * `'right'` (pie on the right side of the data label) or
  40938. * `'center'` (data label overlaps the pie).
  40939. *
  40940. * - Object that holds the information about the position of the
  40941. * connector. Its `touchingSliceAt` porperty tells the position
  40942. * of the place where the connector touches the slice.
  40943. *
  40944. * - Data label options
  40945. *
  40946. * The function has to return an SVG path definition in array form
  40947. * (see the example).
  40948. *
  40949. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorshape-string/
  40950. * connectorShape is a String
  40951. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorshape-function/
  40952. * connectorShape is a function
  40953. *
  40954. * @type {string|Function}
  40955. * @since 7.0.0
  40956. * @product highcharts
  40957. */
  40958. connectorShape: 'fixedOffset',
  40959. /**
  40960. * The width of the line connecting the data label to the pie slice.
  40961. *
  40962. * In styled mode, the connector stroke width is given in the
  40963. * `.highcharts-data-label-connector` class.
  40964. *
  40965. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorwidth-disabled/
  40966. * Disable the connector
  40967. * @sample {highcharts} highcharts/css/pie-point/
  40968. * Styled connectors
  40969. *
  40970. * @type {number}
  40971. * @default 1
  40972. * @since 2.1
  40973. * @product highcharts
  40974. * @apioption plotOptions.pie.dataLabels.connectorWidth
  40975. */
  40976. /**
  40977. * Works only if `connectorShape` is `'crookedLine'`. It defines how
  40978. * far from the vertical plot edge the coonnector path should be
  40979. * crooked.
  40980. *
  40981. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-crookdistance/
  40982. * crookDistance set to 90%
  40983. *
  40984. * @since 7.0.0
  40985. * @product highcharts
  40986. */
  40987. crookDistance: '70%',
  40988. /**
  40989. * The distance of the data label from the pie's edge. Negative
  40990. * numbers put the data label on top of the pie slices. Can also be
  40991. * defined as a percentage of pie's radius. Connectors are only
  40992. * shown for data labels outside the pie.
  40993. *
  40994. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-distance/
  40995. * Data labels on top of the pie
  40996. *
  40997. * @type {number|string}
  40998. * @since 2.1
  40999. * @product highcharts
  41000. */
  41001. distance: 30,
  41002. enabled: true,
  41003. /**
  41004. * A
  41005. * [format string](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting)
  41006. * for the data label. Available variables are the same as for
  41007. * `formatter`.
  41008. *
  41009. * @sample {highcharts} highcharts/plotoptions/series-datalabels-format/
  41010. * Add a unit
  41011. *
  41012. * @type {string}
  41013. * @default undefined
  41014. * @since 3.0
  41015. * @apioption plotOptions.pie.dataLabels.format
  41016. */
  41017. // eslint-disable-next-line valid-jsdoc
  41018. /**
  41019. * Callback JavaScript function to format the data label. Note that
  41020. * if a `format` is defined, the format takes precedence and the
  41021. * formatter is ignored.
  41022. *
  41023. * @type {Highcharts.DataLabelsFormatterCallbackFunction}
  41024. * @default function () { return this.point.isNull ? void 0 : this.point.name; }
  41025. */
  41026. formatter: function () {
  41027. return this.point.isNull ? void 0 : this.point.name;
  41028. },
  41029. /**
  41030. * Whether to render the connector as a soft arc or a line with
  41031. * sharp break. Works only if `connectorShape` equals to
  41032. * `fixedOffset`.
  41033. *
  41034. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-softconnector-true/
  41035. * Soft
  41036. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-softconnector-false/
  41037. * Non soft
  41038. *
  41039. * @since 2.1.7
  41040. * @product highcharts
  41041. */
  41042. softConnector: true,
  41043. /**
  41044. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-overflow
  41045. * Long labels truncated with an ellipsis
  41046. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-overflow-wrap
  41047. * Long labels are wrapped
  41048. *
  41049. * @type {Highcharts.CSSObject}
  41050. * @apioption plotOptions.pie.dataLabels.style
  41051. */
  41052. x: 0
  41053. },
  41054. /**
  41055. * If the total sum of the pie's values is 0, the series is represented
  41056. * as an empty circle . The `fillColor` option defines the color of that
  41057. * circle. Use [pie.borderWidth](#plotOptions.pie.borderWidth) to set
  41058. * the border thickness.
  41059. *
  41060. * @sample {highcharts} highcharts/plotoptions/pie-emptyseries/
  41061. * Empty pie series
  41062. *
  41063. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  41064. * @private
  41065. */
  41066. fillColor: void 0,
  41067. /**
  41068. * The end angle of the pie in degrees where 0 is top and 90 is right.
  41069. * Defaults to `startAngle` plus 360.
  41070. *
  41071. * @sample {highcharts} highcharts/demo/pie-semi-circle/
  41072. * Semi-circle donut
  41073. *
  41074. * @type {number}
  41075. * @since 1.3.6
  41076. * @product highcharts
  41077. * @apioption plotOptions.pie.endAngle
  41078. */
  41079. /**
  41080. * Equivalent to [chart.ignoreHiddenSeries](#chart.ignoreHiddenSeries),
  41081. * this option tells whether the series shall be redrawn as if the
  41082. * hidden point were `null`.
  41083. *
  41084. * The default value changed from `false` to `true` with Highcharts
  41085. * 3.0.
  41086. *
  41087. * @sample {highcharts} highcharts/plotoptions/pie-ignorehiddenpoint/
  41088. * True, the hiddden point is ignored
  41089. *
  41090. * @since 2.3.0
  41091. * @product highcharts
  41092. *
  41093. * @private
  41094. */
  41095. ignoreHiddenPoint: true,
  41096. /**
  41097. * @ignore-option
  41098. *
  41099. * @private
  41100. */
  41101. inactiveOtherPoints: true,
  41102. /**
  41103. * The size of the inner diameter for the pie. A size greater than 0
  41104. * renders a donut chart. Can be a percentage or pixel value.
  41105. * Percentages are relative to the pie size. Pixel values are given as
  41106. * integers.
  41107. *
  41108. *
  41109. * Note: in Highcharts < 4.1.2, the percentage was relative to the plot
  41110. * area, not the pie size.
  41111. *
  41112. * @sample {highcharts} highcharts/plotoptions/pie-innersize-80px/
  41113. * 80px inner size
  41114. * @sample {highcharts} highcharts/plotoptions/pie-innersize-50percent/
  41115. * 50% of the plot area
  41116. * @sample {highcharts} highcharts/demo/3d-pie-donut/
  41117. * 3D donut
  41118. *
  41119. * @type {number|string}
  41120. * @default 0
  41121. * @since 2.0
  41122. * @product highcharts
  41123. * @apioption plotOptions.pie.innerSize
  41124. */
  41125. /**
  41126. * @ignore-option
  41127. *
  41128. * @private
  41129. */
  41130. legendType: 'point',
  41131. /**
  41132. * @ignore-option
  41133. *
  41134. * @private
  41135. */
  41136. marker: null,
  41137. /**
  41138. * The minimum size for a pie in response to auto margins. The pie will
  41139. * try to shrink to make room for data labels in side the plot area,
  41140. * but only to this size.
  41141. *
  41142. * @type {number|string}
  41143. * @default 80
  41144. * @since 3.0
  41145. * @product highcharts
  41146. * @apioption plotOptions.pie.minSize
  41147. */
  41148. /**
  41149. * The diameter of the pie relative to the plot area. Can be a
  41150. * percentage or pixel value. Pixel values are given as integers. The
  41151. * default behaviour (as of 3.0) is to scale to the plot area and give
  41152. * room for data labels within the plot area.
  41153. * [slicedOffset](#plotOptions.pie.slicedOffset) is also included in the
  41154. * default size calculation. As a consequence, the size of the pie may
  41155. * vary when points are updated and data labels more around. In that
  41156. * case it is best to set a fixed value, for example `"75%"`.
  41157. *
  41158. * @sample {highcharts} highcharts/plotoptions/pie-size/
  41159. * Smaller pie
  41160. *
  41161. * @type {number|string|null}
  41162. * @product highcharts
  41163. *
  41164. * @private
  41165. */
  41166. size: null,
  41167. /**
  41168. * Whether to display this particular series or series type in the
  41169. * legend. Since 2.1, pies are not shown in the legend by default.
  41170. *
  41171. * @sample {highcharts} highcharts/plotoptions/series-showinlegend/
  41172. * One series in the legend, one hidden
  41173. *
  41174. * @product highcharts
  41175. *
  41176. * @private
  41177. */
  41178. showInLegend: false,
  41179. /**
  41180. * If a point is sliced, moved out from the center, how many pixels
  41181. * should it be moved?.
  41182. *
  41183. * @sample {highcharts} highcharts/plotoptions/pie-slicedoffset-20/
  41184. * 20px offset
  41185. *
  41186. * @product highcharts
  41187. *
  41188. * @private
  41189. */
  41190. slicedOffset: 10,
  41191. /**
  41192. * The start angle of the pie slices in degrees where 0 is top and 90
  41193. * right.
  41194. *
  41195. * @sample {highcharts} highcharts/plotoptions/pie-startangle-90/
  41196. * Start from right
  41197. *
  41198. * @type {number}
  41199. * @default 0
  41200. * @since 2.3.4
  41201. * @product highcharts
  41202. * @apioption plotOptions.pie.startAngle
  41203. */
  41204. /**
  41205. * Sticky tracking of mouse events. When true, the `mouseOut` event
  41206. * on a series isn't triggered until the mouse moves over another
  41207. * series, or out of the plot area. When false, the `mouseOut` event on
  41208. * a series is triggered when the mouse leaves the area around the
  41209. * series' graph or markers. This also implies the tooltip. When
  41210. * `stickyTracking` is false and `tooltip.shared` is false, the tooltip
  41211. * will be hidden when moving the mouse between series.
  41212. *
  41213. * @product highcharts
  41214. *
  41215. * @private
  41216. */
  41217. stickyTracking: false,
  41218. tooltip: {
  41219. followPointer: true
  41220. },
  41221. /**
  41222. * The color of the border surrounding each slice. When `null`, the
  41223. * border takes the same color as the slice fill. This can be used
  41224. * together with a `borderWidth` to fill drawing gaps created by
  41225. * antialiazing artefacts in borderless pies.
  41226. *
  41227. * In styled mode, the border stroke is given in the `.highcharts-point`
  41228. * class.
  41229. *
  41230. * @sample {highcharts} highcharts/plotoptions/pie-bordercolor-black/
  41231. * Black border
  41232. *
  41233. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  41234. * @default #ffffff
  41235. * @product highcharts
  41236. *
  41237. * @private
  41238. */
  41239. borderColor: '#ffffff',
  41240. /**
  41241. * The width of the border surrounding each slice.
  41242. *
  41243. * When setting the border width to 0, there may be small gaps between
  41244. * the slices due to SVG antialiasing artefacts. To work around this,
  41245. * keep the border width at 0.5 or 1, but set the `borderColor` to
  41246. * `null` instead.
  41247. *
  41248. * In styled mode, the border stroke width is given in the
  41249. * `.highcharts-point` class.
  41250. *
  41251. * @sample {highcharts} highcharts/plotoptions/pie-borderwidth/
  41252. * 3px border
  41253. *
  41254. * @product highcharts
  41255. *
  41256. * @private
  41257. */
  41258. borderWidth: 1,
  41259. /**
  41260. * @ignore-options
  41261. * @private
  41262. */
  41263. lineWidth: void 0,
  41264. states: {
  41265. /**
  41266. * @extends plotOptions.series.states.hover
  41267. * @excluding marker, lineWidth, lineWidthPlus
  41268. * @product highcharts
  41269. */
  41270. hover: {
  41271. /**
  41272. * How much to brighten the point on interaction. Requires the
  41273. * main color to be defined in hex or rgb(a) format.
  41274. *
  41275. * In styled mode, the hover brightness is by default replaced
  41276. * by a fill-opacity given in the `.highcharts-point-hover`
  41277. * class.
  41278. *
  41279. * @sample {highcharts} highcharts/plotoptions/pie-states-hover-brightness/
  41280. * Brightened by 0.5
  41281. *
  41282. * @product highcharts
  41283. */
  41284. brightness: 0.1
  41285. }
  41286. }
  41287. },
  41288. /* eslint-disable valid-jsdoc */
  41289. /**
  41290. * @lends seriesTypes.pie.prototype
  41291. */
  41292. {
  41293. isCartesian: false,
  41294. requireSorting: false,
  41295. directTouch: true,
  41296. noSharedTooltip: true,
  41297. trackerGroups: ['group', 'dataLabelsGroup'],
  41298. axisTypes: [],
  41299. pointAttribs: BaseSeries.seriesTypes.column.prototype.pointAttribs,
  41300. /**
  41301. * Animate the pies in
  41302. *
  41303. * @private
  41304. * @function Highcharts.seriesTypes.pie#animate
  41305. *
  41306. * @param {boolean} [init=false]
  41307. */
  41308. animate: function (init) {
  41309. var series = this,
  41310. points = series.points,
  41311. startAngleRad = series.startAngleRad;
  41312. if (!init) {
  41313. points.forEach(function (point) {
  41314. var graphic = point.graphic,
  41315. args = point.shapeArgs;
  41316. if (graphic && args) {
  41317. // start values
  41318. graphic.attr({
  41319. // animate from inner radius (#779)
  41320. r: pick(point.startR, (series.center && series.center[3] / 2)),
  41321. start: startAngleRad,
  41322. end: startAngleRad
  41323. });
  41324. // animate
  41325. graphic.animate({
  41326. r: args.r,
  41327. start: args.start,
  41328. end: args.end
  41329. }, series.options.animation);
  41330. }
  41331. });
  41332. }
  41333. },
  41334. // Define hasData function for non-cartesian series.
  41335. // Returns true if the series has points at all.
  41336. hasData: function () {
  41337. return !!this.processedXData.length; // != 0
  41338. },
  41339. /**
  41340. * Recompute total chart sum and update percentages of points.
  41341. *
  41342. * @private
  41343. * @function Highcharts.seriesTypes.pie#updateTotals
  41344. * @return {void}
  41345. */
  41346. updateTotals: function () {
  41347. var i,
  41348. total = 0,
  41349. points = this.points,
  41350. len = points.length,
  41351. point,
  41352. ignoreHiddenPoint = this.options.ignoreHiddenPoint;
  41353. // Get the total sum
  41354. for (i = 0; i < len; i++) {
  41355. point = points[i];
  41356. total += (ignoreHiddenPoint && !point.visible) ?
  41357. 0 :
  41358. point.isNull ?
  41359. 0 :
  41360. point.y;
  41361. }
  41362. this.total = total;
  41363. // Set each point's properties
  41364. for (i = 0; i < len; i++) {
  41365. point = points[i];
  41366. point.percentage =
  41367. (total > 0 && (point.visible || !ignoreHiddenPoint)) ?
  41368. point.y / total * 100 :
  41369. 0;
  41370. point.total = total;
  41371. }
  41372. },
  41373. /**
  41374. * Extend the generatePoints method by adding total and percentage
  41375. * properties to each point
  41376. *
  41377. * @private
  41378. * @function Highcharts.seriesTypes.pie#generatePoints
  41379. * @return {void}
  41380. */
  41381. generatePoints: function () {
  41382. LineSeries.prototype.generatePoints.call(this);
  41383. this.updateTotals();
  41384. },
  41385. /**
  41386. * Utility for getting the x value from a given y, used for
  41387. * anticollision logic in data labels. Added point for using specific
  41388. * points' label distance.
  41389. * @private
  41390. */
  41391. getX: function (y, left, point) {
  41392. var center = this.center,
  41393. // Variable pie has individual radius
  41394. radius = this.radii ?
  41395. this.radii[point.index] :
  41396. center[2] / 2,
  41397. angle,
  41398. x;
  41399. angle = Math.asin(clamp((y - center[1]) / (radius + point.labelDistance), -1, 1));
  41400. x = center[0] +
  41401. (left ? -1 : 1) *
  41402. (Math.cos(angle) * (radius + point.labelDistance)) +
  41403. (point.labelDistance > 0 ?
  41404. (left ? -1 : 1) * this.options.dataLabels.padding :
  41405. 0);
  41406. return x;
  41407. },
  41408. /**
  41409. * Do translation for pie slices
  41410. *
  41411. * @private
  41412. * @function Highcharts.seriesTypes.pie#translate
  41413. * @param {Array<number>} [positions]
  41414. * @return {void}
  41415. */
  41416. translate: function (positions) {
  41417. this.generatePoints();
  41418. var series = this,
  41419. cumulative = 0,
  41420. precision = 1000, // issue #172
  41421. options = series.options,
  41422. slicedOffset = options.slicedOffset,
  41423. connectorOffset = slicedOffset + (options.borderWidth || 0),
  41424. finalConnectorOffset,
  41425. start,
  41426. end,
  41427. angle,
  41428. radians = getStartAndEndRadians(options.startAngle,
  41429. options.endAngle),
  41430. startAngleRad = series.startAngleRad = radians.start,
  41431. endAngleRad = series.endAngleRad = radians.end,
  41432. circ = endAngleRad - startAngleRad, // 2 * Math.PI,
  41433. points = series.points,
  41434. // the x component of the radius vector for a given point
  41435. radiusX,
  41436. radiusY,
  41437. labelDistance = options.dataLabels.distance,
  41438. ignoreHiddenPoint = options.ignoreHiddenPoint,
  41439. i,
  41440. len = points.length,
  41441. point;
  41442. // Get positions - either an integer or a percentage string must be
  41443. // given. If positions are passed as a parameter, we're in a
  41444. // recursive loop for adjusting space for data labels.
  41445. if (!positions) {
  41446. series.center = positions = series.getCenter();
  41447. }
  41448. // Calculate the geometry for each point
  41449. for (i = 0; i < len; i++) {
  41450. point = points[i];
  41451. // set start and end angle
  41452. start = startAngleRad + (cumulative * circ);
  41453. if (!ignoreHiddenPoint || point.visible) {
  41454. cumulative += point.percentage / 100;
  41455. }
  41456. end = startAngleRad + (cumulative * circ);
  41457. // set the shape
  41458. point.shapeType = 'arc';
  41459. point.shapeArgs = {
  41460. x: positions[0],
  41461. y: positions[1],
  41462. r: positions[2] / 2,
  41463. innerR: positions[3] / 2,
  41464. start: Math.round(start * precision) / precision,
  41465. end: Math.round(end * precision) / precision
  41466. };
  41467. // Used for distance calculation for specific point.
  41468. point.labelDistance = pick((point.options.dataLabels &&
  41469. point.options.dataLabels.distance), labelDistance);
  41470. // Compute point.labelDistance if it's defined as percentage
  41471. // of slice radius (#8854)
  41472. point.labelDistance = relativeLength(point.labelDistance, point.shapeArgs.r);
  41473. // Saved for later dataLabels distance calculation.
  41474. series.maxLabelDistance = Math.max(series.maxLabelDistance || 0, point.labelDistance);
  41475. // The angle must stay within -90 and 270 (#2645)
  41476. angle = (end + start) / 2;
  41477. if (angle > 1.5 * Math.PI) {
  41478. angle -= 2 * Math.PI;
  41479. }
  41480. else if (angle < -Math.PI / 2) {
  41481. angle += 2 * Math.PI;
  41482. }
  41483. // Center for the sliced out slice
  41484. point.slicedTranslation = {
  41485. translateX: Math.round(Math.cos(angle) * slicedOffset),
  41486. translateY: Math.round(Math.sin(angle) * slicedOffset)
  41487. };
  41488. // set the anchor point for tooltips
  41489. radiusX = Math.cos(angle) * positions[2] / 2;
  41490. radiusY = Math.sin(angle) * positions[2] / 2;
  41491. point.tooltipPos = [
  41492. positions[0] + radiusX * 0.7,
  41493. positions[1] + radiusY * 0.7
  41494. ];
  41495. point.half = angle < -Math.PI / 2 || angle > Math.PI / 2 ?
  41496. 1 :
  41497. 0;
  41498. point.angle = angle;
  41499. // Set the anchor point for data labels. Use point.labelDistance
  41500. // instead of labelDistance // #1174
  41501. // finalConnectorOffset - not override connectorOffset value.
  41502. finalConnectorOffset = Math.min(connectorOffset, point.labelDistance / 5); // #1678
  41503. point.labelPosition = {
  41504. natural: {
  41505. // initial position of the data label - it's utilized for
  41506. // finding the final position for the label
  41507. x: positions[0] + radiusX + Math.cos(angle) *
  41508. point.labelDistance,
  41509. y: positions[1] + radiusY + Math.sin(angle) *
  41510. point.labelDistance
  41511. },
  41512. 'final': {
  41513. // used for generating connector path -
  41514. // initialized later in drawDataLabels function
  41515. // x: undefined,
  41516. // y: undefined
  41517. },
  41518. // left - pie on the left side of the data label
  41519. // right - pie on the right side of the data label
  41520. // center - data label overlaps the pie
  41521. alignment: point.labelDistance < 0 ?
  41522. 'center' : point.half ? 'right' : 'left',
  41523. connectorPosition: {
  41524. breakAt: {
  41525. x: positions[0] + radiusX + Math.cos(angle) *
  41526. finalConnectorOffset,
  41527. y: positions[1] + radiusY + Math.sin(angle) *
  41528. finalConnectorOffset
  41529. },
  41530. touchingSliceAt: {
  41531. x: positions[0] + radiusX,
  41532. y: positions[1] + radiusY
  41533. }
  41534. }
  41535. };
  41536. }
  41537. fireEvent(series, 'afterTranslate');
  41538. },
  41539. /**
  41540. * Called internally to draw auxiliary graph in pie-like series in
  41541. * situtation when the default graph is not sufficient enough to present
  41542. * the data well. Auxiliary graph is saved in the same object as
  41543. * regular graph.
  41544. *
  41545. * @private
  41546. * @function Highcharts.seriesTypes.pie#drawEmpty
  41547. */
  41548. drawEmpty: function () {
  41549. var centerX,
  41550. centerY,
  41551. start = this.startAngleRad,
  41552. end = this.endAngleRad,
  41553. options = this.options;
  41554. // Draw auxiliary graph if there're no visible points.
  41555. if (this.total === 0 && this.center) {
  41556. centerX = this.center[0];
  41557. centerY = this.center[1];
  41558. if (!this.graph) {
  41559. this.graph = this.chart.renderer
  41560. .arc(centerX, centerY, this.center[1] / 2, 0, start, end)
  41561. .addClass('highcharts-empty-series')
  41562. .add(this.group);
  41563. }
  41564. this.graph.attr({
  41565. d: SVGRenderer.prototype.symbols.arc(centerX, centerY, this.center[2] / 2, 0, {
  41566. start: start,
  41567. end: end,
  41568. innerR: this.center[3] / 2
  41569. })
  41570. });
  41571. if (!this.chart.styledMode) {
  41572. this.graph.attr({
  41573. 'stroke-width': options.borderWidth,
  41574. fill: options.fillColor || 'none',
  41575. stroke: options.color ||
  41576. '#cccccc'
  41577. });
  41578. }
  41579. }
  41580. else if (this.graph) { // Destroy the graph object.
  41581. this.graph = this.graph.destroy();
  41582. }
  41583. },
  41584. /**
  41585. * Draw the data points
  41586. *
  41587. * @private
  41588. * @function Highcharts.seriesTypes.pie#drawPoints
  41589. * @return {void}
  41590. */
  41591. redrawPoints: function () {
  41592. var series = this,
  41593. chart = series.chart,
  41594. renderer = chart.renderer,
  41595. groupTranslation,
  41596. graphic,
  41597. pointAttr,
  41598. shapeArgs,
  41599. shadow = series.options.shadow;
  41600. this.drawEmpty();
  41601. if (shadow && !series.shadowGroup && !chart.styledMode) {
  41602. series.shadowGroup = renderer.g('shadow')
  41603. .attr({ zIndex: -1 })
  41604. .add(series.group);
  41605. }
  41606. // draw the slices
  41607. series.points.forEach(function (point) {
  41608. var animateTo = {};
  41609. graphic = point.graphic;
  41610. if (!point.isNull && graphic) {
  41611. shapeArgs = point.shapeArgs;
  41612. // If the point is sliced, use special translation, else use
  41613. // plot area translation
  41614. groupTranslation = point.getTranslate();
  41615. if (!chart.styledMode) {
  41616. // Put the shadow behind all points
  41617. var shadowGroup = point.shadowGroup;
  41618. if (shadow && !shadowGroup) {
  41619. shadowGroup = point.shadowGroup = renderer
  41620. .g('shadow')
  41621. .add(series.shadowGroup);
  41622. }
  41623. if (shadowGroup) {
  41624. shadowGroup.attr(groupTranslation);
  41625. }
  41626. pointAttr = series.pointAttribs(point, (point.selected && 'select'));
  41627. }
  41628. // Draw the slice
  41629. if (!point.delayedRendering) {
  41630. graphic
  41631. .setRadialReference(series.center);
  41632. if (!chart.styledMode) {
  41633. merge(true, animateTo, pointAttr);
  41634. }
  41635. merge(true, animateTo, shapeArgs, groupTranslation);
  41636. graphic.animate(animateTo);
  41637. }
  41638. else {
  41639. graphic
  41640. .setRadialReference(series.center)
  41641. .attr(shapeArgs)
  41642. .attr(groupTranslation);
  41643. if (!chart.styledMode) {
  41644. graphic
  41645. .attr(pointAttr)
  41646. .attr({ 'stroke-linejoin': 'round' })
  41647. .shadow(shadow, shadowGroup);
  41648. }
  41649. point.delayedRendering = false;
  41650. }
  41651. graphic.attr({
  41652. visibility: point.visible ? 'inherit' : 'hidden'
  41653. });
  41654. graphic.addClass(point.getClassName());
  41655. }
  41656. else if (graphic) {
  41657. point.graphic = graphic.destroy();
  41658. }
  41659. });
  41660. },
  41661. /**
  41662. * Slices in pie chart are initialized in DOM, but it's shapes and
  41663. * animations are normally run in `drawPoints()`.
  41664. * @private
  41665. */
  41666. drawPoints: function () {
  41667. var renderer = this.chart.renderer;
  41668. this.points.forEach(function (point) {
  41669. // When updating a series between 2d and 3d or cartesian and
  41670. // polar, the shape type changes.
  41671. if (point.graphic && point.hasNewShapeType()) {
  41672. point.graphic = point.graphic.destroy();
  41673. }
  41674. if (!point.graphic) {
  41675. point.graphic = renderer[point.shapeType](point.shapeArgs)
  41676. .add(point.series.group);
  41677. point.delayedRendering = true;
  41678. }
  41679. });
  41680. },
  41681. /**
  41682. * @private
  41683. * @deprecated
  41684. * @function Highcharts.seriesTypes.pie#searchPoint
  41685. */
  41686. searchPoint: noop,
  41687. /**
  41688. * Utility for sorting data labels
  41689. *
  41690. * @private
  41691. * @function Highcharts.seriesTypes.pie#sortByAngle
  41692. * @param {Array<Highcharts.Point>} points
  41693. * @param {number} sign
  41694. * @return {void}
  41695. */
  41696. sortByAngle: function (points, sign) {
  41697. points.sort(function (a, b) {
  41698. return ((typeof a.angle !== 'undefined') &&
  41699. (b.angle - a.angle) * sign);
  41700. });
  41701. },
  41702. /**
  41703. * Use a simple symbol from LegendSymbolMixin.
  41704. *
  41705. * @private
  41706. * @borrows Highcharts.LegendSymbolMixin.drawRectangle as Highcharts.seriesTypes.pie#drawLegendSymbol
  41707. */
  41708. drawLegendSymbol: LegendSymbolMixin.drawRectangle,
  41709. /**
  41710. * Use the getCenter method from drawLegendSymbol.
  41711. *
  41712. * @private
  41713. * @borrows Highcharts.CenteredSeriesMixin.getCenter as Highcharts.seriesTypes.pie#getCenter
  41714. */
  41715. getCenter: CenteredSeriesMixin.getCenter,
  41716. /**
  41717. * Pies don't have point marker symbols.
  41718. *
  41719. * @deprecated
  41720. * @private
  41721. * @function Highcharts.seriesTypes.pie#getSymbol
  41722. */
  41723. getSymbol: noop,
  41724. /**
  41725. * @private
  41726. * @type {null}
  41727. */
  41728. drawGraph: null
  41729. },
  41730. /**
  41731. * @lends seriesTypes.pie.prototype.pointClass.prototype
  41732. */
  41733. {
  41734. /**
  41735. * Initialize the pie slice
  41736. *
  41737. * @private
  41738. * @function Highcharts.seriesTypes.pie#pointClass#init
  41739. * @return {Highcharts.Point}
  41740. */
  41741. init: function () {
  41742. Point.prototype.init.apply(this, arguments);
  41743. var point = this,
  41744. toggleSlice;
  41745. point.name = pick(point.name, 'Slice');
  41746. // add event listener for select
  41747. toggleSlice = function (e) {
  41748. point.slice(e.type === 'select');
  41749. };
  41750. addEvent(point, 'select', toggleSlice);
  41751. addEvent(point, 'unselect', toggleSlice);
  41752. return point;
  41753. },
  41754. /**
  41755. * Negative points are not valid (#1530, #3623, #5322)
  41756. *
  41757. * @private
  41758. * @function Highcharts.seriesTypes.pie#pointClass#isValid
  41759. * @return {boolean}
  41760. */
  41761. isValid: function () {
  41762. return isNumber(this.y) && this.y >= 0;
  41763. },
  41764. /**
  41765. * Toggle the visibility of the pie slice
  41766. *
  41767. * @private
  41768. * @function Highcharts.seriesTypes.pie#pointClass#setVisible
  41769. * @param {boolean} vis
  41770. * Whether to show the slice or not. If undefined, the visibility
  41771. * is toggled.
  41772. * @param {boolean} [redraw=false]
  41773. * @return {void}
  41774. */
  41775. setVisible: function (vis, redraw) {
  41776. var point = this,
  41777. series = point.series,
  41778. chart = series.chart,
  41779. ignoreHiddenPoint = series.options.ignoreHiddenPoint;
  41780. redraw = pick(redraw, ignoreHiddenPoint);
  41781. if (vis !== point.visible) {
  41782. // If called without an argument, toggle visibility
  41783. point.visible = point.options.visible = vis =
  41784. typeof vis === 'undefined' ? !point.visible : vis;
  41785. // update userOptions.data
  41786. series.options.data[series.data.indexOf(point)] =
  41787. point.options;
  41788. // Show and hide associated elements. This is performed
  41789. // regardless of redraw or not, because chart.redraw only
  41790. // handles full series.
  41791. ['graphic', 'dataLabel', 'connector', 'shadowGroup'].forEach(function (key) {
  41792. if (point[key]) {
  41793. point[key][vis ? 'show' : 'hide'](true);
  41794. }
  41795. });
  41796. if (point.legendItem) {
  41797. chart.legend.colorizeItem(point, vis);
  41798. }
  41799. // #4170, hide halo after hiding point
  41800. if (!vis && point.state === 'hover') {
  41801. point.setState('');
  41802. }
  41803. // Handle ignore hidden slices
  41804. if (ignoreHiddenPoint) {
  41805. series.isDirty = true;
  41806. }
  41807. if (redraw) {
  41808. chart.redraw();
  41809. }
  41810. }
  41811. },
  41812. /**
  41813. * Set or toggle whether the slice is cut out from the pie
  41814. *
  41815. * @private
  41816. * @function Highcharts.seriesTypes.pie#pointClass#slice
  41817. * @param {boolean} sliced
  41818. * When undefined, the slice state is toggled.
  41819. * @param {boolean} redraw
  41820. * Whether to redraw the chart. True by default.
  41821. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>}
  41822. * Animation options.
  41823. * @return {void}
  41824. */
  41825. slice: function (sliced, redraw, animation) {
  41826. var point = this,
  41827. series = point.series,
  41828. chart = series.chart;
  41829. setAnimation(animation, chart);
  41830. // redraw is true by default
  41831. redraw = pick(redraw, true);
  41832. /**
  41833. * Pie series only. Whether to display a slice offset from the
  41834. * center.
  41835. * @name Highcharts.Point#sliced
  41836. * @type {boolean|undefined}
  41837. */
  41838. // if called without an argument, toggle
  41839. point.sliced = point.options.sliced = sliced =
  41840. defined(sliced) ? sliced : !point.sliced;
  41841. // update userOptions.data
  41842. series.options.data[series.data.indexOf(point)] =
  41843. point.options;
  41844. if (point.graphic) {
  41845. point.graphic.animate(this.getTranslate());
  41846. }
  41847. if (point.shadowGroup) {
  41848. point.shadowGroup.animate(this.getTranslate());
  41849. }
  41850. },
  41851. /**
  41852. * @private
  41853. * @function Highcharts.seriesTypes.pie#pointClass#getTranslate
  41854. * @return {Highcharts.TranslationAttributes}
  41855. */
  41856. getTranslate: function () {
  41857. return this.sliced ? this.slicedTranslation : {
  41858. translateX: 0,
  41859. translateY: 0
  41860. };
  41861. },
  41862. /**
  41863. * @private
  41864. * @function Highcharts.seriesTypes.pie#pointClass#haloPath
  41865. * @param {number} size
  41866. * @return {Highcharts.SVGPathArray}
  41867. */
  41868. haloPath: function (size) {
  41869. var shapeArgs = this.shapeArgs;
  41870. return this.sliced || !this.visible ?
  41871. [] :
  41872. this.series.chart.renderer.symbols.arc(shapeArgs.x, shapeArgs.y, shapeArgs.r + size, shapeArgs.r + size, {
  41873. // Substract 1px to ensure the background is not bleeding
  41874. // through between the halo and the slice (#7495).
  41875. innerR: shapeArgs.r - 1,
  41876. start: shapeArgs.start,
  41877. end: shapeArgs.end
  41878. });
  41879. },
  41880. connectorShapes: {
  41881. // only one available before v7.0.0
  41882. fixedOffset: function (labelPosition, connectorPosition, options) {
  41883. var breakAt = connectorPosition.breakAt,
  41884. touchingSliceAt = connectorPosition.touchingSliceAt,
  41885. lineSegment = options.softConnector ? [
  41886. 'C',
  41887. // 1st control point (of the curve)
  41888. labelPosition.x +
  41889. // 5 gives the connector a little horizontal bend
  41890. (labelPosition.alignment === 'left' ? -5 : 5),
  41891. labelPosition.y,
  41892. 2 * breakAt.x - touchingSliceAt.x,
  41893. 2 * breakAt.y - touchingSliceAt.y,
  41894. breakAt.x,
  41895. breakAt.y //
  41896. ] : [
  41897. 'L',
  41898. breakAt.x,
  41899. breakAt.y
  41900. ];
  41901. // assemble the path
  41902. return ([
  41903. ['M', labelPosition.x, labelPosition.y],
  41904. lineSegment,
  41905. ['L', touchingSliceAt.x, touchingSliceAt.y]
  41906. ]);
  41907. },
  41908. straight: function (labelPosition, connectorPosition) {
  41909. var touchingSliceAt = connectorPosition.touchingSliceAt;
  41910. // direct line to the slice
  41911. return [
  41912. ['M', labelPosition.x, labelPosition.y],
  41913. ['L', touchingSliceAt.x, touchingSliceAt.y]
  41914. ];
  41915. },
  41916. crookedLine: function (labelPosition, connectorPosition, options) {
  41917. var touchingSliceAt = connectorPosition.touchingSliceAt,
  41918. series = this.series,
  41919. pieCenterX = series.center[0],
  41920. plotWidth = series.chart.plotWidth,
  41921. plotLeft = series.chart.plotLeft,
  41922. alignment = labelPosition.alignment,
  41923. radius = this.shapeArgs.r,
  41924. crookDistance = relativeLength(// % to fraction
  41925. options.crookDistance, 1),
  41926. crookX = alignment === 'left' ?
  41927. pieCenterX + radius + (plotWidth + plotLeft -
  41928. pieCenterX - radius) * (1 - crookDistance) :
  41929. plotLeft + (pieCenterX - radius) * crookDistance,
  41930. segmentWithCrook = [
  41931. 'L',
  41932. crookX,
  41933. labelPosition.y
  41934. ],
  41935. useCrook = true;
  41936. // crookedLine formula doesn't make sense if the path overlaps
  41937. // the label - use straight line instead in that case
  41938. if (alignment === 'left' ?
  41939. (crookX > labelPosition.x || crookX < touchingSliceAt.x) :
  41940. (crookX < labelPosition.x || crookX > touchingSliceAt.x)) {
  41941. useCrook = false;
  41942. }
  41943. // assemble the path
  41944. var path = [
  41945. ['M',
  41946. labelPosition.x,
  41947. labelPosition.y]
  41948. ];
  41949. if (useCrook) {
  41950. path.push(segmentWithCrook);
  41951. }
  41952. path.push(['L', touchingSliceAt.x, touchingSliceAt.y]);
  41953. return path;
  41954. }
  41955. },
  41956. /**
  41957. * Extendable method for getting the path of the connector between the
  41958. * data label and the pie slice.
  41959. */
  41960. getConnectorPath: function () {
  41961. var labelPosition = this.labelPosition,
  41962. options = this.series.options.dataLabels,
  41963. connectorShape = options.connectorShape,
  41964. predefinedShapes = this.connectorShapes;
  41965. // find out whether to use the predefined shape
  41966. if (predefinedShapes[connectorShape]) {
  41967. connectorShape = predefinedShapes[connectorShape];
  41968. }
  41969. return connectorShape.call(this, {
  41970. // pass simplified label position object for user's convenience
  41971. x: labelPosition.final.x,
  41972. y: labelPosition.final.y,
  41973. alignment: labelPosition.alignment
  41974. }, labelPosition.connectorPosition, options);
  41975. }
  41976. }
  41977. /* eslint-enable valid-jsdoc */
  41978. );
  41979. /**
  41980. * A `pie` series. If the [type](#series.pie.type) option is not specified,
  41981. * it is inherited from [chart.type](#chart.type).
  41982. *
  41983. * @extends series,plotOptions.pie
  41984. * @excluding cropThreshold, dataParser, dataURL, stack, xAxis, yAxis,
  41985. * dataSorting, step, boostThreshold, boostBlending
  41986. * @product highcharts
  41987. * @apioption series.pie
  41988. */
  41989. /**
  41990. * An array of data points for the series. For the `pie` series type,
  41991. * points can be given in the following ways:
  41992. *
  41993. * 1. An array of numerical values. In this case, the numerical values will be
  41994. * interpreted as `y` options. Example:
  41995. * ```js
  41996. * data: [0, 5, 3, 5]
  41997. * ```
  41998. *
  41999. * 2. An array of objects with named values. The following snippet shows only a
  42000. * few settings, see the complete options set below. If the total number of
  42001. * data points exceeds the series'
  42002. * [turboThreshold](#series.pie.turboThreshold),
  42003. * this option is not available.
  42004. * ```js
  42005. * data: [{
  42006. * y: 1,
  42007. * name: "Point2",
  42008. * color: "#00FF00"
  42009. * }, {
  42010. * y: 7,
  42011. * name: "Point1",
  42012. * color: "#FF00FF"
  42013. * }]
  42014. * ```
  42015. *
  42016. * @sample {highcharts} highcharts/chart/reflow-true/
  42017. * Numerical values
  42018. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  42019. * Arrays of numeric x and y
  42020. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  42021. * Arrays of datetime x and y
  42022. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  42023. * Arrays of point.name and y
  42024. * @sample {highcharts} highcharts/series/data-array-of-objects/
  42025. * Config objects
  42026. *
  42027. * @type {Array<number|Array<string,(number|null)>|null|*>}
  42028. * @extends series.line.data
  42029. * @excluding marker, x
  42030. * @product highcharts
  42031. * @apioption series.pie.data
  42032. */
  42033. /**
  42034. * @type {Highcharts.SeriesPieDataLabelsOptionsObject}
  42035. * @product highcharts
  42036. * @apioption series.pie.data.dataLabels
  42037. */
  42038. /**
  42039. * The sequential index of the data point in the legend.
  42040. *
  42041. * @type {number}
  42042. * @product highcharts
  42043. * @apioption series.pie.data.legendIndex
  42044. */
  42045. /**
  42046. * Whether to display a slice offset from the center.
  42047. *
  42048. * @sample {highcharts} highcharts/point/sliced/
  42049. * One sliced point
  42050. *
  42051. * @type {boolean}
  42052. * @product highcharts
  42053. * @apioption series.pie.data.sliced
  42054. */
  42055. /**
  42056. * @excluding legendItemClick
  42057. * @product highcharts
  42058. * @apioption series.pie.events
  42059. */
  42060. ''; // placeholder for transpiled doclets above
  42061. });
  42062. _registerModule(_modules, 'Core/Series/DataLabels.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Globals.js'], _modules['Core/Series/CartesianSeries.js'], _modules['Core/Utilities.js']], function (A, H, CartesianSeries, U) {
  42063. /* *
  42064. *
  42065. * (c) 2010-2020 Torstein Honsi
  42066. *
  42067. * License: www.highcharts.com/license
  42068. *
  42069. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  42070. *
  42071. * */
  42072. var getDeferredAnimation = A.getDeferredAnimation;
  42073. var noop = H.noop,
  42074. seriesTypes = H.seriesTypes;
  42075. var arrayMax = U.arrayMax,
  42076. clamp = U.clamp,
  42077. defined = U.defined,
  42078. extend = U.extend,
  42079. fireEvent = U.fireEvent,
  42080. format = U.format,
  42081. isArray = U.isArray,
  42082. merge = U.merge,
  42083. objectEach = U.objectEach,
  42084. pick = U.pick,
  42085. relativeLength = U.relativeLength,
  42086. splat = U.splat,
  42087. stableSort = U.stableSort;
  42088. /**
  42089. * Callback JavaScript function to format the data label as a string. Note that
  42090. * if a `format` is defined, the format takes precedence and the formatter is
  42091. * ignored.
  42092. *
  42093. * @callback Highcharts.DataLabelsFormatterCallbackFunction
  42094. *
  42095. * @param {Highcharts.PointLabelObject} this
  42096. * Data label context to format
  42097. *
  42098. * @param {Highcharts.DataLabelsOptions} options
  42099. * [API options](/highcharts/plotOptions.series.dataLabels) of the data label
  42100. *
  42101. * @return {number|string|null|undefined}
  42102. * Formatted data label text
  42103. */
  42104. /**
  42105. * Values for handling data labels that flow outside the plot area.
  42106. *
  42107. * @typedef {"allow"|"justify"} Highcharts.DataLabelsOverflowValue
  42108. */
  42109. ''; // detach doclets above
  42110. /* eslint-disable valid-jsdoc */
  42111. /**
  42112. * General distribution algorithm for distributing labels of differing size
  42113. * along a confined length in two dimensions. The algorithm takes an array of
  42114. * objects containing a size, a target and a rank. It will place the labels as
  42115. * close as possible to their targets, skipping the lowest ranked labels if
  42116. * necessary.
  42117. *
  42118. * @private
  42119. * @function Highcharts.distribute
  42120. * @param {Highcharts.DataLabelsBoxArray} boxes
  42121. * @param {number} len
  42122. * @param {number} [maxDistance]
  42123. * @return {void}
  42124. */
  42125. H.distribute = function (boxes, len, maxDistance) {
  42126. var i,
  42127. overlapping = true,
  42128. origBoxes = boxes, // Original array will be altered with added .pos
  42129. restBoxes = [], // The outranked overshoot
  42130. box,
  42131. target,
  42132. total = 0,
  42133. reducedLen = origBoxes.reducedLen || len;
  42134. /**
  42135. * @private
  42136. */
  42137. function sortByTarget(a, b) {
  42138. return a.target - b.target;
  42139. }
  42140. // If the total size exceeds the len, remove those boxes with the lowest
  42141. // rank
  42142. i = boxes.length;
  42143. while (i--) {
  42144. total += boxes[i].size;
  42145. }
  42146. // Sort by rank, then slice away overshoot
  42147. if (total > reducedLen) {
  42148. stableSort(boxes, function (a, b) {
  42149. return (b.rank || 0) - (a.rank || 0);
  42150. });
  42151. i = 0;
  42152. total = 0;
  42153. while (total <= reducedLen) {
  42154. total += boxes[i].size;
  42155. i++;
  42156. }
  42157. restBoxes = boxes.splice(i - 1, boxes.length);
  42158. }
  42159. // Order by target
  42160. stableSort(boxes, sortByTarget);
  42161. // So far we have been mutating the original array. Now
  42162. // create a copy with target arrays
  42163. boxes = boxes.map(function (box) {
  42164. return {
  42165. size: box.size,
  42166. targets: [box.target],
  42167. align: pick(box.align, 0.5)
  42168. };
  42169. });
  42170. while (overlapping) {
  42171. // Initial positions: target centered in box
  42172. i = boxes.length;
  42173. while (i--) {
  42174. box = boxes[i];
  42175. // Composite box, average of targets
  42176. target = (Math.min.apply(0, box.targets) +
  42177. Math.max.apply(0, box.targets)) / 2;
  42178. box.pos = clamp(target - box.size * box.align, 0, len - box.size);
  42179. }
  42180. // Detect overlap and join boxes
  42181. i = boxes.length;
  42182. overlapping = false;
  42183. while (i--) {
  42184. // Overlap
  42185. if (i > 0 &&
  42186. boxes[i - 1].pos + boxes[i - 1].size >
  42187. boxes[i].pos) {
  42188. // Add this size to the previous box
  42189. boxes[i - 1].size += boxes[i].size;
  42190. boxes[i - 1].targets = boxes[i - 1]
  42191. .targets
  42192. .concat(boxes[i].targets);
  42193. boxes[i - 1].align = 0.5;
  42194. // Overlapping right, push left
  42195. if (boxes[i - 1].pos + boxes[i - 1].size > len) {
  42196. boxes[i - 1].pos = len - boxes[i - 1].size;
  42197. }
  42198. boxes.splice(i, 1); // Remove this item
  42199. overlapping = true;
  42200. }
  42201. }
  42202. }
  42203. // Add the rest (hidden boxes)
  42204. origBoxes.push.apply(origBoxes, restBoxes);
  42205. // Now the composite boxes are placed, we need to put the original boxes
  42206. // within them
  42207. i = 0;
  42208. boxes.some(function (box) {
  42209. var posInCompositeBox = 0;
  42210. if (box.targets.some(function () {
  42211. origBoxes[i].pos = box.pos + posInCompositeBox;
  42212. // If the distance between the position and the target exceeds
  42213. // maxDistance, abort the loop and decrease the length in increments
  42214. // of 10% to recursively reduce the number of visible boxes by
  42215. // rank. Once all boxes are within the maxDistance, we're good.
  42216. if (typeof maxDistance !== 'undefined' &&
  42217. Math.abs(origBoxes[i].pos - origBoxes[i].target) > maxDistance) {
  42218. // Reset the positions that are already set
  42219. origBoxes.slice(0, i + 1).forEach(function (box) {
  42220. delete box.pos;
  42221. });
  42222. // Try with a smaller length
  42223. origBoxes.reducedLen =
  42224. (origBoxes.reducedLen || len) - (len * 0.1);
  42225. // Recurse
  42226. if (origBoxes.reducedLen > len * 0.1) {
  42227. H.distribute(origBoxes, len, maxDistance);
  42228. }
  42229. // Exceeded maxDistance => abort
  42230. return true;
  42231. }
  42232. posInCompositeBox += origBoxes[i].size;
  42233. i++;
  42234. })) {
  42235. // Exceeded maxDistance => abort
  42236. return true;
  42237. }
  42238. });
  42239. // Add the rest (hidden) boxes and sort by target
  42240. stableSort(origBoxes, sortByTarget);
  42241. };
  42242. /**
  42243. * Draw the data labels
  42244. *
  42245. * @private
  42246. * @function Highcharts.Series#drawDataLabels
  42247. * @return {void}
  42248. * @fires Highcharts.Series#event:afterDrawDataLabels
  42249. */
  42250. CartesianSeries.prototype.drawDataLabels = function () {
  42251. var series = this,
  42252. chart = series.chart,
  42253. seriesOptions = series.options,
  42254. seriesDlOptions = seriesOptions.dataLabels,
  42255. points = series.points,
  42256. pointOptions,
  42257. hasRendered = series.hasRendered || 0,
  42258. dataLabelsGroup,
  42259. dataLabelAnim = seriesDlOptions.animation,
  42260. animationConfig = seriesDlOptions.defer ?
  42261. getDeferredAnimation(chart,
  42262. dataLabelAnim,
  42263. series) :
  42264. { defer: 0,
  42265. duration: 0 },
  42266. renderer = chart.renderer;
  42267. /**
  42268. * Handle the dataLabels.filter option.
  42269. * @private
  42270. */
  42271. function applyFilter(point, options) {
  42272. var filter = options.filter,
  42273. op,
  42274. prop,
  42275. val;
  42276. if (filter) {
  42277. op = filter.operator;
  42278. prop = point[filter.property];
  42279. val = filter.value;
  42280. if ((op === '>' && prop > val) ||
  42281. (op === '<' && prop < val) ||
  42282. (op === '>=' && prop >= val) ||
  42283. (op === '<=' && prop <= val) ||
  42284. (op === '==' && prop == val) || // eslint-disable-line eqeqeq
  42285. (op === '===' && prop === val)) {
  42286. return true;
  42287. }
  42288. return false;
  42289. }
  42290. return true;
  42291. }
  42292. /**
  42293. * Merge two objects that can be arrays. If one of them is an array, the
  42294. * other is merged into each element. If both are arrays, each element is
  42295. * merged by index. If neither are arrays, we use normal merge.
  42296. * @private
  42297. */
  42298. function mergeArrays(one, two) {
  42299. var res = [],
  42300. i;
  42301. if (isArray(one) && !isArray(two)) {
  42302. res = one.map(function (el) {
  42303. return merge(el, two);
  42304. });
  42305. }
  42306. else if (isArray(two) && !isArray(one)) {
  42307. res = two.map(function (el) {
  42308. return merge(one, el);
  42309. });
  42310. }
  42311. else if (!isArray(one) && !isArray(two)) {
  42312. res = merge(one, two);
  42313. }
  42314. else {
  42315. i = Math.max(one.length, two.length);
  42316. while (i--) {
  42317. res[i] = merge(one[i], two[i]);
  42318. }
  42319. }
  42320. return res;
  42321. }
  42322. // Merge in plotOptions.dataLabels for series
  42323. seriesDlOptions = mergeArrays(mergeArrays(chart.options.plotOptions &&
  42324. chart.options.plotOptions.series &&
  42325. chart.options.plotOptions.series.dataLabels, chart.options.plotOptions &&
  42326. chart.options.plotOptions[series.type] &&
  42327. chart.options.plotOptions[series.type].dataLabels), seriesDlOptions);
  42328. fireEvent(this, 'drawDataLabels');
  42329. if (isArray(seriesDlOptions) ||
  42330. seriesDlOptions.enabled ||
  42331. series._hasPointLabels) {
  42332. // Create a separate group for the data labels to avoid rotation
  42333. dataLabelsGroup = series.plotGroup('dataLabelsGroup', 'data-labels', !hasRendered ? 'hidden' : 'inherit', // #5133, #10220
  42334. seriesDlOptions.zIndex || 6);
  42335. dataLabelsGroup.attr({ opacity: +hasRendered }); // #3300
  42336. if (!hasRendered) {
  42337. var group = series.dataLabelsGroup;
  42338. if (group) {
  42339. if (series.visible) { // #2597, #3023, #3024
  42340. dataLabelsGroup.show(true);
  42341. }
  42342. group[seriesOptions.animation ? 'animate' : 'attr']({ opacity: 1 }, animationConfig);
  42343. }
  42344. }
  42345. // Make the labels for each point
  42346. points.forEach(function (point) {
  42347. // Merge in series options for the point.
  42348. // @note dataLabelAttribs (like pointAttribs) would eradicate
  42349. // the need for dlOptions, and simplify the section below.
  42350. pointOptions = splat(mergeArrays(seriesDlOptions, point.dlOptions || // dlOptions is used in treemaps
  42351. (point.options && point.options.dataLabels)));
  42352. // Handle each individual data label for this point
  42353. pointOptions.forEach(function (labelOptions, i) {
  42354. // Options for one datalabel
  42355. var labelEnabled = (labelOptions.enabled &&
  42356. // #2282, #4641, #7112, #10049
  42357. (!point.isNull || point.dataLabelOnNull) &&
  42358. applyFilter(point,
  42359. labelOptions)),
  42360. labelConfig,
  42361. formatString,
  42362. labelText,
  42363. style,
  42364. rotation,
  42365. attr,
  42366. dataLabel = point.dataLabels ? point.dataLabels[i] :
  42367. point.dataLabel,
  42368. connector = point.connectors ? point.connectors[i] :
  42369. point.connector,
  42370. labelDistance = pick(labelOptions.distance,
  42371. point.labelDistance),
  42372. isNew = !dataLabel;
  42373. if (labelEnabled) {
  42374. // Create individual options structure that can be extended
  42375. // without affecting others
  42376. labelConfig = point.getLabelConfig();
  42377. formatString = pick(labelOptions[point.formatPrefix + 'Format'], labelOptions.format);
  42378. labelText = defined(formatString) ?
  42379. format(formatString, labelConfig, chart) :
  42380. (labelOptions[point.formatPrefix + 'Formatter'] ||
  42381. labelOptions.formatter).call(labelConfig, labelOptions);
  42382. style = labelOptions.style;
  42383. rotation = labelOptions.rotation;
  42384. if (!chart.styledMode) {
  42385. // Determine the color
  42386. style.color = pick(labelOptions.color, style.color, series.color, '#000000');
  42387. // Get automated contrast color
  42388. if (style.color === 'contrast') {
  42389. point.contrastColor = renderer.getContrast((point.color || series.color));
  42390. style.color = (!defined(labelDistance) &&
  42391. labelOptions.inside) ||
  42392. labelDistance < 0 ||
  42393. !!seriesOptions.stacking ?
  42394. point.contrastColor :
  42395. '#000000';
  42396. }
  42397. else {
  42398. delete point.contrastColor;
  42399. }
  42400. if (seriesOptions.cursor) {
  42401. style.cursor = seriesOptions.cursor;
  42402. }
  42403. }
  42404. attr = {
  42405. r: labelOptions.borderRadius || 0,
  42406. rotation: rotation,
  42407. padding: labelOptions.padding,
  42408. zIndex: 1
  42409. };
  42410. if (!chart.styledMode) {
  42411. attr.fill = labelOptions.backgroundColor;
  42412. attr.stroke = labelOptions.borderColor;
  42413. attr['stroke-width'] = labelOptions.borderWidth;
  42414. }
  42415. // Remove unused attributes (#947)
  42416. objectEach(attr, function (val, name) {
  42417. if (typeof val === 'undefined') {
  42418. delete attr[name];
  42419. }
  42420. });
  42421. }
  42422. // If the point is outside the plot area, destroy it. #678, #820
  42423. if (dataLabel && (!labelEnabled || !defined(labelText))) {
  42424. point.dataLabel =
  42425. point.dataLabel && point.dataLabel.destroy();
  42426. if (point.dataLabels) {
  42427. // Remove point.dataLabels if this was the last one
  42428. if (point.dataLabels.length === 1) {
  42429. delete point.dataLabels;
  42430. }
  42431. else {
  42432. delete point.dataLabels[i];
  42433. }
  42434. }
  42435. if (!i) {
  42436. delete point.dataLabel;
  42437. }
  42438. if (connector) {
  42439. point.connector = point.connector.destroy();
  42440. if (point.connectors) {
  42441. // Remove point.connectors if this was the last one
  42442. if (point.connectors.length === 1) {
  42443. delete point.connectors;
  42444. }
  42445. else {
  42446. delete point.connectors[i];
  42447. }
  42448. }
  42449. }
  42450. // Individual labels are disabled if the are explicitly disabled
  42451. // in the point options, or if they fall outside the plot area.
  42452. }
  42453. else if (labelEnabled && defined(labelText)) {
  42454. if (!dataLabel) {
  42455. // Create new label element
  42456. point.dataLabels = point.dataLabels || [];
  42457. dataLabel = point.dataLabels[i] = rotation ?
  42458. // Labels don't rotate, use text element
  42459. renderer.text(labelText, 0, -9999, labelOptions.useHTML)
  42460. .addClass('highcharts-data-label') :
  42461. // We can use label
  42462. renderer.label(labelText, 0, -9999, labelOptions.shape, null, null, labelOptions.useHTML, null, 'data-label');
  42463. // Store for backwards compatibility
  42464. if (!i) {
  42465. point.dataLabel = dataLabel;
  42466. }
  42467. dataLabel.addClass(' highcharts-data-label-color-' + point.colorIndex +
  42468. ' ' + (labelOptions.className || '') +
  42469. ( // #3398
  42470. labelOptions.useHTML ?
  42471. ' highcharts-tracker' :
  42472. ''));
  42473. }
  42474. else {
  42475. // Use old element and just update text
  42476. attr.text = labelText;
  42477. }
  42478. // Store data label options for later access
  42479. dataLabel.options = labelOptions;
  42480. dataLabel.attr(attr);
  42481. if (!chart.styledMode) {
  42482. // Styles must be applied before add in order to read
  42483. // text bounding box
  42484. dataLabel.css(style).shadow(labelOptions.shadow);
  42485. }
  42486. if (!dataLabel.added) {
  42487. dataLabel.add(dataLabelsGroup);
  42488. }
  42489. if (labelOptions.textPath && !labelOptions.useHTML) {
  42490. dataLabel.setTextPath((point.getDataLabelPath &&
  42491. point.getDataLabelPath(dataLabel)) || point.graphic, labelOptions.textPath);
  42492. if (point.dataLabelPath &&
  42493. !labelOptions.textPath.enabled) {
  42494. // clean the DOM
  42495. point.dataLabelPath = point.dataLabelPath.destroy();
  42496. }
  42497. }
  42498. // Now the data label is created and placed at 0,0, so we
  42499. // need to align it
  42500. series.alignDataLabel(point, dataLabel, labelOptions, null, isNew);
  42501. }
  42502. });
  42503. });
  42504. }
  42505. fireEvent(this, 'afterDrawDataLabels');
  42506. };
  42507. /**
  42508. * Align each individual data label.
  42509. *
  42510. * @private
  42511. * @function Highcharts.Series#alignDataLabel
  42512. * @param {Highcharts.Point} point
  42513. * @param {Highcharts.SVGElement} dataLabel
  42514. * @param {Highcharts.DataLabelsOptions} options
  42515. * @param {Highcharts.BBoxObject} alignTo
  42516. * @param {boolean} [isNew]
  42517. * @return {void}
  42518. */
  42519. CartesianSeries.prototype.alignDataLabel = function (point, dataLabel, options, alignTo, isNew) {
  42520. var series = this,
  42521. chart = this.chart,
  42522. inverted = this.isCartesian && chart.inverted,
  42523. enabledDataSorting = this.enabledDataSorting,
  42524. plotX = pick(point.dlBox && point.dlBox.centerX,
  42525. point.plotX, -9999),
  42526. plotY = pick(point.plotY, -9999),
  42527. bBox = dataLabel.getBBox(),
  42528. baseline,
  42529. rotation = options.rotation,
  42530. normRotation,
  42531. negRotation,
  42532. align = options.align,
  42533. rotCorr, // rotation correction
  42534. isInsidePlot = chart.isInsidePlot(plotX,
  42535. Math.round(plotY),
  42536. inverted),
  42537. // Math.round for rounding errors (#2683), alignTo to allow column
  42538. // labels (#2700)
  42539. alignAttr, // the final position;
  42540. justify = pick(options.overflow, (enabledDataSorting ? 'none' : 'justify')) === 'justify', visible = this.visible &&
  42541. point.visible !== false &&
  42542. (point.series.forceDL ||
  42543. (enabledDataSorting && !justify) ||
  42544. isInsidePlot ||
  42545. (
  42546. // If the data label is inside the align box, it is enough
  42547. // that parts of the align box is inside the plot area
  42548. // (#12370)
  42549. options.inside && alignTo && chart.isInsidePlot(plotX, inverted ?
  42550. alignTo.x + 1 :
  42551. alignTo.y + alignTo.height - 1, inverted))), setStartPos = function (alignOptions) {
  42552. if (enabledDataSorting && series.xAxis && !justify) {
  42553. series.setDataLabelStartPos(point, dataLabel, isNew, isInsidePlot, alignOptions);
  42554. }
  42555. };
  42556. if (visible) {
  42557. baseline = chart.renderer.fontMetrics(chart.styledMode ? void 0 : options.style.fontSize, dataLabel).b;
  42558. // The alignment box is a singular point
  42559. alignTo = extend({
  42560. x: inverted ? this.yAxis.len - plotY : plotX,
  42561. y: Math.round(inverted ? this.xAxis.len - plotX : plotY),
  42562. width: 0,
  42563. height: 0
  42564. }, alignTo);
  42565. // Add the text size for alignment calculation
  42566. extend(options, {
  42567. width: bBox.width,
  42568. height: bBox.height
  42569. });
  42570. // Allow a hook for changing alignment in the last moment, then do the
  42571. // alignment
  42572. if (rotation) {
  42573. justify = false; // Not supported for rotated text
  42574. rotCorr = chart.renderer.rotCorr(baseline, rotation); // #3723
  42575. alignAttr = {
  42576. x: (alignTo.x +
  42577. (options.x || 0) +
  42578. alignTo.width / 2 +
  42579. rotCorr.x),
  42580. y: (alignTo.y +
  42581. (options.y || 0) +
  42582. { top: 0, middle: 0.5, bottom: 1 }[options.verticalAlign] *
  42583. alignTo.height)
  42584. };
  42585. setStartPos(alignAttr); // data sorting
  42586. dataLabel[isNew ? 'attr' : 'animate'](alignAttr)
  42587. .attr({
  42588. align: align
  42589. });
  42590. // Compensate for the rotated label sticking out on the sides
  42591. normRotation = (rotation + 720) % 360;
  42592. negRotation = normRotation > 180 && normRotation < 360;
  42593. if (align === 'left') {
  42594. alignAttr.y -= negRotation ? bBox.height : 0;
  42595. }
  42596. else if (align === 'center') {
  42597. alignAttr.x -= bBox.width / 2;
  42598. alignAttr.y -= bBox.height / 2;
  42599. }
  42600. else if (align === 'right') {
  42601. alignAttr.x -= bBox.width;
  42602. alignAttr.y -= negRotation ? 0 : bBox.height;
  42603. }
  42604. dataLabel.placed = true;
  42605. dataLabel.alignAttr = alignAttr;
  42606. }
  42607. else {
  42608. setStartPos(alignTo); // data sorting
  42609. dataLabel.align(options, null, alignTo);
  42610. alignAttr = dataLabel.alignAttr;
  42611. }
  42612. // Handle justify or crop
  42613. if (justify && alignTo.height >= 0) { // #8830
  42614. this.justifyDataLabel(dataLabel, options, alignAttr, bBox, alignTo, isNew);
  42615. // Now check that the data label is within the plot area
  42616. }
  42617. else if (pick(options.crop, true)) {
  42618. visible =
  42619. chart.isInsidePlot(alignAttr.x, alignAttr.y) &&
  42620. chart.isInsidePlot(alignAttr.x + bBox.width, alignAttr.y + bBox.height);
  42621. }
  42622. // When we're using a shape, make it possible with a connector or an
  42623. // arrow pointing to thie point
  42624. if (options.shape && !rotation) {
  42625. dataLabel[isNew ? 'attr' : 'animate']({
  42626. anchorX: inverted ?
  42627. chart.plotWidth - point.plotY :
  42628. point.plotX,
  42629. anchorY: inverted ?
  42630. chart.plotHeight - point.plotX :
  42631. point.plotY
  42632. });
  42633. }
  42634. }
  42635. // To use alignAttr property in hideOverlappingLabels
  42636. if (isNew && enabledDataSorting) {
  42637. dataLabel.placed = false;
  42638. }
  42639. // Show or hide based on the final aligned position
  42640. if (!visible && (!enabledDataSorting || justify)) {
  42641. dataLabel.hide(true);
  42642. dataLabel.placed = false; // don't animate back in
  42643. }
  42644. };
  42645. /**
  42646. * Set starting position for data label sorting animation.
  42647. *
  42648. * @private
  42649. * @function Highcharts.Series#setDataLabelStartPos
  42650. * @param {Highcharts.SVGElement} dataLabel
  42651. * @param {Highcharts.ColumnPoint} point
  42652. * @param {boolean | undefined} [isNew]
  42653. * @param {boolean} [isInside]
  42654. * @param {Highcharts.AlignObject} [alignOptions]
  42655. *
  42656. * @return {void}
  42657. */
  42658. CartesianSeries.prototype.setDataLabelStartPos = function (point, dataLabel, isNew, isInside, alignOptions) {
  42659. var chart = this.chart,
  42660. inverted = chart.inverted,
  42661. xAxis = this.xAxis,
  42662. reversed = xAxis.reversed,
  42663. labelCenter = inverted ? dataLabel.height / 2 : dataLabel.width / 2,
  42664. pointWidth = point.pointWidth,
  42665. halfWidth = pointWidth ? pointWidth / 2 : 0,
  42666. startXPos,
  42667. startYPos;
  42668. startXPos = inverted ?
  42669. alignOptions.x :
  42670. (reversed ?
  42671. -labelCenter - halfWidth :
  42672. xAxis.width - labelCenter + halfWidth);
  42673. startYPos = inverted ?
  42674. (reversed ?
  42675. this.yAxis.height - labelCenter + halfWidth :
  42676. -labelCenter - halfWidth) : alignOptions.y;
  42677. dataLabel.startXPos = startXPos;
  42678. dataLabel.startYPos = startYPos;
  42679. // We need to handle visibility in case of sorting point outside plot area
  42680. if (!isInside) {
  42681. dataLabel
  42682. .attr({ opacity: 1 })
  42683. .animate({ opacity: 0 }, void 0, dataLabel.hide);
  42684. }
  42685. else if (dataLabel.visibility === 'hidden') {
  42686. dataLabel.show();
  42687. dataLabel
  42688. .attr({ opacity: 0 })
  42689. .animate({ opacity: 1 });
  42690. }
  42691. // Save start position on first render, but do not change position
  42692. if (!chart.hasRendered) {
  42693. return;
  42694. }
  42695. // Set start position
  42696. if (isNew) {
  42697. dataLabel.attr({ x: dataLabel.startXPos, y: dataLabel.startYPos });
  42698. }
  42699. dataLabel.placed = true;
  42700. };
  42701. /**
  42702. * If data labels fall partly outside the plot area, align them back in, in a
  42703. * way that doesn't hide the point.
  42704. *
  42705. * @private
  42706. * @function Highcharts.Series#justifyDataLabel
  42707. * @param {Highcharts.SVGElement} dataLabel
  42708. * @param {Highcharts.DataLabelsOptions} options
  42709. * @param {Highcharts.SVGAttributes} alignAttr
  42710. * @param {Highcharts.BBoxObject} bBox
  42711. * @param {Highcharts.BBoxObject} [alignTo]
  42712. * @param {boolean} [isNew]
  42713. * @return {boolean|undefined}
  42714. */
  42715. CartesianSeries.prototype.justifyDataLabel = function (dataLabel, options, alignAttr, bBox, alignTo, isNew) {
  42716. var chart = this.chart,
  42717. align = options.align,
  42718. verticalAlign = options.verticalAlign,
  42719. off,
  42720. justified,
  42721. padding = dataLabel.box ? 0 : (dataLabel.padding || 0);
  42722. var _a = options.x,
  42723. x = _a === void 0 ? 0 : _a,
  42724. _b = options.y,
  42725. y = _b === void 0 ? 0 : _b;
  42726. // Off left
  42727. off = alignAttr.x + padding;
  42728. if (off < 0) {
  42729. if (align === 'right' && x >= 0) {
  42730. options.align = 'left';
  42731. options.inside = true;
  42732. }
  42733. else {
  42734. x -= off;
  42735. }
  42736. justified = true;
  42737. }
  42738. // Off right
  42739. off = alignAttr.x + bBox.width - padding;
  42740. if (off > chart.plotWidth) {
  42741. if (align === 'left' && x <= 0) {
  42742. options.align = 'right';
  42743. options.inside = true;
  42744. }
  42745. else {
  42746. x += chart.plotWidth - off;
  42747. }
  42748. justified = true;
  42749. }
  42750. // Off top
  42751. off = alignAttr.y + padding;
  42752. if (off < 0) {
  42753. if (verticalAlign === 'bottom' && y >= 0) {
  42754. options.verticalAlign = 'top';
  42755. options.inside = true;
  42756. }
  42757. else {
  42758. y -= off;
  42759. }
  42760. justified = true;
  42761. }
  42762. // Off bottom
  42763. off = alignAttr.y + bBox.height - padding;
  42764. if (off > chart.plotHeight) {
  42765. if (verticalAlign === 'top' && y <= 0) {
  42766. options.verticalAlign = 'bottom';
  42767. options.inside = true;
  42768. }
  42769. else {
  42770. y += chart.plotHeight - off;
  42771. }
  42772. justified = true;
  42773. }
  42774. if (justified) {
  42775. options.x = x;
  42776. options.y = y;
  42777. dataLabel.placed = !isNew;
  42778. dataLabel.align(options, void 0, alignTo);
  42779. }
  42780. return justified;
  42781. };
  42782. if (seriesTypes.pie) {
  42783. seriesTypes.pie.prototype.dataLabelPositioners = {
  42784. // Based on the value computed in Highcharts' distribute algorithm.
  42785. radialDistributionY: function (point) {
  42786. return point.top + point.distributeBox.pos;
  42787. },
  42788. // get the x - use the natural x position for labels near the
  42789. // top and bottom, to prevent the top and botton slice
  42790. // connectors from touching each other on either side
  42791. // Based on the value computed in Highcharts' distribute algorithm.
  42792. radialDistributionX: function (series, point, y, naturalY) {
  42793. return series.getX(y < point.top + 2 || y > point.bottom - 2 ?
  42794. naturalY :
  42795. y, point.half, point);
  42796. },
  42797. // dataLabels.distance determines the x position of the label
  42798. justify: function (point, radius, seriesCenter) {
  42799. return seriesCenter[0] + (point.half ? -1 : 1) *
  42800. (radius + point.labelDistance);
  42801. },
  42802. // Left edges of the left-half labels touch the left edge of the plot
  42803. // area. Right edges of the right-half labels touch the right edge of
  42804. // the plot area.
  42805. alignToPlotEdges: function (dataLabel, half, plotWidth, plotLeft) {
  42806. var dataLabelWidth = dataLabel.getBBox().width;
  42807. return half ? dataLabelWidth + plotLeft :
  42808. plotWidth - dataLabelWidth - plotLeft;
  42809. },
  42810. // Connectors of each side end in the same x position. Labels are
  42811. // aligned to them. Left edge of the widest left-half label touches the
  42812. // left edge of the plot area. Right edge of the widest right-half label
  42813. // touches the right edge of the plot area.
  42814. alignToConnectors: function (points, half, plotWidth, plotLeft) {
  42815. var maxDataLabelWidth = 0,
  42816. dataLabelWidth;
  42817. // find widest data label
  42818. points.forEach(function (point) {
  42819. dataLabelWidth = point.dataLabel.getBBox().width;
  42820. if (dataLabelWidth > maxDataLabelWidth) {
  42821. maxDataLabelWidth = dataLabelWidth;
  42822. }
  42823. });
  42824. return half ? maxDataLabelWidth + plotLeft :
  42825. plotWidth - maxDataLabelWidth - plotLeft;
  42826. }
  42827. };
  42828. /**
  42829. * Override the base drawDataLabels method by pie specific functionality
  42830. *
  42831. * @private
  42832. * @function Highcharts.seriesTypes.pie#drawDataLabels
  42833. * @return {void}
  42834. */
  42835. seriesTypes.pie.prototype.drawDataLabels = function () {
  42836. var series = this,
  42837. data = series.data,
  42838. point,
  42839. chart = series.chart,
  42840. options = series.options.dataLabels || {},
  42841. connectorPadding = options.connectorPadding,
  42842. connectorWidth,
  42843. plotWidth = chart.plotWidth,
  42844. plotHeight = chart.plotHeight,
  42845. plotLeft = chart.plotLeft,
  42846. maxWidth = Math.round(chart.chartWidth / 3),
  42847. connector,
  42848. seriesCenter = series.center,
  42849. radius = seriesCenter[2] / 2,
  42850. centerY = seriesCenter[1],
  42851. dataLabel,
  42852. dataLabelWidth,
  42853. // labelPos,
  42854. labelPosition,
  42855. labelHeight,
  42856. // divide the points into right and left halves for anti collision
  42857. halves = [
  42858. [],
  42859. [] // left
  42860. ],
  42861. x,
  42862. y,
  42863. visibility,
  42864. j,
  42865. overflow = [0, 0, 0, 0], // top, right, bottom, left
  42866. dataLabelPositioners = series.dataLabelPositioners,
  42867. pointDataLabelsOptions;
  42868. // get out if not enabled
  42869. if (!series.visible ||
  42870. (!options.enabled &&
  42871. !series._hasPointLabels)) {
  42872. return;
  42873. }
  42874. // Reset all labels that have been shortened
  42875. data.forEach(function (point) {
  42876. if (point.dataLabel && point.visible && point.dataLabel.shortened) {
  42877. point.dataLabel
  42878. .attr({
  42879. width: 'auto'
  42880. }).css({
  42881. width: 'auto',
  42882. textOverflow: 'clip'
  42883. });
  42884. point.dataLabel.shortened = false;
  42885. }
  42886. });
  42887. // run parent method
  42888. CartesianSeries.prototype.drawDataLabels.apply(series);
  42889. data.forEach(function (point) {
  42890. if (point.dataLabel) {
  42891. if (point.visible) { // #407, #2510
  42892. // Arrange points for detection collision
  42893. halves[point.half].push(point);
  42894. // Reset positions (#4905)
  42895. point.dataLabel._pos = null;
  42896. // Avoid long labels squeezing the pie size too far down
  42897. if (!defined(options.style.width) &&
  42898. !defined(point.options.dataLabels &&
  42899. point.options.dataLabels.style &&
  42900. point.options.dataLabels.style.width)) {
  42901. if (point.dataLabel.getBBox().width > maxWidth) {
  42902. point.dataLabel.css({
  42903. // Use a fraction of the maxWidth to avoid
  42904. // wrapping close to the end of the string.
  42905. width: Math.round(maxWidth * 0.7) + 'px'
  42906. });
  42907. point.dataLabel.shortened = true;
  42908. }
  42909. }
  42910. }
  42911. else {
  42912. point.dataLabel = point.dataLabel.destroy();
  42913. // Workaround to make pies destroy multiple datalabels
  42914. // correctly. This logic needs rewriting to support multiple
  42915. // datalabels fully.
  42916. if (point.dataLabels && point.dataLabels.length === 1) {
  42917. delete point.dataLabels;
  42918. }
  42919. }
  42920. }
  42921. });
  42922. /* Loop over the points in each half, starting from the top and bottom
  42923. * of the pie to detect overlapping labels.
  42924. */
  42925. halves.forEach(function (points, i) {
  42926. var top,
  42927. bottom,
  42928. length = points.length,
  42929. positions = [],
  42930. naturalY,
  42931. sideOverflow,
  42932. size,
  42933. distributionLength;
  42934. if (!length) {
  42935. return;
  42936. }
  42937. // Sort by angle
  42938. series.sortByAngle(points, i - 0.5);
  42939. // Only do anti-collision when we have dataLabels outside the pie
  42940. // and have connectors. (#856)
  42941. if (series.maxLabelDistance > 0) {
  42942. top = Math.max(0, centerY - radius - series.maxLabelDistance);
  42943. bottom = Math.min(centerY + radius + series.maxLabelDistance, chart.plotHeight);
  42944. points.forEach(function (point) {
  42945. // check if specific points' label is outside the pie
  42946. if (point.labelDistance > 0 && point.dataLabel) {
  42947. // point.top depends on point.labelDistance value
  42948. // Used for calculation of y value in getX method
  42949. point.top = Math.max(0, centerY - radius - point.labelDistance);
  42950. point.bottom = Math.min(centerY + radius + point.labelDistance, chart.plotHeight);
  42951. size = point.dataLabel.getBBox().height || 21;
  42952. // point.positionsIndex is needed for getting index of
  42953. // parameter related to specific point inside positions
  42954. // array - not every point is in positions array.
  42955. point.distributeBox = {
  42956. target: point.labelPosition.natural.y -
  42957. point.top + size / 2,
  42958. size: size,
  42959. rank: point.y
  42960. };
  42961. positions.push(point.distributeBox);
  42962. }
  42963. });
  42964. distributionLength = bottom + size - top;
  42965. H.distribute(positions, distributionLength, distributionLength / 5);
  42966. }
  42967. // Now the used slots are sorted, fill them up sequentially
  42968. for (j = 0; j < length; j++) {
  42969. point = points[j];
  42970. // labelPos = point.labelPos;
  42971. labelPosition = point.labelPosition;
  42972. dataLabel = point.dataLabel;
  42973. visibility = point.visible === false ? 'hidden' : 'inherit';
  42974. naturalY = labelPosition.natural.y;
  42975. y = naturalY;
  42976. if (positions && defined(point.distributeBox)) {
  42977. if (typeof point.distributeBox.pos === 'undefined') {
  42978. visibility = 'hidden';
  42979. }
  42980. else {
  42981. labelHeight = point.distributeBox.size;
  42982. // Find label's y position
  42983. y = dataLabelPositioners
  42984. .radialDistributionY(point);
  42985. }
  42986. }
  42987. // It is needed to delete point.positionIndex for
  42988. // dynamically added points etc.
  42989. delete point.positionIndex; // @todo unused
  42990. // Find label's x position
  42991. // justify is undocumented in the API - preserve support for it
  42992. if (options.justify) {
  42993. x = dataLabelPositioners.justify(point, radius, seriesCenter);
  42994. }
  42995. else {
  42996. switch (options.alignTo) {
  42997. case 'connectors':
  42998. x = dataLabelPositioners.alignToConnectors(points, i, plotWidth, plotLeft);
  42999. break;
  43000. case 'plotEdges':
  43001. x = dataLabelPositioners.alignToPlotEdges(dataLabel, i, plotWidth, plotLeft);
  43002. break;
  43003. default:
  43004. x = dataLabelPositioners.radialDistributionX(series, point, y, naturalY);
  43005. }
  43006. }
  43007. // Record the placement and visibility
  43008. dataLabel._attr = {
  43009. visibility: visibility,
  43010. align: labelPosition.alignment
  43011. };
  43012. pointDataLabelsOptions = point.options.dataLabels || {};
  43013. dataLabel._pos = {
  43014. x: (x +
  43015. pick(pointDataLabelsOptions.x, options.x) + // (#12985)
  43016. ({
  43017. left: connectorPadding,
  43018. right: -connectorPadding
  43019. }[labelPosition.alignment] || 0)),
  43020. // 10 is for the baseline (label vs text)
  43021. y: (y +
  43022. pick(pointDataLabelsOptions.y, options.y) - // (#12985)
  43023. 10)
  43024. };
  43025. // labelPos.x = x;
  43026. // labelPos.y = y;
  43027. labelPosition.final.x = x;
  43028. labelPosition.final.y = y;
  43029. // Detect overflowing data labels
  43030. if (pick(options.crop, true)) {
  43031. dataLabelWidth = dataLabel.getBBox().width;
  43032. sideOverflow = null;
  43033. // Overflow left
  43034. if (x - dataLabelWidth < connectorPadding &&
  43035. i === 1 // left half
  43036. ) {
  43037. sideOverflow = Math.round(dataLabelWidth - x + connectorPadding);
  43038. overflow[3] = Math.max(sideOverflow, overflow[3]);
  43039. // Overflow right
  43040. }
  43041. else if (x + dataLabelWidth > plotWidth - connectorPadding &&
  43042. i === 0 // right half
  43043. ) {
  43044. sideOverflow = Math.round(x + dataLabelWidth - plotWidth + connectorPadding);
  43045. overflow[1] = Math.max(sideOverflow, overflow[1]);
  43046. }
  43047. // Overflow top
  43048. if (y - labelHeight / 2 < 0) {
  43049. overflow[0] = Math.max(Math.round(-y + labelHeight / 2), overflow[0]);
  43050. // Overflow left
  43051. }
  43052. else if (y + labelHeight / 2 > plotHeight) {
  43053. overflow[2] = Math.max(Math.round(y + labelHeight / 2 - plotHeight), overflow[2]);
  43054. }
  43055. dataLabel.sideOverflow = sideOverflow;
  43056. }
  43057. } // for each point
  43058. }); // for each half
  43059. // Do not apply the final placement and draw the connectors until we
  43060. // have verified that labels are not spilling over.
  43061. if (arrayMax(overflow) === 0 ||
  43062. this.verifyDataLabelOverflow(overflow)) {
  43063. // Place the labels in the final position
  43064. this.placeDataLabels();
  43065. this.points.forEach(function (point) {
  43066. // #8864: every connector can have individual options
  43067. pointDataLabelsOptions =
  43068. merge(options, point.options.dataLabels);
  43069. connectorWidth =
  43070. pick(pointDataLabelsOptions.connectorWidth, 1);
  43071. // Draw the connector
  43072. if (connectorWidth) {
  43073. var isNew;
  43074. connector = point.connector;
  43075. dataLabel = point.dataLabel;
  43076. if (dataLabel &&
  43077. dataLabel._pos &&
  43078. point.visible &&
  43079. point.labelDistance > 0) {
  43080. visibility = dataLabel._attr.visibility;
  43081. isNew = !connector;
  43082. if (isNew) {
  43083. point.connector = connector = chart.renderer
  43084. .path()
  43085. .addClass('highcharts-data-label-connector ' +
  43086. ' highcharts-color-' + point.colorIndex +
  43087. (point.className ?
  43088. ' ' + point.className :
  43089. ''))
  43090. .add(series.dataLabelsGroup);
  43091. if (!chart.styledMode) {
  43092. connector.attr({
  43093. 'stroke-width': connectorWidth,
  43094. 'stroke': (pointDataLabelsOptions.connectorColor ||
  43095. point.color ||
  43096. '#666666')
  43097. });
  43098. }
  43099. }
  43100. connector[isNew ? 'attr' : 'animate']({
  43101. d: point.getConnectorPath()
  43102. });
  43103. connector.attr('visibility', visibility);
  43104. }
  43105. else if (connector) {
  43106. point.connector = connector.destroy();
  43107. }
  43108. }
  43109. });
  43110. }
  43111. };
  43112. /**
  43113. * Extendable method for getting the path of the connector between the data
  43114. * label and the pie slice.
  43115. *
  43116. * @private
  43117. * @function Highcharts.seriesTypes.pie#connectorPath
  43118. *
  43119. * @param {*} labelPos
  43120. *
  43121. * @return {Highcharts.SVGPathArray}
  43122. */
  43123. // TODO: depracated - remove it
  43124. /*
  43125. seriesTypes.pie.prototype.connectorPath = function (labelPos) {
  43126. var x = labelPos.x,
  43127. y = labelPos.y;
  43128. return pick(this.options.dataLabels.softConnector, true) ? [
  43129. 'M',
  43130. // end of the string at the label
  43131. x + (labelPos[6] === 'left' ? 5 : -5), y,
  43132. 'C',
  43133. x, y, // first break, next to the label
  43134. 2 * labelPos[2] - labelPos[4], 2 * labelPos[3] - labelPos[5],
  43135. labelPos[2], labelPos[3], // second break
  43136. 'L',
  43137. labelPos[4], labelPos[5] // base
  43138. ] : [
  43139. 'M',
  43140. // end of the string at the label
  43141. x + (labelPos[6] === 'left' ? 5 : -5), y,
  43142. 'L',
  43143. labelPos[2], labelPos[3], // second break
  43144. 'L',
  43145. labelPos[4], labelPos[5] // base
  43146. ];
  43147. };
  43148. */
  43149. /**
  43150. * Perform the final placement of the data labels after we have verified
  43151. * that they fall within the plot area.
  43152. *
  43153. * @private
  43154. * @function Highcharts.seriesTypes.pie#placeDataLabels
  43155. * @return {void}
  43156. */
  43157. seriesTypes.pie.prototype.placeDataLabels = function () {
  43158. this.points.forEach(function (point) {
  43159. var dataLabel = point.dataLabel,
  43160. _pos;
  43161. if (dataLabel && point.visible) {
  43162. _pos = dataLabel._pos;
  43163. if (_pos) {
  43164. // Shorten data labels with ellipsis if they still overflow
  43165. // after the pie has reached minSize (#223).
  43166. if (dataLabel.sideOverflow) {
  43167. dataLabel._attr.width =
  43168. Math.max(dataLabel.getBBox().width -
  43169. dataLabel.sideOverflow, 0);
  43170. dataLabel.css({
  43171. width: dataLabel._attr.width + 'px',
  43172. textOverflow: ((this.options.dataLabels.style || {})
  43173. .textOverflow ||
  43174. 'ellipsis')
  43175. });
  43176. dataLabel.shortened = true;
  43177. }
  43178. dataLabel.attr(dataLabel._attr);
  43179. dataLabel[dataLabel.moved ? 'animate' : 'attr'](_pos);
  43180. dataLabel.moved = true;
  43181. }
  43182. else if (dataLabel) {
  43183. dataLabel.attr({ y: -9999 });
  43184. }
  43185. }
  43186. // Clear for update
  43187. delete point.distributeBox;
  43188. }, this);
  43189. };
  43190. seriesTypes.pie.prototype.alignDataLabel = noop;
  43191. /**
  43192. * Verify whether the data labels are allowed to draw, or we should run more
  43193. * translation and data label positioning to keep them inside the plot area.
  43194. * Returns true when data labels are ready to draw.
  43195. *
  43196. * @private
  43197. * @function Highcharts.seriesTypes.pie#verifyDataLabelOverflow
  43198. * @param {Array<number>} overflow
  43199. * @return {boolean}
  43200. */
  43201. seriesTypes.pie.prototype.verifyDataLabelOverflow = function (overflow) {
  43202. var center = this.center,
  43203. options = this.options,
  43204. centerOption = options.center,
  43205. minSize = options.minSize || 80,
  43206. newSize = minSize,
  43207. // If a size is set, return true and don't try to shrink the pie
  43208. // to fit the labels.
  43209. ret = options.size !== null;
  43210. if (!ret) {
  43211. // Handle horizontal size and center
  43212. if (centerOption[0] !== null) { // Fixed center
  43213. newSize = Math.max(center[2] -
  43214. Math.max(overflow[1], overflow[3]), minSize);
  43215. }
  43216. else { // Auto center
  43217. newSize = Math.max(
  43218. // horizontal overflow
  43219. center[2] - overflow[1] - overflow[3], minSize);
  43220. // horizontal center
  43221. center[0] += (overflow[3] - overflow[1]) / 2;
  43222. }
  43223. // Handle vertical size and center
  43224. if (centerOption[1] !== null) { // Fixed center
  43225. newSize = clamp(newSize, minSize, center[2] - Math.max(overflow[0], overflow[2]));
  43226. }
  43227. else { // Auto center
  43228. newSize = clamp(newSize, minSize,
  43229. // vertical overflow
  43230. center[2] - overflow[0] - overflow[2]);
  43231. // vertical center
  43232. center[1] += (overflow[0] - overflow[2]) / 2;
  43233. }
  43234. // If the size must be decreased, we need to run translate and
  43235. // drawDataLabels again
  43236. if (newSize < center[2]) {
  43237. center[2] = newSize;
  43238. center[3] = Math.min(// #3632
  43239. relativeLength(options.innerSize || 0, newSize), newSize);
  43240. this.translate(center);
  43241. if (this.drawDataLabels) {
  43242. this.drawDataLabels();
  43243. }
  43244. // Else, return true to indicate that the pie and its labels is
  43245. // within the plot area
  43246. }
  43247. else {
  43248. ret = true;
  43249. }
  43250. }
  43251. return ret;
  43252. };
  43253. }
  43254. if (seriesTypes.column) {
  43255. /**
  43256. * Override the basic data label alignment by adjusting for the position of
  43257. * the column.
  43258. *
  43259. * @private
  43260. * @function Highcharts.seriesTypes.column#alignDataLabel
  43261. * @param {Highcharts.Point} point
  43262. * @param {Highcharts.SVGElement} dataLabel
  43263. * @param {Highcharts.DataLabelsOptions} options
  43264. * @param {Highcharts.BBoxObject} alignTo
  43265. * @param {boolean} [isNew]
  43266. * @return {void}
  43267. */
  43268. seriesTypes.column.prototype.alignDataLabel = function (point, dataLabel, options, alignTo, isNew) {
  43269. var inverted = this.chart.inverted,
  43270. series = point.series,
  43271. // data label box for alignment
  43272. dlBox = point.dlBox || point.shapeArgs,
  43273. below = pick(point.below, // range series
  43274. point.plotY >
  43275. pick(this.translatedThreshold,
  43276. series.yAxis.len)),
  43277. // draw it inside the box?
  43278. inside = pick(options.inside, !!this.options.stacking),
  43279. overshoot;
  43280. // Align to the column itself, or the top of it
  43281. if (dlBox) { // Area range uses this method but not alignTo
  43282. alignTo = merge(dlBox);
  43283. if (alignTo.y < 0) {
  43284. alignTo.height += alignTo.y;
  43285. alignTo.y = 0;
  43286. }
  43287. // If parts of the box overshoots outside the plot area, modify the
  43288. // box to center the label inside
  43289. overshoot = alignTo.y + alignTo.height - series.yAxis.len;
  43290. if (overshoot > 0 && overshoot < alignTo.height) {
  43291. alignTo.height -= overshoot;
  43292. }
  43293. if (inverted) {
  43294. alignTo = {
  43295. x: series.yAxis.len - alignTo.y - alignTo.height,
  43296. y: series.xAxis.len - alignTo.x - alignTo.width,
  43297. width: alignTo.height,
  43298. height: alignTo.width
  43299. };
  43300. }
  43301. // Compute the alignment box
  43302. if (!inside) {
  43303. if (inverted) {
  43304. alignTo.x += below ? 0 : alignTo.width;
  43305. alignTo.width = 0;
  43306. }
  43307. else {
  43308. alignTo.y += below ? alignTo.height : 0;
  43309. alignTo.height = 0;
  43310. }
  43311. }
  43312. }
  43313. // When alignment is undefined (typically columns and bars), display the
  43314. // individual point below or above the point depending on the threshold
  43315. options.align = pick(options.align, !inverted || inside ? 'center' : below ? 'right' : 'left');
  43316. options.verticalAlign = pick(options.verticalAlign, inverted || inside ? 'middle' : below ? 'top' : 'bottom');
  43317. // Call the parent method
  43318. CartesianSeries.prototype.alignDataLabel.call(this, point, dataLabel, options, alignTo, isNew);
  43319. // If label was justified and we have contrast, set it:
  43320. if (options.inside && point.contrastColor) {
  43321. dataLabel.css({
  43322. color: point.contrastColor
  43323. });
  43324. }
  43325. };
  43326. }
  43327. });
  43328. _registerModule(_modules, 'Extensions/OverlappingDataLabels.js', [_modules['Core/Chart/Chart.js'], _modules['Core/Utilities.js']], function (Chart, U) {
  43329. /* *
  43330. *
  43331. * Highcharts module to hide overlapping data labels.
  43332. * This module is included in Highcharts.
  43333. *
  43334. * (c) 2009-2020 Torstein Honsi
  43335. *
  43336. * License: www.highcharts.com/license
  43337. *
  43338. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  43339. *
  43340. * */
  43341. var addEvent = U.addEvent,
  43342. fireEvent = U.fireEvent,
  43343. isArray = U.isArray,
  43344. isNumber = U.isNumber,
  43345. objectEach = U.objectEach,
  43346. pick = U.pick;
  43347. /**
  43348. * Internal type
  43349. * @private
  43350. */
  43351. /* eslint-disable no-invalid-this */
  43352. // Collect potensial overlapping data labels. Stack labels probably don't need
  43353. // to be considered because they are usually accompanied by data labels that lie
  43354. // inside the columns.
  43355. addEvent(Chart, 'render', function collectAndHide() {
  43356. var labels = [];
  43357. // Consider external label collectors
  43358. (this.labelCollectors || []).forEach(function (collector) {
  43359. labels = labels.concat(collector());
  43360. });
  43361. (this.yAxis || []).forEach(function (yAxis) {
  43362. if (yAxis.stacking &&
  43363. yAxis.options.stackLabels &&
  43364. !yAxis.options.stackLabels.allowOverlap) {
  43365. objectEach(yAxis.stacking.stacks, function (stack) {
  43366. objectEach(stack, function (stackItem) {
  43367. labels.push(stackItem.label);
  43368. });
  43369. });
  43370. }
  43371. });
  43372. (this.series || []).forEach(function (series) {
  43373. var dlOptions = series.options.dataLabels;
  43374. if (series.visible &&
  43375. !(dlOptions.enabled === false && !series._hasPointLabels)) { // #3866
  43376. (series.nodes || series.points).forEach(function (point) {
  43377. if (point.visible) {
  43378. var dataLabels = (isArray(point.dataLabels) ?
  43379. point.dataLabels :
  43380. (point.dataLabel ? [point.dataLabel] : []));
  43381. dataLabels.forEach(function (label) {
  43382. var options = label.options;
  43383. label.labelrank = pick(options.labelrank, point.labelrank, point.shapeArgs && point.shapeArgs.height); // #4118
  43384. if (!options.allowOverlap) {
  43385. labels.push(label);
  43386. }
  43387. });
  43388. }
  43389. });
  43390. }
  43391. });
  43392. this.hideOverlappingLabels(labels);
  43393. });
  43394. /**
  43395. * Hide overlapping labels. Labels are moved and faded in and out on zoom to
  43396. * provide a smooth visual imression.
  43397. *
  43398. * @private
  43399. * @function Highcharts.Chart#hideOverlappingLabels
  43400. * @param {Array<Highcharts.SVGElement>} labels
  43401. * Rendered data labels
  43402. * @requires modules/overlapping-datalabels
  43403. */
  43404. Chart.prototype.hideOverlappingLabels = function (labels) {
  43405. var chart = this,
  43406. len = labels.length,
  43407. ren = chart.renderer,
  43408. label,
  43409. i,
  43410. j,
  43411. label1,
  43412. label2,
  43413. box1,
  43414. box2,
  43415. isLabelAffected = false,
  43416. isIntersectRect = function (box1,
  43417. box2) {
  43418. return !(box2.x >= box1.x + box1.width ||
  43419. box2.x + box2.width <= box1.x ||
  43420. box2.y >= box1.y + box1.height ||
  43421. box2.y + box2.height <= box1.y);
  43422. },
  43423. // Get the box with its position inside the chart, as opposed to getBBox
  43424. // that only reports the position relative to the parent.
  43425. getAbsoluteBox = function (label) {
  43426. var pos,
  43427. parent,
  43428. bBox,
  43429. // Substract the padding if no background or border (#4333)
  43430. padding = label.box ? 0 : (label.padding || 0),
  43431. lineHeightCorrection = 0,
  43432. xOffset = 0,
  43433. boxWidth,
  43434. alignValue;
  43435. if (label &&
  43436. (!label.alignAttr || label.placed)) {
  43437. pos = label.alignAttr || {
  43438. x: label.attr('x'),
  43439. y: label.attr('y')
  43440. };
  43441. parent = label.parentGroup;
  43442. // Get width and height if pure text nodes (stack labels)
  43443. if (!label.width) {
  43444. bBox = label.getBBox();
  43445. label.width = bBox.width;
  43446. label.height = bBox.height;
  43447. // Labels positions are computed from top left corner, so
  43448. // we need to substract the text height from text nodes too.
  43449. lineHeightCorrection = ren
  43450. .fontMetrics(null, label.element).h;
  43451. }
  43452. boxWidth = label.width - 2 * padding;
  43453. alignValue = {
  43454. left: '0',
  43455. center: '0.5',
  43456. right: '1'
  43457. }[label.alignValue];
  43458. if (alignValue) {
  43459. xOffset = +alignValue * boxWidth;
  43460. }
  43461. else if (isNumber(label.x) && Math.round(label.x) !== label.translateX) {
  43462. xOffset = label.x - label.translateX;
  43463. }
  43464. return {
  43465. x: pos.x + (parent.translateX || 0) + padding -
  43466. (xOffset || 0),
  43467. y: pos.y + (parent.translateY || 0) + padding -
  43468. lineHeightCorrection,
  43469. width: label.width - 2 * padding,
  43470. height: label.height - 2 * padding
  43471. };
  43472. }
  43473. };
  43474. for (i = 0; i < len; i++) {
  43475. label = labels[i];
  43476. if (label) {
  43477. // Mark with initial opacity
  43478. label.oldOpacity = label.opacity;
  43479. label.newOpacity = 1;
  43480. label.absoluteBox = getAbsoluteBox(label);
  43481. }
  43482. }
  43483. // Prevent a situation in a gradually rising slope, that each label will
  43484. // hide the previous one because the previous one always has lower rank.
  43485. labels.sort(function (a, b) {
  43486. return (b.labelrank || 0) - (a.labelrank || 0);
  43487. });
  43488. // Detect overlapping labels
  43489. for (i = 0; i < len; i++) {
  43490. label1 = labels[i];
  43491. box1 = label1 && label1.absoluteBox;
  43492. for (j = i + 1; j < len; ++j) {
  43493. label2 = labels[j];
  43494. box2 = label2 && label2.absoluteBox;
  43495. if (box1 &&
  43496. box2 &&
  43497. label1 !== label2 && // #6465, polar chart with connectEnds
  43498. label1.newOpacity !== 0 &&
  43499. label2.newOpacity !== 0) {
  43500. if (isIntersectRect(box1, box2)) {
  43501. (label1.labelrank < label2.labelrank ? label1 : label2)
  43502. .newOpacity = 0;
  43503. }
  43504. }
  43505. }
  43506. }
  43507. // Hide or show
  43508. labels.forEach(function (label) {
  43509. var complete,
  43510. newOpacity;
  43511. if (label) {
  43512. newOpacity = label.newOpacity;
  43513. if (label.oldOpacity !== newOpacity) {
  43514. // Make sure the label is completely hidden to avoid catching
  43515. // clicks (#4362)
  43516. if (label.alignAttr && label.placed) { // data labels
  43517. label[newOpacity ? 'removeClass' : 'addClass']('highcharts-data-label-hidden');
  43518. complete = function () {
  43519. if (!chart.styledMode) {
  43520. label.css({ pointerEvents: newOpacity ? 'auto' : 'none' });
  43521. }
  43522. label.visibility = newOpacity ? 'inherit' : 'hidden';
  43523. };
  43524. isLabelAffected = true;
  43525. // Animate or set the opacity
  43526. label.alignAttr.opacity = newOpacity;
  43527. label[label.isOld ? 'animate' : 'attr'](label.alignAttr, null, complete);
  43528. fireEvent(chart, 'afterHideOverlappingLabel');
  43529. }
  43530. else { // other labels, tick labels
  43531. label.attr({
  43532. opacity: newOpacity
  43533. });
  43534. }
  43535. }
  43536. label.isOld = true;
  43537. }
  43538. });
  43539. if (isLabelAffected) {
  43540. fireEvent(chart, 'afterHideAllOverlappingLabels');
  43541. }
  43542. };
  43543. });
  43544. _registerModule(_modules, 'Core/Interaction.js', [_modules['Core/Series/Series.js'], _modules['Core/Chart/Chart.js'], _modules['Core/Globals.js'], _modules['Core/Legend.js'], _modules['Series/LineSeries.js'], _modules['Core/Options.js'], _modules['Core/Series/Point.js'], _modules['Core/Utilities.js']], function (BaseSeries, Chart, H, Legend, LineSeries, O, Point, U) {
  43545. /* *
  43546. *
  43547. * (c) 2010-2020 Torstein Honsi
  43548. *
  43549. * License: www.highcharts.com/license
  43550. *
  43551. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  43552. *
  43553. * */
  43554. var seriesTypes = BaseSeries.seriesTypes;
  43555. var hasTouch = H.hasTouch,
  43556. svg = H.svg;
  43557. var defaultOptions = O.defaultOptions;
  43558. var addEvent = U.addEvent,
  43559. createElement = U.createElement,
  43560. css = U.css,
  43561. defined = U.defined,
  43562. extend = U.extend,
  43563. fireEvent = U.fireEvent,
  43564. isArray = U.isArray,
  43565. isFunction = U.isFunction,
  43566. isNumber = U.isNumber,
  43567. isObject = U.isObject,
  43568. merge = U.merge,
  43569. objectEach = U.objectEach,
  43570. pick = U.pick;
  43571. /**
  43572. * @interface Highcharts.PointEventsOptionsObject
  43573. */ /**
  43574. * Fires when the point is selected either programmatically or following a click
  43575. * on the point. One parameter, `event`, is passed to the function. Returning
  43576. * `false` cancels the operation.
  43577. * @name Highcharts.PointEventsOptionsObject#select
  43578. * @type {Highcharts.PointSelectCallbackFunction|undefined}
  43579. */ /**
  43580. * Fires when the point is unselected either programmatically or following a
  43581. * click on the point. One parameter, `event`, is passed to the function.
  43582. * Returning `false` cancels the operation.
  43583. * @name Highcharts.PointEventsOptionsObject#unselect
  43584. * @type {Highcharts.PointUnselectCallbackFunction|undefined}
  43585. */
  43586. /**
  43587. * Information about the select/unselect event.
  43588. *
  43589. * @interface Highcharts.PointInteractionEventObject
  43590. * @extends global.Event
  43591. */ /**
  43592. * @name Highcharts.PointInteractionEventObject#accumulate
  43593. * @type {boolean}
  43594. */
  43595. /**
  43596. * Gets fired when the point is selected either programmatically or following a
  43597. * click on the point.
  43598. *
  43599. * @callback Highcharts.PointSelectCallbackFunction
  43600. *
  43601. * @param {Highcharts.Point} this
  43602. * Point where the event occured.
  43603. *
  43604. * @param {Highcharts.PointInteractionEventObject} event
  43605. * Event that occured.
  43606. */
  43607. /**
  43608. * Fires when the point is unselected either programmatically or following a
  43609. * click on the point.
  43610. *
  43611. * @callback Highcharts.PointUnselectCallbackFunction
  43612. *
  43613. * @param {Highcharts.Point} this
  43614. * Point where the event occured.
  43615. *
  43616. * @param {Highcharts.PointInteractionEventObject} event
  43617. * Event that occured.
  43618. */
  43619. ''; // detach doclets above
  43620. /* eslint-disable valid-jsdoc */
  43621. /**
  43622. * TrackerMixin for points and graphs.
  43623. *
  43624. * @private
  43625. * @mixin Highcharts.TrackerMixin
  43626. */
  43627. var TrackerMixin = H.TrackerMixin = {
  43628. /**
  43629. * Draw the tracker for a point.
  43630. *
  43631. * @private
  43632. * @function Highcharts.TrackerMixin.drawTrackerPoint
  43633. * @param {Highcharts.Series} this
  43634. * @fires Highcharts.Series#event:afterDrawTracker
  43635. */
  43636. drawTrackerPoint: function () {
  43637. var series = this,
  43638. chart = series.chart,
  43639. pointer = chart.pointer,
  43640. onMouseOver = function (e) {
  43641. var point = pointer.getPointFromEvent(e);
  43642. // undefined on graph in scatterchart
  43643. if (typeof point !== 'undefined') {
  43644. pointer.isDirectTouch = true;
  43645. point.onMouseOver(e);
  43646. }
  43647. }, dataLabels;
  43648. // Add reference to the point
  43649. series.points.forEach(function (point) {
  43650. dataLabels = (isArray(point.dataLabels) ?
  43651. point.dataLabels :
  43652. (point.dataLabel ? [point.dataLabel] : []));
  43653. if (point.graphic) {
  43654. point.graphic.element.point = point;
  43655. }
  43656. dataLabels.forEach(function (dataLabel) {
  43657. if (dataLabel.div) {
  43658. dataLabel.div.point = point;
  43659. }
  43660. else {
  43661. dataLabel.element.point = point;
  43662. }
  43663. });
  43664. });
  43665. // Add the event listeners, we need to do this only once
  43666. if (!series._hasTracking) {
  43667. series.trackerGroups.forEach(function (key) {
  43668. if (series[key]) {
  43669. // we don't always have dataLabelsGroup
  43670. series[key]
  43671. .addClass('highcharts-tracker')
  43672. .on('mouseover', onMouseOver)
  43673. .on('mouseout', function (e) {
  43674. pointer.onTrackerMouseOut(e);
  43675. });
  43676. if (hasTouch) {
  43677. series[key].on('touchstart', onMouseOver);
  43678. }
  43679. if (!chart.styledMode && series.options.cursor) {
  43680. series[key]
  43681. .css(css)
  43682. .css({ cursor: series.options.cursor });
  43683. }
  43684. }
  43685. });
  43686. series._hasTracking = true;
  43687. }
  43688. fireEvent(this, 'afterDrawTracker');
  43689. },
  43690. /**
  43691. * Draw the tracker object that sits above all data labels and markers to
  43692. * track mouse events on the graph or points. For the line type charts
  43693. * the tracker uses the same graphPath, but with a greater stroke width
  43694. * for better control.
  43695. *
  43696. * @private
  43697. * @function Highcharts.TrackerMixin.drawTrackerGraph
  43698. * @param {Highcharts.Series} this
  43699. * @fires Highcharts.Series#event:afterDrawTracker
  43700. */
  43701. drawTrackerGraph: function () {
  43702. var series = this,
  43703. options = series.options,
  43704. trackByArea = options.trackByArea,
  43705. trackerPath = [].concat(trackByArea ?
  43706. series.areaPath :
  43707. series.graphPath),
  43708. // trackerPathLength = trackerPath.length,
  43709. chart = series.chart,
  43710. pointer = chart.pointer,
  43711. renderer = chart.renderer,
  43712. snap = chart.options.tooltip.snap,
  43713. tracker = series.tracker,
  43714. i,
  43715. onMouseOver = function (e) {
  43716. if (chart.hoverSeries !== series) {
  43717. series.onMouseOver();
  43718. }
  43719. },
  43720. /*
  43721. * Empirical lowest possible opacities for TRACKER_FILL for an
  43722. * element to stay invisible but clickable
  43723. * IE6: 0.002
  43724. * IE7: 0.002
  43725. * IE8: 0.002
  43726. * IE9: 0.00000000001 (unlimited)
  43727. * IE10: 0.0001 (exporting only)
  43728. * FF: 0.00000000001 (unlimited)
  43729. * Chrome: 0.000001
  43730. * Safari: 0.000001
  43731. * Opera: 0.00000000001 (unlimited)
  43732. */
  43733. TRACKER_FILL = 'rgba(192,192,192,' + (svg ? 0.0001 : 0.002) + ')';
  43734. // Draw the tracker
  43735. if (tracker) {
  43736. tracker.attr({ d: trackerPath });
  43737. }
  43738. else if (series.graph) { // create
  43739. series.tracker = renderer.path(trackerPath)
  43740. .attr({
  43741. visibility: series.visible ? 'visible' : 'hidden',
  43742. zIndex: 2
  43743. })
  43744. .addClass(trackByArea ?
  43745. 'highcharts-tracker-area' :
  43746. 'highcharts-tracker-line')
  43747. .add(series.group);
  43748. if (!chart.styledMode) {
  43749. series.tracker.attr({
  43750. 'stroke-linecap': 'round',
  43751. 'stroke-linejoin': 'round',
  43752. stroke: TRACKER_FILL,
  43753. fill: trackByArea ? TRACKER_FILL : 'none',
  43754. 'stroke-width': series.graph.strokeWidth() +
  43755. (trackByArea ? 0 : 2 * snap)
  43756. });
  43757. }
  43758. // The tracker is added to the series group, which is clipped, but
  43759. // is covered by the marker group. So the marker group also needs to
  43760. // capture events.
  43761. [series.tracker, series.markerGroup].forEach(function (tracker) {
  43762. tracker.addClass('highcharts-tracker')
  43763. .on('mouseover', onMouseOver)
  43764. .on('mouseout', function (e) {
  43765. pointer.onTrackerMouseOut(e);
  43766. });
  43767. if (options.cursor && !chart.styledMode) {
  43768. tracker.css({ cursor: options.cursor });
  43769. }
  43770. if (hasTouch) {
  43771. tracker.on('touchstart', onMouseOver);
  43772. }
  43773. });
  43774. }
  43775. fireEvent(this, 'afterDrawTracker');
  43776. }
  43777. };
  43778. /* End TrackerMixin */
  43779. // Add tracking event listener to the series group, so the point graphics
  43780. // themselves act as trackers
  43781. if (seriesTypes.column) {
  43782. /**
  43783. * @private
  43784. * @borrows Highcharts.TrackerMixin.drawTrackerPoint as Highcharts.seriesTypes.column#drawTracker
  43785. */
  43786. seriesTypes.column.prototype.drawTracker = TrackerMixin.drawTrackerPoint;
  43787. }
  43788. if (seriesTypes.pie) {
  43789. /**
  43790. * @private
  43791. * @borrows Highcharts.TrackerMixin.drawTrackerPoint as Highcharts.seriesTypes.pie#drawTracker
  43792. */
  43793. seriesTypes.pie.prototype.drawTracker = TrackerMixin.drawTrackerPoint;
  43794. }
  43795. if (seriesTypes.scatter) {
  43796. /**
  43797. * @private
  43798. * @borrows Highcharts.TrackerMixin.drawTrackerPoint as Highcharts.seriesTypes.scatter#drawTracker
  43799. */
  43800. seriesTypes.scatter.prototype.drawTracker = TrackerMixin.drawTrackerPoint;
  43801. }
  43802. // Extend Legend for item events.
  43803. extend(Legend.prototype, {
  43804. /**
  43805. * @private
  43806. * @function Highcharts.Legend#setItemEvents
  43807. * @param {Highcharts.BubbleLegend|Point|Highcharts.Series} item
  43808. * @param {Highcharts.SVGElement} legendItem
  43809. * @param {boolean} [useHTML=false]
  43810. * @fires Highcharts.Point#event:legendItemClick
  43811. * @fires Highcharts.Series#event:legendItemClick
  43812. */
  43813. setItemEvents: function (item, legendItem, useHTML) {
  43814. var legend = this,
  43815. boxWrapper = legend.chart.renderer.boxWrapper,
  43816. isPoint = item instanceof Point,
  43817. activeClass = 'highcharts-legend-' +
  43818. (isPoint ? 'point' : 'series') + '-active',
  43819. styledMode = legend.chart.styledMode,
  43820. // When `useHTML`, the symbol is rendered in other group, so
  43821. // we need to apply events listeners to both places
  43822. legendItems = useHTML ?
  43823. [legendItem,
  43824. item.legendSymbol] :
  43825. [item.legendGroup];
  43826. // Set the events on the item group, or in case of useHTML, the item
  43827. // itself (#1249)
  43828. legendItems.forEach(function (element) {
  43829. if (element) {
  43830. element
  43831. .on('mouseover', function () {
  43832. if (item.visible) {
  43833. legend.allItems.forEach(function (inactiveItem) {
  43834. if (item !== inactiveItem) {
  43835. inactiveItem.setState('inactive', !isPoint);
  43836. }
  43837. });
  43838. }
  43839. item.setState('hover');
  43840. // A CSS class to dim or hide other than the hovered
  43841. // series.
  43842. // Works only if hovered series is visible (#10071).
  43843. if (item.visible) {
  43844. boxWrapper.addClass(activeClass);
  43845. }
  43846. if (!styledMode) {
  43847. legendItem.css(legend.options.itemHoverStyle);
  43848. }
  43849. })
  43850. .on('mouseout', function () {
  43851. if (!legend.chart.styledMode) {
  43852. legendItem.css(merge(item.visible ?
  43853. legend.itemStyle :
  43854. legend.itemHiddenStyle));
  43855. }
  43856. legend.allItems.forEach(function (inactiveItem) {
  43857. if (item !== inactiveItem) {
  43858. inactiveItem.setState('', !isPoint);
  43859. }
  43860. });
  43861. // A CSS class to dim or hide other than the hovered
  43862. // series.
  43863. boxWrapper.removeClass(activeClass);
  43864. item.setState();
  43865. })
  43866. .on('click', function (event) {
  43867. var strLegendItemClick = 'legendItemClick',
  43868. fnLegendItemClick = function () {
  43869. if (item.setVisible) {
  43870. item.setVisible();
  43871. }
  43872. // Reset inactive state
  43873. legend.allItems.forEach(function (inactiveItem) {
  43874. if (item !== inactiveItem) {
  43875. inactiveItem.setState(item.visible ? 'inactive' : '', !isPoint);
  43876. }
  43877. });
  43878. };
  43879. // A CSS class to dim or hide other than the hovered
  43880. // series. Event handling in iOS causes the activeClass
  43881. // to be added prior to click in some cases (#7418).
  43882. boxWrapper.removeClass(activeClass);
  43883. // Pass over the click/touch event. #4.
  43884. event = {
  43885. browserEvent: event
  43886. };
  43887. // click the name or symbol
  43888. if (item.firePointEvent) { // point
  43889. item.firePointEvent(strLegendItemClick, event, fnLegendItemClick);
  43890. }
  43891. else {
  43892. fireEvent(item, strLegendItemClick, event, fnLegendItemClick);
  43893. }
  43894. });
  43895. }
  43896. });
  43897. },
  43898. /**
  43899. * @private
  43900. * @function Highcharts.Legend#createCheckboxForItem
  43901. * @param {Highcharts.BubbleLegend|Point|Highcharts.Series} item
  43902. * @fires Highcharts.Series#event:checkboxClick
  43903. */
  43904. createCheckboxForItem: function (item) {
  43905. var legend = this;
  43906. item.checkbox = createElement('input', {
  43907. type: 'checkbox',
  43908. className: 'highcharts-legend-checkbox',
  43909. checked: item.selected,
  43910. defaultChecked: item.selected // required by IE7
  43911. }, legend.options.itemCheckboxStyle, legend.chart.container);
  43912. addEvent(item.checkbox, 'click', function (event) {
  43913. var target = event.target;
  43914. fireEvent(item.series || item, 'checkboxClick', {
  43915. checked: target.checked,
  43916. item: item
  43917. }, function () {
  43918. item.select();
  43919. });
  43920. });
  43921. }
  43922. });
  43923. // Extend the Chart object with interaction
  43924. extend(Chart.prototype, /** @lends Chart.prototype */ {
  43925. /**
  43926. * Display the zoom button, so users can reset zoom to the default view
  43927. * settings.
  43928. *
  43929. * @function Highcharts.Chart#showResetZoom
  43930. *
  43931. * @fires Highcharts.Chart#event:afterShowResetZoom
  43932. * @fires Highcharts.Chart#event:beforeShowResetZoom
  43933. */
  43934. showResetZoom: function () {
  43935. var chart = this,
  43936. lang = defaultOptions.lang,
  43937. btnOptions = chart.options.chart.resetZoomButton,
  43938. theme = btnOptions.theme,
  43939. states = theme.states,
  43940. alignTo = (btnOptions.relativeTo === 'chart' ||
  43941. btnOptions.relativeTo === 'spaceBox' ?
  43942. null :
  43943. 'plotBox');
  43944. /**
  43945. * @private
  43946. */
  43947. function zoomOut() {
  43948. chart.zoomOut();
  43949. }
  43950. fireEvent(this, 'beforeShowResetZoom', null, function () {
  43951. chart.resetZoomButton = chart.renderer
  43952. .button(lang.resetZoom, null, null, zoomOut, theme, states && states.hover)
  43953. .attr({
  43954. align: btnOptions.position.align,
  43955. title: lang.resetZoomTitle
  43956. })
  43957. .addClass('highcharts-reset-zoom')
  43958. .add()
  43959. .align(btnOptions.position, false, alignTo);
  43960. });
  43961. fireEvent(this, 'afterShowResetZoom');
  43962. },
  43963. /**
  43964. * Zoom the chart out after a user has zoomed in. See also
  43965. * [Axis.setExtremes](/class-reference/Highcharts.Axis#setExtremes).
  43966. *
  43967. * @function Highcharts.Chart#zoomOut
  43968. *
  43969. * @fires Highcharts.Chart#event:selection
  43970. */
  43971. zoomOut: function () {
  43972. fireEvent(this, 'selection', { resetSelection: true }, this.zoom);
  43973. },
  43974. /**
  43975. * Zoom into a given portion of the chart given by axis coordinates.
  43976. *
  43977. * @private
  43978. * @function Highcharts.Chart#zoom
  43979. * @param {Highcharts.SelectEventObject} event
  43980. */
  43981. zoom: function (event) {
  43982. var chart = this,
  43983. hasZoomed,
  43984. pointer = chart.pointer,
  43985. displayButton = false,
  43986. mouseDownPos = chart.inverted ? pointer.mouseDownX : pointer.mouseDownY,
  43987. resetZoomButton;
  43988. // If zoom is called with no arguments, reset the axes
  43989. if (!event || event.resetSelection) {
  43990. chart.axes.forEach(function (axis) {
  43991. hasZoomed = axis.zoom();
  43992. });
  43993. pointer.initiated = false; // #6804
  43994. }
  43995. else { // else, zoom in on all axes
  43996. event.xAxis.concat(event.yAxis).forEach(function (axisData) {
  43997. var axis = axisData.axis,
  43998. axisStartPos = chart.inverted ? axis.left : axis.top,
  43999. axisEndPos = chart.inverted ?
  44000. axisStartPos + axis.width : axisStartPos + axis.height,
  44001. isXAxis = axis.isXAxis,
  44002. isWithinPane = false;
  44003. // Check if zoomed area is within the pane (#1289).
  44004. // In case of multiple panes only one pane should be zoomed.
  44005. if ((!isXAxis &&
  44006. mouseDownPos >= axisStartPos &&
  44007. mouseDownPos <= axisEndPos) ||
  44008. isXAxis ||
  44009. !defined(mouseDownPos)) {
  44010. isWithinPane = true;
  44011. }
  44012. // don't zoom more than minRange
  44013. if (pointer[isXAxis ? 'zoomX' : 'zoomY'] && isWithinPane) {
  44014. hasZoomed = axis.zoom(axisData.min, axisData.max);
  44015. if (axis.displayBtn) {
  44016. displayButton = true;
  44017. }
  44018. }
  44019. });
  44020. }
  44021. // Show or hide the Reset zoom button
  44022. resetZoomButton = chart.resetZoomButton;
  44023. if (displayButton && !resetZoomButton) {
  44024. chart.showResetZoom();
  44025. }
  44026. else if (!displayButton && isObject(resetZoomButton)) {
  44027. chart.resetZoomButton = resetZoomButton.destroy();
  44028. }
  44029. // Redraw
  44030. if (hasZoomed) {
  44031. chart.redraw(pick(chart.options.chart.animation, event && event.animation, chart.pointCount < 100));
  44032. }
  44033. },
  44034. /**
  44035. * Pan the chart by dragging the mouse across the pane. This function is
  44036. * called on mouse move, and the distance to pan is computed from chartX
  44037. * compared to the first chartX position in the dragging operation.
  44038. *
  44039. * @private
  44040. * @function Highcharts.Chart#pan
  44041. * @param {Highcharts.PointerEventObject} e
  44042. * @param {string} panning
  44043. */
  44044. pan: function (e, panning) {
  44045. var chart = this,
  44046. hoverPoints = chart.hoverPoints,
  44047. panningOptions,
  44048. chartOptions = chart.options.chart,
  44049. hasMapNavigation = chart.options.mapNavigation &&
  44050. chart.options.mapNavigation.enabled,
  44051. doRedraw,
  44052. type;
  44053. if (typeof panning === 'object') {
  44054. panningOptions = panning;
  44055. }
  44056. else {
  44057. panningOptions = {
  44058. enabled: panning,
  44059. type: 'x'
  44060. };
  44061. }
  44062. if (chartOptions && chartOptions.panning) {
  44063. chartOptions.panning = panningOptions;
  44064. }
  44065. type = panningOptions.type;
  44066. fireEvent(this, 'pan', { originalEvent: e }, function () {
  44067. // remove active points for shared tooltip
  44068. if (hoverPoints) {
  44069. hoverPoints.forEach(function (point) {
  44070. point.setState();
  44071. });
  44072. }
  44073. // panning axis mapping
  44074. var xy = [1]; // x
  44075. if (type === 'xy') {
  44076. xy = [1, 0];
  44077. }
  44078. else if (type === 'y') {
  44079. xy = [0];
  44080. }
  44081. xy.forEach(function (isX) {
  44082. 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) ||
  44083. (!axis.reversed && chart.inverted) ?
  44084. -1 :
  44085. 1, extremes = axis.getExtremes(), panMin = axis.toValue(startPos - mousePos, true) +
  44086. halfPointRange * pointRangeDirection, panMax = axis.toValue(startPos + axis.len - mousePos, true) -
  44087. halfPointRange * pointRangeDirection, flipped = panMax < panMin, newMin = flipped ? panMax : panMin, newMax = flipped ? panMin : panMax, hasVerticalPanning = axis.hasVerticalPanning(), paddedMin, paddedMax, spill, panningState = axis.panningState;
  44088. // General calculations of panning state.
  44089. // This is related to using vertical panning. (#11315).
  44090. axis.series.forEach(function (series) {
  44091. if (hasVerticalPanning &&
  44092. !isX && (!panningState || panningState.isDirty)) {
  44093. var processedData = series.getProcessedData(true),
  44094. dataExtremes = series.getExtremes(processedData.yData,
  44095. true);
  44096. if (!panningState) {
  44097. panningState = {
  44098. startMin: Number.MAX_VALUE,
  44099. startMax: -Number.MAX_VALUE
  44100. };
  44101. }
  44102. if (isNumber(dataExtremes.dataMin) &&
  44103. isNumber(dataExtremes.dataMax)) {
  44104. panningState.startMin = Math.min(dataExtremes.dataMin, panningState.startMin);
  44105. panningState.startMax = Math.max(dataExtremes.dataMax, panningState.startMax);
  44106. }
  44107. }
  44108. });
  44109. paddedMin = Math.min(pick(panningState === null || panningState === void 0 ? void 0 : panningState.startMin, extremes.dataMin), halfPointRange ?
  44110. extremes.min :
  44111. axis.toValue(axis.toPixels(extremes.min) -
  44112. axis.minPixelPadding));
  44113. paddedMax = Math.max(pick(panningState === null || panningState === void 0 ? void 0 : panningState.startMax, extremes.dataMax), halfPointRange ?
  44114. extremes.max :
  44115. axis.toValue(axis.toPixels(extremes.max) +
  44116. axis.minPixelPadding));
  44117. axis.panningState = panningState;
  44118. // It is not necessary to calculate extremes on ordinal axis,
  44119. // because they are already calculated, so we don't want to
  44120. // override them.
  44121. if (!axis.isOrdinal) {
  44122. // If the new range spills over, either to the min or max,
  44123. // adjust the new range.
  44124. spill = paddedMin - newMin;
  44125. if (spill > 0) {
  44126. newMax += spill;
  44127. newMin = paddedMin;
  44128. }
  44129. spill = newMax - paddedMax;
  44130. if (spill > 0) {
  44131. newMax = paddedMax;
  44132. newMin -= spill;
  44133. }
  44134. // Set new extremes if they are actually new
  44135. if (axis.series.length &&
  44136. newMin !== extremes.min &&
  44137. newMax !== extremes.max &&
  44138. newMin >= paddedMin &&
  44139. newMax <= paddedMax) {
  44140. axis.setExtremes(newMin, newMax, false, false, { trigger: 'pan' });
  44141. if (!chart.resetZoomButton &&
  44142. !hasMapNavigation &&
  44143. // Show reset zoom button only when both newMin and
  44144. // newMax values are between padded axis range.
  44145. newMin !== paddedMin &&
  44146. newMax !== paddedMax &&
  44147. type.match('y')) {
  44148. chart.showResetZoom();
  44149. axis.displayBtn = false;
  44150. }
  44151. doRedraw = true;
  44152. }
  44153. // set new reference for next run:
  44154. chart[mouseDown] = mousePos;
  44155. }
  44156. });
  44157. if (doRedraw) {
  44158. chart.redraw(false);
  44159. }
  44160. css(chart.container, { cursor: 'move' });
  44161. });
  44162. }
  44163. });
  44164. // Extend the Point object with interaction
  44165. extend(Point.prototype, /** @lends Highcharts.Point.prototype */ {
  44166. /**
  44167. * Toggle the selection status of a point.
  44168. *
  44169. * @see Highcharts.Chart#getSelectedPoints
  44170. *
  44171. * @sample highcharts/members/point-select/
  44172. * Select a point from a button
  44173. * @sample highcharts/chart/events-selection-points/
  44174. * Select a range of points through a drag selection
  44175. * @sample maps/series/data-id/
  44176. * Select a point in Highmaps
  44177. *
  44178. * @function Highcharts.Point#select
  44179. *
  44180. * @param {boolean} [selected]
  44181. * When `true`, the point is selected. When `false`, the point is
  44182. * unselected. When `null` or `undefined`, the selection state is toggled.
  44183. *
  44184. * @param {boolean} [accumulate=false]
  44185. * When `true`, the selection is added to other selected points.
  44186. * When `false`, other selected points are deselected. Internally in
  44187. * Highcharts, when
  44188. * [allowPointSelect](https://api.highcharts.com/highcharts/plotOptions.series.allowPointSelect)
  44189. * is `true`, selected points are accumulated on Control, Shift or Cmd
  44190. * clicking the point.
  44191. *
  44192. * @fires Highcharts.Point#event:select
  44193. * @fires Highcharts.Point#event:unselect
  44194. */
  44195. select: function (selected, accumulate) {
  44196. var point = this,
  44197. series = point.series,
  44198. chart = series.chart;
  44199. selected = pick(selected, !point.selected);
  44200. this.selectedStaging = selected;
  44201. // fire the event with the default handler
  44202. point.firePointEvent(selected ? 'select' : 'unselect', { accumulate: accumulate }, function () {
  44203. /**
  44204. * Whether the point is selected or not.
  44205. *
  44206. * @see Point#select
  44207. * @see Chart#getSelectedPoints
  44208. *
  44209. * @name Highcharts.Point#selected
  44210. * @type {boolean}
  44211. */
  44212. point.selected = point.options.selected = selected;
  44213. series.options.data[series.data.indexOf(point)] =
  44214. point.options;
  44215. point.setState(selected && 'select');
  44216. // unselect all other points unless Ctrl or Cmd + click
  44217. if (!accumulate) {
  44218. chart.getSelectedPoints().forEach(function (loopPoint) {
  44219. var loopSeries = loopPoint.series;
  44220. if (loopPoint.selected && loopPoint !== point) {
  44221. loopPoint.selected = loopPoint.options.selected =
  44222. false;
  44223. loopSeries.options.data[loopSeries.data.indexOf(loopPoint)] = loopPoint.options;
  44224. // Programatically selecting a point should restore
  44225. // normal state, but when click happened on other
  44226. // point, set inactive state to match other points
  44227. loopPoint.setState(chart.hoverPoints &&
  44228. loopSeries.options.inactiveOtherPoints ?
  44229. 'inactive' : '');
  44230. loopPoint.firePointEvent('unselect');
  44231. }
  44232. });
  44233. }
  44234. });
  44235. delete this.selectedStaging;
  44236. },
  44237. /**
  44238. * Runs on mouse over the point. Called internally from mouse and touch
  44239. * events.
  44240. *
  44241. * @function Highcharts.Point#onMouseOver
  44242. *
  44243. * @param {Highcharts.PointerEventObject} [e]
  44244. * The event arguments.
  44245. */
  44246. onMouseOver: function (e) {
  44247. var point = this,
  44248. series = point.series,
  44249. chart = series.chart,
  44250. pointer = chart.pointer;
  44251. e = e ?
  44252. pointer.normalize(e) :
  44253. // In cases where onMouseOver is called directly without an event
  44254. pointer.getChartCoordinatesFromPoint(point, chart.inverted);
  44255. pointer.runPointActions(e, point);
  44256. },
  44257. /**
  44258. * Runs on mouse out from the point. Called internally from mouse and touch
  44259. * events.
  44260. *
  44261. * @function Highcharts.Point#onMouseOut
  44262. * @fires Highcharts.Point#event:mouseOut
  44263. */
  44264. onMouseOut: function () {
  44265. var point = this,
  44266. chart = point.series.chart;
  44267. point.firePointEvent('mouseOut');
  44268. if (!point.series.options.inactiveOtherPoints) {
  44269. (chart.hoverPoints || []).forEach(function (p) {
  44270. p.setState();
  44271. });
  44272. }
  44273. chart.hoverPoints = chart.hoverPoint = null;
  44274. },
  44275. /**
  44276. * Import events from the series' and point's options. Only do it on
  44277. * demand, to save processing time on hovering.
  44278. *
  44279. * @private
  44280. * @function Highcharts.Point#importEvents
  44281. */
  44282. importEvents: function () {
  44283. if (!this.hasImportedEvents) {
  44284. var point = this,
  44285. options = merge(point.series.options.point,
  44286. point.options),
  44287. events = options.events;
  44288. point.events = events;
  44289. objectEach(events, function (event, eventType) {
  44290. if (isFunction(event)) {
  44291. addEvent(point, eventType, event);
  44292. }
  44293. });
  44294. this.hasImportedEvents = true;
  44295. }
  44296. },
  44297. /**
  44298. * Set the point's state.
  44299. *
  44300. * @function Highcharts.Point#setState
  44301. *
  44302. * @param {Highcharts.PointStateValue|""} [state]
  44303. * The new state, can be one of `'hover'`, `'select'`, `'inactive'`,
  44304. * or `''` (an empty string), `'normal'` or `undefined` to set to
  44305. * normal state.
  44306. * @param {boolean} [move]
  44307. * State for animation.
  44308. *
  44309. * @fires Highcharts.Point#event:afterSetState
  44310. */
  44311. setState: function (state, move) {
  44312. var point = this,
  44313. series = point.series,
  44314. previousState = point.state,
  44315. stateOptions = (series.options.states[state || 'normal'] ||
  44316. {}),
  44317. markerOptions = (defaultOptions.plotOptions[series.type].marker &&
  44318. series.options.marker),
  44319. normalDisabled = (markerOptions && markerOptions.enabled === false),
  44320. markerStateOptions = ((markerOptions &&
  44321. markerOptions.states &&
  44322. markerOptions.states[state || 'normal']) || {}),
  44323. stateDisabled = markerStateOptions.enabled === false,
  44324. stateMarkerGraphic = series.stateMarkerGraphic,
  44325. pointMarker = point.marker || {},
  44326. chart = series.chart,
  44327. halo = series.halo,
  44328. haloOptions,
  44329. markerAttribs,
  44330. pointAttribs,
  44331. pointAttribsAnimation,
  44332. hasMarkers = (markerOptions && series.markerAttribs),
  44333. newSymbol;
  44334. state = state || ''; // empty string
  44335. if (
  44336. // already has this state
  44337. (state === point.state && !move) ||
  44338. // selected points don't respond to hover
  44339. (point.selected && state !== 'select') ||
  44340. // series' state options is disabled
  44341. (stateOptions.enabled === false) ||
  44342. // general point marker's state options is disabled
  44343. (state && (stateDisabled ||
  44344. (normalDisabled &&
  44345. markerStateOptions.enabled === false))) ||
  44346. // individual point marker's state options is disabled
  44347. (state &&
  44348. pointMarker.states &&
  44349. pointMarker.states[state] &&
  44350. pointMarker.states[state].enabled === false) // #1610
  44351. ) {
  44352. return;
  44353. }
  44354. point.state = state;
  44355. if (hasMarkers) {
  44356. markerAttribs = series.markerAttribs(point, state);
  44357. }
  44358. // Apply hover styles to the existing point
  44359. if (point.graphic) {
  44360. if (previousState) {
  44361. point.graphic.removeClass('highcharts-point-' + previousState);
  44362. }
  44363. if (state) {
  44364. point.graphic.addClass('highcharts-point-' + state);
  44365. }
  44366. if (!chart.styledMode) {
  44367. pointAttribs = series.pointAttribs(point, state);
  44368. pointAttribsAnimation = pick(chart.options.chart.animation, stateOptions.animation);
  44369. // Some inactive points (e.g. slices in pie) should apply
  44370. // oppacity also for it's labels
  44371. if (series.options.inactiveOtherPoints && pointAttribs.opacity) {
  44372. (point.dataLabels || []).forEach(function (label) {
  44373. if (label) {
  44374. label.animate({
  44375. opacity: pointAttribs.opacity
  44376. }, pointAttribsAnimation);
  44377. }
  44378. });
  44379. if (point.connector) {
  44380. point.connector.animate({
  44381. opacity: pointAttribs.opacity
  44382. }, pointAttribsAnimation);
  44383. }
  44384. }
  44385. point.graphic.animate(pointAttribs, pointAttribsAnimation);
  44386. }
  44387. if (markerAttribs) {
  44388. point.graphic.animate(markerAttribs, pick(
  44389. // Turn off globally:
  44390. chart.options.chart.animation, markerStateOptions.animation, markerOptions.animation));
  44391. }
  44392. // Zooming in from a range with no markers to a range with markers
  44393. if (stateMarkerGraphic) {
  44394. stateMarkerGraphic.hide();
  44395. }
  44396. }
  44397. else {
  44398. // if a graphic is not applied to each point in the normal state,
  44399. // create a shared graphic for the hover state
  44400. if (state && markerStateOptions) {
  44401. newSymbol = pointMarker.symbol || series.symbol;
  44402. // If the point has another symbol than the previous one, throw
  44403. // away the state marker graphic and force a new one (#1459)
  44404. if (stateMarkerGraphic &&
  44405. stateMarkerGraphic.currentSymbol !== newSymbol) {
  44406. stateMarkerGraphic = stateMarkerGraphic.destroy();
  44407. }
  44408. // Add a new state marker graphic
  44409. if (markerAttribs) {
  44410. if (!stateMarkerGraphic) {
  44411. if (newSymbol) {
  44412. series.stateMarkerGraphic = stateMarkerGraphic =
  44413. chart.renderer
  44414. .symbol(newSymbol, markerAttribs.x, markerAttribs.y, markerAttribs.width, markerAttribs.height)
  44415. .add(series.markerGroup);
  44416. stateMarkerGraphic.currentSymbol = newSymbol;
  44417. }
  44418. // Move the existing graphic
  44419. }
  44420. else {
  44421. stateMarkerGraphic[move ? 'animate' : 'attr']({
  44422. x: markerAttribs.x,
  44423. y: markerAttribs.y
  44424. });
  44425. }
  44426. }
  44427. if (!chart.styledMode && stateMarkerGraphic) {
  44428. stateMarkerGraphic.attr(series.pointAttribs(point, state));
  44429. }
  44430. }
  44431. if (stateMarkerGraphic) {
  44432. stateMarkerGraphic[state && point.isInside ? 'show' : 'hide'](); // #2450
  44433. stateMarkerGraphic.element.point = point; // #4310
  44434. }
  44435. }
  44436. // Show me your halo
  44437. haloOptions = stateOptions.halo;
  44438. var markerGraphic = (point.graphic || stateMarkerGraphic);
  44439. var markerVisibility = (markerGraphic && markerGraphic.visibility || 'inherit');
  44440. if (haloOptions &&
  44441. haloOptions.size &&
  44442. markerGraphic &&
  44443. markerVisibility !== 'hidden' &&
  44444. !point.isCluster) {
  44445. if (!halo) {
  44446. series.halo = halo = chart.renderer.path()
  44447. // #5818, #5903, #6705
  44448. .add(markerGraphic.parentGroup);
  44449. }
  44450. halo.show()[move ? 'animate' : 'attr']({
  44451. d: point.haloPath(haloOptions.size)
  44452. });
  44453. halo.attr({
  44454. 'class': 'highcharts-halo highcharts-color-' +
  44455. pick(point.colorIndex, series.colorIndex) +
  44456. (point.className ? ' ' + point.className : ''),
  44457. 'visibility': markerVisibility,
  44458. 'zIndex': -1 // #4929, #8276
  44459. });
  44460. halo.point = point; // #6055
  44461. if (!chart.styledMode) {
  44462. halo.attr(extend({
  44463. 'fill': point.color || series.color,
  44464. 'fill-opacity': haloOptions.opacity
  44465. }, haloOptions.attributes));
  44466. }
  44467. }
  44468. else if (halo && halo.point && halo.point.haloPath) {
  44469. // Animate back to 0 on the current halo point (#6055)
  44470. halo.animate({ d: halo.point.haloPath(0) }, null,
  44471. // Hide after unhovering. The `complete` callback runs in the
  44472. // halo's context (#7681).
  44473. halo.hide);
  44474. }
  44475. fireEvent(point, 'afterSetState');
  44476. },
  44477. /**
  44478. * Get the path definition for the halo, which is usually a shadow-like
  44479. * circle around the currently hovered point.
  44480. *
  44481. * @function Highcharts.Point#haloPath
  44482. *
  44483. * @param {number} size
  44484. * The radius of the circular halo.
  44485. *
  44486. * @return {Highcharts.SVGPathArray}
  44487. * The path definition.
  44488. */
  44489. haloPath: function (size) {
  44490. var series = this.series,
  44491. chart = series.chart;
  44492. return chart.renderer.symbols.circle(Math.floor(this.plotX) - size, this.plotY - size, size * 2, size * 2);
  44493. }
  44494. });
  44495. // Extend the Series object with interaction
  44496. extend(LineSeries.prototype, /** @lends Highcharts.Series.prototype */ {
  44497. /**
  44498. * Runs on mouse over the series graphical items.
  44499. *
  44500. * @function Highcharts.Series#onMouseOver
  44501. * @fires Highcharts.Series#event:mouseOver
  44502. */
  44503. onMouseOver: function () {
  44504. var series = this,
  44505. chart = series.chart,
  44506. hoverSeries = chart.hoverSeries,
  44507. pointer = chart.pointer;
  44508. pointer.setHoverChartIndex();
  44509. // set normal state to previous series
  44510. if (hoverSeries && hoverSeries !== series) {
  44511. hoverSeries.onMouseOut();
  44512. }
  44513. // trigger the event, but to save processing time,
  44514. // only if defined
  44515. if (series.options.events.mouseOver) {
  44516. fireEvent(series, 'mouseOver');
  44517. }
  44518. // hover this
  44519. series.setState('hover');
  44520. /**
  44521. * Contains the original hovered series.
  44522. *
  44523. * @name Highcharts.Chart#hoverSeries
  44524. * @type {Highcharts.Series|null}
  44525. */
  44526. chart.hoverSeries = series;
  44527. },
  44528. /**
  44529. * Runs on mouse out of the series graphical items.
  44530. *
  44531. * @function Highcharts.Series#onMouseOut
  44532. *
  44533. * @fires Highcharts.Series#event:mouseOut
  44534. */
  44535. onMouseOut: function () {
  44536. // trigger the event only if listeners exist
  44537. var series = this,
  44538. options = series.options,
  44539. chart = series.chart,
  44540. tooltip = chart.tooltip,
  44541. hoverPoint = chart.hoverPoint;
  44542. // #182, set to null before the mouseOut event fires
  44543. chart.hoverSeries = null;
  44544. // trigger mouse out on the point, which must be in this series
  44545. if (hoverPoint) {
  44546. hoverPoint.onMouseOut();
  44547. }
  44548. // fire the mouse out event
  44549. if (series && options.events.mouseOut) {
  44550. fireEvent(series, 'mouseOut');
  44551. }
  44552. // hide the tooltip
  44553. if (tooltip &&
  44554. !series.stickyTracking &&
  44555. (!tooltip.shared || series.noSharedTooltip)) {
  44556. tooltip.hide();
  44557. }
  44558. // Reset all inactive states
  44559. chart.series.forEach(function (s) {
  44560. s.setState('', true);
  44561. });
  44562. },
  44563. /**
  44564. * Set the state of the series. Called internally on mouse interaction
  44565. * operations, but it can also be called directly to visually
  44566. * highlight a series.
  44567. *
  44568. * @function Highcharts.Series#setState
  44569. *
  44570. * @param {Highcharts.SeriesStateValue|""} [state]
  44571. * The new state, can be either `'hover'`, `'inactive'`, `'select'`,
  44572. * or `''` (an empty string), `'normal'` or `undefined` to set to
  44573. * normal state.
  44574. * @param {boolean} [inherit]
  44575. * Determines if state should be inherited by points too.
  44576. */
  44577. setState: function (state, inherit) {
  44578. var series = this,
  44579. options = series.options,
  44580. graph = series.graph,
  44581. inactiveOtherPoints = options.inactiveOtherPoints,
  44582. stateOptions = options.states,
  44583. lineWidth = options.lineWidth,
  44584. opacity = options.opacity,
  44585. // By default a quick animation to hover/inactive,
  44586. // slower to un-hover
  44587. stateAnimation = pick((stateOptions[state || 'normal'] &&
  44588. stateOptions[state || 'normal'].animation),
  44589. series.chart.options.chart.animation),
  44590. attribs,
  44591. i = 0;
  44592. state = state || '';
  44593. if (series.state !== state) {
  44594. // Toggle class names
  44595. [
  44596. series.group,
  44597. series.markerGroup,
  44598. series.dataLabelsGroup
  44599. ].forEach(function (group) {
  44600. if (group) {
  44601. // Old state
  44602. if (series.state) {
  44603. group.removeClass('highcharts-series-' + series.state);
  44604. }
  44605. // New state
  44606. if (state) {
  44607. group.addClass('highcharts-series-' + state);
  44608. }
  44609. }
  44610. });
  44611. series.state = state;
  44612. if (!series.chart.styledMode) {
  44613. if (stateOptions[state] &&
  44614. stateOptions[state].enabled === false) {
  44615. return;
  44616. }
  44617. if (state) {
  44618. lineWidth = (stateOptions[state].lineWidth ||
  44619. lineWidth + (stateOptions[state].lineWidthPlus || 0)); // #4035
  44620. opacity = pick(stateOptions[state].opacity, opacity);
  44621. }
  44622. if (graph && !graph.dashstyle) {
  44623. attribs = {
  44624. 'stroke-width': lineWidth
  44625. };
  44626. // Animate the graph stroke-width.
  44627. graph.animate(attribs, stateAnimation);
  44628. while (series['zone-graph-' + i]) {
  44629. series['zone-graph-' + i].attr(attribs);
  44630. i = i + 1;
  44631. }
  44632. }
  44633. // For some types (pie, networkgraph, sankey) opacity is
  44634. // resolved on a point level
  44635. if (!inactiveOtherPoints) {
  44636. [
  44637. series.group,
  44638. series.markerGroup,
  44639. series.dataLabelsGroup,
  44640. series.labelBySeries
  44641. ].forEach(function (group) {
  44642. if (group) {
  44643. group.animate({
  44644. opacity: opacity
  44645. }, stateAnimation);
  44646. }
  44647. });
  44648. }
  44649. }
  44650. }
  44651. // Don't loop over points on a series that doesn't apply inactive state
  44652. // to siblings markers (e.g. line, column)
  44653. if (inherit && inactiveOtherPoints && series.points) {
  44654. series.setAllPointsToState(state);
  44655. }
  44656. },
  44657. /**
  44658. * Set the state for all points in the series.
  44659. *
  44660. * @function Highcharts.Series#setAllPointsToState
  44661. *
  44662. * @private
  44663. *
  44664. * @param {string} [state]
  44665. * Can be either `hover` or undefined to set to normal state.
  44666. */
  44667. setAllPointsToState: function (state) {
  44668. this.points.forEach(function (point) {
  44669. if (point.setState) {
  44670. point.setState(state);
  44671. }
  44672. });
  44673. },
  44674. /**
  44675. * Show or hide the series.
  44676. *
  44677. * @function Highcharts.Series#setVisible
  44678. *
  44679. * @param {boolean} [visible]
  44680. * True to show the series, false to hide. If undefined, the visibility is
  44681. * toggled.
  44682. *
  44683. * @param {boolean} [redraw=true]
  44684. * Whether to redraw the chart after the series is altered. If doing more
  44685. * operations on the chart, it is a good idea to set redraw to false and
  44686. * call {@link Chart#redraw|chart.redraw()} after.
  44687. *
  44688. * @fires Highcharts.Series#event:hide
  44689. * @fires Highcharts.Series#event:show
  44690. */
  44691. setVisible: function (vis, redraw) {
  44692. var series = this,
  44693. chart = series.chart,
  44694. legendItem = series.legendItem,
  44695. showOrHide,
  44696. ignoreHiddenSeries = chart.options.chart.ignoreHiddenSeries,
  44697. oldVisibility = series.visible;
  44698. // if called without an argument, toggle visibility
  44699. series.visible =
  44700. vis =
  44701. series.options.visible =
  44702. series.userOptions.visible =
  44703. typeof vis === 'undefined' ? !oldVisibility : vis; // #5618
  44704. showOrHide = vis ? 'show' : 'hide';
  44705. // show or hide elements
  44706. [
  44707. 'group',
  44708. 'dataLabelsGroup',
  44709. 'markerGroup',
  44710. 'tracker',
  44711. 'tt'
  44712. ].forEach(function (key) {
  44713. if (series[key]) {
  44714. series[key][showOrHide]();
  44715. }
  44716. });
  44717. // hide tooltip (#1361)
  44718. if (chart.hoverSeries === series ||
  44719. (chart.hoverPoint && chart.hoverPoint.series) === series) {
  44720. series.onMouseOut();
  44721. }
  44722. if (legendItem) {
  44723. chart.legend.colorizeItem(series, vis);
  44724. }
  44725. // rescale or adapt to resized chart
  44726. series.isDirty = true;
  44727. // in a stack, all other series are affected
  44728. if (series.options.stacking) {
  44729. chart.series.forEach(function (otherSeries) {
  44730. if (otherSeries.options.stacking && otherSeries.visible) {
  44731. otherSeries.isDirty = true;
  44732. }
  44733. });
  44734. }
  44735. // show or hide linked series
  44736. series.linkedSeries.forEach(function (otherSeries) {
  44737. otherSeries.setVisible(vis, false);
  44738. });
  44739. if (ignoreHiddenSeries) {
  44740. chart.isDirtyBox = true;
  44741. }
  44742. fireEvent(series, showOrHide);
  44743. if (redraw !== false) {
  44744. chart.redraw();
  44745. }
  44746. },
  44747. /**
  44748. * Show the series if hidden.
  44749. *
  44750. * @sample highcharts/members/series-hide/
  44751. * Toggle visibility from a button
  44752. *
  44753. * @function Highcharts.Series#show
  44754. * @fires Highcharts.Series#event:show
  44755. */
  44756. show: function () {
  44757. this.setVisible(true);
  44758. },
  44759. /**
  44760. * Hide the series if visible. If the
  44761. * [chart.ignoreHiddenSeries](https://api.highcharts.com/highcharts/chart.ignoreHiddenSeries)
  44762. * option is true, the chart is redrawn without this series.
  44763. *
  44764. * @sample highcharts/members/series-hide/
  44765. * Toggle visibility from a button
  44766. *
  44767. * @function Highcharts.Series#hide
  44768. * @fires Highcharts.Series#event:hide
  44769. */
  44770. hide: function () {
  44771. this.setVisible(false);
  44772. },
  44773. /**
  44774. * Select or unselect the series. This means its
  44775. * {@link Highcharts.Series.selected|selected}
  44776. * property is set, the checkbox in the legend is toggled and when selected,
  44777. * the series is returned by the {@link Highcharts.Chart#getSelectedSeries}
  44778. * function.
  44779. *
  44780. * @sample highcharts/members/series-select/
  44781. * Select a series from a button
  44782. *
  44783. * @function Highcharts.Series#select
  44784. *
  44785. * @param {boolean} [selected]
  44786. * True to select the series, false to unselect. If undefined, the selection
  44787. * state is toggled.
  44788. *
  44789. * @fires Highcharts.Series#event:select
  44790. * @fires Highcharts.Series#event:unselect
  44791. */
  44792. select: function (selected) {
  44793. var series = this;
  44794. series.selected =
  44795. selected =
  44796. this.options.selected = (typeof selected === 'undefined' ?
  44797. !series.selected :
  44798. selected);
  44799. if (series.checkbox) {
  44800. series.checkbox.checked = selected;
  44801. }
  44802. fireEvent(series, selected ? 'select' : 'unselect');
  44803. },
  44804. /**
  44805. * @private
  44806. * @borrows Highcharts.TrackerMixin.drawTrackerGraph as Highcharts.Series#drawTracker
  44807. */
  44808. drawTracker: TrackerMixin.drawTrackerGraph
  44809. });
  44810. });
  44811. _registerModule(_modules, 'Core/Responsive.js', [_modules['Core/Chart/Chart.js'], _modules['Core/Utilities.js']], function (Chart, U) {
  44812. /* *
  44813. *
  44814. * (c) 2010-2020 Torstein Honsi
  44815. *
  44816. * License: www.highcharts.com/license
  44817. *
  44818. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  44819. *
  44820. * */
  44821. var find = U.find,
  44822. isArray = U.isArray,
  44823. isObject = U.isObject,
  44824. merge = U.merge,
  44825. objectEach = U.objectEach,
  44826. pick = U.pick,
  44827. splat = U.splat,
  44828. uniqueKey = U.uniqueKey;
  44829. /**
  44830. * A callback function to gain complete control on when the responsive rule
  44831. * applies.
  44832. *
  44833. * @callback Highcharts.ResponsiveCallbackFunction
  44834. *
  44835. * @param {Highcharts.Chart} this
  44836. * Chart context.
  44837. *
  44838. * @return {boolean}
  44839. * Return `true` if it applies.
  44840. */
  44841. /**
  44842. * Allows setting a set of rules to apply for different screen or chart
  44843. * sizes. Each rule specifies additional chart options.
  44844. *
  44845. * @sample {highstock} stock/demo/responsive/
  44846. * Stock chart
  44847. * @sample highcharts/responsive/axis/
  44848. * Axis
  44849. * @sample highcharts/responsive/legend/
  44850. * Legend
  44851. * @sample highcharts/responsive/classname/
  44852. * Class name
  44853. *
  44854. * @since 5.0.0
  44855. * @apioption responsive
  44856. */
  44857. /**
  44858. * A set of rules for responsive settings. The rules are executed from
  44859. * the top down.
  44860. *
  44861. * @sample {highcharts} highcharts/responsive/axis/
  44862. * Axis changes
  44863. * @sample {highstock} highcharts/responsive/axis/
  44864. * Axis changes
  44865. * @sample {highmaps} highcharts/responsive/axis/
  44866. * Axis changes
  44867. *
  44868. * @type {Array<*>}
  44869. * @since 5.0.0
  44870. * @apioption responsive.rules
  44871. */
  44872. /**
  44873. * A full set of chart options to apply as overrides to the general
  44874. * chart options. The chart options are applied when the given rule
  44875. * is active.
  44876. *
  44877. * A special case is configuration objects that take arrays, for example
  44878. * [xAxis](#xAxis), [yAxis](#yAxis) or [series](#series). For these
  44879. * collections, an `id` option is used to map the new option set to
  44880. * an existing object. If an existing object of the same id is not found,
  44881. * the item of the same indexupdated. So for example, setting `chartOptions`
  44882. * with two series items without an `id`, will cause the existing chart's
  44883. * two series to be updated with respective options.
  44884. *
  44885. * @sample {highstock} stock/demo/responsive/
  44886. * Stock chart
  44887. * @sample highcharts/responsive/axis/
  44888. * Axis
  44889. * @sample highcharts/responsive/legend/
  44890. * Legend
  44891. * @sample highcharts/responsive/classname/
  44892. * Class name
  44893. *
  44894. * @type {Highcharts.Options}
  44895. * @since 5.0.0
  44896. * @apioption responsive.rules.chartOptions
  44897. */
  44898. /**
  44899. * Under which conditions the rule applies.
  44900. *
  44901. * @since 5.0.0
  44902. * @apioption responsive.rules.condition
  44903. */
  44904. /**
  44905. * A callback function to gain complete control on when the responsive
  44906. * rule applies. Return `true` if it applies. This opens for checking
  44907. * against other metrics than the chart size, for example the document
  44908. * size or other elements.
  44909. *
  44910. * @type {Highcharts.ResponsiveCallbackFunction}
  44911. * @since 5.0.0
  44912. * @context Highcharts.Chart
  44913. * @apioption responsive.rules.condition.callback
  44914. */
  44915. /**
  44916. * The responsive rule applies if the chart height is less than this.
  44917. *
  44918. * @type {number}
  44919. * @since 5.0.0
  44920. * @apioption responsive.rules.condition.maxHeight
  44921. */
  44922. /**
  44923. * The responsive rule applies if the chart width is less than this.
  44924. *
  44925. * @sample highcharts/responsive/axis/
  44926. * Max width is 500
  44927. *
  44928. * @type {number}
  44929. * @since 5.0.0
  44930. * @apioption responsive.rules.condition.maxWidth
  44931. */
  44932. /**
  44933. * The responsive rule applies if the chart height is greater than this.
  44934. *
  44935. * @type {number}
  44936. * @default 0
  44937. * @since 5.0.0
  44938. * @apioption responsive.rules.condition.minHeight
  44939. */
  44940. /**
  44941. * The responsive rule applies if the chart width is greater than this.
  44942. *
  44943. * @type {number}
  44944. * @default 0
  44945. * @since 5.0.0
  44946. * @apioption responsive.rules.condition.minWidth
  44947. */
  44948. /* eslint-disable no-invalid-this, valid-jsdoc */
  44949. /**
  44950. * Update the chart based on the current chart/document size and options for
  44951. * responsiveness.
  44952. *
  44953. * @private
  44954. * @function Highcharts.Chart#setResponsive
  44955. * @param {boolean} [redraw=true]
  44956. * @param {boolean} [reset=false]
  44957. * Reset by un-applying all rules. Chart.update resets all rules before applying
  44958. * updated options.
  44959. */
  44960. Chart.prototype.setResponsive = function (redraw, reset) {
  44961. var options = this.options.responsive,
  44962. ruleIds = [],
  44963. currentResponsive = this.currentResponsive,
  44964. currentRuleIds,
  44965. undoOptions;
  44966. if (!reset && options && options.rules) {
  44967. options.rules.forEach(function (rule) {
  44968. if (typeof rule._id === 'undefined') {
  44969. rule._id = uniqueKey();
  44970. }
  44971. this.matchResponsiveRule(rule, ruleIds /* , redraw */);
  44972. }, this);
  44973. }
  44974. // Merge matching rules
  44975. var mergedOptions = merge.apply(0,
  44976. ruleIds.map(function (ruleId) {
  44977. return find(options.rules,
  44978. function (rule) {
  44979. return rule._id === ruleId;
  44980. }).chartOptions;
  44981. }));
  44982. mergedOptions.isResponsiveOptions = true;
  44983. // Stringified key for the rules that currently apply.
  44984. ruleIds = (ruleIds.toString() || void 0);
  44985. currentRuleIds = currentResponsive && currentResponsive.ruleIds;
  44986. // Changes in what rules apply
  44987. if (ruleIds !== currentRuleIds) {
  44988. // Undo previous rules. Before we apply a new set of rules, we need to
  44989. // roll back completely to base options (#6291).
  44990. if (currentResponsive) {
  44991. this.update(currentResponsive.undoOptions, redraw, true);
  44992. }
  44993. if (ruleIds) {
  44994. // Get undo-options for matching rules
  44995. undoOptions = this.currentOptions(mergedOptions);
  44996. undoOptions.isResponsiveOptions = true;
  44997. this.currentResponsive = {
  44998. ruleIds: ruleIds,
  44999. mergedOptions: mergedOptions,
  45000. undoOptions: undoOptions
  45001. };
  45002. this.update(mergedOptions, redraw, true);
  45003. }
  45004. else {
  45005. this.currentResponsive = void 0;
  45006. }
  45007. }
  45008. };
  45009. /**
  45010. * Handle a single responsiveness rule.
  45011. *
  45012. * @private
  45013. * @function Highcharts.Chart#matchResponsiveRule
  45014. * @param {Highcharts.ResponsiveRulesOptions} rule
  45015. * @param {Array<string>} matches
  45016. */
  45017. Chart.prototype.matchResponsiveRule = function (rule, matches) {
  45018. var condition = rule.condition,
  45019. fn = condition.callback || function () {
  45020. return (this.chartWidth <= pick(condition.maxWidth,
  45021. Number.MAX_VALUE) &&
  45022. this.chartHeight <=
  45023. pick(condition.maxHeight,
  45024. Number.MAX_VALUE) &&
  45025. this.chartWidth >= pick(condition.minWidth, 0) &&
  45026. this.chartHeight >= pick(condition.minHeight, 0));
  45027. };
  45028. if (fn.call(this)) {
  45029. matches.push(rule._id);
  45030. }
  45031. };
  45032. /**
  45033. * Get the current values for a given set of options. Used before we update
  45034. * the chart with a new responsiveness rule.
  45035. *
  45036. * @todo Restore axis options (by id?). The matching of items in collections
  45037. * bears resemblance to the oneToOne matching in Chart.update. Probably we can
  45038. * refactor out that matching and reuse it in both functions.
  45039. *
  45040. * @private
  45041. * @function Highcharts.Chart#currentOptions
  45042. * @param {Highcharts.Options} options
  45043. * @return {Highcharts.Options}
  45044. */
  45045. Chart.prototype.currentOptions = function (options) {
  45046. var chart = this,
  45047. ret = {};
  45048. /**
  45049. * Recurse over a set of options and its current values,
  45050. * and store the current values in the ret object.
  45051. */
  45052. function getCurrent(options, curr, ret, depth) {
  45053. var i;
  45054. objectEach(options, function (val, key) {
  45055. if (!depth &&
  45056. chart.collectionsWithUpdate.indexOf(key) > -1) {
  45057. val = splat(val);
  45058. ret[key] = [];
  45059. // Iterate over collections like series, xAxis or yAxis and map
  45060. // the items by index.
  45061. for (i = 0; i < Math.max(val.length, curr[key].length); i++) {
  45062. // Item exists in current data (#6347)
  45063. if (curr[key][i]) {
  45064. // If the item is missing from the new data, we need to
  45065. // save the whole config structure. Like when
  45066. // responsively updating from a dual axis layout to a
  45067. // single axis and back (#13544).
  45068. if (val[i] === void 0) {
  45069. ret[key][i] = curr[key][i];
  45070. // Otherwise, proceed
  45071. }
  45072. else {
  45073. ret[key][i] = {};
  45074. getCurrent(val[i], curr[key][i], ret[key][i], depth + 1);
  45075. }
  45076. }
  45077. }
  45078. }
  45079. else if (isObject(val)) {
  45080. ret[key] = isArray(val) ? [] : {};
  45081. getCurrent(val, curr[key] || {}, ret[key], depth + 1);
  45082. }
  45083. else if (typeof curr[key] === 'undefined') { // #10286
  45084. ret[key] = null;
  45085. }
  45086. else {
  45087. ret[key] = curr[key];
  45088. }
  45089. });
  45090. }
  45091. getCurrent(options, this.options, ret, 0);
  45092. return ret;
  45093. };
  45094. });
  45095. _registerModule(_modules, 'masters/highcharts.src.js', [_modules['Core/Globals.js']], function (Highcharts) {
  45096. return Highcharts;
  45097. });
  45098. _modules['masters/highcharts.src.js']._modules = _modules;
  45099. return _modules['masters/highcharts.src.js'];
  45100. }));