2
0

highcharts-gantt.src.js 2.6 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914459154591645917459184591945920459214592245923459244592545926459274592845929459304593145932459334593445935459364593745938459394594045941459424594345944459454594645947459484594945950459514595245953459544595545956459574595845959459604596145962459634596445965459664596745968459694597045971459724597345974459754597645977459784597945980459814598245983459844598545986459874598845989459904599145992459934599445995459964599745998459994600046001460024600346004460054600646007460084600946010460114601246013460144601546016460174601846019460204602146022460234602446025460264602746028460294603046031460324603346034460354603646037460384603946040460414604246043460444604546046460474604846049460504605146052460534605446055460564605746058460594606046061460624606346064460654606646067460684606946070460714607246073460744607546076460774607846079460804608146082460834608446085460864608746088460894609046091460924609346094460954609646097460984609946100461014610246103461044610546106461074610846109461104611146112461134611446115461164611746118461194612046121461224612346124461254612646127461284612946130461314613246133461344613546136461374613846139461404614146142461434614446145461464614746148461494615046151461524615346154461554615646157461584615946160461614616246163461644616546166461674616846169461704617146172461734617446175461764617746178461794618046181461824618346184461854618646187461884618946190461914619246193461944619546196461974619846199462004620146202462034620446205462064620746208462094621046211462124621346214462154621646217462184621946220462214622246223462244622546226462274622846229462304623146232462334623446235462364623746238462394624046241462424624346244462454624646247462484624946250462514625246253462544625546256462574625846259462604626146262462634626446265462664626746268462694627046271462724627346274462754627646277462784627946280462814628246283462844628546286462874628846289462904629146292462934629446295462964629746298462994630046301463024630346304463054630646307463084630946310463114631246313463144631546316463174631846319463204632146322463234632446325463264632746328463294633046331463324633346334463354633646337463384633946340463414634246343463444634546346463474634846349463504635146352463534635446355463564635746358463594636046361463624636346364463654636646367463684636946370463714637246373463744637546376463774637846379463804638146382463834638446385463864638746388463894639046391463924639346394463954639646397463984639946400464014640246403464044640546406464074640846409464104641146412464134641446415464164641746418464194642046421464224642346424464254642646427464284642946430464314643246433464344643546436464374643846439464404644146442464434644446445464464644746448464494645046451464524645346454464554645646457464584645946460464614646246463464644646546466464674646846469464704647146472464734647446475464764647746478464794648046481464824648346484464854648646487464884648946490464914649246493464944649546496464974649846499465004650146502465034650446505465064650746508465094651046511465124651346514465154651646517465184651946520465214652246523465244652546526465274652846529465304653146532465334653446535465364653746538465394654046541465424654346544465454654646547465484654946550465514655246553465544655546556465574655846559465604656146562465634656446565465664656746568465694657046571465724657346574465754657646577465784657946580465814658246583465844658546586465874658846589465904659146592465934659446595465964659746598465994660046601466024660346604466054660646607466084660946610466114661246613466144661546616466174661846619466204662146622466234662446625466264662746628466294663046631466324663346634466354663646637466384663946640466414664246643466444664546646466474664846649466504665146652466534665446655466564665746658466594666046661466624666346664466654666646667466684666946670466714667246673466744667546676466774667846679466804668146682466834668446685466864668746688466894669046691466924669346694466954669646697466984669946700467014670246703467044670546706467074670846709467104671146712467134671446715467164671746718467194672046721467224672346724467254672646727467284672946730467314673246733467344673546736467374673846739467404674146742467434674446745467464674746748467494675046751467524675346754467554675646757467584675946760467614676246763467644676546766467674676846769467704677146772467734677446775467764677746778467794678046781467824678346784467854678646787467884678946790467914679246793467944679546796467974679846799468004680146802468034680446805468064680746808468094681046811468124681346814468154681646817468184681946820468214682246823468244682546826468274682846829468304683146832468334683446835468364683746838468394684046841468424684346844468454684646847468484684946850468514685246853468544685546856468574685846859468604686146862468634686446865468664686746868468694687046871468724687346874468754687646877468784687946880468814688246883468844688546886468874688846889468904689146892468934689446895468964689746898468994690046901469024690346904469054690646907469084690946910469114691246913469144691546916469174691846919469204692146922469234692446925469264692746928469294693046931469324693346934469354693646937469384693946940469414694246943469444694546946469474694846949469504695146952469534695446955469564695746958469594696046961469624696346964469654696646967469684696946970469714697246973469744697546976469774697846979469804698146982469834698446985469864698746988469894699046991469924699346994469954699646997469984699947000470014700247003470044700547006470074700847009470104701147012470134701447015470164701747018470194702047021470224702347024470254702647027470284702947030470314703247033470344703547036470374703847039470404704147042470434704447045470464704747048470494705047051470524705347054470554705647057470584705947060470614706247063470644706547066470674706847069470704707147072470734707447075470764707747078470794708047081470824708347084470854708647087470884708947090470914709247093470944709547096470974709847099471004710147102471034710447105471064710747108471094711047111471124711347114471154711647117471184711947120471214712247123471244712547126471274712847129471304713147132471334713447135471364713747138471394714047141471424714347144471454714647147471484714947150471514715247153471544715547156471574715847159471604716147162471634716447165471664716747168471694717047171471724717347174471754717647177471784717947180471814718247183471844718547186471874718847189471904719147192471934719447195471964719747198471994720047201472024720347204472054720647207472084720947210472114721247213472144721547216472174721847219472204722147222472234722447225472264722747228472294723047231472324723347234472354723647237472384723947240472414724247243472444724547246472474724847249472504725147252472534725447255472564725747258472594726047261472624726347264472654726647267472684726947270472714727247273472744727547276472774727847279472804728147282472834728447285472864728747288472894729047291472924729347294472954729647297472984729947300473014730247303473044730547306473074730847309473104731147312473134731447315473164731747318473194732047321473224732347324473254732647327473284732947330473314733247333473344733547336473374733847339473404734147342473434734447345473464734747348473494735047351473524735347354473554735647357473584735947360473614736247363473644736547366473674736847369473704737147372473734737447375473764737747378473794738047381473824738347384473854738647387473884738947390473914739247393473944739547396473974739847399474004740147402474034740447405474064740747408474094741047411474124741347414474154741647417474184741947420474214742247423474244742547426474274742847429474304743147432474334743447435474364743747438474394744047441474424744347444474454744647447474484744947450474514745247453474544745547456474574745847459474604746147462474634746447465474664746747468474694747047471474724747347474474754747647477474784747947480474814748247483474844748547486474874748847489474904749147492474934749447495474964749747498474994750047501475024750347504475054750647507475084750947510475114751247513475144751547516475174751847519475204752147522475234752447525475264752747528475294753047531475324753347534475354753647537475384753947540475414754247543475444754547546475474754847549475504755147552475534755447555475564755747558475594756047561475624756347564475654756647567475684756947570475714757247573475744757547576475774757847579475804758147582475834758447585475864758747588475894759047591475924759347594475954759647597475984759947600476014760247603476044760547606476074760847609476104761147612476134761447615476164761747618476194762047621476224762347624476254762647627476284762947630476314763247633476344763547636476374763847639476404764147642476434764447645476464764747648476494765047651476524765347654476554765647657476584765947660476614766247663476644766547666476674766847669476704767147672476734767447675476764767747678476794768047681476824768347684476854768647687476884768947690476914769247693476944769547696476974769847699477004770147702477034770447705477064770747708477094771047711477124771347714477154771647717477184771947720477214772247723477244772547726477274772847729477304773147732477334773447735477364773747738477394774047741477424774347744477454774647747477484774947750477514775247753477544775547756477574775847759477604776147762477634776447765477664776747768477694777047771477724777347774477754777647777477784777947780477814778247783477844778547786477874778847789477904779147792477934779447795477964779747798477994780047801478024780347804478054780647807478084780947810478114781247813478144781547816478174781847819478204782147822478234782447825478264782747828478294783047831478324783347834478354783647837478384783947840478414784247843478444784547846478474784847849478504785147852478534785447855478564785747858478594786047861478624786347864478654786647867478684786947870478714787247873478744787547876478774787847879478804788147882478834788447885478864788747888478894789047891478924789347894478954789647897478984789947900479014790247903479044790547906479074790847909479104791147912479134791447915479164791747918479194792047921479224792347924479254792647927479284792947930479314793247933479344793547936479374793847939479404794147942479434794447945479464794747948479494795047951479524795347954479554795647957479584795947960479614796247963479644796547966479674796847969479704797147972479734797447975479764797747978479794798047981479824798347984479854798647987479884798947990479914799247993479944799547996479974799847999480004800148002480034800448005480064800748008480094801048011480124801348014480154801648017480184801948020480214802248023480244802548026480274802848029480304803148032480334803448035480364803748038480394804048041480424804348044480454804648047480484804948050480514805248053480544805548056480574805848059480604806148062480634806448065480664806748068480694807048071480724807348074480754807648077480784807948080480814808248083480844808548086480874808848089480904809148092480934809448095480964809748098480994810048101481024810348104481054810648107481084810948110481114811248113481144811548116481174811848119481204812148122481234812448125481264812748128481294813048131481324813348134481354813648137481384813948140481414814248143481444814548146481474814848149481504815148152481534815448155481564815748158481594816048161481624816348164481654816648167481684816948170481714817248173481744817548176481774817848179481804818148182481834818448185481864818748188481894819048191481924819348194481954819648197481984819948200482014820248203482044820548206482074820848209482104821148212482134821448215482164821748218482194822048221482224822348224482254822648227482284822948230482314823248233482344823548236482374823848239482404824148242482434824448245482464824748248482494825048251482524825348254482554825648257482584825948260482614826248263482644826548266482674826848269482704827148272482734827448275482764827748278482794828048281482824828348284482854828648287482884828948290482914829248293482944829548296482974829848299483004830148302483034830448305483064830748308483094831048311483124831348314483154831648317483184831948320483214832248323483244832548326483274832848329483304833148332483334833448335483364833748338483394834048341483424834348344483454834648347483484834948350483514835248353483544835548356483574835848359483604836148362483634836448365483664836748368483694837048371483724837348374483754837648377483784837948380483814838248383483844838548386483874838848389483904839148392483934839448395483964839748398483994840048401484024840348404484054840648407484084840948410484114841248413484144841548416484174841848419484204842148422484234842448425484264842748428484294843048431484324843348434484354843648437484384843948440484414844248443484444844548446484474844848449484504845148452484534845448455484564845748458484594846048461484624846348464484654846648467484684846948470484714847248473484744847548476484774847848479484804848148482484834848448485484864848748488484894849048491484924849348494484954849648497484984849948500485014850248503485044850548506485074850848509485104851148512485134851448515485164851748518485194852048521485224852348524485254852648527485284852948530485314853248533485344853548536485374853848539485404854148542485434854448545485464854748548485494855048551485524855348554485554855648557485584855948560485614856248563485644856548566485674856848569485704857148572485734857448575485764857748578485794858048581485824858348584485854858648587485884858948590485914859248593485944859548596485974859848599486004860148602486034860448605486064860748608486094861048611486124861348614486154861648617486184861948620486214862248623486244862548626486274862848629486304863148632486334863448635486364863748638486394864048641486424864348644486454864648647486484864948650486514865248653486544865548656486574865848659486604866148662486634866448665486664866748668486694867048671486724867348674486754867648677486784867948680486814868248683486844868548686486874868848689486904869148692486934869448695486964869748698486994870048701487024870348704487054870648707487084870948710487114871248713487144871548716487174871848719487204872148722487234872448725487264872748728487294873048731487324873348734487354873648737487384873948740487414874248743487444874548746487474874848749487504875148752487534875448755487564875748758487594876048761487624876348764487654876648767487684876948770487714877248773487744877548776487774877848779487804878148782487834878448785487864878748788487894879048791487924879348794487954879648797487984879948800488014880248803488044880548806488074880848809488104881148812488134881448815488164881748818488194882048821488224882348824488254882648827488284882948830488314883248833488344883548836488374883848839488404884148842488434884448845488464884748848488494885048851488524885348854488554885648857488584885948860488614886248863488644886548866488674886848869488704887148872488734887448875488764887748878488794888048881488824888348884488854888648887488884888948890488914889248893488944889548896488974889848899489004890148902489034890448905489064890748908489094891048911489124891348914489154891648917489184891948920489214892248923489244892548926489274892848929489304893148932489334893448935489364893748938489394894048941489424894348944489454894648947489484894948950489514895248953489544895548956489574895848959489604896148962489634896448965489664896748968489694897048971489724897348974489754897648977489784897948980489814898248983489844898548986489874898848989489904899148992489934899448995489964899748998489994900049001490024900349004490054900649007490084900949010490114901249013490144901549016490174901849019490204902149022490234902449025490264902749028490294903049031490324903349034490354903649037490384903949040490414904249043490444904549046490474904849049490504905149052490534905449055490564905749058490594906049061490624906349064490654906649067490684906949070490714907249073490744907549076490774907849079490804908149082490834908449085490864908749088490894909049091490924909349094490954909649097490984909949100491014910249103491044910549106491074910849109491104911149112491134911449115491164911749118491194912049121491224912349124491254912649127491284912949130491314913249133491344913549136491374913849139491404914149142491434914449145491464914749148491494915049151491524915349154491554915649157491584915949160491614916249163491644916549166491674916849169491704917149172491734917449175491764917749178491794918049181491824918349184491854918649187491884918949190491914919249193491944919549196491974919849199492004920149202492034920449205492064920749208492094921049211492124921349214492154921649217492184921949220492214922249223492244922549226492274922849229492304923149232492334923449235492364923749238492394924049241492424924349244492454924649247492484924949250492514925249253492544925549256492574925849259492604926149262492634926449265492664926749268492694927049271492724927349274492754927649277492784927949280492814928249283492844928549286492874928849289492904929149292492934929449295492964929749298492994930049301493024930349304493054930649307493084930949310493114931249313493144931549316493174931849319493204932149322493234932449325493264932749328493294933049331493324933349334493354933649337493384933949340493414934249343493444934549346493474934849349493504935149352493534935449355493564935749358493594936049361493624936349364493654936649367493684936949370493714937249373493744937549376493774937849379493804938149382493834938449385493864938749388493894939049391493924939349394493954939649397493984939949400494014940249403494044940549406494074940849409494104941149412494134941449415494164941749418494194942049421494224942349424494254942649427494284942949430494314943249433494344943549436494374943849439494404944149442494434944449445494464944749448494494945049451494524945349454494554945649457494584945949460494614946249463494644946549466494674946849469494704947149472494734947449475494764947749478494794948049481494824948349484494854948649487494884948949490494914949249493494944949549496494974949849499495004950149502495034950449505495064950749508495094951049511495124951349514495154951649517495184951949520495214952249523495244952549526495274952849529495304953149532495334953449535495364953749538495394954049541495424954349544495454954649547495484954949550495514955249553495544955549556495574955849559495604956149562495634956449565495664956749568495694957049571495724957349574495754957649577495784957949580495814958249583495844958549586495874958849589495904959149592495934959449595495964959749598495994960049601496024960349604496054960649607496084960949610496114961249613496144961549616496174961849619496204962149622496234962449625496264962749628496294963049631496324963349634496354963649637496384963949640496414964249643496444964549646496474964849649496504965149652496534965449655496564965749658496594966049661496624966349664496654966649667496684966949670496714967249673496744967549676496774967849679496804968149682496834968449685496864968749688496894969049691496924969349694496954969649697496984969949700497014970249703497044970549706497074970849709497104971149712497134971449715497164971749718497194972049721497224972349724497254972649727497284972949730497314973249733497344973549736497374973849739497404974149742497434974449745497464974749748497494975049751497524975349754497554975649757497584975949760497614976249763497644976549766497674976849769497704977149772497734977449775497764977749778497794978049781497824978349784497854978649787497884978949790497914979249793497944979549796497974979849799498004980149802498034980449805498064980749808498094981049811498124981349814498154981649817498184981949820498214982249823498244982549826498274982849829498304983149832498334983449835498364983749838498394984049841498424984349844498454984649847498484984949850498514985249853498544985549856498574985849859498604986149862498634986449865498664986749868498694987049871498724987349874498754987649877498784987949880498814988249883498844988549886498874988849889498904989149892498934989449895498964989749898498994990049901499024990349904499054990649907499084990949910499114991249913499144991549916499174991849919499204992149922499234992449925499264992749928499294993049931499324993349934499354993649937499384993949940499414994249943499444994549946499474994849949499504995149952499534995449955499564995749958499594996049961499624996349964499654996649967499684996949970499714997249973499744997549976499774997849979499804998149982499834998449985499864998749988499894999049991499924999349994499954999649997499984999950000500015000250003500045000550006500075000850009500105001150012500135001450015500165001750018500195002050021500225002350024500255002650027500285002950030500315003250033500345003550036500375003850039500405004150042500435004450045500465004750048500495005050051500525005350054500555005650057500585005950060500615006250063500645006550066500675006850069500705007150072500735007450075500765007750078500795008050081500825008350084500855008650087500885008950090500915009250093500945009550096500975009850099501005010150102501035010450105501065010750108501095011050111501125011350114501155011650117501185011950120501215012250123501245012550126501275012850129501305013150132501335013450135501365013750138501395014050141501425014350144501455014650147501485014950150501515015250153501545015550156501575015850159501605016150162501635016450165501665016750168501695017050171501725017350174501755017650177501785017950180501815018250183501845018550186501875018850189501905019150192501935019450195501965019750198501995020050201502025020350204502055020650207502085020950210502115021250213502145021550216502175021850219502205022150222502235022450225502265022750228502295023050231502325023350234502355023650237502385023950240502415024250243502445024550246502475024850249502505025150252502535025450255502565025750258502595026050261502625026350264502655026650267502685026950270502715027250273502745027550276502775027850279502805028150282502835028450285502865028750288502895029050291502925029350294502955029650297502985029950300503015030250303503045030550306503075030850309503105031150312503135031450315503165031750318503195032050321503225032350324503255032650327503285032950330503315033250333503345033550336503375033850339503405034150342503435034450345503465034750348503495035050351503525035350354503555035650357503585035950360503615036250363503645036550366503675036850369503705037150372503735037450375503765037750378503795038050381503825038350384503855038650387503885038950390503915039250393503945039550396503975039850399504005040150402504035040450405504065040750408504095041050411504125041350414504155041650417504185041950420504215042250423504245042550426504275042850429504305043150432504335043450435504365043750438504395044050441504425044350444504455044650447504485044950450504515045250453504545045550456504575045850459504605046150462504635046450465504665046750468504695047050471504725047350474504755047650477504785047950480504815048250483504845048550486504875048850489504905049150492504935049450495504965049750498504995050050501505025050350504505055050650507505085050950510505115051250513505145051550516505175051850519505205052150522505235052450525505265052750528505295053050531505325053350534505355053650537505385053950540505415054250543505445054550546505475054850549505505055150552505535055450555505565055750558505595056050561505625056350564505655056650567505685056950570505715057250573505745057550576505775057850579505805058150582505835058450585505865058750588505895059050591505925059350594505955059650597505985059950600506015060250603506045060550606506075060850609506105061150612506135061450615506165061750618506195062050621506225062350624506255062650627506285062950630506315063250633506345063550636506375063850639506405064150642506435064450645506465064750648506495065050651506525065350654506555065650657506585065950660506615066250663506645066550666506675066850669506705067150672506735067450675506765067750678506795068050681506825068350684506855068650687506885068950690506915069250693506945069550696506975069850699507005070150702507035070450705507065070750708507095071050711507125071350714507155071650717507185071950720507215072250723507245072550726507275072850729507305073150732507335073450735507365073750738507395074050741507425074350744507455074650747507485074950750507515075250753507545075550756507575075850759507605076150762507635076450765507665076750768507695077050771507725077350774507755077650777507785077950780507815078250783507845078550786507875078850789507905079150792507935079450795507965079750798507995080050801508025080350804508055080650807508085080950810508115081250813508145081550816508175081850819508205082150822508235082450825508265082750828508295083050831508325083350834508355083650837508385083950840508415084250843508445084550846508475084850849508505085150852508535085450855508565085750858508595086050861508625086350864508655086650867508685086950870508715087250873508745087550876508775087850879508805088150882508835088450885508865088750888508895089050891508925089350894508955089650897508985089950900509015090250903509045090550906509075090850909509105091150912509135091450915509165091750918509195092050921509225092350924509255092650927509285092950930509315093250933509345093550936509375093850939509405094150942509435094450945509465094750948509495095050951509525095350954509555095650957509585095950960509615096250963509645096550966509675096850969509705097150972509735097450975509765097750978509795098050981509825098350984509855098650987509885098950990509915099250993509945099550996509975099850999510005100151002510035100451005510065100751008510095101051011510125101351014510155101651017510185101951020510215102251023510245102551026510275102851029510305103151032510335103451035510365103751038510395104051041510425104351044510455104651047510485104951050510515105251053510545105551056510575105851059510605106151062510635106451065510665106751068510695107051071510725107351074510755107651077510785107951080510815108251083510845108551086510875108851089510905109151092510935109451095510965109751098510995110051101511025110351104511055110651107511085110951110511115111251113511145111551116511175111851119511205112151122511235112451125511265112751128511295113051131511325113351134511355113651137511385113951140511415114251143511445114551146511475114851149511505115151152511535115451155511565115751158511595116051161511625116351164511655116651167511685116951170511715117251173511745117551176511775117851179511805118151182511835118451185511865118751188511895119051191511925119351194511955119651197511985119951200512015120251203512045120551206512075120851209512105121151212512135121451215512165121751218512195122051221512225122351224512255122651227512285122951230512315123251233512345123551236512375123851239512405124151242512435124451245512465124751248512495125051251512525125351254512555125651257512585125951260512615126251263512645126551266512675126851269512705127151272512735127451275512765127751278512795128051281512825128351284512855128651287512885128951290512915129251293512945129551296512975129851299513005130151302513035130451305513065130751308513095131051311513125131351314513155131651317513185131951320513215132251323513245132551326513275132851329513305133151332513335133451335513365133751338513395134051341513425134351344513455134651347513485134951350513515135251353513545135551356513575135851359513605136151362513635136451365513665136751368513695137051371513725137351374513755137651377513785137951380513815138251383513845138551386513875138851389513905139151392513935139451395513965139751398513995140051401514025140351404514055140651407514085140951410514115141251413514145141551416514175141851419514205142151422514235142451425514265142751428514295143051431514325143351434514355143651437514385143951440514415144251443514445144551446514475144851449514505145151452514535145451455514565145751458514595146051461514625146351464514655146651467514685146951470514715147251473514745147551476514775147851479514805148151482514835148451485514865148751488514895149051491514925149351494514955149651497514985149951500515015150251503515045150551506515075150851509515105151151512515135151451515515165151751518515195152051521515225152351524515255152651527515285152951530515315153251533515345153551536515375153851539515405154151542515435154451545515465154751548515495155051551515525155351554515555155651557515585155951560515615156251563515645156551566515675156851569515705157151572515735157451575515765157751578515795158051581515825158351584515855158651587515885158951590515915159251593515945159551596515975159851599516005160151602516035160451605516065160751608516095161051611516125161351614516155161651617516185161951620516215162251623516245162551626516275162851629516305163151632516335163451635516365163751638516395164051641516425164351644516455164651647516485164951650516515165251653516545165551656516575165851659516605166151662516635166451665516665166751668516695167051671516725167351674516755167651677516785167951680516815168251683516845168551686516875168851689516905169151692516935169451695516965169751698516995170051701517025170351704517055170651707517085170951710517115171251713517145171551716517175171851719517205172151722517235172451725517265172751728517295173051731517325173351734517355173651737517385173951740517415174251743517445174551746517475174851749517505175151752517535175451755517565175751758517595176051761517625176351764517655176651767517685176951770517715177251773517745177551776517775177851779517805178151782517835178451785517865178751788517895179051791517925179351794517955179651797517985179951800518015180251803518045180551806518075180851809518105181151812518135181451815518165181751818518195182051821518225182351824518255182651827518285182951830518315183251833518345183551836518375183851839518405184151842518435184451845518465184751848518495185051851518525185351854518555185651857518585185951860518615186251863518645186551866518675186851869518705187151872518735187451875518765187751878518795188051881518825188351884518855188651887518885188951890518915189251893518945189551896518975189851899519005190151902519035190451905519065190751908519095191051911519125191351914519155191651917519185191951920519215192251923519245192551926519275192851929519305193151932519335193451935519365193751938519395194051941519425194351944519455194651947519485194951950519515195251953519545195551956519575195851959519605196151962519635196451965519665196751968519695197051971519725197351974519755197651977519785197951980519815198251983519845198551986519875198851989519905199151992519935199451995519965199751998519995200052001520025200352004520055200652007520085200952010520115201252013520145201552016520175201852019520205202152022520235202452025520265202752028520295203052031520325203352034520355203652037520385203952040520415204252043520445204552046520475204852049520505205152052520535205452055520565205752058520595206052061520625206352064520655206652067520685206952070520715207252073520745207552076520775207852079520805208152082520835208452085520865208752088520895209052091520925209352094520955209652097520985209952100521015210252103521045210552106521075210852109521105211152112521135211452115521165211752118521195212052121521225212352124521255212652127521285212952130521315213252133521345213552136521375213852139521405214152142521435214452145521465214752148521495215052151521525215352154521555215652157521585215952160521615216252163521645216552166521675216852169521705217152172521735217452175521765217752178521795218052181521825218352184521855218652187521885218952190521915219252193521945219552196521975219852199522005220152202522035220452205522065220752208522095221052211522125221352214522155221652217522185221952220522215222252223522245222552226522275222852229522305223152232522335223452235522365223752238522395224052241522425224352244522455224652247522485224952250522515225252253522545225552256522575225852259522605226152262522635226452265522665226752268522695227052271522725227352274522755227652277522785227952280522815228252283522845228552286522875228852289522905229152292522935229452295522965229752298522995230052301523025230352304523055230652307523085230952310523115231252313523145231552316523175231852319523205232152322523235232452325523265232752328523295233052331523325233352334523355233652337523385233952340523415234252343523445234552346523475234852349523505235152352523535235452355523565235752358523595236052361523625236352364523655236652367523685236952370523715237252373523745237552376523775237852379523805238152382523835238452385523865238752388523895239052391523925239352394523955239652397523985239952400524015240252403524045240552406524075240852409524105241152412524135241452415524165241752418524195242052421524225242352424524255242652427524285242952430524315243252433524345243552436524375243852439524405244152442524435244452445524465244752448524495245052451524525245352454524555245652457524585245952460524615246252463524645246552466524675246852469524705247152472524735247452475524765247752478524795248052481524825248352484524855248652487524885248952490524915249252493524945249552496524975249852499525005250152502525035250452505525065250752508525095251052511525125251352514525155251652517525185251952520525215252252523525245252552526525275252852529525305253152532525335253452535525365253752538525395254052541525425254352544525455254652547525485254952550525515255252553525545255552556525575255852559525605256152562525635256452565525665256752568525695257052571525725257352574525755257652577525785257952580525815258252583525845258552586525875258852589525905259152592525935259452595525965259752598525995260052601526025260352604526055260652607526085260952610526115261252613526145261552616526175261852619526205262152622526235262452625526265262752628526295263052631526325263352634526355263652637526385263952640526415264252643526445264552646526475264852649526505265152652526535265452655526565265752658526595266052661526625266352664526655266652667526685266952670526715267252673526745267552676526775267852679526805268152682526835268452685526865268752688526895269052691526925269352694526955269652697526985269952700527015270252703527045270552706527075270852709527105271152712527135271452715527165271752718527195272052721527225272352724527255272652727527285272952730527315273252733527345273552736527375273852739527405274152742527435274452745527465274752748527495275052751527525275352754527555275652757527585275952760527615276252763527645276552766527675276852769527705277152772527735277452775527765277752778527795278052781527825278352784527855278652787527885278952790527915279252793527945279552796527975279852799528005280152802528035280452805528065280752808528095281052811528125281352814528155281652817528185281952820528215282252823528245282552826528275282852829528305283152832528335283452835528365283752838528395284052841528425284352844528455284652847528485284952850528515285252853528545285552856528575285852859528605286152862528635286452865528665286752868528695287052871528725287352874528755287652877528785287952880528815288252883528845288552886528875288852889528905289152892528935289452895528965289752898528995290052901529025290352904529055290652907529085290952910529115291252913529145291552916529175291852919529205292152922529235292452925529265292752928529295293052931529325293352934529355293652937529385293952940529415294252943529445294552946529475294852949529505295152952529535295452955529565295752958529595296052961529625296352964529655296652967529685296952970529715297252973529745297552976529775297852979529805298152982529835298452985529865298752988529895299052991529925299352994529955299652997529985299953000530015300253003530045300553006530075300853009530105301153012530135301453015530165301753018530195302053021530225302353024530255302653027530285302953030530315303253033530345303553036530375303853039530405304153042530435304453045530465304753048530495305053051530525305353054530555305653057530585305953060530615306253063530645306553066530675306853069530705307153072530735307453075530765307753078530795308053081530825308353084530855308653087530885308953090530915309253093530945309553096530975309853099531005310153102531035310453105531065310753108531095311053111531125311353114531155311653117531185311953120531215312253123531245312553126531275312853129531305313153132531335313453135531365313753138531395314053141531425314353144531455314653147531485314953150531515315253153531545315553156531575315853159531605316153162531635316453165531665316753168531695317053171531725317353174531755317653177531785317953180531815318253183531845318553186531875318853189531905319153192531935319453195531965319753198531995320053201532025320353204532055320653207532085320953210532115321253213532145321553216532175321853219532205322153222532235322453225532265322753228532295323053231532325323353234532355323653237532385323953240532415324253243532445324553246532475324853249532505325153252532535325453255532565325753258532595326053261532625326353264532655326653267532685326953270532715327253273532745327553276532775327853279532805328153282532835328453285532865328753288532895329053291532925329353294532955329653297532985329953300533015330253303533045330553306533075330853309533105331153312533135331453315533165331753318533195332053321533225332353324533255332653327533285332953330533315333253333533345333553336533375333853339533405334153342533435334453345533465334753348533495335053351533525335353354533555335653357533585335953360533615336253363533645336553366533675336853369533705337153372533735337453375533765337753378533795338053381533825338353384533855338653387533885338953390533915339253393533945339553396533975339853399534005340153402534035340453405534065340753408534095341053411534125341353414534155341653417534185341953420534215342253423534245342553426534275342853429534305343153432534335343453435534365343753438534395344053441534425344353444534455344653447534485344953450534515345253453534545345553456534575345853459534605346153462534635346453465534665346753468534695347053471534725347353474534755347653477534785347953480534815348253483534845348553486534875348853489534905349153492534935349453495534965349753498534995350053501535025350353504535055350653507535085350953510535115351253513535145351553516535175351853519535205352153522535235352453525535265352753528535295353053531535325353353534535355353653537535385353953540535415354253543535445354553546535475354853549535505355153552535535355453555535565355753558535595356053561535625356353564535655356653567535685356953570535715357253573535745357553576535775357853579535805358153582535835358453585535865358753588535895359053591535925359353594535955359653597535985359953600536015360253603536045360553606536075360853609536105361153612536135361453615536165361753618536195362053621536225362353624536255362653627536285362953630536315363253633536345363553636536375363853639536405364153642536435364453645536465364753648536495365053651536525365353654536555365653657536585365953660536615366253663536645366553666536675366853669536705367153672536735367453675536765367753678536795368053681536825368353684536855368653687536885368953690536915369253693536945369553696536975369853699537005370153702537035370453705537065370753708537095371053711537125371353714537155371653717537185371953720537215372253723537245372553726537275372853729537305373153732537335373453735537365373753738537395374053741537425374353744537455374653747537485374953750537515375253753537545375553756537575375853759537605376153762537635376453765537665376753768537695377053771537725377353774537755377653777537785377953780537815378253783537845378553786537875378853789537905379153792537935379453795537965379753798537995380053801538025380353804538055380653807538085380953810538115381253813538145381553816538175381853819538205382153822538235382453825538265382753828538295383053831538325383353834538355383653837538385383953840538415384253843538445384553846538475384853849538505385153852538535385453855538565385753858538595386053861538625386353864538655386653867538685386953870538715387253873538745387553876538775387853879538805388153882538835388453885538865388753888538895389053891538925389353894538955389653897538985389953900539015390253903539045390553906539075390853909539105391153912539135391453915539165391753918539195392053921539225392353924539255392653927539285392953930539315393253933539345393553936539375393853939539405394153942539435394453945539465394753948539495395053951539525395353954539555395653957539585395953960539615396253963539645396553966539675396853969539705397153972539735397453975539765397753978539795398053981539825398353984539855398653987539885398953990539915399253993539945399553996539975399853999540005400154002540035400454005540065400754008540095401054011540125401354014540155401654017540185401954020540215402254023540245402554026540275402854029540305403154032540335403454035540365403754038540395404054041540425404354044540455404654047540485404954050540515405254053540545405554056540575405854059540605406154062540635406454065540665406754068540695407054071540725407354074540755407654077540785407954080540815408254083540845408554086540875408854089540905409154092540935409454095540965409754098540995410054101541025410354104541055410654107541085410954110541115411254113541145411554116541175411854119541205412154122541235412454125541265412754128541295413054131541325413354134541355413654137541385413954140541415414254143541445414554146541475414854149541505415154152541535415454155541565415754158541595416054161541625416354164541655416654167541685416954170541715417254173541745417554176541775417854179541805418154182541835418454185541865418754188541895419054191541925419354194541955419654197541985419954200542015420254203542045420554206542075420854209542105421154212542135421454215542165421754218542195422054221542225422354224542255422654227542285422954230542315423254233542345423554236542375423854239542405424154242542435424454245542465424754248542495425054251542525425354254542555425654257542585425954260542615426254263542645426554266542675426854269542705427154272542735427454275542765427754278542795428054281542825428354284542855428654287542885428954290542915429254293542945429554296542975429854299543005430154302543035430454305543065430754308543095431054311543125431354314543155431654317543185431954320543215432254323543245432554326543275432854329543305433154332543335433454335543365433754338543395434054341543425434354344543455434654347543485434954350543515435254353543545435554356543575435854359543605436154362543635436454365543665436754368543695437054371543725437354374543755437654377543785437954380543815438254383543845438554386543875438854389543905439154392543935439454395543965439754398543995440054401544025440354404544055440654407544085440954410544115441254413544145441554416544175441854419544205442154422544235442454425544265442754428544295443054431544325443354434544355443654437544385443954440544415444254443544445444554446544475444854449544505445154452544535445454455544565445754458544595446054461544625446354464544655446654467544685446954470544715447254473544745447554476544775447854479544805448154482544835448454485544865448754488544895449054491544925449354494544955449654497544985449954500545015450254503545045450554506545075450854509545105451154512545135451454515545165451754518545195452054521545225452354524545255452654527545285452954530545315453254533545345453554536545375453854539545405454154542545435454454545545465454754548545495455054551545525455354554545555455654557545585455954560545615456254563545645456554566545675456854569545705457154572545735457454575545765457754578545795458054581545825458354584545855458654587545885458954590545915459254593545945459554596545975459854599546005460154602546035460454605546065460754608546095461054611546125461354614546155461654617546185461954620546215462254623546245462554626546275462854629546305463154632546335463454635546365463754638546395464054641546425464354644546455464654647546485464954650546515465254653546545465554656546575465854659546605466154662546635466454665546665466754668546695467054671546725467354674546755467654677546785467954680546815468254683546845468554686546875468854689546905469154692546935469454695546965469754698546995470054701547025470354704547055470654707547085470954710547115471254713547145471554716547175471854719547205472154722547235472454725547265472754728547295473054731547325473354734547355473654737547385473954740547415474254743547445474554746547475474854749547505475154752547535475454755547565475754758547595476054761547625476354764547655476654767547685476954770547715477254773547745477554776547775477854779547805478154782547835478454785547865478754788547895479054791547925479354794547955479654797547985479954800548015480254803548045480554806548075480854809548105481154812548135481454815548165481754818548195482054821548225482354824548255482654827548285482954830548315483254833548345483554836548375483854839548405484154842548435484454845548465484754848548495485054851548525485354854548555485654857548585485954860548615486254863548645486554866548675486854869548705487154872548735487454875548765487754878548795488054881548825488354884548855488654887548885488954890548915489254893548945489554896548975489854899549005490154902549035490454905549065490754908549095491054911549125491354914549155491654917549185491954920549215492254923549245492554926549275492854929549305493154932549335493454935549365493754938549395494054941549425494354944549455494654947549485494954950549515495254953549545495554956549575495854959549605496154962549635496454965549665496754968549695497054971549725497354974549755497654977549785497954980549815498254983549845498554986549875498854989549905499154992549935499454995549965499754998549995500055001550025500355004550055500655007550085500955010550115501255013550145501555016550175501855019550205502155022550235502455025550265502755028550295503055031550325503355034550355503655037550385503955040550415504255043550445504555046550475504855049550505505155052550535505455055550565505755058550595506055061550625506355064550655506655067550685506955070550715507255073550745507555076550775507855079550805508155082550835508455085550865508755088550895509055091550925509355094550955509655097550985509955100551015510255103551045510555106551075510855109551105511155112551135511455115551165511755118551195512055121551225512355124551255512655127551285512955130551315513255133551345513555136551375513855139551405514155142551435514455145551465514755148551495515055151551525515355154551555515655157551585515955160551615516255163551645516555166551675516855169551705517155172551735517455175551765517755178551795518055181551825518355184551855518655187551885518955190551915519255193551945519555196551975519855199552005520155202552035520455205552065520755208552095521055211552125521355214552155521655217552185521955220552215522255223552245522555226552275522855229552305523155232552335523455235552365523755238552395524055241552425524355244552455524655247552485524955250552515525255253552545525555256552575525855259552605526155262552635526455265552665526755268552695527055271552725527355274552755527655277552785527955280552815528255283552845528555286552875528855289552905529155292552935529455295552965529755298552995530055301553025530355304553055530655307553085530955310553115531255313553145531555316553175531855319553205532155322553235532455325553265532755328553295533055331553325533355334553355533655337553385533955340553415534255343553445534555346553475534855349553505535155352553535535455355553565535755358553595536055361553625536355364553655536655367553685536955370553715537255373553745537555376553775537855379553805538155382553835538455385553865538755388553895539055391553925539355394553955539655397553985539955400554015540255403554045540555406554075540855409554105541155412554135541455415554165541755418554195542055421554225542355424554255542655427554285542955430554315543255433554345543555436554375543855439554405544155442554435544455445554465544755448554495545055451554525545355454554555545655457554585545955460554615546255463554645546555466554675546855469554705547155472554735547455475554765547755478554795548055481554825548355484554855548655487554885548955490554915549255493554945549555496554975549855499555005550155502555035550455505555065550755508555095551055511555125551355514555155551655517555185551955520555215552255523555245552555526555275552855529555305553155532555335553455535555365553755538555395554055541555425554355544555455554655547555485554955550555515555255553555545555555556555575555855559555605556155562555635556455565555665556755568555695557055571555725557355574555755557655577555785557955580555815558255583555845558555586555875558855589555905559155592555935559455595555965559755598555995560055601556025560355604556055560655607556085560955610556115561255613556145561555616556175561855619556205562155622556235562455625556265562755628556295563055631556325563355634556355563655637556385563955640556415564255643556445564555646556475564855649556505565155652556535565455655556565565755658556595566055661556625566355664556655566655667556685566955670556715567255673556745567555676556775567855679556805568155682556835568455685556865568755688556895569055691556925569355694556955569655697556985569955700557015570255703557045570555706557075570855709557105571155712557135571455715557165571755718557195572055721557225572355724557255572655727557285572955730557315573255733557345573555736557375573855739557405574155742557435574455745557465574755748557495575055751557525575355754557555575655757557585575955760557615576255763557645576555766557675576855769557705577155772557735577455775557765577755778557795578055781557825578355784557855578655787557885578955790557915579255793557945579555796557975579855799558005580155802558035580455805558065580755808558095581055811558125581355814558155581655817558185581955820558215582255823558245582555826558275582855829558305583155832558335583455835558365583755838558395584055841558425584355844558455584655847558485584955850558515585255853558545585555856558575585855859558605586155862558635586455865558665586755868558695587055871558725587355874558755587655877558785587955880558815588255883558845588555886558875588855889558905589155892558935589455895558965589755898558995590055901559025590355904559055590655907559085590955910559115591255913559145591555916559175591855919559205592155922559235592455925559265592755928559295593055931559325593355934559355593655937559385593955940559415594255943559445594555946559475594855949559505595155952559535595455955559565595755958559595596055961559625596355964559655596655967559685596955970559715597255973559745597555976559775597855979559805598155982559835598455985559865598755988559895599055991559925599355994559955599655997559985599956000560015600256003560045600556006560075600856009560105601156012560135601456015560165601756018560195602056021560225602356024560255602656027560285602956030560315603256033560345603556036560375603856039560405604156042560435604456045560465604756048560495605056051560525605356054560555605656057560585605956060560615606256063560645606556066560675606856069560705607156072560735607456075560765607756078560795608056081560825608356084560855608656087560885608956090560915609256093560945609556096560975609856099561005610156102561035610456105561065610756108561095611056111561125611356114561155611656117561185611956120561215612256123561245612556126561275612856129561305613156132561335613456135561365613756138561395614056141561425614356144561455614656147561485614956150561515615256153561545615556156561575615856159561605616156162561635616456165561665616756168561695617056171561725617356174561755617656177561785617956180561815618256183561845618556186561875618856189561905619156192561935619456195561965619756198561995620056201562025620356204562055620656207562085620956210562115621256213562145621556216562175621856219562205622156222562235622456225562265622756228562295623056231562325623356234562355623656237562385623956240562415624256243562445624556246562475624856249562505625156252562535625456255562565625756258562595626056261562625626356264562655626656267562685626956270562715627256273562745627556276562775627856279562805628156282562835628456285562865628756288562895629056291562925629356294562955629656297562985629956300563015630256303563045630556306563075630856309563105631156312563135631456315563165631756318563195632056321563225632356324563255632656327563285632956330563315633256333563345633556336563375633856339563405634156342563435634456345563465634756348563495635056351563525635356354563555635656357563585635956360563615636256363563645636556366563675636856369563705637156372563735637456375563765637756378563795638056381563825638356384563855638656387563885638956390563915639256393563945639556396563975639856399564005640156402564035640456405564065640756408564095641056411564125641356414564155641656417564185641956420564215642256423564245642556426564275642856429564305643156432564335643456435564365643756438564395644056441564425644356444564455644656447564485644956450564515645256453564545645556456564575645856459564605646156462564635646456465564665646756468564695647056471564725647356474564755647656477564785647956480564815648256483564845648556486564875648856489564905649156492564935649456495564965649756498564995650056501565025650356504565055650656507565085650956510565115651256513565145651556516565175651856519565205652156522565235652456525565265652756528565295653056531565325653356534565355653656537565385653956540565415654256543565445654556546565475654856549565505655156552565535655456555565565655756558565595656056561565625656356564565655656656567565685656956570565715657256573565745657556576565775657856579565805658156582565835658456585565865658756588565895659056591565925659356594565955659656597565985659956600566015660256603566045660556606566075660856609566105661156612566135661456615566165661756618566195662056621566225662356624566255662656627566285662956630566315663256633566345663556636566375663856639566405664156642566435664456645566465664756648566495665056651566525665356654566555665656657566585665956660566615666256663566645666556666566675666856669566705667156672566735667456675566765667756678566795668056681566825668356684566855668656687566885668956690566915669256693566945669556696566975669856699567005670156702567035670456705567065670756708567095671056711567125671356714567155671656717567185671956720567215672256723567245672556726567275672856729567305673156732567335673456735567365673756738567395674056741567425674356744567455674656747567485674956750567515675256753567545675556756567575675856759567605676156762567635676456765567665676756768567695677056771567725677356774567755677656777567785677956780567815678256783567845678556786567875678856789567905679156792567935679456795567965679756798567995680056801568025680356804568055680656807568085680956810568115681256813568145681556816568175681856819568205682156822568235682456825568265682756828568295683056831568325683356834568355683656837568385683956840568415684256843568445684556846568475684856849568505685156852568535685456855568565685756858568595686056861568625686356864568655686656867568685686956870568715687256873568745687556876568775687856879568805688156882568835688456885568865688756888568895689056891568925689356894568955689656897568985689956900569015690256903569045690556906569075690856909569105691156912569135691456915569165691756918569195692056921569225692356924569255692656927569285692956930569315693256933569345693556936569375693856939569405694156942569435694456945569465694756948569495695056951569525695356954569555695656957569585695956960569615696256963569645696556966569675696856969569705697156972569735697456975569765697756978569795698056981569825698356984569855698656987569885698956990569915699256993569945699556996569975699856999570005700157002570035700457005570065700757008570095701057011570125701357014570155701657017570185701957020570215702257023570245702557026570275702857029570305703157032570335703457035570365703757038570395704057041570425704357044570455704657047570485704957050570515705257053570545705557056570575705857059570605706157062570635706457065570665706757068570695707057071570725707357074570755707657077570785707957080570815708257083570845708557086570875708857089570905709157092570935709457095570965709757098570995710057101571025710357104571055710657107571085710957110571115711257113571145711557116571175711857119571205712157122571235712457125571265712757128571295713057131571325713357134571355713657137571385713957140571415714257143571445714557146571475714857149571505715157152571535715457155571565715757158571595716057161571625716357164571655716657167571685716957170571715717257173571745717557176571775717857179571805718157182571835718457185571865718757188571895719057191571925719357194571955719657197571985719957200572015720257203572045720557206572075720857209572105721157212572135721457215572165721757218572195722057221572225722357224572255722657227572285722957230572315723257233572345723557236572375723857239572405724157242572435724457245572465724757248572495725057251572525725357254572555725657257572585725957260572615726257263572645726557266572675726857269572705727157272572735727457275572765727757278572795728057281572825728357284572855728657287572885728957290572915729257293572945729557296572975729857299573005730157302573035730457305573065730757308573095731057311573125731357314573155731657317573185731957320573215732257323573245732557326573275732857329573305733157332573335733457335573365733757338573395734057341573425734357344573455734657347573485734957350573515735257353573545735557356573575735857359573605736157362573635736457365573665736757368573695737057371573725737357374573755737657377573785737957380573815738257383573845738557386573875738857389573905739157392573935739457395573965739757398573995740057401574025740357404574055740657407574085740957410574115741257413574145741557416574175741857419574205742157422574235742457425574265742757428574295743057431574325743357434574355743657437574385743957440574415744257443574445744557446574475744857449574505745157452574535745457455574565745757458574595746057461574625746357464574655746657467574685746957470574715747257473574745747557476574775747857479574805748157482574835748457485574865748757488574895749057491574925749357494574955749657497574985749957500575015750257503575045750557506575075750857509575105751157512575135751457515575165751757518575195752057521575225752357524575255752657527575285752957530575315753257533575345753557536575375753857539575405754157542575435754457545575465754757548575495755057551575525755357554575555755657557575585755957560575615756257563575645756557566575675756857569575705757157572575735757457575575765757757578575795758057581575825758357584575855758657587575885758957590575915759257593575945759557596575975759857599576005760157602576035760457605576065760757608576095761057611576125761357614576155761657617576185761957620576215762257623576245762557626576275762857629576305763157632576335763457635576365763757638576395764057641576425764357644576455764657647576485764957650576515765257653576545765557656576575765857659576605766157662576635766457665576665766757668576695767057671576725767357674576755767657677576785767957680576815768257683576845768557686576875768857689576905769157692576935769457695576965769757698576995770057701577025770357704577055770657707577085770957710577115771257713577145771557716577175771857719577205772157722577235772457725577265772757728577295773057731577325773357734577355773657737577385773957740577415774257743577445774557746577475774857749577505775157752577535775457755577565775757758577595776057761577625776357764577655776657767577685776957770577715777257773577745777557776577775777857779577805778157782577835778457785577865778757788577895779057791577925779357794577955779657797577985779957800578015780257803578045780557806578075780857809578105781157812578135781457815578165781757818578195782057821578225782357824578255782657827578285782957830578315783257833578345783557836578375783857839578405784157842578435784457845578465784757848578495785057851578525785357854578555785657857578585785957860578615786257863578645786557866578675786857869578705787157872578735787457875578765787757878578795788057881578825788357884578855788657887578885788957890578915789257893578945789557896578975789857899579005790157902579035790457905579065790757908579095791057911579125791357914579155791657917579185791957920579215792257923579245792557926579275792857929579305793157932579335793457935579365793757938579395794057941579425794357944579455794657947579485794957950579515795257953579545795557956579575795857959579605796157962579635796457965579665796757968579695797057971579725797357974579755797657977579785797957980579815798257983579845798557986579875798857989579905799157992579935799457995579965799757998579995800058001580025800358004580055800658007580085800958010580115801258013580145801558016580175801858019580205802158022580235802458025580265802758028580295803058031580325803358034580355803658037580385803958040580415804258043580445804558046580475804858049580505805158052580535805458055580565805758058580595806058061580625806358064580655806658067580685806958070580715807258073580745807558076580775807858079580805808158082580835808458085580865808758088580895809058091580925809358094580955809658097580985809958100581015810258103581045810558106581075810858109581105811158112581135811458115581165811758118581195812058121581225812358124581255812658127581285812958130581315813258133581345813558136581375813858139581405814158142581435814458145581465814758148581495815058151581525815358154581555815658157581585815958160581615816258163581645816558166581675816858169581705817158172581735817458175581765817758178581795818058181581825818358184581855818658187581885818958190581915819258193581945819558196581975819858199582005820158202582035820458205582065820758208582095821058211582125821358214582155821658217582185821958220582215822258223582245822558226582275822858229582305823158232582335823458235582365823758238582395824058241582425824358244582455824658247582485824958250582515825258253582545825558256582575825858259582605826158262582635826458265582665826758268582695827058271582725827358274582755827658277582785827958280582815828258283582845828558286582875828858289582905829158292582935829458295582965829758298582995830058301583025830358304583055830658307583085830958310583115831258313583145831558316583175831858319583205832158322583235832458325583265832758328583295833058331583325833358334583355833658337583385833958340583415834258343583445834558346583475834858349583505835158352583535835458355583565835758358583595836058361583625836358364583655836658367583685836958370583715837258373583745837558376583775837858379583805838158382583835838458385583865838758388583895839058391583925839358394583955839658397583985839958400584015840258403584045840558406584075840858409584105841158412584135841458415584165841758418584195842058421584225842358424584255842658427584285842958430584315843258433584345843558436584375843858439584405844158442584435844458445584465844758448584495845058451584525845358454584555845658457584585845958460584615846258463584645846558466584675846858469584705847158472584735847458475584765847758478584795848058481584825848358484584855848658487584885848958490584915849258493584945849558496584975849858499585005850158502585035850458505585065850758508585095851058511585125851358514585155851658517585185851958520585215852258523585245852558526585275852858529585305853158532585335853458535585365853758538585395854058541585425854358544585455854658547585485854958550585515855258553585545855558556585575855858559585605856158562585635856458565585665856758568585695857058571585725857358574585755857658577585785857958580585815858258583585845858558586585875858858589585905859158592585935859458595585965859758598585995860058601586025860358604586055860658607586085860958610586115861258613586145861558616586175861858619586205862158622586235862458625586265862758628586295863058631586325863358634586355863658637586385863958640586415864258643586445864558646586475864858649586505865158652586535865458655586565865758658586595866058661586625866358664586655866658667586685866958670586715867258673586745867558676586775867858679586805868158682586835868458685586865868758688586895869058691586925869358694586955869658697586985869958700587015870258703587045870558706587075870858709587105871158712587135871458715587165871758718587195872058721587225872358724587255872658727587285872958730587315873258733587345873558736587375873858739587405874158742587435874458745587465874758748587495875058751587525875358754587555875658757587585875958760587615876258763587645876558766587675876858769587705877158772587735877458775587765877758778587795878058781587825878358784587855878658787587885878958790587915879258793587945879558796587975879858799588005880158802588035880458805588065880758808588095881058811588125881358814588155881658817588185881958820588215882258823588245882558826588275882858829588305883158832588335883458835588365883758838588395884058841588425884358844588455884658847588485884958850588515885258853588545885558856588575885858859588605886158862588635886458865588665886758868588695887058871588725887358874588755887658877588785887958880588815888258883588845888558886588875888858889588905889158892588935889458895588965889758898588995890058901589025890358904589055890658907589085890958910589115891258913589145891558916589175891858919589205892158922589235892458925589265892758928589295893058931589325893358934589355893658937589385893958940589415894258943589445894558946589475894858949589505895158952589535895458955589565895758958589595896058961589625896358964589655896658967589685896958970589715897258973589745897558976589775897858979589805898158982589835898458985589865898758988589895899058991589925899358994589955899658997589985899959000590015900259003590045900559006590075900859009590105901159012590135901459015590165901759018590195902059021590225902359024590255902659027590285902959030590315903259033590345903559036590375903859039590405904159042590435904459045590465904759048590495905059051590525905359054590555905659057590585905959060590615906259063590645906559066590675906859069590705907159072590735907459075590765907759078590795908059081590825908359084590855908659087590885908959090590915909259093590945909559096590975909859099591005910159102591035910459105591065910759108591095911059111591125911359114591155911659117591185911959120591215912259123591245912559126591275912859129591305913159132591335913459135591365913759138591395914059141591425914359144591455914659147591485914959150591515915259153591545915559156591575915859159591605916159162591635916459165591665916759168591695917059171591725917359174591755917659177591785917959180591815918259183591845918559186591875918859189591905919159192591935919459195591965919759198591995920059201592025920359204592055920659207592085920959210592115921259213592145921559216592175921859219592205922159222592235922459225592265922759228592295923059231592325923359234592355923659237592385923959240592415924259243592445924559246592475924859249592505925159252592535925459255592565925759258592595926059261592625926359264592655926659267592685926959270592715927259273592745927559276592775927859279592805928159282592835928459285592865928759288592895929059291592925929359294592955929659297592985929959300593015930259303593045930559306593075930859309593105931159312593135931459315593165931759318593195932059321593225932359324593255932659327593285932959330593315933259333593345933559336593375933859339593405934159342593435934459345593465934759348593495935059351593525935359354593555935659357593585935959360593615936259363593645936559366593675936859369593705937159372593735937459375593765937759378593795938059381593825938359384593855938659387593885938959390593915939259393593945939559396593975939859399594005940159402594035940459405594065940759408594095941059411594125941359414594155941659417594185941959420594215942259423594245942559426594275942859429594305943159432594335943459435594365943759438594395944059441594425944359444594455944659447594485944959450594515945259453594545945559456594575945859459594605946159462594635946459465594665946759468594695947059471594725947359474594755947659477594785947959480594815948259483594845948559486594875948859489594905949159492594935949459495594965949759498594995950059501595025950359504595055950659507595085950959510595115951259513595145951559516595175951859519595205952159522595235952459525595265952759528595295953059531595325953359534595355953659537595385953959540595415954259543595445954559546595475954859549595505955159552595535955459555595565955759558595595956059561595625956359564595655956659567595685956959570595715957259573595745957559576595775957859579595805958159582595835958459585595865958759588595895959059591595925959359594595955959659597595985959959600596015960259603596045960559606596075960859609596105961159612596135961459615596165961759618596195962059621596225962359624596255962659627596285962959630596315963259633596345963559636596375963859639596405964159642596435964459645596465964759648596495965059651596525965359654596555965659657596585965959660596615966259663596645966559666596675966859669596705967159672596735967459675596765967759678596795968059681596825968359684596855968659687596885968959690596915969259693596945969559696596975969859699597005970159702597035970459705597065970759708597095971059711597125971359714597155971659717597185971959720597215972259723597245972559726597275972859729597305973159732597335973459735597365973759738597395974059741597425974359744597455974659747597485974959750597515975259753597545975559756597575975859759597605976159762597635976459765597665976759768597695977059771597725977359774597755977659777597785977959780597815978259783597845978559786597875978859789597905979159792597935979459795597965979759798597995980059801598025980359804598055980659807598085980959810598115981259813598145981559816598175981859819598205982159822598235982459825598265982759828598295983059831598325983359834
  1. /**
  2. * @license Highcharts Gantt JS v9.1.0 (2021-05-04)
  3. *
  4. * (c) 2017-2021 Lars Cabrera, Torstein Honsi, Jon Arild Nygard & Oystein Moseng
  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-gantt', function () {
  17. return factory(root);
  18. });
  19. } else {
  20. if (root.Highcharts) {
  21. root.Highcharts.error(16, true);
  22. }
  23. root.Highcharts = factory(root);
  24. }
  25. }(typeof window !== 'undefined' ? window : this, function (win) {
  26. var _modules = {};
  27. function _registerModule(obj, path, args, fn) {
  28. if (!obj.hasOwnProperty(path)) {
  29. obj[path] = fn.apply(null, args);
  30. }
  31. }
  32. _registerModule(_modules, 'Core/Globals.js', [], function () {
  33. /* *
  34. *
  35. * (c) 2010-2021 Torstein Honsi
  36. *
  37. * License: www.highcharts.com/license
  38. *
  39. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  40. *
  41. * */
  42. /* *
  43. *
  44. * Constants
  45. *
  46. * */
  47. /**
  48. * @private
  49. * @deprecated
  50. * @todo Rename UMD argument `win` to `window`; move code to `Globals.win`
  51. */
  52. var w = (typeof win !== 'undefined' ?
  53. win :
  54. typeof window !== 'undefined' ?
  55. window :
  56. {}
  57. // eslint-disable-next-line node/no-unsupported-features/es-builtins
  58. );
  59. /* *
  60. *
  61. * Namespace
  62. *
  63. * */
  64. /**
  65. * Shared Highcharts properties.
  66. */
  67. var Globals;
  68. (function (Globals) {
  69. /* *
  70. *
  71. * Constants
  72. *
  73. * */
  74. Globals.SVG_NS = 'http://www.w3.org/2000/svg', Globals.product = 'Highcharts', Globals.version = '9.1.0', Globals.win = w, Globals.doc = Globals.win.document, Globals.svg = (Globals.doc &&
  75. Globals.doc.createElementNS &&
  76. !!Globals.doc.createElementNS(Globals.SVG_NS, 'svg').createSVGRect), Globals.userAgent = (Globals.win.navigator && Globals.win.navigator.userAgent) || '', Globals.isChrome = Globals.userAgent.indexOf('Chrome') !== -1, Globals.isFirefox = Globals.userAgent.indexOf('Firefox') !== -1, Globals.isMS = /(edge|msie|trident)/i.test(Globals.userAgent) && !Globals.win.opera, Globals.isSafari = !Globals.isChrome && Globals.userAgent.indexOf('Safari') !== -1, Globals.isTouchDevice = /(Mobile|Android|Windows Phone)/.test(Globals.userAgent), Globals.isWebKit = Globals.userAgent.indexOf('AppleWebKit') !== -1, Globals.deg2rad = Math.PI * 2 / 360, Globals.hasBidiBug = (Globals.isFirefox &&
  77. parseInt(Globals.userAgent.split('Firefox/')[1], 10) < 4 // issue #38
  78. ), Globals.hasTouch = !!Globals.win.TouchEvent, Globals.marginNames = [
  79. 'plotTop',
  80. 'marginRight',
  81. 'marginBottom',
  82. 'plotLeft'
  83. ], Globals.noop = function () { }, Globals.supportsPassiveEvents = (function () {
  84. // Checks whether the browser supports passive events, (#11353).
  85. var supportsPassive = false;
  86. // Object.defineProperty doesn't work on IE as well as passive
  87. // events - instead of using polyfill, we can exclude IE totally.
  88. if (!Globals.isMS) {
  89. var opts = Object.defineProperty({}, 'passive', {
  90. get: function () {
  91. supportsPassive = true;
  92. }
  93. });
  94. if (Globals.win.addEventListener && Globals.win.removeEventListener) {
  95. Globals.win.addEventListener('testPassive', Globals.noop, opts);
  96. Globals.win.removeEventListener('testPassive', Globals.noop, opts);
  97. }
  98. }
  99. return supportsPassive;
  100. }());
  101. /**
  102. * An array containing the current chart objects in the page. A chart's
  103. * position in the array is preserved throughout the page's lifetime. When
  104. * a chart is destroyed, the array item becomes `undefined`.
  105. *
  106. * @name Highcharts.charts
  107. * @type {Array<Highcharts.Chart|undefined>}
  108. */
  109. Globals.charts = [];
  110. /**
  111. * A hook for defining additional date format specifiers. New
  112. * specifiers are defined as key-value pairs by using the
  113. * specifier as key, and a function which takes the timestamp as
  114. * value. This function returns the formatted portion of the
  115. * date.
  116. *
  117. * @sample highcharts/global/dateformats/
  118. * Adding support for week number
  119. *
  120. * @name Highcharts.dateFormats
  121. * @type {Record<string, Highcharts.TimeFormatCallbackFunction>}
  122. */
  123. Globals.dateFormats = {};
  124. /**
  125. * @private
  126. * @deprecated
  127. * @todo Use only `Core/Series/SeriesRegistry.seriesTypes`
  128. */
  129. Globals.seriesTypes = {};
  130. /**
  131. * @private
  132. */
  133. Globals.symbolSizes = {};
  134. })(Globals || (Globals = {}));
  135. /* *
  136. *
  137. * Default Export
  138. *
  139. * */
  140. return Globals;
  141. });
  142. _registerModule(_modules, 'Core/Utilities.js', [_modules['Core/Globals.js']], function (H) {
  143. /* *
  144. *
  145. * (c) 2010-2021 Torstein Honsi
  146. *
  147. * License: www.highcharts.com/license
  148. *
  149. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  150. *
  151. * */
  152. var charts = H.charts,
  153. doc = H.doc,
  154. win = H.win;
  155. /**
  156. * An animation configuration. Animation configurations can also be defined as
  157. * booleans, where `false` turns off animation and `true` defaults to a duration
  158. * of 500ms and defer of 0ms.
  159. *
  160. * @interface Highcharts.AnimationOptionsObject
  161. */ /**
  162. * A callback function to exectute when the animation finishes.
  163. * @name Highcharts.AnimationOptionsObject#complete
  164. * @type {Function|undefined}
  165. */ /**
  166. * The animation defer in milliseconds.
  167. * @name Highcharts.AnimationOptionsObject#defer
  168. * @type {number|undefined}
  169. */ /**
  170. * The animation duration in milliseconds.
  171. * @name Highcharts.AnimationOptionsObject#duration
  172. * @type {number|undefined}
  173. */ /**
  174. * The name of an easing function as defined on the `Math` object.
  175. * @name Highcharts.AnimationOptionsObject#easing
  176. * @type {string|Function|undefined}
  177. */ /**
  178. * A callback function to execute on each step of each attribute or CSS property
  179. * that's being animated. The first argument contains information about the
  180. * animation and progress.
  181. * @name Highcharts.AnimationOptionsObject#step
  182. * @type {Function|undefined}
  183. */
  184. /**
  185. * Creates a frame for the animated SVG element.
  186. *
  187. * @callback Highcharts.AnimationStepCallbackFunction
  188. *
  189. * @param {Highcharts.SVGElement} this
  190. * The SVG element to animate.
  191. *
  192. * @return {void}
  193. */
  194. /**
  195. * Interface description for a class.
  196. *
  197. * @interface Highcharts.Class<T>
  198. * @extends Function
  199. */ /**
  200. * Class costructor.
  201. * @function Highcharts.Class<T>#new
  202. * @param {...Array<*>} args
  203. * Constructor arguments.
  204. * @return {T}
  205. * Class instance.
  206. */
  207. /**
  208. * A style object with camel case property names to define visual appearance of
  209. * a SVG element or HTML element. The properties can be whatever styles are
  210. * supported on the given SVG or HTML element.
  211. *
  212. * @example
  213. * {
  214. * fontFamily: 'monospace',
  215. * fontSize: '1.2em'
  216. * }
  217. *
  218. * @interface Highcharts.CSSObject
  219. */ /**
  220. * @name Highcharts.CSSObject#[key:string]
  221. * @type {boolean|number|string|undefined}
  222. */ /**
  223. * Background style for the element.
  224. * @name Highcharts.CSSObject#background
  225. * @type {string|undefined}
  226. */ /**
  227. * Background color of the element.
  228. * @name Highcharts.CSSObject#backgroundColor
  229. * @type {Highcharts.ColorString|undefined}
  230. */ /**
  231. * Border style for the element.
  232. * @name Highcharts.CSSObject#border
  233. * @type {string|undefined}
  234. */ /**
  235. * Radius of the element border.
  236. * @name Highcharts.CSSObject#borderRadius
  237. * @type {number|undefined}
  238. */ /**
  239. * Color used in the element. The 'contrast' option is a Highcharts custom
  240. * property that results in black or white, depending on the background of the
  241. * element.
  242. * @name Highcharts.CSSObject#color
  243. * @type {'contrast'|Highcharts.ColorString|undefined}
  244. */ /**
  245. * Style of the mouse cursor when resting over the element.
  246. * @name Highcharts.CSSObject#cursor
  247. * @type {Highcharts.CursorValue|undefined}
  248. */ /**
  249. * Font family of the element text. Multiple values have to be in decreasing
  250. * preference order and separated by comma.
  251. * @name Highcharts.CSSObject#fontFamily
  252. * @type {string|undefined}
  253. */ /**
  254. * Font size of the element text.
  255. * @name Highcharts.CSSObject#fontSize
  256. * @type {string|undefined}
  257. */ /**
  258. * Font weight of the element text.
  259. * @name Highcharts.CSSObject#fontWeight
  260. * @type {string|undefined}
  261. */ /**
  262. * Height of the element.
  263. * @name Highcharts.CSSObject#height
  264. * @type {number|undefined}
  265. */ /**
  266. * Width of the element border.
  267. * @name Highcharts.CSSObject#lineWidth
  268. * @type {number|undefined}
  269. */ /**
  270. * Opacity of the element.
  271. * @name Highcharts.CSSObject#opacity
  272. * @type {number|undefined}
  273. */ /**
  274. * Space around the element content.
  275. * @name Highcharts.CSSObject#padding
  276. * @type {string|undefined}
  277. */ /**
  278. * Behaviour of the element when the mouse cursor rests over it.
  279. * @name Highcharts.CSSObject#pointerEvents
  280. * @type {string|undefined}
  281. */ /**
  282. * Positioning of the element.
  283. * @name Highcharts.CSSObject#position
  284. * @type {string|undefined}
  285. */ /**
  286. * Alignment of the element text.
  287. * @name Highcharts.CSSObject#textAlign
  288. * @type {string|undefined}
  289. */ /**
  290. * Additional decoration of the element text.
  291. * @name Highcharts.CSSObject#textDecoration
  292. * @type {string|undefined}
  293. */ /**
  294. * Outline style of the element text.
  295. * @name Highcharts.CSSObject#textOutline
  296. * @type {string|undefined}
  297. */ /**
  298. * Line break style of the element text. Highcharts SVG elements support
  299. * `ellipsis` when a `width` is set.
  300. * @name Highcharts.CSSObject#textOverflow
  301. * @type {string|undefined}
  302. */ /**
  303. * Top spacing of the element relative to the parent element.
  304. * @name Highcharts.CSSObject#top
  305. * @type {string|undefined}
  306. */ /**
  307. * Animated transition of selected element properties.
  308. * @name Highcharts.CSSObject#transition
  309. * @type {string|undefined}
  310. */ /**
  311. * Line break style of the element text.
  312. * @name Highcharts.CSSObject#whiteSpace
  313. * @type {string|undefined}
  314. */ /**
  315. * Width of the element.
  316. * @name Highcharts.CSSObject#width
  317. * @type {number|undefined}
  318. */
  319. /**
  320. * All possible cursor styles.
  321. *
  322. * @typedef {'alias'|'all-scroll'|'auto'|'cell'|'col-resize'|'context-menu'|'copy'|'crosshair'|'default'|'e-resize'|'ew-resize'|'grab'|'grabbing'|'help'|'move'|'n-resize'|'ne-resize'|'nesw-resize'|'no-drop'|'none'|'not-allowed'|'ns-resize'|'nw-resize'|'nwse-resize'|'pointer'|'progress'|'row-resize'|'s-resize'|'se-resize'|'sw-resize'|'text'|'vertical-text'|'w-resize'|'wait'|'zoom-in'|'zoom-out'} Highcharts.CursorValue
  323. */
  324. /**
  325. * All possible dash styles.
  326. *
  327. * @typedef {'Dash'|'DashDot'|'Dot'|'LongDash'|'LongDashDot'|'LongDashDotDot'|'ShortDash'|'ShortDashDot'|'ShortDashDotDot'|'ShortDot'|'Solid'} Highcharts.DashStyleValue
  328. */
  329. /**
  330. * Generic dictionary in TypeScript notation.
  331. * Use the native `AnyRecord` instead.
  332. *
  333. * @deprecated
  334. * @interface Highcharts.Dictionary<T>
  335. */ /**
  336. * @name Highcharts.Dictionary<T>#[key:string]
  337. * @type {T}
  338. */
  339. /**
  340. * The function callback to execute when the event is fired. The `this` context
  341. * contains the instance, that fired the event.
  342. *
  343. * @callback Highcharts.EventCallbackFunction<T>
  344. *
  345. * @param {T} this
  346. *
  347. * @param {Highcharts.Dictionary<*>|Event} [eventArguments]
  348. * Event arguments.
  349. *
  350. * @return {boolean|void}
  351. */
  352. /**
  353. * The event options for adding function callback.
  354. *
  355. * @interface Highcharts.EventOptionsObject
  356. */ /**
  357. * The order the event handler should be called. This opens for having one
  358. * handler be called before another, independent of in which order they were
  359. * added.
  360. * @name Highcharts.EventOptionsObject#order
  361. * @type {number}
  362. */ /**
  363. * Whether an event should be passive or not.
  364. * When set to `true`, the function specified by listener will never call
  365. * `preventDefault()`.
  366. * @name Highcharts.EventOptionsObject#passive
  367. * @type boolean
  368. */
  369. /**
  370. * Formats data as a string. Usually the data is accessible throught the `this`
  371. * keyword.
  372. *
  373. * @callback Highcharts.FormatterCallbackFunction<T>
  374. *
  375. * @param {T} this
  376. * Context to format
  377. *
  378. * @return {string}
  379. * Formatted text
  380. */
  381. /**
  382. * An object of key-value pairs for HTML attributes.
  383. *
  384. * @typedef {Highcharts.Dictionary<boolean|number|string|Function>} Highcharts.HTMLAttributes
  385. */
  386. /**
  387. * An HTML DOM element. The type is a reference to the regular HTMLElement in
  388. * the global scope.
  389. *
  390. * @typedef {global.HTMLElement} Highcharts.HTMLDOMElement
  391. *
  392. * @see https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement
  393. */
  394. /**
  395. * The iterator callback.
  396. *
  397. * @callback Highcharts.ObjectEachCallbackFunction<T>
  398. *
  399. * @param {T} this
  400. * The context.
  401. *
  402. * @param {*} value
  403. * The property value.
  404. *
  405. * @param {string} key
  406. * The property key.
  407. *
  408. * @param {*} obj
  409. * The object that objectEach is being applied to.
  410. */
  411. /**
  412. * An object containing `left` and `top` properties for the position in the
  413. * page.
  414. *
  415. * @interface Highcharts.OffsetObject
  416. */ /**
  417. * Left distance to the page border.
  418. * @name Highcharts.OffsetObject#left
  419. * @type {number}
  420. */ /**
  421. * Top distance to the page border.
  422. * @name Highcharts.OffsetObject#top
  423. * @type {number}
  424. */
  425. /**
  426. * Describes a range.
  427. *
  428. * @interface Highcharts.RangeObject
  429. */ /**
  430. * Maximum number of the range.
  431. * @name Highcharts.RangeObject#max
  432. * @type {number}
  433. */ /**
  434. * Minimum number of the range.
  435. * @name Highcharts.RangeObject#min
  436. * @type {number}
  437. */
  438. /**
  439. * If a number is given, it defines the pixel length. If a percentage string is
  440. * given, like for example `'50%'`, the setting defines a length relative to a
  441. * base size, for example the size of a container.
  442. *
  443. * @typedef {number|string} Highcharts.RelativeSize
  444. */
  445. /**
  446. * Proceed function to call original (wrapped) function.
  447. *
  448. * @callback Highcharts.WrapProceedFunction
  449. *
  450. * @param {*} [arg1]
  451. * Optional argument. Without any arguments defaults to first argument of
  452. * the wrapping function.
  453. *
  454. * @param {*} [arg2]
  455. * Optional argument. Without any arguments defaults to second argument
  456. * of the wrapping function.
  457. *
  458. * @param {*} [arg3]
  459. * Optional argument. Without any arguments defaults to third argument of
  460. * the wrapping function.
  461. *
  462. * @return {*}
  463. * Return value of the original function.
  464. */
  465. /**
  466. * The Highcharts object is the placeholder for all other members, and various
  467. * utility functions. The most important member of the namespace would be the
  468. * chart constructor.
  469. *
  470. * @example
  471. * let chart = Highcharts.chart('container', { ... });
  472. *
  473. * @namespace Highcharts
  474. */
  475. ''; // detach doclets above
  476. /**
  477. * Provide error messages for debugging, with links to online explanation. This
  478. * function can be overridden to provide custom error handling.
  479. *
  480. * @sample highcharts/chart/highcharts-error/
  481. * Custom error handler
  482. *
  483. * @function Highcharts.error
  484. *
  485. * @param {number|string} code
  486. * The error code. See
  487. * [errors.xml](https://github.com/highcharts/highcharts/blob/master/errors/errors.xml)
  488. * for available codes. If it is a string, the error message is printed
  489. * directly in the console.
  490. *
  491. * @param {boolean} [stop=false]
  492. * Whether to throw an error or just log a warning in the console.
  493. *
  494. * @param {Highcharts.Chart} [chart]
  495. * Reference to the chart that causes the error. Used in 'debugger'
  496. * module to display errors directly on the chart.
  497. * Important note: This argument is undefined for errors that lack
  498. * access to the Chart instance. In such case, the error will be
  499. * displayed on the last created chart.
  500. *
  501. * @param {Highcharts.Dictionary<string>} [params]
  502. * Additional parameters for the generated message.
  503. *
  504. * @return {void}
  505. */
  506. function error(code, stop, chart, params) {
  507. var severity = stop ? 'Highcharts error' : 'Highcharts warning';
  508. if (code === 32) {
  509. code = severity + ": Deprecated member";
  510. }
  511. var isCode = isNumber(code);
  512. var message = isCode ?
  513. severity + " #" + code + ": www.highcharts.com/errors/" + code + "/" :
  514. code.toString();
  515. var defaultHandler = function () {
  516. if (stop) {
  517. throw new Error(message);
  518. }
  519. // else ...
  520. if (win.console &&
  521. error.messages.indexOf(message) === -1 // prevent console flooting
  522. ) {
  523. console.warn(message); // eslint-disable-line no-console
  524. }
  525. };
  526. if (typeof params !== 'undefined') {
  527. var additionalMessages_1 = '';
  528. if (isCode) {
  529. message += '?';
  530. }
  531. objectEach(params, function (value, key) {
  532. additionalMessages_1 += "\n - " + key + ": " + value;
  533. if (isCode) {
  534. message += encodeURI(key) + '=' + encodeURI(value);
  535. }
  536. });
  537. message += additionalMessages_1;
  538. }
  539. fireEvent(Highcharts, 'displayError', { chart: chart, code: code, message: message, params: params }, defaultHandler);
  540. error.messages.push(message);
  541. }
  542. (function (error) {
  543. error.messages = [];
  544. })(error || (error = {}));
  545. /* eslint-disable valid-jsdoc */
  546. /**
  547. * Utility function to deep merge two or more objects and return a third object.
  548. * If the first argument is true, the contents of the second object is copied
  549. * into the first object. The merge function can also be used with a single
  550. * object argument to create a deep copy of an object.
  551. *
  552. * @function Highcharts.merge<T>
  553. *
  554. * @param {boolean} extend
  555. * Whether to extend the left-side object (a) or return a whole new
  556. * object.
  557. *
  558. * @param {T|undefined} a
  559. * The first object to extend. When only this is given, the function
  560. * returns a deep copy.
  561. *
  562. * @param {...Array<object|undefined>} [n]
  563. * An object to merge into the previous one.
  564. *
  565. * @return {T}
  566. * The merged object. If the first argument is true, the return is the
  567. * same as the second argument.
  568. */ /**
  569. * Utility function to deep merge two or more objects and return a third object.
  570. * The merge function can also be used with a single object argument to create a
  571. * deep copy of an object.
  572. *
  573. * @function Highcharts.merge<T>
  574. *
  575. * @param {T|undefined} a
  576. * The first object to extend. When only this is given, the function
  577. * returns a deep copy.
  578. *
  579. * @param {...Array<object|undefined>} [n]
  580. * An object to merge into the previous one.
  581. *
  582. * @return {T}
  583. * The merged object. If the first argument is true, the return is the
  584. * same as the second argument.
  585. */
  586. function merge() {
  587. /* eslint-enable valid-jsdoc */
  588. var i,
  589. args = arguments,
  590. ret = {};
  591. var doCopy = function (copy,
  592. original) {
  593. // An object is replacing a primitive
  594. if (typeof copy !== 'object') {
  595. copy = {};
  596. }
  597. objectEach(original, function (value, key) {
  598. // Prototype pollution (#14883)
  599. if (key === '__proto__' || key === 'constructor') {
  600. return;
  601. }
  602. // Copy the contents of objects, but not arrays or DOM nodes
  603. if (isObject(value, true) &&
  604. !isClass(value) &&
  605. !isDOMElement(value)) {
  606. copy[key] = doCopy(copy[key] || {}, value);
  607. // Primitives and arrays are copied over directly
  608. }
  609. else {
  610. copy[key] = original[key];
  611. }
  612. });
  613. return copy;
  614. };
  615. // If first argument is true, copy into the existing object. Used in
  616. // setOptions.
  617. if (args[0] === true) {
  618. ret = args[1];
  619. args = Array.prototype.slice.call(args, 2);
  620. }
  621. // For each argument, extend the return
  622. var len = args.length;
  623. for (i = 0; i < len; i++) {
  624. ret = doCopy(ret, args[i]);
  625. }
  626. return ret;
  627. }
  628. /**
  629. * Constrain a value to within a lower and upper threshold.
  630. *
  631. * @private
  632. * @param {number} value The initial value
  633. * @param {number} min The lower threshold
  634. * @param {number} max The upper threshold
  635. * @return {number} Returns a number value within min and max.
  636. */
  637. function clamp(value, min, max) {
  638. return value > min ? value < max ? value : max : min;
  639. }
  640. // eslint-disable-next-line valid-jsdoc
  641. /**
  642. * Remove settings that have not changed, to avoid unnecessary rendering or
  643. * computing (#9197).
  644. * @private
  645. */
  646. function cleanRecursively(newer, older) {
  647. var result = {};
  648. objectEach(newer, function (_val, key) {
  649. var ob;
  650. // Dive into objects (except DOM nodes)
  651. if (isObject(newer[key], true) &&
  652. !newer.nodeType && // #10044
  653. older[key]) {
  654. ob = cleanRecursively(newer[key], older[key]);
  655. if (Object.keys(ob).length) {
  656. result[key] = ob;
  657. }
  658. // Arrays, primitives and DOM nodes are copied directly
  659. }
  660. else if (isObject(newer[key]) ||
  661. newer[key] !== older[key]) {
  662. result[key] = newer[key];
  663. }
  664. });
  665. return result;
  666. }
  667. /**
  668. * Shortcut for parseInt
  669. *
  670. * @private
  671. * @function Highcharts.pInt
  672. *
  673. * @param {*} s
  674. * any
  675. *
  676. * @param {number} [mag]
  677. * Magnitude
  678. *
  679. * @return {number}
  680. * number
  681. */
  682. function pInt(s, mag) {
  683. return parseInt(s, mag || 10);
  684. }
  685. /**
  686. * Utility function to check for string type.
  687. *
  688. * @function Highcharts.isString
  689. *
  690. * @param {*} s
  691. * The item to check.
  692. *
  693. * @return {boolean}
  694. * True if the argument is a string.
  695. */
  696. function isString(s) {
  697. return typeof s === 'string';
  698. }
  699. /**
  700. * Utility function to check if an item is an array.
  701. *
  702. * @function Highcharts.isArray
  703. *
  704. * @param {*} obj
  705. * The item to check.
  706. *
  707. * @return {boolean}
  708. * True if the argument is an array.
  709. */
  710. function isArray(obj) {
  711. var str = Object.prototype.toString.call(obj);
  712. return str === '[object Array]' || str === '[object Array Iterator]';
  713. }
  714. /**
  715. * Utility function to check if an item is of type object.
  716. *
  717. * @function Highcharts.isObject
  718. *
  719. * @param {*} obj
  720. * The item to check.
  721. *
  722. * @param {boolean} [strict=false]
  723. * Also checks that the object is not an array.
  724. *
  725. * @return {boolean}
  726. * True if the argument is an object.
  727. */
  728. function isObject(obj, strict) {
  729. return (!!obj &&
  730. typeof obj === 'object' &&
  731. (!strict || !isArray(obj))); // eslint-disable-line @typescript-eslint/no-explicit-any
  732. }
  733. /**
  734. * Utility function to check if an Object is a HTML Element.
  735. *
  736. * @function Highcharts.isDOMElement
  737. *
  738. * @param {*} obj
  739. * The item to check.
  740. *
  741. * @return {boolean}
  742. * True if the argument is a HTML Element.
  743. */
  744. function isDOMElement(obj) {
  745. return isObject(obj) && typeof obj.nodeType === 'number';
  746. }
  747. /**
  748. * Utility function to check if an Object is a class.
  749. *
  750. * @function Highcharts.isClass
  751. *
  752. * @param {object|undefined} obj
  753. * The item to check.
  754. *
  755. * @return {boolean}
  756. * True if the argument is a class.
  757. */
  758. function isClass(obj) {
  759. var c = obj && obj.constructor;
  760. return !!(isObject(obj, true) &&
  761. !isDOMElement(obj) &&
  762. (c && c.name && c.name !== 'Object'));
  763. }
  764. /**
  765. * Utility function to check if an item is a number and it is finite (not NaN,
  766. * Infinity or -Infinity).
  767. *
  768. * @function Highcharts.isNumber
  769. *
  770. * @param {*} n
  771. * The item to check.
  772. *
  773. * @return {boolean}
  774. * True if the item is a finite number
  775. */
  776. function isNumber(n) {
  777. return typeof n === 'number' && !isNaN(n) && n < Infinity && n > -Infinity;
  778. }
  779. /**
  780. * Remove the last occurence of an item from an array.
  781. *
  782. * @function Highcharts.erase
  783. *
  784. * @param {Array<*>} arr
  785. * The array.
  786. *
  787. * @param {*} item
  788. * The item to remove.
  789. *
  790. * @return {void}
  791. */
  792. function erase(arr, item) {
  793. var i = arr.length;
  794. while (i--) {
  795. if (arr[i] === item) {
  796. arr.splice(i, 1);
  797. break;
  798. }
  799. }
  800. }
  801. /**
  802. * Check if an object is null or undefined.
  803. *
  804. * @function Highcharts.defined
  805. *
  806. * @param {*} obj
  807. * The object to check.
  808. *
  809. * @return {boolean}
  810. * False if the object is null or undefined, otherwise true.
  811. */
  812. function defined(obj) {
  813. return typeof obj !== 'undefined' && obj !== null;
  814. }
  815. /**
  816. * Set or get an attribute or an object of attributes. To use as a setter, pass
  817. * a key and a value, or let the second argument be a collection of keys and
  818. * values. To use as a getter, pass only a string as the second argument.
  819. *
  820. * @function Highcharts.attr
  821. *
  822. * @param {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement} elem
  823. * The DOM element to receive the attribute(s).
  824. *
  825. * @param {string|Highcharts.HTMLAttributes|Highcharts.SVGAttributes} [prop]
  826. * The property or an object of key-value pairs.
  827. *
  828. * @param {number|string} [value]
  829. * The value if a single property is set.
  830. *
  831. * @return {string|null|undefined}
  832. * When used as a getter, return the value.
  833. */
  834. function attr(elem, prop, value) {
  835. var ret;
  836. // if the prop is a string
  837. if (isString(prop)) {
  838. // set the value
  839. if (defined(value)) {
  840. elem.setAttribute(prop, value);
  841. // get the value
  842. }
  843. else if (elem && elem.getAttribute) {
  844. ret = elem.getAttribute(prop);
  845. // IE7 and below cannot get class through getAttribute (#7850)
  846. if (!ret && prop === 'class') {
  847. ret = elem.getAttribute(prop + 'Name');
  848. }
  849. }
  850. // else if prop is defined, it is a hash of key/value pairs
  851. }
  852. else {
  853. objectEach(prop, function (val, key) {
  854. elem.setAttribute(key, val);
  855. });
  856. }
  857. return ret;
  858. }
  859. /**
  860. * Check if an element is an array, and if not, make it into an array.
  861. *
  862. * @function Highcharts.splat
  863. *
  864. * @param {*} obj
  865. * The object to splat.
  866. *
  867. * @return {Array}
  868. * The produced or original array.
  869. */
  870. function splat(obj) {
  871. return isArray(obj) ? obj : [obj];
  872. }
  873. /**
  874. * Set a timeout if the delay is given, otherwise perform the function
  875. * synchronously.
  876. *
  877. * @function Highcharts.syncTimeout
  878. *
  879. * @param {Function} fn
  880. * The function callback.
  881. *
  882. * @param {number} delay
  883. * Delay in milliseconds.
  884. *
  885. * @param {*} [context]
  886. * An optional context to send to the function callback.
  887. *
  888. * @return {number}
  889. * An identifier for the timeout that can later be cleared with
  890. * Highcharts.clearTimeout. Returns -1 if there is no timeout.
  891. */
  892. function syncTimeout(fn, delay, context) {
  893. if (delay > 0) {
  894. return setTimeout(fn, delay, context);
  895. }
  896. fn.call(0, context);
  897. return -1;
  898. }
  899. /**
  900. * Internal clear timeout. The function checks that the `id` was not removed
  901. * (e.g. by `chart.destroy()`). For the details see
  902. * [issue #7901](https://github.com/highcharts/highcharts/issues/7901).
  903. *
  904. * @function Highcharts.clearTimeout
  905. *
  906. * @param {number} id
  907. * Id of a timeout.
  908. *
  909. * @return {void}
  910. */
  911. function internalClearTimeout(id) {
  912. if (defined(id)) {
  913. clearTimeout(id);
  914. }
  915. }
  916. /* eslint-disable valid-jsdoc */
  917. /**
  918. * Utility function to extend an object with the members of another.
  919. *
  920. * @function Highcharts.extend<T>
  921. *
  922. * @param {T|undefined} a
  923. * The object to be extended.
  924. *
  925. * @param {Partial<T>} b
  926. * The object to add to the first one.
  927. *
  928. * @return {T}
  929. * Object a, the original object.
  930. */
  931. function extend(a, b) {
  932. /* eslint-enable valid-jsdoc */
  933. var n;
  934. if (!a) {
  935. a = {};
  936. }
  937. for (n in b) { // eslint-disable-line guard-for-in
  938. a[n] = b[n];
  939. }
  940. return a;
  941. }
  942. /* eslint-disable valid-jsdoc */
  943. /**
  944. * Return the first value that is not null or undefined.
  945. *
  946. * @function Highcharts.pick<T>
  947. *
  948. * @param {...Array<T|null|undefined>} items
  949. * Variable number of arguments to inspect.
  950. *
  951. * @return {T}
  952. * The value of the first argument that is not null or undefined.
  953. */
  954. function pick() {
  955. var args = arguments;
  956. var length = args.length;
  957. for (var i = 0; i < length; i++) {
  958. var arg = args[i];
  959. if (typeof arg !== 'undefined' && arg !== null) {
  960. return arg;
  961. }
  962. }
  963. }
  964. /**
  965. * Set CSS on a given element.
  966. *
  967. * @function Highcharts.css
  968. *
  969. * @param {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement} el
  970. * An HTML DOM element.
  971. *
  972. * @param {Highcharts.CSSObject} styles
  973. * Style object with camel case property names.
  974. *
  975. * @return {void}
  976. */
  977. function css(el, styles) {
  978. if (H.isMS && !H.svg) { // #2686
  979. if (styles && typeof styles.opacity !== 'undefined') {
  980. styles.filter =
  981. 'alpha(opacity=' + (styles.opacity * 100) + ')';
  982. }
  983. }
  984. extend(el.style, styles);
  985. }
  986. /**
  987. * Utility function to create an HTML element with attributes and styles.
  988. *
  989. * @function Highcharts.createElement
  990. *
  991. * @param {string} tag
  992. * The HTML tag.
  993. *
  994. * @param {Highcharts.HTMLAttributes} [attribs]
  995. * Attributes as an object of key-value pairs.
  996. *
  997. * @param {Highcharts.CSSObject} [styles]
  998. * Styles as an object of key-value pairs.
  999. *
  1000. * @param {Highcharts.HTMLDOMElement} [parent]
  1001. * The parent HTML object.
  1002. *
  1003. * @param {boolean} [nopad=false]
  1004. * If true, remove all padding, border and margin.
  1005. *
  1006. * @return {Highcharts.HTMLDOMElement}
  1007. * The created DOM element.
  1008. */
  1009. function createElement(tag, attribs, styles, parent, nopad) {
  1010. var el = doc.createElement(tag);
  1011. if (attribs) {
  1012. extend(el, attribs);
  1013. }
  1014. if (nopad) {
  1015. css(el, { padding: '0', border: 'none', margin: '0' });
  1016. }
  1017. if (styles) {
  1018. css(el, styles);
  1019. }
  1020. if (parent) {
  1021. parent.appendChild(el);
  1022. }
  1023. return el;
  1024. }
  1025. // eslint-disable-next-line valid-jsdoc
  1026. /**
  1027. * Extend a prototyped class by new members.
  1028. *
  1029. * @function Highcharts.extendClass<T>
  1030. *
  1031. * @param {Highcharts.Class<T>} parent
  1032. * The parent prototype to inherit.
  1033. *
  1034. * @param {Highcharts.Dictionary<*>} members
  1035. * A collection of prototype members to add or override compared to the
  1036. * parent prototype.
  1037. *
  1038. * @return {Highcharts.Class<T>}
  1039. * A new prototype.
  1040. */
  1041. function extendClass(parent, members) {
  1042. var obj = (function () { });
  1043. obj.prototype = new parent(); // eslint-disable-line new-cap
  1044. extend(obj.prototype, members);
  1045. return obj;
  1046. }
  1047. /**
  1048. * Left-pad a string to a given length by adding a character repetetively.
  1049. *
  1050. * @function Highcharts.pad
  1051. *
  1052. * @param {number} number
  1053. * The input string or number.
  1054. *
  1055. * @param {number} [length]
  1056. * The desired string length.
  1057. *
  1058. * @param {string} [padder=0]
  1059. * The character to pad with.
  1060. *
  1061. * @return {string}
  1062. * The padded string.
  1063. */
  1064. function pad(number, length, padder) {
  1065. return new Array((length || 2) +
  1066. 1 -
  1067. String(number)
  1068. .replace('-', '')
  1069. .length).join(padder || '0') + number;
  1070. }
  1071. /**
  1072. * Return a length based on either the integer value, or a percentage of a base.
  1073. *
  1074. * @function Highcharts.relativeLength
  1075. *
  1076. * @param {Highcharts.RelativeSize} value
  1077. * A percentage string or a number.
  1078. *
  1079. * @param {number} base
  1080. * The full length that represents 100%.
  1081. *
  1082. * @param {number} [offset=0]
  1083. * A pixel offset to apply for percentage values. Used internally in
  1084. * axis positioning.
  1085. *
  1086. * @return {number}
  1087. * The computed length.
  1088. */
  1089. function relativeLength(value, base, offset) {
  1090. return (/%$/).test(value) ?
  1091. (base * parseFloat(value) / 100) + (offset || 0) :
  1092. parseFloat(value);
  1093. }
  1094. /**
  1095. * Wrap a method with extended functionality, preserving the original function.
  1096. *
  1097. * @function Highcharts.wrap
  1098. *
  1099. * @param {*} obj
  1100. * The context object that the method belongs to. In real cases, this is
  1101. * often a prototype.
  1102. *
  1103. * @param {string} method
  1104. * The name of the method to extend.
  1105. *
  1106. * @param {Highcharts.WrapProceedFunction} func
  1107. * A wrapper function callback. This function is called with the same
  1108. * arguments as the original function, except that the original function
  1109. * is unshifted and passed as the first argument.
  1110. */
  1111. function wrap(obj, method, func) {
  1112. var proceed = obj[method];
  1113. obj[method] = function () {
  1114. var args = Array.prototype.slice.call(arguments),
  1115. outerArgs = arguments,
  1116. ctx = this;
  1117. ctx.proceed = function () {
  1118. proceed.apply(ctx, arguments.length ? arguments : outerArgs);
  1119. };
  1120. args.unshift(proceed);
  1121. var ret = func.apply(this,
  1122. args);
  1123. ctx.proceed = null;
  1124. return ret;
  1125. };
  1126. }
  1127. /**
  1128. * Get the magnitude of a number.
  1129. *
  1130. * @function Highcharts.getMagnitude
  1131. *
  1132. * @param {number} num
  1133. * The number.
  1134. *
  1135. * @return {number}
  1136. * The magnitude, where 1-9 are magnitude 1, 10-99 magnitude 2 etc.
  1137. */
  1138. function getMagnitude(num) {
  1139. return Math.pow(10, Math.floor(Math.log(num) / Math.LN10));
  1140. }
  1141. /**
  1142. * Take an interval and normalize it to multiples of round numbers.
  1143. *
  1144. * @deprecated
  1145. * @function Highcharts.normalizeTickInterval
  1146. *
  1147. * @param {number} interval
  1148. * The raw, un-rounded interval.
  1149. *
  1150. * @param {Array<*>} [multiples]
  1151. * Allowed multiples.
  1152. *
  1153. * @param {number} [magnitude]
  1154. * The magnitude of the number.
  1155. *
  1156. * @param {boolean} [allowDecimals]
  1157. * Whether to allow decimals.
  1158. *
  1159. * @param {boolean} [hasTickAmount]
  1160. * If it has tickAmount, avoid landing on tick intervals lower than
  1161. * original.
  1162. *
  1163. * @return {number}
  1164. * The normalized interval.
  1165. *
  1166. * @todo
  1167. * Move this function to the Axis prototype. It is here only for historical
  1168. * reasons.
  1169. */
  1170. function normalizeTickInterval(interval, multiples, magnitude, allowDecimals, hasTickAmount) {
  1171. var i,
  1172. retInterval = interval;
  1173. // round to a tenfold of 1, 2, 2.5 or 5
  1174. magnitude = pick(magnitude, 1);
  1175. var normalized = interval / magnitude;
  1176. // multiples for a linear scale
  1177. if (!multiples) {
  1178. multiples = hasTickAmount ?
  1179. // Finer grained ticks when the tick amount is hard set, including
  1180. // when alignTicks is true on multiple axes (#4580).
  1181. [1, 1.2, 1.5, 2, 2.5, 3, 4, 5, 6, 8, 10] :
  1182. // Else, let ticks fall on rounder numbers
  1183. [1, 2, 2.5, 5, 10];
  1184. // the allowDecimals option
  1185. if (allowDecimals === false) {
  1186. if (magnitude === 1) {
  1187. multiples = multiples.filter(function (num) {
  1188. return num % 1 === 0;
  1189. });
  1190. }
  1191. else if (magnitude <= 0.1) {
  1192. multiples = [1 / magnitude];
  1193. }
  1194. }
  1195. }
  1196. // normalize the interval to the nearest multiple
  1197. for (i = 0; i < multiples.length; i++) {
  1198. retInterval = multiples[i];
  1199. // only allow tick amounts smaller than natural
  1200. if ((hasTickAmount &&
  1201. retInterval * magnitude >= interval) ||
  1202. (!hasTickAmount &&
  1203. (normalized <=
  1204. (multiples[i] +
  1205. (multiples[i + 1] || multiples[i])) / 2))) {
  1206. break;
  1207. }
  1208. }
  1209. // Multiply back to the correct magnitude. Correct floats to appropriate
  1210. // precision (#6085).
  1211. retInterval = correctFloat(retInterval * magnitude, -Math.round(Math.log(0.001) / Math.LN10));
  1212. return retInterval;
  1213. }
  1214. /**
  1215. * Sort an object array and keep the order of equal items. The ECMAScript
  1216. * standard does not specify the behaviour when items are equal.
  1217. *
  1218. * @function Highcharts.stableSort
  1219. *
  1220. * @param {Array<*>} arr
  1221. * The array to sort.
  1222. *
  1223. * @param {Function} sortFunction
  1224. * The function to sort it with, like with regular Array.prototype.sort.
  1225. *
  1226. * @return {void}
  1227. */
  1228. function stableSort(arr, sortFunction) {
  1229. // @todo It seems like Chrome since v70 sorts in a stable way internally,
  1230. // plus all other browsers do it, so over time we may be able to remove this
  1231. // function
  1232. var length = arr.length;
  1233. var sortValue,
  1234. i;
  1235. // Add index to each item
  1236. for (i = 0; i < length; i++) {
  1237. arr[i].safeI = i; // stable sort index
  1238. }
  1239. arr.sort(function (a, b) {
  1240. sortValue = sortFunction(a, b);
  1241. return sortValue === 0 ? a.safeI - b.safeI : sortValue;
  1242. });
  1243. // Remove index from items
  1244. for (i = 0; i < length; i++) {
  1245. delete arr[i].safeI; // stable sort index
  1246. }
  1247. }
  1248. /**
  1249. * Non-recursive method to find the lowest member of an array. `Math.min` raises
  1250. * a maximum call stack size exceeded error in Chrome when trying to apply more
  1251. * than 150.000 points. This method is slightly slower, but safe.
  1252. *
  1253. * @function Highcharts.arrayMin
  1254. *
  1255. * @param {Array<*>} data
  1256. * An array of numbers.
  1257. *
  1258. * @return {number}
  1259. * The lowest number.
  1260. */
  1261. function arrayMin(data) {
  1262. var i = data.length,
  1263. min = data[0];
  1264. while (i--) {
  1265. if (data[i] < min) {
  1266. min = data[i];
  1267. }
  1268. }
  1269. return min;
  1270. }
  1271. /**
  1272. * Non-recursive method to find the lowest member of an array. `Math.max` raises
  1273. * a maximum call stack size exceeded error in Chrome when trying to apply more
  1274. * than 150.000 points. This method is slightly slower, but safe.
  1275. *
  1276. * @function Highcharts.arrayMax
  1277. *
  1278. * @param {Array<*>} data
  1279. * An array of numbers.
  1280. *
  1281. * @return {number}
  1282. * The highest number.
  1283. */
  1284. function arrayMax(data) {
  1285. var i = data.length,
  1286. max = data[0];
  1287. while (i--) {
  1288. if (data[i] > max) {
  1289. max = data[i];
  1290. }
  1291. }
  1292. return max;
  1293. }
  1294. /**
  1295. * Utility method that destroys any SVGElement instances that are properties on
  1296. * the given object. It loops all properties and invokes destroy if there is a
  1297. * destroy method. The property is then delete.
  1298. *
  1299. * @function Highcharts.destroyObjectProperties
  1300. *
  1301. * @param {*} obj
  1302. * The object to destroy properties on.
  1303. *
  1304. * @param {*} [except]
  1305. * Exception, do not destroy this property, only delete it.
  1306. */
  1307. function destroyObjectProperties(obj, except) {
  1308. objectEach(obj, function (val, n) {
  1309. // If the object is non-null and destroy is defined
  1310. if (val && val !== except && val.destroy) {
  1311. // Invoke the destroy
  1312. val.destroy();
  1313. }
  1314. // Delete the property from the object.
  1315. delete obj[n];
  1316. });
  1317. }
  1318. /**
  1319. * Discard a HTML element by moving it to the bin and delete.
  1320. *
  1321. * @function Highcharts.discardElement
  1322. *
  1323. * @param {Highcharts.HTMLDOMElement} element
  1324. * The HTML node to discard.
  1325. */
  1326. function discardElement(element) {
  1327. // create a garbage bin element, not part of the DOM
  1328. if (!garbageBin) {
  1329. garbageBin = createElement('div');
  1330. }
  1331. // move the node and empty bin
  1332. if (element) {
  1333. garbageBin.appendChild(element);
  1334. }
  1335. garbageBin.innerHTML = '';
  1336. }
  1337. var garbageBin;
  1338. /**
  1339. * Fix JS round off float errors.
  1340. *
  1341. * @function Highcharts.correctFloat
  1342. *
  1343. * @param {number} num
  1344. * A float number to fix.
  1345. *
  1346. * @param {number} [prec=14]
  1347. * The precision.
  1348. *
  1349. * @return {number}
  1350. * The corrected float number.
  1351. */
  1352. function correctFloat(num, prec) {
  1353. return parseFloat(num.toPrecision(prec || 14));
  1354. }
  1355. /**
  1356. * The time unit lookup
  1357. *
  1358. * @ignore
  1359. */
  1360. var timeUnits = {
  1361. millisecond: 1,
  1362. second: 1000,
  1363. minute: 60000,
  1364. hour: 3600000,
  1365. day: 24 * 3600000,
  1366. week: 7 * 24 * 3600000,
  1367. month: 28 * 24 * 3600000,
  1368. year: 364 * 24 * 3600000
  1369. };
  1370. /**
  1371. * Easing definition
  1372. *
  1373. * @private
  1374. * @function Math.easeInOutSine
  1375. *
  1376. * @param {number} pos
  1377. * Current position, ranging from 0 to 1.
  1378. *
  1379. * @return {number}
  1380. * Ease result
  1381. */
  1382. Math.easeInOutSine = function (pos) {
  1383. return -0.5 * (Math.cos(Math.PI * pos) - 1);
  1384. };
  1385. /**
  1386. * Returns the value of a property path on a given object.
  1387. *
  1388. * @private
  1389. * @function getNestedProperty
  1390. *
  1391. * @param {string} path
  1392. * Path to the property, for example `custom.myValue`.
  1393. *
  1394. * @param {unknown} obj
  1395. * Instance containing the property on the specific path.
  1396. *
  1397. * @return {unknown}
  1398. * The unknown property value.
  1399. */
  1400. function getNestedProperty(path, parent) {
  1401. var pathElements = path.split('.');
  1402. while (pathElements.length && defined(parent)) {
  1403. var pathElement = pathElements.shift();
  1404. // Filter on the key
  1405. if (typeof pathElement === 'undefined' ||
  1406. pathElement === '__proto__') {
  1407. return; // undefined
  1408. }
  1409. var child = parent[pathElement];
  1410. // Filter on the child
  1411. if (!defined(child) ||
  1412. typeof child === 'function' ||
  1413. typeof child.nodeType === 'number' ||
  1414. child === win) {
  1415. return; // undefined
  1416. }
  1417. // Else, proceed
  1418. parent = child;
  1419. }
  1420. return parent;
  1421. }
  1422. /**
  1423. * Get the computed CSS value for given element and property, only for numerical
  1424. * properties. For width and height, the dimension of the inner box (excluding
  1425. * padding) is returned. Used for fitting the chart within the container.
  1426. *
  1427. * @function Highcharts.getStyle
  1428. *
  1429. * @param {Highcharts.HTMLDOMElement} el
  1430. * An HTML element.
  1431. *
  1432. * @param {string} prop
  1433. * The property name.
  1434. *
  1435. * @param {boolean} [toInt=true]
  1436. * Parse to integer.
  1437. *
  1438. * @return {number|string|undefined}
  1439. * The style value.
  1440. */
  1441. function getStyle(el, prop, toInt) {
  1442. var customGetStyle = (H.getStyle || // oldie getStyle
  1443. getStyle);
  1444. var style;
  1445. // For width and height, return the actual inner pixel size (#4913)
  1446. if (prop === 'width') {
  1447. var offsetWidth = Math.min(el.offsetWidth,
  1448. el.scrollWidth);
  1449. // In flex boxes, we need to use getBoundingClientRect and floor it,
  1450. // because scrollWidth doesn't support subpixel precision (#6427) ...
  1451. var boundingClientRectWidth = el.getBoundingClientRect &&
  1452. el.getBoundingClientRect().width;
  1453. // ...unless if the containing div or its parents are transform-scaled
  1454. // down, in which case the boundingClientRect can't be used as it is
  1455. // also scaled down (#9871, #10498).
  1456. if (boundingClientRectWidth < offsetWidth &&
  1457. boundingClientRectWidth >= offsetWidth - 1) {
  1458. offsetWidth = Math.floor(boundingClientRectWidth);
  1459. }
  1460. return Math.max(0, // #8377
  1461. (offsetWidth -
  1462. (customGetStyle(el, 'padding-left', true) || 0) -
  1463. (customGetStyle(el, 'padding-right', true) || 0)));
  1464. }
  1465. if (prop === 'height') {
  1466. return Math.max(0, // #8377
  1467. (Math.min(el.offsetHeight, el.scrollHeight) -
  1468. (customGetStyle(el, 'padding-top', true) || 0) -
  1469. (customGetStyle(el, 'padding-bottom', true) || 0)));
  1470. }
  1471. if (!win.getComputedStyle) {
  1472. // SVG not supported, forgot to load oldie.js?
  1473. error(27, true);
  1474. }
  1475. // Otherwise, get the computed style
  1476. var css = win.getComputedStyle(el,
  1477. undefined); // eslint-disable-line no-undefined
  1478. if (css) {
  1479. style = css.getPropertyValue(prop);
  1480. if (pick(toInt, prop !== 'opacity')) {
  1481. style = pInt(style);
  1482. }
  1483. }
  1484. return style;
  1485. }
  1486. /**
  1487. * Search for an item in an array.
  1488. *
  1489. * @function Highcharts.inArray
  1490. *
  1491. * @deprecated
  1492. *
  1493. * @param {*} item
  1494. * The item to search for.
  1495. *
  1496. * @param {Array<*>} arr
  1497. * The array or node collection to search in.
  1498. *
  1499. * @param {number} [fromIndex=0]
  1500. * The index to start searching from.
  1501. *
  1502. * @return {number}
  1503. * The index within the array, or -1 if not found.
  1504. */
  1505. function inArray(item, arr, fromIndex) {
  1506. error(32, false, void 0, { 'Highcharts.inArray': 'use Array.indexOf' });
  1507. return arr.indexOf(item, fromIndex);
  1508. }
  1509. /* eslint-disable valid-jsdoc */
  1510. /**
  1511. * Return the value of the first element in the array that satisfies the
  1512. * provided testing function.
  1513. *
  1514. * @function Highcharts.find<T>
  1515. *
  1516. * @param {Array<T>} arr
  1517. * The array to test.
  1518. *
  1519. * @param {Function} callback
  1520. * The callback function. The function receives the item as the first
  1521. * argument. Return `true` if this item satisfies the condition.
  1522. *
  1523. * @return {T|undefined}
  1524. * The value of the element.
  1525. */
  1526. var find = Array.prototype.find ?
  1527. /* eslint-enable valid-jsdoc */
  1528. function (arr,
  1529. callback) {
  1530. return arr.find(callback);
  1531. } :
  1532. // Legacy implementation. PhantomJS, IE <= 11 etc. #7223.
  1533. function (arr, callback) {
  1534. var i;
  1535. var length = arr.length;
  1536. for (i = 0; i < length; i++) {
  1537. if (callback(arr[i], i)) { // eslint-disable-line callback-return
  1538. return arr[i];
  1539. }
  1540. }
  1541. };
  1542. /**
  1543. * Returns an array of a given object's own properties.
  1544. *
  1545. * @function Highcharts.keys
  1546. * @deprecated
  1547. *
  1548. * @param {*} obj
  1549. * The object of which the properties are to be returned.
  1550. *
  1551. * @return {Array<string>}
  1552. * An array of strings that represents all the properties.
  1553. */
  1554. function keys(obj) {
  1555. error(32, false, void 0, { 'Highcharts.keys': 'use Object.keys' });
  1556. return Object.keys(obj);
  1557. }
  1558. /**
  1559. * Get the element's offset position, corrected for `overflow: auto`.
  1560. *
  1561. * @function Highcharts.offset
  1562. *
  1563. * @param {global.Element} el
  1564. * The DOM element.
  1565. *
  1566. * @return {Highcharts.OffsetObject}
  1567. * An object containing `left` and `top` properties for the position in
  1568. * the page.
  1569. */
  1570. function offset(el) {
  1571. var docElem = doc.documentElement,
  1572. box = (el.parentElement || el.parentNode) ?
  1573. el.getBoundingClientRect() :
  1574. { top: 0,
  1575. left: 0,
  1576. width: 0,
  1577. height: 0 };
  1578. return {
  1579. top: box.top + (win.pageYOffset || docElem.scrollTop) -
  1580. (docElem.clientTop || 0),
  1581. left: box.left + (win.pageXOffset || docElem.scrollLeft) -
  1582. (docElem.clientLeft || 0),
  1583. width: box.width,
  1584. height: box.height
  1585. };
  1586. }
  1587. /* eslint-disable valid-jsdoc */
  1588. /**
  1589. * Iterate over object key pairs in an object.
  1590. *
  1591. * @function Highcharts.objectEach<T>
  1592. *
  1593. * @param {*} obj
  1594. * The object to iterate over.
  1595. *
  1596. * @param {Highcharts.ObjectEachCallbackFunction<T>} fn
  1597. * The iterator callback. It passes three arguments:
  1598. * * value - The property value.
  1599. * * key - The property key.
  1600. * * obj - The object that objectEach is being applied to.
  1601. *
  1602. * @param {T} [ctx]
  1603. * The context.
  1604. *
  1605. * @return {void}
  1606. */
  1607. function objectEach(obj, fn, ctx) {
  1608. /* eslint-enable valid-jsdoc */
  1609. for (var key in obj) {
  1610. if (Object.hasOwnProperty.call(obj, key)) {
  1611. fn.call(ctx || obj[key], obj[key], key, obj);
  1612. }
  1613. }
  1614. }
  1615. /**
  1616. * Iterate over an array.
  1617. *
  1618. * @deprecated
  1619. * @function Highcharts.each
  1620. *
  1621. * @param {Array<*>} arr
  1622. * The array to iterate over.
  1623. *
  1624. * @param {Function} fn
  1625. * The iterator callback. It passes three arguments:
  1626. * - `item`: The array item.
  1627. * - `index`: The item's index in the array.
  1628. * - `arr`: The array that each is being applied to.
  1629. *
  1630. * @param {*} [ctx]
  1631. * The context.
  1632. *
  1633. * @return {void}
  1634. */
  1635. /**
  1636. * Filter an array by a callback.
  1637. *
  1638. * @deprecated
  1639. * @function Highcharts.grep
  1640. *
  1641. * @param {Array<*>} arr
  1642. * The array to filter.
  1643. *
  1644. * @param {Function} callback
  1645. * The callback function. The function receives the item as the first
  1646. * argument. Return `true` if the item is to be preserved.
  1647. *
  1648. * @return {Array<*>}
  1649. * A new, filtered array.
  1650. */
  1651. /**
  1652. * Map an array by a callback.
  1653. *
  1654. * @deprecated
  1655. * @function Highcharts.map
  1656. *
  1657. * @param {Array<*>} arr
  1658. * The array to map.
  1659. *
  1660. * @param {Function} fn
  1661. * The callback function. Return the new value for the new array.
  1662. *
  1663. * @return {Array<*>}
  1664. * A new array item with modified items.
  1665. */
  1666. /**
  1667. * Reduce an array to a single value.
  1668. *
  1669. * @deprecated
  1670. * @function Highcharts.reduce
  1671. *
  1672. * @param {Array<*>} arr
  1673. * The array to reduce.
  1674. *
  1675. * @param {Function} fn
  1676. * The callback function. Return the reduced value. Receives 4
  1677. * arguments: Accumulated/reduced value, current value, current array
  1678. * index, and the array.
  1679. *
  1680. * @param {*} initialValue
  1681. * The initial value of the accumulator.
  1682. *
  1683. * @return {*}
  1684. * The reduced value.
  1685. */
  1686. /**
  1687. * Test whether at least one element in the array passes the test implemented by
  1688. * the provided function.
  1689. *
  1690. * @deprecated
  1691. * @function Highcharts.some
  1692. *
  1693. * @param {Array<*>} arr
  1694. * The array to test
  1695. *
  1696. * @param {Function} fn
  1697. * The function to run on each item. Return truty to pass the test.
  1698. * Receives arguments `currentValue`, `index` and `array`.
  1699. *
  1700. * @param {*} ctx
  1701. * The context.
  1702. *
  1703. * @return {boolean}
  1704. */
  1705. objectEach({
  1706. map: 'map',
  1707. each: 'forEach',
  1708. grep: 'filter',
  1709. reduce: 'reduce',
  1710. some: 'some'
  1711. }, function (val, key) {
  1712. H[key] = function (arr) {
  1713. var _a;
  1714. error(32, false, void 0, (_a = {}, _a["Highcharts." + key] = "use Array." + val, _a));
  1715. return Array.prototype[val].apply(arr, [].slice.call(arguments, 1));
  1716. };
  1717. });
  1718. /* eslint-disable valid-jsdoc */
  1719. /**
  1720. * Add an event listener.
  1721. *
  1722. * @function Highcharts.addEvent<T>
  1723. *
  1724. * @param {Highcharts.Class<T>|T} el
  1725. * The element or object to add a listener to. It can be a
  1726. * {@link HTMLDOMElement}, an {@link SVGElement} or any other object.
  1727. *
  1728. * @param {string} type
  1729. * The event type.
  1730. *
  1731. * @param {Highcharts.EventCallbackFunction<T>|Function} fn
  1732. * The function callback to execute when the event is fired.
  1733. *
  1734. * @param {Highcharts.EventOptionsObject} [options]
  1735. * Options for adding the event.
  1736. *
  1737. * @return {Function}
  1738. * A callback function to remove the added event.
  1739. */
  1740. function addEvent(el, type, fn, options) {
  1741. /* eslint-enable valid-jsdoc */
  1742. if (options === void 0) { options = {}; }
  1743. // Add hcEvents to either the prototype (in case we're running addEvent on a
  1744. // class) or the instance. If hasOwnProperty('hcEvents') is false, it is
  1745. // inherited down the prototype chain, in which case we need to set the
  1746. // property on this instance (which may itself be a prototype).
  1747. var owner = typeof el === 'function' && el.prototype || el;
  1748. if (!Object.hasOwnProperty.call(owner, 'hcEvents')) {
  1749. owner.hcEvents = {};
  1750. }
  1751. var events = owner.hcEvents;
  1752. // Allow click events added to points, otherwise they will be prevented by
  1753. // the TouchPointer.pinch function after a pinch zoom operation (#7091).
  1754. if (H.Point && // without H a dependency loop occurs
  1755. el instanceof H.Point &&
  1756. el.series &&
  1757. el.series.chart) {
  1758. el.series.chart.runTrackerClick = true;
  1759. }
  1760. // Handle DOM events
  1761. // If the browser supports passive events, add it to improve performance
  1762. // on touch events (#11353).
  1763. var addEventListener = (el.addEventListener || H.addEventListenerPolyfill);
  1764. if (addEventListener) {
  1765. addEventListener.call(el, type, fn, H.supportsPassiveEvents ? {
  1766. passive: options.passive === void 0 ?
  1767. type.indexOf('touch') !== -1 : options.passive,
  1768. capture: false
  1769. } : false);
  1770. }
  1771. if (!events[type]) {
  1772. events[type] = [];
  1773. }
  1774. var eventObject = {
  1775. fn: fn,
  1776. order: typeof options.order === 'number' ? options.order : Infinity
  1777. };
  1778. events[type].push(eventObject);
  1779. // Order the calls
  1780. events[type].sort(function (a, b) { return a.order - b.order; });
  1781. // Return a function that can be called to remove this event.
  1782. return function () {
  1783. removeEvent(el, type, fn);
  1784. };
  1785. }
  1786. /* eslint-disable valid-jsdoc */
  1787. /**
  1788. * Remove an event that was added with {@link Highcharts#addEvent}.
  1789. *
  1790. * @function Highcharts.removeEvent<T>
  1791. *
  1792. * @param {Highcharts.Class<T>|T} el
  1793. * The element to remove events on.
  1794. *
  1795. * @param {string} [type]
  1796. * The type of events to remove. If undefined, all events are removed
  1797. * from the element.
  1798. *
  1799. * @param {Highcharts.EventCallbackFunction<T>} [fn]
  1800. * The specific callback to remove. If undefined, all events that match
  1801. * the element and optionally the type are removed.
  1802. *
  1803. * @return {void}
  1804. */
  1805. function removeEvent(el, type, fn) {
  1806. /* eslint-enable valid-jsdoc */
  1807. /**
  1808. * @private
  1809. * @param {string} type - event type
  1810. * @param {Highcharts.EventCallbackFunction<T>} fn - callback
  1811. * @return {void}
  1812. */
  1813. function removeOneEvent(type, fn) {
  1814. var removeEventListener = (el.removeEventListener || H.removeEventListenerPolyfill);
  1815. if (removeEventListener) {
  1816. removeEventListener.call(el, type, fn, false);
  1817. }
  1818. }
  1819. /**
  1820. * @private
  1821. * @param {any} eventCollection - collection
  1822. * @return {void}
  1823. */
  1824. function removeAllEvents(eventCollection) {
  1825. var types,
  1826. len;
  1827. if (!el.nodeName) {
  1828. return; // break on non-DOM events
  1829. }
  1830. if (type) {
  1831. types = {};
  1832. types[type] = true;
  1833. }
  1834. else {
  1835. types = eventCollection;
  1836. }
  1837. objectEach(types, function (_val, n) {
  1838. if (eventCollection[n]) {
  1839. len = eventCollection[n].length;
  1840. while (len--) {
  1841. removeOneEvent(n, eventCollection[n][len].fn);
  1842. }
  1843. }
  1844. });
  1845. }
  1846. var owner = typeof el === 'function' && el.prototype || el;
  1847. if (Object.hasOwnProperty.call(owner, 'hcEvents')) {
  1848. var events = owner.hcEvents;
  1849. if (type) {
  1850. var typeEvents = (events[type] || []);
  1851. if (fn) {
  1852. events[type] = typeEvents.filter(function (obj) {
  1853. return fn !== obj.fn;
  1854. });
  1855. removeOneEvent(type, fn);
  1856. }
  1857. else {
  1858. removeAllEvents(events);
  1859. events[type] = [];
  1860. }
  1861. }
  1862. else {
  1863. removeAllEvents(events);
  1864. delete owner.hcEvents;
  1865. }
  1866. }
  1867. }
  1868. /* eslint-disable valid-jsdoc */
  1869. /**
  1870. * Fire an event that was registered with {@link Highcharts#addEvent}.
  1871. *
  1872. * @function Highcharts.fireEvent<T>
  1873. *
  1874. * @param {T} el
  1875. * The object to fire the event on. It can be a {@link HTMLDOMElement},
  1876. * an {@link SVGElement} or any other object.
  1877. *
  1878. * @param {string} type
  1879. * The type of event.
  1880. *
  1881. * @param {Highcharts.Dictionary<*>|Event} [eventArguments]
  1882. * Custom event arguments that are passed on as an argument to the event
  1883. * handler.
  1884. *
  1885. * @param {Highcharts.EventCallbackFunction<T>|Function} [defaultFunction]
  1886. * The default function to execute if the other listeners haven't
  1887. * returned false.
  1888. *
  1889. * @return {void}
  1890. */
  1891. function fireEvent(el, type, eventArguments, defaultFunction) {
  1892. /* eslint-enable valid-jsdoc */
  1893. var e,
  1894. i;
  1895. eventArguments = eventArguments || {};
  1896. if (doc.createEvent &&
  1897. (el.dispatchEvent ||
  1898. (el.fireEvent &&
  1899. // Enable firing events on Highcharts instance.
  1900. el !== H))) {
  1901. e = doc.createEvent('Events');
  1902. e.initEvent(type, true, true);
  1903. eventArguments = extend(e, eventArguments);
  1904. if (el.dispatchEvent) {
  1905. el.dispatchEvent(eventArguments);
  1906. }
  1907. else {
  1908. el.fireEvent(type, eventArguments);
  1909. }
  1910. }
  1911. else if (el.hcEvents) {
  1912. if (!eventArguments.target) {
  1913. // We're running a custom event
  1914. extend(eventArguments, {
  1915. // Attach a simple preventDefault function to skip
  1916. // default handler if called. The built-in
  1917. // defaultPrevented property is not overwritable (#5112)
  1918. preventDefault: function () {
  1919. eventArguments.defaultPrevented = true;
  1920. },
  1921. // Setting target to native events fails with clicking
  1922. // the zoom-out button in Chrome.
  1923. target: el,
  1924. // If the type is not set, we're running a custom event
  1925. // (#2297). If it is set, we're running a browser event,
  1926. // and setting it will cause en error in IE8 (#2465).
  1927. type: type
  1928. });
  1929. }
  1930. var events = [];
  1931. var object = el;
  1932. var multilevel = false;
  1933. // Recurse up the inheritance chain and collect hcEvents set as own
  1934. // objects on the prototypes.
  1935. while (object.hcEvents) {
  1936. if (Object.hasOwnProperty.call(object, 'hcEvents') &&
  1937. object.hcEvents[type]) {
  1938. if (events.length) {
  1939. multilevel = true;
  1940. }
  1941. events.unshift.apply(events, object.hcEvents[type]);
  1942. }
  1943. object = Object.getPrototypeOf(object);
  1944. }
  1945. // For performance reasons, only sort the event handlers in case we are
  1946. // dealing with multiple levels in the prototype chain. Otherwise, the
  1947. // events are already sorted in the addEvent function.
  1948. if (multilevel) {
  1949. // Order the calls
  1950. events.sort(function (a, b) { return a.order - b.order; });
  1951. }
  1952. // Call the collected event handlers
  1953. events.forEach(function (obj) {
  1954. // If the event handler returns false, prevent the default handler
  1955. // from executing
  1956. if (obj.fn.call(el, eventArguments) === false) {
  1957. eventArguments.preventDefault();
  1958. }
  1959. });
  1960. }
  1961. // Run the default if not prevented
  1962. if (defaultFunction && !eventArguments.defaultPrevented) {
  1963. defaultFunction.call(el, eventArguments);
  1964. }
  1965. }
  1966. var serialMode;
  1967. /**
  1968. * Get a unique key for using in internal element id's and pointers. The key is
  1969. * composed of a random hash specific to this Highcharts instance, and a
  1970. * counter.
  1971. *
  1972. * @example
  1973. * let id = uniqueKey(); // => 'highcharts-x45f6hp-0'
  1974. *
  1975. * @function Highcharts.uniqueKey
  1976. *
  1977. * @return {string}
  1978. * A unique key.
  1979. */
  1980. var uniqueKey = (function () {
  1981. var hash = Math.random().toString(36).substring(2, 9) + '-';
  1982. var id = 0;
  1983. return function () {
  1984. return 'highcharts-' + (serialMode ? '' : hash) + id++;
  1985. };
  1986. }());
  1987. /**
  1988. * Activates a serial mode for element IDs provided by
  1989. * {@link Highcharts.uniqueKey}. This mode can be used in automated tests, where
  1990. * a simple comparison of two rendered SVG graphics is needed.
  1991. *
  1992. * **Note:** This is only for testing purposes and will break functionality in
  1993. * webpages with multiple charts.
  1994. *
  1995. * @example
  1996. * if (
  1997. * process &&
  1998. * process.env.NODE_ENV === 'development'
  1999. * ) {
  2000. * Highcharts.useSerialIds(true);
  2001. * }
  2002. *
  2003. * @function Highcharts.useSerialIds
  2004. *
  2005. * @param {boolean} [mode]
  2006. * Changes the state of serial mode.
  2007. *
  2008. * @return {boolean|undefined}
  2009. * State of the serial mode.
  2010. */
  2011. function useSerialIds(mode) {
  2012. return (serialMode = pick(mode, serialMode));
  2013. }
  2014. function isFunction(obj) {
  2015. return typeof obj === 'function';
  2016. }
  2017. // Register Highcharts as a plugin in jQuery
  2018. if (win.jQuery) {
  2019. /**
  2020. * Highcharts-extended JQuery.
  2021. *
  2022. * @external JQuery
  2023. */
  2024. /**
  2025. * Helper function to return the chart of the current JQuery selector
  2026. * element.
  2027. *
  2028. * @function external:JQuery#highcharts
  2029. *
  2030. * @return {Highcharts.Chart}
  2031. * The chart that is linked to the JQuery selector element.
  2032. */ /**
  2033. * Factory function to create a chart in the current JQuery selector
  2034. * element.
  2035. *
  2036. * @function external:JQuery#highcharts
  2037. *
  2038. * @param {'Chart'|'Map'|'StockChart'|string} [className]
  2039. * Name of the factory class in the Highcharts namespace.
  2040. *
  2041. * @param {Highcharts.Options} [options]
  2042. * The chart options structure.
  2043. *
  2044. * @param {Highcharts.ChartCallbackFunction} [callback]
  2045. * Function to run when the chart has loaded and and all external
  2046. * images are loaded. Defining a
  2047. * [chart.events.load](https://api.highcharts.com/highcharts/chart.events.load)
  2048. * handler is equivalent.
  2049. *
  2050. * @return {JQuery}
  2051. * The current JQuery selector.
  2052. */
  2053. win.jQuery.fn.highcharts = function () {
  2054. var args = [].slice.call(arguments);
  2055. if (this[0]) { // this[0] is the renderTo div
  2056. // Create the chart
  2057. if (args[0]) {
  2058. new H[ // eslint-disable-line computed-property-spacing, no-new
  2059. // Constructor defaults to Chart
  2060. isString(args[0]) ? args.shift() : 'Chart'](this[0], args[0], args[1]);
  2061. return this;
  2062. }
  2063. // When called without parameters or with the return argument,
  2064. // return an existing chart
  2065. return charts[attr(this[0], 'data-highcharts-chart')];
  2066. }
  2067. };
  2068. }
  2069. // TODO use named exports when supported.
  2070. var utilitiesModule = {
  2071. addEvent: addEvent,
  2072. arrayMax: arrayMax,
  2073. arrayMin: arrayMin,
  2074. attr: attr,
  2075. clamp: clamp,
  2076. cleanRecursively: cleanRecursively,
  2077. clearTimeout: internalClearTimeout,
  2078. correctFloat: correctFloat,
  2079. createElement: createElement,
  2080. css: css,
  2081. defined: defined,
  2082. destroyObjectProperties: destroyObjectProperties,
  2083. discardElement: discardElement,
  2084. erase: erase,
  2085. error: error,
  2086. extend: extend,
  2087. extendClass: extendClass,
  2088. find: find,
  2089. fireEvent: fireEvent,
  2090. getMagnitude: getMagnitude,
  2091. getNestedProperty: getNestedProperty,
  2092. getStyle: getStyle,
  2093. inArray: inArray,
  2094. isArray: isArray,
  2095. isClass: isClass,
  2096. isDOMElement: isDOMElement,
  2097. isFunction: isFunction,
  2098. isNumber: isNumber,
  2099. isObject: isObject,
  2100. isString: isString,
  2101. keys: keys,
  2102. merge: merge,
  2103. normalizeTickInterval: normalizeTickInterval,
  2104. objectEach: objectEach,
  2105. offset: offset,
  2106. pad: pad,
  2107. pick: pick,
  2108. pInt: pInt,
  2109. relativeLength: relativeLength,
  2110. removeEvent: removeEvent,
  2111. splat: splat,
  2112. stableSort: stableSort,
  2113. syncTimeout: syncTimeout,
  2114. timeUnits: timeUnits,
  2115. uniqueKey: uniqueKey,
  2116. useSerialIds: useSerialIds,
  2117. wrap: wrap
  2118. };
  2119. return utilitiesModule;
  2120. });
  2121. _registerModule(_modules, 'Core/Color/Color.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  2122. /* *
  2123. *
  2124. * (c) 2010-2021 Torstein Honsi
  2125. *
  2126. * License: www.highcharts.com/license
  2127. *
  2128. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  2129. *
  2130. * */
  2131. var isNumber = U.isNumber,
  2132. merge = U.merge,
  2133. pInt = U.pInt;
  2134. /**
  2135. * A valid color to be parsed and handled by Highcharts. Highcharts internally
  2136. * supports hex colors like `#ffffff`, rgb colors like `rgb(255,255,255)` and
  2137. * rgba colors like `rgba(255,255,255,1)`. Other colors may be supported by the
  2138. * browsers and displayed correctly, but Highcharts is not able to process them
  2139. * and apply concepts like opacity and brightening.
  2140. *
  2141. * @typedef {string} Highcharts.ColorString
  2142. */
  2143. /**
  2144. * A valid color type than can be parsed and handled by Highcharts. It can be a
  2145. * color string, a gradient object, or a pattern object.
  2146. *
  2147. * @typedef {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject} Highcharts.ColorType
  2148. */
  2149. /**
  2150. * Gradient options instead of a solid color.
  2151. *
  2152. * @example
  2153. * // Linear gradient used as a color option
  2154. * color: {
  2155. * linearGradient: { x1: 0, x2: 0, y1: 0, y2: 1 },
  2156. * stops: [
  2157. * [0, '#003399'], // start
  2158. * [0.5, '#ffffff'], // middle
  2159. * [1, '#3366AA'] // end
  2160. * ]
  2161. * }
  2162. *
  2163. * @interface Highcharts.GradientColorObject
  2164. */ /**
  2165. * Holds an object that defines the start position and the end position relative
  2166. * to the shape.
  2167. * @name Highcharts.GradientColorObject#linearGradient
  2168. * @type {Highcharts.LinearGradientColorObject|undefined}
  2169. */ /**
  2170. * Holds an object that defines the center position and the radius.
  2171. * @name Highcharts.GradientColorObject#radialGradient
  2172. * @type {Highcharts.RadialGradientColorObject|undefined}
  2173. */ /**
  2174. * The first item in each tuple is the position in the gradient, where 0 is the
  2175. * start of the gradient and 1 is the end of the gradient. Multiple stops can be
  2176. * applied. The second item is the color for each stop. This color can also be
  2177. * given in the rgba format.
  2178. * @name Highcharts.GradientColorObject#stops
  2179. * @type {Array<Highcharts.GradientColorStopObject>}
  2180. */
  2181. /**
  2182. * Color stop tuple.
  2183. *
  2184. * @see Highcharts.GradientColorObject
  2185. *
  2186. * @interface Highcharts.GradientColorStopObject
  2187. */ /**
  2188. * @name Highcharts.GradientColorStopObject#0
  2189. * @type {number}
  2190. */ /**
  2191. * @name Highcharts.GradientColorStopObject#1
  2192. * @type {Highcharts.ColorString}
  2193. */ /**
  2194. * @name Highcharts.GradientColorStopObject#color
  2195. * @type {Highcharts.Color|undefined}
  2196. */
  2197. /**
  2198. * Defines the start position and the end position for a gradient relative
  2199. * to the shape. Start position (x1, y1) and end position (x2, y2) are relative
  2200. * to the shape, where 0 means top/left and 1 is bottom/right.
  2201. *
  2202. * @interface Highcharts.LinearGradientColorObject
  2203. */ /**
  2204. * Start horizontal position of the gradient. Float ranges 0-1.
  2205. * @name Highcharts.LinearGradientColorObject#x1
  2206. * @type {number}
  2207. */ /**
  2208. * End horizontal position of the gradient. Float ranges 0-1.
  2209. * @name Highcharts.LinearGradientColorObject#x2
  2210. * @type {number}
  2211. */ /**
  2212. * Start vertical position of the gradient. Float ranges 0-1.
  2213. * @name Highcharts.LinearGradientColorObject#y1
  2214. * @type {number}
  2215. */ /**
  2216. * End vertical position of the gradient. Float ranges 0-1.
  2217. * @name Highcharts.LinearGradientColorObject#y2
  2218. * @type {number}
  2219. */
  2220. /**
  2221. * Defines the center position and the radius for a gradient.
  2222. *
  2223. * @interface Highcharts.RadialGradientColorObject
  2224. */ /**
  2225. * Center horizontal position relative to the shape. Float ranges 0-1.
  2226. * @name Highcharts.RadialGradientColorObject#cx
  2227. * @type {number}
  2228. */ /**
  2229. * Center vertical position relative to the shape. Float ranges 0-1.
  2230. * @name Highcharts.RadialGradientColorObject#cy
  2231. * @type {number}
  2232. */ /**
  2233. * Radius relative to the shape. Float ranges 0-1.
  2234. * @name Highcharts.RadialGradientColorObject#r
  2235. * @type {number}
  2236. */
  2237. ''; // detach doclets above
  2238. /* *
  2239. *
  2240. * Class
  2241. *
  2242. * */
  2243. /* eslint-disable no-invalid-this, valid-jsdoc */
  2244. /**
  2245. * Handle color operations. Some object methods are chainable.
  2246. *
  2247. * @class
  2248. * @name Highcharts.Color
  2249. *
  2250. * @param {Highcharts.ColorType} input
  2251. * The input color in either rbga or hex format
  2252. */
  2253. var Color = /** @class */ (function () {
  2254. /* *
  2255. *
  2256. * Constructors
  2257. *
  2258. * */
  2259. function Color(input) {
  2260. // Collection of parsers. This can be extended from the outside by pushing
  2261. // parsers to Highcharts.Color.prototype.parsers.
  2262. this.parsers = [{
  2263. // RGBA color
  2264. // eslint-disable-next-line max-len
  2265. regex: /rgba\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]?(?:\.[0-9]+)?)\s*\)/,
  2266. parse: function (result) {
  2267. return [
  2268. pInt(result[1]),
  2269. pInt(result[2]),
  2270. pInt(result[3]),
  2271. parseFloat(result[4], 10)
  2272. ];
  2273. }
  2274. }, {
  2275. // RGB color
  2276. regex: /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/,
  2277. parse: function (result) {
  2278. return [pInt(result[1]), pInt(result[2]), pInt(result[3]), 1];
  2279. }
  2280. }];
  2281. this.rgba = [];
  2282. // Backwards compatibility, allow class overwrite
  2283. if (H.Color !== Color) {
  2284. return new H.Color(input);
  2285. }
  2286. // Backwards compatibility, allow instanciation without new (#13053)
  2287. if (!(this instanceof Color)) {
  2288. return new Color(input);
  2289. }
  2290. this.init(input);
  2291. }
  2292. /* *
  2293. *
  2294. * Static Functions
  2295. *
  2296. * */
  2297. /**
  2298. * Creates a color instance out of a color string or object.
  2299. *
  2300. * @function Highcharts.Color.parse
  2301. *
  2302. * @param {Highcharts.ColorType} input
  2303. * The input color in either rbga or hex format.
  2304. *
  2305. * @return {Highcharts.Color}
  2306. * Color instance.
  2307. */
  2308. Color.parse = function (input) {
  2309. return new Color(input);
  2310. };
  2311. /* *
  2312. *
  2313. * Functions
  2314. *
  2315. * */
  2316. /**
  2317. * Parse the input color to rgba array
  2318. *
  2319. * @private
  2320. * @function Highcharts.Color#init
  2321. *
  2322. * @param {Highcharts.ColorType} input
  2323. * The input color in either rbga or hex format
  2324. *
  2325. * @return {void}
  2326. */
  2327. Color.prototype.init = function (input) {
  2328. var result,
  2329. rgba,
  2330. i,
  2331. parser,
  2332. len;
  2333. this.input = input = Color.names[input && input.toLowerCase ?
  2334. input.toLowerCase() :
  2335. ''] || input;
  2336. // Gradients
  2337. if (input && input.stops) {
  2338. this.stops = input.stops.map(function (stop) {
  2339. return new Color(stop[1]);
  2340. });
  2341. // Solid colors
  2342. }
  2343. else {
  2344. // Bitmasking as input[0] is not working for legacy IE.
  2345. if (input &&
  2346. input.charAt &&
  2347. input.charAt() === '#') {
  2348. len = input.length;
  2349. input = parseInt(input.substr(1), 16);
  2350. // Handle long-form, e.g. #AABBCC
  2351. if (len === 7) {
  2352. rgba = [
  2353. (input & 0xFF0000) >> 16,
  2354. (input & 0xFF00) >> 8,
  2355. (input & 0xFF),
  2356. 1
  2357. ];
  2358. // Handle short-form, e.g. #ABC
  2359. // In short form, the value is assumed to be the same
  2360. // for both nibbles for each component. e.g. #ABC = #AABBCC
  2361. }
  2362. else if (len === 4) {
  2363. rgba = [
  2364. (((input & 0xF00) >> 4) |
  2365. (input & 0xF00) >> 8),
  2366. (((input & 0xF0) >> 4) |
  2367. (input & 0xF0)),
  2368. ((input & 0xF) << 4) | (input & 0xF),
  2369. 1
  2370. ];
  2371. }
  2372. }
  2373. // Otherwise, check regex parsers
  2374. if (!rgba) {
  2375. i = this.parsers.length;
  2376. while (i-- && !rgba) {
  2377. parser = this.parsers[i];
  2378. result = parser.regex.exec(input);
  2379. if (result) {
  2380. rgba = parser.parse(result);
  2381. }
  2382. }
  2383. }
  2384. }
  2385. this.rgba = rgba || [];
  2386. };
  2387. /**
  2388. * Return the color or gradient stops in the specified format
  2389. *
  2390. * @function Highcharts.Color#get
  2391. *
  2392. * @param {string} [format]
  2393. * Possible values are 'a', 'rgb', 'rgba' (default).
  2394. *
  2395. * @return {Highcharts.ColorType}
  2396. * This color as a string or gradient stops.
  2397. */
  2398. Color.prototype.get = function (format) {
  2399. var input = this.input,
  2400. rgba = this.rgba,
  2401. ret;
  2402. if (typeof this.stops !== 'undefined') {
  2403. ret = merge(input);
  2404. ret.stops = [].concat(ret.stops);
  2405. this.stops.forEach(function (stop, i) {
  2406. ret.stops[i] = [
  2407. ret.stops[i][0],
  2408. stop.get(format)
  2409. ];
  2410. });
  2411. // it's NaN if gradient colors on a column chart
  2412. }
  2413. else if (rgba && isNumber(rgba[0])) {
  2414. if (format === 'rgb' || (!format && rgba[3] === 1)) {
  2415. ret = 'rgb(' + rgba[0] + ',' + rgba[1] + ',' + rgba[2] + ')';
  2416. }
  2417. else if (format === 'a') {
  2418. ret = rgba[3];
  2419. }
  2420. else {
  2421. ret = 'rgba(' + rgba.join(',') + ')';
  2422. }
  2423. }
  2424. else {
  2425. ret = input;
  2426. }
  2427. return ret;
  2428. };
  2429. /**
  2430. * Brighten the color instance.
  2431. *
  2432. * @function Highcharts.Color#brighten
  2433. *
  2434. * @param {number} alpha
  2435. * The alpha value.
  2436. *
  2437. * @return {Highcharts.Color}
  2438. * This color with modifications.
  2439. */
  2440. Color.prototype.brighten = function (alpha) {
  2441. var i,
  2442. rgba = this.rgba;
  2443. if (this.stops) {
  2444. this.stops.forEach(function (stop) {
  2445. stop.brighten(alpha);
  2446. });
  2447. }
  2448. else if (isNumber(alpha) && alpha !== 0) {
  2449. for (i = 0; i < 3; i++) {
  2450. rgba[i] += pInt(alpha * 255);
  2451. if (rgba[i] < 0) {
  2452. rgba[i] = 0;
  2453. }
  2454. if (rgba[i] > 255) {
  2455. rgba[i] = 255;
  2456. }
  2457. }
  2458. }
  2459. return this;
  2460. };
  2461. /**
  2462. * Set the color's opacity to a given alpha value.
  2463. *
  2464. * @function Highcharts.Color#setOpacity
  2465. *
  2466. * @param {number} alpha
  2467. * Opacity between 0 and 1.
  2468. *
  2469. * @return {Highcharts.Color}
  2470. * Color with modifications.
  2471. */
  2472. Color.prototype.setOpacity = function (alpha) {
  2473. this.rgba[3] = alpha;
  2474. return this;
  2475. };
  2476. /**
  2477. * Return an intermediate color between two colors.
  2478. *
  2479. * @function Highcharts.Color#tweenTo
  2480. *
  2481. * @param {Highcharts.Color} to
  2482. * The color object to tween to.
  2483. *
  2484. * @param {number} pos
  2485. * The intermediate position, where 0 is the from color (current
  2486. * color item), and 1 is the `to` color.
  2487. *
  2488. * @return {Highcharts.ColorString}
  2489. * The intermediate color in rgba notation.
  2490. */
  2491. Color.prototype.tweenTo = function (to, pos) {
  2492. // Check for has alpha, because rgba colors perform worse due to lack of
  2493. // support in WebKit.
  2494. var fromRgba = this.rgba,
  2495. toRgba = to.rgba,
  2496. hasAlpha,
  2497. ret;
  2498. // Unsupported color, return to-color (#3920, #7034)
  2499. if (!toRgba.length || !fromRgba || !fromRgba.length) {
  2500. ret = to.input || 'none';
  2501. // Interpolate
  2502. }
  2503. else {
  2504. hasAlpha = (toRgba[3] !== 1 || fromRgba[3] !== 1);
  2505. ret = (hasAlpha ? 'rgba(' : 'rgb(') +
  2506. Math.round(toRgba[0] + (fromRgba[0] - toRgba[0]) * (1 - pos)) +
  2507. ',' +
  2508. Math.round(toRgba[1] + (fromRgba[1] - toRgba[1]) * (1 - pos)) +
  2509. ',' +
  2510. Math.round(toRgba[2] + (fromRgba[2] - toRgba[2]) * (1 - pos)) +
  2511. (hasAlpha ?
  2512. (',' +
  2513. (toRgba[3] + (fromRgba[3] - toRgba[3]) * (1 - pos))) :
  2514. '') +
  2515. ')';
  2516. }
  2517. return ret;
  2518. };
  2519. /* *
  2520. *
  2521. * Static Properties
  2522. *
  2523. * */
  2524. // Collection of named colors. Can be extended from the outside by adding
  2525. // colors to Highcharts.Color.names.
  2526. Color.names = {
  2527. white: '#ffffff',
  2528. black: '#000000'
  2529. };
  2530. return Color;
  2531. }());
  2532. H.Color = Color;
  2533. /**
  2534. * Creates a color instance out of a color string.
  2535. *
  2536. * @function Highcharts.color
  2537. *
  2538. * @param {Highcharts.ColorType} input
  2539. * The input color in either rbga or hex format
  2540. *
  2541. * @return {Highcharts.Color}
  2542. * Color instance
  2543. */
  2544. H.color = Color.parse;
  2545. /* *
  2546. *
  2547. * Export
  2548. *
  2549. * */
  2550. return Color;
  2551. });
  2552. _registerModule(_modules, 'Core/Color/Palette.js', [], function () {
  2553. var palette = {
  2554. /**
  2555. * Colors for data series and points.
  2556. */
  2557. colors: [
  2558. '#7cb5ec',
  2559. '#434348',
  2560. '#90ed7d',
  2561. '#f7a35c',
  2562. '#8085e9',
  2563. '#f15c80',
  2564. '#e4d354',
  2565. '#2b908f',
  2566. '#f45b5b',
  2567. '#91e8e1'
  2568. ],
  2569. /**
  2570. * Chart background,
  2571. point stroke for markers and columns etc
  2572. */
  2573. backgroundColor: '#ffffff',
  2574. /**
  2575. * Strong text.
  2576. */
  2577. neutralColor100: '#000000',
  2578. /**
  2579. * Main text and some strokes.
  2580. */
  2581. neutralColor80: '#333333',
  2582. /**
  2583. * Axis labels,
  2584. axis title,
  2585. connector fallback.
  2586. */
  2587. neutralColor60: '#666666',
  2588. /**
  2589. * Credits text,
  2590. export menu stroke.
  2591. */
  2592. neutralColor40: '#999999',
  2593. /**
  2594. * Disabled texts,
  2595. button strokes,
  2596. crosshair etc.
  2597. */
  2598. neutralColor20: '#cccccc',
  2599. /**
  2600. * Grid lines etc.
  2601. */
  2602. neutralColor10: '#e6e6e6',
  2603. /**
  2604. * Minor grid lines etc.
  2605. */
  2606. neutralColor5: '#f2f2f2',
  2607. /**
  2608. * Tooltip backgroud,
  2609. button fills,
  2610. map null points.
  2611. */
  2612. neutralColor3: '#f7f7f7',
  2613. /**
  2614. * Drilldown clickable labels,
  2615. color axis max color.
  2616. */
  2617. highlightColor100: '#003399',
  2618. /**
  2619. * Selection marker,
  2620. menu hover,
  2621. button hover,
  2622. chart border,
  2623. navigator series.
  2624. */
  2625. highlightColor80: '#335cad',
  2626. /**
  2627. * Navigator mask fill.
  2628. */
  2629. highlightColor60: '#6685c2',
  2630. /**
  2631. * Ticks and axis line.
  2632. */
  2633. highlightColor20: '#ccd6eb',
  2634. /**
  2635. * Pressed button,
  2636. color axis min color.
  2637. */
  2638. highlightColor10: '#e6ebf5',
  2639. /**
  2640. * Positive indicator color
  2641. */
  2642. positiveColor: '#06b535',
  2643. /**
  2644. * Negative indicator color
  2645. */
  2646. negativeColor: '#f21313'
  2647. };
  2648. return palette;
  2649. });
  2650. _registerModule(_modules, 'Core/Time.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  2651. /* *
  2652. *
  2653. * (c) 2010-2021 Torstein Honsi
  2654. *
  2655. * License: www.highcharts.com/license
  2656. *
  2657. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  2658. *
  2659. * */
  2660. var win = H.win;
  2661. var defined = U.defined,
  2662. error = U.error,
  2663. extend = U.extend,
  2664. isObject = U.isObject,
  2665. merge = U.merge,
  2666. objectEach = U.objectEach,
  2667. pad = U.pad,
  2668. pick = U.pick,
  2669. splat = U.splat,
  2670. timeUnits = U.timeUnits;
  2671. /**
  2672. * Normalized interval.
  2673. *
  2674. * @interface Highcharts.TimeNormalizedObject
  2675. */ /**
  2676. * The count.
  2677. *
  2678. * @name Highcharts.TimeNormalizedObject#count
  2679. * @type {number}
  2680. */ /**
  2681. * The interval in axis values (ms).
  2682. *
  2683. * @name Highcharts.TimeNormalizedObject#unitRange
  2684. * @type {number}
  2685. */
  2686. /**
  2687. * Function of an additional date format specifier.
  2688. *
  2689. * @callback Highcharts.TimeFormatCallbackFunction
  2690. *
  2691. * @param {number} timestamp
  2692. * The time to format.
  2693. *
  2694. * @return {string}
  2695. * The formatted portion of the date.
  2696. */
  2697. /**
  2698. * Time ticks.
  2699. *
  2700. * @interface Highcharts.AxisTickPositionsArray
  2701. * @extends global.Array<number>
  2702. */ /**
  2703. * @name Highcharts.AxisTickPositionsArray#info
  2704. * @type {Highcharts.TimeTicksInfoObject|undefined}
  2705. */
  2706. /**
  2707. * A callback to return the time zone offset for a given datetime. It
  2708. * takes the timestamp in terms of milliseconds since January 1 1970,
  2709. * and returns the timezone offset in minutes. This provides a hook
  2710. * for drawing time based charts in specific time zones using their
  2711. * local DST crossover dates, with the help of external libraries.
  2712. *
  2713. * @callback Highcharts.TimezoneOffsetCallbackFunction
  2714. *
  2715. * @param {number} timestamp
  2716. * Timestamp in terms of milliseconds since January 1 1970.
  2717. *
  2718. * @return {number}
  2719. * Timezone offset in minutes.
  2720. */
  2721. /**
  2722. * Allows to manually load the `moment.js` library from Highcharts options
  2723. * instead of the `window`.
  2724. * In case of loading the library from a `script` tag,
  2725. * this option is not needed, it will be loaded from there by default.
  2726. *
  2727. * @type {function}
  2728. * @since 8.2.0
  2729. * @apioption time.moment
  2730. */
  2731. ''; // detach doclets above
  2732. /* eslint-disable no-invalid-this, valid-jsdoc */
  2733. /**
  2734. * The Time class. Time settings are applied in general for each page using
  2735. * `Highcharts.setOptions`, or individually for each Chart item through the
  2736. * [time](https://api.highcharts.com/highcharts/time) options set.
  2737. *
  2738. * The Time object is available from {@link Highcharts.Chart#time},
  2739. * which refers to `Highcharts.time` if no individual time settings are
  2740. * applied.
  2741. *
  2742. * @example
  2743. * // Apply time settings globally
  2744. * Highcharts.setOptions({
  2745. * time: {
  2746. * timezone: 'Europe/London'
  2747. * }
  2748. * });
  2749. *
  2750. * // Apply time settings by instance
  2751. * let chart = Highcharts.chart('container', {
  2752. * time: {
  2753. * timezone: 'America/New_York'
  2754. * },
  2755. * series: [{
  2756. * data: [1, 4, 3, 5]
  2757. * }]
  2758. * });
  2759. *
  2760. * // Use the Time object
  2761. * console.log(
  2762. * 'Current time in New York',
  2763. * chart.time.dateFormat('%Y-%m-%d %H:%M:%S', Date.now())
  2764. * );
  2765. *
  2766. * @since 6.0.5
  2767. *
  2768. * @class
  2769. * @name Highcharts.Time
  2770. *
  2771. * @param {Highcharts.TimeOptions} options
  2772. * Time options as defined in [chart.options.time](/highcharts/time).
  2773. */
  2774. var Time = /** @class */ (function () {
  2775. /* *
  2776. *
  2777. * Constructors
  2778. *
  2779. * */
  2780. function Time(options) {
  2781. /* *
  2782. *
  2783. * Properties
  2784. *
  2785. * */
  2786. this.options = {};
  2787. this.useUTC = false;
  2788. this.variableTimezone = false;
  2789. this.Date = win.Date;
  2790. /**
  2791. * Get the time zone offset based on the current timezone information as
  2792. * set in the global options.
  2793. *
  2794. * @function Highcharts.Time#getTimezoneOffset
  2795. *
  2796. * @param {number} timestamp
  2797. * The JavaScript timestamp to inspect.
  2798. *
  2799. * @return {number}
  2800. * The timezone offset in minutes compared to UTC.
  2801. */
  2802. this.getTimezoneOffset = this.timezoneOffsetFunction();
  2803. this.update(options);
  2804. }
  2805. /* *
  2806. *
  2807. * Functions
  2808. *
  2809. * */
  2810. /**
  2811. * Time units used in `Time.get` and `Time.set`
  2812. *
  2813. * @typedef {"Date"|"Day"|"FullYear"|"Hours"|"Milliseconds"|"Minutes"|"Month"|"Seconds"} Highcharts.TimeUnitValue
  2814. */
  2815. /**
  2816. * Get the value of a date object in given units, and subject to the Time
  2817. * object's current timezone settings. This function corresponds directly to
  2818. * JavaScripts `Date.getXXX / Date.getUTCXXX`, so instead of calling
  2819. * `date.getHours()` or `date.getUTCHours()` we will call
  2820. * `time.get('Hours')`.
  2821. *
  2822. * @function Highcharts.Time#get
  2823. *
  2824. * @param {Highcharts.TimeUnitValue} unit
  2825. * @param {Date} date
  2826. *
  2827. * @return {number}
  2828. * The given time unit
  2829. */
  2830. Time.prototype.get = function (unit, date) {
  2831. if (this.variableTimezone || this.timezoneOffset) {
  2832. var realMs = date.getTime();
  2833. var ms = realMs - this.getTimezoneOffset(date);
  2834. date.setTime(ms); // Temporary adjust to timezone
  2835. var ret = date['getUTC' + unit]();
  2836. date.setTime(realMs); // Reset
  2837. return ret;
  2838. }
  2839. // UTC time with no timezone handling
  2840. if (this.useUTC) {
  2841. return date['getUTC' + unit]();
  2842. }
  2843. // Else, local time
  2844. return date['get' + unit]();
  2845. };
  2846. /**
  2847. * Set the value of a date object in given units, and subject to the Time
  2848. * object's current timezone settings. This function corresponds directly to
  2849. * JavaScripts `Date.setXXX / Date.setUTCXXX`, so instead of calling
  2850. * `date.setHours(0)` or `date.setUTCHours(0)` we will call
  2851. * `time.set('Hours', 0)`.
  2852. *
  2853. * @function Highcharts.Time#set
  2854. *
  2855. * @param {Highcharts.TimeUnitValue} unit
  2856. * @param {Date} date
  2857. * @param {number} value
  2858. *
  2859. * @return {number}
  2860. * The epoch milliseconds of the updated date
  2861. */
  2862. Time.prototype.set = function (unit, date, value) {
  2863. // UTC time with timezone handling
  2864. if (this.variableTimezone || this.timezoneOffset) {
  2865. // For lower order time units, just set it directly using UTC
  2866. // time
  2867. if (unit === 'Milliseconds' ||
  2868. unit === 'Seconds' ||
  2869. (unit === 'Minutes' && this.getTimezoneOffset(date) % 3600000 === 0) // #13961
  2870. ) {
  2871. return date['setUTC' + unit](value);
  2872. }
  2873. // Higher order time units need to take the time zone into
  2874. // account
  2875. // Adjust by timezone
  2876. var offset = this.getTimezoneOffset(date);
  2877. var ms = date.getTime() - offset;
  2878. date.setTime(ms);
  2879. date['setUTC' + unit](value);
  2880. var newOffset = this.getTimezoneOffset(date);
  2881. ms = date.getTime() + newOffset;
  2882. return date.setTime(ms);
  2883. }
  2884. // UTC time with no timezone handling
  2885. if (this.useUTC) {
  2886. return date['setUTC' + unit](value);
  2887. }
  2888. // Else, local time
  2889. return date['set' + unit](value);
  2890. };
  2891. /**
  2892. * Update the Time object with current options. It is called internally on
  2893. * initializing Highcharts, after running `Highcharts.setOptions` and on
  2894. * `Chart.update`.
  2895. *
  2896. * @private
  2897. * @function Highcharts.Time#update
  2898. *
  2899. * @param {Highcharts.TimeOptions} options
  2900. *
  2901. * @return {void}
  2902. */
  2903. Time.prototype.update = function (options) {
  2904. var useUTC = pick(options && options.useUTC,
  2905. true),
  2906. time = this;
  2907. this.options = options = merge(true, this.options || {}, options);
  2908. // Allow using a different Date class
  2909. this.Date = options.Date || win.Date || Date;
  2910. this.useUTC = useUTC;
  2911. this.timezoneOffset = (useUTC && options.timezoneOffset);
  2912. this.getTimezoneOffset = this.timezoneOffsetFunction();
  2913. /*
  2914. * The time object has options allowing for variable time zones, meaning
  2915. * the axis ticks or series data needs to consider this.
  2916. */
  2917. this.variableTimezone = useUTC && !!(options.getTimezoneOffset ||
  2918. options.timezone);
  2919. };
  2920. /**
  2921. * Make a time and returns milliseconds. Interprets the inputs as UTC time,
  2922. * local time or a specific timezone time depending on the current time
  2923. * settings.
  2924. *
  2925. * @function Highcharts.Time#makeTime
  2926. *
  2927. * @param {number} year
  2928. * The year
  2929. *
  2930. * @param {number} month
  2931. * The month. Zero-based, so January is 0.
  2932. *
  2933. * @param {number} [date=1]
  2934. * The day of the month
  2935. *
  2936. * @param {number} [hours=0]
  2937. * The hour of the day, 0-23.
  2938. *
  2939. * @param {number} [minutes=0]
  2940. * The minutes
  2941. *
  2942. * @param {number} [seconds=0]
  2943. * The seconds
  2944. *
  2945. * @return {number}
  2946. * The time in milliseconds since January 1st 1970.
  2947. */
  2948. Time.prototype.makeTime = function (year, month, date, hours, minutes, seconds) {
  2949. var d,
  2950. offset,
  2951. newOffset;
  2952. if (this.useUTC) {
  2953. d = this.Date.UTC.apply(0, arguments);
  2954. offset = this.getTimezoneOffset(d);
  2955. d += offset;
  2956. newOffset = this.getTimezoneOffset(d);
  2957. if (offset !== newOffset) {
  2958. d += newOffset - offset;
  2959. // A special case for transitioning from summer time to winter time.
  2960. // When the clock is set back, the same time is repeated twice, i.e.
  2961. // 02:30 am is repeated since the clock is set back from 3 am to
  2962. // 2 am. We need to make the same time as local Date does.
  2963. }
  2964. else if (offset - 36e5 === this.getTimezoneOffset(d - 36e5) &&
  2965. !H.isSafari) {
  2966. d -= 36e5;
  2967. }
  2968. }
  2969. else {
  2970. d = new this.Date(year, month, pick(date, 1), pick(hours, 0), pick(minutes, 0), pick(seconds, 0)).getTime();
  2971. }
  2972. return d;
  2973. };
  2974. /**
  2975. * Sets the getTimezoneOffset function. If the `timezone` option is set, a
  2976. * default getTimezoneOffset function with that timezone is returned. If
  2977. * a `getTimezoneOffset` option is defined, it is returned. If neither are
  2978. * specified, the function using the `timezoneOffset` option or 0 offset is
  2979. * returned.
  2980. *
  2981. * @private
  2982. * @function Highcharts.Time#timezoneOffsetFunction
  2983. *
  2984. * @return {Function}
  2985. * A getTimezoneOffset function
  2986. */
  2987. Time.prototype.timezoneOffsetFunction = function () {
  2988. var time = this,
  2989. options = this.options,
  2990. moment = options.moment || win.moment;
  2991. if (!this.useUTC) {
  2992. return function (timestamp) {
  2993. return new Date(timestamp.toString()).getTimezoneOffset() * 60000;
  2994. };
  2995. }
  2996. if (options.timezone) {
  2997. if (!moment) {
  2998. // getTimezoneOffset-function stays undefined because it depends
  2999. // on Moment.js
  3000. error(25);
  3001. }
  3002. else {
  3003. return function (timestamp) {
  3004. return -moment.tz(timestamp, options.timezone).utcOffset() * 60000;
  3005. };
  3006. }
  3007. }
  3008. // If not timezone is set, look for the getTimezoneOffset callback
  3009. if (this.useUTC && options.getTimezoneOffset) {
  3010. return function (timestamp) {
  3011. return options.getTimezoneOffset(timestamp.valueOf()) * 60000;
  3012. };
  3013. }
  3014. // Last, use the `timezoneOffset` option if set
  3015. return function () {
  3016. return (time.timezoneOffset || 0) * 60000;
  3017. };
  3018. };
  3019. /**
  3020. * Formats a JavaScript date timestamp (milliseconds since Jan 1st 1970)
  3021. * into a human readable date string. The available format keys are listed
  3022. * below. Additional formats can be given in the
  3023. * {@link Highcharts.dateFormats} hook.
  3024. *
  3025. * Supported format keys:
  3026. * - `%a`: Short weekday, like 'Mon'
  3027. * - `%A`: Long weekday, like 'Monday'
  3028. * - `%d`: Two digit day of the month, 01 to 31
  3029. * - `%e`: Day of the month, 1 through 31
  3030. * - `%w`: Day of the week, 0 through 6
  3031. * - `%b`: Short month, like 'Jan'
  3032. * - `%B`: Long month, like 'January'
  3033. * - `%m`: Two digit month number, 01 through 12
  3034. * - `%y`: Two digits year, like 09 for 2009
  3035. * - `%Y`: Four digits year, like 2009
  3036. * - `%H`: Two digits hours in 24h format, 00 through 23
  3037. * - `%k`: Hours in 24h format, 0 through 23
  3038. * - `%I`: Two digits hours in 12h format, 00 through 11
  3039. * - `%l`: Hours in 12h format, 1 through 12
  3040. * - `%M`: Two digits minutes, 00 through 59
  3041. * - `%p`: Upper case AM or PM
  3042. * - `%P`: Lower case AM or PM
  3043. * - `%S`: Two digits seconds, 00 through 59
  3044. * - `%L`: Milliseconds (naming from Ruby)
  3045. *
  3046. * @example
  3047. * const time = new Highcharts.Time();
  3048. * const s = time.dateFormat('%Y-%m-%d %H:%M:%S', Date.UTC(2020, 0, 1));
  3049. * console.log(s); // => 2020-01-01 00:00:00
  3050. *
  3051. * @function Highcharts.Time#dateFormat
  3052. *
  3053. * @param {string} format
  3054. * The desired format where various time representations are
  3055. * prefixed with %.
  3056. *
  3057. * @param {number} [timestamp]
  3058. * The JavaScript timestamp.
  3059. *
  3060. * @param {boolean} [capitalize=false]
  3061. * Upper case first letter in the return.
  3062. *
  3063. * @return {string}
  3064. * The formatted date.
  3065. */
  3066. Time.prototype.dateFormat = function (format, timestamp, capitalize) {
  3067. if (!defined(timestamp) || isNaN(timestamp)) {
  3068. return (H.defaultOptions.lang &&
  3069. H.defaultOptions.lang.invalidDate ||
  3070. '');
  3071. }
  3072. format = pick(format, '%Y-%m-%d %H:%M:%S');
  3073. var time = this, date = new this.Date(timestamp),
  3074. // get the basic time values
  3075. hours = this.get('Hours', date), day = this.get('Day', date), dayOfMonth = this.get('Date', date), month = this.get('Month', date), fullYear = this.get('FullYear', date), lang = H.defaultOptions.lang, langWeekdays = (lang && lang.weekdays), shortWeekdays = (lang && lang.shortWeekdays),
  3076. // List all format keys. Custom formats can be added from the
  3077. // outside.
  3078. replacements = extend({
  3079. // Day
  3080. // Short weekday, like 'Mon'
  3081. a: shortWeekdays ?
  3082. shortWeekdays[day] :
  3083. langWeekdays[day].substr(0, 3),
  3084. // Long weekday, like 'Monday'
  3085. A: langWeekdays[day],
  3086. // Two digit day of the month, 01 to 31
  3087. d: pad(dayOfMonth),
  3088. // Day of the month, 1 through 31
  3089. e: pad(dayOfMonth, 2, ' '),
  3090. // Day of the week, 0 through 6
  3091. w: day,
  3092. // Week (none implemented)
  3093. // 'W': weekNumber(),
  3094. // Month
  3095. // Short month, like 'Jan'
  3096. b: lang.shortMonths[month],
  3097. // Long month, like 'January'
  3098. B: lang.months[month],
  3099. // Two digit month number, 01 through 12
  3100. m: pad(month + 1),
  3101. // Month number, 1 through 12 (#8150)
  3102. o: month + 1,
  3103. // Year
  3104. // Two digits year, like 09 for 2009
  3105. y: fullYear.toString().substr(2, 2),
  3106. // Four digits year, like 2009
  3107. Y: fullYear,
  3108. // Time
  3109. // Two digits hours in 24h format, 00 through 23
  3110. H: pad(hours),
  3111. // Hours in 24h format, 0 through 23
  3112. k: hours,
  3113. // Two digits hours in 12h format, 00 through 11
  3114. I: pad((hours % 12) || 12),
  3115. // Hours in 12h format, 1 through 12
  3116. l: (hours % 12) || 12,
  3117. // Two digits minutes, 00 through 59
  3118. M: pad(this.get('Minutes', date)),
  3119. // Upper case AM or PM
  3120. p: hours < 12 ? 'AM' : 'PM',
  3121. // Lower case AM or PM
  3122. P: hours < 12 ? 'am' : 'pm',
  3123. // Two digits seconds, 00 through 59
  3124. S: pad(date.getSeconds()),
  3125. // Milliseconds (naming from Ruby)
  3126. L: pad(Math.floor(timestamp % 1000), 3)
  3127. }, H.dateFormats);
  3128. // Do the replaces
  3129. objectEach(replacements, function (val, key) {
  3130. // Regex would do it in one line, but this is faster
  3131. while (format.indexOf('%' + key) !== -1) {
  3132. format = format.replace('%' + key, typeof val === 'function' ? val.call(time, timestamp) : val);
  3133. }
  3134. });
  3135. // Optionally capitalize the string and return
  3136. return capitalize ?
  3137. (format.substr(0, 1).toUpperCase() +
  3138. format.substr(1)) :
  3139. format;
  3140. };
  3141. /**
  3142. * Resolve legacy formats of dateTimeLabelFormats (strings and arrays) into
  3143. * an object.
  3144. * @private
  3145. * @param {string|Array<T>|Highcharts.Dictionary<T>} f - General format description
  3146. * @return {Highcharts.Dictionary<T>} - The object definition
  3147. */
  3148. Time.prototype.resolveDTLFormat = function (f) {
  3149. if (!isObject(f, true)) { // check for string or array
  3150. f = splat(f);
  3151. return {
  3152. main: f[0],
  3153. from: f[1],
  3154. to: f[2]
  3155. };
  3156. }
  3157. return f;
  3158. };
  3159. /**
  3160. * Return an array with time positions distributed on round time values
  3161. * right and right after min and max. Used in datetime axes as well as for
  3162. * grouping data on a datetime axis.
  3163. *
  3164. * @function Highcharts.Time#getTimeTicks
  3165. *
  3166. * @param {Highcharts.TimeNormalizedObject} normalizedInterval
  3167. * The interval in axis values (ms) and the count
  3168. *
  3169. * @param {number} [min]
  3170. * The minimum in axis values
  3171. *
  3172. * @param {number} [max]
  3173. * The maximum in axis values
  3174. *
  3175. * @param {number} [startOfWeek=1]
  3176. *
  3177. * @return {Highcharts.AxisTickPositionsArray}
  3178. */
  3179. Time.prototype.getTimeTicks = function (normalizedInterval, min, max, startOfWeek) {
  3180. var time = this,
  3181. Date = time.Date,
  3182. tickPositions = [],
  3183. i,
  3184. higherRanks = {},
  3185. minYear, // used in months and years as a basis for Date.UTC()
  3186. // When crossing DST, use the max. Resolves #6278.
  3187. minDate = new Date(min),
  3188. interval = normalizedInterval.unitRange,
  3189. count = normalizedInterval.count || 1,
  3190. variableDayLength,
  3191. minDay;
  3192. startOfWeek = pick(startOfWeek, 1);
  3193. if (defined(min)) { // #1300
  3194. time.set('Milliseconds', minDate, interval >= timeUnits.second ?
  3195. 0 : // #3935
  3196. count * Math.floor(time.get('Milliseconds', minDate) / count)); // #3652, #3654
  3197. if (interval >= timeUnits.second) { // second
  3198. time.set('Seconds', minDate, interval >= timeUnits.minute ?
  3199. 0 : // #3935
  3200. count * Math.floor(time.get('Seconds', minDate) / count));
  3201. }
  3202. if (interval >= timeUnits.minute) { // minute
  3203. time.set('Minutes', minDate, interval >= timeUnits.hour ?
  3204. 0 :
  3205. count * Math.floor(time.get('Minutes', minDate) / count));
  3206. }
  3207. if (interval >= timeUnits.hour) { // hour
  3208. time.set('Hours', minDate, interval >= timeUnits.day ?
  3209. 0 :
  3210. count * Math.floor(time.get('Hours', minDate) / count));
  3211. }
  3212. if (interval >= timeUnits.day) { // day
  3213. time.set('Date', minDate, interval >= timeUnits.month ?
  3214. 1 :
  3215. Math.max(1, count * Math.floor(time.get('Date', minDate) / count)));
  3216. }
  3217. if (interval >= timeUnits.month) { // month
  3218. time.set('Month', minDate, interval >= timeUnits.year ? 0 :
  3219. count * Math.floor(time.get('Month', minDate) / count));
  3220. minYear = time.get('FullYear', minDate);
  3221. }
  3222. if (interval >= timeUnits.year) { // year
  3223. minYear -= minYear % count;
  3224. time.set('FullYear', minDate, minYear);
  3225. }
  3226. // week is a special case that runs outside the hierarchy
  3227. if (interval === timeUnits.week) {
  3228. // get start of current week, independent of count
  3229. minDay = time.get('Day', minDate);
  3230. time.set('Date', minDate, (time.get('Date', minDate) -
  3231. minDay + startOfWeek +
  3232. // We don't want to skip days that are before
  3233. // startOfWeek (#7051)
  3234. (minDay < startOfWeek ? -7 : 0)));
  3235. }
  3236. // Get basics for variable time spans
  3237. minYear = time.get('FullYear', minDate);
  3238. var minMonth = time.get('Month', minDate), minDateDate = time.get('Date', minDate), minHours = time.get('Hours', minDate);
  3239. // Redefine min to the floored/rounded minimum time (#7432)
  3240. min = minDate.getTime();
  3241. // Handle local timezone offset
  3242. if ((time.variableTimezone || !time.useUTC) && defined(max)) {
  3243. // Detect whether we need to take the DST crossover into
  3244. // consideration. If we're crossing over DST, the day length may
  3245. // be 23h or 25h and we need to compute the exact clock time for
  3246. // each tick instead of just adding hours. This comes at a cost,
  3247. // so first we find out if it is needed (#4951).
  3248. variableDayLength = (
  3249. // Long range, assume we're crossing over.
  3250. max - min > 4 * timeUnits.month ||
  3251. // Short range, check if min and max are in different time
  3252. // zones.
  3253. time.getTimezoneOffset(min) !==
  3254. time.getTimezoneOffset(max));
  3255. }
  3256. // Iterate and add tick positions at appropriate values
  3257. var t = minDate.getTime();
  3258. i = 1;
  3259. while (t < max) {
  3260. tickPositions.push(t);
  3261. // if the interval is years, use Date.UTC to increase years
  3262. if (interval === timeUnits.year) {
  3263. t = time.makeTime(minYear + i * count, 0);
  3264. // if the interval is months, use Date.UTC to increase months
  3265. }
  3266. else if (interval === timeUnits.month) {
  3267. t = time.makeTime(minYear, minMonth + i * count);
  3268. // if we're using global time, the interval is not fixed as it
  3269. // jumps one hour at the DST crossover
  3270. }
  3271. else if (variableDayLength &&
  3272. (interval === timeUnits.day || interval === timeUnits.week)) {
  3273. t = time.makeTime(minYear, minMonth, minDateDate +
  3274. i * count * (interval === timeUnits.day ? 1 : 7));
  3275. }
  3276. else if (variableDayLength &&
  3277. interval === timeUnits.hour &&
  3278. count > 1) {
  3279. // make sure higher ranks are preserved across DST (#6797,
  3280. // #7621)
  3281. t = time.makeTime(minYear, minMonth, minDateDate, minHours + i * count);
  3282. // else, the interval is fixed and we use simple addition
  3283. }
  3284. else {
  3285. t += interval * count;
  3286. }
  3287. i++;
  3288. }
  3289. // push the last time
  3290. tickPositions.push(t);
  3291. // Handle higher ranks. Mark new days if the time is on midnight
  3292. // (#950, #1649, #1760, #3349). Use a reasonable dropout threshold
  3293. // to prevent looping over dense data grouping (#6156).
  3294. if (interval <= timeUnits.hour && tickPositions.length < 10000) {
  3295. tickPositions.forEach(function (t) {
  3296. if (
  3297. // Speed optimization, no need to run dateFormat unless
  3298. // we're on a full or half hour
  3299. t % 1800000 === 0 &&
  3300. // Check for local or global midnight
  3301. time.dateFormat('%H%M%S%L', t) === '000000000') {
  3302. higherRanks[t] = 'day';
  3303. }
  3304. });
  3305. }
  3306. }
  3307. // record information on the chosen unit - for dynamic label formatter
  3308. tickPositions.info = extend(normalizedInterval, {
  3309. higherRanks: higherRanks,
  3310. totalRange: interval * count
  3311. });
  3312. return tickPositions;
  3313. };
  3314. return Time;
  3315. }());
  3316. H.Time = Time;
  3317. return H.Time;
  3318. });
  3319. _registerModule(_modules, 'Core/Options.js', [_modules['Core/Globals.js'], _modules['Core/Color/Color.js'], _modules['Core/Color/Palette.js'], _modules['Core/Time.js'], _modules['Core/Utilities.js']], function (H, Color, palette, Time, U) {
  3320. /* *
  3321. *
  3322. * (c) 2010-2021 Torstein Honsi
  3323. *
  3324. * License: www.highcharts.com/license
  3325. *
  3326. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  3327. *
  3328. * */
  3329. var isTouchDevice = H.isTouchDevice,
  3330. svg = H.svg;
  3331. var color = Color.parse;
  3332. var getNestedProperty = U.getNestedProperty,
  3333. isNumber = U.isNumber,
  3334. merge = U.merge,
  3335. pick = U.pick,
  3336. pInt = U.pInt;
  3337. /* *
  3338. *
  3339. * API Declarations
  3340. *
  3341. * */
  3342. /**
  3343. * @typedef {"plotBox"|"spacingBox"} Highcharts.ButtonRelativeToValue
  3344. */
  3345. /**
  3346. * Gets fired when a series is added to the chart after load time, using the
  3347. * `addSeries` method. Returning `false` prevents the series from being added.
  3348. *
  3349. * @callback Highcharts.ChartAddSeriesCallbackFunction
  3350. *
  3351. * @param {Highcharts.Chart} this
  3352. * The chart on which the event occured.
  3353. *
  3354. * @param {Highcharts.ChartAddSeriesEventObject} event
  3355. * The event that occured.
  3356. */
  3357. /**
  3358. * Contains common event information. Through the `options` property you can
  3359. * access the series options that were passed to the `addSeries` method.
  3360. *
  3361. * @interface Highcharts.ChartAddSeriesEventObject
  3362. */ /**
  3363. * The series options that were passed to the `addSeries` method.
  3364. * @name Highcharts.ChartAddSeriesEventObject#options
  3365. * @type {Highcharts.SeriesOptionsType}
  3366. */ /**
  3367. * Prevents the default behaviour of the event.
  3368. * @name Highcharts.ChartAddSeriesEventObject#preventDefault
  3369. * @type {Function}
  3370. */ /**
  3371. * The event target.
  3372. * @name Highcharts.ChartAddSeriesEventObject#target
  3373. * @type {Highcharts.Chart}
  3374. */ /**
  3375. * The event type.
  3376. * @name Highcharts.ChartAddSeriesEventObject#type
  3377. * @type {"addSeries"}
  3378. */
  3379. /**
  3380. * Gets fired when clicking on the plot background.
  3381. *
  3382. * @callback Highcharts.ChartClickCallbackFunction
  3383. *
  3384. * @param {Highcharts.Chart} this
  3385. * The chart on which the event occured.
  3386. *
  3387. * @param {Highcharts.PointerEventObject} event
  3388. * The event that occured.
  3389. */
  3390. /**
  3391. * Contains an axes of the clicked spot.
  3392. *
  3393. * @interface Highcharts.ChartClickEventAxisObject
  3394. */ /**
  3395. * Axis at the clicked spot.
  3396. * @name Highcharts.ChartClickEventAxisObject#axis
  3397. * @type {Highcharts.Axis}
  3398. */ /**
  3399. * Axis value at the clicked spot.
  3400. * @name Highcharts.ChartClickEventAxisObject#value
  3401. * @type {number}
  3402. */
  3403. /**
  3404. * Contains information about the clicked spot on the chart. Remember the unit
  3405. * of a datetime axis is milliseconds since 1970-01-01 00:00:00.
  3406. *
  3407. * @interface Highcharts.ChartClickEventObject
  3408. * @extends Highcharts.PointerEventObject
  3409. */ /**
  3410. * Information about the x-axis on the clicked spot.
  3411. * @name Highcharts.ChartClickEventObject#xAxis
  3412. * @type {Array<Highcharts.ChartClickEventAxisObject>}
  3413. */ /**
  3414. * Information about the y-axis on the clicked spot.
  3415. * @name Highcharts.ChartClickEventObject#yAxis
  3416. * @type {Array<Highcharts.ChartClickEventAxisObject>}
  3417. */ /**
  3418. * Information about the z-axis on the clicked spot.
  3419. * @name Highcharts.ChartClickEventObject#zAxis
  3420. * @type {Array<Highcharts.ChartClickEventAxisObject>|undefined}
  3421. */
  3422. /**
  3423. * Gets fired when the chart is finished loading.
  3424. *
  3425. * @callback Highcharts.ChartLoadCallbackFunction
  3426. *
  3427. * @param {Highcharts.Chart} this
  3428. * The chart on which the event occured.
  3429. *
  3430. * @param {global.Event} event
  3431. * The event that occured.
  3432. */
  3433. /**
  3434. * Fires when the chart is redrawn, either after a call to `chart.redraw()` or
  3435. * after an axis, series or point is modified with the `redraw` option set to
  3436. * `true`.
  3437. *
  3438. * @callback Highcharts.ChartRedrawCallbackFunction
  3439. *
  3440. * @param {Highcharts.Chart} this
  3441. * The chart on which the event occured.
  3442. *
  3443. * @param {global.Event} event
  3444. * The event that occured.
  3445. */
  3446. /**
  3447. * Gets fired after initial load of the chart (directly after the `load` event),
  3448. * and after each redraw (directly after the `redraw` event).
  3449. *
  3450. * @callback Highcharts.ChartRenderCallbackFunction
  3451. *
  3452. * @param {Highcharts.Chart} this
  3453. * The chart on which the event occured.
  3454. *
  3455. * @param {global.Event} event
  3456. * The event that occured.
  3457. */
  3458. /**
  3459. * Gets fired when an area of the chart has been selected. The default action
  3460. * for the selection event is to zoom the chart to the selected area. It can be
  3461. * prevented by calling `event.preventDefault()` or return false.
  3462. *
  3463. * @callback Highcharts.ChartSelectionCallbackFunction
  3464. *
  3465. * @param {Highcharts.Chart} this
  3466. * The chart on which the event occured.
  3467. *
  3468. * @param {global.ChartSelectionContextObject} event
  3469. * Event informations
  3470. *
  3471. * @return {boolean|undefined}
  3472. * Return false to prevent the default action, usually zoom.
  3473. */
  3474. /**
  3475. * The primary axes are `xAxis[0]` and `yAxis[0]`. Remember the unit of a
  3476. * datetime axis is milliseconds since 1970-01-01 00:00:00.
  3477. *
  3478. * @interface Highcharts.ChartSelectionContextObject
  3479. * @extends global.Event
  3480. */ /**
  3481. * Arrays containing the axes of each dimension and each axis' min and max
  3482. * values.
  3483. * @name Highcharts.ChartSelectionContextObject#xAxis
  3484. * @type {Array<Highcharts.ChartSelectionAxisContextObject>}
  3485. */ /**
  3486. * Arrays containing the axes of each dimension and each axis' min and max
  3487. * values.
  3488. * @name Highcharts.ChartSelectionContextObject#yAxis
  3489. * @type {Array<Highcharts.ChartSelectionAxisContextObject>}
  3490. */
  3491. /**
  3492. * Axis context of the selection.
  3493. *
  3494. * @interface Highcharts.ChartSelectionAxisContextObject
  3495. */ /**
  3496. * The selected Axis.
  3497. * @name Highcharts.ChartSelectionAxisContextObject#axis
  3498. * @type {Highcharts.Axis}
  3499. */ /**
  3500. * The maximum axis value, either automatic or set manually.
  3501. * @name Highcharts.ChartSelectionAxisContextObject#max
  3502. * @type {number}
  3503. */ /**
  3504. * The minimum axis value, either automatic or set manually.
  3505. * @name Highcharts.ChartSelectionAxisContextObject#min
  3506. * @type {number}
  3507. */
  3508. (''); // detach doclets above
  3509. /* *
  3510. *
  3511. * API Options
  3512. *
  3513. * */
  3514. /**
  3515. * Global default settings.
  3516. *
  3517. * @name Highcharts.defaultOptions
  3518. * @type {Highcharts.Options}
  3519. */ /**
  3520. * @optionparent
  3521. */
  3522. var defaultOptions = {
  3523. /**
  3524. * An array containing the default colors for the chart's series. When
  3525. * all colors are used, new colors are pulled from the start again.
  3526. *
  3527. * Default colors can also be set on a series or series.type basis,
  3528. * see [column.colors](#plotOptions.column.colors),
  3529. * [pie.colors](#plotOptions.pie.colors).
  3530. *
  3531. * In styled mode, the colors option doesn't exist. Instead, colors
  3532. * are defined in CSS and applied either through series or point class
  3533. * names, or through the [chart.colorCount](#chart.colorCount) option.
  3534. *
  3535. *
  3536. * ### Legacy
  3537. *
  3538. * In Highcharts 3.x, the default colors were:
  3539. * ```js
  3540. * colors: ['#2f7ed8', '#0d233a', '#8bbc21', '#910000', '#1aadce',
  3541. * '#492970', '#f28f43', '#77a1e5', '#c42525', '#a6c96a']
  3542. * ```
  3543. *
  3544. * In Highcharts 2.x, the default colors were:
  3545. * ```js
  3546. * colors: ['#4572A7', '#AA4643', '#89A54E', '#80699B', '#3D96AE',
  3547. * '#DB843D', '#92A8CD', '#A47D7C', '#B5CA92']
  3548. * ```
  3549. *
  3550. * @sample {highcharts} highcharts/chart/colors/
  3551. * Assign a global color theme
  3552. *
  3553. * @type {Array<Highcharts.ColorString>}
  3554. * @default ["#7cb5ec", "#434348", "#90ed7d", "#f7a35c", "#8085e9",
  3555. * "#f15c80", "#e4d354", "#2b908f", "#f45b5b", "#91e8e1"]
  3556. */
  3557. colors: palette.colors,
  3558. /**
  3559. * Styled mode only. Configuration object for adding SVG definitions for
  3560. * reusable elements. See [gradients, shadows and
  3561. * patterns](https://www.highcharts.com/docs/chart-design-and-style/gradients-shadows-and-patterns)
  3562. * for more information and code examples.
  3563. *
  3564. * @type {*}
  3565. * @since 5.0.0
  3566. * @apioption defs
  3567. */
  3568. /**
  3569. * @ignore-option
  3570. */
  3571. symbols: ['circle', 'diamond', 'square', 'triangle', 'triangle-down'],
  3572. /**
  3573. * The language object is global and it can't be set on each chart
  3574. * initialization. Instead, use `Highcharts.setOptions` to set it before any
  3575. * chart is initialized.
  3576. *
  3577. * ```js
  3578. * Highcharts.setOptions({
  3579. * lang: {
  3580. * months: [
  3581. * 'Janvier', 'Février', 'Mars', 'Avril',
  3582. * 'Mai', 'Juin', 'Juillet', 'Août',
  3583. * 'Septembre', 'Octobre', 'Novembre', 'Décembre'
  3584. * ],
  3585. * weekdays: [
  3586. * 'Dimanche', 'Lundi', 'Mardi', 'Mercredi',
  3587. * 'Jeudi', 'Vendredi', 'Samedi'
  3588. * ]
  3589. * }
  3590. * });
  3591. * ```
  3592. */
  3593. lang: {
  3594. /**
  3595. * The loading text that appears when the chart is set into the loading
  3596. * state following a call to `chart.showLoading`.
  3597. */
  3598. loading: 'Loading...',
  3599. /**
  3600. * An array containing the months names. Corresponds to the `%B` format
  3601. * in `Highcharts.dateFormat()`.
  3602. *
  3603. * @type {Array<string>}
  3604. * @default ["January", "February", "March", "April", "May", "June",
  3605. * "July", "August", "September", "October", "November",
  3606. * "December"]
  3607. */
  3608. months: [
  3609. 'January', 'February', 'March', 'April', 'May', 'June', 'July',
  3610. 'August', 'September', 'October', 'November', 'December'
  3611. ],
  3612. /**
  3613. * An array containing the months names in abbreviated form. Corresponds
  3614. * to the `%b` format in `Highcharts.dateFormat()`.
  3615. *
  3616. * @type {Array<string>}
  3617. * @default ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
  3618. * "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
  3619. */
  3620. shortMonths: [
  3621. 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul',
  3622. 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
  3623. ],
  3624. /**
  3625. * An array containing the weekday names.
  3626. *
  3627. * @type {Array<string>}
  3628. * @default ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
  3629. * "Friday", "Saturday"]
  3630. */
  3631. weekdays: [
  3632. 'Sunday', 'Monday', 'Tuesday', 'Wednesday',
  3633. 'Thursday', 'Friday', 'Saturday'
  3634. ],
  3635. /**
  3636. * Short week days, starting Sunday. If not specified, Highcharts uses
  3637. * the first three letters of the `lang.weekdays` option.
  3638. *
  3639. * @sample highcharts/lang/shortweekdays/
  3640. * Finnish two-letter abbreviations
  3641. *
  3642. * @type {Array<string>}
  3643. * @since 4.2.4
  3644. * @apioption lang.shortWeekdays
  3645. */
  3646. /**
  3647. * What to show in a date field for invalid dates. Defaults to an empty
  3648. * string.
  3649. *
  3650. * @type {string}
  3651. * @since 4.1.8
  3652. * @product highcharts highstock
  3653. * @apioption lang.invalidDate
  3654. */
  3655. /**
  3656. * The title appearing on hovering the zoom in button. The text itself
  3657. * defaults to "+" and can be changed in the button options.
  3658. *
  3659. * @type {string}
  3660. * @default Zoom in
  3661. * @product highmaps
  3662. * @apioption lang.zoomIn
  3663. */
  3664. /**
  3665. * The title appearing on hovering the zoom out button. The text itself
  3666. * defaults to "-" and can be changed in the button options.
  3667. *
  3668. * @type {string}
  3669. * @default Zoom out
  3670. * @product highmaps
  3671. * @apioption lang.zoomOut
  3672. */
  3673. /**
  3674. * The default decimal point used in the `Highcharts.numberFormat`
  3675. * method unless otherwise specified in the function arguments.
  3676. *
  3677. * @since 1.2.2
  3678. */
  3679. decimalPoint: '.',
  3680. /**
  3681. * [Metric prefixes](https://en.wikipedia.org/wiki/Metric_prefix) used
  3682. * to shorten high numbers in axis labels. Replacing any of the
  3683. * positions with `null` causes the full number to be written. Setting
  3684. * `numericSymbols` to `null` disables shortening altogether.
  3685. *
  3686. * @sample {highcharts} highcharts/lang/numericsymbols/
  3687. * Replacing the symbols with text
  3688. * @sample {highstock} highcharts/lang/numericsymbols/
  3689. * Replacing the symbols with text
  3690. *
  3691. * @type {Array<string>}
  3692. * @default ["k", "M", "G", "T", "P", "E"]
  3693. * @since 2.3.0
  3694. */
  3695. numericSymbols: ['k', 'M', 'G', 'T', 'P', 'E'],
  3696. /**
  3697. * The magnitude of [numericSymbols](#lang.numericSymbol) replacements.
  3698. * Use 10000 for Japanese, Korean and various Chinese locales, which
  3699. * use symbols for 10^4, 10^8 and 10^12.
  3700. *
  3701. * @sample highcharts/lang/numericsymbolmagnitude/
  3702. * 10000 magnitude for Japanese
  3703. *
  3704. * @type {number}
  3705. * @default 1000
  3706. * @since 5.0.3
  3707. * @apioption lang.numericSymbolMagnitude
  3708. */
  3709. /**
  3710. * The text for the label appearing when a chart is zoomed.
  3711. *
  3712. * @since 1.2.4
  3713. */
  3714. resetZoom: 'Reset zoom',
  3715. /**
  3716. * The tooltip title for the label appearing when a chart is zoomed.
  3717. *
  3718. * @since 1.2.4
  3719. */
  3720. resetZoomTitle: 'Reset zoom level 1:1',
  3721. /**
  3722. * The default thousands separator used in the `Highcharts.numberFormat`
  3723. * method unless otherwise specified in the function arguments. Defaults
  3724. * to a single space character, which is recommended in
  3725. * [ISO 31-0](https://en.wikipedia.org/wiki/ISO_31-0#Numbers) and works
  3726. * across Anglo-American and continental European languages.
  3727. *
  3728. * @default \u0020
  3729. * @since 1.2.2
  3730. */
  3731. thousandsSep: ' '
  3732. },
  3733. /**
  3734. * Global options that don't apply to each chart. These options, like
  3735. * the `lang` options, must be set using the `Highcharts.setOptions`
  3736. * method.
  3737. *
  3738. * ```js
  3739. * Highcharts.setOptions({
  3740. * global: {
  3741. * useUTC: false
  3742. * }
  3743. * });
  3744. * ```
  3745. */
  3746. /**
  3747. * _Canvg rendering for Android 2.x is removed as of Highcharts 5.0\.
  3748. * Use the [libURL](#exporting.libURL) option to configure exporting._
  3749. *
  3750. * The URL to the additional file to lazy load for Android 2.x devices.
  3751. * These devices don't support SVG, so we download a helper file that
  3752. * contains [canvg](https://github.com/canvg/canvg), its dependency
  3753. * rbcolor, and our own CanVG Renderer class. To avoid hotlinking to
  3754. * our site, you can install canvas-tools.js on your own server and
  3755. * change this option accordingly.
  3756. *
  3757. * @deprecated
  3758. *
  3759. * @type {string}
  3760. * @default https://code.highcharts.com/{version}/modules/canvas-tools.js
  3761. * @product highcharts highmaps
  3762. * @apioption global.canvasToolsURL
  3763. */
  3764. /**
  3765. * This option is deprecated since v6.0.5. Instead, use
  3766. * [time.useUTC](#time.useUTC) that supports individual time settings
  3767. * per chart.
  3768. *
  3769. * @deprecated
  3770. *
  3771. * @type {boolean}
  3772. * @apioption global.useUTC
  3773. */
  3774. /**
  3775. * This option is deprecated since v6.0.5. Instead, use
  3776. * [time.Date](#time.Date) that supports individual time settings
  3777. * per chart.
  3778. *
  3779. * @deprecated
  3780. *
  3781. * @type {Function}
  3782. * @product highcharts highstock
  3783. * @apioption global.Date
  3784. */
  3785. /**
  3786. * This option is deprecated since v6.0.5. Instead, use
  3787. * [time.getTimezoneOffset](#time.getTimezoneOffset) that supports
  3788. * individual time settings per chart.
  3789. *
  3790. * @deprecated
  3791. *
  3792. * @type {Function}
  3793. * @product highcharts highstock
  3794. * @apioption global.getTimezoneOffset
  3795. */
  3796. /**
  3797. * This option is deprecated since v6.0.5. Instead, use
  3798. * [time.timezone](#time.timezone) that supports individual time
  3799. * settings per chart.
  3800. *
  3801. * @deprecated
  3802. *
  3803. * @type {string}
  3804. * @product highcharts highstock
  3805. * @apioption global.timezone
  3806. */
  3807. /**
  3808. * This option is deprecated since v6.0.5. Instead, use
  3809. * [time.timezoneOffset](#time.timezoneOffset) that supports individual
  3810. * time settings per chart.
  3811. *
  3812. * @deprecated
  3813. *
  3814. * @type {number}
  3815. * @product highcharts highstock
  3816. * @apioption global.timezoneOffset
  3817. */
  3818. global: {},
  3819. /**
  3820. * Time options that can apply globally or to individual charts. These
  3821. * settings affect how `datetime` axes are laid out, how tooltips are
  3822. * formatted, how series
  3823. * [pointIntervalUnit](#plotOptions.series.pointIntervalUnit) works and how
  3824. * the Highcharts Stock range selector handles time.
  3825. *
  3826. * The common use case is that all charts in the same Highcharts object
  3827. * share the same time settings, in which case the global settings are set
  3828. * using `setOptions`.
  3829. *
  3830. * ```js
  3831. * // Apply time settings globally
  3832. * Highcharts.setOptions({
  3833. * time: {
  3834. * timezone: 'Europe/London'
  3835. * }
  3836. * });
  3837. * // Apply time settings by instance
  3838. * let chart = Highcharts.chart('container', {
  3839. * time: {
  3840. * timezone: 'America/New_York'
  3841. * },
  3842. * series: [{
  3843. * data: [1, 4, 3, 5]
  3844. * }]
  3845. * });
  3846. *
  3847. * // Use the Time object
  3848. * console.log(
  3849. * 'Current time in New York',
  3850. * chart.time.dateFormat('%Y-%m-%d %H:%M:%S', Date.now())
  3851. * );
  3852. * ```
  3853. *
  3854. * Since v6.0.5, the time options were moved from the `global` obect to the
  3855. * `time` object, and time options can be set on each individual chart.
  3856. *
  3857. * @sample {highcharts|highstock}
  3858. * highcharts/time/timezone/
  3859. * Set the timezone globally
  3860. * @sample {highcharts}
  3861. * highcharts/time/individual/
  3862. * Set the timezone per chart instance
  3863. * @sample {highstock}
  3864. * stock/time/individual/
  3865. * Set the timezone per chart instance
  3866. *
  3867. * @since 6.0.5
  3868. * @optionparent time
  3869. */
  3870. time: {
  3871. /**
  3872. * A custom `Date` class for advanced date handling. For example,
  3873. * [JDate](https://github.com/tahajahangir/jdate) can be hooked in to
  3874. * handle Jalali dates.
  3875. *
  3876. * @type {*}
  3877. * @since 4.0.4
  3878. * @product highcharts highstock gantt
  3879. */
  3880. Date: void 0,
  3881. /**
  3882. * A callback to return the time zone offset for a given datetime. It
  3883. * takes the timestamp in terms of milliseconds since January 1 1970,
  3884. * and returns the timezone offset in minutes. This provides a hook
  3885. * for drawing time based charts in specific time zones using their
  3886. * local DST crossover dates, with the help of external libraries.
  3887. *
  3888. * @see [global.timezoneOffset](#global.timezoneOffset)
  3889. *
  3890. * @sample {highcharts|highstock} highcharts/time/gettimezoneoffset/
  3891. * Use moment.js to draw Oslo time regardless of browser locale
  3892. *
  3893. * @type {Highcharts.TimezoneOffsetCallbackFunction}
  3894. * @since 4.1.0
  3895. * @product highcharts highstock gantt
  3896. */
  3897. getTimezoneOffset: void 0,
  3898. /**
  3899. * Requires [moment.js](https://momentjs.com/). If the timezone option
  3900. * is specified, it creates a default
  3901. * [getTimezoneOffset](#time.getTimezoneOffset) function that looks
  3902. * up the specified timezone in moment.js. If moment.js is not included,
  3903. * this throws a Highcharts error in the console, but does not crash the
  3904. * chart.
  3905. *
  3906. * @see [getTimezoneOffset](#time.getTimezoneOffset)
  3907. *
  3908. * @sample {highcharts|highstock} highcharts/time/timezone/
  3909. * Europe/Oslo
  3910. *
  3911. * @type {string}
  3912. * @since 5.0.7
  3913. * @product highcharts highstock gantt
  3914. */
  3915. timezone: void 0,
  3916. /**
  3917. * The timezone offset in minutes. Positive values are west, negative
  3918. * values are east of UTC, as in the ECMAScript
  3919. * [getTimezoneOffset](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset)
  3920. * method. Use this to display UTC based data in a predefined time zone.
  3921. *
  3922. * @see [time.getTimezoneOffset](#time.getTimezoneOffset)
  3923. *
  3924. * @sample {highcharts|highstock} highcharts/time/timezoneoffset/
  3925. * Timezone offset
  3926. *
  3927. * @since 3.0.8
  3928. * @product highcharts highstock gantt
  3929. */
  3930. timezoneOffset: 0,
  3931. /**
  3932. * Whether to use UTC time for axis scaling, tickmark placement and
  3933. * time display in `Highcharts.dateFormat`. Advantages of using UTC
  3934. * is that the time displays equally regardless of the user agent's
  3935. * time zone settings. Local time can be used when the data is loaded
  3936. * in real time or when correct Daylight Saving Time transitions are
  3937. * required.
  3938. *
  3939. * @sample {highcharts} highcharts/time/useutc-true/
  3940. * True by default
  3941. * @sample {highcharts} highcharts/time/useutc-false/
  3942. * False
  3943. */
  3944. useUTC: true
  3945. },
  3946. /**
  3947. * General options for the chart.
  3948. */
  3949. chart: {
  3950. /**
  3951. * Default `mapData` for all series. If set to a string, it functions
  3952. * as an index into the `Highcharts.maps` array. Otherwise it is
  3953. * interpreted as map data.
  3954. *
  3955. * @see [mapData](#series.map.mapData)
  3956. *
  3957. * @sample maps/demo/geojson
  3958. * Loading geoJSON data
  3959. * @sample maps/chart/topojson
  3960. * Loading topoJSON converted to geoJSON
  3961. *
  3962. * @type {string|Array<*>|Highcharts.GeoJSON}
  3963. * @since 5.0.0
  3964. * @product highmaps
  3965. * @apioption chart.map
  3966. */
  3967. /**
  3968. * Set lat/lon transformation definitions for the chart. If not defined,
  3969. * these are extracted from the map data.
  3970. *
  3971. * @type {*}
  3972. * @since 5.0.0
  3973. * @product highmaps
  3974. * @apioption chart.mapTransforms
  3975. */
  3976. /**
  3977. * When using multiple axis, the ticks of two or more opposite axes
  3978. * will automatically be aligned by adding ticks to the axis or axes
  3979. * with the least ticks, as if `tickAmount` were specified.
  3980. *
  3981. * This can be prevented by setting `alignTicks` to false. If the grid
  3982. * lines look messy, it's a good idea to hide them for the secondary
  3983. * axis by setting `gridLineWidth` to 0.
  3984. *
  3985. * If `startOnTick` or `endOnTick` in an Axis options are set to false,
  3986. * then the `alignTicks ` will be disabled for the Axis.
  3987. *
  3988. * Disabled for logarithmic axes.
  3989. *
  3990. * @sample {highcharts} highcharts/chart/alignticks-true/
  3991. * True by default
  3992. * @sample {highcharts} highcharts/chart/alignticks-false/
  3993. * False
  3994. * @sample {highstock} stock/chart/alignticks-true/
  3995. * True by default
  3996. * @sample {highstock} stock/chart/alignticks-false/
  3997. * False
  3998. *
  3999. * @type {boolean}
  4000. * @default true
  4001. * @product highcharts highstock gantt
  4002. * @apioption chart.alignTicks
  4003. */
  4004. /**
  4005. * Set the overall animation for all chart updating. Animation can be
  4006. * disabled throughout the chart by setting it to false here. It can
  4007. * be overridden for each individual API method as a function parameter.
  4008. * The only animation not affected by this option is the initial series
  4009. * animation, see [plotOptions.series.animation](
  4010. * #plotOptions.series.animation).
  4011. *
  4012. * The animation can either be set as a boolean or a configuration
  4013. * object. If `true`, it will use the 'swing' jQuery easing and a
  4014. * duration of 500 ms. If used as a configuration object, the following
  4015. * properties are supported:
  4016. *
  4017. * - `defer`: The animation delay time in milliseconds.
  4018. *
  4019. * - `duration`: The duration of the animation in milliseconds.
  4020. *
  4021. * - `easing`: A string reference to an easing function set on the
  4022. * `Math` object. See
  4023. * [the easing demo](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-animation-easing/).
  4024. *
  4025. * When zooming on a series with less than 100 points, the chart redraw
  4026. * will be done with animation, but in case of more data points, it is
  4027. * necessary to set this option to ensure animation on zoom.
  4028. *
  4029. * @sample {highcharts} highcharts/chart/animation-none/
  4030. * Updating with no animation
  4031. * @sample {highcharts} highcharts/chart/animation-duration/
  4032. * With a longer duration
  4033. * @sample {highcharts} highcharts/chart/animation-easing/
  4034. * With a jQuery UI easing
  4035. * @sample {highmaps} maps/chart/animation-none/
  4036. * Updating with no animation
  4037. * @sample {highmaps} maps/chart/animation-duration/
  4038. * With a longer duration
  4039. *
  4040. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  4041. * @default undefined
  4042. * @apioption chart.animation
  4043. */
  4044. /**
  4045. * A CSS class name to apply to the charts container `div`, allowing
  4046. * unique CSS styling for each chart.
  4047. *
  4048. * @type {string}
  4049. * @apioption chart.className
  4050. */
  4051. /**
  4052. * Event listeners for the chart.
  4053. *
  4054. * @apioption chart.events
  4055. */
  4056. /**
  4057. * Fires when a series is added to the chart after load time, using the
  4058. * `addSeries` method. One parameter, `event`, is passed to the
  4059. * function, containing common event information. Through
  4060. * `event.options` you can access the series options that were passed to
  4061. * the `addSeries` method. Returning false prevents the series from
  4062. * being added.
  4063. *
  4064. * @sample {highcharts} highcharts/chart/events-addseries/
  4065. * Alert on add series
  4066. * @sample {highstock} stock/chart/events-addseries/
  4067. * Alert on add series
  4068. *
  4069. * @type {Highcharts.ChartAddSeriesCallbackFunction}
  4070. * @since 1.2.0
  4071. * @context Highcharts.Chart
  4072. * @apioption chart.events.addSeries
  4073. */
  4074. /**
  4075. * Fires when clicking on the plot background. One parameter, `event`,
  4076. * is passed to the function, containing common event information.
  4077. *
  4078. * Information on the clicked spot can be found through `event.xAxis`
  4079. * and `event.yAxis`, which are arrays containing the axes of each
  4080. * dimension and each axis' value at the clicked spot. The primary axes
  4081. * are `event.xAxis[0]` and `event.yAxis[0]`. Remember the unit of a
  4082. * datetime axis is milliseconds since 1970-01-01 00:00:00.
  4083. *
  4084. * ```js
  4085. * click: function(e) {
  4086. * console.log(
  4087. * Highcharts.dateFormat('%Y-%m-%d %H:%M:%S', e.xAxis[0].value),
  4088. * e.yAxis[0].value
  4089. * )
  4090. * }
  4091. * ```
  4092. *
  4093. * @sample {highcharts} highcharts/chart/events-click/
  4094. * Alert coordinates on click
  4095. * @sample {highcharts} highcharts/chart/events-container/
  4096. * Alternatively, attach event to container
  4097. * @sample {highstock} stock/chart/events-click/
  4098. * Alert coordinates on click
  4099. * @sample {highstock} highcharts/chart/events-container/
  4100. * Alternatively, attach event to container
  4101. * @sample {highmaps} maps/chart/events-click/
  4102. * Record coordinates on click
  4103. * @sample {highmaps} highcharts/chart/events-container/
  4104. * Alternatively, attach event to container
  4105. *
  4106. * @type {Highcharts.ChartClickCallbackFunction}
  4107. * @since 1.2.0
  4108. * @context Highcharts.Chart
  4109. * @apioption chart.events.click
  4110. */
  4111. /**
  4112. * Fires when the chart is finished loading. Since v4.2.2, it also waits
  4113. * for images to be loaded, for example from point markers. One
  4114. * parameter, `event`, is passed to the function, containing common
  4115. * event information.
  4116. *
  4117. * There is also a second parameter to the chart constructor where a
  4118. * callback function can be passed to be executed on chart.load.
  4119. *
  4120. * @sample {highcharts} highcharts/chart/events-load/
  4121. * Alert on chart load
  4122. * @sample {highstock} stock/chart/events-load/
  4123. * Alert on chart load
  4124. * @sample {highmaps} maps/chart/events-load/
  4125. * Add series on chart load
  4126. *
  4127. * @type {Highcharts.ChartLoadCallbackFunction}
  4128. * @context Highcharts.Chart
  4129. * @apioption chart.events.load
  4130. */
  4131. /**
  4132. * Fires when the chart is redrawn, either after a call to
  4133. * `chart.redraw()` or after an axis, series or point is modified with
  4134. * the `redraw` option set to `true`. One parameter, `event`, is passed
  4135. * to the function, containing common event information.
  4136. *
  4137. * @sample {highcharts} highcharts/chart/events-redraw/
  4138. * Alert on chart redraw
  4139. * @sample {highstock} stock/chart/events-redraw/
  4140. * Alert on chart redraw when adding a series or moving the
  4141. * zoomed range
  4142. * @sample {highmaps} maps/chart/events-redraw/
  4143. * Set subtitle on chart redraw
  4144. *
  4145. * @type {Highcharts.ChartRedrawCallbackFunction}
  4146. * @since 1.2.0
  4147. * @context Highcharts.Chart
  4148. * @apioption chart.events.redraw
  4149. */
  4150. /**
  4151. * Fires after initial load of the chart (directly after the `load`
  4152. * event), and after each redraw (directly after the `redraw` event).
  4153. *
  4154. * @type {Highcharts.ChartRenderCallbackFunction}
  4155. * @since 5.0.7
  4156. * @context Highcharts.Chart
  4157. * @apioption chart.events.render
  4158. */
  4159. /**
  4160. * Fires when an area of the chart has been selected. Selection is
  4161. * enabled by setting the chart's zoomType. One parameter, `event`, is
  4162. * passed to the function, containing common event information. The
  4163. * default action for the selection event is to zoom the chart to the
  4164. * selected area. It can be prevented by calling
  4165. * `event.preventDefault()` or return false.
  4166. *
  4167. * Information on the selected area can be found through `event.xAxis`
  4168. * and `event.yAxis`, which are arrays containing the axes of each
  4169. * dimension and each axis' min and max values. The primary axes are
  4170. * `event.xAxis[0]` and `event.yAxis[0]`. Remember the unit of a
  4171. * datetime axis is milliseconds since 1970-01-01 00:00:00.
  4172. *
  4173. * ```js
  4174. * selection: function(event) {
  4175. * // log the min and max of the primary, datetime x-axis
  4176. * console.log(
  4177. * Highcharts.dateFormat(
  4178. * '%Y-%m-%d %H:%M:%S',
  4179. * event.xAxis[0].min
  4180. * ),
  4181. * Highcharts.dateFormat(
  4182. * '%Y-%m-%d %H:%M:%S',
  4183. * event.xAxis[0].max
  4184. * )
  4185. * );
  4186. * // log the min and max of the y axis
  4187. * console.log(event.yAxis[0].min, event.yAxis[0].max);
  4188. * }
  4189. * ```
  4190. *
  4191. * @sample {highcharts} highcharts/chart/events-selection/
  4192. * Report on selection and reset
  4193. * @sample {highcharts} highcharts/chart/events-selection-points/
  4194. * Select a range of points through a drag selection
  4195. * @sample {highstock} stock/chart/events-selection/
  4196. * Report on selection and reset
  4197. * @sample {highstock} highcharts/chart/events-selection-points/
  4198. * Select a range of points through a drag selection
  4199. * (Highcharts)
  4200. *
  4201. * @type {Highcharts.ChartSelectionCallbackFunction}
  4202. * @apioption chart.events.selection
  4203. */
  4204. /**
  4205. * The margin between the outer edge of the chart and the plot area.
  4206. * The numbers in the array designate top, right, bottom and left
  4207. * respectively. Use the options `marginTop`, `marginRight`,
  4208. * `marginBottom` and `marginLeft` for shorthand setting of one option.
  4209. *
  4210. * By default there is no margin. The actual space is dynamically
  4211. * calculated from the offset of axis labels, axis title, title,
  4212. * subtitle and legend in addition to the `spacingTop`, `spacingRight`,
  4213. * `spacingBottom` and `spacingLeft` options.
  4214. *
  4215. * @sample {highcharts} highcharts/chart/margins-zero/
  4216. * Zero margins
  4217. * @sample {highstock} stock/chart/margin-zero/
  4218. * Zero margins
  4219. *
  4220. * @type {number|Array<number>}
  4221. * @apioption chart.margin
  4222. */
  4223. /**
  4224. * The margin between the bottom outer edge of the chart and the plot
  4225. * area. Use this to set a fixed pixel value for the margin as opposed
  4226. * to the default dynamic margin. See also `spacingBottom`.
  4227. *
  4228. * @sample {highcharts} highcharts/chart/marginbottom/
  4229. * 100px bottom margin
  4230. * @sample {highstock} stock/chart/marginbottom/
  4231. * 100px bottom margin
  4232. * @sample {highmaps} maps/chart/margin/
  4233. * 100px margins
  4234. *
  4235. * @type {number}
  4236. * @since 2.0
  4237. * @apioption chart.marginBottom
  4238. */
  4239. /**
  4240. * The margin between the left outer edge of the chart and the plot
  4241. * area. Use this to set a fixed pixel value for the margin as opposed
  4242. * to the default dynamic margin. See also `spacingLeft`.
  4243. *
  4244. * @sample {highcharts} highcharts/chart/marginleft/
  4245. * 150px left margin
  4246. * @sample {highstock} stock/chart/marginleft/
  4247. * 150px left margin
  4248. * @sample {highmaps} maps/chart/margin/
  4249. * 100px margins
  4250. *
  4251. * @type {number}
  4252. * @since 2.0
  4253. * @apioption chart.marginLeft
  4254. */
  4255. /**
  4256. * The margin between the right outer edge of the chart and the plot
  4257. * area. Use this to set a fixed pixel value for the margin as opposed
  4258. * to the default dynamic margin. See also `spacingRight`.
  4259. *
  4260. * @sample {highcharts} highcharts/chart/marginright/
  4261. * 100px right margin
  4262. * @sample {highstock} stock/chart/marginright/
  4263. * 100px right margin
  4264. * @sample {highmaps} maps/chart/margin/
  4265. * 100px margins
  4266. *
  4267. * @type {number}
  4268. * @since 2.0
  4269. * @apioption chart.marginRight
  4270. */
  4271. /**
  4272. * The margin between the top outer edge of the chart and the plot area.
  4273. * Use this to set a fixed pixel value for the margin as opposed to
  4274. * the default dynamic margin. See also `spacingTop`.
  4275. *
  4276. * @sample {highcharts} highcharts/chart/margintop/ 100px top margin
  4277. * @sample {highstock} stock/chart/margintop/
  4278. * 100px top margin
  4279. * @sample {highmaps} maps/chart/margin/
  4280. * 100px margins
  4281. *
  4282. * @type {number}
  4283. * @since 2.0
  4284. * @apioption chart.marginTop
  4285. */
  4286. /**
  4287. * Callback function to override the default function that formats all
  4288. * the numbers in the chart. Returns a string with the formatted number.
  4289. *
  4290. * @sample highcharts/members/highcharts-numberformat
  4291. * Arabic digits in Highcharts
  4292. * @type {Highcharts.NumberFormatterCallbackFunction}
  4293. * @since 8.0.0
  4294. * @apioption chart.numberFormatter
  4295. */
  4296. /**
  4297. * Allows setting a key to switch between zooming and panning. Can be
  4298. * one of `alt`, `ctrl`, `meta` (the command key on Mac and Windows
  4299. * key on Windows) or `shift`. The keys are mapped directly to the key
  4300. * properties of the click event argument (`event.altKey`,
  4301. * `event.ctrlKey`, `event.metaKey` and `event.shiftKey`).
  4302. *
  4303. * @type {string}
  4304. * @since 4.0.3
  4305. * @product highcharts gantt
  4306. * @validvalue ["alt", "ctrl", "meta", "shift"]
  4307. * @apioption chart.panKey
  4308. */
  4309. /**
  4310. * Allow panning in a chart. Best used with [panKey](#chart.panKey)
  4311. * to combine zooming and panning.
  4312. *
  4313. * On touch devices, when the [tooltip.followTouchMove](
  4314. * #tooltip.followTouchMove) option is `true` (default), panning
  4315. * requires two fingers. To allow panning with one finger, set
  4316. * `followTouchMove` to `false`.
  4317. *
  4318. * @sample {highcharts} highcharts/chart/pankey/ Zooming and panning
  4319. * @sample {highstock} stock/chart/panning/ Zooming and xy panning
  4320. */
  4321. panning: {
  4322. /**
  4323. * Enable or disable chart panning.
  4324. *
  4325. * @type {boolean}
  4326. * @default {highcharts} false
  4327. * @default {highstock|highmaps} true
  4328. */
  4329. enabled: false,
  4330. /**
  4331. * Decides in what dimensions the user can pan the chart. Can be
  4332. * one of `x`, `y`, or `xy`.
  4333. *
  4334. * @sample {highcharts} highcharts/chart/panning-type
  4335. * Zooming and xy panning
  4336. *
  4337. * @type {string}
  4338. * @validvalue ["x", "y", "xy"]
  4339. * @default {highcharts|highstock} x
  4340. * @default {highmaps} xy
  4341. */
  4342. type: 'x'
  4343. },
  4344. /**
  4345. * Equivalent to [zoomType](#chart.zoomType), but for multitouch
  4346. * gestures only. By default, the `pinchType` is the same as the
  4347. * `zoomType` setting. However, pinching can be enabled separately in
  4348. * some cases, for example in stock charts where a mouse drag pans the
  4349. * chart, while pinching is enabled. When [tooltip.followTouchMove](
  4350. * #tooltip.followTouchMove) is true, pinchType only applies to
  4351. * two-finger touches.
  4352. *
  4353. * @type {string}
  4354. * @default {highcharts} undefined
  4355. * @default {highstock} x
  4356. * @since 3.0
  4357. * @product highcharts highstock gantt
  4358. * @validvalue ["x", "y", "xy"]
  4359. * @apioption chart.pinchType
  4360. */
  4361. /**
  4362. * Whether to apply styled mode. When in styled mode, no presentational
  4363. * attributes or CSS are applied to the chart SVG. Instead, CSS rules
  4364. * are required to style the chart. The default style sheet is
  4365. * available from `https://code.highcharts.com/css/highcharts.css`.
  4366. *
  4367. * @type {boolean}
  4368. * @default false
  4369. * @since 7.0
  4370. * @apioption chart.styledMode
  4371. */
  4372. styledMode: false,
  4373. /**
  4374. * The corner radius of the outer chart border.
  4375. *
  4376. * @sample {highcharts} highcharts/chart/borderradius/
  4377. * 20px radius
  4378. * @sample {highstock} stock/chart/border/
  4379. * 10px radius
  4380. * @sample {highmaps} maps/chart/border/
  4381. * Border options
  4382. *
  4383. */
  4384. borderRadius: 0,
  4385. /**
  4386. * In styled mode, this sets how many colors the class names
  4387. * should rotate between. With ten colors, series (or points) are
  4388. * given class names like `highcharts-color-0`, `highcharts-color-0`
  4389. * [...] `highcharts-color-9`. The equivalent in non-styled mode
  4390. * is to set colors using the [colors](#colors) setting.
  4391. *
  4392. * @since 5.0.0
  4393. */
  4394. colorCount: 10,
  4395. /**
  4396. * Alias of `type`.
  4397. *
  4398. * @sample {highcharts} highcharts/chart/defaultseriestype/
  4399. * Bar
  4400. *
  4401. * @deprecated
  4402. *
  4403. * @product highcharts
  4404. */
  4405. defaultSeriesType: 'line',
  4406. /**
  4407. * If true, the axes will scale to the remaining visible series once
  4408. * one series is hidden. If false, hiding and showing a series will
  4409. * not affect the axes or the other series. For stacks, once one series
  4410. * within the stack is hidden, the rest of the stack will close in
  4411. * around it even if the axis is not affected.
  4412. *
  4413. * @sample {highcharts} highcharts/chart/ignorehiddenseries-true/
  4414. * True by default
  4415. * @sample {highcharts} highcharts/chart/ignorehiddenseries-false/
  4416. * False
  4417. * @sample {highcharts} highcharts/chart/ignorehiddenseries-true-stacked/
  4418. * True with stack
  4419. * @sample {highstock} stock/chart/ignorehiddenseries-true/
  4420. * True by default
  4421. * @sample {highstock} stock/chart/ignorehiddenseries-false/
  4422. * False
  4423. *
  4424. * @since 1.2.0
  4425. * @product highcharts highstock gantt
  4426. */
  4427. ignoreHiddenSeries: true,
  4428. /**
  4429. * Whether to invert the axes so that the x axis is vertical and y axis
  4430. * is horizontal. When `true`, the x axis is [reversed](#xAxis.reversed)
  4431. * by default.
  4432. *
  4433. * @productdesc {highcharts}
  4434. * If a bar series is present in the chart, it will be inverted
  4435. * automatically. Inverting the chart doesn't have an effect if there
  4436. * are no cartesian series in the chart, or if the chart is
  4437. * [polar](#chart.polar).
  4438. *
  4439. * @sample {highcharts} highcharts/chart/inverted/
  4440. * Inverted line
  4441. * @sample {highstock} stock/navigator/inverted/
  4442. * Inverted stock chart
  4443. *
  4444. * @type {boolean}
  4445. * @default false
  4446. * @product highcharts highstock gantt
  4447. * @apioption chart.inverted
  4448. */
  4449. /**
  4450. * The distance between the outer edge of the chart and the content,
  4451. * like title or legend, or axis title and labels if present. The
  4452. * numbers in the array designate top, right, bottom and left
  4453. * respectively. Use the options spacingTop, spacingRight, spacingBottom
  4454. * and spacingLeft options for shorthand setting of one option.
  4455. *
  4456. * @type {Array<number>}
  4457. * @see [chart.margin](#chart.margin)
  4458. * @default [10, 10, 15, 10]
  4459. * @since 3.0.6
  4460. */
  4461. spacing: [10, 10, 15, 10],
  4462. /**
  4463. * The button that appears after a selection zoom, allowing the user
  4464. * to reset zoom.
  4465. */
  4466. resetZoomButton: {
  4467. /**
  4468. * What frame the button placement should be related to. Can be
  4469. * either `plotBox` or `spacingBox`.
  4470. *
  4471. * @sample {highcharts} highcharts/chart/resetzoombutton-relativeto/
  4472. * Relative to the chart
  4473. * @sample {highstock} highcharts/chart/resetzoombutton-relativeto/
  4474. * Relative to the chart
  4475. *
  4476. * @type {Highcharts.ButtonRelativeToValue}
  4477. * @default plot
  4478. * @since 2.2
  4479. * @apioption chart.resetZoomButton.relativeTo
  4480. */
  4481. /**
  4482. * A collection of attributes for the button. The object takes SVG
  4483. * attributes like `fill`, `stroke`, `stroke-width` or `r`, the
  4484. * border radius. The theme also supports `style`, a collection of
  4485. * CSS properties for the text. Equivalent attributes for the hover
  4486. * state are given in `theme.states.hover`.
  4487. *
  4488. * @sample {highcharts} highcharts/chart/resetzoombutton-theme/
  4489. * Theming the button
  4490. * @sample {highstock} highcharts/chart/resetzoombutton-theme/
  4491. * Theming the button
  4492. *
  4493. * @type {Highcharts.SVGAttributes}
  4494. * @since 2.2
  4495. */
  4496. theme: {
  4497. /** @internal */
  4498. zIndex: 6
  4499. },
  4500. /**
  4501. * The position of the button.
  4502. *
  4503. * @sample {highcharts} highcharts/chart/resetzoombutton-position/
  4504. * Above the plot area
  4505. * @sample {highstock} highcharts/chart/resetzoombutton-position/
  4506. * Above the plot area
  4507. * @sample {highmaps} highcharts/chart/resetzoombutton-position/
  4508. * Above the plot area
  4509. *
  4510. * @type {Highcharts.AlignObject}
  4511. * @since 2.2
  4512. */
  4513. position: {
  4514. /**
  4515. * The horizontal alignment of the button.
  4516. */
  4517. align: 'right',
  4518. /**
  4519. * The horizontal offset of the button.
  4520. */
  4521. x: -10,
  4522. /**
  4523. * The vertical alignment of the button.
  4524. *
  4525. * @type {Highcharts.VerticalAlignValue}
  4526. * @default top
  4527. * @apioption chart.resetZoomButton.position.verticalAlign
  4528. */
  4529. /**
  4530. * The vertical offset of the button.
  4531. */
  4532. y: 10
  4533. }
  4534. },
  4535. /**
  4536. * The pixel width of the plot area border.
  4537. *
  4538. * @sample {highcharts} highcharts/chart/plotborderwidth/
  4539. * 1px border
  4540. * @sample {highstock} stock/chart/plotborder/
  4541. * 2px border
  4542. * @sample {highmaps} maps/chart/plotborder/
  4543. * Plot border options
  4544. *
  4545. * @type {number}
  4546. * @default 0
  4547. * @apioption chart.plotBorderWidth
  4548. */
  4549. /**
  4550. * Whether to apply a drop shadow to the plot area. Requires that
  4551. * plotBackgroundColor be set. The shadow can be an object configuration
  4552. * containing `color`, `offsetX`, `offsetY`, `opacity` and `width`.
  4553. *
  4554. * @sample {highcharts} highcharts/chart/plotshadow/
  4555. * Plot shadow
  4556. * @sample {highstock} stock/chart/plotshadow/
  4557. * Plot shadow
  4558. * @sample {highmaps} maps/chart/plotborder/
  4559. * Plot border options
  4560. *
  4561. * @type {boolean|Highcharts.CSSObject}
  4562. * @default false
  4563. * @apioption chart.plotShadow
  4564. */
  4565. /**
  4566. * When true, cartesian charts like line, spline, area and column are
  4567. * transformed into the polar coordinate system. This produces _polar
  4568. * charts_, also known as _radar charts_.
  4569. *
  4570. * @sample {highcharts} highcharts/demo/polar/
  4571. * Polar chart
  4572. * @sample {highcharts} highcharts/demo/polar-wind-rose/
  4573. * Wind rose, stacked polar column chart
  4574. * @sample {highcharts} highcharts/demo/polar-spider/
  4575. * Spider web chart
  4576. * @sample {highcharts} highcharts/parallel-coordinates/polar/
  4577. * Star plot, multivariate data in a polar chart
  4578. *
  4579. * @type {boolean}
  4580. * @default false
  4581. * @since 2.3.0
  4582. * @product highcharts
  4583. * @requires highcharts-more
  4584. * @apioption chart.polar
  4585. */
  4586. /**
  4587. * Whether to reflow the chart to fit the width of the container div
  4588. * on resizing the window.
  4589. *
  4590. * @sample {highcharts} highcharts/chart/reflow-true/
  4591. * True by default
  4592. * @sample {highcharts} highcharts/chart/reflow-false/
  4593. * False
  4594. * @sample {highstock} stock/chart/reflow-true/
  4595. * True by default
  4596. * @sample {highstock} stock/chart/reflow-false/
  4597. * False
  4598. * @sample {highmaps} maps/chart/reflow-true/
  4599. * True by default
  4600. * @sample {highmaps} maps/chart/reflow-false/
  4601. * False
  4602. *
  4603. * @type {boolean}
  4604. * @default true
  4605. * @since 2.1
  4606. * @apioption chart.reflow
  4607. */
  4608. /**
  4609. * The HTML element where the chart will be rendered. If it is a string,
  4610. * the element by that id is used. The HTML element can also be passed
  4611. * by direct reference, or as the first argument of the chart
  4612. * constructor, in which case the option is not needed.
  4613. *
  4614. * @sample {highcharts} highcharts/chart/reflow-true/
  4615. * String
  4616. * @sample {highcharts} highcharts/chart/renderto-object/
  4617. * Object reference
  4618. * @sample {highstock} stock/chart/renderto-string/
  4619. * String
  4620. * @sample {highstock} stock/chart/renderto-object/
  4621. * Object reference
  4622. *
  4623. * @type {string|Highcharts.HTMLDOMElement}
  4624. * @apioption chart.renderTo
  4625. */
  4626. /**
  4627. * The background color of the marker square when selecting (zooming
  4628. * in on) an area of the chart.
  4629. *
  4630. * @see In styled mode, the selection marker fill is set with the
  4631. * `.highcharts-selection-marker` class.
  4632. *
  4633. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  4634. * @default rgba(51,92,173,0.25)
  4635. * @since 2.1.7
  4636. * @apioption chart.selectionMarkerFill
  4637. */
  4638. /**
  4639. * Whether to apply a drop shadow to the outer chart area. Requires
  4640. * that backgroundColor be set. The shadow can be an object
  4641. * configuration containing `color`, `offsetX`, `offsetY`, `opacity` and
  4642. * `width`.
  4643. *
  4644. * @sample {highcharts} highcharts/chart/shadow/
  4645. * Shadow
  4646. * @sample {highstock} stock/chart/shadow/
  4647. * Shadow
  4648. * @sample {highmaps} maps/chart/border/
  4649. * Chart border and shadow
  4650. *
  4651. * @type {boolean|Highcharts.CSSObject}
  4652. * @default false
  4653. * @apioption chart.shadow
  4654. */
  4655. /**
  4656. * Whether to show the axes initially. This only applies to empty charts
  4657. * where series are added dynamically, as axes are automatically added
  4658. * to cartesian series.
  4659. *
  4660. * @sample {highcharts} highcharts/chart/showaxes-false/
  4661. * False by default
  4662. * @sample {highcharts} highcharts/chart/showaxes-true/
  4663. * True
  4664. *
  4665. * @type {boolean}
  4666. * @since 1.2.5
  4667. * @product highcharts gantt
  4668. * @apioption chart.showAxes
  4669. */
  4670. /**
  4671. * The space between the bottom edge of the chart and the content (plot
  4672. * area, axis title and labels, title, subtitle or legend in top
  4673. * position).
  4674. *
  4675. * @sample {highcharts} highcharts/chart/spacingbottom/
  4676. * Spacing bottom set to 100
  4677. * @sample {highstock} stock/chart/spacingbottom/
  4678. * Spacing bottom set to 100
  4679. * @sample {highmaps} maps/chart/spacing/
  4680. * Spacing 100 all around
  4681. *
  4682. * @type {number}
  4683. * @default 15
  4684. * @since 2.1
  4685. * @apioption chart.spacingBottom
  4686. */
  4687. /**
  4688. * The space between the left edge of the chart and the content (plot
  4689. * area, axis title and labels, title, subtitle or legend in top
  4690. * position).
  4691. *
  4692. * @sample {highcharts} highcharts/chart/spacingleft/
  4693. * Spacing left set to 100
  4694. * @sample {highstock} stock/chart/spacingleft/
  4695. * Spacing left set to 100
  4696. * @sample {highmaps} maps/chart/spacing/
  4697. * Spacing 100 all around
  4698. *
  4699. * @type {number}
  4700. * @default 10
  4701. * @since 2.1
  4702. * @apioption chart.spacingLeft
  4703. */
  4704. /**
  4705. * The space between the right edge of the chart and the content (plot
  4706. * area, axis title and labels, title, subtitle or legend in top
  4707. * position).
  4708. *
  4709. * @sample {highcharts} highcharts/chart/spacingright-100/
  4710. * Spacing set to 100
  4711. * @sample {highcharts} highcharts/chart/spacingright-legend/
  4712. * Legend in right position with default spacing
  4713. * @sample {highstock} stock/chart/spacingright/
  4714. * Spacing set to 100
  4715. * @sample {highmaps} maps/chart/spacing/
  4716. * Spacing 100 all around
  4717. *
  4718. * @type {number}
  4719. * @default 10
  4720. * @since 2.1
  4721. * @apioption chart.spacingRight
  4722. */
  4723. /**
  4724. * The space between the top edge of the chart and the content (plot
  4725. * area, axis title and labels, title, subtitle or legend in top
  4726. * position).
  4727. *
  4728. * @sample {highcharts} highcharts/chart/spacingtop-100/
  4729. * A top spacing of 100
  4730. * @sample {highcharts} highcharts/chart/spacingtop-10/
  4731. * Floating chart title makes the plot area align to the default
  4732. * spacingTop of 10.
  4733. * @sample {highstock} stock/chart/spacingtop/
  4734. * A top spacing of 100
  4735. * @sample {highmaps} maps/chart/spacing/
  4736. * Spacing 100 all around
  4737. *
  4738. * @type {number}
  4739. * @default 10
  4740. * @since 2.1
  4741. * @apioption chart.spacingTop
  4742. */
  4743. /**
  4744. * Additional CSS styles to apply inline to the container `div`. Note
  4745. * that since the default font styles are applied in the renderer, it
  4746. * is ignorant of the individual chart options and must be set globally.
  4747. *
  4748. * @see In styled mode, general chart styles can be set with the
  4749. * `.highcharts-root` class.
  4750. * @sample {highcharts} highcharts/chart/style-serif-font/
  4751. * Using a serif type font
  4752. * @sample {highcharts} highcharts/css/em/
  4753. * Styled mode with relative font sizes
  4754. * @sample {highstock} stock/chart/style/
  4755. * Using a serif type font
  4756. * @sample {highmaps} maps/chart/style-serif-font/
  4757. * Using a serif type font
  4758. *
  4759. * @type {Highcharts.CSSObject}
  4760. * @default {"fontFamily": "\"Lucida Grande\", \"Lucida Sans Unicode\", Verdana, Arial, Helvetica, sans-serif","fontSize":"12px"}
  4761. * @apioption chart.style
  4762. */
  4763. /**
  4764. * The default series type for the chart. Can be any of the chart types
  4765. * listed under [plotOptions](#plotOptions) and [series](#series) or can
  4766. * be a series provided by an additional module.
  4767. *
  4768. * In TypeScript this option has no effect in sense of typing and
  4769. * instead the `type` option must always be set in the series.
  4770. *
  4771. * @sample {highcharts} highcharts/chart/type-bar/
  4772. * Bar
  4773. * @sample {highstock} stock/chart/type/
  4774. * Areaspline
  4775. * @sample {highmaps} maps/chart/type-mapline/
  4776. * Mapline
  4777. *
  4778. * @type {string}
  4779. * @default {highcharts} line
  4780. * @default {highstock} line
  4781. * @default {highmaps} map
  4782. * @since 2.1.0
  4783. * @apioption chart.type
  4784. */
  4785. /**
  4786. * Decides in what dimensions the user can zoom by dragging the mouse.
  4787. * Can be one of `x`, `y` or `xy`.
  4788. *
  4789. * @see [panKey](#chart.panKey)
  4790. *
  4791. * @sample {highcharts} highcharts/chart/zoomtype-none/
  4792. * None by default
  4793. * @sample {highcharts} highcharts/chart/zoomtype-x/
  4794. * X
  4795. * @sample {highcharts} highcharts/chart/zoomtype-y/
  4796. * Y
  4797. * @sample {highcharts} highcharts/chart/zoomtype-xy/
  4798. * Xy
  4799. * @sample {highstock} stock/demo/basic-line/
  4800. * None by default
  4801. * @sample {highstock} stock/chart/zoomtype-x/
  4802. * X
  4803. * @sample {highstock} stock/chart/zoomtype-y/
  4804. * Y
  4805. * @sample {highstock} stock/chart/zoomtype-xy/
  4806. * Xy
  4807. *
  4808. * @type {string}
  4809. * @product highcharts highstock gantt
  4810. * @validvalue ["x", "y", "xy"]
  4811. * @apioption chart.zoomType
  4812. */
  4813. /**
  4814. * Enables zooming by a single touch, in combination with
  4815. * [chart.zoomType](#chart.zoomType). When enabled, two-finger pinch
  4816. * will still work as set up by [chart.pinchType](#chart.pinchType).
  4817. * However, `zoomBySingleTouch` will interfere with touch-dragging the
  4818. * chart to read the tooltip. And especially when vertical zooming is
  4819. * enabled, it will make it hard to scroll vertically on the page.
  4820. * @since 9.0.0
  4821. * @sample highcharts/chart/zoombysingletouch
  4822. * Zoom by single touch enabled, with buttons to toggle
  4823. * @product highcharts highstock gantt
  4824. */
  4825. zoomBySingleTouch: false,
  4826. /**
  4827. * An explicit width for the chart. By default (when `null`) the width
  4828. * is calculated from the offset width of the containing element.
  4829. *
  4830. * @sample {highcharts} highcharts/chart/width/
  4831. * 800px wide
  4832. * @sample {highstock} stock/chart/width/
  4833. * 800px wide
  4834. * @sample {highmaps} maps/chart/size/
  4835. * Chart with explicit size
  4836. *
  4837. * @type {null|number|string}
  4838. */
  4839. width: null,
  4840. /**
  4841. * An explicit height for the chart. If a _number_, the height is
  4842. * given in pixels. If given a _percentage string_ (for example
  4843. * `'56%'`), the height is given as the percentage of the actual chart
  4844. * width. This allows for preserving the aspect ratio across responsive
  4845. * sizes.
  4846. *
  4847. * By default (when `null`) the height is calculated from the offset
  4848. * height of the containing element, or 400 pixels if the containing
  4849. * element's height is 0.
  4850. *
  4851. * @sample {highcharts} highcharts/chart/height/
  4852. * 500px height
  4853. * @sample {highstock} stock/chart/height/
  4854. * 300px height
  4855. * @sample {highmaps} maps/chart/size/
  4856. * Chart with explicit size
  4857. * @sample highcharts/chart/height-percent/
  4858. * Highcharts with percentage height
  4859. *
  4860. * @type {null|number|string}
  4861. */
  4862. height: null,
  4863. /**
  4864. * The color of the outer chart border.
  4865. *
  4866. * @see In styled mode, the stroke is set with the
  4867. * `.highcharts-background` class.
  4868. *
  4869. * @sample {highcharts} highcharts/chart/bordercolor/
  4870. * Brown border
  4871. * @sample {highstock} stock/chart/border/
  4872. * Brown border
  4873. * @sample {highmaps} maps/chart/border/
  4874. * Border options
  4875. *
  4876. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  4877. */
  4878. borderColor: palette.highlightColor80,
  4879. /**
  4880. * The pixel width of the outer chart border.
  4881. *
  4882. * @see In styled mode, the stroke is set with the
  4883. * `.highcharts-background` class.
  4884. *
  4885. * @sample {highcharts} highcharts/chart/borderwidth/
  4886. * 5px border
  4887. * @sample {highstock} stock/chart/border/
  4888. * 2px border
  4889. * @sample {highmaps} maps/chart/border/
  4890. * Border options
  4891. *
  4892. * @type {number}
  4893. * @default 0
  4894. * @apioption chart.borderWidth
  4895. */
  4896. /**
  4897. * The background color or gradient for the outer chart area.
  4898. *
  4899. * @see In styled mode, the background is set with the
  4900. * `.highcharts-background` class.
  4901. *
  4902. * @sample {highcharts} highcharts/chart/backgroundcolor-color/
  4903. * Color
  4904. * @sample {highcharts} highcharts/chart/backgroundcolor-gradient/
  4905. * Gradient
  4906. * @sample {highstock} stock/chart/backgroundcolor-color/
  4907. * Color
  4908. * @sample {highstock} stock/chart/backgroundcolor-gradient/
  4909. * Gradient
  4910. * @sample {highmaps} maps/chart/backgroundcolor-color/
  4911. * Color
  4912. * @sample {highmaps} maps/chart/backgroundcolor-gradient/
  4913. * Gradient
  4914. *
  4915. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  4916. */
  4917. backgroundColor: palette.backgroundColor,
  4918. /**
  4919. * The background color or gradient for the plot area.
  4920. *
  4921. * @see In styled mode, the plot background is set with the
  4922. * `.highcharts-plot-background` class.
  4923. *
  4924. * @sample {highcharts} highcharts/chart/plotbackgroundcolor-color/
  4925. * Color
  4926. * @sample {highcharts} highcharts/chart/plotbackgroundcolor-gradient/
  4927. * Gradient
  4928. * @sample {highstock} stock/chart/plotbackgroundcolor-color/
  4929. * Color
  4930. * @sample {highstock} stock/chart/plotbackgroundcolor-gradient/
  4931. * Gradient
  4932. * @sample {highmaps} maps/chart/plotbackgroundcolor-color/
  4933. * Color
  4934. * @sample {highmaps} maps/chart/plotbackgroundcolor-gradient/
  4935. * Gradient
  4936. *
  4937. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  4938. * @apioption chart.plotBackgroundColor
  4939. */
  4940. /**
  4941. * The URL for an image to use as the plot background. To set an image
  4942. * as the background for the entire chart, set a CSS background image
  4943. * to the container element. Note that for the image to be applied to
  4944. * exported charts, its URL needs to be accessible by the export server.
  4945. *
  4946. * @see In styled mode, a plot background image can be set with the
  4947. * `.highcharts-plot-background` class and a [custom pattern](
  4948. * https://www.highcharts.com/docs/chart-design-and-style/
  4949. * gradients-shadows-and-patterns).
  4950. *
  4951. * @sample {highcharts} highcharts/chart/plotbackgroundimage/
  4952. * Skies
  4953. * @sample {highstock} stock/chart/plotbackgroundimage/
  4954. * Skies
  4955. *
  4956. * @type {string}
  4957. * @apioption chart.plotBackgroundImage
  4958. */
  4959. /**
  4960. * The color of the inner chart or plot area border.
  4961. *
  4962. * @see In styled mode, a plot border stroke can be set with the
  4963. * `.highcharts-plot-border` class.
  4964. *
  4965. * @sample {highcharts} highcharts/chart/plotbordercolor/
  4966. * Blue border
  4967. * @sample {highstock} stock/chart/plotborder/
  4968. * Blue border
  4969. * @sample {highmaps} maps/chart/plotborder/
  4970. * Plot border options
  4971. *
  4972. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  4973. */
  4974. plotBorderColor: palette.neutralColor20
  4975. },
  4976. /**
  4977. * The chart's main title.
  4978. *
  4979. * @sample {highmaps} maps/title/title/
  4980. * Title options demonstrated
  4981. */
  4982. title: {
  4983. /**
  4984. * When the title is floating, the plot area will not move to make space
  4985. * for it.
  4986. *
  4987. * @sample {highcharts} highcharts/chart/zoomtype-none/
  4988. * False by default
  4989. * @sample {highcharts} highcharts/title/floating/
  4990. * True - title on top of the plot area
  4991. * @sample {highstock} stock/chart/title-floating/
  4992. * True - title on top of the plot area
  4993. *
  4994. * @type {boolean}
  4995. * @default false
  4996. * @since 2.1
  4997. * @apioption title.floating
  4998. */
  4999. /**
  5000. * CSS styles for the title. Use this for font styling, but use `align`,
  5001. * `x` and `y` for text alignment.
  5002. *
  5003. * In styled mode, the title style is given in the `.highcharts-title`
  5004. * class.
  5005. *
  5006. * @sample {highcharts} highcharts/title/style/
  5007. * Custom color and weight
  5008. * @sample {highstock} stock/chart/title-style/
  5009. * Custom color and weight
  5010. * @sample highcharts/css/titles/
  5011. * Styled mode
  5012. *
  5013. * @type {Highcharts.CSSObject}
  5014. * @default {highcharts|highmaps} { "color": "#333333", "fontSize": "18px" }
  5015. * @default {highstock} { "color": "#333333", "fontSize": "16px" }
  5016. * @apioption title.style
  5017. */
  5018. /**
  5019. * Whether to
  5020. * [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  5021. * to render the text.
  5022. *
  5023. * @type {boolean}
  5024. * @default false
  5025. * @apioption title.useHTML
  5026. */
  5027. /**
  5028. * The vertical alignment of the title. Can be one of `"top"`,
  5029. * `"middle"` and `"bottom"`. When a value is given, the title behaves
  5030. * as if [floating](#title.floating) were `true`.
  5031. *
  5032. * @sample {highcharts} highcharts/title/verticalalign/
  5033. * Chart title in bottom right corner
  5034. * @sample {highstock} stock/chart/title-verticalalign/
  5035. * Chart title in bottom right corner
  5036. *
  5037. * @type {Highcharts.VerticalAlignValue}
  5038. * @since 2.1
  5039. * @apioption title.verticalAlign
  5040. */
  5041. /**
  5042. * The x position of the title relative to the alignment within
  5043. * `chart.spacingLeft` and `chart.spacingRight`.
  5044. *
  5045. * @sample {highcharts} highcharts/title/align/
  5046. * Aligned to the plot area (x = 70px = margin left - spacing
  5047. * left)
  5048. * @sample {highstock} stock/chart/title-align/
  5049. * Aligned to the plot area (x = 50px = margin left - spacing
  5050. * left)
  5051. *
  5052. * @type {number}
  5053. * @default 0
  5054. * @since 2.0
  5055. * @apioption title.x
  5056. */
  5057. /**
  5058. * The y position of the title relative to the alignment within
  5059. * [chart.spacingTop](#chart.spacingTop) and [chart.spacingBottom](
  5060. * #chart.spacingBottom). By default it depends on the font size.
  5061. *
  5062. * @sample {highcharts} highcharts/title/y/
  5063. * Title inside the plot area
  5064. * @sample {highstock} stock/chart/title-verticalalign/
  5065. * Chart title in bottom right corner
  5066. *
  5067. * @type {number}
  5068. * @since 2.0
  5069. * @apioption title.y
  5070. */
  5071. /**
  5072. * The title of the chart. To disable the title, set the `text` to
  5073. * `undefined`.
  5074. *
  5075. * @sample {highcharts} highcharts/title/text/
  5076. * Custom title
  5077. * @sample {highstock} stock/chart/title-text/
  5078. * Custom title
  5079. *
  5080. * @default {highcharts|highmaps} Chart title
  5081. * @default {highstock} undefined
  5082. */
  5083. text: 'Chart title',
  5084. /**
  5085. * The horizontal alignment of the title. Can be one of "left", "center"
  5086. * and "right".
  5087. *
  5088. * @sample {highcharts} highcharts/title/align/
  5089. * Aligned to the plot area (x = 70px = margin left - spacing
  5090. * left)
  5091. * @sample {highstock} stock/chart/title-align/
  5092. * Aligned to the plot area (x = 50px = margin left - spacing
  5093. * left)
  5094. *
  5095. * @type {Highcharts.AlignValue}
  5096. * @since 2.0
  5097. */
  5098. align: 'center',
  5099. /**
  5100. * The margin between the title and the plot area, or if a subtitle
  5101. * is present, the margin between the subtitle and the plot area.
  5102. *
  5103. * @sample {highcharts} highcharts/title/margin-50/
  5104. * A chart title margin of 50
  5105. * @sample {highcharts} highcharts/title/margin-subtitle/
  5106. * The same margin applied with a subtitle
  5107. * @sample {highstock} stock/chart/title-margin/
  5108. * A chart title margin of 50
  5109. *
  5110. * @since 2.1
  5111. */
  5112. margin: 15,
  5113. /**
  5114. * Adjustment made to the title width, normally to reserve space for
  5115. * the exporting burger menu.
  5116. *
  5117. * @sample highcharts/title/widthadjust/
  5118. * Wider menu, greater padding
  5119. *
  5120. * @since 4.2.5
  5121. */
  5122. widthAdjust: -44
  5123. },
  5124. /**
  5125. * The chart's subtitle. This can be used both to display a subtitle below
  5126. * the main title, and to display random text anywhere in the chart. The
  5127. * subtitle can be updated after chart initialization through the
  5128. * `Chart.setTitle` method.
  5129. *
  5130. * @sample {highmaps} maps/title/subtitle/
  5131. * Subtitle options demonstrated
  5132. */
  5133. subtitle: {
  5134. /**
  5135. * When the subtitle is floating, the plot area will not move to make
  5136. * space for it.
  5137. *
  5138. * @sample {highcharts} highcharts/subtitle/floating/
  5139. * Floating title and subtitle
  5140. * @sample {highstock} stock/chart/subtitle-footnote
  5141. * Footnote floating at bottom right of plot area
  5142. *
  5143. * @type {boolean}
  5144. * @default false
  5145. * @since 2.1
  5146. * @apioption subtitle.floating
  5147. */
  5148. /**
  5149. * CSS styles for the title.
  5150. *
  5151. * In styled mode, the subtitle style is given in the
  5152. * `.highcharts-subtitle` class.
  5153. *
  5154. * @sample {highcharts} highcharts/subtitle/style/
  5155. * Custom color and weight
  5156. * @sample {highcharts} highcharts/css/titles/
  5157. * Styled mode
  5158. * @sample {highstock} stock/chart/subtitle-style
  5159. * Custom color and weight
  5160. * @sample {highstock} highcharts/css/titles/
  5161. * Styled mode
  5162. * @sample {highmaps} highcharts/css/titles/
  5163. * Styled mode
  5164. *
  5165. * @type {Highcharts.CSSObject}
  5166. * @default {"color": "#666666"}
  5167. * @apioption subtitle.style
  5168. */
  5169. /**
  5170. * Whether to
  5171. * [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  5172. * to render the text.
  5173. *
  5174. * @type {boolean}
  5175. * @default false
  5176. * @apioption subtitle.useHTML
  5177. */
  5178. /**
  5179. * The vertical alignment of the title. Can be one of `"top"`,
  5180. * `"middle"` and `"bottom"`. When middle, the subtitle behaves as
  5181. * floating.
  5182. *
  5183. * @sample {highcharts} highcharts/subtitle/verticalalign/
  5184. * Footnote at the bottom right of plot area
  5185. * @sample {highstock} stock/chart/subtitle-footnote
  5186. * Footnote at the bottom right of plot area
  5187. *
  5188. * @type {Highcharts.VerticalAlignValue}
  5189. * @since 2.1
  5190. * @apioption subtitle.verticalAlign
  5191. */
  5192. /**
  5193. * The x position of the subtitle relative to the alignment within
  5194. * `chart.spacingLeft` and `chart.spacingRight`.
  5195. *
  5196. * @sample {highcharts} highcharts/subtitle/align/
  5197. * Footnote at right of plot area
  5198. * @sample {highstock} stock/chart/subtitle-footnote
  5199. * Footnote at the bottom right of plot area
  5200. *
  5201. * @type {number}
  5202. * @default 0
  5203. * @since 2.0
  5204. * @apioption subtitle.x
  5205. */
  5206. /**
  5207. * The y position of the subtitle relative to the alignment within
  5208. * `chart.spacingTop` and `chart.spacingBottom`. By default the subtitle
  5209. * is laid out below the title unless the title is floating.
  5210. *
  5211. * @sample {highcharts} highcharts/subtitle/verticalalign/
  5212. * Footnote at the bottom right of plot area
  5213. * @sample {highstock} stock/chart/subtitle-footnote
  5214. * Footnote at the bottom right of plot area
  5215. *
  5216. * @type {number}
  5217. * @since 2.0
  5218. * @apioption subtitle.y
  5219. */
  5220. /**
  5221. * The subtitle of the chart.
  5222. *
  5223. * @sample {highcharts|highstock} highcharts/subtitle/text/
  5224. * Custom subtitle
  5225. * @sample {highcharts|highstock} highcharts/subtitle/text-formatted/
  5226. * Formatted and linked text.
  5227. */
  5228. text: '',
  5229. /**
  5230. * The horizontal alignment of the subtitle. Can be one of "left",
  5231. * "center" and "right".
  5232. *
  5233. * @sample {highcharts} highcharts/subtitle/align/
  5234. * Footnote at right of plot area
  5235. * @sample {highstock} stock/chart/subtitle-footnote
  5236. * Footnote at bottom right of plot area
  5237. *
  5238. * @type {Highcharts.AlignValue}
  5239. * @since 2.0
  5240. */
  5241. align: 'center',
  5242. /**
  5243. * Adjustment made to the subtitle width, normally to reserve space
  5244. * for the exporting burger menu.
  5245. *
  5246. * @see [title.widthAdjust](#title.widthAdjust)
  5247. *
  5248. * @sample highcharts/title/widthadjust/
  5249. * Wider menu, greater padding
  5250. *
  5251. * @since 4.2.5
  5252. */
  5253. widthAdjust: -44
  5254. },
  5255. /**
  5256. * The chart's caption, which will render below the chart and will be part
  5257. * of exported charts. The caption can be updated after chart initialization
  5258. * through the `Chart.update` or `Chart.caption.update` methods.
  5259. *
  5260. * @sample highcharts/caption/text/
  5261. * A chart with a caption
  5262. * @since 7.2.0
  5263. */
  5264. caption: {
  5265. /**
  5266. * When the caption is floating, the plot area will not move to make
  5267. * space for it.
  5268. *
  5269. * @type {boolean}
  5270. * @default false
  5271. * @apioption caption.floating
  5272. */
  5273. /**
  5274. * The margin between the caption and the plot area.
  5275. */
  5276. margin: 15,
  5277. /**
  5278. * CSS styles for the caption.
  5279. *
  5280. * In styled mode, the caption style is given in the
  5281. * `.highcharts-caption` class.
  5282. *
  5283. * @sample {highcharts} highcharts/css/titles/
  5284. * Styled mode
  5285. *
  5286. * @type {Highcharts.CSSObject}
  5287. * @default {"color": "#666666"}
  5288. * @apioption caption.style
  5289. */
  5290. /**
  5291. * Whether to
  5292. * [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  5293. * to render the text.
  5294. *
  5295. * @type {boolean}
  5296. * @default false
  5297. * @apioption caption.useHTML
  5298. */
  5299. /**
  5300. * The x position of the caption relative to the alignment within
  5301. * `chart.spacingLeft` and `chart.spacingRight`.
  5302. *
  5303. * @type {number}
  5304. * @default 0
  5305. * @apioption caption.x
  5306. */
  5307. /**
  5308. * The y position of the caption relative to the alignment within
  5309. * `chart.spacingTop` and `chart.spacingBottom`.
  5310. *
  5311. * @type {number}
  5312. * @apioption caption.y
  5313. */
  5314. /**
  5315. * The caption text of the chart.
  5316. *
  5317. * @sample {highcharts} highcharts/caption/text/
  5318. * Custom caption
  5319. */
  5320. text: '',
  5321. /**
  5322. * The horizontal alignment of the caption. Can be one of "left",
  5323. * "center" and "right".
  5324. *
  5325. * @type {Highcharts.AlignValue}
  5326. */
  5327. align: 'left',
  5328. /**
  5329. * The vertical alignment of the caption. Can be one of `"top"`,
  5330. * `"middle"` and `"bottom"`. When middle, the caption behaves as
  5331. * floating.
  5332. *
  5333. * @type {Highcharts.VerticalAlignValue}
  5334. */
  5335. verticalAlign: 'bottom'
  5336. },
  5337. /**
  5338. * The plotOptions is a wrapper object for config objects for each series
  5339. * type. The config objects for each series can also be overridden for
  5340. * each series item as given in the series array.
  5341. *
  5342. * Configuration options for the series are given in three levels. Options
  5343. * for all series in a chart are given in the [plotOptions.series](
  5344. * #plotOptions.series) object. Then options for all series of a specific
  5345. * type are given in the plotOptions of that type, for example
  5346. * `plotOptions.line`. Next, options for one single series are given in
  5347. * [the series array](#series).
  5348. */
  5349. plotOptions: {},
  5350. /**
  5351. * HTML labels that can be positioned anywhere in the chart area.
  5352. *
  5353. * This option is deprecated since v7.1.2. Instead, use
  5354. * [annotations](#annotations) that support labels.
  5355. *
  5356. * @deprecated
  5357. * @product highcharts highstock
  5358. */
  5359. labels: {
  5360. /**
  5361. * An HTML label that can be positioned anywhere in the chart area.
  5362. *
  5363. * @deprecated
  5364. * @type {Array<*>}
  5365. * @apioption labels.items
  5366. */
  5367. /**
  5368. * Inner HTML or text for the label.
  5369. *
  5370. * @deprecated
  5371. * @type {string}
  5372. * @apioption labels.items.html
  5373. */
  5374. /**
  5375. * CSS styles for each label. To position the label, use left and top
  5376. * like this:
  5377. * ```js
  5378. * style: {
  5379. * left: '100px',
  5380. * top: '100px'
  5381. * }
  5382. * ```
  5383. *
  5384. * @deprecated
  5385. * @type {Highcharts.CSSObject}
  5386. * @apioption labels.items.style
  5387. */
  5388. /**
  5389. * Shared CSS styles for all labels.
  5390. *
  5391. * @deprecated
  5392. * @type {Highcharts.CSSObject}
  5393. * @default {"color": "#333333", "position": "absolute"}
  5394. */
  5395. style: {
  5396. /**
  5397. * @ignore-option
  5398. */
  5399. position: 'absolute',
  5400. /**
  5401. * @ignore-option
  5402. */
  5403. color: palette.neutralColor80
  5404. }
  5405. },
  5406. /**
  5407. * The legend is a box containing a symbol and name for each series
  5408. * item or point item in the chart. Each series (or points in case
  5409. * of pie charts) is represented by a symbol and its name in the legend.
  5410. *
  5411. * It is possible to override the symbol creator function and create
  5412. * [custom legend symbols](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/studies/legend-custom-symbol/).
  5413. *
  5414. * @productdesc {highmaps}
  5415. * A Highmaps legend by default contains one legend item per series, but if
  5416. * a `colorAxis` is defined, the axis will be displayed in the legend.
  5417. * Either as a gradient, or as multiple legend items for `dataClasses`.
  5418. */
  5419. legend: {
  5420. /**
  5421. * The background color of the legend.
  5422. *
  5423. * @see In styled mode, the legend background fill can be applied with
  5424. * the `.highcharts-legend-box` class.
  5425. *
  5426. * @sample {highcharts} highcharts/legend/backgroundcolor/
  5427. * Yellowish background
  5428. * @sample {highstock} stock/legend/align/
  5429. * Various legend options
  5430. * @sample {highmaps} maps/legend/border-background/
  5431. * Border and background options
  5432. *
  5433. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  5434. * @apioption legend.backgroundColor
  5435. */
  5436. /**
  5437. * The width of the drawn border around the legend.
  5438. *
  5439. * @see In styled mode, the legend border stroke width can be applied
  5440. * with the `.highcharts-legend-box` class.
  5441. *
  5442. * @sample {highcharts} highcharts/legend/borderwidth/
  5443. * 2px border width
  5444. * @sample {highstock} stock/legend/align/
  5445. * Various legend options
  5446. * @sample {highmaps} maps/legend/border-background/
  5447. * Border and background options
  5448. *
  5449. * @type {number}
  5450. * @default 0
  5451. * @apioption legend.borderWidth
  5452. */
  5453. /**
  5454. * Enable or disable the legend. There is also a series-specific option,
  5455. * [showInLegend](#plotOptions.series.showInLegend), that can hide the
  5456. * series from the legend. In some series types this is `false` by
  5457. * default, so it must set to `true` in order to show the legend for the
  5458. * series.
  5459. *
  5460. * @sample {highcharts} highcharts/legend/enabled-false/ Legend disabled
  5461. * @sample {highstock} stock/legend/align/ Various legend options
  5462. * @sample {highmaps} maps/legend/enabled-false/ Legend disabled
  5463. *
  5464. * @default {highstock} false
  5465. * @default {highmaps} true
  5466. * @default {gantt} false
  5467. */
  5468. enabled: true,
  5469. /**
  5470. * The horizontal alignment of the legend box within the chart area.
  5471. * Valid values are `left`, `center` and `right`.
  5472. *
  5473. * In the case that the legend is aligned in a corner position, the
  5474. * `layout` option will determine whether to place it above/below
  5475. * or on the side of the plot area.
  5476. *
  5477. * @sample {highcharts} highcharts/legend/align/
  5478. * Legend at the right of the chart
  5479. * @sample {highstock} stock/legend/align/
  5480. * Various legend options
  5481. * @sample {highmaps} maps/legend/alignment/
  5482. * Legend alignment
  5483. *
  5484. * @type {Highcharts.AlignValue}
  5485. * @since 2.0
  5486. */
  5487. align: 'center',
  5488. /**
  5489. * If the [layout](legend.layout) is `horizontal` and the legend items
  5490. * span over two lines or more, whether to align the items into vertical
  5491. * columns. Setting this to `false` makes room for more items, but will
  5492. * look more messy.
  5493. *
  5494. * @since 6.1.0
  5495. */
  5496. alignColumns: true,
  5497. /**
  5498. * When the legend is floating, the plot area ignores it and is allowed
  5499. * to be placed below it.
  5500. *
  5501. * @sample {highcharts} highcharts/legend/floating-false/
  5502. * False by default
  5503. * @sample {highcharts} highcharts/legend/floating-true/
  5504. * True
  5505. * @sample {highmaps} maps/legend/alignment/
  5506. * Floating legend
  5507. *
  5508. * @type {boolean}
  5509. * @default false
  5510. * @since 2.1
  5511. * @apioption legend.floating
  5512. */
  5513. /**
  5514. * The layout of the legend items. Can be one of `horizontal` or
  5515. * `vertical` or `proximate`. When `proximate`, the legend items will be
  5516. * placed as close as possible to the graphs they're representing,
  5517. * except in inverted charts or when the legend position doesn't allow
  5518. * it.
  5519. *
  5520. * @sample {highcharts} highcharts/legend/layout-horizontal/
  5521. * Horizontal by default
  5522. * @sample {highcharts} highcharts/legend/layout-vertical/
  5523. * Vertical
  5524. * @sample highcharts/legend/layout-proximate
  5525. * Labels proximate to the data
  5526. * @sample {highstock} stock/legend/layout-horizontal/
  5527. * Horizontal by default
  5528. * @sample {highmaps} maps/legend/padding-itemmargin/
  5529. * Vertical with data classes
  5530. * @sample {highmaps} maps/legend/layout-vertical/
  5531. * Vertical with color axis gradient
  5532. *
  5533. * @validvalue ["horizontal", "vertical", "proximate"]
  5534. */
  5535. layout: 'horizontal',
  5536. /**
  5537. * In a legend with horizontal layout, the itemDistance defines the
  5538. * pixel distance between each item.
  5539. *
  5540. * @sample {highcharts} highcharts/legend/layout-horizontal/
  5541. * 50px item distance
  5542. * @sample {highstock} highcharts/legend/layout-horizontal/
  5543. * 50px item distance
  5544. *
  5545. * @type {number}
  5546. * @default {highcharts} 20
  5547. * @default {highstock} 20
  5548. * @default {highmaps} 8
  5549. * @since 3.0.3
  5550. * @apioption legend.itemDistance
  5551. */
  5552. /**
  5553. * The pixel bottom margin for each legend item.
  5554. *
  5555. * @sample {highcharts|highstock} highcharts/legend/padding-itemmargin/
  5556. * Padding and item margins demonstrated
  5557. * @sample {highmaps} maps/legend/padding-itemmargin/
  5558. * Padding and item margins demonstrated
  5559. *
  5560. * @type {number}
  5561. * @default 0
  5562. * @since 2.2.0
  5563. * @apioption legend.itemMarginBottom
  5564. */
  5565. /**
  5566. * The pixel top margin for each legend item.
  5567. *
  5568. * @sample {highcharts|highstock} highcharts/legend/padding-itemmargin/
  5569. * Padding and item margins demonstrated
  5570. * @sample {highmaps} maps/legend/padding-itemmargin/
  5571. * Padding and item margins demonstrated
  5572. *
  5573. * @type {number}
  5574. * @default 0
  5575. * @since 2.2.0
  5576. * @apioption legend.itemMarginTop
  5577. */
  5578. /**
  5579. * The width for each legend item. By default the items are laid out
  5580. * successively. In a [horizontal layout](legend.layout), if the items
  5581. * are laid out across two rows or more, they will be vertically aligned
  5582. * depending on the [legend.alignColumns](legend.alignColumns) option.
  5583. *
  5584. * @sample {highcharts} highcharts/legend/itemwidth-default/
  5585. * Undefined by default
  5586. * @sample {highcharts} highcharts/legend/itemwidth-80/
  5587. * 80 for aligned legend items
  5588. *
  5589. * @type {number}
  5590. * @since 2.0
  5591. * @apioption legend.itemWidth
  5592. */
  5593. /**
  5594. * A [format string](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting)
  5595. * for each legend label. Available variables relates to properties on
  5596. * the series, or the point in case of pies.
  5597. *
  5598. * @type {string}
  5599. * @default {name}
  5600. * @since 1.3
  5601. * @apioption legend.labelFormat
  5602. */
  5603. /* eslint-disable valid-jsdoc */
  5604. /**
  5605. * Callback function to format each of the series' labels. The `this`
  5606. * keyword refers to the series object, or the point object in case of
  5607. * pie charts. By default the series or point name is printed.
  5608. *
  5609. * @productdesc {highmaps}
  5610. * In Highmaps the context can also be a data class in case of a
  5611. * `colorAxis`.
  5612. *
  5613. * @sample {highcharts} highcharts/legend/labelformatter/
  5614. * Add text
  5615. * @sample {highmaps} maps/legend/labelformatter/
  5616. * Data classes with label formatter
  5617. *
  5618. * @type {Highcharts.FormatterCallbackFunction<Point|Series>}
  5619. */
  5620. labelFormatter: function () {
  5621. /** eslint-enable valid-jsdoc */
  5622. return this.name;
  5623. },
  5624. /**
  5625. * Line height for the legend items. Deprecated as of 2.1\. Instead,
  5626. * the line height for each item can be set using
  5627. * `itemStyle.lineHeight`, and the padding between items using
  5628. * `itemMarginTop` and `itemMarginBottom`.
  5629. *
  5630. * @sample {highcharts} highcharts/legend/lineheight/
  5631. * Setting padding
  5632. *
  5633. * @deprecated
  5634. *
  5635. * @type {number}
  5636. * @default 16
  5637. * @since 2.0
  5638. * @product highcharts gantt
  5639. * @apioption legend.lineHeight
  5640. */
  5641. /**
  5642. * If the plot area sized is calculated automatically and the legend is
  5643. * not floating, the legend margin is the space between the legend and
  5644. * the axis labels or plot area.
  5645. *
  5646. * @sample {highcharts} highcharts/legend/margin-default/
  5647. * 12 pixels by default
  5648. * @sample {highcharts} highcharts/legend/margin-30/
  5649. * 30 pixels
  5650. *
  5651. * @type {number}
  5652. * @default 12
  5653. * @since 2.1
  5654. * @apioption legend.margin
  5655. */
  5656. /**
  5657. * Maximum pixel height for the legend. When the maximum height is
  5658. * extended, navigation will show.
  5659. *
  5660. * @type {number}
  5661. * @since 2.3.0
  5662. * @apioption legend.maxHeight
  5663. */
  5664. /**
  5665. * The color of the drawn border around the legend.
  5666. *
  5667. * @see In styled mode, the legend border stroke can be applied with the
  5668. * `.highcharts-legend-box` class.
  5669. *
  5670. * @sample {highcharts} highcharts/legend/bordercolor/
  5671. * Brown border
  5672. * @sample {highstock} stock/legend/align/
  5673. * Various legend options
  5674. * @sample {highmaps} maps/legend/border-background/
  5675. * Border and background options
  5676. *
  5677. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  5678. */
  5679. borderColor: palette.neutralColor40,
  5680. /**
  5681. * The border corner radius of the legend.
  5682. *
  5683. * @sample {highcharts} highcharts/legend/borderradius-default/
  5684. * Square by default
  5685. * @sample {highcharts} highcharts/legend/borderradius-round/
  5686. * 5px rounded
  5687. * @sample {highmaps} maps/legend/border-background/
  5688. * Border and background options
  5689. */
  5690. borderRadius: 0,
  5691. /**
  5692. * Options for the paging or navigation appearing when the legend is
  5693. * overflown. Navigation works well on screen, but not in static
  5694. * exported images. One way of working around that is to
  5695. * [increase the chart height in
  5696. * export](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/legend/navigation-enabled-false/).
  5697. */
  5698. navigation: {
  5699. /**
  5700. * How to animate the pages when navigating up or down. A value of
  5701. * `true` applies the default navigation given in the
  5702. * `chart.animation` option. Additional options can be given as an
  5703. * object containing values for easing and duration.
  5704. *
  5705. * @sample {highcharts} highcharts/legend/navigation/
  5706. * Legend page navigation demonstrated
  5707. * @sample {highstock} highcharts/legend/navigation/
  5708. * Legend page navigation demonstrated
  5709. *
  5710. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  5711. * @default true
  5712. * @since 2.2.4
  5713. * @apioption legend.navigation.animation
  5714. */
  5715. /**
  5716. * The pixel size of the up and down arrows in the legend paging
  5717. * navigation.
  5718. *
  5719. * @sample {highcharts} highcharts/legend/navigation/
  5720. * Legend page navigation demonstrated
  5721. * @sample {highstock} highcharts/legend/navigation/
  5722. * Legend page navigation demonstrated
  5723. *
  5724. * @type {number}
  5725. * @default 12
  5726. * @since 2.2.4
  5727. * @apioption legend.navigation.arrowSize
  5728. */
  5729. /**
  5730. * Whether to enable the legend navigation. In most cases, disabling
  5731. * the navigation results in an unwanted overflow.
  5732. *
  5733. * See also the [adapt chart to legend](
  5734. * https://www.highcharts.com/products/plugin-registry/single/8/Adapt-Chart-To-Legend)
  5735. * plugin for a solution to extend the chart height to make room for
  5736. * the legend, optionally in exported charts only.
  5737. *
  5738. * @type {boolean}
  5739. * @default true
  5740. * @since 4.2.4
  5741. * @apioption legend.navigation.enabled
  5742. */
  5743. /**
  5744. * Text styles for the legend page navigation.
  5745. *
  5746. * @see In styled mode, the navigation items are styled with the
  5747. * `.highcharts-legend-navigation` class.
  5748. *
  5749. * @sample {highcharts} highcharts/legend/navigation/
  5750. * Legend page navigation demonstrated
  5751. * @sample {highstock} highcharts/legend/navigation/
  5752. * Legend page navigation demonstrated
  5753. *
  5754. * @type {Highcharts.CSSObject}
  5755. * @since 2.2.4
  5756. * @apioption legend.navigation.style
  5757. */
  5758. /**
  5759. * The color for the active up or down arrow in the legend page
  5760. * navigation.
  5761. *
  5762. * @see In styled mode, the active arrow be styled with the
  5763. * `.highcharts-legend-nav-active` class.
  5764. *
  5765. * @sample {highcharts} highcharts/legend/navigation/
  5766. * Legend page navigation demonstrated
  5767. * @sample {highstock} highcharts/legend/navigation/
  5768. * Legend page navigation demonstrated
  5769. *
  5770. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  5771. * @since 2.2.4
  5772. */
  5773. activeColor: palette.highlightColor100,
  5774. /**
  5775. * The color of the inactive up or down arrow in the legend page
  5776. * navigation. .
  5777. *
  5778. * @see In styled mode, the inactive arrow be styled with the
  5779. * `.highcharts-legend-nav-inactive` class.
  5780. *
  5781. * @sample {highcharts} highcharts/legend/navigation/
  5782. * Legend page navigation demonstrated
  5783. * @sample {highstock} highcharts/legend/navigation/
  5784. * Legend page navigation demonstrated
  5785. *
  5786. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  5787. * @since 2.2.4
  5788. */
  5789. inactiveColor: palette.neutralColor20
  5790. },
  5791. /**
  5792. * The inner padding of the legend box.
  5793. *
  5794. * @sample {highcharts|highstock} highcharts/legend/padding-itemmargin/
  5795. * Padding and item margins demonstrated
  5796. * @sample {highmaps} maps/legend/padding-itemmargin/
  5797. * Padding and item margins demonstrated
  5798. *
  5799. * @type {number}
  5800. * @default 8
  5801. * @since 2.2.0
  5802. * @apioption legend.padding
  5803. */
  5804. /**
  5805. * Whether to reverse the order of the legend items compared to the
  5806. * order of the series or points as defined in the configuration object.
  5807. *
  5808. * @see [yAxis.reversedStacks](#yAxis.reversedStacks),
  5809. * [series.legendIndex](#series.legendIndex)
  5810. *
  5811. * @sample {highcharts} highcharts/legend/reversed/
  5812. * Stacked bar with reversed legend
  5813. *
  5814. * @type {boolean}
  5815. * @default false
  5816. * @since 1.2.5
  5817. * @apioption legend.reversed
  5818. */
  5819. /**
  5820. * Whether to show the symbol on the right side of the text rather than
  5821. * the left side. This is common in Arabic and Hebrew.
  5822. *
  5823. * @sample {highcharts} highcharts/legend/rtl/
  5824. * Symbol to the right
  5825. *
  5826. * @type {boolean}
  5827. * @default false
  5828. * @since 2.2
  5829. * @apioption legend.rtl
  5830. */
  5831. /**
  5832. * CSS styles for the legend area. In the 1.x versions the position
  5833. * of the legend area was determined by CSS. In 2.x, the position is
  5834. * determined by properties like `align`, `verticalAlign`, `x` and `y`,
  5835. * but the styles are still parsed for backwards compatibility.
  5836. *
  5837. * @deprecated
  5838. *
  5839. * @type {Highcharts.CSSObject}
  5840. * @product highcharts highstock
  5841. * @apioption legend.style
  5842. */
  5843. /**
  5844. * CSS styles for each legend item. Only a subset of CSS is supported,
  5845. * notably those options related to text. The default `textOverflow`
  5846. * property makes long texts truncate. Set it to `undefined` to wrap
  5847. * text instead. A `width` property can be added to control the text
  5848. * width.
  5849. *
  5850. * @see In styled mode, the legend items can be styled with the
  5851. * `.highcharts-legend-item` class.
  5852. *
  5853. * @sample {highcharts} highcharts/legend/itemstyle/
  5854. * Bold black text
  5855. * @sample {highmaps} maps/legend/itemstyle/
  5856. * Item text styles
  5857. *
  5858. * @type {Highcharts.CSSObject}
  5859. * @default {"color": "#333333", "cursor": "pointer", "fontSize": "12px", "fontWeight": "bold", "textOverflow": "ellipsis"}
  5860. */
  5861. itemStyle: {
  5862. /**
  5863. * @ignore
  5864. */
  5865. color: palette.neutralColor80,
  5866. /**
  5867. * @ignore
  5868. */
  5869. cursor: 'pointer',
  5870. /**
  5871. * @ignore
  5872. */
  5873. fontSize: '12px',
  5874. /**
  5875. * @ignore
  5876. */
  5877. fontWeight: 'bold',
  5878. /**
  5879. * @ignore
  5880. */
  5881. textOverflow: 'ellipsis'
  5882. },
  5883. /**
  5884. * CSS styles for each legend item in hover mode. Only a subset of
  5885. * CSS is supported, notably those options related to text. Properties
  5886. * are inherited from `style` unless overridden here.
  5887. *
  5888. * @see In styled mode, the hovered legend items can be styled with
  5889. * the `.highcharts-legend-item:hover` pesudo-class.
  5890. *
  5891. * @sample {highcharts} highcharts/legend/itemhoverstyle/
  5892. * Red on hover
  5893. * @sample {highmaps} maps/legend/itemstyle/
  5894. * Item text styles
  5895. *
  5896. * @type {Highcharts.CSSObject}
  5897. * @default {"color": "#000000"}
  5898. */
  5899. itemHoverStyle: {
  5900. /**
  5901. * @ignore
  5902. */
  5903. color: palette.neutralColor100
  5904. },
  5905. /**
  5906. * CSS styles for each legend item when the corresponding series or
  5907. * point is hidden. Only a subset of CSS is supported, notably those
  5908. * options related to text. Properties are inherited from `style`
  5909. * unless overridden here.
  5910. *
  5911. * @see In styled mode, the hidden legend items can be styled with
  5912. * the `.highcharts-legend-item-hidden` class.
  5913. *
  5914. * @sample {highcharts} highcharts/legend/itemhiddenstyle/
  5915. * Darker gray color
  5916. *
  5917. * @type {Highcharts.CSSObject}
  5918. * @default {"color": "#cccccc"}
  5919. */
  5920. itemHiddenStyle: {
  5921. /**
  5922. * @ignore
  5923. */
  5924. color: palette.neutralColor20
  5925. },
  5926. /**
  5927. * Whether to apply a drop shadow to the legend. A `backgroundColor`
  5928. * also needs to be applied for this to take effect. The shadow can be
  5929. * an object configuration containing `color`, `offsetX`, `offsetY`,
  5930. * `opacity` and `width`.
  5931. *
  5932. * @sample {highcharts} highcharts/legend/shadow/
  5933. * White background and drop shadow
  5934. * @sample {highstock} stock/legend/align/
  5935. * Various legend options
  5936. * @sample {highmaps} maps/legend/border-background/
  5937. * Border and background options
  5938. *
  5939. * @type {boolean|Highcharts.CSSObject}
  5940. */
  5941. shadow: false,
  5942. /**
  5943. * Default styling for the checkbox next to a legend item when
  5944. * `showCheckbox` is true.
  5945. *
  5946. * @type {Highcharts.CSSObject}
  5947. * @default {"width": "13px", "height": "13px", "position":"absolute"}
  5948. */
  5949. itemCheckboxStyle: {
  5950. /**
  5951. * @ignore
  5952. */
  5953. position: 'absolute',
  5954. /**
  5955. * @ignore
  5956. */
  5957. width: '13px',
  5958. /**
  5959. * @ignore
  5960. */
  5961. height: '13px'
  5962. },
  5963. // itemWidth: undefined,
  5964. /**
  5965. * When this is true, the legend symbol width will be the same as
  5966. * the symbol height, which in turn defaults to the font size of the
  5967. * legend items.
  5968. *
  5969. * @since 5.0.0
  5970. */
  5971. squareSymbol: true,
  5972. /**
  5973. * The pixel height of the symbol for series types that use a rectangle
  5974. * in the legend. Defaults to the font size of legend items.
  5975. *
  5976. * @productdesc {highmaps}
  5977. * In Highmaps, when the symbol is the gradient of a vertical color
  5978. * axis, the height defaults to 200.
  5979. *
  5980. * @sample {highmaps} maps/legend/layout-vertical-sized/
  5981. * Sized vertical gradient
  5982. * @sample {highmaps} maps/legend/padding-itemmargin/
  5983. * No distance between data classes
  5984. *
  5985. * @type {number}
  5986. * @since 3.0.8
  5987. * @apioption legend.symbolHeight
  5988. */
  5989. /**
  5990. * The border radius of the symbol for series types that use a rectangle
  5991. * in the legend. Defaults to half the `symbolHeight`.
  5992. *
  5993. * @sample {highcharts} highcharts/legend/symbolradius/
  5994. * Round symbols
  5995. * @sample {highstock} highcharts/legend/symbolradius/
  5996. * Round symbols
  5997. * @sample {highmaps} highcharts/legend/symbolradius/
  5998. * Round symbols
  5999. *
  6000. * @type {number}
  6001. * @since 3.0.8
  6002. * @apioption legend.symbolRadius
  6003. */
  6004. /**
  6005. * The pixel width of the legend item symbol. When the `squareSymbol`
  6006. * option is set, this defaults to the `symbolHeight`, otherwise 16.
  6007. *
  6008. * @productdesc {highmaps}
  6009. * In Highmaps, when the symbol is the gradient of a horizontal color
  6010. * axis, the width defaults to 200.
  6011. *
  6012. * @sample {highcharts} highcharts/legend/symbolwidth/
  6013. * Greater symbol width and padding
  6014. * @sample {highmaps} maps/legend/padding-itemmargin/
  6015. * Padding and item margins demonstrated
  6016. * @sample {highmaps} maps/legend/layout-vertical-sized/
  6017. * Sized vertical gradient
  6018. *
  6019. * @type {number}
  6020. * @apioption legend.symbolWidth
  6021. */
  6022. /**
  6023. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  6024. * to render the legend item texts.
  6025. *
  6026. * Prior to 4.1.7, when using HTML, [legend.navigation](
  6027. * #legend.navigation) was disabled.
  6028. *
  6029. * @type {boolean}
  6030. * @default false
  6031. * @apioption legend.useHTML
  6032. */
  6033. /**
  6034. * The width of the legend box. If a number is set, it translates to
  6035. * pixels. Since v7.0.2 it allows setting a percent string of the full
  6036. * chart width, for example `40%`.
  6037. *
  6038. * Defaults to the full chart width for legends below or above the
  6039. * chart, half the chart width for legends to the left and right.
  6040. *
  6041. * @sample {highcharts} highcharts/legend/width/
  6042. * Aligned to the plot area
  6043. * @sample {highcharts} highcharts/legend/width-percent/
  6044. * A percent of the chart width
  6045. *
  6046. * @type {number|string}
  6047. * @since 2.0
  6048. * @apioption legend.width
  6049. */
  6050. /**
  6051. * The pixel padding between the legend item symbol and the legend
  6052. * item text.
  6053. *
  6054. * @sample {highcharts} highcharts/legend/symbolpadding/
  6055. * Greater symbol width and padding
  6056. */
  6057. symbolPadding: 5,
  6058. /**
  6059. * The vertical alignment of the legend box. Can be one of `top`,
  6060. * `middle` or `bottom`. Vertical position can be further determined
  6061. * by the `y` option.
  6062. *
  6063. * In the case that the legend is aligned in a corner position, the
  6064. * `layout` option will determine whether to place it above/below
  6065. * or on the side of the plot area.
  6066. *
  6067. * When the [layout](#legend.layout) option is `proximate`, the
  6068. * `verticalAlign` option doesn't apply.
  6069. *
  6070. * @sample {highcharts} highcharts/legend/verticalalign/
  6071. * Legend 100px from the top of the chart
  6072. * @sample {highstock} stock/legend/align/
  6073. * Various legend options
  6074. * @sample {highmaps} maps/legend/alignment/
  6075. * Legend alignment
  6076. *
  6077. * @type {Highcharts.VerticalAlignValue}
  6078. * @since 2.0
  6079. */
  6080. verticalAlign: 'bottom',
  6081. // width: undefined,
  6082. /**
  6083. * The x offset of the legend relative to its horizontal alignment
  6084. * `align` within chart.spacingLeft and chart.spacingRight. Negative
  6085. * x moves it to the left, positive x moves it to the right.
  6086. *
  6087. * @sample {highcharts} highcharts/legend/width/
  6088. * Aligned to the plot area
  6089. *
  6090. * @since 2.0
  6091. */
  6092. x: 0,
  6093. /**
  6094. * The vertical offset of the legend relative to it's vertical alignment
  6095. * `verticalAlign` within chart.spacingTop and chart.spacingBottom.
  6096. * Negative y moves it up, positive y moves it down.
  6097. *
  6098. * @sample {highcharts} highcharts/legend/verticalalign/
  6099. * Legend 100px from the top of the chart
  6100. * @sample {highstock} stock/legend/align/
  6101. * Various legend options
  6102. * @sample {highmaps} maps/legend/alignment/
  6103. * Legend alignment
  6104. *
  6105. * @since 2.0
  6106. */
  6107. y: 0,
  6108. /**
  6109. * A title to be added on top of the legend.
  6110. *
  6111. * @sample {highcharts} highcharts/legend/title/
  6112. * Legend title
  6113. * @sample {highmaps} maps/legend/alignment/
  6114. * Legend with title
  6115. *
  6116. * @since 3.0
  6117. */
  6118. title: {
  6119. /**
  6120. * A text or HTML string for the title.
  6121. *
  6122. * @type {string}
  6123. * @since 3.0
  6124. * @apioption legend.title.text
  6125. */
  6126. /**
  6127. * Generic CSS styles for the legend title.
  6128. *
  6129. * @see In styled mode, the legend title is styled with the
  6130. * `.highcharts-legend-title` class.
  6131. *
  6132. * @type {Highcharts.CSSObject}
  6133. * @default {"fontWeight": "bold"}
  6134. * @since 3.0
  6135. */
  6136. style: {
  6137. /**
  6138. * @ignore
  6139. */
  6140. fontWeight: 'bold'
  6141. }
  6142. }
  6143. },
  6144. /**
  6145. * The loading options control the appearance of the loading screen
  6146. * that covers the plot area on chart operations. This screen only
  6147. * appears after an explicit call to `chart.showLoading()`. It is a
  6148. * utility for developers to communicate to the end user that something
  6149. * is going on, for example while retrieving new data via an XHR connection.
  6150. * The "Loading..." text itself is not part of this configuration
  6151. * object, but part of the `lang` object.
  6152. */
  6153. loading: {
  6154. /**
  6155. * The duration in milliseconds of the fade out effect.
  6156. *
  6157. * @sample highcharts/loading/hideduration/
  6158. * Fade in and out over a second
  6159. *
  6160. * @type {number}
  6161. * @default 100
  6162. * @since 1.2.0
  6163. * @apioption loading.hideDuration
  6164. */
  6165. /**
  6166. * The duration in milliseconds of the fade in effect.
  6167. *
  6168. * @sample highcharts/loading/hideduration/
  6169. * Fade in and out over a second
  6170. *
  6171. * @type {number}
  6172. * @default 100
  6173. * @since 1.2.0
  6174. * @apioption loading.showDuration
  6175. */
  6176. /**
  6177. * CSS styles for the loading label `span`.
  6178. *
  6179. * @see In styled mode, the loading label is styled with the
  6180. * `.highcharts-loading-inner` class.
  6181. *
  6182. * @sample {highcharts|highmaps} highcharts/loading/labelstyle/
  6183. * Vertically centered
  6184. * @sample {highstock} stock/loading/general/
  6185. * Label styles
  6186. *
  6187. * @type {Highcharts.CSSObject}
  6188. * @default {"fontWeight": "bold", "position": "relative", "top": "45%"}
  6189. * @since 1.2.0
  6190. */
  6191. labelStyle: {
  6192. /**
  6193. * @ignore
  6194. */
  6195. fontWeight: 'bold',
  6196. /**
  6197. * @ignore
  6198. */
  6199. position: 'relative',
  6200. /**
  6201. * @ignore
  6202. */
  6203. top: '45%'
  6204. },
  6205. /**
  6206. * CSS styles for the loading screen that covers the plot area.
  6207. *
  6208. * In styled mode, the loading label is styled with the
  6209. * `.highcharts-loading` class.
  6210. *
  6211. * @sample {highcharts|highmaps} highcharts/loading/style/
  6212. * Gray plot area, white text
  6213. * @sample {highstock} stock/loading/general/
  6214. * Gray plot area, white text
  6215. *
  6216. * @type {Highcharts.CSSObject}
  6217. * @default {"position": "absolute", "backgroundColor": "#ffffff", "opacity": 0.5, "textAlign": "center"}
  6218. * @since 1.2.0
  6219. */
  6220. style: {
  6221. /**
  6222. * @ignore
  6223. */
  6224. position: 'absolute',
  6225. /**
  6226. * @ignore
  6227. */
  6228. backgroundColor: palette.backgroundColor,
  6229. /**
  6230. * @ignore
  6231. */
  6232. opacity: 0.5,
  6233. /**
  6234. * @ignore
  6235. */
  6236. textAlign: 'center'
  6237. }
  6238. },
  6239. /**
  6240. * Options for the tooltip that appears when the user hovers over a
  6241. * series or point.
  6242. *
  6243. * @declare Highcharts.TooltipOptions
  6244. */
  6245. tooltip: {
  6246. /**
  6247. * The color of the tooltip border. When `undefined`, the border takes
  6248. * the color of the corresponding series or point.
  6249. *
  6250. * @sample {highcharts} highcharts/tooltip/bordercolor-default/
  6251. * Follow series by default
  6252. * @sample {highcharts} highcharts/tooltip/bordercolor-black/
  6253. * Black border
  6254. * @sample {highstock} stock/tooltip/general/
  6255. * Styled tooltip
  6256. * @sample {highmaps} maps/tooltip/background-border/
  6257. * Background and border demo
  6258. *
  6259. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  6260. * @apioption tooltip.borderColor
  6261. */
  6262. /**
  6263. * A CSS class name to apply to the tooltip's container div,
  6264. * allowing unique CSS styling for each chart.
  6265. *
  6266. * @type {string}
  6267. * @apioption tooltip.className
  6268. */
  6269. /**
  6270. * Since 4.1, the crosshair definitions are moved to the Axis object
  6271. * in order for a better separation from the tooltip. See
  6272. * [xAxis.crosshair](#xAxis.crosshair).
  6273. *
  6274. * @sample {highcharts} highcharts/tooltip/crosshairs-x/
  6275. * Enable a crosshair for the x value
  6276. *
  6277. * @deprecated
  6278. *
  6279. * @type {*}
  6280. * @default true
  6281. * @apioption tooltip.crosshairs
  6282. */
  6283. /**
  6284. * Distance from point to tooltip in pixels.
  6285. *
  6286. * @type {number}
  6287. * @default 16
  6288. * @apioption tooltip.distance
  6289. */
  6290. /**
  6291. * Whether the tooltip should follow the mouse as it moves across
  6292. * columns, pie slices and other point types with an extent.
  6293. * By default it behaves this way for pie, polygon, map, sankey
  6294. * and wordcloud series by override in the `plotOptions`
  6295. * for those series types.
  6296. *
  6297. * Does not apply if [split](#tooltip.split) is `true`.
  6298. *
  6299. * For touch moves to behave the same way, [followTouchMove](
  6300. * #tooltip.followTouchMove) must be `true` also.
  6301. *
  6302. * @type {boolean}
  6303. * @default {highcharts} false
  6304. * @default {highstock} false
  6305. * @default {highmaps} true
  6306. * @since 3.0
  6307. * @apioption tooltip.followPointer
  6308. */
  6309. /**
  6310. * Whether the tooltip should update as the finger moves on a touch
  6311. * device. If this is `true` and [chart.panning](#chart.panning) is
  6312. * set,`followTouchMove` will take over one-finger touches, so the user
  6313. * needs to use two fingers for zooming and panning.
  6314. *
  6315. * Note the difference to [followPointer](#tooltip.followPointer) that
  6316. * only defines the _position_ of the tooltip. If `followPointer` is
  6317. * false in for example a column series, the tooltip will show above or
  6318. * below the column, but as `followTouchMove` is true, the tooltip will
  6319. * jump from column to column as the user swipes across the plot area.
  6320. *
  6321. * @type {boolean}
  6322. * @default {highcharts} true
  6323. * @default {highstock} true
  6324. * @default {highmaps} false
  6325. * @since 3.0.1
  6326. * @apioption tooltip.followTouchMove
  6327. */
  6328. /**
  6329. * Callback function to format the text of the tooltip from scratch. In
  6330. * case of single or [shared](#tooltip.shared) tooltips, a string should
  6331. * be returned. In case of [split](#tooltip.split) tooltips, it should
  6332. * return an array where the first item is the header, and subsequent
  6333. * items are mapped to the points. Return `false` to disable tooltip for
  6334. * a specific point on series.
  6335. *
  6336. * A subset of HTML is supported. Unless `useHTML` is true, the HTML of
  6337. * the tooltip is parsed and converted to SVG, therefore this isn't a
  6338. * complete HTML renderer. The following HTML tags are supported: `b`,
  6339. * `br`, `em`, `i`, `span`, `strong`. Spans can be styled with a `style`
  6340. * attribute, but only text-related CSS, that is shared with SVG, is
  6341. * handled.
  6342. *
  6343. * The available data in the formatter differ a bit depending on whether
  6344. * the tooltip is shared or split, or belongs to a single point. In a
  6345. * shared/split tooltip, all properties except `x`, which is common for
  6346. * all points, are kept in an array, `this.points`.
  6347. *
  6348. * Available data are:
  6349. *
  6350. * - **this.percentage (not shared) /**
  6351. * **this.points[i].percentage (shared)**:
  6352. * Stacked series and pies only. The point's percentage of the total.
  6353. *
  6354. * - **this.point (not shared) / this.points[i].point (shared)**:
  6355. * The point object. The point name, if defined, is available through
  6356. * `this.point.name`.
  6357. *
  6358. * - **this.points**:
  6359. * In a shared tooltip, this is an array containing all other
  6360. * properties for each point.
  6361. *
  6362. * - **this.series (not shared) / this.points[i].series (shared)**:
  6363. * The series object. The series name is available through
  6364. * `this.series.name`.
  6365. *
  6366. * - **this.total (not shared) / this.points[i].total (shared)**:
  6367. * Stacked series only. The total value at this point's x value.
  6368. *
  6369. * - **this.x**:
  6370. * The x value. This property is the same regardless of the tooltip
  6371. * being shared or not.
  6372. *
  6373. * - **this.y (not shared) / this.points[i].y (shared)**:
  6374. * The y value.
  6375. *
  6376. * @sample {highcharts} highcharts/tooltip/formatter-simple/
  6377. * Simple string formatting
  6378. * @sample {highcharts} highcharts/tooltip/formatter-shared/
  6379. * Formatting with shared tooltip
  6380. * @sample {highcharts|highstock} highcharts/tooltip/formatter-split/
  6381. * Formatting with split tooltip
  6382. * @sample highcharts/tooltip/formatter-conditional-default/
  6383. * Extending default formatter
  6384. * @sample {highstock} stock/tooltip/formatter/
  6385. * Formatting with shared tooltip
  6386. * @sample {highmaps} maps/tooltip/formatter/
  6387. * String formatting
  6388. *
  6389. * @type {Highcharts.TooltipFormatterCallbackFunction}
  6390. * @apioption tooltip.formatter
  6391. */
  6392. /**
  6393. * Callback function to format the text of the tooltip for
  6394. * visible null points.
  6395. * Works analogously to [formatter](#tooltip.formatter).
  6396. *
  6397. * @sample highcharts/plotoptions/series-nullformat
  6398. * Format data label and tooltip for null point.
  6399. *
  6400. * @type {Highcharts.TooltipFormatterCallbackFunction}
  6401. * @apioption tooltip.nullFormatter
  6402. */
  6403. /**
  6404. * The number of milliseconds to wait until the tooltip is hidden when
  6405. * mouse out from a point or chart.
  6406. *
  6407. * @type {number}
  6408. * @default 500
  6409. * @since 3.0
  6410. * @apioption tooltip.hideDelay
  6411. */
  6412. /**
  6413. * Whether to allow the tooltip to render outside the chart's SVG
  6414. * element box. By default (`false`), the tooltip is rendered within the
  6415. * chart's SVG element, which results in the tooltip being aligned
  6416. * inside the chart area. For small charts, this may result in clipping
  6417. * or overlapping. When `true`, a separate SVG element is created and
  6418. * overlaid on the page, allowing the tooltip to be aligned inside the
  6419. * page itself.
  6420. *
  6421. * Defaults to `true` if `chart.scrollablePlotArea` is activated,
  6422. * otherwise `false`.
  6423. *
  6424. * @sample highcharts/tooltip/outside
  6425. * Small charts with tooltips outside
  6426. *
  6427. * @type {boolean|undefined}
  6428. * @default undefined
  6429. * @since 6.1.1
  6430. * @apioption tooltip.outside
  6431. */
  6432. /**
  6433. * A callback function for formatting the HTML output for a single point
  6434. * in the tooltip. Like the `pointFormat` string, but with more
  6435. * flexibility.
  6436. *
  6437. * @type {Highcharts.FormatterCallbackFunction<Highcharts.Point>}
  6438. * @since 4.1.0
  6439. * @context Highcharts.Point
  6440. * @apioption tooltip.pointFormatter
  6441. */
  6442. /**
  6443. * A callback function to place the tooltip in a default position. The
  6444. * callback receives three parameters: `labelWidth`, `labelHeight` and
  6445. * `point`, where point contains values for `plotX` and `plotY` telling
  6446. * where the reference point is in the plot area. Add `chart.plotLeft`
  6447. * and `chart.plotTop` to get the full coordinates.
  6448. *
  6449. * Since v7, when [tooltip.split](#tooltip.split) option is enabled,
  6450. * positioner is called for each of the boxes separately, including
  6451. * xAxis header. xAxis header is not a point, instead `point` argument
  6452. * contains info:
  6453. * `{ plotX: Number, plotY: Number, isHeader: Boolean }`
  6454. *
  6455. *
  6456. * The return should be an object containing x and y values, for example
  6457. * `{ x: 100, y: 100 }`.
  6458. *
  6459. * @sample {highcharts} highcharts/tooltip/positioner/
  6460. * A fixed tooltip position
  6461. * @sample {highstock} stock/tooltip/positioner/
  6462. * A fixed tooltip position on top of the chart
  6463. * @sample {highmaps} maps/tooltip/positioner/
  6464. * A fixed tooltip position
  6465. * @sample {highstock} stock/tooltip/split-positioner/
  6466. * Split tooltip with fixed positions
  6467. * @sample {highstock} stock/tooltip/positioner-scrollable-plotarea/
  6468. * Scrollable plot area combined with tooltip positioner
  6469. *
  6470. * @type {Highcharts.TooltipPositionerCallbackFunction}
  6471. * @since 2.2.4
  6472. * @apioption tooltip.positioner
  6473. */
  6474. /**
  6475. * The name of a symbol to use for the border around the tooltip. Can
  6476. * be one of: `"callout"`, `"circle"` or `"rect"`. When
  6477. * [tooltip.split](#tooltip.split)
  6478. * option is enabled, shape is applied to all boxes except header, which
  6479. * is controlled by
  6480. * [tooltip.headerShape](#tooltip.headerShape).
  6481. *
  6482. * Custom callbacks for symbol path generation can also be added to
  6483. * `Highcharts.SVGRenderer.prototype.symbols` the same way as for
  6484. * [series.marker.symbol](plotOptions.line.marker.symbol).
  6485. *
  6486. * @type {Highcharts.TooltipShapeValue}
  6487. * @default callout
  6488. * @since 4.0
  6489. * @apioption tooltip.shape
  6490. */
  6491. /**
  6492. * The name of a symbol to use for the border around the tooltip
  6493. * header. Applies only when [tooltip.split](#tooltip.split) is
  6494. * enabled.
  6495. *
  6496. * Custom callbacks for symbol path generation can also be added to
  6497. * `Highcharts.SVGRenderer.prototype.symbols` the same way as for
  6498. * [series.marker.symbol](plotOptions.line.marker.symbol).
  6499. *
  6500. * @see [tooltip.shape](#tooltip.shape)
  6501. *
  6502. * @sample {highstock} stock/tooltip/split-positioner/
  6503. * Different shapes for header and split boxes
  6504. *
  6505. * @type {Highcharts.TooltipShapeValue}
  6506. * @default callout
  6507. * @validvalue ["callout", "square"]
  6508. * @since 7.0
  6509. * @apioption tooltip.headerShape
  6510. */
  6511. /**
  6512. * When the tooltip is shared, the entire plot area will capture mouse
  6513. * movement or touch events. Tooltip texts for series types with ordered
  6514. * data (not pie, scatter, flags etc) will be shown in a single bubble.
  6515. * This is recommended for single series charts and for tablet/mobile
  6516. * optimized charts.
  6517. *
  6518. * See also [tooltip.split](#tooltip.split), that is better suited for
  6519. * charts with many series, especially line-type series. The
  6520. * `tooltip.split` option takes precedence over `tooltip.shared`.
  6521. *
  6522. * @sample {highcharts} highcharts/tooltip/shared-false/
  6523. * False by default
  6524. * @sample {highcharts} highcharts/tooltip/shared-true/
  6525. * True
  6526. * @sample {highcharts} highcharts/tooltip/shared-x-crosshair/
  6527. * True with x axis crosshair
  6528. * @sample {highcharts} highcharts/tooltip/shared-true-mixed-types/
  6529. * True with mixed series types
  6530. *
  6531. * @type {boolean}
  6532. * @default false
  6533. * @since 2.1
  6534. * @product highcharts highstock
  6535. * @apioption tooltip.shared
  6536. */
  6537. /**
  6538. * Split the tooltip into one label per series, with the header close
  6539. * to the axis. This is recommended over [shared](#tooltip.shared)
  6540. * tooltips for charts with multiple line series, generally making them
  6541. * easier to read. This option takes precedence over `tooltip.shared`.
  6542. *
  6543. * @productdesc {highstock} In Highcharts Stock, tooltips are split
  6544. * by default since v6.0.0. Stock charts typically contain
  6545. * multi-dimension points and multiple panes, making split tooltips
  6546. * the preferred layout over
  6547. * the previous `shared` tooltip.
  6548. *
  6549. * @sample highcharts/tooltip/split/
  6550. * Split tooltip
  6551. * @sample {highcharts|highstock} highcharts/tooltip/formatter-split/
  6552. * Split tooltip and custom formatter callback
  6553. *
  6554. * @type {boolean}
  6555. * @default {highcharts} false
  6556. * @default {highstock} true
  6557. * @since 5.0.0
  6558. * @product highcharts highstock
  6559. * @apioption tooltip.split
  6560. */
  6561. /**
  6562. * Prevents the tooltip from switching or closing, when touched or
  6563. * pointed.
  6564. *
  6565. * @sample highcharts/tooltip/stickoncontact/
  6566. * Tooltip sticks on pointer contact
  6567. *
  6568. * @type {boolean}
  6569. * @since 8.0.1
  6570. * @apioption tooltip.stickOnContact
  6571. */
  6572. /**
  6573. * Use HTML to render the contents of the tooltip instead of SVG. Using
  6574. * HTML allows advanced formatting like tables and images in the
  6575. * tooltip. It is also recommended for rtl languages as it works around
  6576. * rtl bugs in early Firefox.
  6577. *
  6578. * @sample {highcharts|highstock} highcharts/tooltip/footerformat/
  6579. * A table for value alignment
  6580. * @sample {highcharts|highstock} highcharts/tooltip/fullhtml/
  6581. * Full HTML tooltip
  6582. * @sample {highmaps} maps/tooltip/usehtml/
  6583. * Pure HTML tooltip
  6584. *
  6585. * @type {boolean}
  6586. * @default false
  6587. * @since 2.2
  6588. * @apioption tooltip.useHTML
  6589. */
  6590. /**
  6591. * How many decimals to show in each series' y value. This is
  6592. * overridable in each series' tooltip options object. The default is to
  6593. * preserve all decimals.
  6594. *
  6595. * @sample {highcharts|highstock} highcharts/tooltip/valuedecimals/
  6596. * Set decimals, prefix and suffix for the value
  6597. * @sample {highmaps} maps/tooltip/valuedecimals/
  6598. * Set decimals, prefix and suffix for the value
  6599. *
  6600. * @type {number}
  6601. * @since 2.2
  6602. * @apioption tooltip.valueDecimals
  6603. */
  6604. /**
  6605. * A string to prepend to each series' y value. Overridable in each
  6606. * series' tooltip options object.
  6607. *
  6608. * @sample {highcharts|highstock} highcharts/tooltip/valuedecimals/
  6609. * Set decimals, prefix and suffix for the value
  6610. * @sample {highmaps} maps/tooltip/valuedecimals/
  6611. * Set decimals, prefix and suffix for the value
  6612. *
  6613. * @type {string}
  6614. * @since 2.2
  6615. * @apioption tooltip.valuePrefix
  6616. */
  6617. /**
  6618. * A string to append to each series' y value. Overridable in each
  6619. * series' tooltip options object.
  6620. *
  6621. * @sample {highcharts|highstock} highcharts/tooltip/valuedecimals/
  6622. * Set decimals, prefix and suffix for the value
  6623. * @sample {highmaps} maps/tooltip/valuedecimals/
  6624. * Set decimals, prefix and suffix for the value
  6625. *
  6626. * @type {string}
  6627. * @since 2.2
  6628. * @apioption tooltip.valueSuffix
  6629. */
  6630. /**
  6631. * The format for the date in the tooltip header if the X axis is a
  6632. * datetime axis. The default is a best guess based on the smallest
  6633. * distance between points in the chart.
  6634. *
  6635. * @sample {highcharts} highcharts/tooltip/xdateformat/
  6636. * A different format
  6637. *
  6638. * @type {string}
  6639. * @product highcharts highstock gantt
  6640. * @apioption tooltip.xDateFormat
  6641. */
  6642. /**
  6643. * How many decimals to show for the `point.change` value when the
  6644. * `series.compare` option is set. This is overridable in each series'
  6645. * tooltip options object. The default is to preserve all decimals.
  6646. *
  6647. * @type {number}
  6648. * @since 1.0.1
  6649. * @product highstock
  6650. * @apioption tooltip.changeDecimals
  6651. */
  6652. /**
  6653. * Enable or disable the tooltip.
  6654. *
  6655. * @sample {highcharts} highcharts/tooltip/enabled/
  6656. * Disabled
  6657. * @sample {highcharts} highcharts/plotoptions/series-point-events-mouseover/
  6658. * Disable tooltip and show values on chart instead
  6659. */
  6660. enabled: true,
  6661. /**
  6662. * Enable or disable animation of the tooltip.
  6663. *
  6664. * @type {boolean}
  6665. * @default true
  6666. * @since 2.3.0
  6667. */
  6668. animation: svg,
  6669. /**
  6670. * The radius of the rounded border corners.
  6671. *
  6672. * @sample {highcharts} highcharts/tooltip/bordercolor-default/
  6673. * 5px by default
  6674. * @sample {highcharts} highcharts/tooltip/borderradius-0/
  6675. * Square borders
  6676. * @sample {highmaps} maps/tooltip/background-border/
  6677. * Background and border demo
  6678. */
  6679. borderRadius: 3,
  6680. /**
  6681. * For series on datetime axes, the date format in the tooltip's
  6682. * header will by default be guessed based on the closest data points.
  6683. * This member gives the default string representations used for
  6684. * each unit. For an overview of the replacement codes, see
  6685. * [dateFormat](/class-reference/Highcharts#.dateFormat).
  6686. *
  6687. * @see [xAxis.dateTimeLabelFormats](#xAxis.dateTimeLabelFormats)
  6688. *
  6689. * @type {Highcharts.Dictionary<string>}
  6690. * @product highcharts highstock gantt
  6691. */
  6692. dateTimeLabelFormats: {
  6693. /** @internal */
  6694. millisecond: '%A, %b %e, %H:%M:%S.%L',
  6695. /** @internal */
  6696. second: '%A, %b %e, %H:%M:%S',
  6697. /** @internal */
  6698. minute: '%A, %b %e, %H:%M',
  6699. /** @internal */
  6700. hour: '%A, %b %e, %H:%M',
  6701. /** @internal */
  6702. day: '%A, %b %e, %Y',
  6703. /** @internal */
  6704. week: 'Week from %A, %b %e, %Y',
  6705. /** @internal */
  6706. month: '%B %Y',
  6707. /** @internal */
  6708. year: '%Y'
  6709. },
  6710. /**
  6711. * A string to append to the tooltip format.
  6712. *
  6713. * @sample {highcharts} highcharts/tooltip/footerformat/
  6714. * A table for value alignment
  6715. * @sample {highmaps} maps/tooltip/format/
  6716. * Format demo
  6717. *
  6718. * @since 2.2
  6719. */
  6720. footerFormat: '',
  6721. /**
  6722. * Padding inside the tooltip, in pixels.
  6723. *
  6724. * @since 5.0.0
  6725. */
  6726. padding: 8,
  6727. /**
  6728. * Proximity snap for graphs or single points. It defaults to 10 for
  6729. * mouse-powered devices and 25 for touch devices.
  6730. *
  6731. * Note that in most cases the whole plot area captures the mouse
  6732. * movement, and in these cases `tooltip.snap` doesn't make sense. This
  6733. * applies when [stickyTracking](#plotOptions.series.stickyTracking)
  6734. * is `true` (default) and when the tooltip is [shared](#tooltip.shared)
  6735. * or [split](#tooltip.split).
  6736. *
  6737. * @sample {highcharts} highcharts/tooltip/bordercolor-default/
  6738. * 10 px by default
  6739. * @sample {highcharts} highcharts/tooltip/snap-50/
  6740. * 50 px on graph
  6741. *
  6742. * @type {number}
  6743. * @default 10/25
  6744. * @since 1.2.0
  6745. * @product highcharts highstock
  6746. */
  6747. snap: isTouchDevice ? 25 : 10,
  6748. /**
  6749. * The HTML of the tooltip header line. Variables are enclosed by
  6750. * curly brackets. Available variables are `point.key`, `series.name`,
  6751. * `series.color` and other members from the `point` and `series`
  6752. * objects. The `point.key` variable contains the category name, x
  6753. * value or datetime string depending on the type of axis. For datetime
  6754. * axes, the `point.key` date format can be set using
  6755. * `tooltip.xDateFormat`.
  6756. *
  6757. * @sample {highcharts} highcharts/tooltip/footerformat/
  6758. * An HTML table in the tooltip
  6759. * @sample {highstock} highcharts/tooltip/footerformat/
  6760. * An HTML table in the tooltip
  6761. * @sample {highmaps} maps/tooltip/format/
  6762. * Format demo
  6763. *
  6764. * @type {string}
  6765. * @apioption tooltip.headerFormat
  6766. */
  6767. headerFormat: '<span style="font-size: 10px">{point.key}</span><br/>',
  6768. /**
  6769. * The HTML of the null point's line in the tooltip. Works analogously
  6770. * to [pointFormat](#tooltip.pointFormat).
  6771. *
  6772. * @sample {highcharts} highcharts/plotoptions/series-nullformat
  6773. * Format data label and tooltip for null point.
  6774. *
  6775. * @type {string}
  6776. * @apioption tooltip.nullFormat
  6777. */
  6778. /**
  6779. * The HTML of the point's line in the tooltip. Variables are enclosed
  6780. * by curly brackets. Available variables are `point.x`, `point.y`,
  6781. * `series.name` and `series.color` and other properties on the same
  6782. * form. Furthermore, `point.y` can be extended by the
  6783. * `tooltip.valuePrefix` and `tooltip.valueSuffix` variables. This can
  6784. * also be overridden for each series, which makes it a good hook for
  6785. * displaying units.
  6786. *
  6787. * In styled mode, the dot is colored by a class name rather
  6788. * than the point color.
  6789. *
  6790. * @sample {highcharts} highcharts/tooltip/pointformat/
  6791. * A different point format with value suffix
  6792. * @sample {highmaps} maps/tooltip/format/
  6793. * Format demo
  6794. *
  6795. * @type {string}
  6796. * @since 2.2
  6797. * @apioption tooltip.pointFormat
  6798. */
  6799. pointFormat: '<span style="color:{point.color}">\u25CF</span> {series.name}: <b>{point.y}</b><br/>',
  6800. /**
  6801. * The background color or gradient for the tooltip.
  6802. *
  6803. * In styled mode, the stroke width is set in the
  6804. * `.highcharts-tooltip-box` class.
  6805. *
  6806. * @sample {highcharts} highcharts/tooltip/backgroundcolor-solid/
  6807. * Yellowish background
  6808. * @sample {highcharts} highcharts/tooltip/backgroundcolor-gradient/
  6809. * Gradient
  6810. * @sample {highcharts} highcharts/css/tooltip-border-background/
  6811. * Tooltip in styled mode
  6812. * @sample {highstock} stock/tooltip/general/
  6813. * Custom tooltip
  6814. * @sample {highstock} highcharts/css/tooltip-border-background/
  6815. * Tooltip in styled mode
  6816. * @sample {highmaps} maps/tooltip/background-border/
  6817. * Background and border demo
  6818. * @sample {highmaps} highcharts/css/tooltip-border-background/
  6819. * Tooltip in styled mode
  6820. *
  6821. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  6822. */
  6823. backgroundColor: color(palette.neutralColor3)
  6824. .setOpacity(0.85).get(),
  6825. /**
  6826. * The pixel width of the tooltip border.
  6827. *
  6828. * In styled mode, the stroke width is set in the
  6829. * `.highcharts-tooltip-box` class.
  6830. *
  6831. * @sample {highcharts} highcharts/tooltip/bordercolor-default/
  6832. * 2px by default
  6833. * @sample {highcharts} highcharts/tooltip/borderwidth/
  6834. * No border (shadow only)
  6835. * @sample {highcharts} highcharts/css/tooltip-border-background/
  6836. * Tooltip in styled mode
  6837. * @sample {highstock} stock/tooltip/general/
  6838. * Custom tooltip
  6839. * @sample {highstock} highcharts/css/tooltip-border-background/
  6840. * Tooltip in styled mode
  6841. * @sample {highmaps} maps/tooltip/background-border/
  6842. * Background and border demo
  6843. * @sample {highmaps} highcharts/css/tooltip-border-background/
  6844. * Tooltip in styled mode
  6845. */
  6846. borderWidth: 1,
  6847. /**
  6848. * Whether to apply a drop shadow to the tooltip.
  6849. *
  6850. * @sample {highcharts} highcharts/tooltip/bordercolor-default/
  6851. * True by default
  6852. * @sample {highcharts} highcharts/tooltip/shadow/
  6853. * False
  6854. * @sample {highmaps} maps/tooltip/positioner/
  6855. * Fixed tooltip position, border and shadow disabled
  6856. *
  6857. * @type {boolean|Highcharts.ShadowOptionsObject}
  6858. */
  6859. shadow: true,
  6860. /**
  6861. * CSS styles for the tooltip. The tooltip can also be styled through
  6862. * the CSS class `.highcharts-tooltip`.
  6863. *
  6864. * Note that the default `pointerEvents` style makes the tooltip ignore
  6865. * mouse events, so in order to use clickable tooltips, this value must
  6866. * be set to `auto`.
  6867. *
  6868. * @sample {highcharts} highcharts/tooltip/style/
  6869. * Greater padding, bold text
  6870. *
  6871. * @type {Highcharts.CSSObject}
  6872. */
  6873. style: {
  6874. /** @internal */
  6875. color: palette.neutralColor80,
  6876. /** @internal */
  6877. cursor: 'default',
  6878. /** @internal */
  6879. fontSize: '12px',
  6880. /** @internal */
  6881. whiteSpace: 'nowrap'
  6882. }
  6883. },
  6884. /**
  6885. * Highchart by default puts a credits label in the lower right corner
  6886. * of the chart. This can be changed using these options.
  6887. */
  6888. credits: {
  6889. /**
  6890. * Credits for map source to be concatenated with conventional credit
  6891. * text. By default this is a format string that collects copyright
  6892. * information from the map if available.
  6893. *
  6894. * @see [mapTextFull](#credits.mapTextFull)
  6895. * @see [text](#credits.text)
  6896. *
  6897. * @type {string}
  6898. * @default \u00a9 <a href="{geojson.copyrightUrl}">{geojson.copyrightShort}</a>
  6899. * @since 4.2.2
  6900. * @product highmaps
  6901. * @apioption credits.mapText
  6902. */
  6903. /**
  6904. * Detailed credits for map source to be displayed on hover of credits
  6905. * text. By default this is a format string that collects copyright
  6906. * information from the map if available.
  6907. *
  6908. * @see [mapText](#credits.mapText)
  6909. * @see [text](#credits.text)
  6910. *
  6911. * @type {string}
  6912. * @default {geojson.copyright}
  6913. * @since 4.2.2
  6914. * @product highmaps
  6915. * @apioption credits.mapTextFull
  6916. */
  6917. /**
  6918. * Whether to show the credits text.
  6919. *
  6920. * @sample {highcharts} highcharts/credits/enabled-false/
  6921. * Credits disabled
  6922. * @sample {highstock} stock/credits/enabled/
  6923. * Credits disabled
  6924. * @sample {highmaps} maps/credits/enabled-false/
  6925. * Credits disabled
  6926. */
  6927. enabled: true,
  6928. /**
  6929. * The URL for the credits label.
  6930. *
  6931. * @sample {highcharts} highcharts/credits/href/
  6932. * Custom URL and text
  6933. * @sample {highmaps} maps/credits/customized/
  6934. * Custom URL and text
  6935. */
  6936. href: 'https://www.highcharts.com?credits',
  6937. /**
  6938. * Position configuration for the credits label.
  6939. *
  6940. * @sample {highcharts} highcharts/credits/position-left/
  6941. * Left aligned
  6942. * @sample {highcharts} highcharts/credits/position-left/
  6943. * Left aligned
  6944. * @sample {highmaps} maps/credits/customized/
  6945. * Left aligned
  6946. * @sample {highmaps} maps/credits/customized/
  6947. * Left aligned
  6948. *
  6949. * @type {Highcharts.AlignObject}
  6950. * @since 2.1
  6951. */
  6952. position: {
  6953. /** @internal */
  6954. align: 'right',
  6955. /** @internal */
  6956. x: -10,
  6957. /** @internal */
  6958. verticalAlign: 'bottom',
  6959. /** @internal */
  6960. y: -5
  6961. },
  6962. /**
  6963. * CSS styles for the credits label.
  6964. *
  6965. * @see In styled mode, credits styles can be set with the
  6966. * `.highcharts-credits` class.
  6967. *
  6968. * @type {Highcharts.CSSObject}
  6969. */
  6970. style: {
  6971. /** @internal */
  6972. cursor: 'pointer',
  6973. /** @internal */
  6974. color: palette.neutralColor40,
  6975. /** @internal */
  6976. fontSize: '9px'
  6977. },
  6978. /**
  6979. * The text for the credits label.
  6980. *
  6981. * @productdesc {highmaps}
  6982. * If a map is loaded as GeoJSON, the text defaults to
  6983. * `Highcharts @ {map-credits}`. Otherwise, it defaults to
  6984. * `Highcharts.com`.
  6985. *
  6986. * @sample {highcharts} highcharts/credits/href/
  6987. * Custom URL and text
  6988. * @sample {highmaps} maps/credits/customized/
  6989. * Custom URL and text
  6990. */
  6991. text: 'Highcharts.com'
  6992. }
  6993. };
  6994. /* eslint-disable spaced-comment */
  6995. defaultOptions.chart.styledMode = false;
  6996. '';
  6997. var defaultTime = new Time(merge(defaultOptions.global,
  6998. defaultOptions.time));
  6999. /**
  7000. * Get the updated default options. Until 3.0.7, merely exposing defaultOptions
  7001. * for outside modules wasn't enough because the setOptions method created a new
  7002. * object.
  7003. *
  7004. * @function Highcharts.getOptions
  7005. *
  7006. * @return {Highcharts.Options}
  7007. */
  7008. function getOptions() {
  7009. return defaultOptions;
  7010. }
  7011. /**
  7012. * Merge the default options with custom options and return the new options
  7013. * structure. Commonly used for defining reusable templates.
  7014. *
  7015. * @sample highcharts/global/useutc-false Setting a global option
  7016. * @sample highcharts/members/setoptions Applying a global theme
  7017. *
  7018. * @function Highcharts.setOptions
  7019. *
  7020. * @param {Highcharts.Options} options
  7021. * The new custom chart options.
  7022. *
  7023. * @return {Highcharts.Options}
  7024. * Updated options.
  7025. */
  7026. function setOptions(options) {
  7027. // Copy in the default options
  7028. merge(true, defaultOptions, options);
  7029. // Update the time object
  7030. if (options.time || options.global) {
  7031. if (H.time) {
  7032. H.time.update(merge(defaultOptions.global, defaultOptions.time, options.global, options.time));
  7033. }
  7034. else {
  7035. /**
  7036. * Global `Time` object with default options. Since v6.0.5, time
  7037. * settings can be applied individually for each chart. If no
  7038. * individual settings apply, this `Time` object is shared by all
  7039. * instances.
  7040. *
  7041. * @name Highcharts.time
  7042. * @type {Highcharts.Time}
  7043. */
  7044. H.time = defaultTime;
  7045. }
  7046. }
  7047. return defaultOptions;
  7048. }
  7049. var optionsModule = {
  7050. defaultOptions: defaultOptions,
  7051. defaultTime: defaultTime,
  7052. getOptions: getOptions,
  7053. setOptions: setOptions
  7054. };
  7055. return optionsModule;
  7056. });
  7057. _registerModule(_modules, 'Core/Animation/Fx.js', [_modules['Core/Color/Color.js'], _modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (Color, H, U) {
  7058. /* *
  7059. *
  7060. * (c) 2010-2021 Torstein Honsi
  7061. *
  7062. * License: www.highcharts.com/license
  7063. *
  7064. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  7065. *
  7066. * */
  7067. var color = Color.parse;
  7068. var win = H.win;
  7069. var isNumber = U.isNumber,
  7070. objectEach = U.objectEach;
  7071. /* eslint-disable no-invalid-this, valid-jsdoc */
  7072. /**
  7073. * An animator object used internally. One instance applies to one property
  7074. * (attribute or style prop) on one element. Animation is always initiated
  7075. * through {@link SVGElement#animate}.
  7076. *
  7077. * @example
  7078. * let rect = renderer.rect(0, 0, 10, 10).add();
  7079. * rect.animate({ width: 100 });
  7080. *
  7081. * @private
  7082. * @class
  7083. * @name Highcharts.Fx
  7084. */
  7085. var Fx = /** @class */ (function () {
  7086. /* *
  7087. *
  7088. * Constructors
  7089. *
  7090. * */
  7091. /**
  7092. *
  7093. * @param {Highcharts.HTMLDOMElement|Highcharts.SVGElement} elem
  7094. * The element to animate.
  7095. *
  7096. * @param {Partial<Highcharts.AnimationOptionsObject>} options
  7097. * Animation options.
  7098. *
  7099. * @param {string} prop
  7100. * The single attribute or CSS property to animate.
  7101. */
  7102. function Fx(elem, options, prop) {
  7103. this.pos = NaN;
  7104. this.options = options;
  7105. this.elem = elem;
  7106. this.prop = prop;
  7107. }
  7108. /* *
  7109. *
  7110. * Functions
  7111. *
  7112. * */
  7113. /**
  7114. * Set the current step of a path definition on SVGElement.
  7115. *
  7116. * @function Highcharts.Fx#dSetter
  7117. *
  7118. * @return {void}
  7119. */
  7120. Fx.prototype.dSetter = function () {
  7121. var paths = this.paths,
  7122. start = paths && paths[0],
  7123. end = paths && paths[1],
  7124. now = this.now || 0;
  7125. var path = [];
  7126. // Land on the final path without adjustment points appended in the ends
  7127. if (now === 1 || !start || !end) {
  7128. path = this.toD || [];
  7129. }
  7130. else if (start.length === end.length && now < 1) {
  7131. for (var i = 0; i < end.length; i++) {
  7132. // Tween between the start segment and the end segment. Start
  7133. // with a copy of the end segment and tween the appropriate
  7134. // numerics
  7135. var startSeg = start[i];
  7136. var endSeg = end[i];
  7137. var tweenSeg = [];
  7138. for (var j = 0; j < endSeg.length; j++) {
  7139. var startItem = startSeg[j];
  7140. var endItem = endSeg[j];
  7141. // Tween numbers
  7142. if (isNumber(startItem) &&
  7143. isNumber(endItem) &&
  7144. // Arc boolean flags
  7145. !(endSeg[0] === 'A' && (j === 4 || j === 5))) {
  7146. tweenSeg[j] = startItem + now * (endItem - startItem);
  7147. // Strings, take directly from the end segment
  7148. }
  7149. else {
  7150. tweenSeg[j] = endItem;
  7151. }
  7152. }
  7153. path.push(tweenSeg);
  7154. }
  7155. // If animation is finished or length not matching, land on right value
  7156. }
  7157. else {
  7158. path = end;
  7159. }
  7160. this.elem.attr('d', path, void 0, true);
  7161. };
  7162. /**
  7163. * Update the element with the current animation step.
  7164. *
  7165. * @function Highcharts.Fx#update
  7166. *
  7167. * @return {void}
  7168. */
  7169. Fx.prototype.update = function () {
  7170. var elem = this.elem,
  7171. prop = this.prop, // if destroyed, it is null
  7172. now = this.now,
  7173. step = this.options.step;
  7174. // Animation setter defined from outside
  7175. if (this[prop + 'Setter']) {
  7176. this[prop + 'Setter']();
  7177. // Other animations on SVGElement
  7178. }
  7179. else if (elem.attr) {
  7180. if (elem.element) {
  7181. elem.attr(prop, now, null, true);
  7182. }
  7183. // HTML styles, raw HTML content like container size
  7184. }
  7185. else {
  7186. elem.style[prop] = now + this.unit;
  7187. }
  7188. if (step) {
  7189. step.call(elem, now, this);
  7190. }
  7191. };
  7192. /**
  7193. * Run an animation.
  7194. *
  7195. * @function Highcharts.Fx#run
  7196. *
  7197. * @param {number} from
  7198. * The current value, value to start from.
  7199. *
  7200. * @param {number} to
  7201. * The end value, value to land on.
  7202. *
  7203. * @param {string} unit
  7204. * The property unit, for example `px`.
  7205. *
  7206. * @return {void}
  7207. */
  7208. Fx.prototype.run = function (from, to, unit) {
  7209. var self = this,
  7210. options = self.options,
  7211. timer = function (gotoEnd) {
  7212. return timer.stopped ? false : self.step(gotoEnd);
  7213. }, requestAnimationFrame = win.requestAnimationFrame ||
  7214. function (step) {
  7215. setTimeout(step, 13);
  7216. }, step = function () {
  7217. for (var i = 0; i < Fx.timers.length; i++) {
  7218. if (!Fx.timers[i]()) {
  7219. Fx.timers.splice(i--, 1);
  7220. }
  7221. }
  7222. if (Fx.timers.length) {
  7223. requestAnimationFrame(step);
  7224. }
  7225. };
  7226. if (from === to && !this.elem['forceAnimate:' + this.prop]) {
  7227. delete options.curAnim[this.prop];
  7228. if (options.complete && Object.keys(options.curAnim).length === 0) {
  7229. options.complete.call(this.elem);
  7230. }
  7231. }
  7232. else { // #7166
  7233. this.startTime = +new Date();
  7234. this.start = from;
  7235. this.end = to;
  7236. this.unit = unit;
  7237. this.now = this.start;
  7238. this.pos = 0;
  7239. timer.elem = this.elem;
  7240. timer.prop = this.prop;
  7241. if (timer() && Fx.timers.push(timer) === 1) {
  7242. requestAnimationFrame(step);
  7243. }
  7244. }
  7245. };
  7246. /**
  7247. * Run a single step in the animation.
  7248. *
  7249. * @function Highcharts.Fx#step
  7250. *
  7251. * @param {boolean} [gotoEnd]
  7252. * Whether to go to the endpoint of the animation after abort.
  7253. *
  7254. * @return {boolean}
  7255. * Returns `true` if animation continues.
  7256. */
  7257. Fx.prototype.step = function (gotoEnd) {
  7258. var t = +new Date(),
  7259. options = this.options,
  7260. elem = this.elem,
  7261. complete = options.complete,
  7262. duration = options.duration,
  7263. curAnim = options.curAnim;
  7264. var ret,
  7265. done;
  7266. if (elem.attr && !elem.element) { // #2616, element is destroyed
  7267. ret = false;
  7268. }
  7269. else if (gotoEnd || t >= duration + this.startTime) {
  7270. this.now = this.end;
  7271. this.pos = 1;
  7272. this.update();
  7273. curAnim[this.prop] = true;
  7274. done = true;
  7275. objectEach(curAnim, function (val) {
  7276. if (val !== true) {
  7277. done = false;
  7278. }
  7279. });
  7280. if (done && complete) {
  7281. complete.call(elem);
  7282. }
  7283. ret = false;
  7284. }
  7285. else {
  7286. this.pos = options.easing((t - this.startTime) / duration);
  7287. this.now = this.start + ((this.end - this.start) * this.pos);
  7288. this.update();
  7289. ret = true;
  7290. }
  7291. return ret;
  7292. };
  7293. /**
  7294. * Prepare start and end values so that the path can be animated one to one.
  7295. *
  7296. * @function Highcharts.Fx#initPath
  7297. *
  7298. * @param {Highcharts.SVGElement} elem
  7299. * The SVGElement item.
  7300. *
  7301. * @param {Highcharts.SVGPathArray|undefined} fromD
  7302. * Starting path definition.
  7303. *
  7304. * @param {Highcharts.SVGPathArray} toD
  7305. * Ending path definition.
  7306. *
  7307. * @return {Array<Highcharts.SVGPathArray,Highcharts.SVGPathArray>}
  7308. * An array containing start and end paths in array form so that
  7309. * they can be animated in parallel.
  7310. */
  7311. Fx.prototype.initPath = function (elem, fromD, toD) {
  7312. var startX = elem.startX,
  7313. endX = elem.endX,
  7314. end = toD.slice(), // copy
  7315. isArea = elem.isArea,
  7316. positionFactor = isArea ? 2 : 1;
  7317. var shift,
  7318. fullLength,
  7319. i,
  7320. reverse,
  7321. start = fromD && fromD.slice(); // copy
  7322. if (!start) {
  7323. return [end,
  7324. end];
  7325. }
  7326. /**
  7327. * If shifting points, prepend a dummy point to the end path.
  7328. * @private
  7329. * @param {Highcharts.SVGPathArray} arr - array
  7330. * @param {Highcharts.SVGPathArray} other - array
  7331. * @return {void}
  7332. */
  7333. function prepend(arr, other) {
  7334. while (arr.length < fullLength) {
  7335. // Move to, line to or curve to?
  7336. var moveSegment = arr[0],
  7337. otherSegment = other[fullLength - arr.length];
  7338. if (otherSegment && moveSegment[0] === 'M') {
  7339. if (otherSegment[0] === 'C') {
  7340. arr[0] = [
  7341. 'C',
  7342. moveSegment[1],
  7343. moveSegment[2],
  7344. moveSegment[1],
  7345. moveSegment[2],
  7346. moveSegment[1],
  7347. moveSegment[2]
  7348. ];
  7349. }
  7350. else {
  7351. arr[0] = ['L', moveSegment[1], moveSegment[2]];
  7352. }
  7353. }
  7354. // Prepend a copy of the first point
  7355. arr.unshift(moveSegment);
  7356. // For areas, the bottom path goes back again to the left, so we
  7357. // need to append a copy of the last point.
  7358. if (isArea) {
  7359. var z = arr.pop();
  7360. arr.push(arr[arr.length - 1], z); // append point and the Z
  7361. }
  7362. }
  7363. }
  7364. /**
  7365. * Copy and append last point until the length matches the end length.
  7366. * @private
  7367. * @param {Highcharts.SVGPathArray} arr - array
  7368. * @param {Highcharts.SVGPathArray} other - array
  7369. * @return {void}
  7370. */
  7371. function append(arr, other) {
  7372. while (arr.length < fullLength) {
  7373. // Pull out the slice that is going to be appended or inserted.
  7374. // In a line graph, the positionFactor is 1, and the last point
  7375. // is sliced out. In an area graph, the positionFactor is 2,
  7376. // causing the middle two points to be sliced out, since an area
  7377. // path starts at left, follows the upper path then turns and
  7378. // follows the bottom back.
  7379. var segmentToAdd = arr[Math.floor(arr.length / positionFactor) - 1].slice();
  7380. // Disable the first control point of curve segments
  7381. if (segmentToAdd[0] === 'C') {
  7382. segmentToAdd[1] = segmentToAdd[5];
  7383. segmentToAdd[2] = segmentToAdd[6];
  7384. }
  7385. if (!isArea) {
  7386. arr.push(segmentToAdd);
  7387. }
  7388. else {
  7389. var lowerSegmentToAdd = arr[Math.floor(arr.length / positionFactor)].slice();
  7390. arr.splice(arr.length / 2, 0, segmentToAdd, lowerSegmentToAdd);
  7391. }
  7392. }
  7393. }
  7394. // For sideways animation, find out how much we need to shift to get the
  7395. // start path Xs to match the end path Xs.
  7396. if (startX && endX && endX.length) {
  7397. for (i = 0; i < startX.length; i++) {
  7398. // Moving left, new points coming in on right
  7399. if (startX[i] === endX[0]) {
  7400. shift = i;
  7401. break;
  7402. // Moving right
  7403. }
  7404. else if (startX[0] ===
  7405. endX[endX.length - startX.length + i]) {
  7406. shift = i;
  7407. reverse = true;
  7408. break;
  7409. // Fixed from the right side, "scaling" left
  7410. }
  7411. else if (startX[startX.length - 1] ===
  7412. endX[endX.length - startX.length + i]) {
  7413. shift = startX.length - i;
  7414. break;
  7415. }
  7416. }
  7417. if (typeof shift === 'undefined') {
  7418. start = [];
  7419. }
  7420. }
  7421. if (start.length && isNumber(shift)) {
  7422. // The common target length for the start and end array, where both
  7423. // arrays are padded in opposite ends
  7424. fullLength = end.length + shift * positionFactor;
  7425. if (!reverse) {
  7426. prepend(end, start);
  7427. append(start, end);
  7428. }
  7429. else {
  7430. prepend(start, end);
  7431. append(end, start);
  7432. }
  7433. }
  7434. return [start, end];
  7435. };
  7436. /**
  7437. * Handle animation of the color attributes directly.
  7438. *
  7439. * @function Highcharts.Fx#fillSetter
  7440. *
  7441. * @return {void}
  7442. */
  7443. Fx.prototype.fillSetter = function () {
  7444. Fx.prototype.strokeSetter.apply(this, arguments);
  7445. };
  7446. /**
  7447. * Handle animation of the color attributes directly.
  7448. *
  7449. * @function Highcharts.Fx#strokeSetter
  7450. *
  7451. * @return {void}
  7452. */
  7453. Fx.prototype.strokeSetter = function () {
  7454. this.elem.attr(this.prop, color(this.start).tweenTo(color(this.end), this.pos), null, true);
  7455. };
  7456. /* *
  7457. *
  7458. * Static properties
  7459. *
  7460. * */
  7461. Fx.timers = [];
  7462. return Fx;
  7463. }());
  7464. /* *
  7465. *
  7466. * Default Export
  7467. *
  7468. * */
  7469. return Fx;
  7470. });
  7471. _registerModule(_modules, 'Core/Animation/AnimationUtilities.js', [_modules['Core/Animation/Fx.js'], _modules['Core/Utilities.js']], function (Fx, U) {
  7472. /* *
  7473. *
  7474. * (c) 2010-2021 Torstein Honsi
  7475. *
  7476. * License: www.highcharts.com/license
  7477. *
  7478. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  7479. *
  7480. * */
  7481. var defined = U.defined,
  7482. getStyle = U.getStyle,
  7483. isArray = U.isArray,
  7484. isNumber = U.isNumber,
  7485. isObject = U.isObject,
  7486. merge = U.merge,
  7487. objectEach = U.objectEach,
  7488. pick = U.pick;
  7489. /**
  7490. * Set the global animation to either a given value, or fall back to the given
  7491. * chart's animation option.
  7492. *
  7493. * @function Highcharts.setAnimation
  7494. *
  7495. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>|undefined} animation
  7496. * The animation object.
  7497. *
  7498. * @param {Highcharts.Chart} chart
  7499. * The chart instance.
  7500. *
  7501. * @todo
  7502. * This function always relates to a chart, and sets a property on the renderer,
  7503. * so it should be moved to the SVGRenderer.
  7504. */
  7505. function setAnimation(animation, chart) {
  7506. chart.renderer.globalAnimation = pick(animation, chart.options.chart.animation, true);
  7507. }
  7508. /**
  7509. * Get the animation in object form, where a disabled animation is always
  7510. * returned as `{ duration: 0 }`.
  7511. *
  7512. * @function Highcharts.animObject
  7513. *
  7514. * @param {boolean|Highcharts.AnimationOptionsObject} [animation=0]
  7515. * An animation setting. Can be an object with duration, complete and
  7516. * easing properties, or a boolean to enable or disable.
  7517. *
  7518. * @return {Highcharts.AnimationOptionsObject}
  7519. * An object with at least a duration property.
  7520. */
  7521. function animObject(animation) {
  7522. return isObject(animation) ?
  7523. merge({ duration: 500, defer: 0 }, animation) :
  7524. { duration: animation ? 500 : 0, defer: 0 };
  7525. }
  7526. /**
  7527. * Get the defer as a number value from series animation options.
  7528. *
  7529. * @function Highcharts.getDeferredAnimation
  7530. *
  7531. * @param {Highcharts.Chart} chart
  7532. * The chart instance.
  7533. *
  7534. * @param {boolean|Highcharts.AnimationOptionsObject} animation
  7535. * An animation setting. Can be an object with duration, complete and
  7536. * easing properties, or a boolean to enable or disable.
  7537. *
  7538. * @param {Highcharts.Series} [series]
  7539. * Series to defer animation.
  7540. *
  7541. * @return {number}
  7542. * The numeric value.
  7543. */
  7544. function getDeferredAnimation(chart, animation, series) {
  7545. var labelAnimation = animObject(animation);
  7546. var s = series ? [series] : chart.series;
  7547. var defer = 0;
  7548. var duration = 0;
  7549. s.forEach(function (series) {
  7550. var seriesAnim = animObject(series.options.animation);
  7551. defer = animation && defined(animation.defer) ?
  7552. labelAnimation.defer :
  7553. Math.max(defer, seriesAnim.duration + seriesAnim.defer);
  7554. duration = Math.min(labelAnimation.duration, seriesAnim.duration);
  7555. });
  7556. // Disable defer for exporting
  7557. if (chart.renderer.forExport) {
  7558. defer = 0;
  7559. }
  7560. var anim = {
  7561. defer: Math.max(0,
  7562. defer - duration),
  7563. duration: Math.min(defer,
  7564. duration)
  7565. };
  7566. return anim;
  7567. }
  7568. /**
  7569. * The global animate method, which uses Fx to create individual animators.
  7570. *
  7571. * @function Highcharts.animate
  7572. *
  7573. * @param {Highcharts.HTMLDOMElement|Highcharts.SVGElement} el
  7574. * The element to animate.
  7575. *
  7576. * @param {Highcharts.CSSObject|Highcharts.SVGAttributes} params
  7577. * An object containing key-value pairs of the properties to animate.
  7578. * Supports numeric as pixel-based CSS properties for HTML objects and
  7579. * attributes for SVGElements.
  7580. *
  7581. * @param {Partial<Highcharts.AnimationOptionsObject>} [opt]
  7582. * Animation options.
  7583. *
  7584. * @return {void}
  7585. */
  7586. function animate(el, params, opt) {
  7587. var start,
  7588. unit = '',
  7589. end,
  7590. fx,
  7591. args;
  7592. if (!isObject(opt)) { // Number or undefined/null
  7593. args = arguments;
  7594. opt = {
  7595. duration: args[2],
  7596. easing: args[3],
  7597. complete: args[4]
  7598. };
  7599. }
  7600. if (!isNumber(opt.duration)) {
  7601. opt.duration = 400;
  7602. }
  7603. opt.easing = typeof opt.easing === 'function' ?
  7604. opt.easing :
  7605. (Math[opt.easing] || Math.easeInOutSine);
  7606. opt.curAnim = merge(params);
  7607. objectEach(params, function (val, prop) {
  7608. // Stop current running animation of this property
  7609. stop(el, prop);
  7610. fx = new Fx(el, opt, prop);
  7611. end = void 0;
  7612. if (prop === 'd' && isArray(params.d)) {
  7613. fx.paths = fx.initPath(el, el.pathArray, params.d);
  7614. fx.toD = params.d;
  7615. start = 0;
  7616. end = 1;
  7617. }
  7618. else if (el.attr) {
  7619. start = el.attr(prop);
  7620. }
  7621. else {
  7622. start = parseFloat(getStyle(el, prop)) || 0;
  7623. if (prop !== 'opacity') {
  7624. unit = 'px';
  7625. }
  7626. }
  7627. if (!end) {
  7628. end = val;
  7629. }
  7630. if (typeof end === 'string' && end.match('px')) {
  7631. end = end.replace(/px/g, ''); // #4351
  7632. }
  7633. fx.run(start, end, unit);
  7634. });
  7635. }
  7636. /**
  7637. * Stop running animation.
  7638. *
  7639. * @function Highcharts.stop
  7640. *
  7641. * @param {Highcharts.SVGElement} el
  7642. * The SVGElement to stop animation on.
  7643. *
  7644. * @param {string} [prop]
  7645. * The property to stop animating. If given, the stop method will stop a
  7646. * single property from animating, while others continue.
  7647. *
  7648. * @return {void}
  7649. *
  7650. * @todo
  7651. * A possible extension to this would be to stop a single property, when
  7652. * we want to continue animating others. Then assign the prop to the timer
  7653. * in the Fx.run method, and check for the prop here. This would be an
  7654. * improvement in all cases where we stop the animation from .attr. Instead of
  7655. * stopping everything, we can just stop the actual attributes we're setting.
  7656. */
  7657. function stop(el, prop) {
  7658. var i = Fx.timers.length;
  7659. // Remove timers related to this element (#4519)
  7660. while (i--) {
  7661. if (Fx.timers[i].elem === el && (!prop || prop === Fx.timers[i].prop)) {
  7662. Fx.timers[i].stopped = true; // #4667
  7663. }
  7664. }
  7665. }
  7666. var animationExports = {
  7667. animate: animate,
  7668. animObject: animObject,
  7669. getDeferredAnimation: getDeferredAnimation,
  7670. setAnimation: setAnimation,
  7671. stop: stop
  7672. };
  7673. return animationExports;
  7674. });
  7675. _registerModule(_modules, 'Core/Renderer/HTML/AST.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  7676. /* *
  7677. *
  7678. * (c) 2010-2020 Torstein Honsi
  7679. *
  7680. * License: www.highcharts.com/license
  7681. *
  7682. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  7683. *
  7684. * */
  7685. var SVG_NS = H.SVG_NS;
  7686. var attr = U.attr,
  7687. createElement = U.createElement,
  7688. discardElement = U.discardElement,
  7689. error = U.error,
  7690. isString = U.isString,
  7691. objectEach = U.objectEach,
  7692. splat = U.splat;
  7693. /**
  7694. * Serialized form of an SVG/HTML definition, including children.
  7695. *
  7696. * @interface Highcharts.ASTNode
  7697. */ /**
  7698. * @name Highcharts.ASTNode#attributes
  7699. * @type {Highcharts.SVGAttributes|undefined}
  7700. */ /**
  7701. * @name Highcharts.ASTNode#children
  7702. * @type {Array<Highcharts.ASTNode>|undefined}
  7703. */ /**
  7704. * @name Highcharts.ASTNode#tagName
  7705. * @type {string|undefined}
  7706. */ /**
  7707. * @name Highcharts.ASTNode#textContent
  7708. * @type {string|undefined}
  7709. */
  7710. ''; // detach doclets above
  7711. // In IE8, DOMParser is undefined. IE9 and PhantomJS are only able to parse XML.
  7712. var hasValidDOMParser = false;
  7713. try {
  7714. hasValidDOMParser = Boolean(new DOMParser().parseFromString('', 'text/html'));
  7715. }
  7716. catch (e) { } // eslint-disable-line no-empty
  7717. /**
  7718. * The AST class represents an abstract syntax tree of HTML or SVG content. It
  7719. * can take HTML as an argument, parse it, optionally transform it to SVG, then
  7720. * perform sanitation before inserting it into the DOM.
  7721. *
  7722. * @class
  7723. * @name Highcharts.AST
  7724. * @param {string|Highcharts.ASTNode[]} source
  7725. * Either an HTML string or an ASTNode list
  7726. * to populate the tree
  7727. */
  7728. var AST = /** @class */ (function () {
  7729. // Construct an AST from HTML markup, or wrap an array of existing AST nodes
  7730. function AST(source) {
  7731. this.nodes = typeof source === 'string' ?
  7732. this.parseMarkup(source) : source;
  7733. }
  7734. /**
  7735. * Filter an object of SVG or HTML attributes against the allow list.
  7736. *
  7737. * @static
  7738. *
  7739. * @function Highcharts.AST#filterUserAttributes
  7740. *
  7741. * @param {Highcharts.SVGAttributes} attributes The attributes to filter
  7742. *
  7743. * @return {Highcharts.SVGAttributes}
  7744. * The filtered attributes
  7745. */
  7746. AST.filterUserAttributes = function (attributes) {
  7747. objectEach(attributes, function (val, key) {
  7748. var valid = true;
  7749. if (AST.allowedAttributes.indexOf(key) === -1) {
  7750. valid = false;
  7751. }
  7752. if (['background', 'dynsrc', 'href', 'lowsrc', 'src']
  7753. .indexOf(key) !== -1) {
  7754. valid = isString(val) && AST.allowedReferences.some(function (ref) { return val.indexOf(ref) === 0; });
  7755. }
  7756. if (!valid) {
  7757. error("Highcharts warning: Invalid attribute '" + key + "' in config");
  7758. delete attributes[key];
  7759. }
  7760. });
  7761. return attributes;
  7762. };
  7763. /**
  7764. * Utility function to set html content for an element by passing in a
  7765. * markup string. The markup is safely parsed by the AST class to avoid
  7766. * XSS vulnerabilities. This function should be used instead of setting
  7767. * `innerHTML` in all cases where the content is not fully trusted.
  7768. *
  7769. * @static
  7770. *
  7771. * @function Highcharts.AST#setElementHTML
  7772. *
  7773. * @param {SVGDOMElement|HTMLDOMElement} el The node to set content of
  7774. * @param {string} html The markup string
  7775. */
  7776. AST.setElementHTML = function (el, html) {
  7777. el.innerHTML = ''; // Clear previous
  7778. if (html) {
  7779. var ast = new AST(html);
  7780. ast.addToDOM(el);
  7781. }
  7782. };
  7783. /**
  7784. * Add the tree defined as a hierarchical JS structure to the DOM
  7785. *
  7786. * @function Highcharts.AST#addToDOM
  7787. *
  7788. * @param {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement} parent
  7789. * The node where it should be added
  7790. *
  7791. * @return {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement}
  7792. * The inserted node.
  7793. */
  7794. AST.prototype.addToDOM = function (parent) {
  7795. /**
  7796. * @private
  7797. * @param {Highcharts.ASTNode} subtree - HTML/SVG definition
  7798. * @param {Element} [subParent] - parent node
  7799. * @return {Highcharts.SVGDOMElement|Highcharts.HTMLDOMElement} The inserted node.
  7800. */
  7801. function recurse(subtree, subParent) {
  7802. var ret;
  7803. splat(subtree).forEach(function (item) {
  7804. var tagName = item.tagName;
  7805. var textNode = item.textContent ?
  7806. H.doc.createTextNode(item.textContent) :
  7807. void 0;
  7808. var node;
  7809. if (tagName) {
  7810. if (tagName === '#text') {
  7811. node = textNode;
  7812. }
  7813. else if (AST.allowedTags.indexOf(tagName) !== -1) {
  7814. var NS = tagName === 'svg' ?
  7815. SVG_NS :
  7816. (subParent.namespaceURI || SVG_NS);
  7817. var element = H.doc.createElementNS(NS,
  7818. tagName);
  7819. var attributes_1 = item.attributes || {};
  7820. // Apply attributes from root of AST node, legacy from
  7821. // from before TextBuilder
  7822. objectEach(item, function (val, key) {
  7823. if (key !== 'tagName' &&
  7824. key !== 'attributes' &&
  7825. key !== 'children' &&
  7826. key !== 'textContent') {
  7827. attributes_1[key] = val;
  7828. }
  7829. });
  7830. attr(element, AST.filterUserAttributes(attributes_1));
  7831. // Add text content
  7832. if (textNode) {
  7833. element.appendChild(textNode);
  7834. }
  7835. // Recurse
  7836. recurse(item.children || [], element);
  7837. node = element;
  7838. }
  7839. else {
  7840. error("Highcharts warning: Invalid tagName '" + tagName + "' in config");
  7841. }
  7842. }
  7843. // Add to the tree
  7844. if (node) {
  7845. subParent.appendChild(node);
  7846. }
  7847. ret = node;
  7848. });
  7849. // Return last node added (on top level it's the only one)
  7850. return ret;
  7851. }
  7852. return recurse(this.nodes, parent);
  7853. };
  7854. /**
  7855. * Parse HTML/SVG markup into AST Node objects. Used internally from the
  7856. * constructor.
  7857. *
  7858. * @private
  7859. *
  7860. * @function Highcharts.AST#getNodesFromMarkup
  7861. *
  7862. * @param {string} markup The markup string.
  7863. *
  7864. * @return {Array<Highcharts.ASTNode>} The parsed nodes.
  7865. */
  7866. AST.prototype.parseMarkup = function (markup) {
  7867. var nodes = [];
  7868. var doc;
  7869. var body;
  7870. if (hasValidDOMParser) {
  7871. doc = new DOMParser().parseFromString(markup, 'text/html');
  7872. }
  7873. else {
  7874. body = createElement('div');
  7875. body.innerHTML = markup;
  7876. doc = { body: body };
  7877. }
  7878. var appendChildNodes = function (node,
  7879. addTo) {
  7880. var tagName = node.nodeName.toLowerCase();
  7881. // Add allowed tags
  7882. var astNode = {
  7883. tagName: tagName
  7884. };
  7885. if (tagName === '#text') {
  7886. var textContent = node.textContent || '';
  7887. // Whitespace text node, don't append it to the AST
  7888. if (/^[\s]*$/.test(textContent)) {
  7889. return;
  7890. }
  7891. astNode.textContent = textContent;
  7892. }
  7893. var parsedAttributes = node.attributes;
  7894. // Add attributes
  7895. if (parsedAttributes) {
  7896. var attributes_2 = {};
  7897. [].forEach.call(parsedAttributes, function (attrib) {
  7898. attributes_2[attrib.name] = attrib.value;
  7899. });
  7900. astNode.attributes = attributes_2;
  7901. }
  7902. // Handle children
  7903. if (node.childNodes.length) {
  7904. var children_1 = [];
  7905. [].forEach.call(node.childNodes, function (childNode) {
  7906. appendChildNodes(childNode, children_1);
  7907. });
  7908. if (children_1.length) {
  7909. astNode.children = children_1;
  7910. }
  7911. }
  7912. addTo.push(astNode);
  7913. };
  7914. [].forEach.call(doc.body.childNodes, function (childNode) { return appendChildNodes(childNode, nodes); });
  7915. if (body) {
  7916. discardElement(body);
  7917. }
  7918. return nodes;
  7919. };
  7920. /**
  7921. * The list of allowed SVG or HTML tags, used for sanitizing potentially
  7922. * harmful content from the chart configuration before adding to the DOM.
  7923. *
  7924. * @example
  7925. * // Allow a custom, trusted tag
  7926. * Highcharts.AST.allowedTags.push('blink'); // ;)
  7927. *
  7928. * @name Highcharts.AST.allowedTags
  7929. * @static
  7930. */
  7931. AST.allowedTags = [
  7932. 'a',
  7933. 'b',
  7934. 'br',
  7935. 'button',
  7936. 'caption',
  7937. 'circle',
  7938. 'clipPath',
  7939. 'code',
  7940. 'dd',
  7941. 'defs',
  7942. 'div',
  7943. 'dl',
  7944. 'dt',
  7945. 'em',
  7946. 'feComponentTransfer',
  7947. 'feFuncA',
  7948. 'feFuncB',
  7949. 'feFuncG',
  7950. 'feFuncR',
  7951. 'feGaussianBlur',
  7952. 'feOffset',
  7953. 'feMerge',
  7954. 'feMergeNode',
  7955. 'filter',
  7956. 'h1',
  7957. 'h2',
  7958. 'h3',
  7959. 'h4',
  7960. 'h5',
  7961. 'h6',
  7962. 'hr',
  7963. 'i',
  7964. 'img',
  7965. 'li',
  7966. 'linearGradient',
  7967. 'marker',
  7968. 'ol',
  7969. 'p',
  7970. 'path',
  7971. 'pattern',
  7972. 'pre',
  7973. 'rect',
  7974. 'small',
  7975. 'span',
  7976. 'stop',
  7977. 'strong',
  7978. 'style',
  7979. 'sub',
  7980. 'sup',
  7981. 'svg',
  7982. 'table',
  7983. 'text',
  7984. 'thead',
  7985. 'tbody',
  7986. 'tspan',
  7987. 'td',
  7988. 'th',
  7989. 'tr',
  7990. 'u',
  7991. 'ul',
  7992. '#text'
  7993. ];
  7994. /**
  7995. * The list of allowed SVG or HTML attributes, used for sanitizing
  7996. * potentially harmful content from the chart configuration before adding to
  7997. * the DOM.
  7998. *
  7999. * @example
  8000. * // Allow a custom, trusted attribute
  8001. * Highcharts.AST.allowedAttributes.push('data-value');
  8002. *
  8003. * @name Highcharts.AST.allowedAttributes
  8004. * @static
  8005. */
  8006. AST.allowedAttributes = [
  8007. 'aria-controls',
  8008. 'aria-describedby',
  8009. 'aria-expanded',
  8010. 'aria-haspopup',
  8011. 'aria-hidden',
  8012. 'aria-label',
  8013. 'aria-labelledby',
  8014. 'aria-live',
  8015. 'aria-pressed',
  8016. 'aria-readonly',
  8017. 'aria-roledescription',
  8018. 'aria-selected',
  8019. 'class',
  8020. 'clip-path',
  8021. 'color',
  8022. 'colspan',
  8023. 'cx',
  8024. 'cy',
  8025. 'd',
  8026. 'dx',
  8027. 'dy',
  8028. 'disabled',
  8029. 'fill',
  8030. 'height',
  8031. 'href',
  8032. 'id',
  8033. 'in',
  8034. 'markerHeight',
  8035. 'markerWidth',
  8036. 'offset',
  8037. 'opacity',
  8038. 'orient',
  8039. 'padding',
  8040. 'paddingLeft',
  8041. 'patternUnits',
  8042. 'r',
  8043. 'refX',
  8044. 'refY',
  8045. 'role',
  8046. 'scope',
  8047. 'slope',
  8048. 'src',
  8049. 'startOffset',
  8050. 'stdDeviation',
  8051. 'stroke',
  8052. 'stroke-linecap',
  8053. 'stroke-width',
  8054. 'style',
  8055. 'result',
  8056. 'rowspan',
  8057. 'summary',
  8058. 'target',
  8059. 'tabindex',
  8060. 'text-align',
  8061. 'textAnchor',
  8062. 'textLength',
  8063. 'type',
  8064. 'valign',
  8065. 'width',
  8066. 'x',
  8067. 'x1',
  8068. 'x2',
  8069. 'y',
  8070. 'y1',
  8071. 'y2',
  8072. 'zIndex'
  8073. ];
  8074. /**
  8075. * The list of allowed references for referring attributes like `href` and
  8076. * `src`. Attribute values will only be allowed if they start with one of
  8077. * these strings.
  8078. *
  8079. * @example
  8080. * // Allow tel:
  8081. * Highcharts.AST.allowedReferences.push('tel:');
  8082. *
  8083. * @name Highcharts.AST.allowedReferences
  8084. * @static
  8085. */
  8086. AST.allowedReferences = [
  8087. 'https://',
  8088. 'http://',
  8089. 'mailto:',
  8090. '/',
  8091. '../',
  8092. './',
  8093. '#'
  8094. ];
  8095. return AST;
  8096. }());
  8097. return AST;
  8098. });
  8099. _registerModule(_modules, 'Core/FormatUtilities.js', [_modules['Core/Options.js'], _modules['Core/Utilities.js']], function (O, U) {
  8100. /* *
  8101. *
  8102. * (c) 2010-2021 Torstein Honsi
  8103. *
  8104. * License: www.highcharts.com/license
  8105. *
  8106. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  8107. *
  8108. * */
  8109. var defaultOptions = O.defaultOptions,
  8110. defaultTime = O.defaultTime;
  8111. var getNestedProperty = U.getNestedProperty,
  8112. isNumber = U.isNumber,
  8113. pick = U.pick,
  8114. pInt = U.pInt;
  8115. /* *
  8116. *
  8117. * Functions
  8118. *
  8119. * */
  8120. /**
  8121. * Formats a JavaScript date timestamp (milliseconds since Jan 1st 1970) into a
  8122. * human readable date string. The format is a subset of the formats for PHP's
  8123. * [strftime](https://www.php.net/manual/en/function.strftime.php) function.
  8124. * Additional formats can be given in the {@link Highcharts.dateFormats} hook.
  8125. *
  8126. * Since v6.0.5, all internal dates are formatted through the
  8127. * {@link Highcharts.Chart#time} instance to respect chart-level time settings.
  8128. * The `Highcharts.dateFormat` function only reflects global time settings set
  8129. * with `setOptions`.
  8130. *
  8131. * Supported format keys:
  8132. * - `%a`: Short weekday, like 'Mon'
  8133. * - `%A`: Long weekday, like 'Monday'
  8134. * - `%d`: Two digit day of the month, 01 to 31
  8135. * - `%e`: Day of the month, 1 through 31
  8136. * - `%w`: Day of the week, 0 through 6
  8137. * - `%b`: Short month, like 'Jan'
  8138. * - `%B`: Long month, like 'January'
  8139. * - `%m`: Two digit month number, 01 through 12
  8140. * - `%y`: Two digits year, like 09 for 2009
  8141. * - `%Y`: Four digits year, like 2009
  8142. * - `%H`: Two digits hours in 24h format, 00 through 23
  8143. * - `%k`: Hours in 24h format, 0 through 23
  8144. * - `%I`: Two digits hours in 12h format, 00 through 11
  8145. * - `%l`: Hours in 12h format, 1 through 12
  8146. * - `%M`: Two digits minutes, 00 through 59
  8147. * - `%p`: Upper case AM or PM
  8148. * - `%P`: Lower case AM or PM
  8149. * - `%S`: Two digits seconds, 00 through 59
  8150. * - `%L`: Milliseconds (naming from Ruby)
  8151. *
  8152. * @function Highcharts.dateFormat
  8153. *
  8154. * @param {string} format
  8155. * The desired format where various time representations are prefixed
  8156. * with `%`.
  8157. *
  8158. * @param {number} timestamp
  8159. * The JavaScript timestamp.
  8160. *
  8161. * @param {boolean} [capitalize=false]
  8162. * Upper case first letter in the return.
  8163. *
  8164. * @return {string}
  8165. * The formatted date.
  8166. */
  8167. function dateFormat(format, timestamp, capitalize) {
  8168. return defaultTime.dateFormat(format, timestamp, capitalize);
  8169. }
  8170. /**
  8171. * Format a string according to a subset of the rules of Python's String.format
  8172. * method.
  8173. *
  8174. * @example
  8175. * let s = Highcharts.format(
  8176. * 'The {color} fox was {len:.2f} feet long',
  8177. * { color: 'red', len: Math.PI }
  8178. * );
  8179. * // => The red fox was 3.14 feet long
  8180. *
  8181. * @function Highcharts.format
  8182. *
  8183. * @param {string} str
  8184. * The string to format.
  8185. *
  8186. * @param {Record<string, *>} ctx
  8187. * The context, a collection of key-value pairs where each key is
  8188. * replaced by its value.
  8189. *
  8190. * @param {Highcharts.Chart} [chart]
  8191. * A `Chart` instance used to get numberFormatter and time.
  8192. *
  8193. * @return {string}
  8194. * The formatted string.
  8195. */
  8196. function format(str, ctx, chart) {
  8197. var splitter = '{',
  8198. isInside = false,
  8199. segment,
  8200. valueAndFormat,
  8201. val,
  8202. index;
  8203. var floatRegex = /f$/;
  8204. var decRegex = /\.([0-9])/;
  8205. var lang = defaultOptions.lang;
  8206. var time = chart && chart.time || defaultTime;
  8207. var numberFormatter = chart && chart.numberFormatter || numberFormat;
  8208. var ret = [];
  8209. while (str) {
  8210. index = str.indexOf(splitter);
  8211. if (index === -1) {
  8212. break;
  8213. }
  8214. segment = str.slice(0, index);
  8215. if (isInside) { // we're on the closing bracket looking back
  8216. valueAndFormat = segment.split(':');
  8217. val = getNestedProperty(valueAndFormat.shift() || '', ctx);
  8218. // Format the replacement
  8219. if (valueAndFormat.length && typeof val === 'number') {
  8220. segment = valueAndFormat.join(':');
  8221. if (floatRegex.test(segment)) { // float
  8222. var decimals = parseInt((segment.match(decRegex) || ['', '-1'])[1], 10);
  8223. if (val !== null) {
  8224. val = numberFormatter(val, decimals, lang.decimalPoint, segment.indexOf(',') > -1 ? lang.thousandsSep : '');
  8225. }
  8226. }
  8227. else {
  8228. val = time.dateFormat(segment, val);
  8229. }
  8230. }
  8231. // Push the result and advance the cursor
  8232. ret.push(val);
  8233. }
  8234. else {
  8235. ret.push(segment);
  8236. }
  8237. str = str.slice(index + 1); // the rest
  8238. isInside = !isInside; // toggle
  8239. splitter = isInside ? '}' : '{'; // now look for next matching bracket
  8240. }
  8241. ret.push(str);
  8242. return ret.join('');
  8243. }
  8244. /**
  8245. * Format a number and return a string based on input settings.
  8246. *
  8247. * @sample highcharts/members/highcharts-numberformat/
  8248. * Custom number format
  8249. *
  8250. * @function Highcharts.numberFormat
  8251. *
  8252. * @param {number} number
  8253. * The input number to format.
  8254. *
  8255. * @param {number} decimals
  8256. * The amount of decimals. A value of -1 preserves the amount in the
  8257. * input number.
  8258. *
  8259. * @param {string} [decimalPoint]
  8260. * The decimal point, defaults to the one given in the lang options, or
  8261. * a dot.
  8262. *
  8263. * @param {string} [thousandsSep]
  8264. * The thousands separator, defaults to the one given in the lang
  8265. * options, or a space character.
  8266. *
  8267. * @return {string}
  8268. * The formatted number.
  8269. */
  8270. function numberFormat(number, decimals, decimalPoint, thousandsSep) {
  8271. number = +number || 0;
  8272. decimals = +decimals;
  8273. var ret,
  8274. fractionDigits;
  8275. var lang = defaultOptions.lang, origDec = (number.toString().split('.')[1] || '').split('e')[0].length, exponent = number.toString().split('e'), firstDecimals = decimals;
  8276. if (decimals === -1) {
  8277. // Preserve decimals. Not huge numbers (#3793).
  8278. decimals = Math.min(origDec, 20);
  8279. }
  8280. else if (!isNumber(decimals)) {
  8281. decimals = 2;
  8282. }
  8283. else if (decimals && exponent[1] && exponent[1] < 0) {
  8284. // Expose decimals from exponential notation (#7042)
  8285. fractionDigits = decimals + +exponent[1];
  8286. if (fractionDigits >= 0) {
  8287. // remove too small part of the number while keeping the notation
  8288. exponent[0] = (+exponent[0]).toExponential(fractionDigits)
  8289. .split('e')[0];
  8290. decimals = fractionDigits;
  8291. }
  8292. else {
  8293. // fractionDigits < 0
  8294. exponent[0] = exponent[0].split('.')[0] || 0;
  8295. if (decimals < 20) {
  8296. // use number instead of exponential notation (#7405)
  8297. number = (exponent[0] * Math.pow(10, exponent[1]))
  8298. .toFixed(decimals);
  8299. }
  8300. else {
  8301. // or zero
  8302. number = 0;
  8303. }
  8304. exponent[1] = 0;
  8305. }
  8306. }
  8307. // Add another decimal to avoid rounding errors of float numbers. (#4573)
  8308. // Then use toFixed to handle rounding.
  8309. var roundedNumber = (Math.abs(exponent[1] ? exponent[0] : number) +
  8310. Math.pow(10, -Math.max(decimals,
  8311. origDec) - 1)).toFixed(decimals);
  8312. // A string containing the positive integer component of the number
  8313. var strinteger = String(pInt(roundedNumber));
  8314. // Leftover after grouping into thousands. Can be 0, 1 or 2.
  8315. var thousands = strinteger.length > 3 ? strinteger.length % 3 : 0;
  8316. // Language
  8317. decimalPoint = pick(decimalPoint, lang.decimalPoint);
  8318. thousandsSep = pick(thousandsSep, lang.thousandsSep);
  8319. // Start building the return
  8320. ret = number < 0 ? '-' : '';
  8321. // Add the leftover after grouping into thousands. For example, in the
  8322. // number 42 000 000, this line adds 42.
  8323. ret += thousands ? strinteger.substr(0, thousands) + thousandsSep : '';
  8324. if (+exponent[1] < 0 && !firstDecimals) {
  8325. ret = '0';
  8326. }
  8327. else {
  8328. // Add the remaining thousands groups, joined by the thousands separator
  8329. ret += strinteger
  8330. .substr(thousands)
  8331. .replace(/(\d{3})(?=\d)/g, '$1' + thousandsSep);
  8332. }
  8333. // Add the decimal point and the decimal component
  8334. if (decimals) {
  8335. // Get the decimal component
  8336. ret += decimalPoint + roundedNumber.slice(-decimals);
  8337. }
  8338. if (exponent[1] && +ret !== 0) {
  8339. ret += 'e' + exponent[1];
  8340. }
  8341. return ret;
  8342. }
  8343. /* *
  8344. *
  8345. * Default Export
  8346. *
  8347. * */
  8348. var exports = {
  8349. dateFormat: dateFormat,
  8350. format: format,
  8351. numberFormat: numberFormat
  8352. };
  8353. return exports;
  8354. });
  8355. _registerModule(_modules, 'Core/Renderer/SVG/SVGElement.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Renderer/HTML/AST.js'], _modules['Core/Color/Color.js'], _modules['Core/Globals.js'], _modules['Core/Color/Palette.js'], _modules['Core/Utilities.js']], function (A, AST, Color, H, palette, U) {
  8356. /* *
  8357. *
  8358. * (c) 2010-2021 Torstein Honsi
  8359. *
  8360. * License: www.highcharts.com/license
  8361. *
  8362. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  8363. *
  8364. * */
  8365. var animate = A.animate,
  8366. animObject = A.animObject,
  8367. stop = A.stop;
  8368. var deg2rad = H.deg2rad,
  8369. doc = H.doc,
  8370. hasTouch = H.hasTouch,
  8371. noop = H.noop,
  8372. svg = H.svg,
  8373. SVG_NS = H.SVG_NS,
  8374. win = H.win;
  8375. var addEvent = U.addEvent,
  8376. attr = U.attr,
  8377. createElement = U.createElement,
  8378. css = U.css,
  8379. defined = U.defined,
  8380. erase = U.erase,
  8381. extend = U.extend,
  8382. fireEvent = U.fireEvent,
  8383. isArray = U.isArray,
  8384. isFunction = U.isFunction,
  8385. isNumber = U.isNumber,
  8386. isString = U.isString,
  8387. merge = U.merge,
  8388. objectEach = U.objectEach,
  8389. pick = U.pick,
  8390. pInt = U.pInt,
  8391. syncTimeout = U.syncTimeout,
  8392. uniqueKey = U.uniqueKey;
  8393. /* *
  8394. *
  8395. * Class
  8396. *
  8397. * */
  8398. /* eslint-disable no-invalid-this, valid-jsdoc */
  8399. /**
  8400. * The SVGElement prototype is a JavaScript wrapper for SVG elements used in the
  8401. * rendering layer of Highcharts. Combined with the
  8402. * {@link Highcharts.SVGRenderer}
  8403. * object, these prototypes allow freeform annotation in the charts or even in
  8404. * HTML pages without instanciating a chart. The SVGElement can also wrap HTML
  8405. * labels, when `text` or `label` elements are created with the `useHTML`
  8406. * parameter.
  8407. *
  8408. * The SVGElement instances are created through factory functions on the
  8409. * {@link Highcharts.SVGRenderer}
  8410. * object, like
  8411. * {@link Highcharts.SVGRenderer#rect|rect},
  8412. * {@link Highcharts.SVGRenderer#path|path},
  8413. * {@link Highcharts.SVGRenderer#text|text},
  8414. * {@link Highcharts.SVGRenderer#label|label},
  8415. * {@link Highcharts.SVGRenderer#g|g}
  8416. * and more.
  8417. *
  8418. * @class
  8419. * @name Highcharts.SVGElement
  8420. */
  8421. var SVGElement = /** @class */ (function () {
  8422. function SVGElement() {
  8423. /* *
  8424. *
  8425. * Properties
  8426. *
  8427. * */
  8428. this.element = void 0;
  8429. this.onEvents = {};
  8430. this.opacity = 1; // Default base for animation
  8431. this.renderer = void 0;
  8432. this.SVG_NS = SVG_NS;
  8433. // Custom attributes used for symbols, these should be filtered out when
  8434. // setting SVGElement attributes (#9375).
  8435. this.symbolCustomAttribs = [
  8436. 'x',
  8437. 'y',
  8438. 'width',
  8439. 'height',
  8440. 'r',
  8441. 'start',
  8442. 'end',
  8443. 'innerR',
  8444. 'anchorX',
  8445. 'anchorY',
  8446. 'rounded'
  8447. ];
  8448. }
  8449. // @todo public zIndex?: number;
  8450. /* *
  8451. *
  8452. * Functions
  8453. *
  8454. * */
  8455. /**
  8456. * Get the current value of an attribute or pseudo attribute,
  8457. * used mainly for animation. Called internally from
  8458. * the {@link Highcharts.SVGRenderer#attr} function.
  8459. *
  8460. * @private
  8461. * @function Highcharts.SVGElement#_defaultGetter
  8462. *
  8463. * @param {string} key
  8464. * Property key.
  8465. *
  8466. * @return {number|string}
  8467. * Property value.
  8468. */
  8469. SVGElement.prototype._defaultGetter = function (key) {
  8470. var ret = pick(this[key + 'Value'], // align getter
  8471. this[key],
  8472. this.element ? this.element.getAttribute(key) : null, 0);
  8473. if (/^[\-0-9\.]+$/.test(ret)) { // is numerical
  8474. ret = parseFloat(ret);
  8475. }
  8476. return ret;
  8477. };
  8478. /**
  8479. * @private
  8480. * @function Highcharts.SVGElement#_defaultSetter
  8481. *
  8482. * @param {string} value
  8483. *
  8484. * @param {string} key
  8485. *
  8486. * @param {Highcharts.SVGDOMElement} element
  8487. *
  8488. * @return {void}
  8489. */
  8490. SVGElement.prototype._defaultSetter = function (value, key, element) {
  8491. element.setAttribute(key, value);
  8492. };
  8493. /**
  8494. * Add the element to the DOM. All elements must be added this way.
  8495. *
  8496. * @sample highcharts/members/renderer-g
  8497. * Elements added to a group
  8498. *
  8499. * @function Highcharts.SVGElement#add
  8500. *
  8501. * @param {Highcharts.SVGElement} [parent]
  8502. * The parent item to add it to. If undefined, the element is added
  8503. * to the {@link Highcharts.SVGRenderer.box}.
  8504. *
  8505. * @return {Highcharts.SVGElement}
  8506. * Returns the SVGElement for chaining.
  8507. */
  8508. SVGElement.prototype.add = function (parent) {
  8509. var renderer = this.renderer,
  8510. element = this.element;
  8511. var inserted;
  8512. if (parent) {
  8513. this.parentGroup = parent;
  8514. }
  8515. // Mark as inverted
  8516. this.parentInverted = parent && parent.inverted;
  8517. // Build formatted text
  8518. if (typeof this.textStr !== 'undefined' &&
  8519. this.element.nodeName === 'text' // Not for SVGLabel instances
  8520. ) {
  8521. renderer.buildText(this);
  8522. }
  8523. // Mark as added
  8524. this.added = true;
  8525. // If we're adding to renderer root, or other elements in the group
  8526. // have a z index, we need to handle it
  8527. if (!parent || parent.handleZ || this.zIndex) {
  8528. inserted = this.zIndexSetter();
  8529. }
  8530. // If zIndex is not handled, append at the end
  8531. if (!inserted) {
  8532. (parent ?
  8533. parent.element :
  8534. renderer.box).appendChild(element);
  8535. }
  8536. // fire an event for internal hooks
  8537. if (this.onAdd) {
  8538. this.onAdd();
  8539. }
  8540. return this;
  8541. };
  8542. /**
  8543. * Add a class name to an element.
  8544. *
  8545. * @function Highcharts.SVGElement#addClass
  8546. *
  8547. * @param {string} className
  8548. * The new class name to add.
  8549. *
  8550. * @param {boolean} [replace=false]
  8551. * When true, the existing class name(s) will be overwritten with the new
  8552. * one. When false, the new one is added.
  8553. *
  8554. * @return {Highcharts.SVGElement}
  8555. * Return the SVG element for chainability.
  8556. */
  8557. SVGElement.prototype.addClass = function (className, replace) {
  8558. var currentClassName = replace ? '' : (this.attr('class') || '');
  8559. // Trim the string and remove duplicates
  8560. className = (className || '')
  8561. .split(/ /g)
  8562. .reduce(function (newClassName, name) {
  8563. if (currentClassName.indexOf(name) === -1) {
  8564. newClassName.push(name);
  8565. }
  8566. return newClassName;
  8567. }, (currentClassName ?
  8568. [currentClassName] :
  8569. []))
  8570. .join(' ');
  8571. if (className !== currentClassName) {
  8572. this.attr('class', className);
  8573. }
  8574. return this;
  8575. };
  8576. /**
  8577. * This method is executed in the end of `attr()`, after setting all
  8578. * attributes in the hash. In can be used to efficiently consolidate
  8579. * multiple attributes in one SVG property -- e.g., translate, rotate and
  8580. * scale are merged in one "transform" attribute in the SVG node.
  8581. *
  8582. * @private
  8583. * @function Highcharts.SVGElement#afterSetters
  8584. */
  8585. SVGElement.prototype.afterSetters = function () {
  8586. // Update transform. Do this outside the loop to prevent redundant
  8587. // updating for batch setting of attributes.
  8588. if (this.doTransform) {
  8589. this.updateTransform();
  8590. this.doTransform = false;
  8591. }
  8592. };
  8593. /**
  8594. * Align the element relative to the chart or another box.
  8595. *
  8596. * @function Highcharts.SVGElement#align
  8597. *
  8598. * @param {Highcharts.AlignObject} [alignOptions]
  8599. * The alignment options. The function can be called without this
  8600. * parameter in order to re-align an element after the box has been
  8601. * updated.
  8602. *
  8603. * @param {boolean} [alignByTranslate]
  8604. * Align element by translation.
  8605. *
  8606. * @param {string|Highcharts.BBoxObject} [box]
  8607. * The box to align to, needs a width and height. When the box is a
  8608. * string, it refers to an object in the Renderer. For example, when
  8609. * box is `spacingBox`, it refers to `Renderer.spacingBox` which
  8610. * holds `width`, `height`, `x` and `y` properties.
  8611. *
  8612. * @return {Highcharts.SVGElement} Returns the SVGElement for chaining.
  8613. */
  8614. SVGElement.prototype.align = function (alignOptions, alignByTranslate, box) {
  8615. var attribs = {},
  8616. renderer = this.renderer,
  8617. alignedObjects = renderer.alignedObjects;
  8618. var x,
  8619. y,
  8620. alignTo,
  8621. alignFactor,
  8622. vAlignFactor;
  8623. // First call on instanciate
  8624. if (alignOptions) {
  8625. this.alignOptions = alignOptions;
  8626. this.alignByTranslate = alignByTranslate;
  8627. if (!box || isString(box)) {
  8628. this.alignTo = alignTo = box || 'renderer';
  8629. // prevent duplicates, like legendGroup after resize
  8630. erase(alignedObjects, this);
  8631. alignedObjects.push(this);
  8632. box = void 0; // reassign it below
  8633. }
  8634. // When called on resize, no arguments are supplied
  8635. }
  8636. else {
  8637. alignOptions = this.alignOptions;
  8638. alignByTranslate = this.alignByTranslate;
  8639. alignTo = this.alignTo;
  8640. }
  8641. box = pick(box, renderer[alignTo], alignTo === 'scrollablePlotBox' ? renderer.plotBox : void 0, renderer);
  8642. // Assign variables
  8643. var align = alignOptions.align,
  8644. vAlign = alignOptions.verticalAlign;
  8645. // default: left align
  8646. x = (box.x || 0) + (alignOptions.x || 0);
  8647. // default: top align
  8648. y = (box.y || 0) + (alignOptions.y || 0);
  8649. // Align
  8650. if (align === 'right') {
  8651. alignFactor = 1;
  8652. }
  8653. else if (align === 'center') {
  8654. alignFactor = 2;
  8655. }
  8656. if (alignFactor) {
  8657. x += (box.width - (alignOptions.width || 0)) /
  8658. alignFactor;
  8659. }
  8660. attribs[alignByTranslate ? 'translateX' : 'x'] = Math.round(x);
  8661. // Vertical align
  8662. if (vAlign === 'bottom') {
  8663. vAlignFactor = 1;
  8664. }
  8665. else if (vAlign === 'middle') {
  8666. vAlignFactor = 2;
  8667. }
  8668. if (vAlignFactor) {
  8669. y += (box.height - (alignOptions.height || 0)) /
  8670. vAlignFactor;
  8671. }
  8672. attribs[alignByTranslate ? 'translateY' : 'y'] = Math.round(y);
  8673. // Animate only if already placed
  8674. this[this.placed ? 'animate' : 'attr'](attribs);
  8675. this.placed = true;
  8676. this.alignAttr = attribs;
  8677. return this;
  8678. };
  8679. /**
  8680. * @private
  8681. * @function Highcharts.SVGElement#alignSetter
  8682. * @param {"left"|"center"|"right"} value
  8683. */
  8684. SVGElement.prototype.alignSetter = function (value) {
  8685. var convert = {
  8686. left: 'start',
  8687. center: 'middle',
  8688. right: 'end'
  8689. };
  8690. if (convert[value]) {
  8691. this.alignValue = value;
  8692. this.element.setAttribute('text-anchor', convert[value]);
  8693. }
  8694. };
  8695. /**
  8696. * Animate to given attributes or CSS properties.
  8697. *
  8698. * @sample highcharts/members/element-on/
  8699. * Setting some attributes by animation
  8700. *
  8701. * @function Highcharts.SVGElement#animate
  8702. *
  8703. * @param {Highcharts.SVGAttributes} params
  8704. * SVG attributes or CSS to animate.
  8705. *
  8706. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [options]
  8707. * Animation options.
  8708. *
  8709. * @param {Function} [complete]
  8710. * Function to perform at the end of animation.
  8711. *
  8712. * @return {Highcharts.SVGElement}
  8713. * Returns the SVGElement for chaining.
  8714. */
  8715. SVGElement.prototype.animate = function (params, options, complete) {
  8716. var _this = this;
  8717. var animOptions = animObject(pick(options,
  8718. this.renderer.globalAnimation,
  8719. true)),
  8720. deferTime = animOptions.defer;
  8721. // When the page is hidden save resources in the background by not
  8722. // running animation at all (#9749).
  8723. if (pick(doc.hidden, doc.msHidden, doc.webkitHidden, false)) {
  8724. animOptions.duration = 0;
  8725. }
  8726. if (animOptions.duration !== 0) {
  8727. // allows using a callback with the global animation without
  8728. // overwriting it
  8729. if (complete) {
  8730. animOptions.complete = complete;
  8731. }
  8732. // If defer option is defined delay the animation #12901
  8733. syncTimeout(function () {
  8734. if (_this.element) {
  8735. animate(_this, params, animOptions);
  8736. }
  8737. }, deferTime);
  8738. }
  8739. else {
  8740. this.attr(params, void 0, complete);
  8741. // Call the end step synchronously
  8742. objectEach(params, function (val, prop) {
  8743. if (animOptions.step) {
  8744. animOptions.step.call(this, val, { prop: prop, pos: 1, elem: this });
  8745. }
  8746. }, this);
  8747. }
  8748. return this;
  8749. };
  8750. /**
  8751. * Apply a text outline through a custom CSS property, by copying the text
  8752. * element and apply stroke to the copy. Used internally. Contrast checks at
  8753. * [example](https://jsfiddle.net/highcharts/43soe9m1/2/).
  8754. *
  8755. * @example
  8756. * // Specific color
  8757. * text.css({
  8758. * textOutline: '1px black'
  8759. * });
  8760. * // Automatic contrast
  8761. * text.css({
  8762. * color: '#000000', // black text
  8763. * textOutline: '1px contrast' // => white outline
  8764. * });
  8765. *
  8766. * @private
  8767. * @function Highcharts.SVGElement#applyTextOutline
  8768. *
  8769. * @param {string} textOutline
  8770. * A custom CSS `text-outline` setting, defined by `width color`.
  8771. */
  8772. SVGElement.prototype.applyTextOutline = function (textOutline) {
  8773. var elem = this.element,
  8774. hasContrast = textOutline.indexOf('contrast') !== -1,
  8775. styles = {};
  8776. // When the text shadow is set to contrast, use dark stroke for light
  8777. // text and vice versa.
  8778. if (hasContrast) {
  8779. styles.textOutline = textOutline = textOutline.replace(/contrast/g, this.renderer.getContrast(elem.style.fill));
  8780. }
  8781. // Extract the stroke width and color
  8782. var parts = textOutline.split(' ');
  8783. var color = parts[parts.length - 1];
  8784. var strokeWidth = parts[0];
  8785. if (strokeWidth && strokeWidth !== 'none' && H.svg) {
  8786. this.fakeTS = true; // Fake text shadow
  8787. // In order to get the right y position of the clone,
  8788. // copy over the y setter
  8789. this.ySetter = this.xSetter;
  8790. // Since the stroke is applied on center of the actual outline, we
  8791. // need to double it to get the correct stroke-width outside the
  8792. // glyphs.
  8793. strokeWidth = strokeWidth.replace(/(^[\d\.]+)(.*?)$/g, function (match, digit, unit) {
  8794. return (2 * Number(digit)) + unit;
  8795. });
  8796. // Remove shadows from previous runs.
  8797. this.removeTextOutline();
  8798. var outline_1 = doc.createElementNS(SVG_NS, 'tspan');
  8799. attr(outline_1, {
  8800. 'class': 'highcharts-text-outline',
  8801. fill: color,
  8802. stroke: color,
  8803. 'stroke-width': strokeWidth,
  8804. 'stroke-linejoin': 'round'
  8805. });
  8806. // For each of the tspans and text nodes, create a copy in the
  8807. // outline.
  8808. [].forEach.call(elem.childNodes, function (childNode) {
  8809. var clone = childNode.cloneNode(true);
  8810. if (clone.removeAttribute) {
  8811. ['fill', 'stroke', 'stroke-width', 'stroke'].forEach(function (prop) { return clone.removeAttribute(prop); });
  8812. }
  8813. outline_1.appendChild(clone);
  8814. });
  8815. // Insert an absolutely positioned break before the original text
  8816. // to keep it in place
  8817. var br_1 = doc.createElementNS(SVG_NS, 'tspan');
  8818. br_1.textContent = '\u200B';
  8819. // Copy x and y if not null
  8820. ['x', 'y'].forEach(function (key) {
  8821. var value = elem.getAttribute(key);
  8822. if (value) {
  8823. br_1.setAttribute(key, value);
  8824. }
  8825. });
  8826. // Insert the outline
  8827. outline_1.appendChild(br_1);
  8828. elem.insertBefore(outline_1, elem.firstChild);
  8829. }
  8830. };
  8831. /**
  8832. * @function Highcharts.SVGElement#attr
  8833. * @param {string} key
  8834. * @return {number|string}
  8835. */ /**
  8836. * Apply native and custom attributes to the SVG elements.
  8837. *
  8838. * In order to set the rotation center for rotation, set x and y to 0 and
  8839. * use `translateX` and `translateY` attributes to position the element
  8840. * instead.
  8841. *
  8842. * Attributes frequently used in Highcharts are `fill`, `stroke`,
  8843. * `stroke-width`.
  8844. *
  8845. * @sample highcharts/members/renderer-rect/
  8846. * Setting some attributes
  8847. *
  8848. * @example
  8849. * // Set multiple attributes
  8850. * element.attr({
  8851. * stroke: 'red',
  8852. * fill: 'blue',
  8853. * x: 10,
  8854. * y: 10
  8855. * });
  8856. *
  8857. * // Set a single attribute
  8858. * element.attr('stroke', 'red');
  8859. *
  8860. * // Get an attribute
  8861. * element.attr('stroke'); // => 'red'
  8862. *
  8863. * @function Highcharts.SVGElement#attr
  8864. *
  8865. * @param {string|Highcharts.SVGAttributes} [hash]
  8866. * The native and custom SVG attributes.
  8867. *
  8868. * @param {number|string|Highcharts.SVGPathArray} [val]
  8869. * If the type of the first argument is `string`, the second can be a
  8870. * value, which will serve as a single attribute setter. If the first
  8871. * argument is a string and the second is undefined, the function
  8872. * serves as a getter and the current value of the property is
  8873. * returned.
  8874. *
  8875. * @param {Function} [complete]
  8876. * A callback function to execute after setting the attributes. This
  8877. * makes the function compliant and interchangeable with the
  8878. * {@link SVGElement#animate} function.
  8879. *
  8880. * @param {boolean} [continueAnimation=true]
  8881. * Used internally when `.attr` is called as part of an animation
  8882. * step. Otherwise, calling `.attr` for an attribute will stop
  8883. * animation for that attribute.
  8884. *
  8885. * @return {Highcharts.SVGElement}
  8886. * If used as a setter, it returns the current
  8887. * {@link Highcharts.SVGElement} so the calls can be chained. If
  8888. * used as a getter, the current value of the attribute is returned.
  8889. */
  8890. SVGElement.prototype.attr = function (hash, val, complete, continueAnimation) {
  8891. var element = this.element,
  8892. symbolCustomAttribs = this.symbolCustomAttribs;
  8893. var key,
  8894. hasSetSymbolSize,
  8895. ret = this,
  8896. skipAttr,
  8897. setter;
  8898. // single key-value pair
  8899. if (typeof hash === 'string' && typeof val !== 'undefined') {
  8900. key = hash;
  8901. hash = {};
  8902. hash[key] = val;
  8903. }
  8904. // used as a getter: first argument is a string, second is undefined
  8905. if (typeof hash === 'string') {
  8906. ret = (this[hash + 'Getter'] ||
  8907. this._defaultGetter).call(this, hash, element);
  8908. // setter
  8909. }
  8910. else {
  8911. objectEach(hash, function eachAttribute(val, key) {
  8912. skipAttr = false;
  8913. // Unless .attr is from the animator update, stop current
  8914. // running animation of this property
  8915. if (!continueAnimation) {
  8916. stop(this, key);
  8917. }
  8918. // Special handling of symbol attributes
  8919. if (this.symbolName &&
  8920. symbolCustomAttribs.indexOf(key) !== -1) {
  8921. if (!hasSetSymbolSize) {
  8922. this.symbolAttr(hash);
  8923. hasSetSymbolSize = true;
  8924. }
  8925. skipAttr = true;
  8926. }
  8927. if (this.rotation && (key === 'x' || key === 'y')) {
  8928. this.doTransform = true;
  8929. }
  8930. if (!skipAttr) {
  8931. setter = (this[key + 'Setter'] ||
  8932. this._defaultSetter);
  8933. setter.call(this, val, key, element);
  8934. // Let the shadow follow the main element
  8935. if (!this.styledMode &&
  8936. this.shadows &&
  8937. /^(width|height|visibility|x|y|d|transform|cx|cy|r)$/.test(key)) {
  8938. this.updateShadows(key, val, setter);
  8939. }
  8940. }
  8941. }, this);
  8942. this.afterSetters();
  8943. }
  8944. // In accordance with animate, run a complete callback
  8945. if (complete) {
  8946. complete.call(this);
  8947. }
  8948. return ret;
  8949. };
  8950. /**
  8951. * Apply a clipping rectangle to this element.
  8952. *
  8953. * @function Highcharts.SVGElement#clip
  8954. *
  8955. * @param {Highcharts.ClipRectElement} [clipRect]
  8956. * The clipping rectangle. If skipped, the current clip is removed.
  8957. *
  8958. * @return {Highcharts.SVGElement}
  8959. * Returns the SVG element to allow chaining.
  8960. */
  8961. SVGElement.prototype.clip = function (clipRect) {
  8962. return this.attr('clip-path', clipRect ?
  8963. 'url(' + this.renderer.url + '#' + clipRect.id + ')' :
  8964. 'none');
  8965. };
  8966. /**
  8967. * Calculate the coordinates needed for drawing a rectangle crisply and
  8968. * return the calculated attributes.
  8969. *
  8970. * @function Highcharts.SVGElement#crisp
  8971. *
  8972. * @param {Highcharts.RectangleObject} rect
  8973. * Rectangle to crisp.
  8974. *
  8975. * @param {number} [strokeWidth]
  8976. * The stroke width to consider when computing crisp positioning. It can
  8977. * also be set directly on the rect parameter.
  8978. *
  8979. * @return {Highcharts.RectangleObject}
  8980. * The modified rectangle arguments.
  8981. */
  8982. SVGElement.prototype.crisp = function (rect, strokeWidth) {
  8983. var wrapper = this;
  8984. strokeWidth = strokeWidth || rect.strokeWidth || 0;
  8985. // Math.round because strokeWidth can sometimes have roundoff errors
  8986. var normalizer = Math.round(strokeWidth) % 2 / 2;
  8987. // normalize for crisp edges
  8988. rect.x = Math.floor(rect.x || wrapper.x || 0) + normalizer;
  8989. rect.y = Math.floor(rect.y || wrapper.y || 0) + normalizer;
  8990. rect.width = Math.floor((rect.width || wrapper.width || 0) - 2 * normalizer);
  8991. rect.height = Math.floor((rect.height || wrapper.height || 0) - 2 * normalizer);
  8992. if (defined(rect.strokeWidth)) {
  8993. rect.strokeWidth = strokeWidth;
  8994. }
  8995. return rect;
  8996. };
  8997. /**
  8998. * Build and apply an SVG gradient out of a common JavaScript configuration
  8999. * object. This function is called from the attribute setters. An event
  9000. * hook is added for supporting other complex color types.
  9001. *
  9002. * @private
  9003. * @function Highcharts.SVGElement#complexColor
  9004. *
  9005. * @param {Highcharts.GradientColorObject|Highcharts.PatternObject} colorOptions
  9006. * The gradient or pattern options structure.
  9007. *
  9008. * @param {string} prop
  9009. * The property to apply, can either be `fill` or `stroke`.
  9010. *
  9011. * @param {Highcharts.SVGDOMElement} elem
  9012. * SVG element to apply the gradient on.
  9013. */
  9014. SVGElement.prototype.complexColor = function (colorOptions, prop, elem) {
  9015. var renderer = this.renderer;
  9016. var colorObject,
  9017. gradName,
  9018. gradAttr,
  9019. radAttr,
  9020. gradients,
  9021. stops,
  9022. stopColor,
  9023. stopOpacity,
  9024. radialReference,
  9025. id,
  9026. key = [],
  9027. value;
  9028. fireEvent(this.renderer, 'complexColor', {
  9029. args: arguments
  9030. }, function () {
  9031. // Apply linear or radial gradients
  9032. if (colorOptions.radialGradient) {
  9033. gradName = 'radialGradient';
  9034. }
  9035. else if (colorOptions.linearGradient) {
  9036. gradName = 'linearGradient';
  9037. }
  9038. if (gradName) {
  9039. gradAttr = colorOptions[gradName];
  9040. gradients = renderer.gradients;
  9041. stops = colorOptions.stops;
  9042. radialReference = elem.radialReference;
  9043. // Keep < 2.2 kompatibility
  9044. if (isArray(gradAttr)) {
  9045. colorOptions[gradName] = gradAttr = {
  9046. x1: gradAttr[0],
  9047. y1: gradAttr[1],
  9048. x2: gradAttr[2],
  9049. y2: gradAttr[3],
  9050. gradientUnits: 'userSpaceOnUse'
  9051. };
  9052. }
  9053. // Correct the radial gradient for the radial reference system
  9054. if (gradName === 'radialGradient' &&
  9055. radialReference &&
  9056. !defined(gradAttr.gradientUnits)) {
  9057. // Save the radial attributes for updating
  9058. radAttr = gradAttr;
  9059. gradAttr = merge(gradAttr, renderer.getRadialAttr(radialReference, radAttr), { gradientUnits: 'userSpaceOnUse' });
  9060. }
  9061. // Build the unique key to detect whether we need to create a
  9062. // new element (#1282)
  9063. objectEach(gradAttr, function (value, n) {
  9064. if (n !== 'id') {
  9065. key.push(n, value);
  9066. }
  9067. });
  9068. objectEach(stops, function (val) {
  9069. key.push(val);
  9070. });
  9071. key = key.join(',');
  9072. // Check if a gradient object with the same config object is
  9073. // created within this renderer
  9074. if (gradients[key]) {
  9075. id = gradients[key].attr('id');
  9076. }
  9077. else {
  9078. // Set the id and create the element
  9079. gradAttr.id = id = uniqueKey();
  9080. var gradientObject_1 = gradients[key] =
  9081. renderer.createElement(gradName)
  9082. .attr(gradAttr)
  9083. .add(renderer.defs);
  9084. gradientObject_1.radAttr = radAttr;
  9085. // The gradient needs to keep a list of stops to be able to
  9086. // destroy them
  9087. gradientObject_1.stops = [];
  9088. stops.forEach(function (stop) {
  9089. if (stop[1].indexOf('rgba') === 0) {
  9090. colorObject = Color.parse(stop[1]);
  9091. stopColor = colorObject.get('rgb');
  9092. stopOpacity = colorObject.get('a');
  9093. }
  9094. else {
  9095. stopColor = stop[1];
  9096. stopOpacity = 1;
  9097. }
  9098. var stopObject = renderer.createElement('stop').attr({
  9099. offset: stop[0],
  9100. 'stop-color': stopColor,
  9101. 'stop-opacity': stopOpacity
  9102. }).add(gradientObject_1);
  9103. // Add the stop element to the gradient
  9104. gradientObject_1.stops.push(stopObject);
  9105. });
  9106. }
  9107. // Set the reference to the gradient object
  9108. value = 'url(' + renderer.url + '#' + id + ')';
  9109. elem.setAttribute(prop, value);
  9110. elem.gradient = key;
  9111. // Allow the color to be concatenated into tooltips formatters
  9112. // etc. (#2995)
  9113. colorOptions.toString = function () {
  9114. return value;
  9115. };
  9116. }
  9117. });
  9118. };
  9119. /**
  9120. * Set styles for the element. In addition to CSS styles supported by
  9121. * native SVG and HTML elements, there are also some custom made for
  9122. * Highcharts, like `width`, `ellipsis` and `textOverflow` for SVG text
  9123. * elements.
  9124. *
  9125. * @sample highcharts/members/renderer-text-on-chart/
  9126. * Styled text
  9127. *
  9128. * @function Highcharts.SVGElement#css
  9129. *
  9130. * @param {Highcharts.CSSObject} styles
  9131. * The new CSS styles.
  9132. *
  9133. * @return {Highcharts.SVGElement}
  9134. * Return the SVG element for chaining.
  9135. */
  9136. SVGElement.prototype.css = function (styles) {
  9137. var oldStyles = this.styles, newStyles = {}, elem = this.element,
  9138. // These CSS properties are interpreted internally by the SVG
  9139. // renderer, but are not supported by SVG and should not be added to
  9140. // the DOM. In styled mode, no CSS should find its way to the DOM
  9141. // whatsoever (#6173, #6474).
  9142. svgPseudoProps = ['textOutline', 'textOverflow', 'width'];
  9143. var textWidth,
  9144. serializedCss = '',
  9145. hyphenate,
  9146. hasNew = !oldStyles;
  9147. // convert legacy
  9148. if (styles && styles.color) {
  9149. styles.fill = styles.color;
  9150. }
  9151. // Filter out existing styles to increase performance (#2640)
  9152. if (oldStyles) {
  9153. objectEach(styles, function (style, n) {
  9154. if (oldStyles && oldStyles[n] !== style) {
  9155. newStyles[n] = style;
  9156. hasNew = true;
  9157. }
  9158. });
  9159. }
  9160. if (hasNew) {
  9161. // Merge the new styles with the old ones
  9162. if (oldStyles) {
  9163. styles = extend(oldStyles, newStyles);
  9164. }
  9165. // Get the text width from style
  9166. if (styles) {
  9167. // Previously set, unset it (#8234)
  9168. if (styles.width === null || styles.width === 'auto') {
  9169. delete this.textWidth;
  9170. // Apply new
  9171. }
  9172. else if (elem.nodeName.toLowerCase() === 'text' &&
  9173. styles.width) {
  9174. textWidth = this.textWidth = pInt(styles.width);
  9175. }
  9176. }
  9177. // store object
  9178. this.styles = styles;
  9179. if (textWidth && (!svg && this.renderer.forExport)) {
  9180. delete styles.width;
  9181. }
  9182. // Serialize and set style attribute
  9183. if (elem.namespaceURI === this.SVG_NS) { // #7633
  9184. hyphenate = function (a, b) {
  9185. return '-' + b.toLowerCase();
  9186. };
  9187. objectEach(styles, function (style, n) {
  9188. if (svgPseudoProps.indexOf(n) === -1) {
  9189. serializedCss +=
  9190. n.replace(/([A-Z])/g, hyphenate) + ':' +
  9191. style + ';';
  9192. }
  9193. });
  9194. if (serializedCss) {
  9195. attr(elem, 'style', serializedCss); // #1881
  9196. }
  9197. }
  9198. else {
  9199. css(elem, styles);
  9200. }
  9201. if (this.added) {
  9202. // Rebuild text after added. Cache mechanisms in the buildText
  9203. // will prevent building if there are no significant changes.
  9204. if (this.element.nodeName === 'text') {
  9205. this.renderer.buildText(this);
  9206. }
  9207. // Apply text outline after added
  9208. if (styles && styles.textOutline) {
  9209. this.applyTextOutline(styles.textOutline);
  9210. }
  9211. }
  9212. }
  9213. return this;
  9214. };
  9215. /**
  9216. * @private
  9217. * @function Highcharts.SVGElement#dashstyleSetter
  9218. * @param {string} value
  9219. */
  9220. SVGElement.prototype.dashstyleSetter = function (value) {
  9221. var i,
  9222. strokeWidth = this['stroke-width'];
  9223. // If "inherit", like maps in IE, assume 1 (#4981). With HC5 and the new
  9224. // strokeWidth function, we should be able to use that instead.
  9225. if (strokeWidth === 'inherit') {
  9226. strokeWidth = 1;
  9227. }
  9228. value = value && value.toLowerCase();
  9229. if (value) {
  9230. var v = value
  9231. .replace('shortdashdotdot', '3,1,1,1,1,1,')
  9232. .replace('shortdashdot', '3,1,1,1')
  9233. .replace('shortdot', '1,1,')
  9234. .replace('shortdash', '3,1,')
  9235. .replace('longdash', '8,3,')
  9236. .replace(/dot/g, '1,3,')
  9237. .replace('dash', '4,3,')
  9238. .replace(/,$/, '')
  9239. .split(','); // ending comma
  9240. i = v.length;
  9241. while (i--) {
  9242. v[i] = '' + (pInt(v[i]) * pick(strokeWidth, NaN));
  9243. }
  9244. value = v.join(',').replace(/NaN/g, 'none'); // #3226
  9245. this.element.setAttribute('stroke-dasharray', value);
  9246. }
  9247. };
  9248. /**
  9249. * Destroy the element and element wrapper and clear up the DOM and event
  9250. * hooks.
  9251. *
  9252. * @function Highcharts.SVGElement#destroy
  9253. */
  9254. SVGElement.prototype.destroy = function () {
  9255. var wrapper = this,
  9256. element = wrapper.element || {},
  9257. renderer = wrapper.renderer,
  9258. ownerSVGElement = element.ownerSVGElement;
  9259. var parentToClean = (renderer.isSVG &&
  9260. element.nodeName === 'SPAN' &&
  9261. wrapper.parentGroup ||
  9262. void 0),
  9263. grandParent,
  9264. i;
  9265. // remove events
  9266. element.onclick = element.onmouseout = element.onmouseover =
  9267. element.onmousemove = element.point = null;
  9268. stop(wrapper); // stop running animations
  9269. if (wrapper.clipPath && ownerSVGElement) {
  9270. var clipPath_1 = wrapper.clipPath;
  9271. // Look for existing references to this clipPath and remove them
  9272. // before destroying the element (#6196).
  9273. // The upper case version is for Edge
  9274. [].forEach.call(ownerSVGElement.querySelectorAll('[clip-path],[CLIP-PATH]'), function (el) {
  9275. if (el.getAttribute('clip-path').indexOf(clipPath_1.element.id) > -1) {
  9276. el.removeAttribute('clip-path');
  9277. }
  9278. });
  9279. wrapper.clipPath = clipPath_1.destroy();
  9280. }
  9281. // Destroy stops in case this is a gradient object @todo old code?
  9282. if (wrapper.stops) {
  9283. for (i = 0; i < wrapper.stops.length; i++) {
  9284. wrapper.stops[i].destroy();
  9285. }
  9286. wrapper.stops.length = 0;
  9287. wrapper.stops = void 0;
  9288. }
  9289. // remove element
  9290. wrapper.safeRemoveChild(element);
  9291. if (!renderer.styledMode) {
  9292. wrapper.destroyShadows();
  9293. }
  9294. // In case of useHTML, clean up empty containers emulating SVG groups
  9295. // (#1960, #2393, #2697).
  9296. while (parentToClean &&
  9297. parentToClean.div &&
  9298. parentToClean.div.childNodes.length === 0) {
  9299. grandParent = parentToClean.parentGroup;
  9300. wrapper.safeRemoveChild(parentToClean.div);
  9301. delete parentToClean.div;
  9302. parentToClean = grandParent;
  9303. }
  9304. // remove from alignObjects
  9305. if (wrapper.alignTo) {
  9306. erase(renderer.alignedObjects, wrapper);
  9307. }
  9308. objectEach(wrapper, function (val, key) {
  9309. // Destroy child elements of a group
  9310. if (wrapper[key] &&
  9311. wrapper[key].parentGroup === wrapper &&
  9312. wrapper[key].destroy) {
  9313. wrapper[key].destroy();
  9314. }
  9315. // Delete all properties
  9316. delete wrapper[key];
  9317. });
  9318. return;
  9319. };
  9320. /**
  9321. * Destroy shadows on the element.
  9322. *
  9323. * @private
  9324. * @function Highcharts.SVGElement#destroyShadows
  9325. *
  9326. * @return {void}
  9327. */
  9328. SVGElement.prototype.destroyShadows = function () {
  9329. (this.shadows || []).forEach(function (shadow) {
  9330. this.safeRemoveChild(shadow);
  9331. }, this);
  9332. this.shadows = void 0;
  9333. };
  9334. /**
  9335. * @private
  9336. */
  9337. SVGElement.prototype.destroyTextPath = function (elem, path) {
  9338. var textElement = elem.getElementsByTagName('text')[0];
  9339. var childNodes;
  9340. if (textElement) {
  9341. // Remove textPath attributes
  9342. textElement.removeAttribute('dx');
  9343. textElement.removeAttribute('dy');
  9344. // Remove ID's:
  9345. path.element.setAttribute('id', '');
  9346. // Check if textElement includes textPath,
  9347. if (this.textPathWrapper &&
  9348. textElement.getElementsByTagName('textPath').length) {
  9349. // Move nodes to <text>
  9350. childNodes = this.textPathWrapper.element.childNodes;
  9351. // Now move all <tspan>'s and text nodes to the <textPath> node
  9352. while (childNodes.length) {
  9353. textElement.appendChild(childNodes[0]);
  9354. }
  9355. // Remove <textPath> from the DOM
  9356. textElement.removeChild(this.textPathWrapper.element);
  9357. }
  9358. }
  9359. else if (elem.getAttribute('dx') || elem.getAttribute('dy')) {
  9360. // Remove textPath attributes from elem
  9361. // to get correct text-outline position
  9362. elem.removeAttribute('dx');
  9363. elem.removeAttribute('dy');
  9364. }
  9365. if (this.textPathWrapper) {
  9366. // Set textPathWrapper to undefined and destroy it
  9367. this.textPathWrapper = this.textPathWrapper.destroy();
  9368. }
  9369. };
  9370. /**
  9371. * @private
  9372. * @function Highcharts.SVGElement#dSettter
  9373. * @param {number|string|Highcharts.SVGPathArray} value
  9374. * @param {string} key
  9375. * @param {Highcharts.SVGDOMElement} element
  9376. */
  9377. SVGElement.prototype.dSetter = function (value, key, element) {
  9378. if (isArray(value)) {
  9379. // Backwards compatibility, convert one-dimensional array into an
  9380. // array of segments
  9381. if (typeof value[0] === 'string') {
  9382. value = this.renderer.pathToSegments(value);
  9383. }
  9384. this.pathArray = value;
  9385. value = value.reduce(function (acc, seg, i) {
  9386. if (!seg || !seg.join) {
  9387. return (seg || '').toString();
  9388. }
  9389. return (i ? acc + ' ' : '') + seg.join(' ');
  9390. }, '');
  9391. }
  9392. if (/(NaN| {2}|^$)/.test(value)) {
  9393. value = 'M 0 0';
  9394. }
  9395. // Check for cache before resetting. Resetting causes disturbance in the
  9396. // DOM, causing flickering in some cases in Edge/IE (#6747). Also
  9397. // possible performance gain.
  9398. if (this[key] !== value) {
  9399. element.setAttribute(key, value);
  9400. this[key] = value;
  9401. }
  9402. };
  9403. /**
  9404. * Fade out an element by animating its opacity down to 0, and hide it on
  9405. * complete. Used internally for the tooltip.
  9406. *
  9407. * @function Highcharts.SVGElement#fadeOut
  9408. *
  9409. * @param {number} [duration=150]
  9410. * The fade duration in milliseconds.
  9411. */
  9412. SVGElement.prototype.fadeOut = function (duration) {
  9413. var elemWrapper = this;
  9414. elemWrapper.animate({
  9415. opacity: 0
  9416. }, {
  9417. duration: pick(duration, 150),
  9418. complete: function () {
  9419. // #3088, assuming we're only using this for tooltips
  9420. elemWrapper.attr({ y: -9999 }).hide();
  9421. }
  9422. });
  9423. };
  9424. /**
  9425. * @private
  9426. * @function Highcharts.SVGElement#fillSetter
  9427. * @param {Highcharts.ColorType} value
  9428. * @param {string} key
  9429. * @param {Highcharts.SVGDOMElement} element
  9430. */
  9431. SVGElement.prototype.fillSetter = function (value, key, element) {
  9432. if (typeof value === 'string') {
  9433. element.setAttribute(key, value);
  9434. }
  9435. else if (value) {
  9436. this.complexColor(value, key, element);
  9437. }
  9438. };
  9439. /**
  9440. * Get the bounding box (width, height, x and y) for the element. Generally
  9441. * used to get rendered text size. Since this is called a lot in charts,
  9442. * the results are cached based on text properties, in order to save DOM
  9443. * traffic. The returned bounding box includes the rotation, so for example
  9444. * a single text line of rotation 90 will report a greater height, and a
  9445. * width corresponding to the line-height.
  9446. *
  9447. * @sample highcharts/members/renderer-on-chart/
  9448. * Draw a rectangle based on a text's bounding box
  9449. *
  9450. * @function Highcharts.SVGElement#getBBox
  9451. *
  9452. * @param {boolean} [reload]
  9453. * Skip the cache and get the updated DOM bouding box.
  9454. *
  9455. * @param {number} [rot]
  9456. * Override the element's rotation. This is internally used on axis
  9457. * labels with a value of 0 to find out what the bounding box would
  9458. * be have been if it were not rotated.
  9459. *
  9460. * @return {Highcharts.BBoxObject}
  9461. * The bounding box with `x`, `y`, `width` and `height` properties.
  9462. */
  9463. SVGElement.prototype.getBBox = function (reload, rot) {
  9464. var wrapper = this,
  9465. renderer = wrapper.renderer,
  9466. element = wrapper.element,
  9467. styles = wrapper.styles,
  9468. textStr = wrapper.textStr,
  9469. cache = renderer.cache,
  9470. cacheKeys = renderer.cacheKeys,
  9471. isSVG = element.namespaceURI === wrapper.SVG_NS,
  9472. rotation = pick(rot,
  9473. wrapper.rotation, 0),
  9474. fontSize = renderer.styledMode ? (element &&
  9475. SVGElement.prototype.getStyle.call(element, 'font-size')) : (styles && styles.fontSize);
  9476. var bBox, // = wrapper.bBox,
  9477. width,
  9478. height,
  9479. toggleTextShadowShim,
  9480. cacheKey;
  9481. // Avoid undefined and null (#7316)
  9482. if (defined(textStr)) {
  9483. cacheKey = textStr.toString();
  9484. // Since numbers are monospaced, and numerical labels appear a lot
  9485. // in a chart, we assume that a label of n characters has the same
  9486. // bounding box as others of the same length. Unless there is inner
  9487. // HTML in the label. In that case, leave the numbers as is (#5899).
  9488. if (cacheKey.indexOf('<') === -1) {
  9489. cacheKey = cacheKey.replace(/[0-9]/g, '0');
  9490. }
  9491. // Properties that affect bounding box
  9492. cacheKey += [
  9493. '',
  9494. rotation,
  9495. fontSize,
  9496. wrapper.textWidth,
  9497. styles && styles.textOverflow,
  9498. styles && styles.fontWeight // #12163
  9499. ].join(',');
  9500. }
  9501. if (cacheKey && !reload) {
  9502. bBox = cache[cacheKey];
  9503. }
  9504. // No cache found
  9505. if (!bBox) {
  9506. // SVG elements
  9507. if (isSVG || renderer.forExport) {
  9508. try { // Fails in Firefox if the container has display: none.
  9509. // When the text shadow shim is used, we need to hide the
  9510. // fake shadows to get the correct bounding box (#3872)
  9511. toggleTextShadowShim = this.fakeTS && function (display) {
  9512. var outline = element.querySelector('.highcharts-text-outline');
  9513. if (outline) {
  9514. css(outline, { display: display });
  9515. }
  9516. };
  9517. // Workaround for #3842, Firefox reporting wrong bounding
  9518. // box for shadows
  9519. if (isFunction(toggleTextShadowShim)) {
  9520. toggleTextShadowShim('none');
  9521. }
  9522. bBox = element.getBBox ?
  9523. // SVG: use extend because IE9 is not allowed to change
  9524. // width and height in case of rotation (below)
  9525. extend({}, element.getBBox()) : {
  9526. // Legacy IE in export mode
  9527. width: element.offsetWidth,
  9528. height: element.offsetHeight
  9529. };
  9530. // #3842
  9531. if (isFunction(toggleTextShadowShim)) {
  9532. toggleTextShadowShim('');
  9533. }
  9534. }
  9535. catch (e) {
  9536. '';
  9537. }
  9538. // If the bBox is not set, the try-catch block above failed. The
  9539. // other condition is for Opera that returns a width of
  9540. // -Infinity on hidden elements.
  9541. if (!bBox || bBox.width < 0) {
  9542. bBox = { width: 0, height: 0 };
  9543. }
  9544. // VML Renderer or useHTML within SVG
  9545. }
  9546. else {
  9547. bBox = wrapper.htmlGetBBox();
  9548. }
  9549. // True SVG elements as well as HTML elements in modern browsers
  9550. // using the .useHTML option need to compensated for rotation
  9551. if (renderer.isSVG) {
  9552. width = bBox.width;
  9553. height = bBox.height;
  9554. // Workaround for wrong bounding box in IE, Edge and Chrome on
  9555. // Windows. With Highcharts' default font, IE and Edge report
  9556. // a box height of 16.899 and Chrome rounds it to 17. If this
  9557. // stands uncorrected, it results in more padding added below
  9558. // the text than above when adding a label border or background.
  9559. // Also vertical positioning is affected.
  9560. // https://jsfiddle.net/highcharts/em37nvuj/
  9561. // (#1101, #1505, #1669, #2568, #6213).
  9562. if (isSVG) {
  9563. bBox.height = height = ({
  9564. '11px,17': 14,
  9565. '13px,20': 16
  9566. }[styles &&
  9567. styles.fontSize + ',' + Math.round(height)] ||
  9568. height);
  9569. }
  9570. // Adjust for rotated text
  9571. if (rotation) {
  9572. var rad = rotation * deg2rad;
  9573. bBox.width = Math.abs(height * Math.sin(rad)) +
  9574. Math.abs(width * Math.cos(rad));
  9575. bBox.height = Math.abs(height * Math.cos(rad)) +
  9576. Math.abs(width * Math.sin(rad));
  9577. }
  9578. }
  9579. // Cache it. When loading a chart in a hidden iframe in Firefox and
  9580. // IE/Edge, the bounding box height is 0, so don't cache it (#5620).
  9581. if (cacheKey && bBox.height > 0) {
  9582. // Rotate (#4681)
  9583. while (cacheKeys.length > 250) {
  9584. delete cache[cacheKeys.shift()];
  9585. }
  9586. if (!cache[cacheKey]) {
  9587. cacheKeys.push(cacheKey);
  9588. }
  9589. cache[cacheKey] = bBox;
  9590. }
  9591. }
  9592. return bBox;
  9593. };
  9594. /**
  9595. * Get the computed style. Only in styled mode.
  9596. *
  9597. * @example
  9598. * chart.series[0].points[0].graphic.getStyle('stroke-width'); // => '1px'
  9599. *
  9600. * @function Highcharts.SVGElement#getStyle
  9601. *
  9602. * @param {string} prop
  9603. * The property name to check for.
  9604. *
  9605. * @return {string}
  9606. * The current computed value.
  9607. */
  9608. SVGElement.prototype.getStyle = function (prop) {
  9609. return win
  9610. .getComputedStyle(this.element || this, '')
  9611. .getPropertyValue(prop);
  9612. };
  9613. /**
  9614. * Check if an element has the given class name.
  9615. *
  9616. * @function Highcharts.SVGElement#hasClass
  9617. *
  9618. * @param {string} className
  9619. * The class name to check for.
  9620. *
  9621. * @return {boolean}
  9622. * Whether the class name is found.
  9623. */
  9624. SVGElement.prototype.hasClass = function (className) {
  9625. return ('' + this.attr('class'))
  9626. .split(' ')
  9627. .indexOf(className) !== -1;
  9628. };
  9629. /**
  9630. * Hide the element, similar to setting the `visibility` attribute to
  9631. * `hidden`.
  9632. *
  9633. * @function Highcharts.SVGElement#hide
  9634. *
  9635. * @param {boolean} [hideByTranslation=false]
  9636. * The flag to determine if element should be hidden by moving out
  9637. * of the viewport. Used for example for dataLabels.
  9638. *
  9639. * @return {Highcharts.SVGElement}
  9640. * Returns the SVGElement for chaining.
  9641. */
  9642. SVGElement.prototype.hide = function (hideByTranslation) {
  9643. if (hideByTranslation) {
  9644. this.attr({ y: -9999 });
  9645. }
  9646. else {
  9647. this.attr({ visibility: 'hidden' });
  9648. }
  9649. return this;
  9650. };
  9651. /**
  9652. * @private
  9653. */
  9654. SVGElement.prototype.htmlGetBBox = function () {
  9655. return { height: 0, width: 0, x: 0, y: 0 };
  9656. };
  9657. /**
  9658. * Initialize the SVG element. This function only exists to make the
  9659. * initialization process overridable. It should not be called directly.
  9660. *
  9661. * @function Highcharts.SVGElement#init
  9662. *
  9663. * @param {Highcharts.SVGRenderer} renderer
  9664. * The SVGRenderer instance to initialize to.
  9665. *
  9666. * @param {string} nodeName
  9667. * The SVG node name.
  9668. */
  9669. SVGElement.prototype.init = function (renderer, nodeName) {
  9670. /**
  9671. * The primary DOM node. Each `SVGElement` instance wraps a main DOM
  9672. * node, but may also represent more nodes.
  9673. *
  9674. * @name Highcharts.SVGElement#element
  9675. * @type {Highcharts.SVGDOMElement|Highcharts.HTMLDOMElement}
  9676. */
  9677. this.element = nodeName === 'span' ?
  9678. createElement(nodeName) :
  9679. doc.createElementNS(this.SVG_NS, nodeName);
  9680. /**
  9681. * The renderer that the SVGElement belongs to.
  9682. *
  9683. * @name Highcharts.SVGElement#renderer
  9684. * @type {Highcharts.SVGRenderer}
  9685. */
  9686. this.renderer = renderer;
  9687. fireEvent(this, 'afterInit');
  9688. };
  9689. /**
  9690. * Invert a group, rotate and flip. This is used internally on inverted
  9691. * charts, where the points and graphs are drawn as if not inverted, then
  9692. * the series group elements are inverted.
  9693. *
  9694. * @function Highcharts.SVGElement#invert
  9695. *
  9696. * @param {boolean} inverted
  9697. * Whether to invert or not. An inverted shape can be un-inverted by
  9698. * setting it to false.
  9699. *
  9700. * @return {Highcharts.SVGElement}
  9701. * Return the SVGElement for chaining.
  9702. */
  9703. SVGElement.prototype.invert = function (inverted) {
  9704. this.inverted = inverted;
  9705. this.updateTransform();
  9706. return this;
  9707. };
  9708. /**
  9709. * Add an event listener. This is a simple setter that replaces the
  9710. * previous event of the same type added by this function, as opposed to
  9711. * the {@link Highcharts#addEvent} function.
  9712. *
  9713. * @sample highcharts/members/element-on/
  9714. * A clickable rectangle
  9715. *
  9716. * @function Highcharts.SVGElement#on
  9717. *
  9718. * @param {string} eventType
  9719. * The event type.
  9720. *
  9721. * @param {Function} handler
  9722. * The handler callback.
  9723. *
  9724. * @return {Highcharts.SVGElement}
  9725. * The SVGElement for chaining.
  9726. */
  9727. SVGElement.prototype.on = function (eventType, handler) {
  9728. var onEvents = this.onEvents;
  9729. if (onEvents[eventType]) {
  9730. // Unbind existing event
  9731. onEvents[eventType]();
  9732. }
  9733. onEvents[eventType] = addEvent(this.element, eventType, handler);
  9734. return this;
  9735. };
  9736. /**
  9737. * @private
  9738. * @function Highcharts.SVGElement#opacitySetter
  9739. * @param {string} value
  9740. * @param {string} key
  9741. * @param {Highcharts.SVGDOMElement} element
  9742. */
  9743. SVGElement.prototype.opacitySetter = function (value, key, element) {
  9744. // Round off to avoid float errors, like tests where opacity lands on
  9745. // 9.86957e-06 instead of 0
  9746. var opacity = Number(Number(value).toFixed(3));
  9747. this.opacity = opacity;
  9748. element.setAttribute(key, opacity);
  9749. };
  9750. /**
  9751. * Remove a class name from the element.
  9752. *
  9753. * @function Highcharts.SVGElement#removeClass
  9754. *
  9755. * @param {string|RegExp} className
  9756. * The class name to remove.
  9757. *
  9758. * @return {Highcharts.SVGElement} Returns the SVG element for chainability.
  9759. */
  9760. SVGElement.prototype.removeClass = function (className) {
  9761. return this.attr('class', ('' + this.attr('class'))
  9762. .replace(isString(className) ?
  9763. new RegExp("(^| )" + className + "( |$)") : // #12064, #13590
  9764. className, ' ')
  9765. .replace(/ +/g, ' ')
  9766. .trim());
  9767. };
  9768. /**
  9769. *
  9770. * @private
  9771. */
  9772. SVGElement.prototype.removeTextOutline = function () {
  9773. var outline = this.element
  9774. .querySelector('tspan.highcharts-text-outline');
  9775. if (outline) {
  9776. this.safeRemoveChild(outline);
  9777. }
  9778. };
  9779. /**
  9780. * Removes an element from the DOM.
  9781. *
  9782. * @private
  9783. * @function Highcharts.SVGElement#safeRemoveChild
  9784. *
  9785. * @param {Highcharts.SVGDOMElement|Highcharts.HTMLDOMElement} element
  9786. * The DOM node to remove.
  9787. */
  9788. SVGElement.prototype.safeRemoveChild = function (element) {
  9789. var parentNode = element.parentNode;
  9790. if (parentNode) {
  9791. parentNode.removeChild(element);
  9792. }
  9793. };
  9794. /**
  9795. * Set the coordinates needed to draw a consistent radial gradient across
  9796. * a shape regardless of positioning inside the chart. Used on pie slices
  9797. * to make all the slices have the same radial reference point.
  9798. *
  9799. * @function Highcharts.SVGElement#setRadialReference
  9800. *
  9801. * @param {Array<number>} coordinates
  9802. * The center reference. The format is `[centerX, centerY, diameter]` in
  9803. * pixels.
  9804. *
  9805. * @return {Highcharts.SVGElement}
  9806. * Returns the SVGElement for chaining.
  9807. */
  9808. SVGElement.prototype.setRadialReference = function (coordinates) {
  9809. var existingGradient = (this.element.gradient &&
  9810. this.renderer.gradients[this.element.gradient]);
  9811. this.element.radialReference = coordinates;
  9812. // On redrawing objects with an existing gradient, the gradient needs
  9813. // to be repositioned (#3801)
  9814. if (existingGradient && existingGradient.radAttr) {
  9815. existingGradient.animate(this.renderer.getRadialAttr(coordinates, existingGradient.radAttr));
  9816. }
  9817. return this;
  9818. };
  9819. /**
  9820. * @private
  9821. * @function Highcharts.SVGElement#setTextPath
  9822. * @param {Highcharts.SVGElement} path
  9823. * Path to follow.
  9824. * @param {Highcharts.DataLabelsTextPathOptionsObject} textPathOptions
  9825. * Options.
  9826. * @return {Highcharts.SVGElement}
  9827. * Returns the SVGElement for chaining.
  9828. */
  9829. SVGElement.prototype.setTextPath = function (path, textPathOptions) {
  9830. var elem = this.element,
  9831. textNode = this.text ? this.text.element : elem,
  9832. attribsMap = {
  9833. textAnchor: 'text-anchor'
  9834. };
  9835. var adder = false,
  9836. textPathElement,
  9837. textPathId,
  9838. textPathWrapper = this.textPathWrapper,
  9839. firstTime = !textPathWrapper;
  9840. // Defaults
  9841. textPathOptions = merge(true, {
  9842. enabled: true,
  9843. attributes: {
  9844. dy: -5,
  9845. startOffset: '50%',
  9846. textAnchor: 'middle'
  9847. }
  9848. }, textPathOptions);
  9849. var attrs = AST.filterUserAttributes(textPathOptions.attributes);
  9850. if (path && textPathOptions && textPathOptions.enabled) {
  9851. // In case of fixed width for a text, string is rebuilt
  9852. // (e.g. ellipsis is applied), so we need to rebuild textPath too
  9853. if (textPathWrapper &&
  9854. textPathWrapper.element.parentNode === null) {
  9855. // When buildText functionality was triggered again
  9856. // and deletes textPathWrapper parentNode
  9857. firstTime = true;
  9858. textPathWrapper = textPathWrapper.destroy();
  9859. }
  9860. else if (textPathWrapper) {
  9861. // Case after drillup when spans were added into
  9862. // the DOM outside the textPathWrapper parentGroup
  9863. this.removeTextOutline.call(textPathWrapper.parentGroup);
  9864. }
  9865. // label() has padding, text() doesn't
  9866. if (this.options && this.options.padding) {
  9867. attrs.dx = -this.options.padding;
  9868. }
  9869. if (!textPathWrapper) {
  9870. // Create <textPath>, defer the DOM adder
  9871. this.textPathWrapper = textPathWrapper =
  9872. this.renderer.createElement('textPath');
  9873. adder = true;
  9874. }
  9875. textPathElement = textPathWrapper.element;
  9876. // Set ID for the path
  9877. textPathId = path.element.getAttribute('id');
  9878. if (!textPathId) {
  9879. path.element.setAttribute('id', textPathId = uniqueKey());
  9880. }
  9881. // Change DOM structure, by placing <textPath> tag in <text>
  9882. if (firstTime) {
  9883. // Adjust the position
  9884. textNode.setAttribute('y', 0); // Firefox
  9885. if (isNumber(attrs.dx)) {
  9886. textNode.setAttribute('x', -attrs.dx);
  9887. }
  9888. // Move all <tspan>'s and text nodes to the <textPath> node. Do
  9889. // not move other elements like <title> or <path>
  9890. var childNodes = [].slice.call(textNode.childNodes);
  9891. for (var i = 0; i < childNodes.length; i++) {
  9892. var childNode = childNodes[i];
  9893. if (childNode.nodeType === Node.TEXT_NODE ||
  9894. childNode.nodeName === 'tspan') {
  9895. textPathElement.appendChild(childNode);
  9896. }
  9897. }
  9898. }
  9899. // Add <textPath> to the DOM
  9900. if (adder && textPathWrapper) {
  9901. textPathWrapper.add({ element: textNode });
  9902. }
  9903. // Set basic options:
  9904. // Use `setAttributeNS` because Safari needs this..
  9905. textPathElement.setAttributeNS('http://www.w3.org/1999/xlink', 'href', this.renderer.url + '#' + textPathId);
  9906. // Presentation attributes:
  9907. // dx/dy options must by set on <text> (parent),
  9908. // the rest should be set on <textPath>
  9909. if (defined(attrs.dy)) {
  9910. textPathElement.parentNode
  9911. .setAttribute('dy', attrs.dy);
  9912. delete attrs.dy;
  9913. }
  9914. if (defined(attrs.dx)) {
  9915. textPathElement.parentNode
  9916. .setAttribute('dx', attrs.dx);
  9917. delete attrs.dx;
  9918. }
  9919. // Additional attributes
  9920. objectEach(attrs, function (val, key) {
  9921. textPathElement.setAttribute(attribsMap[key] || key, val);
  9922. });
  9923. // Remove translation, text that follows path does not need that
  9924. elem.removeAttribute('transform');
  9925. // Remove shadows and text outlines
  9926. this.removeTextOutline.call(textPathWrapper);
  9927. // Remove background and border for label(), see #10545
  9928. // Alternatively, we can disable setting background rects in
  9929. // series.drawDataLabels()
  9930. if (this.text && !this.renderer.styledMode) {
  9931. this.attr({
  9932. fill: 'none',
  9933. 'stroke-width': 0
  9934. });
  9935. }
  9936. // Disable some functions
  9937. this.updateTransform = noop;
  9938. this.applyTextOutline = noop;
  9939. }
  9940. else if (textPathWrapper) {
  9941. // Reset to prototype
  9942. delete this.updateTransform;
  9943. delete this.applyTextOutline;
  9944. // Restore DOM structure:
  9945. this.destroyTextPath(elem, path);
  9946. // Bring attributes back
  9947. this.updateTransform();
  9948. // Set textOutline back for text()
  9949. if (this.options && this.options.rotation) {
  9950. this.applyTextOutline(this.options.style.textOutline);
  9951. }
  9952. }
  9953. return this;
  9954. };
  9955. /**
  9956. * Add a shadow to the element. Must be called after the element is added to
  9957. * the DOM. In styled mode, this method is not used, instead use `defs` and
  9958. * filters.
  9959. *
  9960. * @example
  9961. * renderer.rect(10, 100, 100, 100)
  9962. * .attr({ fill: 'red' })
  9963. * .shadow(true);
  9964. *
  9965. * @function Highcharts.SVGElement#shadow
  9966. *
  9967. * @param {boolean|Highcharts.ShadowOptionsObject} [shadowOptions]
  9968. * The shadow options. If `true`, the default options are applied. If
  9969. * `false`, the current shadow will be removed.
  9970. *
  9971. * @param {Highcharts.SVGElement} [group]
  9972. * The SVG group element where the shadows will be applied. The
  9973. * default is to add it to the same parent as the current element.
  9974. * Internally, this is ised for pie slices, where all the shadows are
  9975. * added to an element behind all the slices.
  9976. *
  9977. * @param {boolean} [cutOff]
  9978. * Used internally for column shadows.
  9979. *
  9980. * @return {Highcharts.SVGElement}
  9981. * Returns the SVGElement for chaining.
  9982. */
  9983. SVGElement.prototype.shadow = function (shadowOptions, group, cutOff) {
  9984. var shadows = [],
  9985. element = this.element,
  9986. oldShadowOptions = this.oldShadowOptions,
  9987. defaultShadowOptions = {
  9988. color: palette.neutralColor100,
  9989. offsetX: 1,
  9990. offsetY: 1,
  9991. opacity: 0.15,
  9992. width: 3
  9993. };
  9994. var i,
  9995. shadow,
  9996. strokeWidth,
  9997. shadowElementOpacity,
  9998. update = false,
  9999. // compensate for inverted plot area
  10000. transform,
  10001. options;
  10002. if (shadowOptions === true) {
  10003. options = defaultShadowOptions;
  10004. }
  10005. else if (typeof shadowOptions === 'object') {
  10006. options = extend(defaultShadowOptions, shadowOptions);
  10007. }
  10008. // Update shadow when options change (#12091).
  10009. if (options) {
  10010. // Go over each key to look for change
  10011. if (options && oldShadowOptions) {
  10012. objectEach(options, function (value, key) {
  10013. if (value !== oldShadowOptions[key]) {
  10014. update = true;
  10015. }
  10016. });
  10017. }
  10018. if (update) {
  10019. this.destroyShadows();
  10020. }
  10021. this.oldShadowOptions = options;
  10022. }
  10023. if (!options) {
  10024. this.destroyShadows();
  10025. }
  10026. else if (!this.shadows) {
  10027. shadowElementOpacity = options.opacity / options.width;
  10028. transform = this.parentInverted ?
  10029. 'translate(-1,-1)' :
  10030. "translate(" + options.offsetX + ", " + options.offsetY + ")";
  10031. for (i = 1; i <= options.width; i++) {
  10032. shadow = element.cloneNode(false);
  10033. strokeWidth = (options.width * 2) + 1 - (2 * i);
  10034. attr(shadow, {
  10035. stroke: (shadowOptions.color ||
  10036. palette.neutralColor100),
  10037. 'stroke-opacity': shadowElementOpacity * i,
  10038. 'stroke-width': strokeWidth,
  10039. transform: transform,
  10040. fill: 'none'
  10041. });
  10042. shadow.setAttribute('class', (shadow.getAttribute('class') || '') + ' highcharts-shadow');
  10043. if (cutOff) {
  10044. attr(shadow, 'height', Math.max(attr(shadow, 'height') - strokeWidth, 0));
  10045. shadow.cutHeight = strokeWidth;
  10046. }
  10047. if (group) {
  10048. group.element.appendChild(shadow);
  10049. }
  10050. else if (element.parentNode) {
  10051. element.parentNode.insertBefore(shadow, element);
  10052. }
  10053. shadows.push(shadow);
  10054. }
  10055. this.shadows = shadows;
  10056. }
  10057. return this;
  10058. };
  10059. /**
  10060. * Show the element after it has been hidden.
  10061. *
  10062. * @function Highcharts.SVGElement#show
  10063. *
  10064. * @param {boolean} [inherit=false]
  10065. * Set the visibility attribute to `inherit` rather than `visible`.
  10066. * The difference is that an element with `visibility="visible"`
  10067. * will be visible even if the parent is hidden.
  10068. *
  10069. * @return {Highcharts.SVGElement}
  10070. * Returns the SVGElement for chaining.
  10071. */
  10072. SVGElement.prototype.show = function (inherit) {
  10073. return this.attr({ visibility: inherit ? 'inherit' : 'visible' });
  10074. };
  10075. /**
  10076. * WebKit and Batik have problems with a stroke-width of zero, so in this
  10077. * case we remove the stroke attribute altogether. #1270, #1369, #3065,
  10078. * #3072.
  10079. *
  10080. * @private
  10081. * @function Highcharts.SVGElement#strokeSetter
  10082. * @param {number|string} value
  10083. * @param {string} key
  10084. * @param {Highcharts.SVGDOMElement} element
  10085. */
  10086. SVGElement.prototype.strokeSetter = function (value, key, element) {
  10087. this[key] = value;
  10088. // Only apply the stroke attribute if the stroke width is defined and
  10089. // larger than 0
  10090. if (this.stroke && this['stroke-width']) {
  10091. // Use prototype as instance may be overridden
  10092. SVGElement.prototype.fillSetter.call(this, this.stroke, 'stroke', element);
  10093. element.setAttribute('stroke-width', this['stroke-width']);
  10094. this.hasStroke = true;
  10095. }
  10096. else if (key === 'stroke-width' && value === 0 && this.hasStroke) {
  10097. element.removeAttribute('stroke');
  10098. this.hasStroke = false;
  10099. }
  10100. else if (this.renderer.styledMode && this['stroke-width']) {
  10101. element.setAttribute('stroke-width', this['stroke-width']);
  10102. this.hasStroke = true;
  10103. }
  10104. };
  10105. /**
  10106. * Get the computed stroke width in pixel values. This is used extensively
  10107. * when drawing shapes to ensure the shapes are rendered crisp and
  10108. * positioned correctly relative to each other. Using
  10109. * `shape-rendering: crispEdges` leaves us less control over positioning,
  10110. * for example when we want to stack columns next to each other, or position
  10111. * things pixel-perfectly within the plot box.
  10112. *
  10113. * The common pattern when placing a shape is:
  10114. * - Create the SVGElement and add it to the DOM. In styled mode, it will
  10115. * now receive a stroke width from the style sheet. In classic mode we
  10116. * will add the `stroke-width` attribute.
  10117. * - Read the computed `elem.strokeWidth()`.
  10118. * - Place it based on the stroke width.
  10119. *
  10120. * @function Highcharts.SVGElement#strokeWidth
  10121. *
  10122. * @return {number}
  10123. * The stroke width in pixels. Even if the given stroke widtch (in CSS or by
  10124. * attributes) is based on `em` or other units, the pixel size is returned.
  10125. */
  10126. SVGElement.prototype.strokeWidth = function () {
  10127. // In non-styled mode, read the stroke width as set by .attr
  10128. if (!this.renderer.styledMode) {
  10129. return this['stroke-width'] || 0;
  10130. }
  10131. // In styled mode, read computed stroke width
  10132. var val = this.getStyle('stroke-width');
  10133. var ret = 0,
  10134. dummy;
  10135. // Read pixel values directly
  10136. if (val.indexOf('px') === val.length - 2) {
  10137. ret = pInt(val);
  10138. // Other values like em, pt etc need to be measured
  10139. }
  10140. else if (val !== '') {
  10141. dummy = doc.createElementNS(SVG_NS, 'rect');
  10142. attr(dummy, {
  10143. width: val,
  10144. 'stroke-width': 0
  10145. });
  10146. this.element.parentNode.appendChild(dummy);
  10147. ret = dummy.getBBox().width;
  10148. dummy.parentNode.removeChild(dummy);
  10149. }
  10150. return ret;
  10151. };
  10152. /**
  10153. * If one of the symbol size affecting parameters are changed,
  10154. * check all the others only once for each call to an element's
  10155. * .attr() method
  10156. *
  10157. * @private
  10158. * @function Highcharts.SVGElement#symbolAttr
  10159. *
  10160. * @param {Highcharts.SVGAttributes} hash
  10161. * The attributes to set.
  10162. */
  10163. SVGElement.prototype.symbolAttr = function (hash) {
  10164. var wrapper = this;
  10165. [
  10166. 'x',
  10167. 'y',
  10168. 'r',
  10169. 'start',
  10170. 'end',
  10171. 'width',
  10172. 'height',
  10173. 'innerR',
  10174. 'anchorX',
  10175. 'anchorY',
  10176. 'clockwise'
  10177. ].forEach(function (key) {
  10178. wrapper[key] = pick(hash[key], wrapper[key]);
  10179. });
  10180. wrapper.attr({
  10181. d: wrapper.renderer.symbols[wrapper.symbolName](wrapper.x, wrapper.y, wrapper.width, wrapper.height, wrapper)
  10182. });
  10183. };
  10184. /**
  10185. * @private
  10186. * @function Highcharts.SVGElement#textSetter
  10187. * @param {string} value
  10188. */
  10189. SVGElement.prototype.textSetter = function (value) {
  10190. if (value !== this.textStr) {
  10191. // Delete size caches when the text changes
  10192. // delete this.bBox; // old code in series-label
  10193. delete this.textPxLength;
  10194. this.textStr = value;
  10195. if (this.added) {
  10196. this.renderer.buildText(this);
  10197. }
  10198. }
  10199. };
  10200. /**
  10201. * @private
  10202. * @function Highcharts.SVGElement#titleSetter
  10203. * @param {string} value
  10204. */
  10205. SVGElement.prototype.titleSetter = function (value) {
  10206. var el = this.element;
  10207. var titleNode = el.getElementsByTagName('title')[0] ||
  10208. doc.createElementNS(this.SVG_NS, 'title');
  10209. // Move to first child
  10210. if (el.insertBefore) {
  10211. el.insertBefore(titleNode, el.firstChild);
  10212. }
  10213. else {
  10214. el.appendChild(titleNode);
  10215. }
  10216. // Replace text content and escape markup
  10217. titleNode.textContent =
  10218. // #3276, #3895
  10219. String(pick(value, ''))
  10220. .replace(/<[^>]*>/g, '')
  10221. .replace(/&lt;/g, '<')
  10222. .replace(/&gt;/g, '>');
  10223. };
  10224. /**
  10225. * Bring the element to the front. Alternatively, a new zIndex can be set.
  10226. *
  10227. * @sample highcharts/members/element-tofront/
  10228. * Click an element to bring it to front
  10229. *
  10230. * @function Highcharts.SVGElement#toFront
  10231. *
  10232. * @return {Highcharts.SVGElement}
  10233. * Returns the SVGElement for chaining.
  10234. */
  10235. SVGElement.prototype.toFront = function () {
  10236. var element = this.element;
  10237. element.parentNode.appendChild(element);
  10238. return this;
  10239. };
  10240. /**
  10241. * Move an object and its children by x and y values.
  10242. *
  10243. * @function Highcharts.SVGElement#translate
  10244. *
  10245. * @param {number} x
  10246. * The x value.
  10247. *
  10248. * @param {number} y
  10249. * The y value.
  10250. *
  10251. * @return {Highcharts.SVGElement}
  10252. */
  10253. SVGElement.prototype.translate = function (x, y) {
  10254. return this.attr({
  10255. translateX: x,
  10256. translateY: y
  10257. });
  10258. };
  10259. /**
  10260. * Update the shadow elements with new attributes.
  10261. *
  10262. * @private
  10263. * @function Highcharts.SVGElement#updateShadows
  10264. *
  10265. * @param {string} key
  10266. * The attribute name.
  10267. *
  10268. * @param {number} value
  10269. * The value of the attribute.
  10270. *
  10271. * @param {Function} setter
  10272. * The setter function, inherited from the parent wrapper.
  10273. */
  10274. SVGElement.prototype.updateShadows = function (key, value, setter) {
  10275. var shadows = this.shadows;
  10276. if (shadows) {
  10277. var i = shadows.length;
  10278. while (i--) {
  10279. setter.call(shadows[i], key === 'height' ?
  10280. Math.max(value - (shadows[i].cutHeight || 0), 0) :
  10281. key === 'd' ? this.d : value, key, shadows[i]);
  10282. }
  10283. }
  10284. };
  10285. /**
  10286. * Update the transform attribute based on internal properties. Deals with
  10287. * the custom `translateX`, `translateY`, `rotation`, `scaleX` and `scaleY`
  10288. * attributes and updates the SVG `transform` attribute.
  10289. *
  10290. * @private
  10291. * @function Highcharts.SVGElement#updateTransform
  10292. */
  10293. SVGElement.prototype.updateTransform = function () {
  10294. var wrapper = this,
  10295. scaleX = wrapper.scaleX,
  10296. scaleY = wrapper.scaleY,
  10297. inverted = wrapper.inverted,
  10298. rotation = wrapper.rotation,
  10299. matrix = wrapper.matrix,
  10300. element = wrapper.element;
  10301. var translateX = wrapper.translateX || 0,
  10302. translateY = wrapper.translateY || 0;
  10303. // Flipping affects translate as adjustment for flipping around the
  10304. // group's axis
  10305. if (inverted) {
  10306. translateX += wrapper.width;
  10307. translateY += wrapper.height;
  10308. }
  10309. // Apply translate. Nearly all transformed elements have translation,
  10310. // so instead of checking for translate = 0, do it always (#1767,
  10311. // #1846).
  10312. var transform = ['translate(' + translateX + ',' + translateY + ')'];
  10313. // apply matrix
  10314. if (defined(matrix)) {
  10315. transform.push('matrix(' + matrix.join(',') + ')');
  10316. }
  10317. // apply rotation
  10318. if (inverted) {
  10319. transform.push('rotate(90) scale(-1,1)');
  10320. }
  10321. else if (rotation) { // text rotation
  10322. transform.push('rotate(' + rotation + ' ' +
  10323. pick(this.rotationOriginX, element.getAttribute('x'), 0) +
  10324. ' ' +
  10325. pick(this.rotationOriginY, element.getAttribute('y') || 0) + ')');
  10326. }
  10327. // apply scale
  10328. if (defined(scaleX) || defined(scaleY)) {
  10329. transform.push('scale(' + pick(scaleX, 1) + ' ' + pick(scaleY, 1) + ')');
  10330. }
  10331. if (transform.length) {
  10332. element.setAttribute('transform', transform.join(' '));
  10333. }
  10334. };
  10335. /**
  10336. * @private
  10337. * @function Highcharts.SVGElement#visibilitySetter
  10338. *
  10339. * @param {string} value
  10340. *
  10341. * @param {string} key
  10342. *
  10343. * @param {Highcharts.SVGDOMElement} element
  10344. *
  10345. * @return {void}
  10346. */
  10347. SVGElement.prototype.visibilitySetter = function (value, key, element) {
  10348. // IE9-11 doesn't handle visibilty:inherit well, so we remove the
  10349. // attribute instead (#2881, #3909)
  10350. if (value === 'inherit') {
  10351. element.removeAttribute(key);
  10352. }
  10353. else if (this[key] !== value) { // #6747
  10354. element.setAttribute(key, value);
  10355. }
  10356. this[key] = value;
  10357. };
  10358. /**
  10359. * @private
  10360. * @function Highcharts.SVGElement#xGetter
  10361. *
  10362. * @param {string} key
  10363. *
  10364. * @return {number|string|null}
  10365. */
  10366. SVGElement.prototype.xGetter = function (key) {
  10367. if (this.element.nodeName === 'circle') {
  10368. if (key === 'x') {
  10369. key = 'cx';
  10370. }
  10371. else if (key === 'y') {
  10372. key = 'cy';
  10373. }
  10374. }
  10375. return this._defaultGetter(key);
  10376. };
  10377. /**
  10378. * @private
  10379. * @function Highcharts.SVGElement#zIndexSetter
  10380. * @param {number} [value]
  10381. * @param {string} [key]
  10382. * @return {boolean}
  10383. */
  10384. SVGElement.prototype.zIndexSetter = function (value, key) {
  10385. var renderer = this.renderer,
  10386. parentGroup = this.parentGroup,
  10387. parentWrapper = parentGroup || renderer,
  10388. parentNode = parentWrapper.element || renderer.box,
  10389. element = this.element,
  10390. svgParent = parentNode === renderer.box;
  10391. var childNodes,
  10392. otherElement,
  10393. otherZIndex,
  10394. inserted = false,
  10395. undefinedOtherZIndex,
  10396. run = this.added,
  10397. i;
  10398. if (defined(value)) {
  10399. // So we can read it for other elements in the group
  10400. element.setAttribute('data-z-index', value);
  10401. value = +value;
  10402. if (this[key] === value) {
  10403. // Only update when needed (#3865)
  10404. run = false;
  10405. }
  10406. }
  10407. else if (defined(this[key])) {
  10408. element.removeAttribute('data-z-index');
  10409. }
  10410. this[key] = value;
  10411. // Insert according to this and other elements' zIndex. Before .add() is
  10412. // called, nothing is done. Then on add, or by later calls to
  10413. // zIndexSetter, the node is placed on the right place in the DOM.
  10414. if (run) {
  10415. value = this.zIndex;
  10416. if (value && parentGroup) {
  10417. parentGroup.handleZ = true;
  10418. }
  10419. childNodes = parentNode.childNodes;
  10420. for (i = childNodes.length - 1; i >= 0 && !inserted; i--) {
  10421. otherElement = childNodes[i];
  10422. otherZIndex = otherElement.getAttribute('data-z-index');
  10423. undefinedOtherZIndex = !defined(otherZIndex);
  10424. if (otherElement !== element) {
  10425. if (
  10426. // Negative zIndex versus no zIndex:
  10427. // On all levels except the highest. If the parent is
  10428. // <svg>, then we don't want to put items before <desc>
  10429. // or <defs>
  10430. value < 0 &&
  10431. undefinedOtherZIndex &&
  10432. !svgParent &&
  10433. !i) {
  10434. parentNode.insertBefore(element, childNodes[i]);
  10435. inserted = true;
  10436. }
  10437. else if (
  10438. // Insert after the first element with a lower zIndex
  10439. pInt(otherZIndex) <= value ||
  10440. // If negative zIndex, add this before first undefined
  10441. // zIndex element
  10442. (undefinedOtherZIndex &&
  10443. (!defined(value) || value >= 0))) {
  10444. parentNode.insertBefore(element, childNodes[i + 1] || null // null for oldIE export
  10445. );
  10446. inserted = true;
  10447. }
  10448. }
  10449. }
  10450. if (!inserted) {
  10451. parentNode.insertBefore(element, childNodes[svgParent ? 3 : 0] || null // null for oldIE
  10452. );
  10453. inserted = true;
  10454. }
  10455. }
  10456. return inserted;
  10457. };
  10458. return SVGElement;
  10459. }());
  10460. // Some shared setters and getters
  10461. SVGElement.prototype['stroke-widthSetter'] = SVGElement.prototype.strokeSetter;
  10462. SVGElement.prototype.yGetter = SVGElement.prototype.xGetter;
  10463. SVGElement.prototype.matrixSetter =
  10464. SVGElement.prototype.rotationOriginXSetter =
  10465. SVGElement.prototype.rotationOriginYSetter =
  10466. SVGElement.prototype.rotationSetter =
  10467. SVGElement.prototype.scaleXSetter =
  10468. SVGElement.prototype.scaleYSetter =
  10469. SVGElement.prototype.translateXSetter =
  10470. SVGElement.prototype.translateYSetter =
  10471. SVGElement.prototype.verticalAlignSetter = function (value, key) {
  10472. this[key] = value;
  10473. this.doTransform = true;
  10474. };
  10475. /* *
  10476. *
  10477. * API Declarations
  10478. *
  10479. * */
  10480. /**
  10481. * Reference to the global SVGElement class as a workaround for a name conflict
  10482. * in the Highcharts namespace.
  10483. *
  10484. * @global
  10485. * @typedef {global.SVGElement} GlobalSVGElement
  10486. *
  10487. * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGElement
  10488. */
  10489. /**
  10490. * The horizontal alignment of an element.
  10491. *
  10492. * @typedef {"center"|"left"|"right"} Highcharts.AlignValue
  10493. */
  10494. /**
  10495. * Options to align the element relative to the chart or another box.
  10496. *
  10497. * @interface Highcharts.AlignObject
  10498. */ /**
  10499. * Horizontal alignment. Can be one of `left`, `center` and `right`.
  10500. *
  10501. * @name Highcharts.AlignObject#align
  10502. * @type {Highcharts.AlignValue|undefined}
  10503. *
  10504. * @default left
  10505. */ /**
  10506. * Vertical alignment. Can be one of `top`, `middle` and `bottom`.
  10507. *
  10508. * @name Highcharts.AlignObject#verticalAlign
  10509. * @type {Highcharts.VerticalAlignValue|undefined}
  10510. *
  10511. * @default top
  10512. */ /**
  10513. * Horizontal pixel offset from alignment.
  10514. *
  10515. * @name Highcharts.AlignObject#x
  10516. * @type {number|undefined}
  10517. *
  10518. * @default 0
  10519. */ /**
  10520. * Vertical pixel offset from alignment.
  10521. *
  10522. * @name Highcharts.AlignObject#y
  10523. * @type {number|undefined}
  10524. *
  10525. * @default 0
  10526. */ /**
  10527. * Use the `transform` attribute with translateX and translateY custom
  10528. * attributes to align this elements rather than `x` and `y` attributes.
  10529. *
  10530. * @name Highcharts.AlignObject#alignByTranslate
  10531. * @type {boolean|undefined}
  10532. *
  10533. * @default false
  10534. */
  10535. /**
  10536. * Bounding box of an element.
  10537. *
  10538. * @interface Highcharts.BBoxObject
  10539. * @extends Highcharts.PositionObject
  10540. */ /**
  10541. * Height of the bounding box.
  10542. *
  10543. * @name Highcharts.BBoxObject#height
  10544. * @type {number}
  10545. */ /**
  10546. * Width of the bounding box.
  10547. *
  10548. * @name Highcharts.BBoxObject#width
  10549. * @type {number}
  10550. */ /**
  10551. * Horizontal position of the bounding box.
  10552. *
  10553. * @name Highcharts.BBoxObject#x
  10554. * @type {number}
  10555. */ /**
  10556. * Vertical position of the bounding box.
  10557. *
  10558. * @name Highcharts.BBoxObject#y
  10559. * @type {number}
  10560. */
  10561. /**
  10562. * An object of key-value pairs for SVG attributes. Attributes in Highcharts
  10563. * elements for the most parts correspond to SVG, but some are specific to
  10564. * Highcharts, like `zIndex`, `rotation`, `rotationOriginX`,
  10565. * `rotationOriginY`, `translateX`, `translateY`, `scaleX` and `scaleY`. SVG
  10566. * attributes containing a hyphen are _not_ camel-cased, they should be
  10567. * quoted to preserve the hyphen.
  10568. *
  10569. * @example
  10570. * {
  10571. * 'stroke': '#ff0000', // basic
  10572. * 'stroke-width': 2, // hyphenated
  10573. * 'rotation': 45 // custom
  10574. * 'd': ['M', 10, 10, 'L', 30, 30, 'z'] // path definition, note format
  10575. * }
  10576. *
  10577. * @interface Highcharts.SVGAttributes
  10578. */ /**
  10579. * @name Highcharts.SVGAttributes#[key:string]
  10580. * @type {*}
  10581. */ /**
  10582. * @name Highcharts.SVGAttributes#d
  10583. * @type {string|Highcharts.SVGPathArray|undefined}
  10584. */ /**
  10585. * @name Highcharts.SVGAttributes#fill
  10586. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject|undefined}
  10587. */ /**
  10588. * @name Highcharts.SVGAttributes#inverted
  10589. * @type {boolean|undefined}
  10590. */ /**
  10591. * @name Highcharts.SVGAttributes#matrix
  10592. * @type {Array<number>|undefined}
  10593. */ /**
  10594. * @name Highcharts.SVGAttributes#rotation
  10595. * @type {number|undefined}
  10596. */ /**
  10597. * @name Highcharts.SVGAttributes#rotationOriginX
  10598. * @type {number|undefined}
  10599. */ /**
  10600. * @name Highcharts.SVGAttributes#rotationOriginY
  10601. * @type {number|undefined}
  10602. */ /**
  10603. * @name Highcharts.SVGAttributes#scaleX
  10604. * @type {number|undefined}
  10605. */ /**
  10606. * @name Highcharts.SVGAttributes#scaleY
  10607. * @type {number|undefined}
  10608. */ /**
  10609. * @name Highcharts.SVGAttributes#stroke
  10610. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject|undefined}
  10611. */ /**
  10612. * @name Highcharts.SVGAttributes#style
  10613. * @type {string|Highcharts.CSSObject|undefined}
  10614. */ /**
  10615. * @name Highcharts.SVGAttributes#translateX
  10616. * @type {number|undefined}
  10617. */ /**
  10618. * @name Highcharts.SVGAttributes#translateY
  10619. * @type {number|undefined}
  10620. */ /**
  10621. * @name Highcharts.SVGAttributes#zIndex
  10622. * @type {number|undefined}
  10623. */
  10624. /**
  10625. * An SVG DOM element. The type is a reference to the regular SVGElement in the
  10626. * global scope.
  10627. *
  10628. * @typedef {globals.GlobalSVGElement} Highcharts.SVGDOMElement
  10629. *
  10630. * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGElement
  10631. */
  10632. /**
  10633. * The vertical alignment of an element.
  10634. *
  10635. * @typedef {"bottom"|"middle"|"top"} Highcharts.VerticalAlignValue
  10636. */
  10637. ''; // detach doclets above
  10638. return SVGElement;
  10639. });
  10640. _registerModule(_modules, 'Core/Renderer/SVG/SVGLabel.js', [_modules['Core/Renderer/SVG/SVGElement.js'], _modules['Core/Utilities.js']], function (SVGElement, U) {
  10641. /* *
  10642. *
  10643. * (c) 2010-2021 Torstein Honsi
  10644. *
  10645. * License: www.highcharts.com/license
  10646. *
  10647. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  10648. *
  10649. * */
  10650. var __extends = (this && this.__extends) || (function () {
  10651. var extendStatics = function (d,
  10652. b) {
  10653. extendStatics = Object.setPrototypeOf ||
  10654. ({ __proto__: [] } instanceof Array && function (d,
  10655. b) { d.__proto__ = b; }) ||
  10656. function (d,
  10657. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  10658. return extendStatics(d, b);
  10659. };
  10660. return function (d, b) {
  10661. extendStatics(d, b);
  10662. function __() { this.constructor = d; }
  10663. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  10664. };
  10665. })();
  10666. var defined = U.defined,
  10667. extend = U.extend,
  10668. isNumber = U.isNumber,
  10669. merge = U.merge,
  10670. pick = U.pick,
  10671. removeEvent = U.removeEvent;
  10672. /* eslint require-jsdoc: 0, no-invalid-this: 0 */
  10673. function paddingSetter(value, key) {
  10674. if (!isNumber(value)) {
  10675. this[key] = void 0;
  10676. }
  10677. else if (value !== this[key]) {
  10678. this[key] = value;
  10679. this.updateTextPadding();
  10680. }
  10681. }
  10682. /**
  10683. * SVG label to render text.
  10684. * @private
  10685. * @class
  10686. * @name Highcharts.SVGLabel
  10687. * @augments Highcharts.SVGElement
  10688. */
  10689. var SVGLabel = /** @class */ (function (_super) {
  10690. __extends(SVGLabel, _super);
  10691. /* *
  10692. *
  10693. * Constructors
  10694. *
  10695. * */
  10696. function SVGLabel(renderer, str, x, y, shape, anchorX, anchorY, useHTML, baseline, className) {
  10697. var _this = _super.call(this) || this;
  10698. _this.paddingSetter = paddingSetter;
  10699. _this.paddingLeftSetter = paddingSetter;
  10700. _this.paddingRightSetter = paddingSetter;
  10701. _this.init(renderer, 'g');
  10702. _this.textStr = str;
  10703. _this.x = x;
  10704. _this.y = y;
  10705. _this.anchorX = anchorX;
  10706. _this.anchorY = anchorY;
  10707. _this.baseline = baseline;
  10708. _this.className = className;
  10709. if (className !== 'button') {
  10710. _this.addClass('highcharts-label');
  10711. }
  10712. if (className) {
  10713. _this.addClass('highcharts-' + className);
  10714. }
  10715. _this.text = renderer.text('', 0, 0, useHTML).attr({ zIndex: 1 });
  10716. // Validate the shape argument
  10717. var hasBGImage;
  10718. if (typeof shape === 'string') {
  10719. hasBGImage = /^url\((.*?)\)$/.test(shape);
  10720. if (_this.renderer.symbols[shape] || hasBGImage) {
  10721. _this.symbolKey = shape;
  10722. }
  10723. }
  10724. _this.bBox = SVGLabel.emptyBBox;
  10725. _this.padding = 3;
  10726. _this.baselineOffset = 0;
  10727. _this.needsBox = renderer.styledMode || hasBGImage;
  10728. _this.deferredAttr = {};
  10729. _this.alignFactor = 0;
  10730. return _this;
  10731. }
  10732. /* *
  10733. *
  10734. * Functions
  10735. *
  10736. * */
  10737. SVGLabel.prototype.alignSetter = function (value) {
  10738. var alignFactor = ({
  10739. left: 0,
  10740. center: 0.5,
  10741. right: 1
  10742. })[value];
  10743. if (alignFactor !== this.alignFactor) {
  10744. this.alignFactor = alignFactor;
  10745. // Bounding box exists, means we're dynamically changing
  10746. if (this.bBox && isNumber(this.xSetting)) {
  10747. this.attr({ x: this.xSetting }); // #5134
  10748. }
  10749. }
  10750. };
  10751. SVGLabel.prototype.anchorXSetter = function (value, key) {
  10752. this.anchorX = value;
  10753. this.boxAttr(key, Math.round(value) - this.getCrispAdjust() - this.xSetting);
  10754. };
  10755. SVGLabel.prototype.anchorYSetter = function (value, key) {
  10756. this.anchorY = value;
  10757. this.boxAttr(key, value - this.ySetting);
  10758. };
  10759. /*
  10760. * Set a box attribute, or defer it if the box is not yet created
  10761. */
  10762. SVGLabel.prototype.boxAttr = function (key, value) {
  10763. if (this.box) {
  10764. this.box.attr(key, value);
  10765. }
  10766. else {
  10767. this.deferredAttr[key] = value;
  10768. }
  10769. };
  10770. /*
  10771. * Pick up some properties and apply them to the text instead of the
  10772. * wrapper.
  10773. */
  10774. SVGLabel.prototype.css = function (styles) {
  10775. if (styles) {
  10776. var textStyles_1 = {},
  10777. isWidth = void 0,
  10778. isFontStyle = void 0;
  10779. // Create a copy to avoid altering the original object
  10780. // (#537)
  10781. styles = merge(styles);
  10782. SVGLabel.textProps.forEach(function (prop) {
  10783. if (typeof styles[prop] !== 'undefined') {
  10784. textStyles_1[prop] = styles[prop];
  10785. delete styles[prop];
  10786. }
  10787. });
  10788. this.text.css(textStyles_1);
  10789. isWidth = 'width' in textStyles_1;
  10790. isFontStyle = 'fontSize' in textStyles_1 ||
  10791. 'fontWeight' in textStyles_1;
  10792. // Update existing text, box (#9400, #12163)
  10793. if (isFontStyle) {
  10794. this.updateTextPadding();
  10795. }
  10796. else if (isWidth) {
  10797. this.updateBoxSize();
  10798. }
  10799. }
  10800. return SVGElement.prototype.css.call(this, styles);
  10801. };
  10802. /*
  10803. * Destroy and release memory.
  10804. */
  10805. SVGLabel.prototype.destroy = function () {
  10806. // Added by button implementation
  10807. removeEvent(this.element, 'mouseenter');
  10808. removeEvent(this.element, 'mouseleave');
  10809. if (this.text) {
  10810. this.text.destroy();
  10811. }
  10812. if (this.box) {
  10813. this.box = this.box.destroy();
  10814. }
  10815. // Call base implementation to destroy the rest
  10816. SVGElement.prototype.destroy.call(this);
  10817. return void 0;
  10818. };
  10819. SVGLabel.prototype.fillSetter = function (value, key) {
  10820. if (value) {
  10821. this.needsBox = true;
  10822. }
  10823. // for animation getter (#6776)
  10824. this.fill = value;
  10825. this.boxAttr(key, value);
  10826. };
  10827. /*
  10828. * Return the bounding box of the box, not the group.
  10829. */
  10830. SVGLabel.prototype.getBBox = function () {
  10831. // If we have a text string and the DOM bBox was 0, it typically means
  10832. // that the label was first rendered hidden, so we need to update the
  10833. // bBox (#15246)
  10834. if (this.textStr && this.bBox.width === 0 && this.bBox.height === 0) {
  10835. this.updateBoxSize();
  10836. }
  10837. var padding = this.padding;
  10838. var paddingLeft = pick(this.paddingLeft,
  10839. padding);
  10840. return {
  10841. width: this.width,
  10842. height: this.height,
  10843. x: this.bBox.x - paddingLeft,
  10844. y: this.bBox.y - padding
  10845. };
  10846. };
  10847. SVGLabel.prototype.getCrispAdjust = function () {
  10848. return this.renderer.styledMode && this.box ?
  10849. this.box.strokeWidth() % 2 / 2 :
  10850. (this['stroke-width'] ? parseInt(this['stroke-width'], 10) : 0) % 2 / 2;
  10851. };
  10852. SVGLabel.prototype.heightSetter = function (value) {
  10853. this.heightSetting = value;
  10854. };
  10855. // Event handling. In case of useHTML, we need to make sure that events
  10856. // are captured on the span as well, and that mouseenter/mouseleave
  10857. // between the SVG group and the HTML span are not treated as real
  10858. // enter/leave events. #13310.
  10859. SVGLabel.prototype.on = function (eventType, handler) {
  10860. var label = this;
  10861. var text = label.text;
  10862. var span = text && text.element.tagName === 'SPAN' ? text : void 0;
  10863. var selectiveHandler;
  10864. if (span) {
  10865. selectiveHandler = function (e) {
  10866. if ((eventType === 'mouseenter' ||
  10867. eventType === 'mouseleave') &&
  10868. e.relatedTarget instanceof Element &&
  10869. (
  10870. // #14110
  10871. label.element.compareDocumentPosition(e.relatedTarget) & Node.DOCUMENT_POSITION_CONTAINED_BY ||
  10872. span.element.compareDocumentPosition(e.relatedTarget) & Node.DOCUMENT_POSITION_CONTAINED_BY)) {
  10873. return;
  10874. }
  10875. handler.call(label.element, e);
  10876. };
  10877. span.on(eventType, selectiveHandler);
  10878. }
  10879. SVGElement.prototype.on.call(label, eventType, selectiveHandler || handler);
  10880. return label;
  10881. };
  10882. /*
  10883. * After the text element is added, get the desired size of the border
  10884. * box and add it before the text in the DOM.
  10885. */
  10886. SVGLabel.prototype.onAdd = function () {
  10887. var str = this.textStr;
  10888. this.text.add(this);
  10889. this.attr({
  10890. // Alignment is available now (#3295, 0 not rendered if given
  10891. // as a value)
  10892. text: (defined(str) ? str : ''),
  10893. x: this.x,
  10894. y: this.y
  10895. });
  10896. if (this.box && defined(this.anchorX)) {
  10897. this.attr({
  10898. anchorX: this.anchorX,
  10899. anchorY: this.anchorY
  10900. });
  10901. }
  10902. };
  10903. SVGLabel.prototype.rSetter = function (value, key) {
  10904. this.boxAttr(key, value);
  10905. };
  10906. SVGLabel.prototype.shadow = function (b) {
  10907. if (b && !this.renderer.styledMode) {
  10908. this.updateBoxSize();
  10909. if (this.box) {
  10910. this.box.shadow(b);
  10911. }
  10912. }
  10913. return this;
  10914. };
  10915. SVGLabel.prototype.strokeSetter = function (value, key) {
  10916. // for animation getter (#6776)
  10917. this.stroke = value;
  10918. this.boxAttr(key, value);
  10919. };
  10920. SVGLabel.prototype['stroke-widthSetter'] = function (value, key) {
  10921. if (value) {
  10922. this.needsBox = true;
  10923. }
  10924. this['stroke-width'] = value;
  10925. this.boxAttr(key, value);
  10926. };
  10927. SVGLabel.prototype['text-alignSetter'] = function (value) {
  10928. this.textAlign = value;
  10929. };
  10930. SVGLabel.prototype.textSetter = function (text) {
  10931. if (typeof text !== 'undefined') {
  10932. // Must use .attr to ensure transforms are done (#10009)
  10933. this.text.attr({ text: text });
  10934. }
  10935. this.updateTextPadding();
  10936. };
  10937. /*
  10938. * This function runs after the label is added to the DOM (when the bounding
  10939. * box is available), and after the text of the label is updated to detect
  10940. * the new bounding box and reflect it in the border box.
  10941. */
  10942. SVGLabel.prototype.updateBoxSize = function () {
  10943. var style = this.text.element.style,
  10944. crispAdjust,
  10945. attribs = {};
  10946. var padding = this.padding;
  10947. // #12165 error when width is null (auto)
  10948. // #12163 when fontweight: bold, recalculate bBox withot cache
  10949. // #3295 && 3514 box failure when string equals 0
  10950. var bBox = this.bBox = ((!isNumber(this.widthSetting) || !isNumber(this.heightSetting) || this.textAlign) &&
  10951. defined(this.text.textStr)) ?
  10952. this.text.getBBox() : SVGLabel.emptyBBox;
  10953. this.width = this.getPaddedWidth();
  10954. this.height = (this.heightSetting || bBox.height || 0) + 2 * padding;
  10955. // Update the label-scoped y offset. Math.min because of inline
  10956. // style (#9400)
  10957. this.baselineOffset = padding + Math.min(this.renderer.fontMetrics(style && style.fontSize, this.text).b,
  10958. // When the height is 0, there is no bBox, so go with the font
  10959. // metrics. Highmaps CSS demos.
  10960. bBox.height || Infinity);
  10961. if (this.needsBox) {
  10962. // Create the border box if it is not already present
  10963. if (!this.box) {
  10964. // Symbol definition exists (#5324)
  10965. var box = this.box = this.symbolKey ?
  10966. this.renderer.symbol(this.symbolKey) :
  10967. this.renderer.rect();
  10968. box.addClass(// Don't use label className for buttons
  10969. (this.className === 'button' ? '' : 'highcharts-label-box') +
  10970. (this.className ? ' highcharts-' + this.className + '-box' : ''));
  10971. box.add(this);
  10972. }
  10973. crispAdjust = this.getCrispAdjust();
  10974. attribs.x = crispAdjust;
  10975. attribs.y = (this.baseline ? -this.baselineOffset : 0) + crispAdjust;
  10976. // Apply the box attributes
  10977. attribs.width = Math.round(this.width);
  10978. attribs.height = Math.round(this.height);
  10979. this.box.attr(extend(attribs, this.deferredAttr));
  10980. this.deferredAttr = {};
  10981. }
  10982. };
  10983. /*
  10984. * This function runs after setting text or padding, but only if padding
  10985. * is changed.
  10986. */
  10987. SVGLabel.prototype.updateTextPadding = function () {
  10988. var text = this.text;
  10989. this.updateBoxSize();
  10990. // Determine y based on the baseline
  10991. var textY = this.baseline ? 0 : this.baselineOffset;
  10992. var textX = pick(this.paddingLeft,
  10993. this.padding);
  10994. // compensate for alignment
  10995. if (defined(this.widthSetting) &&
  10996. this.bBox &&
  10997. (this.textAlign === 'center' || this.textAlign === 'right')) {
  10998. textX += { center: 0.5, right: 1 }[this.textAlign] *
  10999. (this.widthSetting - this.bBox.width);
  11000. }
  11001. // update if anything changed
  11002. if (textX !== text.x || textY !== text.y) {
  11003. text.attr('x', textX);
  11004. // #8159 - prevent misplaced data labels in treemap
  11005. // (useHTML: true)
  11006. if (text.hasBoxWidthChanged) {
  11007. this.bBox = text.getBBox(true);
  11008. }
  11009. if (typeof textY !== 'undefined') {
  11010. text.attr('y', textY);
  11011. }
  11012. }
  11013. // record current values
  11014. text.x = textX;
  11015. text.y = textY;
  11016. };
  11017. SVGLabel.prototype.widthSetter = function (value) {
  11018. // width:auto => null
  11019. this.widthSetting = isNumber(value) ? value : void 0;
  11020. };
  11021. SVGLabel.prototype.getPaddedWidth = function () {
  11022. var padding = this.padding;
  11023. var paddingLeft = pick(this.paddingLeft,
  11024. padding);
  11025. var paddingRight = pick(this.paddingRight,
  11026. padding);
  11027. return (this.widthSetting || this.bBox.width || 0) + paddingLeft + paddingRight;
  11028. };
  11029. SVGLabel.prototype.xSetter = function (value) {
  11030. this.x = value; // for animation getter
  11031. if (this.alignFactor) {
  11032. value -= this.alignFactor * this.getPaddedWidth();
  11033. // Force animation even when setting to the same value (#7898)
  11034. this['forceAnimate:x'] = true;
  11035. }
  11036. this.xSetting = Math.round(value);
  11037. this.attr('translateX', this.xSetting);
  11038. };
  11039. SVGLabel.prototype.ySetter = function (value) {
  11040. this.ySetting = this.y = Math.round(value);
  11041. this.attr('translateY', this.ySetting);
  11042. };
  11043. /* *
  11044. *
  11045. * Static Properties
  11046. *
  11047. * */
  11048. SVGLabel.emptyBBox = { width: 0, height: 0, x: 0, y: 0 };
  11049. /**
  11050. * For labels, these CSS properties are applied to the `text` node directly.
  11051. *
  11052. * @private
  11053. * @name Highcharts.SVGLabel#textProps
  11054. * @type {Array<string>}
  11055. */
  11056. SVGLabel.textProps = [
  11057. 'color', 'direction', 'fontFamily', 'fontSize', 'fontStyle',
  11058. 'fontWeight', 'lineHeight', 'textAlign', 'textDecoration',
  11059. 'textOutline', 'textOverflow', 'width'
  11060. ];
  11061. return SVGLabel;
  11062. }(SVGElement));
  11063. return SVGLabel;
  11064. });
  11065. _registerModule(_modules, 'Core/Renderer/SVG/TextBuilder.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js'], _modules['Core/Renderer/HTML/AST.js']], function (H, U, AST) {
  11066. /* *
  11067. *
  11068. * (c) 2010-2020 Torstein Honsi
  11069. *
  11070. * License: www.highcharts.com/license
  11071. *
  11072. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  11073. *
  11074. * */
  11075. var doc = H.doc,
  11076. SVG_NS = H.SVG_NS;
  11077. var attr = U.attr,
  11078. erase = U.erase,
  11079. isString = U.isString,
  11080. objectEach = U.objectEach,
  11081. pick = U.pick;
  11082. /**
  11083. * SVG Text Builder
  11084. * @private
  11085. * @class
  11086. * @name Highcharts.TextBuilder
  11087. */
  11088. var TextBuilder = /** @class */ (function () {
  11089. function TextBuilder(svgElement) {
  11090. var textStyles = svgElement.styles;
  11091. this.renderer = svgElement.renderer;
  11092. this.svgElement = svgElement;
  11093. this.width = svgElement.textWidth;
  11094. this.textLineHeight = textStyles && textStyles.lineHeight;
  11095. this.textOutline = textStyles && textStyles.textOutline;
  11096. this.ellipsis = Boolean(textStyles && textStyles.textOverflow === 'ellipsis');
  11097. this.noWrap = Boolean(textStyles && textStyles.whiteSpace === 'nowrap');
  11098. this.fontSize = textStyles && textStyles.fontSize;
  11099. }
  11100. /**
  11101. * Build an SVG representation of the pseudo HTML given in the object's
  11102. * svgElement.
  11103. *
  11104. * @private
  11105. *
  11106. * @return {void}.
  11107. */
  11108. TextBuilder.prototype.buildSVG = function () {
  11109. var wrapper = this.svgElement;
  11110. var textNode = wrapper.element, renderer = wrapper.renderer, textStr = pick(wrapper.textStr, '').toString(), hasMarkup = textStr.indexOf('<') !== -1, childNodes = textNode.childNodes, textCache, i = childNodes.length, tempParent = this.width && !wrapper.added && renderer.box;
  11111. var regexMatchBreaks = /<br.*?>/g;
  11112. // The buildText code is quite heavy, so if we're not changing something
  11113. // that affects the text, skip it (#6113).
  11114. textCache = [
  11115. textStr,
  11116. this.ellipsis,
  11117. this.noWrap,
  11118. this.textLineHeight,
  11119. this.textOutline,
  11120. this.fontSize,
  11121. this.width
  11122. ].join(',');
  11123. if (textCache === wrapper.textCache) {
  11124. return;
  11125. }
  11126. wrapper.textCache = textCache;
  11127. delete wrapper.actualWidth;
  11128. // Remove old text
  11129. while (i--) {
  11130. textNode.removeChild(childNodes[i]);
  11131. }
  11132. // Simple strings, add text directly and return
  11133. if (!hasMarkup &&
  11134. !this.ellipsis &&
  11135. !this.width &&
  11136. (textStr.indexOf(' ') === -1 ||
  11137. (this.noWrap && !regexMatchBreaks.test(textStr)))) {
  11138. textNode.appendChild(doc.createTextNode(this.unescapeEntities(textStr)));
  11139. // Complex strings, add more logic
  11140. }
  11141. else if (textStr !== '') {
  11142. if (tempParent) {
  11143. // attach it to the DOM to read offset width
  11144. tempParent.appendChild(textNode);
  11145. }
  11146. // Step 1. Parse the markup safely and directly into a tree
  11147. // structure.
  11148. var ast = new AST(textStr);
  11149. // Step 2. Do as many as we can of the modifications to the tree
  11150. // structure before it is added to the DOM
  11151. this.modifyTree(ast.nodes);
  11152. ast.addToDOM(wrapper.element);
  11153. // Step 3. Some modifications can't be done until the structure is
  11154. // in the DOM, because we need to read computed metrics.
  11155. this.modifyDOM();
  11156. // Add title if an ellipsis was added
  11157. if (this.ellipsis &&
  11158. (textNode.textContent || '').indexOf('\u2026') !== -1) {
  11159. wrapper.attr('title', this.unescapeEntities(wrapper.textStr || '', ['&lt;', '&gt;']) // #7179
  11160. );
  11161. }
  11162. if (tempParent) {
  11163. tempParent.removeChild(textNode);
  11164. }
  11165. }
  11166. // Apply the text outline
  11167. if (isString(this.textOutline) && wrapper.applyTextOutline) {
  11168. wrapper.applyTextOutline(this.textOutline);
  11169. }
  11170. };
  11171. /**
  11172. * Modify the DOM of the generated SVG structure. This function only does
  11173. * operations that cannot be done until the elements are attached to the
  11174. * DOM, like doing layout based on rendered metrics of the added elements.
  11175. *
  11176. * @private
  11177. *
  11178. * @return {void}
  11179. */
  11180. TextBuilder.prototype.modifyDOM = function () {
  11181. var _this = this;
  11182. var wrapper = this.svgElement;
  11183. var x = attr(wrapper.element, 'x');
  11184. // Modify hard line breaks by applying the rendered line height
  11185. [].forEach.call(wrapper.element.querySelectorAll('tspan.highcharts-br'), function (br) {
  11186. if (br.nextSibling && br.previousSibling) { // #5261
  11187. attr(br, {
  11188. // Since the break is inserted in front of the next
  11189. // line, we need to use the next sibling for the line
  11190. // height
  11191. dy: _this.getLineHeight(br.nextSibling),
  11192. x: x
  11193. });
  11194. }
  11195. });
  11196. // Constrain the line width, either by ellipsis or wrapping
  11197. var width = this.width || 0;
  11198. if (!width) {
  11199. return;
  11200. }
  11201. // Insert soft line breaks into each text node
  11202. var modifyTextNode = function (textNode,
  11203. parentElement) {
  11204. var text = textNode.textContent || '';
  11205. var words = text
  11206. .replace(/([^\^])-/g, '$1- ') // Split on hyphens
  11207. // .trim()
  11208. .split(' '); // #1273
  11209. var hasWhiteSpace = !_this.noWrap && (words.length > 1 || wrapper.element.childNodes.length > 1);
  11210. var dy = _this.getLineHeight(parentElement);
  11211. var lineNo = 0;
  11212. var startAt = wrapper.actualWidth;
  11213. if (_this.ellipsis) {
  11214. if (text) {
  11215. _this.truncate(textNode, text, void 0, 0,
  11216. // Target width
  11217. Math.max(0,
  11218. // Substract the font face to make room for the
  11219. // ellipsis itself
  11220. width - parseInt(_this.fontSize || 12, 10)),
  11221. // Build the text to test for
  11222. function (text, currentIndex) {
  11223. return text.substring(0, currentIndex) + '\u2026';
  11224. });
  11225. }
  11226. }
  11227. else if (hasWhiteSpace) {
  11228. var lines = [];
  11229. // Remove preceding siblings in order to make the text length
  11230. // calculation correct in the truncate function
  11231. var precedingSiblings = [];
  11232. while (parentElement.firstChild &&
  11233. parentElement.firstChild !== textNode) {
  11234. precedingSiblings.push(parentElement.firstChild);
  11235. parentElement.removeChild(parentElement.firstChild);
  11236. }
  11237. while (words.length) {
  11238. // Apply the previous line
  11239. if (words.length && !_this.noWrap && lineNo > 0) {
  11240. lines.push(textNode.textContent || '');
  11241. textNode.textContent = words.join(' ')
  11242. .replace(/- /g, '-');
  11243. }
  11244. // For each line, truncate the remaining
  11245. // words into the line length.
  11246. _this.truncate(textNode, void 0, words, lineNo === 0 ? (startAt || 0) : 0, width,
  11247. // Build the text to test for
  11248. function (t, currentIndex) {
  11249. return words
  11250. .slice(0, currentIndex)
  11251. .join(' ')
  11252. .replace(/- /g, '-');
  11253. });
  11254. startAt = wrapper.actualWidth;
  11255. lineNo++;
  11256. }
  11257. // Reinsert the preceding child nodes
  11258. precedingSiblings.forEach(function (childNode) {
  11259. parentElement.insertBefore(childNode, textNode);
  11260. });
  11261. // Insert the previous lines before the original text node
  11262. lines.forEach(function (line) {
  11263. // Insert the line
  11264. parentElement.insertBefore(doc.createTextNode(line), textNode);
  11265. // Insert a break
  11266. var br = doc.createElementNS(SVG_NS, 'tspan');
  11267. br.textContent = '\u200B'; // zero-width space
  11268. attr(br, { dy: dy, x: x });
  11269. parentElement.insertBefore(br, textNode);
  11270. });
  11271. }
  11272. };
  11273. // Recurse down the DOM tree and handle line breaks for each text node
  11274. var modifyChildren = (function (node) {
  11275. var childNodes = [].slice.call(node.childNodes);
  11276. childNodes.forEach(function (childNode) {
  11277. if (childNode.nodeType === Node.TEXT_NODE) {
  11278. modifyTextNode(childNode, node);
  11279. }
  11280. else {
  11281. // Reset word-wrap width readings after hard breaks
  11282. if (childNode.className.baseVal
  11283. .indexOf('highcharts-br') !== -1) {
  11284. wrapper.actualWidth = 0;
  11285. }
  11286. // Recurse down to child node
  11287. modifyChildren(childNode);
  11288. }
  11289. });
  11290. });
  11291. modifyChildren(wrapper.element);
  11292. };
  11293. /**
  11294. * Get the rendered line height of a <text>, <tspan> or pure text node.
  11295. *
  11296. * @param {DOMElementType|Text} node The node to check for
  11297. *
  11298. * @return {number} The rendered line height
  11299. */
  11300. TextBuilder.prototype.getLineHeight = function (node) {
  11301. var fontSizeStyle;
  11302. // If the node is a text node, use its parent
  11303. var element = node.nodeType === Node.TEXT_NODE ?
  11304. node.parentElement :
  11305. node;
  11306. if (!this.renderer.styledMode) {
  11307. fontSizeStyle =
  11308. element && /(px|em)$/.test(element.style.fontSize) ?
  11309. element.style.fontSize :
  11310. (this.fontSize || this.renderer.style.fontSize || 12);
  11311. }
  11312. return this.textLineHeight ?
  11313. parseInt(this.textLineHeight.toString(), 10) :
  11314. this.renderer.fontMetrics(fontSizeStyle, element || this.svgElement.element).h;
  11315. };
  11316. /**
  11317. * Transform a pseudo HTML AST node tree into an SVG structure. We do as
  11318. * much heavy lifting as we can here, before doing the final processing in
  11319. * the modifyDOM function. The original data is mutated.
  11320. *
  11321. * @private
  11322. *
  11323. * @param {ASTNode[]} nodes The AST nodes
  11324. *
  11325. * @return {void}
  11326. */
  11327. TextBuilder.prototype.modifyTree = function (nodes) {
  11328. var _this = this;
  11329. var modifyChild = function (node,
  11330. i) {
  11331. var tagName = node.tagName;
  11332. var styledMode = _this.renderer.styledMode;
  11333. var attributes = node.attributes || {};
  11334. // Apply styling to text tags
  11335. if (tagName === 'b' || tagName === 'strong') {
  11336. if (styledMode) {
  11337. attributes['class'] = 'highcharts-strong'; // eslint-disable-line dot-notation
  11338. }
  11339. else {
  11340. attributes.style = 'font-weight:bold;' + (attributes.style || '');
  11341. }
  11342. }
  11343. else if (tagName === 'i' || tagName === 'em') {
  11344. if (styledMode) {
  11345. attributes['class'] = 'highcharts-emphasized'; // eslint-disable-line dot-notation
  11346. }
  11347. else {
  11348. attributes.style = 'font-style:italic;' + (attributes.style || '');
  11349. }
  11350. }
  11351. // Modify attributes
  11352. if (isString(attributes.style)) {
  11353. attributes.style = attributes.style.replace(/(;| |^)color([ :])/, '$1fill$2');
  11354. }
  11355. if (tagName === 'br') {
  11356. attributes['class'] = 'highcharts-br'; // eslint-disable-line dot-notation
  11357. node.textContent = '\u200B'; // zero-width space
  11358. // Trim whitespace off the beginning of new lines
  11359. var nextNode = nodes[i + 1];
  11360. if (nextNode && nextNode.textContent) {
  11361. nextNode.textContent =
  11362. nextNode.textContent.replace(/^ +/gm, '');
  11363. }
  11364. }
  11365. if (tagName !== '#text' && tagName !== 'a') {
  11366. node.tagName = 'tspan';
  11367. }
  11368. node.attributes = attributes;
  11369. // Recurse
  11370. if (node.children) {
  11371. node.children
  11372. .filter(function (c) { return c.tagName !== '#text'; })
  11373. .forEach(modifyChild);
  11374. }
  11375. };
  11376. nodes.forEach(modifyChild);
  11377. // Remove empty spans from the beginning because SVG's getBBox doesn't
  11378. // count empty lines. The use case is tooltip where the header is empty.
  11379. while (nodes[0]) {
  11380. if (nodes[0].tagName === 'tspan' && !nodes[0].children) {
  11381. nodes.splice(0, 1);
  11382. }
  11383. else {
  11384. break;
  11385. }
  11386. }
  11387. };
  11388. /*
  11389. * Truncate the text node contents to a given length. Used when the css
  11390. * width is set. If the `textOverflow` is `ellipsis`, the text is truncated
  11391. * character by character to the given length. If not, the text is
  11392. * word-wrapped line by line.
  11393. */
  11394. TextBuilder.prototype.truncate = function (textNode, text, words, startAt, width, getString) {
  11395. var svgElement = this.svgElement;
  11396. var renderer = svgElement.renderer,
  11397. rotation = svgElement.rotation;
  11398. // Cache the lengths to avoid checking the same twice
  11399. var lengths = [];
  11400. // Word wrap can not be truncated to shorter than one word, ellipsis
  11401. // text can be completely blank.
  11402. var minIndex = words ? 1 : 0;
  11403. var maxIndex = (text || words || '').length;
  11404. var currentIndex = maxIndex;
  11405. var str;
  11406. var actualWidth;
  11407. var getSubStringLength = function (charEnd,
  11408. concatenatedEnd) {
  11409. // charEnd is used when finding the character-by-character
  11410. // break for ellipsis, concatenatedEnd is used for word-by-word
  11411. // break for word wrapping.
  11412. var end = concatenatedEnd || charEnd;
  11413. var parentNode = textNode.parentNode;
  11414. if (parentNode && typeof lengths[end] === 'undefined') {
  11415. // Modern browsers
  11416. if (parentNode.getSubStringLength) {
  11417. // Fails with DOM exception on unit-tests/legend/members
  11418. // of unknown reason. Desired width is 0, text content
  11419. // is "5" and end is 1.
  11420. try {
  11421. lengths[end] = startAt +
  11422. parentNode.getSubStringLength(0, words ? end + 1 : end);
  11423. }
  11424. catch (e) {
  11425. '';
  11426. }
  11427. // Legacy
  11428. }
  11429. else if (renderer.getSpanWidth) { // #9058 jsdom
  11430. textNode.textContent = getString(text || words, charEnd);
  11431. lengths[end] = startAt +
  11432. renderer.getSpanWidth(svgElement, textNode);
  11433. }
  11434. }
  11435. return lengths[end];
  11436. };
  11437. svgElement.rotation = 0; // discard rotation when computing box
  11438. actualWidth = getSubStringLength(textNode.textContent.length);
  11439. if (startAt + actualWidth > width) {
  11440. // Do a binary search for the index where to truncate the text
  11441. while (minIndex <= maxIndex) {
  11442. currentIndex = Math.ceil((minIndex + maxIndex) / 2);
  11443. // When checking words for word-wrap, we need to build the
  11444. // string and measure the subStringLength at the concatenated
  11445. // word length.
  11446. if (words) {
  11447. str = getString(words, currentIndex);
  11448. }
  11449. actualWidth = getSubStringLength(currentIndex, str && str.length - 1);
  11450. if (minIndex === maxIndex) {
  11451. // Complete
  11452. minIndex = maxIndex + 1;
  11453. }
  11454. else if (actualWidth > width) {
  11455. // Too large. Set max index to current.
  11456. maxIndex = currentIndex - 1;
  11457. }
  11458. else {
  11459. // Within width. Set min index to current.
  11460. minIndex = currentIndex;
  11461. }
  11462. }
  11463. // If max index was 0 it means the shortest possible text was also
  11464. // too large. For ellipsis that means only the ellipsis, while for
  11465. // word wrap it means the whole first word.
  11466. if (maxIndex === 0) {
  11467. // Remove ellipsis
  11468. textNode.textContent = '';
  11469. // If the new text length is one less than the original, we don't
  11470. // need the ellipsis
  11471. }
  11472. else if (!(text && maxIndex === text.length - 1)) {
  11473. textNode.textContent = str || getString(text || words, currentIndex);
  11474. }
  11475. }
  11476. // When doing line wrapping, prepare for the next line by removing the
  11477. // items from this line.
  11478. if (words) {
  11479. words.splice(0, currentIndex);
  11480. }
  11481. svgElement.actualWidth = actualWidth;
  11482. svgElement.rotation = rotation; // Apply rotation again.
  11483. };
  11484. /*
  11485. * Un-escape HTML entities based on the public `renderer.escapes` list
  11486. *
  11487. * @private
  11488. *
  11489. * @param {string} inputStr The string to unescape
  11490. * @param {Array<string>} [except] Exceptions
  11491. *
  11492. * @return {string} The processed string
  11493. */
  11494. TextBuilder.prototype.unescapeEntities = function (inputStr, except) {
  11495. objectEach(this.renderer.escapes, function (value, key) {
  11496. if (!except || except.indexOf(value) === -1) {
  11497. inputStr = inputStr.toString().replace(new RegExp(value, 'g'), key);
  11498. }
  11499. });
  11500. return inputStr;
  11501. };
  11502. return TextBuilder;
  11503. }());
  11504. return TextBuilder;
  11505. });
  11506. _registerModule(_modules, 'Core/Renderer/SVG/SVGRenderer.js', [_modules['Core/Color/Color.js'], _modules['Core/Globals.js'], _modules['Core/Color/Palette.js'], _modules['Core/Renderer/SVG/SVGElement.js'], _modules['Core/Renderer/SVG/SVGLabel.js'], _modules['Core/Renderer/HTML/AST.js'], _modules['Core/Renderer/SVG/TextBuilder.js'], _modules['Core/Utilities.js']], function (Color, H, palette, SVGElement, SVGLabel, AST, TextBuilder, U) {
  11507. /* *
  11508. *
  11509. * (c) 2010-2021 Torstein Honsi
  11510. *
  11511. * License: www.highcharts.com/license
  11512. *
  11513. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  11514. *
  11515. * */
  11516. var addEvent = U.addEvent,
  11517. attr = U.attr,
  11518. createElement = U.createElement,
  11519. css = U.css,
  11520. defined = U.defined,
  11521. destroyObjectProperties = U.destroyObjectProperties,
  11522. extend = U.extend,
  11523. isArray = U.isArray,
  11524. isNumber = U.isNumber,
  11525. isObject = U.isObject,
  11526. isString = U.isString,
  11527. merge = U.merge,
  11528. pick = U.pick,
  11529. pInt = U.pInt,
  11530. uniqueKey = U.uniqueKey;
  11531. /**
  11532. * A clipping rectangle that can be applied to one or more {@link SVGElement}
  11533. * instances. It is instanciated with the {@link SVGRenderer#clipRect} function
  11534. * and applied with the {@link SVGElement#clip} function.
  11535. *
  11536. * @example
  11537. * let circle = renderer.circle(100, 100, 100)
  11538. * .attr({ fill: 'red' })
  11539. * .add();
  11540. * let clipRect = renderer.clipRect(100, 100, 100, 100);
  11541. *
  11542. * // Leave only the lower right quarter visible
  11543. * circle.clip(clipRect);
  11544. *
  11545. * @typedef {Highcharts.SVGElement} Highcharts.ClipRectElement
  11546. */
  11547. /**
  11548. * The font metrics.
  11549. *
  11550. * @interface Highcharts.FontMetricsObject
  11551. */ /**
  11552. * The baseline relative to the top of the box.
  11553. *
  11554. * @name Highcharts.FontMetricsObject#b
  11555. * @type {number}
  11556. */ /**
  11557. * The font size.
  11558. *
  11559. * @name Highcharts.FontMetricsObject#f
  11560. * @type {number}
  11561. */ /**
  11562. * The line height.
  11563. *
  11564. * @name Highcharts.FontMetricsObject#h
  11565. * @type {number}
  11566. */
  11567. /**
  11568. * An object containing `x` and `y` properties for the position of an element.
  11569. *
  11570. * @interface Highcharts.PositionObject
  11571. */ /**
  11572. * X position of the element.
  11573. * @name Highcharts.PositionObject#x
  11574. * @type {number}
  11575. */ /**
  11576. * Y position of the element.
  11577. * @name Highcharts.PositionObject#y
  11578. * @type {number}
  11579. */
  11580. /**
  11581. * A rectangle.
  11582. *
  11583. * @interface Highcharts.RectangleObject
  11584. */ /**
  11585. * Height of the rectangle.
  11586. * @name Highcharts.RectangleObject#height
  11587. * @type {number}
  11588. */ /**
  11589. * Width of the rectangle.
  11590. * @name Highcharts.RectangleObject#width
  11591. * @type {number}
  11592. */ /**
  11593. * Horizontal position of the rectangle.
  11594. * @name Highcharts.RectangleObject#x
  11595. * @type {number}
  11596. */ /**
  11597. * Vertical position of the rectangle.
  11598. * @name Highcharts.RectangleObject#y
  11599. * @type {number}
  11600. */
  11601. /**
  11602. * The shadow options.
  11603. *
  11604. * @interface Highcharts.ShadowOptionsObject
  11605. */ /**
  11606. * The shadow color.
  11607. * @name Highcharts.ShadowOptionsObject#color
  11608. * @type {Highcharts.ColorString|undefined}
  11609. * @default ${palette.neutralColor100}
  11610. */ /**
  11611. * The horizontal offset from the element.
  11612. *
  11613. * @name Highcharts.ShadowOptionsObject#offsetX
  11614. * @type {number|undefined}
  11615. * @default 1
  11616. */ /**
  11617. * The vertical offset from the element.
  11618. * @name Highcharts.ShadowOptionsObject#offsetY
  11619. * @type {number|undefined}
  11620. * @default 1
  11621. */ /**
  11622. * The shadow opacity.
  11623. *
  11624. * @name Highcharts.ShadowOptionsObject#opacity
  11625. * @type {number|undefined}
  11626. * @default 0.15
  11627. */ /**
  11628. * The shadow width or distance from the element.
  11629. * @name Highcharts.ShadowOptionsObject#width
  11630. * @type {number|undefined}
  11631. * @default 3
  11632. */
  11633. /**
  11634. * @interface Highcharts.SizeObject
  11635. */ /**
  11636. * @name Highcharts.SizeObject#height
  11637. * @type {number}
  11638. */ /**
  11639. * @name Highcharts.SizeObject#width
  11640. * @type {number}
  11641. */
  11642. /**
  11643. * Array of path commands, that will go into the `d` attribute of an SVG
  11644. * element.
  11645. *
  11646. * @typedef {Array<(Array<Highcharts.SVGPathCommand>|Array<Highcharts.SVGPathCommand,number>|Array<Highcharts.SVGPathCommand,number,number>|Array<Highcharts.SVGPathCommand,number,number,number,number>|Array<Highcharts.SVGPathCommand,number,number,number,number,number,number>|Array<Highcharts.SVGPathCommand,number,number,number,number,number,number,number>)>} Highcharts.SVGPathArray
  11647. */
  11648. /**
  11649. * Possible path commands in an SVG path array. Valid values are `A`, `C`, `H`,
  11650. * `L`, `M`, `Q`, `S`, `T`, `V`, `Z`.
  11651. *
  11652. * @typedef {string} Highcharts.SVGPathCommand
  11653. * @validvalue ["a","c","h","l","m","q","s","t","v","z","A","C","H","L","M","Q","S","T","V","Z"]
  11654. */
  11655. /**
  11656. * An extendable collection of functions for defining symbol paths. Symbols are
  11657. * used internally for point markers, button and label borders and backgrounds,
  11658. * or custom shapes. Extendable by adding to {@link SVGRenderer#symbols}.
  11659. *
  11660. * @interface Highcharts.SymbolDictionary
  11661. */ /**
  11662. * @name Highcharts.SymbolDictionary#[key:string]
  11663. * @type {Function|undefined}
  11664. */ /**
  11665. * @name Highcharts.SymbolDictionary#arc
  11666. * @type {Function|undefined}
  11667. */ /**
  11668. * @name Highcharts.SymbolDictionary#callout
  11669. * @type {Function|undefined}
  11670. */ /**
  11671. * @name Highcharts.SymbolDictionary#circle
  11672. * @type {Function|undefined}
  11673. */ /**
  11674. * @name Highcharts.SymbolDictionary#diamond
  11675. * @type {Function|undefined}
  11676. */ /**
  11677. * @name Highcharts.SymbolDictionary#square
  11678. * @type {Function|undefined}
  11679. */ /**
  11680. * @name Highcharts.SymbolDictionary#triangle
  11681. * @type {Function|undefined}
  11682. */
  11683. /**
  11684. * Can be one of `arc`, `callout`, `circle`, `diamond`, `square`, `triangle`,
  11685. * and `triangle-down`. Symbols are used internally for point markers, button
  11686. * and label borders and backgrounds, or custom shapes. Extendable by adding to
  11687. * {@link SVGRenderer#symbols}.
  11688. *
  11689. * @typedef {"arc"|"callout"|"circle"|"diamond"|"square"|"triangle"|"triangle-down"} Highcharts.SymbolKeyValue
  11690. */
  11691. /**
  11692. * Additional options, depending on the actual symbol drawn.
  11693. *
  11694. * @interface Highcharts.SymbolOptionsObject
  11695. */ /**
  11696. * The anchor X position for the `callout` symbol. This is where the chevron
  11697. * points to.
  11698. *
  11699. * @name Highcharts.SymbolOptionsObject#anchorX
  11700. * @type {number|undefined}
  11701. */ /**
  11702. * The anchor Y position for the `callout` symbol. This is where the chevron
  11703. * points to.
  11704. *
  11705. * @name Highcharts.SymbolOptionsObject#anchorY
  11706. * @type {number|undefined}
  11707. */ /**
  11708. * The end angle of an `arc` symbol.
  11709. *
  11710. * @name Highcharts.SymbolOptionsObject#end
  11711. * @type {number|undefined}
  11712. */ /**
  11713. * Whether to draw `arc` symbol open or closed.
  11714. *
  11715. * @name Highcharts.SymbolOptionsObject#open
  11716. * @type {boolean|undefined}
  11717. */ /**
  11718. * The radius of an `arc` symbol, or the border radius for the `callout` symbol.
  11719. *
  11720. * @name Highcharts.SymbolOptionsObject#r
  11721. * @type {number|undefined}
  11722. */ /**
  11723. * The start angle of an `arc` symbol.
  11724. *
  11725. * @name Highcharts.SymbolOptionsObject#start
  11726. * @type {number|undefined}
  11727. */
  11728. /* eslint-disable no-invalid-this, valid-jsdoc */
  11729. var charts = H.charts,
  11730. deg2rad = H.deg2rad,
  11731. doc = H.doc,
  11732. isFirefox = H.isFirefox,
  11733. isMS = H.isMS,
  11734. isWebKit = H.isWebKit,
  11735. noop = H.noop,
  11736. SVG_NS = H.SVG_NS,
  11737. symbolSizes = H.symbolSizes,
  11738. win = H.win,
  11739. hasInternalReferenceBug;
  11740. /**
  11741. * Allows direct access to the Highcharts rendering layer in order to draw
  11742. * primitive shapes like circles, rectangles, paths or text directly on a chart,
  11743. * or independent from any chart. The SVGRenderer represents a wrapper object
  11744. * for SVG in modern browsers. Through the VMLRenderer, part of the `oldie.js`
  11745. * module, it also brings vector graphics to IE <= 8.
  11746. *
  11747. * An existing chart's renderer can be accessed through {@link Chart.renderer}.
  11748. * The renderer can also be used completely decoupled from a chart.
  11749. *
  11750. * @sample highcharts/members/renderer-on-chart
  11751. * Annotating a chart programmatically.
  11752. * @sample highcharts/members/renderer-basic
  11753. * Independent SVG drawing.
  11754. *
  11755. * @example
  11756. * // Use directly without a chart object.
  11757. * let renderer = new Highcharts.Renderer(parentNode, 600, 400);
  11758. *
  11759. * @class
  11760. * @name Highcharts.SVGRenderer
  11761. *
  11762. * @param {Highcharts.HTMLDOMElement} container
  11763. * Where to put the SVG in the web page.
  11764. *
  11765. * @param {number} width
  11766. * The width of the SVG.
  11767. *
  11768. * @param {number} height
  11769. * The height of the SVG.
  11770. *
  11771. * @param {Highcharts.CSSObject} [style]
  11772. * The box style, if not in styleMode
  11773. *
  11774. * @param {boolean} [forExport=false]
  11775. * Whether the rendered content is intended for export.
  11776. *
  11777. * @param {boolean} [allowHTML=true]
  11778. * Whether the renderer is allowed to include HTML text, which will be
  11779. * projected on top of the SVG.
  11780. *
  11781. * @param {boolean} [styledMode=false]
  11782. * Whether the renderer belongs to a chart that is in styled mode.
  11783. * If it does, it will avoid setting presentational attributes in
  11784. * some cases, but not when set explicitly through `.attr` and `.css`
  11785. * etc.
  11786. */
  11787. var SVGRenderer = /** @class */ (function () {
  11788. /* *
  11789. *
  11790. * Constructors
  11791. *
  11792. * */
  11793. function SVGRenderer(container, width, height, style, forExport, allowHTML, styledMode) {
  11794. /* *
  11795. *
  11796. * Properties
  11797. *
  11798. * */
  11799. this.alignedObjects = void 0;
  11800. /**
  11801. * The root `svg` node of the renderer.
  11802. *
  11803. * @name Highcharts.SVGRenderer#box
  11804. * @type {Highcharts.SVGDOMElement}
  11805. */
  11806. this.box = void 0;
  11807. /**
  11808. * The wrapper for the root `svg` node of the renderer.
  11809. *
  11810. * @name Highcharts.SVGRenderer#boxWrapper
  11811. * @type {Highcharts.SVGElement}
  11812. */
  11813. this.boxWrapper = void 0;
  11814. this.cache = void 0;
  11815. this.cacheKeys = void 0;
  11816. this.chartIndex = void 0;
  11817. /**
  11818. * A pointer to the `defs` node of the root SVG.
  11819. *
  11820. * @name Highcharts.SVGRenderer#defs
  11821. * @type {Highcharts.SVGElement}
  11822. */
  11823. this.defs = void 0;
  11824. this.globalAnimation = void 0;
  11825. this.gradients = void 0;
  11826. this.height = void 0;
  11827. this.imgCount = void 0;
  11828. this.isSVG = void 0;
  11829. this.style = void 0;
  11830. /**
  11831. * Page url used for internal references.
  11832. *
  11833. * @private
  11834. * @name Highcharts.SVGRenderer#url
  11835. * @type {string}
  11836. */
  11837. this.url = void 0;
  11838. this.width = void 0;
  11839. this.init(container, width, height, style, forExport, allowHTML, styledMode);
  11840. }
  11841. /* *
  11842. *
  11843. * Functions
  11844. *
  11845. * */
  11846. /**
  11847. * Initialize the SVGRenderer. Overridable initializer function that takes
  11848. * the same parameters as the constructor.
  11849. *
  11850. * @function Highcharts.SVGRenderer#init
  11851. *
  11852. * @param {Highcharts.HTMLDOMElement} container
  11853. * Where to put the SVG in the web page.
  11854. *
  11855. * @param {number} width
  11856. * The width of the SVG.
  11857. *
  11858. * @param {number} height
  11859. * The height of the SVG.
  11860. *
  11861. * @param {Highcharts.CSSObject} [style]
  11862. * The box style, if not in styleMode
  11863. *
  11864. * @param {boolean} [forExport=false]
  11865. * Whether the rendered content is intended for export.
  11866. *
  11867. * @param {boolean} [allowHTML=true]
  11868. * Whether the renderer is allowed to include HTML text, which will be
  11869. * projected on top of the SVG.
  11870. *
  11871. * @param {boolean} [styledMode=false]
  11872. * Whether the renderer belongs to a chart that is in styled mode. If it
  11873. * does, it will avoid setting presentational attributes in some cases, but
  11874. * not when set explicitly through `.attr` and `.css` etc.
  11875. */
  11876. SVGRenderer.prototype.init = function (container, width, height, style, forExport, allowHTML, styledMode) {
  11877. var renderer = this,
  11878. boxWrapper,
  11879. element,
  11880. desc;
  11881. boxWrapper = renderer.createElement('svg')
  11882. .attr({
  11883. version: '1.1',
  11884. 'class': 'highcharts-root'
  11885. });
  11886. if (!styledMode) {
  11887. boxWrapper.css(this.getStyle(style));
  11888. }
  11889. element = boxWrapper.element;
  11890. container.appendChild(element);
  11891. // Always use ltr on the container, otherwise text-anchor will be
  11892. // flipped and text appear outside labels, buttons, tooltip etc (#3482)
  11893. attr(container, 'dir', 'ltr');
  11894. // For browsers other than IE, add the namespace attribute (#1978)
  11895. if (container.innerHTML.indexOf('xmlns') === -1) {
  11896. attr(element, 'xmlns', this.SVG_NS);
  11897. }
  11898. // object properties
  11899. renderer.isSVG = true;
  11900. this.box = element;
  11901. this.boxWrapper = boxWrapper;
  11902. renderer.alignedObjects = [];
  11903. this.url = this.getReferenceURL();
  11904. // Add description
  11905. desc = this.createElement('desc').add();
  11906. desc.element.appendChild(doc.createTextNode('Created with Highcharts 9.1.0'));
  11907. renderer.defs = this.createElement('defs').add();
  11908. renderer.allowHTML = allowHTML;
  11909. renderer.forExport = forExport;
  11910. renderer.styledMode = styledMode;
  11911. renderer.gradients = {}; // Object where gradient SvgElements are stored
  11912. renderer.cache = {}; // Cache for numerical bounding boxes
  11913. renderer.cacheKeys = [];
  11914. renderer.imgCount = 0;
  11915. renderer.setSize(width, height, false);
  11916. // Issue 110 workaround:
  11917. // In Firefox, if a div is positioned by percentage, its pixel position
  11918. // may land between pixels. The container itself doesn't display this,
  11919. // but an SVG element inside this container will be drawn at subpixel
  11920. // precision. In order to draw sharp lines, this must be compensated
  11921. // for. This doesn't seem to work inside iframes though (like in
  11922. // jsFiddle).
  11923. var subPixelFix,
  11924. rect;
  11925. if (isFirefox && container.getBoundingClientRect) {
  11926. subPixelFix = function () {
  11927. css(container, { left: 0, top: 0 });
  11928. rect = container.getBoundingClientRect();
  11929. css(container, {
  11930. left: (Math.ceil(rect.left) - rect.left) + 'px',
  11931. top: (Math.ceil(rect.top) - rect.top) + 'px'
  11932. });
  11933. };
  11934. // run the fix now
  11935. subPixelFix();
  11936. // run it on resize
  11937. renderer.unSubPixelFix = addEvent(win, 'resize', subPixelFix);
  11938. }
  11939. };
  11940. /**
  11941. * General method for adding a definition to the SVG `defs` tag. Can be used
  11942. * for gradients, fills, filters etc. Styled mode only. A hook for adding
  11943. * general definitions to the SVG's defs tag. Definitions can be referenced
  11944. * from the CSS by its `id`. Read more in
  11945. * [gradients, shadows and patterns](https://www.highcharts.com/docs/chart-design-and-style/gradients-shadows-and-patterns).
  11946. * Styled mode only.
  11947. *
  11948. * @function Highcharts.SVGRenderer#definition
  11949. *
  11950. * @param {Highcharts.ASTNode} def
  11951. * A serialized form of an SVG definition, including children.
  11952. *
  11953. * @return {Highcharts.SVGElement}
  11954. * The inserted node.
  11955. */
  11956. SVGRenderer.prototype.definition = function (def) {
  11957. var ast = new AST([def]);
  11958. return ast.addToDOM(this.defs.element);
  11959. };
  11960. /**
  11961. * Get the prefix needed for internal URL references to work in certain
  11962. * cases. Some older browser versions had a bug where internal url
  11963. * references in SVG attributes, on the form `url(#some-id)`, would fail if
  11964. * a base tag was present in the page. There were also issues with
  11965. * `history.pushState` related to this prefix.
  11966. *
  11967. * Related issues: #24, #672, #1070, #5244.
  11968. *
  11969. * The affected browsers are:
  11970. * - Chrome <= 53 (May 2018)
  11971. * - Firefox <= 51 (January 2017)
  11972. * - Safari/Mac <= 12.1 (2018 or 2019)
  11973. * - Safari/iOS <= 13
  11974. *
  11975. * @todo Remove this hack when time has passed. All the affected browsers
  11976. * are evergreens, so it is increasingly unlikely that users are affected by
  11977. * the bug.
  11978. *
  11979. * @return {string}
  11980. * The prefix to use. An empty string for modern browsers.
  11981. */
  11982. SVGRenderer.prototype.getReferenceURL = function () {
  11983. if ((isFirefox || isWebKit) &&
  11984. doc.getElementsByTagName('base').length) {
  11985. // Detect if a clip path is taking effect by performing a hit test
  11986. // outside the clipped area. If the hit element is the rectangle
  11987. // that was supposed to be clipped, the bug is present. This only
  11988. // has to be performed once per page load, so we store the result
  11989. // locally in the module.
  11990. if (!defined(hasInternalReferenceBug)) {
  11991. var id = uniqueKey();
  11992. var ast = new AST([{
  11993. tagName: 'svg',
  11994. attributes: {
  11995. width: 8,
  11996. height: 8
  11997. },
  11998. children: [{
  11999. tagName: 'defs',
  12000. children: [{
  12001. tagName: 'clipPath',
  12002. attributes: {
  12003. id: id
  12004. },
  12005. children: [{
  12006. tagName: 'rect',
  12007. attributes: {
  12008. width: 4,
  12009. height: 4
  12010. }
  12011. }]
  12012. }]
  12013. }, {
  12014. tagName: 'rect',
  12015. attributes: {
  12016. id: 'hitme',
  12017. width: 8,
  12018. height: 8,
  12019. 'clip-path': "url(#" + id + ")",
  12020. fill: 'rgba(0,0,0,0.001)'
  12021. }
  12022. }]
  12023. }]);
  12024. var svg = ast.addToDOM(doc.body);
  12025. css(svg, {
  12026. position: 'fixed',
  12027. top: 0,
  12028. left: 0,
  12029. zIndex: 9e5
  12030. });
  12031. var hitElement = doc.elementFromPoint(6, 6);
  12032. hasInternalReferenceBug =
  12033. (hitElement && hitElement.id) === 'hitme';
  12034. doc.body.removeChild(svg);
  12035. }
  12036. if (hasInternalReferenceBug) {
  12037. return win.location.href
  12038. .split('#')[0] // remove the hash
  12039. .replace(/<[^>]*>/g, '') // wing cut HTML
  12040. // escape parantheses and quotes
  12041. .replace(/([\('\)])/g, '\\$1')
  12042. // replace spaces (needed for Safari only)
  12043. .replace(/ /g, '%20');
  12044. }
  12045. }
  12046. return '';
  12047. };
  12048. /**
  12049. * Get the global style setting for the renderer.
  12050. *
  12051. * @private
  12052. * @function Highcharts.SVGRenderer#getStyle
  12053. *
  12054. * @param {Highcharts.CSSObject} style
  12055. * Style settings.
  12056. *
  12057. * @return {Highcharts.CSSObject}
  12058. * The style settings mixed with defaults.
  12059. */
  12060. SVGRenderer.prototype.getStyle = function (style) {
  12061. this.style = extend({
  12062. fontFamily: '"Lucida Grande", "Lucida Sans Unicode", ' +
  12063. 'Arial, Helvetica, sans-serif',
  12064. fontSize: '12px'
  12065. }, style);
  12066. return this.style;
  12067. };
  12068. /**
  12069. * Apply the global style on the renderer, mixed with the default styles.
  12070. *
  12071. * @function Highcharts.SVGRenderer#setStyle
  12072. *
  12073. * @param {Highcharts.CSSObject} style
  12074. * CSS to apply.
  12075. */
  12076. SVGRenderer.prototype.setStyle = function (style) {
  12077. this.boxWrapper.css(this.getStyle(style));
  12078. };
  12079. /**
  12080. * Detect whether the renderer is hidden. This happens when one of the
  12081. * parent elements has `display: none`. Used internally to detect when we
  12082. * needto render preliminarily in another div to get the text bounding boxes
  12083. * right.
  12084. *
  12085. * @function Highcharts.SVGRenderer#isHidden
  12086. *
  12087. * @return {boolean}
  12088. * True if it is hidden.
  12089. */
  12090. SVGRenderer.prototype.isHidden = function () {
  12091. return !this.boxWrapper.getBBox().width;
  12092. };
  12093. /**
  12094. * Destroys the renderer and its allocated members.
  12095. *
  12096. * @function Highcharts.SVGRenderer#destroy
  12097. *
  12098. * @return {null}
  12099. */
  12100. SVGRenderer.prototype.destroy = function () {
  12101. var renderer = this,
  12102. rendererDefs = renderer.defs;
  12103. renderer.box = null;
  12104. renderer.boxWrapper = renderer.boxWrapper.destroy();
  12105. // Call destroy on all gradient elements
  12106. destroyObjectProperties(renderer.gradients || {});
  12107. renderer.gradients = null;
  12108. // Defs are null in VMLRenderer
  12109. // Otherwise, destroy them here.
  12110. if (rendererDefs) {
  12111. renderer.defs = rendererDefs.destroy();
  12112. }
  12113. // Remove sub pixel fix handler (#982)
  12114. if (renderer.unSubPixelFix) {
  12115. renderer.unSubPixelFix();
  12116. }
  12117. renderer.alignedObjects = null;
  12118. return null;
  12119. };
  12120. /**
  12121. * Create a wrapper for an SVG element. Serves as a factory for
  12122. * {@link SVGElement}, but this function is itself mostly called from
  12123. * primitive factories like {@link SVGRenderer#path}, {@link
  12124. * SVGRenderer#rect} or {@link SVGRenderer#text}.
  12125. *
  12126. * @function Highcharts.SVGRenderer#createElement
  12127. *
  12128. * @param {string} nodeName
  12129. * The node name, for example `rect`, `g` etc.
  12130. *
  12131. * @return {Highcharts.SVGElement}
  12132. * The generated SVGElement.
  12133. */
  12134. SVGRenderer.prototype.createElement = function (nodeName) {
  12135. var wrapper = new this.Element();
  12136. wrapper.init(this, nodeName);
  12137. return wrapper;
  12138. };
  12139. /**
  12140. * Get converted radial gradient attributes according to the radial
  12141. * reference. Used internally from the {@link SVGElement#colorGradient}
  12142. * function.
  12143. *
  12144. * @private
  12145. * @function Highcharts.SVGRenderer#getRadialAttr
  12146. */
  12147. SVGRenderer.prototype.getRadialAttr = function (radialReference, gradAttr) {
  12148. return {
  12149. cx: (radialReference[0] - radialReference[2] / 2) +
  12150. (gradAttr.cx || 0) * radialReference[2],
  12151. cy: (radialReference[1] - radialReference[2] / 2) +
  12152. (gradAttr.cy || 0) * radialReference[2],
  12153. r: (gradAttr.r || 0) * radialReference[2]
  12154. };
  12155. };
  12156. /**
  12157. * Parse a simple HTML string into SVG tspans. Called internally when text
  12158. * is set on an SVGElement. The function supports a subset of HTML tags, CSS
  12159. * text features like `width`, `text-overflow`, `white-space`, and also
  12160. * attributes like `href` and `style`.
  12161. *
  12162. * @private
  12163. * @function Highcharts.SVGRenderer#buildText
  12164. *
  12165. * @param {Highcharts.SVGElement} wrapper
  12166. * The parent SVGElement.
  12167. */
  12168. SVGRenderer.prototype.buildText = function (wrapper) {
  12169. new TextBuilder(wrapper).buildSVG();
  12170. };
  12171. /**
  12172. * Returns white for dark colors and black for bright colors.
  12173. *
  12174. * @function Highcharts.SVGRenderer#getContrast
  12175. *
  12176. * @param {Highcharts.ColorString} rgba
  12177. * The color to get the contrast for.
  12178. *
  12179. * @return {Highcharts.ColorString}
  12180. * The contrast color, either `#000000` or `#FFFFFF`.
  12181. */
  12182. SVGRenderer.prototype.getContrast = function (rgba) {
  12183. rgba = Color.parse(rgba).rgba;
  12184. // The threshold may be discussed. Here's a proposal for adding
  12185. // different weight to the color channels (#6216)
  12186. rgba[0] *= 1; // red
  12187. rgba[1] *= 1.2; // green
  12188. rgba[2] *= 0.5; // blue
  12189. return rgba[0] + rgba[1] + rgba[2] >
  12190. 1.8 * 255 ?
  12191. '#000000' :
  12192. '#FFFFFF';
  12193. };
  12194. /**
  12195. * Create a button with preset states.
  12196. *
  12197. * @function Highcharts.SVGRenderer#button
  12198. *
  12199. * @param {string} text
  12200. * The text or HTML to draw.
  12201. *
  12202. * @param {number} x
  12203. * The x position of the button's left side.
  12204. *
  12205. * @param {number} y
  12206. * The y position of the button's top side.
  12207. *
  12208. * @param {Highcharts.EventCallbackFunction<Highcharts.SVGElement>} callback
  12209. * The function to execute on button click or touch.
  12210. *
  12211. * @param {Highcharts.SVGAttributes} [theme]
  12212. * SVG attributes for the normal state.
  12213. *
  12214. * @param {Highcharts.SVGAttributes} [hoverState]
  12215. * SVG attributes for the hover state.
  12216. *
  12217. * @param {Highcharts.SVGAttributes} [pressedState]
  12218. * SVG attributes for the pressed state.
  12219. *
  12220. * @param {Highcharts.SVGAttributes} [disabledState]
  12221. * SVG attributes for the disabled state.
  12222. *
  12223. * @param {Highcharts.SymbolKeyValue} [shape=rect]
  12224. * The shape type.
  12225. *
  12226. * @param {boolean} [useHTML=false]
  12227. * Wether to use HTML to render the label.
  12228. *
  12229. * @return {Highcharts.SVGElement}
  12230. * The button element.
  12231. */
  12232. SVGRenderer.prototype.button = function (text, x, y, callback, theme, hoverState, pressedState, disabledState, shape, useHTML) {
  12233. var label = this.label(text,
  12234. x,
  12235. y,
  12236. shape,
  12237. void 0,
  12238. void 0,
  12239. useHTML,
  12240. void 0, 'button'),
  12241. curState = 0,
  12242. styledMode = this.styledMode,
  12243. // Make a copy of normalState (#13798)
  12244. // (reference to options.rangeSelector.buttonTheme)
  12245. normalState = theme ? merge(theme) : {},
  12246. userNormalStyle = normalState && normalState.style || {};
  12247. // Remove stylable attributes
  12248. normalState = AST.filterUserAttributes(normalState);
  12249. // Default, non-stylable attributes
  12250. label.attr(merge({ padding: 8, r: 2 }, normalState));
  12251. // Presentational
  12252. var normalStyle,
  12253. hoverStyle,
  12254. pressedStyle,
  12255. disabledStyle;
  12256. if (!styledMode) {
  12257. // Normal state - prepare the attributes
  12258. normalState = merge({
  12259. fill: palette.neutralColor3,
  12260. stroke: palette.neutralColor20,
  12261. 'stroke-width': 1,
  12262. style: {
  12263. color: palette.neutralColor80,
  12264. cursor: 'pointer',
  12265. fontWeight: 'normal'
  12266. }
  12267. }, {
  12268. style: userNormalStyle
  12269. }, normalState);
  12270. normalStyle = normalState.style;
  12271. delete normalState.style;
  12272. // Hover state
  12273. hoverState = merge(normalState, {
  12274. fill: palette.neutralColor10
  12275. }, AST.filterUserAttributes(hoverState || {}));
  12276. hoverStyle = hoverState.style;
  12277. delete hoverState.style;
  12278. // Pressed state
  12279. pressedState = merge(normalState, {
  12280. fill: palette.highlightColor10,
  12281. style: {
  12282. color: palette.neutralColor100,
  12283. fontWeight: 'bold'
  12284. }
  12285. }, AST.filterUserAttributes(pressedState || {}));
  12286. pressedStyle = pressedState.style;
  12287. delete pressedState.style;
  12288. // Disabled state
  12289. disabledState = merge(normalState, {
  12290. style: {
  12291. color: palette.neutralColor20
  12292. }
  12293. }, AST.filterUserAttributes(disabledState || {}));
  12294. disabledStyle = disabledState.style;
  12295. delete disabledState.style;
  12296. }
  12297. // Add the events. IE9 and IE10 need mouseover and mouseout to funciton
  12298. // (#667).
  12299. addEvent(label.element, isMS ? 'mouseover' : 'mouseenter', function () {
  12300. if (curState !== 3) {
  12301. label.setState(1);
  12302. }
  12303. });
  12304. addEvent(label.element, isMS ? 'mouseout' : 'mouseleave', function () {
  12305. if (curState !== 3) {
  12306. label.setState(curState);
  12307. }
  12308. });
  12309. label.setState = function (state) {
  12310. // Hover state is temporary, don't record it
  12311. if (state !== 1) {
  12312. label.state = curState = state;
  12313. }
  12314. // Update visuals
  12315. label
  12316. .removeClass(/highcharts-button-(normal|hover|pressed|disabled)/)
  12317. .addClass('highcharts-button-' +
  12318. ['normal', 'hover', 'pressed', 'disabled'][state || 0]);
  12319. if (!styledMode) {
  12320. label
  12321. .attr([
  12322. normalState,
  12323. hoverState,
  12324. pressedState,
  12325. disabledState
  12326. ][state || 0])
  12327. .css([
  12328. normalStyle,
  12329. hoverStyle,
  12330. pressedStyle,
  12331. disabledStyle
  12332. ][state || 0]);
  12333. }
  12334. };
  12335. // Presentational attributes
  12336. if (!styledMode) {
  12337. label
  12338. .attr(normalState)
  12339. .css(extend({ cursor: 'default' }, normalStyle));
  12340. }
  12341. return label
  12342. .on('touchstart', function (e) { return e.stopPropagation(); })
  12343. .on('click', function (e) {
  12344. if (curState !== 3) {
  12345. callback.call(label, e);
  12346. }
  12347. });
  12348. };
  12349. /**
  12350. * Make a straight line crisper by not spilling out to neighbour pixels.
  12351. *
  12352. * @function Highcharts.SVGRenderer#crispLine
  12353. *
  12354. * @param {Highcharts.SVGPathArray} points
  12355. * The original points on the format `[['M', 0, 0], ['L', 100, 0]]`.
  12356. *
  12357. * @param {number} width
  12358. * The width of the line.
  12359. *
  12360. * @param {string} roundingFunction
  12361. * The rounding function name on the `Math` object, can be one of
  12362. * `round`, `floor` or `ceil`.
  12363. *
  12364. * @return {Highcharts.SVGPathArray}
  12365. * The original points array, but modified to render crisply.
  12366. */
  12367. SVGRenderer.prototype.crispLine = function (points, width, roundingFunction) {
  12368. if (roundingFunction === void 0) { roundingFunction = 'round'; }
  12369. var start = points[0];
  12370. var end = points[1];
  12371. // Normalize to a crisp line
  12372. if (start[1] === end[1]) {
  12373. // Substract due to #1129. Now bottom and left axis gridlines behave
  12374. // the same.
  12375. start[1] = end[1] =
  12376. Math[roundingFunction](start[1]) - (width % 2 / 2);
  12377. }
  12378. if (start[2] === end[2]) {
  12379. start[2] = end[2] =
  12380. Math[roundingFunction](start[2]) + (width % 2 / 2);
  12381. }
  12382. return points;
  12383. };
  12384. /**
  12385. * Draw a path, wraps the SVG `path` element.
  12386. *
  12387. * @sample highcharts/members/renderer-path-on-chart/
  12388. * Draw a path in a chart
  12389. * @sample highcharts/members/renderer-path/
  12390. * Draw a path independent from a chart
  12391. *
  12392. * @example
  12393. * let path = renderer.path(['M', 10, 10, 'L', 30, 30, 'z'])
  12394. * .attr({ stroke: '#ff00ff' })
  12395. * .add();
  12396. *
  12397. * @function Highcharts.SVGRenderer#path
  12398. *
  12399. * @param {Highcharts.SVGPathArray} [path]
  12400. * An SVG path definition in array form.
  12401. *
  12402. * @return {Highcharts.SVGElement}
  12403. * The generated wrapper element.
  12404. *
  12405. */ /**
  12406. * Draw a path, wraps the SVG `path` element.
  12407. *
  12408. * @function Highcharts.SVGRenderer#path
  12409. *
  12410. * @param {Highcharts.SVGAttributes} [attribs]
  12411. * The initial attributes.
  12412. *
  12413. * @return {Highcharts.SVGElement}
  12414. * The generated wrapper element.
  12415. */
  12416. SVGRenderer.prototype.path = function (path) {
  12417. var attribs = (this.styledMode ? {} : {
  12418. fill: 'none'
  12419. });
  12420. if (isArray(path)) {
  12421. attribs.d = path;
  12422. }
  12423. else if (isObject(path)) { // attributes
  12424. extend(attribs, path);
  12425. }
  12426. return this.createElement('path').attr(attribs);
  12427. };
  12428. /**
  12429. * Draw a circle, wraps the SVG `circle` element.
  12430. *
  12431. * @sample highcharts/members/renderer-circle/
  12432. * Drawing a circle
  12433. *
  12434. * @function Highcharts.SVGRenderer#circle
  12435. *
  12436. * @param {number} [x]
  12437. * The center x position.
  12438. *
  12439. * @param {number} [y]
  12440. * The center y position.
  12441. *
  12442. * @param {number} [r]
  12443. * The radius.
  12444. *
  12445. * @return {Highcharts.SVGElement}
  12446. * The generated wrapper element.
  12447. */ /**
  12448. * Draw a circle, wraps the SVG `circle` element.
  12449. *
  12450. * @function Highcharts.SVGRenderer#circle
  12451. *
  12452. * @param {Highcharts.SVGAttributes} [attribs]
  12453. * The initial attributes.
  12454. *
  12455. * @return {Highcharts.SVGElement}
  12456. * The generated wrapper element.
  12457. */
  12458. SVGRenderer.prototype.circle = function (x, y, r) {
  12459. var attribs = (isObject(x) ?
  12460. x :
  12461. typeof x === 'undefined' ? {} : { x: x, y: y, r: r }), wrapper = this.createElement('circle');
  12462. // Setting x or y translates to cx and cy
  12463. wrapper.xSetter = wrapper.ySetter = function (value, key, element) {
  12464. element.setAttribute('c' + key, value);
  12465. };
  12466. return wrapper.attr(attribs);
  12467. };
  12468. /**
  12469. * Draw and return an arc.
  12470. *
  12471. * @sample highcharts/members/renderer-arc/
  12472. * Drawing an arc
  12473. *
  12474. * @function Highcharts.SVGRenderer#arc
  12475. *
  12476. * @param {number} [x=0]
  12477. * Center X position.
  12478. *
  12479. * @param {number} [y=0]
  12480. * Center Y position.
  12481. *
  12482. * @param {number} [r=0]
  12483. * The outer radius' of the arc.
  12484. *
  12485. * @param {number} [innerR=0]
  12486. * Inner radius like used in donut charts.
  12487. *
  12488. * @param {number} [start=0]
  12489. * The starting angle of the arc in radians, where 0 is to the right and
  12490. * `-Math.PI/2` is up.
  12491. *
  12492. * @param {number} [end=0]
  12493. * The ending angle of the arc in radians, where 0 is to the right and
  12494. * `-Math.PI/2` is up.
  12495. *
  12496. * @return {Highcharts.SVGElement}
  12497. * The generated wrapper element.
  12498. */ /**
  12499. * Draw and return an arc. Overloaded function that takes arguments object.
  12500. *
  12501. * @function Highcharts.SVGRenderer#arc
  12502. *
  12503. * @param {Highcharts.SVGAttributes} attribs
  12504. * Initial SVG attributes.
  12505. *
  12506. * @return {Highcharts.SVGElement}
  12507. * The generated wrapper element.
  12508. */
  12509. SVGRenderer.prototype.arc = function (x, y, r, innerR, start, end) {
  12510. var arc,
  12511. options;
  12512. if (isObject(x)) {
  12513. options = x;
  12514. y = options.y;
  12515. r = options.r;
  12516. innerR = options.innerR;
  12517. start = options.start;
  12518. end = options.end;
  12519. x = options.x;
  12520. }
  12521. else {
  12522. options = {
  12523. innerR: innerR,
  12524. start: start,
  12525. end: end
  12526. };
  12527. }
  12528. // Arcs are defined as symbols for the ability to set
  12529. // attributes in attr and animate
  12530. arc = this.symbol('arc', x, y, r, r, options);
  12531. arc.r = r; // #959
  12532. return arc;
  12533. };
  12534. /**
  12535. * Draw and return a rectangle.
  12536. *
  12537. * @function Highcharts.SVGRenderer#rect
  12538. *
  12539. * @param {number} [x]
  12540. * Left position.
  12541. *
  12542. * @param {number} [y]
  12543. * Top position.
  12544. *
  12545. * @param {number} [width]
  12546. * Width of the rectangle.
  12547. *
  12548. * @param {number} [height]
  12549. * Height of the rectangle.
  12550. *
  12551. * @param {number} [r]
  12552. * Border corner radius.
  12553. *
  12554. * @param {number} [strokeWidth]
  12555. * A stroke width can be supplied to allow crisp drawing.
  12556. *
  12557. * @return {Highcharts.SVGElement}
  12558. * The generated wrapper element.
  12559. */ /**
  12560. * Draw and return a rectangle.
  12561. *
  12562. * @sample highcharts/members/renderer-rect-on-chart/
  12563. * Draw a rectangle in a chart
  12564. * @sample highcharts/members/renderer-rect/
  12565. * Draw a rectangle independent from a chart
  12566. *
  12567. * @function Highcharts.SVGRenderer#rect
  12568. *
  12569. * @param {Highcharts.SVGAttributes} [attributes]
  12570. * General SVG attributes for the rectangle.
  12571. *
  12572. * @return {Highcharts.SVGElement}
  12573. * The generated wrapper element.
  12574. */
  12575. SVGRenderer.prototype.rect = function (x, y, width, height, r, strokeWidth) {
  12576. r = isObject(x) ? x.r : r;
  12577. var wrapper = this.createElement('rect'),
  12578. attribs = isObject(x) ?
  12579. x :
  12580. typeof x === 'undefined' ?
  12581. {} :
  12582. {
  12583. x: x,
  12584. y: y,
  12585. width: Math.max(width, 0),
  12586. height: Math.max(height, 0)
  12587. };
  12588. if (!this.styledMode) {
  12589. if (typeof strokeWidth !== 'undefined') {
  12590. attribs['stroke-width'] = strokeWidth;
  12591. attribs = wrapper.crisp(attribs);
  12592. }
  12593. attribs.fill = 'none';
  12594. }
  12595. if (r) {
  12596. attribs.r = r;
  12597. }
  12598. wrapper.rSetter = function (value, key, element) {
  12599. wrapper.r = value;
  12600. attr(element, {
  12601. rx: value,
  12602. ry: value
  12603. });
  12604. };
  12605. wrapper.rGetter = function () {
  12606. return wrapper.r || 0;
  12607. };
  12608. return wrapper.attr(attribs);
  12609. };
  12610. /**
  12611. * Resize the {@link SVGRenderer#box} and re-align all aligned child
  12612. * elements.
  12613. *
  12614. * @sample highcharts/members/renderer-g/
  12615. * Show and hide grouped objects
  12616. *
  12617. * @function Highcharts.SVGRenderer#setSize
  12618. *
  12619. * @param {number} width
  12620. * The new pixel width.
  12621. *
  12622. * @param {number} height
  12623. * The new pixel height.
  12624. *
  12625. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animate=true]
  12626. * Whether and how to animate.
  12627. */
  12628. SVGRenderer.prototype.setSize = function (width, height, animate) {
  12629. var renderer = this;
  12630. renderer.width = width;
  12631. renderer.height = height;
  12632. renderer.boxWrapper.animate({
  12633. width: width,
  12634. height: height
  12635. }, {
  12636. step: function () {
  12637. this.attr({
  12638. viewBox: '0 0 ' + this.attr('width') + ' ' +
  12639. this.attr('height')
  12640. });
  12641. },
  12642. duration: pick(animate, true) ? void 0 : 0
  12643. });
  12644. renderer.alignElements();
  12645. };
  12646. /**
  12647. * Create and return an svg group element. Child
  12648. * {@link Highcharts.SVGElement} objects are added to the group by using the
  12649. * group as the first parameter in {@link Highcharts.SVGElement#add|add()}.
  12650. *
  12651. * @function Highcharts.SVGRenderer#g
  12652. *
  12653. * @param {string} [name]
  12654. * The group will be given a class name of `highcharts-{name}`. This
  12655. * can be used for styling and scripting.
  12656. *
  12657. * @return {Highcharts.SVGElement}
  12658. * The generated wrapper element.
  12659. */
  12660. SVGRenderer.prototype.g = function (name) {
  12661. var elem = this.createElement('g');
  12662. return name ?
  12663. elem.attr({ 'class': 'highcharts-' + name }) :
  12664. elem;
  12665. };
  12666. /**
  12667. * Display an image.
  12668. *
  12669. * @sample highcharts/members/renderer-image-on-chart/
  12670. * Add an image in a chart
  12671. * @sample highcharts/members/renderer-image/
  12672. * Add an image independent of a chart
  12673. *
  12674. * @function Highcharts.SVGRenderer#image
  12675. *
  12676. * @param {string} src
  12677. * The image source.
  12678. *
  12679. * @param {number} [x]
  12680. * The X position.
  12681. *
  12682. * @param {number} [y]
  12683. * The Y position.
  12684. *
  12685. * @param {number} [width]
  12686. * The image width. If omitted, it defaults to the image file width.
  12687. *
  12688. * @param {number} [height]
  12689. * The image height. If omitted it defaults to the image file
  12690. * height.
  12691. *
  12692. * @param {Function} [onload]
  12693. * Event handler for image load.
  12694. *
  12695. * @return {Highcharts.SVGElement}
  12696. * The generated wrapper element.
  12697. */
  12698. SVGRenderer.prototype.image = function (src, x, y, width, height, onload) {
  12699. var attribs = { preserveAspectRatio: 'none' }, elemWrapper, dummy, setSVGImageSource = function (el, src) {
  12700. // Set the href in the xlink namespace
  12701. if (el.setAttributeNS) {
  12702. el.setAttributeNS('http://www.w3.org/1999/xlink', 'href', src);
  12703. }
  12704. else {
  12705. // could be exporting in IE
  12706. // using href throws "not supported" in ie7 and under,
  12707. // requries regex shim to fix later
  12708. el.setAttribute('hc-svg-href', src);
  12709. }
  12710. }, onDummyLoad = function (e) {
  12711. setSVGImageSource(elemWrapper.element, src);
  12712. onload.call(elemWrapper, e);
  12713. };
  12714. // optional properties
  12715. if (arguments.length > 1) {
  12716. extend(attribs, {
  12717. x: x,
  12718. y: y,
  12719. width: width,
  12720. height: height
  12721. });
  12722. }
  12723. elemWrapper = this.createElement('image').attr(attribs);
  12724. // Add load event if supplied
  12725. if (onload) {
  12726. // We have to use a dummy HTML image since IE support for SVG image
  12727. // load events is very buggy. First set a transparent src, wait for
  12728. // dummy to load, and then add the real src to the SVG image.
  12729. setSVGImageSource(elemWrapper.element, 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==' /* eslint-disable-line */);
  12730. dummy = new win.Image();
  12731. addEvent(dummy, 'load', onDummyLoad);
  12732. dummy.src = src;
  12733. if (dummy.complete) {
  12734. onDummyLoad({});
  12735. }
  12736. }
  12737. else {
  12738. setSVGImageSource(elemWrapper.element, src);
  12739. }
  12740. return elemWrapper;
  12741. };
  12742. /**
  12743. * Draw a symbol out of pre-defined shape paths from
  12744. * {@link SVGRenderer#symbols}.
  12745. * It is used in Highcharts for point makers, which cake a `symbol` option,
  12746. * and label and button backgrounds like in the tooltip and stock flags.
  12747. *
  12748. * @function Highcharts.SVGRenderer#symbol
  12749. *
  12750. * @param {string} symbol
  12751. * The symbol name.
  12752. *
  12753. * @param {number} [x]
  12754. * The X coordinate for the top left position.
  12755. *
  12756. * @param {number} [y]
  12757. * The Y coordinate for the top left position.
  12758. *
  12759. * @param {number} [width]
  12760. * The pixel width.
  12761. *
  12762. * @param {number} [height]
  12763. * The pixel height.
  12764. *
  12765. * @param {Highcharts.SymbolOptionsObject} [options]
  12766. * Additional options, depending on the actual symbol drawn.
  12767. *
  12768. * @return {Highcharts.SVGElement}
  12769. */
  12770. SVGRenderer.prototype.symbol = function (symbol, x, y, width, height, options) {
  12771. var ren = this,
  12772. obj,
  12773. imageRegex = /^url\((.*?)\)$/,
  12774. isImage = imageRegex.test(symbol),
  12775. sym = (!isImage && (this.symbols[symbol] ? symbol : 'circle')),
  12776. // get the symbol definition function
  12777. symbolFn = (sym && this.symbols[sym]),
  12778. path,
  12779. imageSrc,
  12780. centerImage;
  12781. if (symbolFn) {
  12782. // Check if there's a path defined for this symbol
  12783. if (typeof x === 'number') {
  12784. path = symbolFn.call(this.symbols, Math.round(x || 0), Math.round(y || 0), width || 0, height || 0, options);
  12785. }
  12786. obj = this.path(path);
  12787. if (!ren.styledMode) {
  12788. obj.attr('fill', 'none');
  12789. }
  12790. // expando properties for use in animate and attr
  12791. extend(obj, {
  12792. symbolName: sym,
  12793. x: x,
  12794. y: y,
  12795. width: width,
  12796. height: height
  12797. });
  12798. if (options) {
  12799. extend(obj, options);
  12800. }
  12801. // Image symbols
  12802. }
  12803. else if (isImage) {
  12804. imageSrc = symbol.match(imageRegex)[1];
  12805. // Create the image synchronously, add attribs async
  12806. obj = this.image(imageSrc);
  12807. // The image width is not always the same as the symbol width. The
  12808. // image may be centered within the symbol, as is the case when
  12809. // image shapes are used as label backgrounds, for example in flags.
  12810. obj.imgwidth = pick(symbolSizes[imageSrc] && symbolSizes[imageSrc].width, options && options.width);
  12811. obj.imgheight = pick(symbolSizes[imageSrc] && symbolSizes[imageSrc].height, options && options.height);
  12812. /**
  12813. * Set the size and position
  12814. */
  12815. centerImage = function () {
  12816. obj.attr({
  12817. width: obj.width,
  12818. height: obj.height
  12819. });
  12820. };
  12821. /**
  12822. * Width and height setters that take both the image's physical size
  12823. * and the label size into consideration, and translates the image
  12824. * to center within the label.
  12825. */
  12826. ['width', 'height'].forEach(function (key) {
  12827. obj[key + 'Setter'] = function (value, key) {
  12828. var imgSize = this['img' + key];
  12829. this[key] = value;
  12830. if (defined(imgSize)) {
  12831. // Scale and center the image within its container.
  12832. // The name `backgroundSize` is taken from the CSS spec,
  12833. // but the value `within` is made up. Other possible
  12834. // values in the spec, `cover` and `contain`, can be
  12835. // implemented if needed.
  12836. if (options &&
  12837. options.backgroundSize === 'within' &&
  12838. this.width &&
  12839. this.height) {
  12840. imgSize = Math.round(imgSize * Math.min(this.width / this.imgwidth, this.height / this.imgheight));
  12841. }
  12842. if (this.element) {
  12843. this.element.setAttribute(key, imgSize);
  12844. }
  12845. if (!this.alignByTranslate) {
  12846. var translate = ((this[key] || 0) - imgSize) / 2;
  12847. var attribs = key === 'width' ?
  12848. { translateX: translate } :
  12849. { translateY: translate };
  12850. this.attr(attribs);
  12851. }
  12852. }
  12853. };
  12854. });
  12855. if (defined(x)) {
  12856. obj.attr({
  12857. x: x,
  12858. y: y
  12859. });
  12860. }
  12861. obj.isImg = true;
  12862. if (defined(obj.imgwidth) && defined(obj.imgheight)) {
  12863. centerImage();
  12864. }
  12865. else {
  12866. // Initialize image to be 0 size so export will still function
  12867. // if there's no cached sizes.
  12868. obj.attr({ width: 0, height: 0 });
  12869. // Create a dummy JavaScript image to get the width and height.
  12870. createElement('img', {
  12871. onload: function () {
  12872. var chart = charts[ren.chartIndex];
  12873. // Special case for SVGs on IE11, the width is not
  12874. // accessible until the image is part of the DOM
  12875. // (#2854).
  12876. if (this.width === 0) {
  12877. css(this, {
  12878. position: 'absolute',
  12879. top: '-999em'
  12880. });
  12881. doc.body.appendChild(this);
  12882. }
  12883. // Center the image
  12884. symbolSizes[imageSrc] = {
  12885. width: this.width,
  12886. height: this.height
  12887. };
  12888. obj.imgwidth = this.width;
  12889. obj.imgheight = this.height;
  12890. if (obj.element) {
  12891. centerImage();
  12892. }
  12893. // Clean up after #2854 workaround.
  12894. if (this.parentNode) {
  12895. this.parentNode.removeChild(this);
  12896. }
  12897. // Fire the load event when all external images are
  12898. // loaded
  12899. ren.imgCount--;
  12900. if (!ren.imgCount && chart && !chart.hasLoaded) {
  12901. chart.onload();
  12902. }
  12903. },
  12904. src: imageSrc
  12905. });
  12906. this.imgCount++;
  12907. }
  12908. }
  12909. return obj;
  12910. };
  12911. /**
  12912. * Define a clipping rectangle. The clipping rectangle is later applied
  12913. * to {@link SVGElement} objects through the {@link SVGElement#clip}
  12914. * function.
  12915. *
  12916. * @example
  12917. * let circle = renderer.circle(100, 100, 100)
  12918. * .attr({ fill: 'red' })
  12919. * .add();
  12920. * let clipRect = renderer.clipRect(100, 100, 100, 100);
  12921. *
  12922. * // Leave only the lower right quarter visible
  12923. * circle.clip(clipRect);
  12924. *
  12925. * @function Highcharts.SVGRenderer#clipRect
  12926. *
  12927. * @param {number} [x]
  12928. *
  12929. * @param {number} [y]
  12930. *
  12931. * @param {number} [width]
  12932. *
  12933. * @param {number} [height]
  12934. *
  12935. * @return {Highcharts.ClipRectElement}
  12936. * A clipping rectangle.
  12937. */
  12938. SVGRenderer.prototype.clipRect = function (x, y, width, height) {
  12939. var wrapper,
  12940. // Add a hyphen at the end to avoid confusion in testing indexes
  12941. // -1 and -10, -11 etc (#6550)
  12942. id = uniqueKey() + '-', clipPath = this.createElement('clipPath').attr({
  12943. id: id
  12944. }).add(this.defs);
  12945. wrapper = this.rect(x, y, width, height, 0).add(clipPath);
  12946. wrapper.id = id;
  12947. wrapper.clipPath = clipPath;
  12948. wrapper.count = 0;
  12949. return wrapper;
  12950. };
  12951. /**
  12952. * Draw text. The text can contain a subset of HTML, like spans and anchors
  12953. * and some basic text styling of these. For more advanced features like
  12954. * border and background, use {@link Highcharts.SVGRenderer#label} instead.
  12955. * To update the text after render, run `text.attr({ text: 'New text' })`.
  12956. *
  12957. * @sample highcharts/members/renderer-text-on-chart/
  12958. * Annotate the chart freely
  12959. * @sample highcharts/members/renderer-on-chart/
  12960. * Annotate with a border and in response to the data
  12961. * @sample highcharts/members/renderer-text/
  12962. * Formatted text
  12963. *
  12964. * @function Highcharts.SVGRenderer#text
  12965. *
  12966. * @param {string} [str]
  12967. * The text of (subset) HTML to draw.
  12968. *
  12969. * @param {number} [x]
  12970. * The x position of the text's lower left corner.
  12971. *
  12972. * @param {number} [y]
  12973. * The y position of the text's lower left corner.
  12974. *
  12975. * @param {boolean} [useHTML=false]
  12976. * Use HTML to render the text.
  12977. *
  12978. * @return {Highcharts.SVGElement}
  12979. * The text object.
  12980. */
  12981. SVGRenderer.prototype.text = function (str, x, y, useHTML) {
  12982. // declare variables
  12983. var renderer = this,
  12984. wrapper,
  12985. attribs = {};
  12986. if (useHTML && (renderer.allowHTML || !renderer.forExport)) {
  12987. return renderer.html(str, x, y);
  12988. }
  12989. attribs.x = Math.round(x || 0); // X always needed for line-wrap logic
  12990. if (y) {
  12991. attribs.y = Math.round(y);
  12992. }
  12993. if (defined(str)) {
  12994. attribs.text = str;
  12995. }
  12996. wrapper = renderer.createElement('text')
  12997. .attr(attribs);
  12998. if (!useHTML) {
  12999. wrapper.xSetter = function (value, key, element) {
  13000. var tspans = element.getElementsByTagName('tspan'),
  13001. tspan,
  13002. parentVal = element.getAttribute(key),
  13003. i;
  13004. for (i = 0; i < tspans.length; i++) {
  13005. tspan = tspans[i];
  13006. // If the x values are equal, the tspan represents a
  13007. // linebreak
  13008. if (tspan.getAttribute(key) === parentVal) {
  13009. tspan.setAttribute(key, value);
  13010. }
  13011. }
  13012. element.setAttribute(key, value);
  13013. };
  13014. }
  13015. return wrapper;
  13016. };
  13017. /**
  13018. * Utility to return the baseline offset and total line height from the font
  13019. * size.
  13020. *
  13021. * @function Highcharts.SVGRenderer#fontMetrics
  13022. *
  13023. * @param {number|string} [fontSize]
  13024. * The current font size to inspect. If not given, the font size
  13025. * will be found from the DOM element.
  13026. *
  13027. * @param {Highcharts.SVGElement|Highcharts.SVGDOMElement} [elem]
  13028. * The element to inspect for a current font size.
  13029. *
  13030. * @return {Highcharts.FontMetricsObject}
  13031. * The font metrics.
  13032. */
  13033. SVGRenderer.prototype.fontMetrics = function (fontSize, elem) {
  13034. var lineHeight,
  13035. baseline;
  13036. if ((this.styledMode || !/px/.test(fontSize)) &&
  13037. win.getComputedStyle // old IE doesn't support it
  13038. ) {
  13039. fontSize = elem && SVGElement.prototype.getStyle.call(elem, 'font-size');
  13040. }
  13041. else {
  13042. fontSize = fontSize ||
  13043. // When the elem is a DOM element (#5932)
  13044. (elem && elem.style && elem.style.fontSize) ||
  13045. // Fall back on the renderer style default
  13046. (this.style && this.style.fontSize);
  13047. }
  13048. // Handle different units
  13049. if (/px/.test(fontSize)) {
  13050. fontSize = pInt(fontSize);
  13051. }
  13052. else {
  13053. fontSize = 12;
  13054. }
  13055. // Empirical values found by comparing font size and bounding box
  13056. // height. Applies to the default font family.
  13057. // https://jsfiddle.net/highcharts/7xvn7/
  13058. lineHeight = fontSize < 24 ? fontSize + 3 : Math.round(fontSize * 1.2);
  13059. baseline = Math.round(lineHeight * 0.8);
  13060. return {
  13061. h: lineHeight,
  13062. b: baseline,
  13063. f: fontSize
  13064. };
  13065. };
  13066. /**
  13067. * Correct X and Y positioning of a label for rotation (#1764).
  13068. *
  13069. * @private
  13070. * @function Highcharts.SVGRenderer#rotCorr
  13071. *
  13072. * @param {number} baseline
  13073. *
  13074. * @param {number} rotation
  13075. *
  13076. * @param {boolean} [alterY]
  13077. *
  13078. * @param {Highcharts.PositionObject}
  13079. */
  13080. SVGRenderer.prototype.rotCorr = function (baseline, rotation, alterY) {
  13081. var y = baseline;
  13082. if (rotation && alterY) {
  13083. y = Math.max(y * Math.cos(rotation * deg2rad), 4);
  13084. }
  13085. return {
  13086. x: (-baseline / 3) * Math.sin(rotation * deg2rad),
  13087. y: y
  13088. };
  13089. };
  13090. /**
  13091. * Compatibility function to convert the legacy one-dimensional path array
  13092. * into an array of segments.
  13093. *
  13094. * It is used in maps to parse the `path` option, and in SVGRenderer.dSetter
  13095. * to support legacy paths from demos.
  13096. *
  13097. * @private
  13098. * @function Highcharts.SVGRenderer#pathToSegments
  13099. */
  13100. SVGRenderer.prototype.pathToSegments = function (path) {
  13101. var ret = [];
  13102. var segment = [];
  13103. var commandLength = {
  13104. A: 8,
  13105. C: 7,
  13106. H: 2,
  13107. L: 3,
  13108. M: 3,
  13109. Q: 5,
  13110. S: 5,
  13111. T: 3,
  13112. V: 2
  13113. };
  13114. // Short, non-typesafe parsing of the one-dimensional array. It splits
  13115. // the path on any string. This is not type checked against the tuple
  13116. // types, but is shorter, and doesn't require specific checks for any
  13117. // command type in SVG.
  13118. for (var i = 0; i < path.length; i++) {
  13119. // Command skipped, repeat previous or insert L/l for M/m
  13120. if (isString(segment[0]) &&
  13121. isNumber(path[i]) &&
  13122. segment.length === commandLength[(segment[0].toUpperCase())]) {
  13123. path.splice(i, 0, segment[0].replace('M', 'L').replace('m', 'l'));
  13124. }
  13125. // Split on string
  13126. if (typeof path[i] === 'string') {
  13127. if (segment.length) {
  13128. ret.push(segment.slice(0));
  13129. }
  13130. segment.length = 0;
  13131. }
  13132. segment.push(path[i]);
  13133. }
  13134. ret.push(segment.slice(0));
  13135. return ret;
  13136. /*
  13137. // Fully type-safe version where each tuple type is checked. The
  13138. // downside is filesize and a lack of flexibility for unsupported
  13139. // commands
  13140. const ret: SVGPath = [],
  13141. commands = {
  13142. A: 7,
  13143. C: 6,
  13144. H: 1,
  13145. L: 2,
  13146. M: 2,
  13147. Q: 4,
  13148. S: 4,
  13149. T: 2,
  13150. V: 1,
  13151. Z: 0
  13152. };
  13153. let i = 0,
  13154. lastI = 0,
  13155. lastCommand;
  13156. while (i < path.length) {
  13157. const item = path[i];
  13158. let command;
  13159. if (typeof item === 'string') {
  13160. command = item;
  13161. i += 1;
  13162. } else {
  13163. command = lastCommand || 'M';
  13164. }
  13165. // Upper case
  13166. const commandUC = command.toUpperCase();
  13167. if (commandUC in commands) {
  13168. // No numeric parameters
  13169. if (command === 'Z' || command === 'z') {
  13170. ret.push([command]);
  13171. // One numeric parameter
  13172. } else {
  13173. const val0 = path[i];
  13174. if (typeof val0 === 'number') {
  13175. // Horizontal line to
  13176. if (command === 'H' || command === 'h') {
  13177. ret.push([command, val0]);
  13178. i += 1;
  13179. // Vertical line to
  13180. } else if (command === 'V' || command === 'v') {
  13181. ret.push([command, val0]);
  13182. i += 1;
  13183. // Two numeric parameters
  13184. } else {
  13185. const val1 = path[i + 1];
  13186. if (typeof val1 === 'number') {
  13187. // lineTo
  13188. if (command === 'L' || command === 'l') {
  13189. ret.push([command, val0, val1]);
  13190. i += 2;
  13191. // moveTo
  13192. } else if (command === 'M' || command === 'm') {
  13193. ret.push([command, val0, val1]);
  13194. i += 2;
  13195. // Smooth quadratic bezier
  13196. } else if (command === 'T' || command === 't') {
  13197. ret.push([command, val0, val1]);
  13198. i += 2;
  13199. // Four numeric parameters
  13200. } else {
  13201. const val2 = path[i + 2],
  13202. val3 = path[i + 3];
  13203. if (
  13204. typeof val2 === 'number' &&
  13205. typeof val3 === 'number'
  13206. ) {
  13207. // Quadratic bezier to
  13208. if (
  13209. command === 'Q' ||
  13210. command === 'q'
  13211. ) {
  13212. ret.push([
  13213. command,
  13214. val0,
  13215. val1,
  13216. val2,
  13217. val3
  13218. ]);
  13219. i += 4;
  13220. // Smooth cubic bezier to
  13221. } else if (
  13222. command === 'S' ||
  13223. command === 's'
  13224. ) {
  13225. ret.push([
  13226. command,
  13227. val0,
  13228. val1,
  13229. val2,
  13230. val3
  13231. ]);
  13232. i += 4;
  13233. // Six numeric parameters
  13234. } else {
  13235. const val4 = path[i + 4],
  13236. val5 = path[i + 5];
  13237. if (
  13238. typeof val4 === 'number' &&
  13239. typeof val5 === 'number'
  13240. ) {
  13241. // Curve to
  13242. if (
  13243. command === 'C' ||
  13244. command === 'c'
  13245. ) {
  13246. ret.push([
  13247. command,
  13248. val0,
  13249. val1,
  13250. val2,
  13251. val3,
  13252. val4,
  13253. val5
  13254. ]);
  13255. i += 6;
  13256. // Seven numeric parameters
  13257. } else {
  13258. const val6 = path[i + 6];
  13259. // Arc to
  13260. if (
  13261. typeof val6 ===
  13262. 'number' &&
  13263. (
  13264. command === 'A' ||
  13265. command === 'a'
  13266. )
  13267. ) {
  13268. ret.push([
  13269. command,
  13270. val0,
  13271. val1,
  13272. val2,
  13273. val3,
  13274. val4,
  13275. val5,
  13276. val6
  13277. ]);
  13278. i += 7;
  13279. }
  13280. }
  13281. }
  13282. }
  13283. }
  13284. }
  13285. }
  13286. }
  13287. }
  13288. }
  13289. }
  13290. // An unmarked command following a moveTo is a lineTo
  13291. lastCommand = command === 'M' ? 'L' : command;
  13292. if (i === lastI) {
  13293. break;
  13294. }
  13295. lastI = i;
  13296. }
  13297. return ret;
  13298. */
  13299. };
  13300. /**
  13301. * Draw a label, which is an extended text element with support for border
  13302. * and background. Highcharts creates a `g` element with a text and a `path`
  13303. * or `rect` inside, to make it behave somewhat like a HTML div. Border and
  13304. * background are set through `stroke`, `stroke-width` and `fill` attributes
  13305. * using the {@link Highcharts.SVGElement#attr|attr} method. To update the
  13306. * text after render, run `label.attr({ text: 'New text' })`.
  13307. *
  13308. * @sample highcharts/members/renderer-label-on-chart/
  13309. * A label on the chart
  13310. *
  13311. * @function Highcharts.SVGRenderer#label
  13312. *
  13313. * @param {string} str
  13314. * The initial text string or (subset) HTML to render.
  13315. *
  13316. * @param {number} x
  13317. * The x position of the label's left side.
  13318. *
  13319. * @param {number} [y]
  13320. * The y position of the label's top side or baseline, depending on
  13321. * the `baseline` parameter.
  13322. *
  13323. * @param {string} [shape='rect']
  13324. * The shape of the label's border/background, if any. Defaults to
  13325. * `rect`. Other possible values are `callout` or other shapes
  13326. * defined in {@link Highcharts.SVGRenderer#symbols}.
  13327. *
  13328. * @param {number} [anchorX]
  13329. * In case the `shape` has a pointer, like a flag, this is the
  13330. * coordinates it should be pinned to.
  13331. *
  13332. * @param {number} [anchorY]
  13333. * In case the `shape` has a pointer, like a flag, this is the
  13334. * coordinates it should be pinned to.
  13335. *
  13336. * @param {boolean} [useHTML=false]
  13337. * Wether to use HTML to render the label.
  13338. *
  13339. * @param {boolean} [baseline=false]
  13340. * Whether to position the label relative to the text baseline,
  13341. * like {@link Highcharts.SVGRenderer#text|renderer.text}, or to the
  13342. * upper border of the rectangle.
  13343. *
  13344. * @param {string} [className]
  13345. * Class name for the group.
  13346. *
  13347. * @return {Highcharts.SVGElement}
  13348. * The generated label.
  13349. */
  13350. SVGRenderer.prototype.label = function (str, x, y, shape, anchorX, anchorY, useHTML, baseline, className) {
  13351. return new SVGLabel(this, str, x, y, shape, anchorX, anchorY, useHTML, baseline, className);
  13352. };
  13353. /**
  13354. * Re-align all aligned elements.
  13355. *
  13356. * @private
  13357. * @function Highcharts.SVGRenderer#alignElements
  13358. * @return {void}
  13359. */
  13360. SVGRenderer.prototype.alignElements = function () {
  13361. this.alignedObjects.forEach(function (el) { return el.align(); });
  13362. };
  13363. return SVGRenderer;
  13364. }());
  13365. /**
  13366. * A pointer to the renderer's associated Element class. The VMLRenderer
  13367. * will have a pointer to VMLElement here.
  13368. *
  13369. * @name Highcharts.SVGRenderer#Element
  13370. * @type {Highcharts.SVGElement}
  13371. */
  13372. SVGRenderer.prototype.Element = SVGElement;
  13373. /**
  13374. * @private
  13375. */
  13376. SVGRenderer.prototype.SVG_NS = SVG_NS;
  13377. /**
  13378. * Dummy function for plugins, called every time the renderer is updated.
  13379. * Prior to Highcharts 5, this was used for the canvg renderer.
  13380. *
  13381. * @deprecated
  13382. * @function Highcharts.SVGRenderer#draw
  13383. */
  13384. SVGRenderer.prototype.draw = noop;
  13385. /**
  13386. * A collection of characters mapped to HTML entities. When `useHTML` on an
  13387. * element is true, these entities will be rendered correctly by HTML. In
  13388. * the SVG pseudo-HTML, they need to be unescaped back to simple characters,
  13389. * so for example `&lt;` will render as `<`.
  13390. *
  13391. * @example
  13392. * // Add support for unescaping quotes
  13393. * Highcharts.SVGRenderer.prototype.escapes['"'] = '&quot;';
  13394. *
  13395. * @name Highcharts.SVGRenderer#escapes
  13396. * @type {Highcharts.Dictionary<string>}
  13397. */
  13398. SVGRenderer.prototype.escapes = {
  13399. '&': '&amp;',
  13400. '<': '&lt;',
  13401. '>': '&gt;',
  13402. "'": '&#39;',
  13403. '"': '&quot;'
  13404. };
  13405. var roundedRect = function (x,
  13406. y,
  13407. w,
  13408. h,
  13409. options) {
  13410. var r = (options && options.r) || 0;
  13411. return [
  13412. ['M', x + r, y],
  13413. ['L', x + w - r, y],
  13414. ['C', x + w, y, x + w, y, x + w, y + r],
  13415. ['L', x + w, y + h - r],
  13416. ['C', x + w, y + h, x + w, y + h, x + w - r, y + h],
  13417. ['L', x + r, y + h],
  13418. ['C', x, y + h, x, y + h, x, y + h - r],
  13419. ['L', x, y + r],
  13420. ['C', x, y, x, y, x + r, y] // top-left corner
  13421. ];
  13422. };
  13423. // #15291
  13424. var rect = function (x,
  13425. y,
  13426. w,
  13427. h,
  13428. options) {
  13429. if (options && options.r) {
  13430. return roundedRect(x,
  13431. y,
  13432. w,
  13433. h,
  13434. options);
  13435. }
  13436. return [
  13437. ['M', x, y],
  13438. ['L', x + w, y],
  13439. ['L', x + w, y + h],
  13440. ['L', x, y + h],
  13441. ['Z']
  13442. ];
  13443. };
  13444. /**
  13445. * An extendable collection of functions for defining symbol paths.
  13446. *
  13447. * @name Highcharts.SVGRenderer#symbols
  13448. * @type {Highcharts.SymbolDictionary}
  13449. */
  13450. SVGRenderer.prototype.symbols = {
  13451. circle: function (x, y, w, h) {
  13452. // Return a full arc
  13453. return this.arc(x + w / 2, y + h / 2, w / 2, h / 2, {
  13454. start: Math.PI * 0.5,
  13455. end: Math.PI * 2.5,
  13456. open: false
  13457. });
  13458. },
  13459. rect: rect,
  13460. square: rect,
  13461. triangle: function (x, y, w, h) {
  13462. return [
  13463. ['M', x + w / 2, y],
  13464. ['L', x + w, y + h],
  13465. ['L', x, y + h],
  13466. ['Z']
  13467. ];
  13468. },
  13469. 'triangle-down': function (x, y, w, h) {
  13470. return [
  13471. ['M', x, y],
  13472. ['L', x + w, y],
  13473. ['L', x + w / 2, y + h],
  13474. ['Z']
  13475. ];
  13476. },
  13477. diamond: function (x, y, w, h) {
  13478. return [
  13479. ['M', x + w / 2, y],
  13480. ['L', x + w, y + h / 2],
  13481. ['L', x + w / 2, y + h],
  13482. ['L', x, y + h / 2],
  13483. ['Z']
  13484. ];
  13485. },
  13486. arc: function (x, y, w, h, options) {
  13487. var arc = [];
  13488. if (options) {
  13489. var start = options.start || 0,
  13490. rx = pick(options.r,
  13491. w),
  13492. ry = pick(options.r,
  13493. h || w),
  13494. proximity = 0.001,
  13495. fullCircle = (Math.abs((options.end || 0) - start - 2 * Math.PI) <
  13496. proximity),
  13497. // Substract a small number to prevent cos and sin of start and
  13498. // end from becoming equal on 360 arcs (related: #1561)
  13499. end = (options.end || 0) - proximity,
  13500. innerRadius = options.innerR,
  13501. open_1 = pick(options.open,
  13502. fullCircle),
  13503. cosStart = Math.cos(start),
  13504. sinStart = Math.sin(start),
  13505. cosEnd = Math.cos(end),
  13506. sinEnd = Math.sin(end),
  13507. // Proximity takes care of rounding errors around PI (#6971)
  13508. longArc = pick(options.longArc,
  13509. end - start - Math.PI < proximity ? 0 : 1);
  13510. arc.push([
  13511. 'M',
  13512. x + rx * cosStart,
  13513. y + ry * sinStart
  13514. ], [
  13515. 'A',
  13516. rx,
  13517. ry,
  13518. 0,
  13519. longArc,
  13520. pick(options.clockwise, 1),
  13521. x + rx * cosEnd,
  13522. y + ry * sinEnd
  13523. ]);
  13524. if (defined(innerRadius)) {
  13525. arc.push(open_1 ?
  13526. [
  13527. 'M',
  13528. x + innerRadius * cosEnd,
  13529. y + innerRadius * sinEnd
  13530. ] : [
  13531. 'L',
  13532. x + innerRadius * cosEnd,
  13533. y + innerRadius * sinEnd
  13534. ], [
  13535. 'A',
  13536. innerRadius,
  13537. innerRadius,
  13538. 0,
  13539. longArc,
  13540. // Clockwise - opposite to the outer arc clockwise
  13541. defined(options.clockwise) ? 1 - options.clockwise : 0,
  13542. x + innerRadius * cosStart,
  13543. y + innerRadius * sinStart
  13544. ]);
  13545. }
  13546. if (!open_1) {
  13547. arc.push(['Z']);
  13548. }
  13549. }
  13550. return arc;
  13551. },
  13552. /**
  13553. * Callout shape used for default tooltips, also used for rounded
  13554. * rectangles in VML
  13555. */
  13556. callout: function (x, y, w, h, options) {
  13557. var arrowLength = 6,
  13558. halfDistance = 6,
  13559. r = Math.min((options && options.r) || 0,
  13560. w,
  13561. h),
  13562. safeDistance = r + halfDistance,
  13563. anchorX = options && options.anchorX,
  13564. anchorY = options && options.anchorY || 0;
  13565. var path = roundedRect(x,
  13566. y,
  13567. w,
  13568. h, { r: r });
  13569. if (!isNumber(anchorX)) {
  13570. return path;
  13571. }
  13572. // Anchor on right side
  13573. if (x + anchorX >= w) {
  13574. // Chevron
  13575. if (anchorY > y + safeDistance &&
  13576. anchorY < y + h - safeDistance) {
  13577. path.splice(3, 1, ['L', x + w, anchorY - halfDistance], ['L', x + w + arrowLength, anchorY], ['L', x + w, anchorY + halfDistance], ['L', x + w, y + h - r]);
  13578. // Simple connector
  13579. }
  13580. else {
  13581. path.splice(3, 1, ['L', x + w, h / 2], ['L', anchorX, anchorY], ['L', x + w, h / 2], ['L', x + w, y + h - r]);
  13582. }
  13583. // Anchor on left side
  13584. }
  13585. else if (x + anchorX <= 0) {
  13586. // Chevron
  13587. if (anchorY > y + safeDistance &&
  13588. anchorY < y + h - safeDistance) {
  13589. path.splice(7, 1, ['L', x, anchorY + halfDistance], ['L', x - arrowLength, anchorY], ['L', x, anchorY - halfDistance], ['L', x, y + r]);
  13590. // Simple connector
  13591. }
  13592. else {
  13593. path.splice(7, 1, ['L', x, h / 2], ['L', anchorX, anchorY], ['L', x, h / 2], ['L', x, y + r]);
  13594. }
  13595. }
  13596. else if ( // replace bottom
  13597. anchorY &&
  13598. anchorY > h &&
  13599. anchorX > x + safeDistance &&
  13600. anchorX < x + w - safeDistance) {
  13601. path.splice(5, 1, ['L', anchorX + halfDistance, y + h], ['L', anchorX, y + h + arrowLength], ['L', anchorX - halfDistance, y + h], ['L', x + r, y + h]);
  13602. }
  13603. else if ( // replace top
  13604. anchorY &&
  13605. anchorY < 0 &&
  13606. anchorX > x + safeDistance &&
  13607. anchorX < x + w - safeDistance) {
  13608. path.splice(1, 1, ['L', anchorX - halfDistance, y], ['L', anchorX, y - arrowLength], ['L', anchorX + halfDistance, y], ['L', w - r, y]);
  13609. }
  13610. return path;
  13611. }
  13612. };
  13613. H.SVGRenderer = SVGRenderer;
  13614. H.Renderer = H.SVGRenderer;
  13615. return H.Renderer;
  13616. });
  13617. _registerModule(_modules, 'Core/Renderer/HTML/HTMLElement.js', [_modules['Core/Globals.js'], _modules['Core/Renderer/SVG/SVGElement.js'], _modules['Core/Utilities.js']], function (H, SVGElement, U) {
  13618. /* *
  13619. *
  13620. * (c) 2010-2021 Torstein Honsi
  13621. *
  13622. * License: www.highcharts.com/license
  13623. *
  13624. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  13625. *
  13626. * */
  13627. var isFirefox = H.isFirefox,
  13628. isMS = H.isMS,
  13629. isWebKit = H.isWebKit,
  13630. win = H.win;
  13631. var css = U.css,
  13632. defined = U.defined,
  13633. extend = U.extend,
  13634. pick = U.pick,
  13635. pInt = U.pInt;
  13636. /**
  13637. * Element placebo
  13638. * @private
  13639. */
  13640. var HTMLElement = SVGElement;
  13641. /* eslint-disable valid-jsdoc */
  13642. // Extend SvgElement for useHTML option.
  13643. extend(HTMLElement.prototype, /** @lends SVGElement.prototype */ {
  13644. /**
  13645. * Apply CSS to HTML elements. This is used in text within SVG rendering and
  13646. * by the VML renderer
  13647. *
  13648. * @private
  13649. * @function Highcharts.SVGElement#htmlCss
  13650. *
  13651. * @param {Highcharts.CSSObject} styles
  13652. *
  13653. * @return {Highcharts.SVGElement}
  13654. */
  13655. htmlCss: function (styles) {
  13656. var wrapper = this,
  13657. element = wrapper.element,
  13658. // When setting or unsetting the width style, we need to update
  13659. // transform (#8809)
  13660. isSettingWidth = (element.tagName === 'SPAN' &&
  13661. styles &&
  13662. 'width' in styles),
  13663. textWidth = pick(isSettingWidth && styles.width,
  13664. void 0),
  13665. doTransform;
  13666. if (isSettingWidth) {
  13667. delete styles.width;
  13668. wrapper.textWidth = textWidth;
  13669. doTransform = true;
  13670. }
  13671. if (styles && styles.textOverflow === 'ellipsis') {
  13672. styles.whiteSpace = 'nowrap';
  13673. styles.overflow = 'hidden';
  13674. }
  13675. wrapper.styles = extend(wrapper.styles, styles);
  13676. css(wrapper.element, styles);
  13677. // Now that all styles are applied, to the transform
  13678. if (doTransform) {
  13679. wrapper.htmlUpdateTransform();
  13680. }
  13681. return wrapper;
  13682. },
  13683. /**
  13684. * VML and useHTML method for calculating the bounding box based on offsets.
  13685. *
  13686. * @private
  13687. * @function Highcharts.SVGElement#htmlGetBBox
  13688. *
  13689. * @param {boolean} refresh
  13690. * Whether to force a fresh value from the DOM or to use the cached
  13691. * value.
  13692. *
  13693. * @return {Highcharts.BBoxObject}
  13694. * A hash containing values for x, y, width and height.
  13695. */
  13696. htmlGetBBox: function () {
  13697. var wrapper = this,
  13698. element = wrapper.element;
  13699. return {
  13700. x: element.offsetLeft,
  13701. y: element.offsetTop,
  13702. width: element.offsetWidth,
  13703. height: element.offsetHeight
  13704. };
  13705. },
  13706. /**
  13707. * VML override private method to update elements based on internal
  13708. * properties based on SVG transform.
  13709. *
  13710. * @private
  13711. * @function Highcharts.SVGElement#htmlUpdateTransform
  13712. * @return {void}
  13713. */
  13714. htmlUpdateTransform: function () {
  13715. // aligning non added elements is expensive
  13716. if (!this.added) {
  13717. this.alignOnAdd = true;
  13718. return;
  13719. }
  13720. var wrapper = this,
  13721. renderer = wrapper.renderer,
  13722. elem = wrapper.element,
  13723. translateX = wrapper.translateX || 0,
  13724. translateY = wrapper.translateY || 0,
  13725. x = wrapper.x || 0,
  13726. y = wrapper.y || 0,
  13727. align = wrapper.textAlign || 'left',
  13728. alignCorrection = {
  13729. left: 0,
  13730. center: 0.5,
  13731. right: 1
  13732. }[align],
  13733. styles = wrapper.styles,
  13734. whiteSpace = styles && styles.whiteSpace;
  13735. /**
  13736. * @private
  13737. * @return {number}
  13738. */
  13739. function getTextPxLength() {
  13740. // Reset multiline/ellipsis in order to read width (#4928,
  13741. // #5417)
  13742. css(elem, {
  13743. width: '',
  13744. whiteSpace: whiteSpace || 'nowrap'
  13745. });
  13746. return elem.offsetWidth;
  13747. }
  13748. // apply translate
  13749. css(elem, {
  13750. marginLeft: translateX,
  13751. marginTop: translateY
  13752. });
  13753. if (!renderer.styledMode && wrapper.shadows) { // used in labels/tooltip
  13754. wrapper.shadows.forEach(function (shadow) {
  13755. css(shadow, {
  13756. marginLeft: translateX + 1,
  13757. marginTop: translateY + 1
  13758. });
  13759. });
  13760. }
  13761. // apply inversion
  13762. if (wrapper.inverted) { // wrapper is a group
  13763. [].forEach.call(elem.childNodes, function (child) {
  13764. renderer.invertChild(child, elem);
  13765. });
  13766. }
  13767. if (elem.tagName === 'SPAN') {
  13768. var rotation = wrapper.rotation, baseline = void 0, textWidth = wrapper.textWidth && pInt(wrapper.textWidth), currentTextTransform = [
  13769. rotation,
  13770. align,
  13771. elem.innerHTML,
  13772. wrapper.textWidth,
  13773. wrapper.textAlign
  13774. ].join(',');
  13775. // Update textWidth. Use the memoized textPxLength if possible, to
  13776. // avoid the getTextPxLength function using elem.offsetWidth.
  13777. // Calling offsetWidth affects rendering time as it forces layout
  13778. // (#7656).
  13779. if (textWidth !== wrapper.oldTextWidth &&
  13780. ((textWidth > wrapper.oldTextWidth) ||
  13781. (wrapper.textPxLength || getTextPxLength()) > textWidth) && (
  13782. // Only set the width if the text is able to word-wrap, or
  13783. // text-overflow is ellipsis (#9537)
  13784. /[ \-]/.test(elem.textContent || elem.innerText) ||
  13785. elem.style.textOverflow === 'ellipsis')) { // #983, #1254
  13786. css(elem, {
  13787. width: textWidth + 'px',
  13788. display: 'block',
  13789. whiteSpace: whiteSpace || 'normal' // #3331
  13790. });
  13791. wrapper.oldTextWidth = textWidth;
  13792. wrapper.hasBoxWidthChanged = true; // #8159
  13793. }
  13794. else {
  13795. wrapper.hasBoxWidthChanged = false; // #8159
  13796. }
  13797. // Do the calculations and DOM access only if properties changed
  13798. if (currentTextTransform !== wrapper.cTT) {
  13799. baseline = renderer.fontMetrics(elem.style.fontSize, elem).b;
  13800. // Renderer specific handling of span rotation, but only if we
  13801. // have something to update.
  13802. if (defined(rotation) &&
  13803. ((rotation !== (wrapper.oldRotation || 0)) ||
  13804. (align !== wrapper.oldAlign))) {
  13805. wrapper.setSpanRotation(rotation, alignCorrection, baseline);
  13806. }
  13807. wrapper.getSpanCorrection(
  13808. // Avoid elem.offsetWidth if we can, it affects rendering
  13809. // time heavily (#7656)
  13810. ((!defined(rotation) && wrapper.textPxLength) || // #7920
  13811. elem.offsetWidth), baseline, alignCorrection, rotation, align);
  13812. }
  13813. // apply position with correction
  13814. css(elem, {
  13815. left: (x + (wrapper.xCorr || 0)) + 'px',
  13816. top: (y + (wrapper.yCorr || 0)) + 'px'
  13817. });
  13818. // record current text transform
  13819. wrapper.cTT = currentTextTransform;
  13820. wrapper.oldRotation = rotation;
  13821. wrapper.oldAlign = align;
  13822. }
  13823. },
  13824. /**
  13825. * Set the rotation of an individual HTML span.
  13826. *
  13827. * @private
  13828. * @function Highcharts.SVGElement#setSpanRotation
  13829. * @param {number} rotation
  13830. * @param {number} alignCorrection
  13831. * @param {number} baseline
  13832. * @return {void}
  13833. */
  13834. setSpanRotation: function (rotation, alignCorrection, baseline) {
  13835. var getTransformKey = function () { return (isMS &&
  13836. !/Edge/.test(win.navigator.userAgent) ?
  13837. '-ms-transform' :
  13838. isWebKit ?
  13839. '-webkit-transform' :
  13840. isFirefox ?
  13841. 'MozTransform' :
  13842. win.opera ?
  13843. '-o-transform' :
  13844. void 0); };
  13845. var rotationStyle = {},
  13846. cssTransformKey = getTransformKey();
  13847. if (cssTransformKey) {
  13848. rotationStyle[cssTransformKey] = rotationStyle.transform =
  13849. 'rotate(' + rotation + 'deg)';
  13850. rotationStyle[cssTransformKey + (isFirefox ? 'Origin' : '-origin')] = rotationStyle.transformOrigin =
  13851. (alignCorrection * 100) + '% ' + baseline + 'px';
  13852. css(this.element, rotationStyle);
  13853. }
  13854. },
  13855. /**
  13856. * Get the correction in X and Y positioning as the element is rotated.
  13857. *
  13858. * @private
  13859. * @function Highcharts.SVGElement#getSpanCorrection
  13860. * @param {number} width
  13861. * @param {number} baseline
  13862. * @param {number} alignCorrection
  13863. * @return {void}
  13864. */
  13865. getSpanCorrection: function (width, baseline, alignCorrection) {
  13866. this.xCorr = -width * alignCorrection;
  13867. this.yCorr = -baseline;
  13868. }
  13869. });
  13870. return HTMLElement;
  13871. });
  13872. _registerModule(_modules, 'Core/Renderer/HTML/HTMLRenderer.js', [_modules['Core/Renderer/HTML/AST.js'], _modules['Core/Renderer/SVG/SVGElement.js'], _modules['Core/Renderer/SVG/SVGRenderer.js'], _modules['Core/Utilities.js']], function (AST, SVGElement, SVGRenderer, U) {
  13873. /* *
  13874. *
  13875. * (c) 2010-2021 Torstein Honsi
  13876. *
  13877. * License: www.highcharts.com/license
  13878. *
  13879. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  13880. *
  13881. * */
  13882. var attr = U.attr,
  13883. createElement = U.createElement,
  13884. extend = U.extend,
  13885. pick = U.pick;
  13886. /**
  13887. * Renderer placebo
  13888. * @private
  13889. */
  13890. var HTMLRenderer = SVGRenderer;
  13891. /* eslint-disable valid-jsdoc */
  13892. // Extend SvgRenderer for useHTML option.
  13893. extend(SVGRenderer.prototype, /** @lends SVGRenderer.prototype */ {
  13894. /**
  13895. * Create HTML text node. This is used by the VML renderer as well as the
  13896. * SVG renderer through the useHTML option.
  13897. *
  13898. * @private
  13899. * @function Highcharts.SVGRenderer#html
  13900. *
  13901. * @param {string} str
  13902. * The text of (subset) HTML to draw.
  13903. *
  13904. * @param {number} x
  13905. * The x position of the text's lower left corner.
  13906. *
  13907. * @param {number} y
  13908. * The y position of the text's lower left corner.
  13909. *
  13910. * @return {Highcharts.HTMLDOMElement}
  13911. */
  13912. html: function (str, x, y) {
  13913. var wrapper = this.createElement('span'), element = wrapper.element, renderer = wrapper.renderer, isSVG = renderer.isSVG, addSetters = function (gWrapper, style) {
  13914. // These properties are set as attributes on the SVG group, and
  13915. // as identical CSS properties on the div. (#3542)
  13916. ['opacity', 'visibility'].forEach(function (prop) {
  13917. gWrapper[prop + 'Setter'] = function (value, key, elem) {
  13918. var styleObject = gWrapper.div ?
  13919. gWrapper.div.style :
  13920. style;
  13921. SVGElement.prototype[prop + 'Setter']
  13922. .call(this, value, key, elem);
  13923. if (styleObject) {
  13924. styleObject[key] = value;
  13925. }
  13926. };
  13927. });
  13928. gWrapper.addedSetters = true;
  13929. };
  13930. // Text setter
  13931. wrapper.textSetter = function (value) {
  13932. if (value !== this.textStr) {
  13933. delete this.bBox;
  13934. delete this.oldTextWidth;
  13935. AST.setElementHTML(this.element, pick(value, ''));
  13936. this.textStr = value;
  13937. wrapper.doTransform = true;
  13938. }
  13939. };
  13940. // Add setters for the element itself (#4938)
  13941. if (isSVG) { // #4938, only for HTML within SVG
  13942. addSetters(wrapper, wrapper.element.style);
  13943. }
  13944. // Various setters which rely on update transform
  13945. wrapper.xSetter =
  13946. wrapper.ySetter =
  13947. wrapper.alignSetter =
  13948. wrapper.rotationSetter =
  13949. function (value, key) {
  13950. if (key === 'align') {
  13951. // Do not overwrite the SVGElement.align method. Same as VML.
  13952. wrapper.alignValue = wrapper.textAlign = value;
  13953. }
  13954. else {
  13955. wrapper[key] = value;
  13956. }
  13957. wrapper.doTransform = true;
  13958. };
  13959. // Runs at the end of .attr()
  13960. wrapper.afterSetters = function () {
  13961. // Update transform. Do this outside the loop to prevent redundant
  13962. // updating for batch setting of attributes.
  13963. if (this.doTransform) {
  13964. this.htmlUpdateTransform();
  13965. this.doTransform = false;
  13966. }
  13967. };
  13968. // Set the default attributes
  13969. wrapper
  13970. .attr({
  13971. text: str,
  13972. x: Math.round(x),
  13973. y: Math.round(y)
  13974. })
  13975. .css({
  13976. position: 'absolute'
  13977. });
  13978. if (!renderer.styledMode) {
  13979. wrapper.css({
  13980. fontFamily: this.style.fontFamily,
  13981. fontSize: this.style.fontSize
  13982. });
  13983. }
  13984. // Keep the whiteSpace style outside the wrapper.styles collection
  13985. element.style.whiteSpace = 'nowrap';
  13986. // Use the HTML specific .css method
  13987. wrapper.css = wrapper.htmlCss;
  13988. // This is specific for HTML within SVG
  13989. if (isSVG) {
  13990. wrapper.add = function (svgGroupWrapper) {
  13991. var htmlGroup,
  13992. container = renderer.box.parentNode,
  13993. parentGroup,
  13994. parents = [];
  13995. this.parentGroup = svgGroupWrapper;
  13996. // Create a mock group to hold the HTML elements
  13997. if (svgGroupWrapper) {
  13998. htmlGroup = svgGroupWrapper.div;
  13999. if (!htmlGroup) {
  14000. // Read the parent chain into an array and read from top
  14001. // down
  14002. parentGroup = svgGroupWrapper;
  14003. while (parentGroup) {
  14004. parents.push(parentGroup);
  14005. // Move up to the next parent group
  14006. parentGroup = parentGroup.parentGroup;
  14007. }
  14008. // Ensure dynamically updating position when any parent
  14009. // is translated
  14010. parents.reverse().forEach(function (parentGroup) {
  14011. var htmlGroupStyle,
  14012. cls = attr(parentGroup.element, 'class');
  14013. /**
  14014. * Common translate setter for X and Y on the HTML
  14015. * group. Reverted the fix for #6957 du to
  14016. * positioning problems and offline export (#7254,
  14017. * #7280, #7529)
  14018. * @private
  14019. * @param {*} value
  14020. * @param {string} key
  14021. * @return {void}
  14022. */
  14023. function translateSetter(value, key) {
  14024. parentGroup[key] = value;
  14025. if (key === 'translateX') {
  14026. htmlGroupStyle.left = value + 'px';
  14027. }
  14028. else {
  14029. htmlGroupStyle.top = value + 'px';
  14030. }
  14031. parentGroup.doTransform = true;
  14032. }
  14033. // Create a HTML div and append it to the parent div
  14034. // to emulate the SVG group structure
  14035. var parentGroupStyles = parentGroup.styles || {};
  14036. htmlGroup =
  14037. parentGroup.div =
  14038. parentGroup.div || createElement('div', cls ? { className: cls } : void 0, {
  14039. position: 'absolute',
  14040. left: (parentGroup.translateX || 0) + 'px',
  14041. top: (parentGroup.translateY || 0) + 'px',
  14042. display: parentGroup.display,
  14043. opacity: parentGroup.opacity,
  14044. cursor: parentGroupStyles.cursor,
  14045. pointerEvents: parentGroupStyles.pointerEvents // #5595
  14046. // the top group is appended to container
  14047. }, htmlGroup || container);
  14048. // Shortcut
  14049. htmlGroupStyle = htmlGroup.style;
  14050. // Set listeners to update the HTML div's position
  14051. // whenever the SVG group position is changed.
  14052. extend(parentGroup, {
  14053. // (#7287) Pass htmlGroup to use
  14054. // the related group
  14055. classSetter: (function (htmlGroup) {
  14056. return function (value) {
  14057. this.element.setAttribute('class', value);
  14058. htmlGroup.className = value;
  14059. };
  14060. }(htmlGroup)),
  14061. on: function () {
  14062. if (parents[0].div) { // #6418
  14063. wrapper.on.apply({
  14064. element: parents[0].div,
  14065. onEvents: wrapper.onEvents
  14066. }, arguments);
  14067. }
  14068. return parentGroup;
  14069. },
  14070. translateXSetter: translateSetter,
  14071. translateYSetter: translateSetter
  14072. });
  14073. if (!parentGroup.addedSetters) {
  14074. addSetters(parentGroup);
  14075. }
  14076. });
  14077. }
  14078. }
  14079. else {
  14080. htmlGroup = container;
  14081. }
  14082. htmlGroup.appendChild(element);
  14083. // Shared with VML:
  14084. wrapper.added = true;
  14085. if (wrapper.alignOnAdd) {
  14086. wrapper.htmlUpdateTransform();
  14087. }
  14088. return wrapper;
  14089. };
  14090. }
  14091. return wrapper;
  14092. }
  14093. });
  14094. return HTMLRenderer;
  14095. });
  14096. _registerModule(_modules, 'Core/Axis/Tick.js', [_modules['Core/FormatUtilities.js'], _modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (F, H, U) {
  14097. /* *
  14098. *
  14099. * (c) 2010-2021 Torstein Honsi
  14100. *
  14101. * License: www.highcharts.com/license
  14102. *
  14103. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  14104. *
  14105. * */
  14106. var deg2rad = H.deg2rad;
  14107. var clamp = U.clamp,
  14108. correctFloat = U.correctFloat,
  14109. defined = U.defined,
  14110. destroyObjectProperties = U.destroyObjectProperties,
  14111. extend = U.extend,
  14112. fireEvent = U.fireEvent,
  14113. isNumber = U.isNumber,
  14114. merge = U.merge,
  14115. objectEach = U.objectEach,
  14116. pick = U.pick;
  14117. /**
  14118. * Optional parameters for the tick.
  14119. * @private
  14120. * @interface Highcharts.TickParametersObject
  14121. */ /**
  14122. * Set category for the tick.
  14123. * @name Highcharts.TickParametersObject#category
  14124. * @type {string|undefined}
  14125. */ /**
  14126. * @name Highcharts.TickParametersObject#options
  14127. * @type {Highcharts.Dictionary<any>|undefined}
  14128. */ /**
  14129. * Set tickmarkOffset for the tick.
  14130. * @name Highcharts.TickParametersObject#tickmarkOffset
  14131. * @type {number|undefined}
  14132. */
  14133. /**
  14134. * Additonal time tick information.
  14135. *
  14136. * @interface Highcharts.TimeTicksInfoObject
  14137. * @extends Highcharts.TimeNormalizedObject
  14138. */ /**
  14139. * @name Highcharts.TimeTicksInfoObject#higherRanks
  14140. * @type {Array<string>}
  14141. */ /**
  14142. * @name Highcharts.TimeTicksInfoObject#totalRange
  14143. * @type {number}
  14144. */
  14145. ''; // detach doclets above
  14146. /* eslint-disable no-invalid-this, valid-jsdoc */
  14147. /**
  14148. * The Tick class.
  14149. *
  14150. * @class
  14151. * @name Highcharts.Tick
  14152. *
  14153. * @param {Highcharts.Axis} axis
  14154. * The axis of the tick.
  14155. *
  14156. * @param {number} pos
  14157. * The position of the tick on the axis in terms of axis values.
  14158. *
  14159. * @param {string} [type]
  14160. * The type of tick, either 'minor' or an empty string
  14161. *
  14162. * @param {boolean} [noLabel=false]
  14163. * Whether to disable the label or not. Defaults to false.
  14164. *
  14165. * @param {object} [parameters]
  14166. * Optional parameters for the tick.
  14167. */
  14168. var Tick = /** @class */ (function () {
  14169. /* *
  14170. *
  14171. * Constructors
  14172. *
  14173. * */
  14174. function Tick(axis, pos, type, noLabel, parameters) {
  14175. this.isNew = true;
  14176. this.isNewLabel = true;
  14177. /**
  14178. * The related axis of the tick.
  14179. * @name Highcharts.Tick#axis
  14180. * @type {Highcharts.Axis}
  14181. */
  14182. this.axis = axis;
  14183. /**
  14184. * The logical position of the tick on the axis in terms of axis values.
  14185. * @name Highcharts.Tick#pos
  14186. * @type {number}
  14187. */
  14188. this.pos = pos;
  14189. /**
  14190. * The tick type, which can be `"minor"`, or an empty string.
  14191. * @name Highcharts.Tick#type
  14192. * @type {string}
  14193. */
  14194. this.type = type || '';
  14195. this.parameters = parameters || {};
  14196. /**
  14197. * The mark offset of the tick on the axis. Usually `undefined`, numeric
  14198. * for grid axes.
  14199. * @name Highcharts.Tick#tickmarkOffset
  14200. * @type {number|undefined}
  14201. */
  14202. this.tickmarkOffset = this.parameters.tickmarkOffset;
  14203. this.options = this.parameters.options;
  14204. fireEvent(this, 'init');
  14205. if (!type && !noLabel) {
  14206. this.addLabel();
  14207. }
  14208. }
  14209. /* *
  14210. *
  14211. * Functions
  14212. *
  14213. * */
  14214. /**
  14215. * Write the tick label.
  14216. *
  14217. * @private
  14218. * @function Highcharts.Tick#addLabel
  14219. * @return {void}
  14220. */
  14221. Tick.prototype.addLabel = function () {
  14222. var tick = this,
  14223. axis = tick.axis,
  14224. options = axis.options,
  14225. chart = axis.chart,
  14226. categories = axis.categories,
  14227. log = axis.logarithmic,
  14228. names = axis.names,
  14229. pos = tick.pos,
  14230. labelOptions = pick(tick.options && tick.options.labels,
  14231. options.labels),
  14232. str,
  14233. tickPositions = axis.tickPositions,
  14234. isFirst = pos === tickPositions[0],
  14235. isLast = pos === tickPositions[tickPositions.length - 1],
  14236. label = tick.label,
  14237. animateLabels = (!labelOptions.step || labelOptions.step === 1) &&
  14238. axis.tickInterval === 1,
  14239. tickPositionInfo = tickPositions.info,
  14240. dateTimeLabelFormat,
  14241. dateTimeLabelFormats,
  14242. i,
  14243. list;
  14244. // The context value
  14245. var value = this.parameters.category || (categories ?
  14246. pick(categories[pos],
  14247. names[pos],
  14248. pos) :
  14249. pos);
  14250. if (log && isNumber(value)) {
  14251. value = correctFloat(log.lin2log(value));
  14252. }
  14253. // Set the datetime label format. If a higher rank is set for this
  14254. // position, use that. If not, use the general format.
  14255. if (axis.dateTime && tickPositionInfo) {
  14256. dateTimeLabelFormats = chart.time.resolveDTLFormat(options.dateTimeLabelFormats[(!options.grid &&
  14257. tickPositionInfo.higherRanks[pos]) ||
  14258. tickPositionInfo.unitName]);
  14259. dateTimeLabelFormat = dateTimeLabelFormats.main;
  14260. }
  14261. // set properties for access in render method
  14262. /**
  14263. * True if the tick is the first one on the axis.
  14264. * @name Highcharts.Tick#isFirst
  14265. * @readonly
  14266. * @type {boolean|undefined}
  14267. */
  14268. tick.isFirst = isFirst;
  14269. /**
  14270. * True if the tick is the last one on the axis.
  14271. * @name Highcharts.Tick#isLast
  14272. * @readonly
  14273. * @type {boolean|undefined}
  14274. */
  14275. tick.isLast = isLast;
  14276. // Get the string
  14277. var ctx = {
  14278. axis: axis,
  14279. chart: chart,
  14280. dateTimeLabelFormat: dateTimeLabelFormat,
  14281. isFirst: isFirst,
  14282. isLast: isLast,
  14283. pos: pos,
  14284. tick: tick,
  14285. tickPositionInfo: tickPositionInfo,
  14286. value: value
  14287. };
  14288. // Fire an event that allows modifying the context for use in
  14289. // `labels.format` and `labels.formatter`.
  14290. fireEvent(this, 'labelFormat', ctx);
  14291. // Label formatting. When `labels.format` is given, we first run the
  14292. // defaultFormatter and append the result to the context as `text`.
  14293. // Handy for adding prefix or suffix while keeping default number
  14294. // formatting.
  14295. var labelFormatter = function (ctx) {
  14296. if (labelOptions.formatter) {
  14297. return labelOptions.formatter.call(ctx,
  14298. ctx);
  14299. }
  14300. if (labelOptions.format) {
  14301. ctx.text = axis.defaultLabelFormatter.call(ctx);
  14302. return F.format(labelOptions.format, ctx, chart);
  14303. }
  14304. return axis.defaultLabelFormatter.call(ctx, ctx);
  14305. };
  14306. str = labelFormatter.call(ctx, ctx);
  14307. // Set up conditional formatting based on the format list if existing.
  14308. list = dateTimeLabelFormats && dateTimeLabelFormats.list;
  14309. if (list) {
  14310. tick.shortenLabel = function () {
  14311. for (i = 0; i < list.length; i++) {
  14312. extend(ctx, { dateTimeLabelFormat: list[i] });
  14313. label.attr({
  14314. text: labelFormatter.call(ctx, ctx)
  14315. });
  14316. if (label.getBBox().width <
  14317. axis.getSlotWidth(tick) - 2 *
  14318. labelOptions.padding) {
  14319. return;
  14320. }
  14321. }
  14322. label.attr({
  14323. text: ''
  14324. });
  14325. };
  14326. }
  14327. // Call only after first render
  14328. if (animateLabels && axis._addedPlotLB) {
  14329. tick.moveLabel(str, labelOptions);
  14330. }
  14331. // First call
  14332. if (!defined(label) && !tick.movedLabel) {
  14333. /**
  14334. * The rendered text label of the tick.
  14335. * @name Highcharts.Tick#label
  14336. * @type {Highcharts.SVGElement|undefined}
  14337. */
  14338. tick.label = label = tick.createLabel({ x: 0, y: 0 }, str, labelOptions);
  14339. // Base value to detect change for new calls to getBBox
  14340. tick.rotation = 0;
  14341. // update
  14342. }
  14343. else if (label && label.textStr !== str && !animateLabels) {
  14344. // When resetting text, also reset the width if dynamically set
  14345. // (#8809)
  14346. if (label.textWidth &&
  14347. !labelOptions.style.width &&
  14348. !label.styles.width) {
  14349. label.css({ width: null });
  14350. }
  14351. label.attr({ text: str });
  14352. label.textPxLength = label.getBBox().width;
  14353. }
  14354. };
  14355. /**
  14356. * Render and return the label of the tick.
  14357. *
  14358. * @private
  14359. * @function Highcharts.Tick#createLabel
  14360. * @param {Highcharts.PositionObject} xy
  14361. * @param {string} str
  14362. * @param {Highcharts.XAxisLabelsOptions} labelOptions
  14363. * @return {Highcharts.SVGElement|undefined}
  14364. */
  14365. Tick.prototype.createLabel = function (xy, str, labelOptions) {
  14366. var axis = this.axis,
  14367. chart = axis.chart,
  14368. label = defined(str) && labelOptions.enabled ?
  14369. chart.renderer
  14370. .text(str,
  14371. xy.x,
  14372. xy.y,
  14373. labelOptions.useHTML)
  14374. .add(axis.labelGroup) :
  14375. null;
  14376. // Un-rotated length
  14377. if (label) {
  14378. // Without position absolute, IE export sometimes is wrong
  14379. if (!chart.styledMode) {
  14380. label.css(merge(labelOptions.style));
  14381. }
  14382. label.textPxLength = label.getBBox().width;
  14383. }
  14384. return label;
  14385. };
  14386. /**
  14387. * Destructor for the tick prototype
  14388. *
  14389. * @private
  14390. * @function Highcharts.Tick#destroy
  14391. * @return {void}
  14392. */
  14393. Tick.prototype.destroy = function () {
  14394. destroyObjectProperties(this, this.axis);
  14395. };
  14396. /**
  14397. * Gets the x and y positions for ticks in terms of pixels.
  14398. *
  14399. * @private
  14400. * @function Highcharts.Tick#getPosition
  14401. *
  14402. * @param {boolean} horiz
  14403. * Whether the tick is on an horizontal axis or not.
  14404. *
  14405. * @param {number} tickPos
  14406. * Position of the tick.
  14407. *
  14408. * @param {number} tickmarkOffset
  14409. * Tickmark offset for all ticks.
  14410. *
  14411. * @param {boolean} [old]
  14412. * Whether the axis has changed or not.
  14413. *
  14414. * @return {Highcharts.PositionObject}
  14415. * The tick position.
  14416. *
  14417. * @fires Highcharts.Tick#event:afterGetPosition
  14418. */
  14419. Tick.prototype.getPosition = function (horiz, tickPos, tickmarkOffset, old) {
  14420. var axis = this.axis,
  14421. chart = axis.chart,
  14422. cHeight = (old && chart.oldChartHeight) || chart.chartHeight,
  14423. pos;
  14424. pos = {
  14425. x: horiz ?
  14426. correctFloat(axis.translate(tickPos + tickmarkOffset, null, null, old) +
  14427. axis.transB) :
  14428. (axis.left +
  14429. axis.offset +
  14430. (axis.opposite ?
  14431. (((old && chart.oldChartWidth) ||
  14432. chart.chartWidth) -
  14433. axis.right -
  14434. axis.left) :
  14435. 0)),
  14436. y: horiz ?
  14437. (cHeight -
  14438. axis.bottom +
  14439. axis.offset -
  14440. (axis.opposite ? axis.height : 0)) :
  14441. correctFloat(cHeight -
  14442. axis.translate(tickPos + tickmarkOffset, null, null, old) -
  14443. axis.transB)
  14444. };
  14445. // Chrome workaround for #10516
  14446. pos.y = clamp(pos.y, -1e5, 1e5);
  14447. fireEvent(this, 'afterGetPosition', { pos: pos });
  14448. return pos;
  14449. };
  14450. /**
  14451. * Get the x, y position of the tick label
  14452. *
  14453. * @private
  14454. * @return {Highcharts.PositionObject}
  14455. */
  14456. Tick.prototype.getLabelPosition = function (x, y, label, horiz, labelOptions, tickmarkOffset, index, step) {
  14457. var axis = this.axis,
  14458. transA = axis.transA,
  14459. reversed = ( // #7911
  14460. axis.isLinked && axis.linkedParent ?
  14461. axis.linkedParent.reversed :
  14462. axis.reversed),
  14463. staggerLines = axis.staggerLines,
  14464. rotCorr = axis.tickRotCorr || { x: 0,
  14465. y: 0 },
  14466. yOffset = labelOptions.y,
  14467. // Adjust for label alignment if we use reserveSpace: true (#5286)
  14468. labelOffsetCorrection = (!horiz && !axis.reserveSpaceDefault ?
  14469. -axis.labelOffset * (axis.labelAlign === 'center' ? 0.5 : 1) :
  14470. 0),
  14471. line,
  14472. pos = {};
  14473. if (!defined(yOffset)) {
  14474. if (axis.side === 0) {
  14475. yOffset = label.rotation ? -8 : -label.getBBox().height;
  14476. }
  14477. else if (axis.side === 2) {
  14478. yOffset = rotCorr.y + 8;
  14479. }
  14480. else {
  14481. // #3140, #3140
  14482. yOffset = Math.cos(label.rotation * deg2rad) *
  14483. (rotCorr.y - label.getBBox(false, 0).height / 2);
  14484. }
  14485. }
  14486. x = x +
  14487. labelOptions.x +
  14488. labelOffsetCorrection +
  14489. rotCorr.x -
  14490. (tickmarkOffset && horiz ?
  14491. tickmarkOffset * transA * (reversed ? -1 : 1) :
  14492. 0);
  14493. y = y + yOffset - (tickmarkOffset && !horiz ?
  14494. tickmarkOffset * transA * (reversed ? 1 : -1) : 0);
  14495. // Correct for staggered labels
  14496. if (staggerLines) {
  14497. line = (index / (step || 1) % staggerLines);
  14498. if (axis.opposite) {
  14499. line = staggerLines - line - 1;
  14500. }
  14501. y += line * (axis.labelOffset / staggerLines);
  14502. }
  14503. pos.x = x;
  14504. pos.y = Math.round(y);
  14505. fireEvent(this, 'afterGetLabelPosition', { pos: pos, tickmarkOffset: tickmarkOffset, index: index });
  14506. return pos;
  14507. };
  14508. /**
  14509. * Get the offset height or width of the label
  14510. *
  14511. * @private
  14512. * @function Highcharts.Tick#getLabelSize
  14513. * @return {number}
  14514. */
  14515. Tick.prototype.getLabelSize = function () {
  14516. return this.label ?
  14517. this.label.getBBox()[this.axis.horiz ? 'height' : 'width'] :
  14518. 0;
  14519. };
  14520. /**
  14521. * Extendible method to return the path of the marker
  14522. *
  14523. * @private
  14524. *
  14525. */
  14526. Tick.prototype.getMarkPath = function (x, y, tickLength, tickWidth, horiz, renderer) {
  14527. return renderer.crispLine([[
  14528. 'M',
  14529. x,
  14530. y
  14531. ], [
  14532. 'L',
  14533. x + (horiz ? 0 : -tickLength),
  14534. y + (horiz ? tickLength : 0)
  14535. ]], tickWidth);
  14536. };
  14537. /**
  14538. * Handle the label overflow by adjusting the labels to the left and right
  14539. * edge, or hide them if they collide into the neighbour label.
  14540. *
  14541. * @private
  14542. * @function Highcharts.Tick#handleOverflow
  14543. * @param {Highcharts.PositionObject} xy
  14544. * @return {void}
  14545. */
  14546. Tick.prototype.handleOverflow = function (xy) {
  14547. var tick = this,
  14548. axis = this.axis,
  14549. labelOptions = axis.options.labels,
  14550. pxPos = xy.x,
  14551. chartWidth = axis.chart.chartWidth,
  14552. spacing = axis.chart.spacing,
  14553. leftBound = pick(axis.labelLeft,
  14554. Math.min(axis.pos,
  14555. spacing[3])),
  14556. rightBound = pick(axis.labelRight,
  14557. Math.max(!axis.isRadial ? axis.pos + axis.len : 0,
  14558. chartWidth - spacing[1])),
  14559. label = this.label,
  14560. rotation = this.rotation,
  14561. factor = {
  14562. left: 0,
  14563. center: 0.5,
  14564. right: 1
  14565. }[axis.labelAlign || label.attr('align')],
  14566. labelWidth = label.getBBox().width,
  14567. slotWidth = axis.getSlotWidth(tick),
  14568. modifiedSlotWidth = slotWidth,
  14569. xCorrection = factor,
  14570. goRight = 1,
  14571. leftPos,
  14572. rightPos,
  14573. textWidth,
  14574. css = {};
  14575. // Check if the label overshoots the chart spacing box. If it does, move
  14576. // it. If it now overshoots the slotWidth, add ellipsis.
  14577. if (!rotation && labelOptions.overflow === 'justify') {
  14578. leftPos = pxPos - factor * labelWidth;
  14579. rightPos = pxPos + (1 - factor) * labelWidth;
  14580. if (leftPos < leftBound) {
  14581. modifiedSlotWidth =
  14582. xy.x + modifiedSlotWidth * (1 - factor) - leftBound;
  14583. }
  14584. else if (rightPos > rightBound) {
  14585. modifiedSlotWidth =
  14586. rightBound - xy.x + modifiedSlotWidth * factor;
  14587. goRight = -1;
  14588. }
  14589. modifiedSlotWidth = Math.min(slotWidth, modifiedSlotWidth); // #4177
  14590. if (modifiedSlotWidth < slotWidth && axis.labelAlign === 'center') {
  14591. xy.x += (goRight *
  14592. (slotWidth -
  14593. modifiedSlotWidth -
  14594. xCorrection * (slotWidth - Math.min(labelWidth, modifiedSlotWidth))));
  14595. }
  14596. // If the label width exceeds the available space, set a text width
  14597. // to be picked up below. Also, if a width has been set before, we
  14598. // need to set a new one because the reported labelWidth will be
  14599. // limited by the box (#3938).
  14600. if (labelWidth > modifiedSlotWidth ||
  14601. (axis.autoRotation && (label.styles || {}).width)) {
  14602. textWidth = modifiedSlotWidth;
  14603. }
  14604. // Add ellipsis to prevent rotated labels to be clipped against the edge
  14605. // of the chart
  14606. }
  14607. else if (rotation < 0 &&
  14608. pxPos - factor * labelWidth < leftBound) {
  14609. textWidth = Math.round(pxPos / Math.cos(rotation * deg2rad) - leftBound);
  14610. }
  14611. else if (rotation > 0 &&
  14612. pxPos + factor * labelWidth > rightBound) {
  14613. textWidth = Math.round((chartWidth - pxPos) /
  14614. Math.cos(rotation * deg2rad));
  14615. }
  14616. if (textWidth) {
  14617. if (tick.shortenLabel) {
  14618. tick.shortenLabel();
  14619. }
  14620. else {
  14621. css.width = Math.floor(textWidth) + 'px';
  14622. if (!(labelOptions.style || {}).textOverflow) {
  14623. css.textOverflow = 'ellipsis';
  14624. }
  14625. label.css(css);
  14626. }
  14627. }
  14628. };
  14629. /**
  14630. * Try to replace the label if the same one already exists.
  14631. *
  14632. * @private
  14633. * @function Highcharts.Tick#moveLabel
  14634. * @param {string} str
  14635. * @param {Highcharts.XAxisLabelsOptions} labelOptions
  14636. *
  14637. * @return {void}
  14638. */
  14639. Tick.prototype.moveLabel = function (str, labelOptions) {
  14640. var tick = this,
  14641. label = tick.label,
  14642. moved = false,
  14643. axis = tick.axis,
  14644. labelPos,
  14645. reversed = axis.reversed,
  14646. xPos,
  14647. yPos;
  14648. if (label && label.textStr === str) {
  14649. tick.movedLabel = label;
  14650. moved = true;
  14651. delete tick.label;
  14652. }
  14653. else { // Find a label with the same string
  14654. objectEach(axis.ticks, function (currentTick) {
  14655. if (!moved &&
  14656. !currentTick.isNew &&
  14657. currentTick !== tick &&
  14658. currentTick.label &&
  14659. currentTick.label.textStr === str) {
  14660. tick.movedLabel = currentTick.label;
  14661. moved = true;
  14662. currentTick.labelPos = tick.movedLabel.xy;
  14663. delete currentTick.label;
  14664. }
  14665. });
  14666. }
  14667. // Create new label if the actual one is moved
  14668. if (!moved && (tick.labelPos || label)) {
  14669. labelPos = tick.labelPos || label.xy;
  14670. xPos = axis.horiz ?
  14671. (reversed ? 0 : axis.width + axis.left) : labelPos.x;
  14672. yPos = axis.horiz ?
  14673. labelPos.y : (reversed ? (axis.width + axis.left) : 0);
  14674. tick.movedLabel = tick.createLabel({ x: xPos, y: yPos }, str, labelOptions);
  14675. if (tick.movedLabel) {
  14676. tick.movedLabel.attr({ opacity: 0 });
  14677. }
  14678. }
  14679. };
  14680. /**
  14681. * Put everything in place
  14682. *
  14683. * @private
  14684. * @param {number} index
  14685. * @param {boolean} [old]
  14686. * Use old coordinates to prepare an animation into new position
  14687. * @param {number} [opacity]
  14688. * @return {voids}
  14689. */
  14690. Tick.prototype.render = function (index, old, opacity) {
  14691. var tick = this,
  14692. axis = tick.axis,
  14693. horiz = axis.horiz,
  14694. pos = tick.pos,
  14695. tickmarkOffset = pick(tick.tickmarkOffset,
  14696. axis.tickmarkOffset),
  14697. xy = tick.getPosition(horiz,
  14698. pos,
  14699. tickmarkOffset,
  14700. old),
  14701. x = xy.x,
  14702. y = xy.y,
  14703. reverseCrisp = ((horiz && x === axis.pos + axis.len) ||
  14704. (!horiz && y === axis.pos)) ? -1 : 1; // #1480, #1687
  14705. var labelOpacity = pick(opacity,
  14706. tick.label && tick.label.newOpacity, // #15528
  14707. 1);
  14708. opacity = pick(opacity, 1);
  14709. this.isActive = true;
  14710. // Create the grid line
  14711. this.renderGridLine(old, opacity, reverseCrisp);
  14712. // create the tick mark
  14713. this.renderMark(xy, opacity, reverseCrisp);
  14714. // the label is created on init - now move it into place
  14715. this.renderLabel(xy, old, labelOpacity, index);
  14716. tick.isNew = false;
  14717. fireEvent(this, 'afterRender');
  14718. };
  14719. /**
  14720. * Renders the gridLine.
  14721. *
  14722. * @private
  14723. * @param {boolean} old Whether or not the tick is old
  14724. * @param {number} opacity The opacity of the grid line
  14725. * @param {number} reverseCrisp Modifier for avoiding overlapping 1 or -1
  14726. * @return {void}
  14727. */
  14728. Tick.prototype.renderGridLine = function (old, opacity, reverseCrisp) {
  14729. var tick = this,
  14730. axis = tick.axis,
  14731. options = axis.options,
  14732. gridLine = tick.gridLine,
  14733. gridLinePath,
  14734. attribs = {},
  14735. pos = tick.pos,
  14736. type = tick.type,
  14737. tickmarkOffset = pick(tick.tickmarkOffset,
  14738. axis.tickmarkOffset),
  14739. renderer = axis.chart.renderer,
  14740. gridLineWidth = options.gridLineWidth,
  14741. gridLineColor = options.gridLineColor,
  14742. dashStyle = options.gridLineDashStyle;
  14743. if (tick.type === 'minor') {
  14744. gridLineWidth = options.minorGridLineWidth;
  14745. gridLineColor = options.minorGridLineColor;
  14746. dashStyle = options.minorGridLineDashStyle;
  14747. }
  14748. if (!gridLine) {
  14749. if (!axis.chart.styledMode) {
  14750. attribs.stroke = gridLineColor;
  14751. attribs['stroke-width'] = gridLineWidth || 0;
  14752. attribs.dashstyle = dashStyle;
  14753. }
  14754. if (!type) {
  14755. attribs.zIndex = 1;
  14756. }
  14757. if (old) {
  14758. opacity = 0;
  14759. }
  14760. /**
  14761. * The rendered grid line of the tick.
  14762. * @name Highcharts.Tick#gridLine
  14763. * @type {Highcharts.SVGElement|undefined}
  14764. */
  14765. tick.gridLine = gridLine = renderer.path()
  14766. .attr(attribs)
  14767. .addClass('highcharts-' + (type ? type + '-' : '') + 'grid-line')
  14768. .add(axis.gridGroup);
  14769. }
  14770. if (gridLine) {
  14771. gridLinePath = axis.getPlotLinePath({
  14772. value: pos + tickmarkOffset,
  14773. lineWidth: gridLine.strokeWidth() * reverseCrisp,
  14774. force: 'pass',
  14775. old: old
  14776. });
  14777. // If the parameter 'old' is set, the current call will be followed
  14778. // by another call, therefore do not do any animations this time
  14779. if (gridLinePath) {
  14780. gridLine[old || tick.isNew ? 'attr' : 'animate']({
  14781. d: gridLinePath,
  14782. opacity: opacity
  14783. });
  14784. }
  14785. }
  14786. };
  14787. /**
  14788. * Renders the tick mark.
  14789. *
  14790. * @private
  14791. * @param {Highcharts.PositionObject} xy The position vector of the mark
  14792. * @param {number} opacity The opacity of the mark
  14793. * @param {number} reverseCrisp Modifier for avoiding overlapping 1 or -1
  14794. * @return {void}
  14795. */
  14796. Tick.prototype.renderMark = function (xy, opacity, reverseCrisp) {
  14797. var tick = this, axis = tick.axis, options = axis.options, renderer = axis.chart.renderer, type = tick.type, tickSize = axis.tickSize(type ? type + 'Tick' : 'tick'), mark = tick.mark, isNewMark = !mark, x = xy.x, y = xy.y, tickWidth = pick(options[type !== 'minor' ? 'tickWidth' : 'minorTickWidth'], !type && axis.isXAxis ? 1 : 0), // X axis defaults to 1
  14798. tickColor = options[type !== 'minor' ? 'tickColor' : 'minorTickColor'];
  14799. if (tickSize) {
  14800. // negate the length
  14801. if (axis.opposite) {
  14802. tickSize[0] = -tickSize[0];
  14803. }
  14804. // First time, create it
  14805. if (isNewMark) {
  14806. /**
  14807. * The rendered mark of the tick.
  14808. * @name Highcharts.Tick#mark
  14809. * @type {Highcharts.SVGElement|undefined}
  14810. */
  14811. tick.mark = mark = renderer.path()
  14812. .addClass('highcharts-' + (type ? type + '-' : '') + 'tick')
  14813. .add(axis.axisGroup);
  14814. if (!axis.chart.styledMode) {
  14815. mark.attr({
  14816. stroke: tickColor,
  14817. 'stroke-width': tickWidth
  14818. });
  14819. }
  14820. }
  14821. mark[isNewMark ? 'attr' : 'animate']({
  14822. d: tick.getMarkPath(x, y, tickSize[0], mark.strokeWidth() * reverseCrisp, axis.horiz, renderer),
  14823. opacity: opacity
  14824. });
  14825. }
  14826. };
  14827. /**
  14828. * Renders the tick label.
  14829. * Note: The label should already be created in init(), so it should only
  14830. * have to be moved into place.
  14831. *
  14832. * @private
  14833. * @param {Highcharts.PositionObject} xy The position vector of the label
  14834. * @param {boolean} old Whether or not the tick is old
  14835. * @param {number} opacity The opacity of the label
  14836. * @param {number} index The index of the tick
  14837. * @return {void}
  14838. */
  14839. Tick.prototype.renderLabel = function (xy, old, opacity, index) {
  14840. var tick = this,
  14841. axis = tick.axis,
  14842. horiz = axis.horiz,
  14843. options = axis.options,
  14844. label = tick.label,
  14845. labelOptions = options.labels,
  14846. step = labelOptions.step,
  14847. tickmarkOffset = pick(tick.tickmarkOffset,
  14848. axis.tickmarkOffset),
  14849. show = true,
  14850. x = xy.x,
  14851. y = xy.y;
  14852. if (label && isNumber(x)) {
  14853. label.xy = xy = tick.getLabelPosition(x, y, label, horiz, labelOptions, tickmarkOffset, index, step);
  14854. // Apply show first and show last. If the tick is both first and
  14855. // last, it is a single centered tick, in which case we show the
  14856. // label anyway (#2100).
  14857. if ((tick.isFirst &&
  14858. !tick.isLast &&
  14859. !options.showFirstLabel) ||
  14860. (tick.isLast &&
  14861. !tick.isFirst &&
  14862. !options.showLastLabel)) {
  14863. show = false;
  14864. // Handle label overflow and show or hide accordingly
  14865. }
  14866. else if (horiz &&
  14867. !labelOptions.step &&
  14868. !labelOptions.rotation &&
  14869. !old &&
  14870. opacity !== 0) {
  14871. tick.handleOverflow(xy);
  14872. }
  14873. // apply step
  14874. if (step && index % step) {
  14875. // show those indices dividable by step
  14876. show = false;
  14877. }
  14878. // Set the new position, and show or hide
  14879. if (show && isNumber(xy.y)) {
  14880. xy.opacity = opacity;
  14881. label[tick.isNewLabel ? 'attr' : 'animate'](xy);
  14882. tick.isNewLabel = false;
  14883. }
  14884. else {
  14885. label.attr('y', -9999); // #1338
  14886. tick.isNewLabel = true;
  14887. }
  14888. }
  14889. };
  14890. /**
  14891. * Replace labels with the moved ones to perform animation. Additionally
  14892. * destroy unused labels.
  14893. *
  14894. * @private
  14895. * @function Highcharts.Tick#replaceMovedLabel
  14896. * @return {void}
  14897. */
  14898. Tick.prototype.replaceMovedLabel = function () {
  14899. var tick = this,
  14900. label = tick.label,
  14901. axis = tick.axis,
  14902. reversed = axis.reversed,
  14903. x,
  14904. y;
  14905. // Animate and destroy
  14906. if (label && !tick.isNew) {
  14907. x = axis.horiz ? (reversed ? axis.left : axis.width + axis.left) : label.xy.x;
  14908. y = axis.horiz ?
  14909. label.xy.y :
  14910. (reversed ? axis.width + axis.top : axis.top);
  14911. label.animate({ x: x, y: y, opacity: 0 }, void 0, label.destroy);
  14912. delete tick.label;
  14913. }
  14914. axis.isDirty = true;
  14915. tick.label = tick.movedLabel;
  14916. delete tick.movedLabel;
  14917. };
  14918. return Tick;
  14919. }());
  14920. H.Tick = Tick;
  14921. return H.Tick;
  14922. });
  14923. _registerModule(_modules, 'Core/Axis/Axis.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Color/Color.js'], _modules['Core/Globals.js'], _modules['Core/Color/Palette.js'], _modules['Core/Options.js'], _modules['Core/Axis/Tick.js'], _modules['Core/Utilities.js']], function (A, Color, H, palette, O, Tick, U) {
  14924. /* *
  14925. *
  14926. * (c) 2010-2021 Torstein Honsi
  14927. *
  14928. * License: www.highcharts.com/license
  14929. *
  14930. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  14931. *
  14932. * */
  14933. var animObject = A.animObject;
  14934. var defaultOptions = O.defaultOptions;
  14935. var addEvent = U.addEvent,
  14936. arrayMax = U.arrayMax,
  14937. arrayMin = U.arrayMin,
  14938. clamp = U.clamp,
  14939. correctFloat = U.correctFloat,
  14940. defined = U.defined,
  14941. destroyObjectProperties = U.destroyObjectProperties,
  14942. erase = U.erase,
  14943. error = U.error,
  14944. extend = U.extend,
  14945. fireEvent = U.fireEvent,
  14946. getMagnitude = U.getMagnitude,
  14947. isArray = U.isArray,
  14948. isFunction = U.isFunction,
  14949. isNumber = U.isNumber,
  14950. isString = U.isString,
  14951. merge = U.merge,
  14952. normalizeTickInterval = U.normalizeTickInterval,
  14953. objectEach = U.objectEach,
  14954. pick = U.pick,
  14955. relativeLength = U.relativeLength,
  14956. removeEvent = U.removeEvent,
  14957. splat = U.splat,
  14958. syncTimeout = U.syncTimeout;
  14959. /**
  14960. * Options for the path on the Axis to be calculated.
  14961. * @interface Highcharts.AxisPlotLinePathOptionsObject
  14962. */ /**
  14963. * Axis value.
  14964. * @name Highcharts.AxisPlotLinePathOptionsObject#value
  14965. * @type {number|undefined}
  14966. */ /**
  14967. * Line width used for calculation crisp line coordinates. Defaults to 1.
  14968. * @name Highcharts.AxisPlotLinePathOptionsObject#lineWidth
  14969. * @type {number|undefined}
  14970. */ /**
  14971. * If `false`, the function will return null when it falls outside the axis
  14972. * bounds. If `true`, the function will return a path aligned to the plot area
  14973. * sides if it falls outside. If `pass`, it will return a path outside.
  14974. * @name Highcharts.AxisPlotLinePathOptionsObject#force
  14975. * @type {string|boolean|undefined}
  14976. */ /**
  14977. * Used in Highcharts Stock. When `true`, plot paths
  14978. * (crosshair, plotLines, gridLines)
  14979. * will be rendered on all axes when defined on the first axis.
  14980. * @name Highcharts.AxisPlotLinePathOptionsObject#acrossPanes
  14981. * @type {boolean|undefined}
  14982. */ /**
  14983. * Use old coordinates (for resizing and rescaling).
  14984. * If not set, defaults to `false`.
  14985. * @name Highcharts.AxisPlotLinePathOptionsObject#old
  14986. * @type {boolean|undefined}
  14987. */ /**
  14988. * If given, return the plot line path of a pixel position on the axis.
  14989. * @name Highcharts.AxisPlotLinePathOptionsObject#translatedValue
  14990. * @type {number|undefined}
  14991. */ /**
  14992. * Used in Polar axes. Reverse the positions for concatenation of polygonal
  14993. * plot bands
  14994. * @name Highcharts.AxisPlotLinePathOptionsObject#reverse
  14995. * @type {boolean|undefined}
  14996. */
  14997. /**
  14998. * Options for crosshairs on axes.
  14999. *
  15000. * @product highstock
  15001. *
  15002. * @typedef {Highcharts.XAxisCrosshairOptions|Highcharts.YAxisCrosshairOptions} Highcharts.AxisCrosshairOptions
  15003. */
  15004. /**
  15005. * @typedef {"navigator"|"pan"|"rangeSelectorButton"|"rangeSelectorInput"|"scrollbar"|"traverseUpButton"|"zoom"} Highcharts.AxisExtremesTriggerValue
  15006. */
  15007. /**
  15008. * @callback Highcharts.AxisEventCallbackFunction
  15009. *
  15010. * @param {Highcharts.Axis} this
  15011. */
  15012. /**
  15013. * @callback Highcharts.AxisLabelsFormatterCallbackFunction
  15014. *
  15015. * @param {Highcharts.AxisLabelsFormatterContextObject} this
  15016. *
  15017. * @param {Highcharts.AxisLabelsFormatterContextObject} ctx
  15018. *
  15019. * @return {string}
  15020. */
  15021. /**
  15022. * @interface Highcharts.AxisLabelsFormatterContextObject
  15023. */ /**
  15024. * The axis item of the label
  15025. * @name Highcharts.AxisLabelsFormatterContextObject#axis
  15026. * @type {Highcharts.Axis}
  15027. */ /**
  15028. * The chart instance.
  15029. * @name Highcharts.AxisLabelsFormatterContextObject#chart
  15030. * @type {Highcharts.Chart}
  15031. */ /**
  15032. * Whether the label belongs to the first tick on the axis.
  15033. * @name Highcharts.AxisLabelsFormatterContextObject#isFirst
  15034. * @type {boolean}
  15035. */ /**
  15036. * Whether the label belongs to the last tick on the axis.
  15037. * @name Highcharts.AxisLabelsFormatterContextObject#isLast
  15038. * @type {boolean}
  15039. */ /**
  15040. * The position on the axis in terms of axis values. For category axes, a
  15041. * zero-based index. For datetime axes, the JavaScript time in milliseconds
  15042. * since 1970.
  15043. * @name Highcharts.AxisLabelsFormatterContextObject#pos
  15044. * @type {number}
  15045. */ /**
  15046. * The preformatted text as the result of the default formatting. For example
  15047. * dates will be formatted as strings, and numbers with language-specific comma
  15048. * separators, thousands separators and numeric symbols like `k` or `M`.
  15049. * @name Highcharts.AxisLabelsFormatterContextObject#text
  15050. * @type {string}
  15051. */ /**
  15052. * The Tick instance.
  15053. * @name Highcharts.AxisLabelsFormatterContextObject#tick
  15054. * @type {Highcharts.Tick}
  15055. */ /**
  15056. * This can be either a numeric value or a category string.
  15057. * @name Highcharts.AxisLabelsFormatterContextObject#value
  15058. * @type {number|string}
  15059. */
  15060. /**
  15061. * Options for axes.
  15062. *
  15063. * @typedef {Highcharts.XAxisOptions|Highcharts.YAxisOptions|Highcharts.ZAxisOptions} Highcharts.AxisOptions
  15064. */
  15065. /**
  15066. * @callback Highcharts.AxisPointBreakEventCallbackFunction
  15067. *
  15068. * @param {Highcharts.Axis} this
  15069. *
  15070. * @param {Highcharts.AxisPointBreakEventObject} evt
  15071. */
  15072. /**
  15073. * @interface Highcharts.AxisPointBreakEventObject
  15074. */ /**
  15075. * @name Highcharts.AxisPointBreakEventObject#brk
  15076. * @type {Highcharts.Dictionary<number>}
  15077. */ /**
  15078. * @name Highcharts.AxisPointBreakEventObject#point
  15079. * @type {Highcharts.Point}
  15080. */ /**
  15081. * @name Highcharts.AxisPointBreakEventObject#preventDefault
  15082. * @type {Function}
  15083. */ /**
  15084. * @name Highcharts.AxisPointBreakEventObject#target
  15085. * @type {Highcharts.SVGElement}
  15086. */ /**
  15087. * @name Highcharts.AxisPointBreakEventObject#type
  15088. * @type {"pointBreak"|"pointInBreak"}
  15089. */
  15090. /**
  15091. * @callback Highcharts.AxisSetExtremesEventCallbackFunction
  15092. *
  15093. * @param {Highcharts.Axis} this
  15094. *
  15095. * @param {Highcharts.AxisSetExtremesEventObject} evt
  15096. */
  15097. /**
  15098. * @interface Highcharts.AxisSetExtremesEventObject
  15099. * @extends Highcharts.ExtremesObject
  15100. */ /**
  15101. * @name Highcharts.AxisSetExtremesEventObject#preventDefault
  15102. * @type {Function}
  15103. */ /**
  15104. * @name Highcharts.AxisSetExtremesEventObject#target
  15105. * @type {Highcharts.SVGElement}
  15106. */ /**
  15107. * @name Highcharts.AxisSetExtremesEventObject#trigger
  15108. * @type {Highcharts.AxisExtremesTriggerValue|string}
  15109. */ /**
  15110. * @name Highcharts.AxisSetExtremesEventObject#type
  15111. * @type {"setExtremes"}
  15112. */
  15113. /**
  15114. * @callback Highcharts.AxisTickPositionerCallbackFunction
  15115. *
  15116. * @param {Highcharts.Axis} this
  15117. *
  15118. * @return {Highcharts.AxisTickPositionsArray}
  15119. */
  15120. /**
  15121. * @interface Highcharts.AxisTickPositionsArray
  15122. * @augments Array<number>
  15123. */
  15124. /**
  15125. * @typedef {"high"|"low"|"middle"} Highcharts.AxisTitleAlignValue
  15126. */
  15127. /**
  15128. * @typedef {Highcharts.XAxisTitleOptions|Highcharts.YAxisTitleOptions|Highcharts.ZAxisTitleOptions} Highcharts.AxisTitleOptions
  15129. */
  15130. /**
  15131. * @typedef {"linear"|"logarithmic"|"datetime"|"category"|"treegrid"} Highcharts.AxisTypeValue
  15132. */
  15133. /**
  15134. * The returned object literal from the {@link Highcharts.Axis#getExtremes}
  15135. * function.
  15136. *
  15137. * @interface Highcharts.ExtremesObject
  15138. */ /**
  15139. * The maximum value of the axis' associated series.
  15140. * @name Highcharts.ExtremesObject#dataMax
  15141. * @type {number}
  15142. */ /**
  15143. * The minimum value of the axis' associated series.
  15144. * @name Highcharts.ExtremesObject#dataMin
  15145. * @type {number}
  15146. */ /**
  15147. * The maximum axis value, either automatic or set manually. If the `max` option
  15148. * is not set, `maxPadding` is 0 and `endOnTick` is false, this value will be
  15149. * the same as `dataMax`.
  15150. * @name Highcharts.ExtremesObject#max
  15151. * @type {number}
  15152. */ /**
  15153. * The minimum axis value, either automatic or set manually. If the `min` option
  15154. * is not set, `minPadding` is 0 and `startOnTick` is false, this value will be
  15155. * the same as `dataMin`.
  15156. * @name Highcharts.ExtremesObject#min
  15157. * @type {number}
  15158. */ /**
  15159. * The user defined maximum, either from the `max` option or from a zoom or
  15160. * `setExtremes` action.
  15161. * @name Highcharts.ExtremesObject#userMax
  15162. * @type {number}
  15163. */ /**
  15164. * The user defined minimum, either from the `min` option or from a zoom or
  15165. * `setExtremes` action.
  15166. * @name Highcharts.ExtremesObject#userMin
  15167. * @type {number}
  15168. */
  15169. /**
  15170. * Formatter function for the text of a crosshair label.
  15171. *
  15172. * @callback Highcharts.XAxisCrosshairLabelFormatterCallbackFunction
  15173. *
  15174. * @param {Highcharts.Axis} this
  15175. * Axis context
  15176. *
  15177. * @param {number} value
  15178. * Y value of the data point
  15179. *
  15180. * @return {string}
  15181. */
  15182. ''; // detach doclets above
  15183. var deg2rad = H.deg2rad;
  15184. /**
  15185. * Create a new axis object. Called internally when instanciating a new chart or
  15186. * adding axes by {@link Highcharts.Chart#addAxis}.
  15187. *
  15188. * A chart can have from 0 axes (pie chart) to multiples. In a normal, single
  15189. * series cartesian chart, there is one X axis and one Y axis.
  15190. *
  15191. * The X axis or axes are referenced by {@link Highcharts.Chart.xAxis}, which is
  15192. * an array of Axis objects. If there is only one axis, it can be referenced
  15193. * through `chart.xAxis[0]`, and multiple axes have increasing indices. The same
  15194. * pattern goes for Y axes.
  15195. *
  15196. * If you need to get the axes from a series object, use the `series.xAxis` and
  15197. * `series.yAxis` properties. These are not arrays, as one series can only be
  15198. * associated to one X and one Y axis.
  15199. *
  15200. * A third way to reference the axis programmatically is by `id`. Add an `id` in
  15201. * the axis configuration options, and get the axis by
  15202. * {@link Highcharts.Chart#get}.
  15203. *
  15204. * Configuration options for the axes are given in options.xAxis and
  15205. * options.yAxis.
  15206. *
  15207. * @class
  15208. * @name Highcharts.Axis
  15209. *
  15210. * @param {Highcharts.Chart} chart
  15211. * The Chart instance to apply the axis on.
  15212. *
  15213. * @param {Highcharts.AxisOptions} userOptions
  15214. * Axis options.
  15215. */
  15216. var Axis = /** @class */ (function () {
  15217. /* *
  15218. *
  15219. * Constructors
  15220. *
  15221. * */
  15222. function Axis(chart, userOptions) {
  15223. this.alternateBands = void 0;
  15224. this.bottom = void 0;
  15225. this.categories = void 0;
  15226. this.chart = void 0;
  15227. this.closestPointRange = void 0;
  15228. this.coll = void 0;
  15229. this.hasNames = void 0;
  15230. this.hasVisibleSeries = void 0;
  15231. this.height = void 0;
  15232. this.isLinked = void 0;
  15233. this.labelEdge = void 0; // @todo
  15234. this.labelFormatter = void 0;
  15235. this.left = void 0;
  15236. this.len = void 0;
  15237. this.max = void 0;
  15238. this.maxLabelLength = void 0;
  15239. this.min = void 0;
  15240. this.minorTickInterval = void 0;
  15241. this.minorTicks = void 0;
  15242. this.minPixelPadding = void 0;
  15243. this.names = void 0;
  15244. this.offset = void 0;
  15245. this.options = void 0;
  15246. this.overlap = void 0;
  15247. this.paddedTicks = void 0;
  15248. this.plotLinesAndBands = void 0;
  15249. this.plotLinesAndBandsGroups = void 0;
  15250. this.pointRange = void 0;
  15251. this.pointRangePadding = void 0;
  15252. this.pos = void 0;
  15253. this.positiveValuesOnly = void 0;
  15254. this.right = void 0;
  15255. this.series = void 0;
  15256. this.side = void 0;
  15257. this.tickAmount = void 0;
  15258. this.tickInterval = void 0;
  15259. this.tickmarkOffset = void 0;
  15260. this.tickPositions = void 0;
  15261. this.tickRotCorr = void 0;
  15262. this.ticks = void 0;
  15263. this.top = void 0;
  15264. this.transA = void 0;
  15265. this.transB = void 0;
  15266. this.translationSlope = void 0;
  15267. this.userOptions = void 0;
  15268. this.visible = void 0;
  15269. this.width = void 0;
  15270. this.zoomEnabled = void 0;
  15271. this.init(chart, userOptions);
  15272. }
  15273. /* *
  15274. *
  15275. * Functions
  15276. *
  15277. * */
  15278. /**
  15279. * Overrideable function to initialize the axis.
  15280. *
  15281. * @see {@link Axis}
  15282. *
  15283. * @function Highcharts.Axis#init
  15284. *
  15285. * @param {Highcharts.Chart} chart
  15286. * The Chart instance to apply the axis on.
  15287. *
  15288. * @param {Highcharts.AxisOptions} userOptions
  15289. * Axis options.
  15290. *
  15291. * @fires Highcharts.Axis#event:afterInit
  15292. * @fires Highcharts.Axis#event:init
  15293. */
  15294. Axis.prototype.init = function (chart, userOptions) {
  15295. var isXAxis = userOptions.isX,
  15296. axis = this;
  15297. /**
  15298. * The Chart that the axis belongs to.
  15299. *
  15300. * @name Highcharts.Axis#chart
  15301. * @type {Highcharts.Chart}
  15302. */
  15303. axis.chart = chart;
  15304. /**
  15305. * Whether the axis is horizontal.
  15306. *
  15307. * @name Highcharts.Axis#horiz
  15308. * @type {boolean|undefined}
  15309. */
  15310. axis.horiz = chart.inverted && !axis.isZAxis ? !isXAxis : isXAxis;
  15311. /**
  15312. * Whether the axis is the x-axis.
  15313. *
  15314. * @name Highcharts.Axis#isXAxis
  15315. * @type {boolean|undefined}
  15316. */
  15317. axis.isXAxis = isXAxis;
  15318. /**
  15319. * The collection where the axis belongs, for example `xAxis`, `yAxis`
  15320. * or `colorAxis`. Corresponds to properties on Chart, for example
  15321. * {@link Chart.xAxis}.
  15322. *
  15323. * @name Highcharts.Axis#coll
  15324. * @type {string}
  15325. */
  15326. axis.coll = axis.coll || (isXAxis ? 'xAxis' : 'yAxis');
  15327. fireEvent(this, 'init', { userOptions: userOptions });
  15328. axis.opposite = pick(userOptions.opposite, axis.opposite); // needed in setOptions
  15329. /**
  15330. * The side on which the axis is rendered. 0 is top, 1 is right, 2
  15331. * is bottom and 3 is left.
  15332. *
  15333. * @name Highcharts.Axis#side
  15334. * @type {number}
  15335. */
  15336. axis.side = pick(userOptions.side, axis.side, (axis.horiz ?
  15337. (axis.opposite ? 0 : 2) : // top : bottom
  15338. (axis.opposite ? 1 : 3)) // right : left
  15339. );
  15340. /**
  15341. * Current options for the axis after merge of defaults and user's
  15342. * options.
  15343. *
  15344. * @name Highcharts.Axis#options
  15345. * @type {Highcharts.AxisOptions}
  15346. */
  15347. axis.setOptions(userOptions);
  15348. var options = this.options,
  15349. labelsOptions = options.labels,
  15350. type = options.type;
  15351. /**
  15352. * User's options for this axis without defaults.
  15353. *
  15354. * @name Highcharts.Axis#userOptions
  15355. * @type {Highcharts.AxisOptions}
  15356. */
  15357. axis.userOptions = userOptions;
  15358. axis.minPixelPadding = 0;
  15359. /**
  15360. * Whether the axis is reversed. Based on the `axis.reversed`,
  15361. * option, but inverted charts have reversed xAxis by default.
  15362. *
  15363. * @name Highcharts.Axis#reversed
  15364. * @type {boolean}
  15365. */
  15366. axis.reversed = pick(options.reversed, axis.reversed);
  15367. axis.visible = options.visible;
  15368. axis.zoomEnabled = options.zoomEnabled;
  15369. // Initial categories
  15370. axis.hasNames =
  15371. type === 'category' || options.categories === true;
  15372. /**
  15373. * If categories are present for the axis, names are used instead of
  15374. * numbers for that axis.
  15375. *
  15376. * Since Highcharts 3.0, categories can also be extracted by giving each
  15377. * point a name and setting axis type to `category`. However, if you
  15378. * have multiple series, best practice remains defining the `categories`
  15379. * array.
  15380. *
  15381. * @see [xAxis.categories](/highcharts/xAxis.categories)
  15382. *
  15383. * @name Highcharts.Axis#categories
  15384. * @type {Array<string>}
  15385. * @readonly
  15386. */
  15387. axis.categories = options.categories || axis.hasNames;
  15388. if (!axis.names) { // Preserve on update (#3830)
  15389. axis.names = [];
  15390. axis.names.keys = {};
  15391. }
  15392. // Placeholder for plotlines and plotbands groups
  15393. axis.plotLinesAndBandsGroups = {};
  15394. // Shorthand types
  15395. axis.positiveValuesOnly = !!axis.logarithmic;
  15396. // Flag, if axis is linked to another axis
  15397. axis.isLinked = defined(options.linkedTo);
  15398. /**
  15399. * List of major ticks mapped by postition on axis.
  15400. *
  15401. * @see {@link Highcharts.Tick}
  15402. *
  15403. * @name Highcharts.Axis#ticks
  15404. * @type {Highcharts.Dictionary<Highcharts.Tick>}
  15405. */
  15406. axis.ticks = {};
  15407. axis.labelEdge = [];
  15408. /**
  15409. * List of minor ticks mapped by position on the axis.
  15410. *
  15411. * @see {@link Highcharts.Tick}
  15412. *
  15413. * @name Highcharts.Axis#minorTicks
  15414. * @type {Highcharts.Dictionary<Highcharts.Tick>}
  15415. */
  15416. axis.minorTicks = {};
  15417. // List of plotLines/Bands
  15418. axis.plotLinesAndBands = [];
  15419. // Alternate bands
  15420. axis.alternateBands = {};
  15421. // Axis metrics
  15422. axis.len = 0;
  15423. axis.minRange = axis.userMinRange = options.minRange || options.maxZoom;
  15424. axis.range = options.range;
  15425. axis.offset = options.offset || 0;
  15426. /**
  15427. * The maximum value of the axis. In a logarithmic axis, this is the
  15428. * logarithm of the real value, and the real value can be obtained from
  15429. * {@link Axis#getExtremes}.
  15430. *
  15431. * @name Highcharts.Axis#max
  15432. * @type {number|null}
  15433. */
  15434. axis.max = null;
  15435. /**
  15436. * The minimum value of the axis. In a logarithmic axis, this is the
  15437. * logarithm of the real value, and the real value can be obtained from
  15438. * {@link Axis#getExtremes}.
  15439. *
  15440. * @name Highcharts.Axis#min
  15441. * @type {number|null}
  15442. */
  15443. axis.min = null;
  15444. /**
  15445. * The processed crosshair options.
  15446. *
  15447. * @name Highcharts.Axis#crosshair
  15448. * @type {boolean|Highcharts.AxisCrosshairOptions}
  15449. */
  15450. var crosshair = pick(options.crosshair,
  15451. splat(chart.options.tooltip.crosshairs)[isXAxis ? 0 : 1]);
  15452. axis.crosshair = crosshair === true ? {} : crosshair;
  15453. var events = axis.options.events;
  15454. // Register. Don't add it again on Axis.update().
  15455. if (chart.axes.indexOf(axis) === -1) { //
  15456. if (isXAxis) { // #2713
  15457. chart.axes.splice(chart.xAxis.length, 0, axis);
  15458. }
  15459. else {
  15460. chart.axes.push(axis);
  15461. }
  15462. chart[axis.coll].push(axis);
  15463. }
  15464. /**
  15465. * All series associated to the axis.
  15466. *
  15467. * @name Highcharts.Axis#series
  15468. * @type {Array<Highcharts.Series>}
  15469. */
  15470. axis.series = axis.series || []; // populated by Series
  15471. // Reversed axis
  15472. if (chart.inverted &&
  15473. !axis.isZAxis &&
  15474. isXAxis &&
  15475. typeof axis.reversed === 'undefined') {
  15476. axis.reversed = true;
  15477. }
  15478. axis.labelRotation = isNumber(labelsOptions.rotation) ?
  15479. labelsOptions.rotation :
  15480. void 0;
  15481. // register event listeners
  15482. objectEach(events, function (event, eventType) {
  15483. if (isFunction(event)) {
  15484. addEvent(axis, eventType, event);
  15485. }
  15486. });
  15487. fireEvent(this, 'afterInit');
  15488. };
  15489. /**
  15490. * Merge and set options.
  15491. *
  15492. * @private
  15493. * @function Highcharts.Axis#setOptions
  15494. *
  15495. * @param {Highcharts.AxisOptions} userOptions
  15496. * Axis options.
  15497. *
  15498. * @fires Highcharts.Axis#event:afterSetOptions
  15499. */
  15500. Axis.prototype.setOptions = function (userOptions) {
  15501. this.options = merge(Axis.defaultOptions, (this.coll === 'yAxis') && Axis.defaultYAxisOptions, [
  15502. Axis.defaultTopAxisOptions,
  15503. Axis.defaultRightAxisOptions,
  15504. Axis.defaultBottomAxisOptions,
  15505. Axis.defaultLeftAxisOptions
  15506. ][this.side], merge(
  15507. // if set in setOptions (#1053):
  15508. defaultOptions[this.coll], userOptions));
  15509. fireEvent(this, 'afterSetOptions', { userOptions: userOptions });
  15510. };
  15511. /**
  15512. * The default label formatter. The context is a special config object for
  15513. * the label. In apps, use the
  15514. * [labels.formatter](https://api.highcharts.com/highcharts/xAxis.labels.formatter)
  15515. * instead, except when a modification is needed.
  15516. *
  15517. * @function Highcharts.Axis#defaultLabelFormatter
  15518. *
  15519. * @param {Highcharts.AxisLabelsFormatterContextObject} this
  15520. * Formatter context of axis label.
  15521. *
  15522. * @return {string}
  15523. * The formatted label content.
  15524. */
  15525. Axis.prototype.defaultLabelFormatter = function () {
  15526. var axis = this.axis,
  15527. value = isNumber(this.value) ? this.value : NaN,
  15528. time = axis.chart.time,
  15529. categories = axis.categories,
  15530. dateTimeLabelFormat = this.dateTimeLabelFormat,
  15531. lang = defaultOptions.lang,
  15532. numericSymbols = lang.numericSymbols,
  15533. numSymMagnitude = lang.numericSymbolMagnitude || 1000,
  15534. i = numericSymbols && numericSymbols.length,
  15535. multi,
  15536. ret,
  15537. // make sure the same symbol is added for all labels on a linear
  15538. // axis
  15539. numericSymbolDetector = axis.logarithmic ?
  15540. Math.abs(value) :
  15541. axis.tickInterval;
  15542. var chart = this.chart;
  15543. var numberFormatter = chart.numberFormatter;
  15544. if (categories) {
  15545. ret = "" + this.value;
  15546. }
  15547. else if (dateTimeLabelFormat) { // datetime axis
  15548. ret = time.dateFormat(dateTimeLabelFormat, value);
  15549. }
  15550. else if (i && numericSymbolDetector >= 1000) {
  15551. // Decide whether we should add a numeric symbol like k (thousands)
  15552. // or M (millions). If we are to enable this in tooltip or other
  15553. // places as well, we can move this logic to the numberFormatter and
  15554. // enable it by a parameter.
  15555. while (i-- && typeof ret === 'undefined') {
  15556. multi = Math.pow(numSymMagnitude, i + 1);
  15557. if (
  15558. // Only accept a numeric symbol when the distance is more
  15559. // than a full unit. So for example if the symbol is k, we
  15560. // don't accept numbers like 0.5k.
  15561. numericSymbolDetector >= multi &&
  15562. // Accept one decimal before the symbol. Accepts 0.5k but
  15563. // not 0.25k. How does this work with the previous?
  15564. (value * 10) % multi === 0 &&
  15565. numericSymbols[i] !== null &&
  15566. value !== 0) { // #5480
  15567. ret = numberFormatter(value / multi, -1) + numericSymbols[i];
  15568. }
  15569. }
  15570. }
  15571. if (typeof ret === 'undefined') {
  15572. if (Math.abs(value) >= 10000) { // add thousands separators
  15573. ret = numberFormatter(value, -1);
  15574. }
  15575. else { // small numbers
  15576. ret = numberFormatter(value, -1, void 0, ''); // #2466
  15577. }
  15578. }
  15579. return ret;
  15580. };
  15581. /**
  15582. * Get the minimum and maximum for the series of each axis. The function
  15583. * analyzes the axis series and updates `this.dataMin` and `this.dataMax`.
  15584. *
  15585. * @private
  15586. * @function Highcharts.Axis#getSeriesExtremes
  15587. *
  15588. * @fires Highcharts.Axis#event:afterGetSeriesExtremes
  15589. * @fires Highcharts.Axis#event:getSeriesExtremes
  15590. */
  15591. Axis.prototype.getSeriesExtremes = function () {
  15592. var axis = this,
  15593. chart = axis.chart,
  15594. xExtremes;
  15595. fireEvent(this, 'getSeriesExtremes', null, function () {
  15596. axis.hasVisibleSeries = false;
  15597. // Reset properties in case we're redrawing (#3353)
  15598. axis.dataMin = axis.dataMax = axis.threshold = null;
  15599. axis.softThreshold = !axis.isXAxis;
  15600. if (axis.stacking) {
  15601. axis.stacking.buildStacks();
  15602. }
  15603. // loop through this axis' series
  15604. axis.series.forEach(function (series) {
  15605. if (series.visible ||
  15606. !chart.options.chart.ignoreHiddenSeries) {
  15607. var seriesOptions = series.options,
  15608. xData = void 0,
  15609. threshold = seriesOptions.threshold,
  15610. seriesDataMin = void 0,
  15611. seriesDataMax = void 0;
  15612. axis.hasVisibleSeries = true;
  15613. // Validate threshold in logarithmic axes
  15614. if (axis.positiveValuesOnly && threshold <= 0) {
  15615. threshold = null;
  15616. }
  15617. // Get dataMin and dataMax for X axes
  15618. if (axis.isXAxis) {
  15619. xData = series.xData;
  15620. if (xData.length) {
  15621. var isPositive = function (number) { return number > 0; };
  15622. xData = axis.logarithmic ?
  15623. xData.filter(axis.validatePositiveValue) :
  15624. xData;
  15625. xExtremes = series.getXExtremes(xData);
  15626. // If xData contains values which is not numbers,
  15627. // then filter them out. To prevent performance hit,
  15628. // we only do this after we have already found
  15629. // seriesDataMin because in most cases all data is
  15630. // valid. #5234.
  15631. seriesDataMin = xExtremes.min;
  15632. seriesDataMax = xExtremes.max;
  15633. if (!isNumber(seriesDataMin) &&
  15634. // #5010:
  15635. !(seriesDataMin instanceof Date)) {
  15636. xData = xData.filter(isNumber);
  15637. xExtremes = series.getXExtremes(xData);
  15638. // Do it again with valid data
  15639. seriesDataMin = xExtremes.min;
  15640. seriesDataMax = xExtremes.max;
  15641. }
  15642. if (xData.length) {
  15643. axis.dataMin = Math.min(pick(axis.dataMin, seriesDataMin), seriesDataMin);
  15644. axis.dataMax = Math.max(pick(axis.dataMax, seriesDataMax), seriesDataMax);
  15645. }
  15646. }
  15647. // Get dataMin and dataMax for Y axes, as well as handle
  15648. // stacking and processed data
  15649. }
  15650. else {
  15651. // Get this particular series extremes
  15652. var dataExtremes = series.applyExtremes();
  15653. // Get the dataMin and dataMax so far. If percentage is
  15654. // used, the min and max are always 0 and 100. If
  15655. // seriesDataMin and seriesDataMax is null, then series
  15656. // doesn't have active y data, we continue with nulls
  15657. if (isNumber(dataExtremes.dataMin)) {
  15658. seriesDataMin = dataExtremes.dataMin;
  15659. axis.dataMin = Math.min(pick(axis.dataMin, seriesDataMin), seriesDataMin);
  15660. }
  15661. if (isNumber(dataExtremes.dataMax)) {
  15662. seriesDataMax = dataExtremes.dataMax;
  15663. axis.dataMax = Math.max(pick(axis.dataMax, seriesDataMax), seriesDataMax);
  15664. }
  15665. // Adjust to threshold
  15666. if (defined(threshold)) {
  15667. axis.threshold = threshold;
  15668. }
  15669. // If any series has a hard threshold, it takes
  15670. // precedence
  15671. if (!seriesOptions.softThreshold ||
  15672. axis.positiveValuesOnly) {
  15673. axis.softThreshold = false;
  15674. }
  15675. }
  15676. }
  15677. });
  15678. });
  15679. fireEvent(this, 'afterGetSeriesExtremes');
  15680. };
  15681. /**
  15682. * Translate from axis value to pixel position on the chart, or back. Use
  15683. * the `toPixels` and `toValue` functions in applications.
  15684. *
  15685. * @private
  15686. * @function Highcharts.Axis#translate
  15687. *
  15688. * @param {number} val
  15689. * TO-DO: parameter description
  15690. *
  15691. * @param {boolean|null} [backwards]
  15692. * TO-DO: parameter description
  15693. *
  15694. * @param {boolean|null} [cvsCoord]
  15695. * TO-DO: parameter description
  15696. *
  15697. * @param {boolean|null} [old]
  15698. * TO-DO: parameter description
  15699. *
  15700. * @param {boolean} [handleLog]
  15701. * TO-DO: parameter description
  15702. *
  15703. * @param {number} [pointPlacement]
  15704. * TO-DO: parameter description
  15705. *
  15706. * @return {number|undefined}
  15707. */
  15708. Axis.prototype.translate = function (val, backwards, cvsCoord, old, handleLog, pointPlacement) {
  15709. var axis = this.linkedParent || this, // #1417
  15710. sign = 1,
  15711. cvsOffset = 0,
  15712. localA = old && axis.old ? axis.old.transA : axis.transA,
  15713. localMin = old && axis.old ? axis.old.min : axis.min,
  15714. returnValue = 0,
  15715. minPixelPadding = axis.minPixelPadding,
  15716. doPostTranslate = (axis.isOrdinal ||
  15717. axis.brokenAxis && axis.brokenAxis.hasBreaks ||
  15718. (axis.logarithmic && handleLog)) && axis.lin2val;
  15719. if (!localA) {
  15720. localA = axis.transA;
  15721. }
  15722. // In vertical axes, the canvas coordinates start from 0 at the top like
  15723. // in SVG.
  15724. if (cvsCoord) {
  15725. sign *= -1; // canvas coordinates inverts the value
  15726. cvsOffset = axis.len;
  15727. }
  15728. // Handle reversed axis
  15729. if (axis.reversed) {
  15730. sign *= -1;
  15731. cvsOffset -= sign * (axis.sector || axis.len);
  15732. }
  15733. // From pixels to value
  15734. if (backwards) { // reverse translation
  15735. val = val * sign + cvsOffset;
  15736. val -= minPixelPadding;
  15737. // from chart pixel to value:
  15738. returnValue = val / localA + localMin;
  15739. if (doPostTranslate) { // log and ordinal axes
  15740. returnValue = axis.lin2val(returnValue);
  15741. }
  15742. // From value to pixels
  15743. }
  15744. else {
  15745. if (doPostTranslate) { // log and ordinal axes
  15746. val = axis.val2lin(val);
  15747. }
  15748. returnValue = isNumber(localMin) ?
  15749. (sign * (val - localMin) * localA +
  15750. cvsOffset +
  15751. (sign * minPixelPadding) +
  15752. (isNumber(pointPlacement) ?
  15753. localA * pointPlacement :
  15754. 0)) :
  15755. void 0;
  15756. }
  15757. return returnValue;
  15758. };
  15759. /**
  15760. * Translate a value in terms of axis units into pixels within the chart.
  15761. *
  15762. * @function Highcharts.Axis#toPixels
  15763. *
  15764. * @param {number} value
  15765. * A value in terms of axis units.
  15766. *
  15767. * @param {boolean} paneCoordinates
  15768. * Whether to return the pixel coordinate relative to the chart or just the
  15769. * axis/pane itself.
  15770. *
  15771. * @return {number}
  15772. * Pixel position of the value on the chart or axis.
  15773. */
  15774. Axis.prototype.toPixels = function (value, paneCoordinates) {
  15775. return this.translate(value, false, !this.horiz, null, true) +
  15776. (paneCoordinates ? 0 : this.pos);
  15777. };
  15778. /**
  15779. * Translate a pixel position along the axis to a value in terms of axis
  15780. * units.
  15781. *
  15782. * @function Highcharts.Axis#toValue
  15783. *
  15784. * @param {number} pixel
  15785. * The pixel value coordinate.
  15786. *
  15787. * @param {boolean} [paneCoordinates=false]
  15788. * Whether the input pixel is relative to the chart or just the axis/pane
  15789. * itself.
  15790. *
  15791. * @return {number}
  15792. * The axis value.
  15793. */
  15794. Axis.prototype.toValue = function (pixel, paneCoordinates) {
  15795. return this.translate(pixel - (paneCoordinates ? 0 : this.pos), true, !this.horiz, null, true);
  15796. };
  15797. /**
  15798. * Create the path for a plot line that goes from the given value on
  15799. * this axis, across the plot to the opposite side. Also used internally for
  15800. * grid lines and crosshairs.
  15801. *
  15802. * @function Highcharts.Axis#getPlotLinePath
  15803. *
  15804. * @param {Highcharts.AxisPlotLinePathOptionsObject} options
  15805. * Options for the path.
  15806. *
  15807. * @return {Highcharts.SVGPathArray|null}
  15808. * The SVG path definition for the plot line.
  15809. */
  15810. Axis.prototype.getPlotLinePath = function (options) {
  15811. var axis = this,
  15812. chart = axis.chart,
  15813. axisLeft = axis.left,
  15814. axisTop = axis.top,
  15815. old = options.old,
  15816. value = options.value,
  15817. translatedValue = options.translatedValue,
  15818. lineWidth = options.lineWidth,
  15819. force = options.force,
  15820. x1,
  15821. y1,
  15822. x2,
  15823. y2,
  15824. cHeight = (old && chart.oldChartHeight) || chart.chartHeight,
  15825. cWidth = (old && chart.oldChartWidth) || chart.chartWidth,
  15826. skip,
  15827. transB = axis.transB,
  15828. evt;
  15829. // eslint-disable-next-line valid-jsdoc
  15830. /**
  15831. * Check if x is between a and b. If not, either move to a/b
  15832. * or skip, depending on the force parameter.
  15833. * @private
  15834. */
  15835. function between(x, a, b) {
  15836. if (force !== 'pass' && x < a || x > b) {
  15837. if (force) {
  15838. x = clamp(x, a, b);
  15839. }
  15840. else {
  15841. skip = true;
  15842. }
  15843. }
  15844. return x;
  15845. }
  15846. evt = {
  15847. value: value,
  15848. lineWidth: lineWidth,
  15849. old: old,
  15850. force: force,
  15851. acrossPanes: options.acrossPanes,
  15852. translatedValue: translatedValue
  15853. };
  15854. fireEvent(this, 'getPlotLinePath', evt, function (e) {
  15855. translatedValue = pick(translatedValue, axis.translate(value, null, null, old));
  15856. // Keep the translated value within sane bounds, and avoid Infinity
  15857. // to fail the isNumber test (#7709).
  15858. translatedValue = clamp(translatedValue, -1e5, 1e5);
  15859. x1 = x2 = Math.round(translatedValue + transB);
  15860. y1 = y2 = Math.round(cHeight - translatedValue - transB);
  15861. if (!isNumber(translatedValue)) { // no min or max
  15862. skip = true;
  15863. force = false; // #7175, don't force it when path is invalid
  15864. }
  15865. else if (axis.horiz) {
  15866. y1 = axisTop;
  15867. y2 = cHeight - axis.bottom;
  15868. x1 = x2 = between(x1, axisLeft, axisLeft + axis.width);
  15869. }
  15870. else {
  15871. x1 = axisLeft;
  15872. x2 = cWidth - axis.right;
  15873. y1 = y2 = between(y1, axisTop, axisTop + axis.height);
  15874. }
  15875. e.path = skip && !force ?
  15876. null :
  15877. chart.renderer.crispLine([['M', x1, y1], ['L', x2, y2]], lineWidth || 1);
  15878. });
  15879. return evt.path;
  15880. };
  15881. /**
  15882. * Internal function to get the tick positions of a linear axis to round
  15883. * values like whole tens or every five.
  15884. *
  15885. * @function Highcharts.Axis#getLinearTickPositions
  15886. *
  15887. * @param {number} tickInterval
  15888. * The normalized tick interval.
  15889. *
  15890. * @param {number} min
  15891. * Axis minimum.
  15892. *
  15893. * @param {number} max
  15894. * Axis maximum.
  15895. *
  15896. * @return {Array<number>}
  15897. * An array of axis values where ticks should be placed.
  15898. */
  15899. Axis.prototype.getLinearTickPositions = function (tickInterval, min, max) {
  15900. var pos,
  15901. lastPos,
  15902. roundedMin = correctFloat(Math.floor(min / tickInterval) * tickInterval),
  15903. roundedMax = correctFloat(Math.ceil(max / tickInterval) * tickInterval),
  15904. tickPositions = [],
  15905. precision;
  15906. // When the precision is higher than what we filter out in
  15907. // correctFloat, skip it (#6183).
  15908. if (correctFloat(roundedMin + tickInterval) === roundedMin) {
  15909. precision = 20;
  15910. }
  15911. // For single points, add a tick regardless of the relative position
  15912. // (#2662, #6274)
  15913. if (this.single) {
  15914. return [min];
  15915. }
  15916. // Populate the intermediate values
  15917. pos = roundedMin;
  15918. while (pos <= roundedMax) {
  15919. // Place the tick on the rounded value
  15920. tickPositions.push(pos);
  15921. // Always add the raw tickInterval, not the corrected one.
  15922. pos = correctFloat(pos + tickInterval, precision);
  15923. // If the interval is not big enough in the current min - max range
  15924. // to actually increase the loop variable, we need to break out to
  15925. // prevent endless loop. Issue #619
  15926. if (pos === lastPos) {
  15927. break;
  15928. }
  15929. // Record the last value
  15930. lastPos = pos;
  15931. }
  15932. return tickPositions;
  15933. };
  15934. /**
  15935. * Resolve the new minorTicks/minorTickInterval options into the legacy
  15936. * loosely typed minorTickInterval option.
  15937. *
  15938. * @function Highcharts.Axis#getMinorTickInterval
  15939. *
  15940. * @return {number|"auto"|null}
  15941. */
  15942. Axis.prototype.getMinorTickInterval = function () {
  15943. var options = this.options;
  15944. if (options.minorTicks === true) {
  15945. return pick(options.minorTickInterval, 'auto');
  15946. }
  15947. if (options.minorTicks === false) {
  15948. return null;
  15949. }
  15950. return options.minorTickInterval;
  15951. };
  15952. /**
  15953. * Internal function to return the minor tick positions. For logarithmic
  15954. * axes, the same logic as for major ticks is reused.
  15955. *
  15956. * @function Highcharts.Axis#getMinorTickPositions
  15957. *
  15958. * @return {Array<number>}
  15959. * An array of axis values where ticks should be placed.
  15960. */
  15961. Axis.prototype.getMinorTickPositions = function () {
  15962. var axis = this,
  15963. options = axis.options,
  15964. tickPositions = axis.tickPositions,
  15965. minorTickInterval = axis.minorTickInterval,
  15966. minorTickPositions = [],
  15967. pos,
  15968. pointRangePadding = axis.pointRangePadding || 0,
  15969. min = axis.min - pointRangePadding, // #1498
  15970. max = axis.max + pointRangePadding, // #1498
  15971. range = max - min;
  15972. // If minor ticks get too dense, they are hard to read, and may cause
  15973. // long running script. So we don't draw them.
  15974. if (range && range / minorTickInterval < axis.len / 3) { // #3875
  15975. var logarithmic_1 = axis.logarithmic;
  15976. if (logarithmic_1) {
  15977. // For each interval in the major ticks, compute the minor ticks
  15978. // separately.
  15979. this.paddedTicks.forEach(function (_pos, i, paddedTicks) {
  15980. if (i) {
  15981. minorTickPositions.push.apply(minorTickPositions, logarithmic_1.getLogTickPositions(minorTickInterval, paddedTicks[i - 1], paddedTicks[i], true));
  15982. }
  15983. });
  15984. }
  15985. else if (axis.dateTime &&
  15986. this.getMinorTickInterval() === 'auto') { // #1314
  15987. minorTickPositions = minorTickPositions.concat(axis.getTimeTicks(axis.dateTime.normalizeTimeTickInterval(minorTickInterval), min, max, options.startOfWeek));
  15988. }
  15989. else {
  15990. for (pos = min + (tickPositions[0] - min) % minorTickInterval; pos <= max; pos += minorTickInterval) {
  15991. // Very, very, tight grid lines (#5771)
  15992. if (pos === minorTickPositions[0]) {
  15993. break;
  15994. }
  15995. minorTickPositions.push(pos);
  15996. }
  15997. }
  15998. }
  15999. if (minorTickPositions.length !== 0) {
  16000. axis.trimTicks(minorTickPositions); // #3652 #3743 #1498 #6330
  16001. }
  16002. return minorTickPositions;
  16003. };
  16004. /**
  16005. * Adjust the min and max for the minimum range. Keep in mind that the
  16006. * series data is not yet processed, so we don't have information on data
  16007. * cropping and grouping, or updated `axis.pointRange` or
  16008. * `series.pointRange`. The data can't be processed until we have finally
  16009. * established min and max.
  16010. *
  16011. * @private
  16012. * @function Highcharts.Axis#adjustForMinRange
  16013. */
  16014. Axis.prototype.adjustForMinRange = function () {
  16015. var axis = this,
  16016. options = axis.options,
  16017. min = axis.min,
  16018. max = axis.max,
  16019. log = axis.logarithmic,
  16020. zoomOffset,
  16021. spaceAvailable,
  16022. closestDataRange = 0,
  16023. i,
  16024. distance,
  16025. xData,
  16026. loopLength,
  16027. minArgs,
  16028. maxArgs,
  16029. minRange;
  16030. // Set the automatic minimum range based on the closest point distance
  16031. if (axis.isXAxis &&
  16032. typeof axis.minRange === 'undefined' &&
  16033. !log) {
  16034. if (defined(options.min) || defined(options.max)) {
  16035. axis.minRange = null; // don't do this again
  16036. }
  16037. else {
  16038. // Find the closest distance between raw data points, as opposed
  16039. // to closestPointRange that applies to processed points
  16040. // (cropped and grouped)
  16041. axis.series.forEach(function (series) {
  16042. xData = series.xData;
  16043. loopLength = series.xIncrement ? 1 : xData.length - 1;
  16044. if (xData.length > 1) {
  16045. for (i = loopLength; i > 0; i--) {
  16046. distance = xData[i] - xData[i - 1];
  16047. if (!closestDataRange || distance < closestDataRange) {
  16048. closestDataRange = distance;
  16049. }
  16050. }
  16051. }
  16052. });
  16053. axis.minRange = Math.min(closestDataRange * 5, axis.dataMax - axis.dataMin);
  16054. }
  16055. }
  16056. // if minRange is exceeded, adjust
  16057. if (max - min < axis.minRange) {
  16058. spaceAvailable =
  16059. axis.dataMax - axis.dataMin >=
  16060. axis.minRange;
  16061. minRange = axis.minRange;
  16062. zoomOffset = (minRange - max + min) / 2;
  16063. // if min and max options have been set, don't go beyond it
  16064. minArgs = [
  16065. min - zoomOffset,
  16066. pick(options.min, min - zoomOffset)
  16067. ];
  16068. // If space is available, stay within the data range
  16069. if (spaceAvailable) {
  16070. minArgs[2] = axis.logarithmic ?
  16071. axis.logarithmic.log2lin(axis.dataMin) :
  16072. axis.dataMin;
  16073. }
  16074. min = arrayMax(minArgs);
  16075. maxArgs = [
  16076. min + minRange,
  16077. pick(options.max, min + minRange)
  16078. ];
  16079. // If space is availabe, stay within the data range
  16080. if (spaceAvailable) {
  16081. maxArgs[2] = log ?
  16082. log.log2lin(axis.dataMax) :
  16083. axis.dataMax;
  16084. }
  16085. max = arrayMin(maxArgs);
  16086. // now if the max is adjusted, adjust the min back
  16087. if (max - min < minRange) {
  16088. minArgs[0] = max - minRange;
  16089. minArgs[1] = pick(options.min, max - minRange);
  16090. min = arrayMax(minArgs);
  16091. }
  16092. }
  16093. // Record modified extremes
  16094. axis.min = min;
  16095. axis.max = max;
  16096. };
  16097. // eslint-disable-next-line valid-jsdoc
  16098. /**
  16099. * Find the closestPointRange across all series.
  16100. *
  16101. * @private
  16102. * @function Highcharts.Axis#getClosest
  16103. */
  16104. Axis.prototype.getClosest = function () {
  16105. var ret;
  16106. if (this.categories) {
  16107. ret = 1;
  16108. }
  16109. else {
  16110. this.series.forEach(function (series) {
  16111. var seriesClosest = series.closestPointRange,
  16112. visible = series.visible ||
  16113. !series.chart.options.chart.ignoreHiddenSeries;
  16114. if (!series.noSharedTooltip &&
  16115. defined(seriesClosest) &&
  16116. visible) {
  16117. ret = defined(ret) ?
  16118. Math.min(ret, seriesClosest) :
  16119. seriesClosest;
  16120. }
  16121. });
  16122. }
  16123. return ret;
  16124. };
  16125. /**
  16126. * When a point name is given and no x, search for the name in the existing
  16127. * categories, or if categories aren't provided, search names or create a
  16128. * new category (#2522).
  16129. * @private
  16130. * @function Highcharts.Axis#nameToX
  16131. *
  16132. * @param {Highcharts.Point} point
  16133. * The point to inspect.
  16134. *
  16135. * @return {number}
  16136. * The X value that the point is given.
  16137. */
  16138. Axis.prototype.nameToX = function (point) {
  16139. var explicitCategories = isArray(this.categories),
  16140. names = explicitCategories ? this.categories : this.names,
  16141. nameX = point.options.x,
  16142. x;
  16143. point.series.requireSorting = false;
  16144. if (!defined(nameX)) {
  16145. nameX = this.options.uniqueNames ?
  16146. (explicitCategories ?
  16147. names.indexOf(point.name) :
  16148. pick(names.keys[point.name], -1)) :
  16149. point.series.autoIncrement();
  16150. }
  16151. if (nameX === -1) { // Not found in currenct categories
  16152. if (!explicitCategories) {
  16153. x = names.length;
  16154. }
  16155. }
  16156. else {
  16157. x = nameX;
  16158. }
  16159. // Write the last point's name to the names array
  16160. if (typeof x !== 'undefined') {
  16161. this.names[x] = point.name;
  16162. // Backwards mapping is much faster than array searching (#7725)
  16163. this.names.keys[point.name] = x;
  16164. }
  16165. return x;
  16166. };
  16167. /**
  16168. * When changes have been done to series data, update the axis.names.
  16169. *
  16170. * @private
  16171. * @function Highcharts.Axis#updateNames
  16172. */
  16173. Axis.prototype.updateNames = function () {
  16174. var axis = this,
  16175. names = this.names,
  16176. i = names.length;
  16177. if (i > 0) {
  16178. Object.keys(names.keys).forEach(function (key) {
  16179. delete (names.keys)[key];
  16180. });
  16181. names.length = 0;
  16182. this.minRange = this.userMinRange; // Reset
  16183. (this.series || []).forEach(function (series) {
  16184. // Reset incrementer (#5928)
  16185. series.xIncrement = null;
  16186. // When adding a series, points are not yet generated
  16187. if (!series.points || series.isDirtyData) {
  16188. // When we're updating the series with data that is longer
  16189. // than it was, and cropThreshold is passed, we need to make
  16190. // sure that the axis.max is increased _before_ running the
  16191. // premature processData. Otherwise this early iteration of
  16192. // processData will crop the points to axis.max, and the
  16193. // names array will be too short (#5857).
  16194. axis.max = Math.max(axis.max, series.xData.length - 1);
  16195. series.processData();
  16196. series.generatePoints();
  16197. }
  16198. series.data.forEach(function (point, i) {
  16199. var x;
  16200. if (point &&
  16201. point.options &&
  16202. typeof point.name !== 'undefined' // #9562
  16203. ) {
  16204. x = axis.nameToX(point);
  16205. if (typeof x !== 'undefined' && x !== point.x) {
  16206. point.x = x;
  16207. series.xData[i] = x;
  16208. }
  16209. }
  16210. });
  16211. });
  16212. }
  16213. };
  16214. /**
  16215. * Update translation information.
  16216. *
  16217. * @private
  16218. * @function Highcharts.Axis#setAxisTranslation
  16219. *
  16220. * @fires Highcharts.Axis#event:afterSetAxisTranslation
  16221. */
  16222. Axis.prototype.setAxisTranslation = function () {
  16223. var axis = this,
  16224. range = axis.max - axis.min,
  16225. pointRange = axis.axisPointRange || 0,
  16226. closestPointRange,
  16227. minPointOffset = 0,
  16228. pointRangePadding = 0,
  16229. linkedParent = axis.linkedParent,
  16230. ordinalCorrection,
  16231. hasCategories = !!axis.categories,
  16232. transA = axis.transA,
  16233. isXAxis = axis.isXAxis;
  16234. // Adjust translation for padding. Y axis with categories need to go
  16235. // through the same (#1784).
  16236. if (isXAxis || hasCategories || pointRange) {
  16237. // Get the closest points
  16238. closestPointRange = axis.getClosest();
  16239. if (linkedParent) {
  16240. minPointOffset = linkedParent.minPointOffset;
  16241. pointRangePadding = linkedParent.pointRangePadding;
  16242. }
  16243. else {
  16244. axis.series.forEach(function (series) {
  16245. var seriesPointRange = hasCategories ?
  16246. 1 :
  16247. (isXAxis ?
  16248. pick(series.options.pointRange,
  16249. closestPointRange, 0) :
  16250. (axis.axisPointRange || 0)), // #2806
  16251. pointPlacement = series.options.pointPlacement;
  16252. pointRange = Math.max(pointRange, seriesPointRange);
  16253. if (!axis.single || hasCategories) {
  16254. // TODO: series should internally set x- and y-
  16255. // pointPlacement to simplify this logic.
  16256. var isPointPlacementAxis = series.is('xrange') ? !isXAxis : isXAxis;
  16257. // minPointOffset is the value padding to the left of
  16258. // the axis in order to make room for points with a
  16259. // pointRange, typically columns. When the
  16260. // pointPlacement option is 'between' or 'on', this
  16261. // padding does not apply.
  16262. minPointOffset = Math.max(minPointOffset, isPointPlacementAxis && isString(pointPlacement) ?
  16263. 0 :
  16264. seriesPointRange / 2);
  16265. // Determine the total padding needed to the length of
  16266. // the axis to make room for the pointRange. If the
  16267. // series' pointPlacement is 'on', no padding is added.
  16268. pointRangePadding = Math.max(pointRangePadding, isPointPlacementAxis && pointPlacement === 'on' ?
  16269. 0 :
  16270. seriesPointRange);
  16271. }
  16272. });
  16273. }
  16274. // Record minPointOffset and pointRangePadding
  16275. ordinalCorrection = axis.ordinal && axis.ordinal.slope && closestPointRange ?
  16276. axis.ordinal.slope / closestPointRange :
  16277. 1; // #988, #1853
  16278. axis.minPointOffset = minPointOffset =
  16279. minPointOffset * ordinalCorrection;
  16280. axis.pointRangePadding =
  16281. pointRangePadding = pointRangePadding * ordinalCorrection;
  16282. // pointRange means the width reserved for each point, like in a
  16283. // column chart
  16284. axis.pointRange = Math.min(pointRange, axis.single && hasCategories ? 1 : range);
  16285. // closestPointRange means the closest distance between points. In
  16286. // columns it is mostly equal to pointRange, but in lines pointRange
  16287. // is 0 while closestPointRange is some other value
  16288. if (isXAxis) {
  16289. axis.closestPointRange = closestPointRange;
  16290. }
  16291. }
  16292. // Secondary values
  16293. axis.translationSlope = axis.transA = transA =
  16294. axis.staticScale ||
  16295. axis.len / ((range + pointRangePadding) || 1);
  16296. // Translation addend
  16297. axis.transB = axis.horiz ? axis.left : axis.bottom;
  16298. axis.minPixelPadding = transA * minPointOffset;
  16299. fireEvent(this, 'afterSetAxisTranslation');
  16300. };
  16301. /**
  16302. * @private
  16303. * @function Highcharts.Axis#minFromRange
  16304. *
  16305. * @return {number}
  16306. */
  16307. Axis.prototype.minFromRange = function () {
  16308. var axis = this;
  16309. return axis.max - axis.range;
  16310. };
  16311. /**
  16312. * Set the tick positions to round values and optionally extend the extremes
  16313. * to the nearest tick.
  16314. *
  16315. * @private
  16316. * @function Highcharts.Axis#setTickInterval
  16317. *
  16318. * @param {boolean} secondPass
  16319. * TO-DO: parameter description
  16320. *
  16321. * @fires Highcharts.Axis#event:foundExtremes
  16322. */
  16323. Axis.prototype.setTickInterval = function (secondPass) {
  16324. var axis = this,
  16325. chart = axis.chart,
  16326. log = axis.logarithmic,
  16327. options = axis.options,
  16328. isXAxis = axis.isXAxis,
  16329. isLinked = axis.isLinked,
  16330. maxPadding = options.maxPadding,
  16331. minPadding = options.minPadding,
  16332. length,
  16333. linkedParentExtremes,
  16334. tickIntervalOption = options.tickInterval,
  16335. minTickInterval,
  16336. tickPixelIntervalOption = options.tickPixelInterval,
  16337. categories = axis.categories,
  16338. threshold = isNumber(axis.threshold) ? axis.threshold : null,
  16339. softThreshold = axis.softThreshold,
  16340. thresholdMin,
  16341. thresholdMax,
  16342. hardMin,
  16343. hardMax;
  16344. if (!axis.dateTime && !categories && !isLinked) {
  16345. this.getTickAmount();
  16346. }
  16347. // Min or max set either by zooming/setExtremes or initial options
  16348. hardMin = pick(axis.userMin, options.min);
  16349. hardMax = pick(axis.userMax, options.max);
  16350. // Linked axis gets the extremes from the parent axis
  16351. if (isLinked) {
  16352. axis.linkedParent = chart[axis.coll][options.linkedTo];
  16353. linkedParentExtremes = axis.linkedParent.getExtremes();
  16354. axis.min = pick(linkedParentExtremes.min, linkedParentExtremes.dataMin);
  16355. axis.max = pick(linkedParentExtremes.max, linkedParentExtremes.dataMax);
  16356. if (options.type !== axis.linkedParent.options.type) {
  16357. // Can't link axes of different type
  16358. error(11, 1, chart);
  16359. }
  16360. // Initial min and max from the extreme data values
  16361. }
  16362. else {
  16363. // Adjust to hard threshold
  16364. if (softThreshold && defined(threshold)) {
  16365. if (axis.dataMin >= threshold) {
  16366. thresholdMin = threshold;
  16367. minPadding = 0;
  16368. }
  16369. else if (axis.dataMax <= threshold) {
  16370. thresholdMax = threshold;
  16371. maxPadding = 0;
  16372. }
  16373. }
  16374. axis.min = pick(hardMin, thresholdMin, axis.dataMin);
  16375. axis.max = pick(hardMax, thresholdMax, axis.dataMax);
  16376. }
  16377. if (log) {
  16378. if (axis.positiveValuesOnly &&
  16379. !secondPass &&
  16380. Math.min(axis.min, pick(axis.dataMin, axis.min)) <= 0) { // #978
  16381. // Can't plot negative values on log axis
  16382. error(10, 1, chart);
  16383. }
  16384. // The correctFloat cures #934, float errors on full tens. But it
  16385. // was too aggressive for #4360 because of conversion back to lin,
  16386. // therefore use precision 15.
  16387. axis.min = correctFloat(log.log2lin(axis.min), 16);
  16388. axis.max = correctFloat(log.log2lin(axis.max), 16);
  16389. }
  16390. // handle zoomed range
  16391. if (axis.range && defined(axis.max)) {
  16392. // #618, #6773:
  16393. axis.userMin = axis.min = hardMin =
  16394. Math.max(axis.dataMin, axis.minFromRange());
  16395. axis.userMax = hardMax = axis.max;
  16396. axis.range = null; // don't use it when running setExtremes
  16397. }
  16398. // Hook for Highcharts Stock Scroller.
  16399. // Consider combining with beforePadding.
  16400. fireEvent(axis, 'foundExtremes');
  16401. // Hook for adjusting this.min and this.max. Used by bubble series.
  16402. if (axis.beforePadding) {
  16403. axis.beforePadding();
  16404. }
  16405. // adjust min and max for the minimum range
  16406. axis.adjustForMinRange();
  16407. // Pad the values to get clear of the chart's edges. To avoid
  16408. // tickInterval taking the padding into account, we do this after
  16409. // computing tick interval (#1337).
  16410. if (!categories &&
  16411. !axis.axisPointRange &&
  16412. !(axis.stacking && axis.stacking.usePercentage) &&
  16413. !isLinked &&
  16414. defined(axis.min) &&
  16415. defined(axis.max)) {
  16416. length = axis.max - axis.min;
  16417. if (length) {
  16418. if (!defined(hardMin) && minPadding) {
  16419. axis.min -= length * minPadding;
  16420. }
  16421. if (!defined(hardMax) && maxPadding) {
  16422. axis.max += length * maxPadding;
  16423. }
  16424. }
  16425. }
  16426. // Handle options for floor, ceiling, softMin and softMax (#6359)
  16427. if (!isNumber(axis.userMin)) {
  16428. if (isNumber(options.softMin) && options.softMin < axis.min) {
  16429. axis.min = hardMin = options.softMin; // #6894
  16430. }
  16431. if (isNumber(options.floor)) {
  16432. axis.min = Math.max(axis.min, options.floor);
  16433. }
  16434. }
  16435. if (!isNumber(axis.userMax)) {
  16436. if (isNumber(options.softMax) && options.softMax > axis.max) {
  16437. axis.max = hardMax = options.softMax; // #6894
  16438. }
  16439. if (isNumber(options.ceiling)) {
  16440. axis.max = Math.min(axis.max, options.ceiling);
  16441. }
  16442. }
  16443. // When the threshold is soft, adjust the extreme value only if the data
  16444. // extreme and the padded extreme land on either side of the threshold.
  16445. // For example, a series of [0, 1, 2, 3] would make the yAxis add a tick
  16446. // for -1 because of the default minPadding and startOnTick options.
  16447. // This is prevented by the softThreshold option.
  16448. if (softThreshold && defined(axis.dataMin)) {
  16449. threshold = threshold || 0;
  16450. if (!defined(hardMin) &&
  16451. axis.min < threshold &&
  16452. axis.dataMin >= threshold) {
  16453. axis.min = axis.options.minRange ?
  16454. Math.min(threshold, axis.max -
  16455. axis.minRange) :
  16456. threshold;
  16457. }
  16458. else if (!defined(hardMax) &&
  16459. axis.max > threshold &&
  16460. axis.dataMax <= threshold) {
  16461. axis.max = axis.options.minRange ?
  16462. Math.max(threshold, axis.min +
  16463. axis.minRange) :
  16464. threshold;
  16465. }
  16466. }
  16467. // If min is bigger than highest, or if max less than lowest value, the
  16468. // chart should not render points. (#14417)
  16469. if (isNumber(axis.min) &&
  16470. isNumber(axis.max) &&
  16471. !this.chart.polar &&
  16472. (axis.min > axis.max)) {
  16473. if (defined(axis.options.min)) {
  16474. axis.max = axis.min;
  16475. }
  16476. else if (defined(axis.options.max)) {
  16477. axis.min = axis.max;
  16478. }
  16479. }
  16480. // get tickInterval
  16481. if (axis.min === axis.max ||
  16482. typeof axis.min === 'undefined' ||
  16483. typeof axis.max === 'undefined') {
  16484. axis.tickInterval = 1;
  16485. }
  16486. else if (isLinked &&
  16487. axis.linkedParent &&
  16488. !tickIntervalOption &&
  16489. tickPixelIntervalOption ===
  16490. axis.linkedParent.options.tickPixelInterval) {
  16491. axis.tickInterval = tickIntervalOption =
  16492. axis.linkedParent.tickInterval;
  16493. }
  16494. else {
  16495. axis.tickInterval = pick(tickIntervalOption, this.tickAmount ?
  16496. ((axis.max - axis.min) /
  16497. Math.max(this.tickAmount - 1, 1)) :
  16498. void 0,
  16499. // For categoried axis, 1 is default, for linear axis use
  16500. // tickPix
  16501. categories ?
  16502. 1 :
  16503. // don't let it be more than the data range
  16504. (axis.max - axis.min) *
  16505. tickPixelIntervalOption /
  16506. Math.max(axis.len, tickPixelIntervalOption));
  16507. }
  16508. // Now we're finished detecting min and max, crop and group series data.
  16509. // This is in turn needed in order to find tick positions in ordinal
  16510. // axes.
  16511. if (isXAxis && !secondPass) {
  16512. axis.series.forEach(function (series) {
  16513. series.processData(axis.min !== (axis.old && axis.old.min) ||
  16514. axis.max !== (axis.old && axis.old.max));
  16515. });
  16516. }
  16517. // set the translation factor used in translate function
  16518. axis.setAxisTranslation();
  16519. // hook for ordinal axes and radial axes
  16520. fireEvent(this, 'initialAxisTranslation');
  16521. // In column-like charts, don't cramp in more ticks than there are
  16522. // points (#1943, #4184)
  16523. if (axis.pointRange && !tickIntervalOption) {
  16524. axis.tickInterval = Math.max(axis.pointRange, axis.tickInterval);
  16525. }
  16526. // Before normalizing the tick interval, handle minimum tick interval.
  16527. // This applies only if tickInterval is not defined.
  16528. minTickInterval = pick(options.minTickInterval,
  16529. // In datetime axes, don't go below the data interval, except when
  16530. // there are scatter-like series involved (#13369).
  16531. axis.dateTime &&
  16532. !axis.series.some(function (s) { return s.noSharedTooltip; }) ?
  16533. axis.closestPointRange : 0);
  16534. if (!tickIntervalOption && axis.tickInterval < minTickInterval) {
  16535. axis.tickInterval = minTickInterval;
  16536. }
  16537. // for linear axes, get magnitude and normalize the interval
  16538. if (!axis.dateTime && !axis.logarithmic && !tickIntervalOption) {
  16539. axis.tickInterval = normalizeTickInterval(axis.tickInterval, void 0, getMagnitude(axis.tickInterval), pick(options.allowDecimals,
  16540. // If the tick interval is greather than 0.5, avoid
  16541. // decimals, as linear axes are often used to render
  16542. // discrete values. #3363. If a tick amount is set, allow
  16543. // decimals by default, as it increases the chances for a
  16544. // good fit.
  16545. axis.tickInterval < 0.5 || this.tickAmount !== void 0), !!this.tickAmount);
  16546. }
  16547. // Prevent ticks from getting so close that we can't draw the labels
  16548. if (!this.tickAmount) {
  16549. axis.tickInterval = axis.unsquish();
  16550. }
  16551. this.setTickPositions();
  16552. };
  16553. /**
  16554. * Now we have computed the normalized tickInterval, get the tick positions.
  16555. *
  16556. * @private
  16557. * @function Highcharts.Axis#setTickPositions
  16558. *
  16559. * @fires Highcharts.Axis#event:afterSetTickPositions
  16560. */
  16561. Axis.prototype.setTickPositions = function () {
  16562. var axis = this,
  16563. options = this.options,
  16564. tickPositions,
  16565. tickPositionsOption = options.tickPositions,
  16566. minorTickIntervalOption = this.getMinorTickInterval(),
  16567. tickPositioner = options.tickPositioner,
  16568. hasVerticalPanning = this.hasVerticalPanning(),
  16569. isColorAxis = this.coll === 'colorAxis',
  16570. startOnTick = (isColorAxis || !hasVerticalPanning) && options.startOnTick,
  16571. endOnTick = (isColorAxis || !hasVerticalPanning) && options.endOnTick;
  16572. // Set the tickmarkOffset
  16573. this.tickmarkOffset = (this.categories &&
  16574. options.tickmarkPlacement === 'between' &&
  16575. this.tickInterval === 1) ? 0.5 : 0; // #3202
  16576. // get minorTickInterval
  16577. this.minorTickInterval =
  16578. minorTickIntervalOption === 'auto' &&
  16579. this.tickInterval ?
  16580. this.tickInterval / 5 :
  16581. minorTickIntervalOption;
  16582. // When there is only one point, or all points have the same value on
  16583. // this axis, then min and max are equal and tickPositions.length is 0
  16584. // or 1. In this case, add some padding in order to center the point,
  16585. // but leave it with one tick. #1337.
  16586. this.single =
  16587. this.min === this.max &&
  16588. defined(this.min) &&
  16589. !this.tickAmount &&
  16590. (
  16591. // Data is on integer (#6563)
  16592. parseInt(this.min, 10) === this.min ||
  16593. // Between integers and decimals are not allowed (#6274)
  16594. options.allowDecimals !== false);
  16595. /**
  16596. * Contains the current positions that are laid out on the axis. The
  16597. * positions are numbers in terms of axis values. In a category axis
  16598. * they are integers, in a datetime axis they are also integers, but
  16599. * designating milliseconds.
  16600. *
  16601. * This property is read only - for modifying the tick positions, use
  16602. * the `tickPositioner` callback or [axis.tickPositions(
  16603. * https://api.highcharts.com/highcharts/xAxis.tickPositions) option
  16604. * instead.
  16605. *
  16606. * @name Highcharts.Axis#tickPositions
  16607. * @type {Highcharts.AxisTickPositionsArray|undefined}
  16608. */
  16609. this.tickPositions =
  16610. // Find the tick positions. Work on a copy (#1565)
  16611. tickPositions =
  16612. (tickPositionsOption && tickPositionsOption.slice());
  16613. if (!tickPositions) {
  16614. // Too many ticks (#6405). Create a friendly warning and provide two
  16615. // ticks so at least we can show the data series.
  16616. if ((!axis.ordinal || !axis.ordinal.positions) &&
  16617. ((this.max - this.min) /
  16618. this.tickInterval >
  16619. Math.max(2 * this.len, 200))) {
  16620. tickPositions = [this.min, this.max];
  16621. error(19, false, this.chart);
  16622. }
  16623. else if (axis.dateTime) {
  16624. tickPositions = axis.getTimeTicks(axis.dateTime.normalizeTimeTickInterval(this.tickInterval, options.units), this.min, this.max, options.startOfWeek, axis.ordinal && axis.ordinal.positions, this.closestPointRange, true);
  16625. }
  16626. else if (axis.logarithmic) {
  16627. tickPositions = axis.logarithmic.getLogTickPositions(this.tickInterval, this.min, this.max);
  16628. }
  16629. else {
  16630. tickPositions = this.getLinearTickPositions(this.tickInterval, this.min, this.max);
  16631. }
  16632. // Too dense ticks, keep only the first and last (#4477)
  16633. if (tickPositions.length > this.len) {
  16634. tickPositions = [tickPositions[0], tickPositions.pop()];
  16635. // Reduce doubled value (#7339)
  16636. if (tickPositions[0] === tickPositions[1]) {
  16637. tickPositions.length = 1;
  16638. }
  16639. }
  16640. this.tickPositions = tickPositions;
  16641. // Run the tick positioner callback, that allows modifying auto tick
  16642. // positions.
  16643. if (tickPositioner) {
  16644. tickPositioner = tickPositioner.apply(axis, [this.min, this.max]);
  16645. if (tickPositioner) {
  16646. this.tickPositions = tickPositions = tickPositioner;
  16647. }
  16648. }
  16649. }
  16650. // Reset min/max or remove extremes based on start/end on tick
  16651. this.paddedTicks = tickPositions.slice(0); // Used for logarithmic minor
  16652. this.trimTicks(tickPositions, startOnTick, endOnTick);
  16653. if (!this.isLinked) {
  16654. // Substract half a unit (#2619, #2846, #2515, #3390),
  16655. // but not in case of multiple ticks (#6897)
  16656. if (this.single &&
  16657. tickPositions.length < 2 &&
  16658. !this.categories &&
  16659. !this.series.some(function (s) {
  16660. return (s.is('heatmap') && s.options.pointPlacement === 'between');
  16661. })) {
  16662. this.min -= 0.5;
  16663. this.max += 0.5;
  16664. }
  16665. if (!tickPositionsOption && !tickPositioner) {
  16666. this.adjustTickAmount();
  16667. }
  16668. }
  16669. fireEvent(this, 'afterSetTickPositions');
  16670. };
  16671. /**
  16672. * Handle startOnTick and endOnTick by either adapting to padding min/max or
  16673. * rounded min/max. Also handle single data points.
  16674. *
  16675. * @private
  16676. * @function Highcharts.Axis#trimTicks
  16677. *
  16678. * @param {Array<number>} tickPositions
  16679. * TO-DO: parameter description
  16680. *
  16681. * @param {boolean} [startOnTick]
  16682. * TO-DO: parameter description
  16683. *
  16684. * @param {boolean} [endOnTick]
  16685. * TO-DO: parameter description
  16686. */
  16687. Axis.prototype.trimTicks = function (tickPositions, startOnTick, endOnTick) {
  16688. var roundedMin = tickPositions[0],
  16689. roundedMax = tickPositions[tickPositions.length - 1],
  16690. minPointOffset = (!this.isOrdinal && this.minPointOffset) || 0; // (#12716)
  16691. fireEvent(this, 'trimTicks');
  16692. if (!this.isLinked) {
  16693. if (startOnTick && roundedMin !== -Infinity) { // #6502
  16694. this.min = roundedMin;
  16695. }
  16696. else {
  16697. while (this.min - minPointOffset > tickPositions[0]) {
  16698. tickPositions.shift();
  16699. }
  16700. }
  16701. if (endOnTick) {
  16702. this.max = roundedMax;
  16703. }
  16704. else {
  16705. while (this.max + minPointOffset <
  16706. tickPositions[tickPositions.length - 1]) {
  16707. tickPositions.pop();
  16708. }
  16709. }
  16710. // If no tick are left, set one tick in the middle (#3195)
  16711. if (tickPositions.length === 0 &&
  16712. defined(roundedMin) &&
  16713. !this.options.tickPositions) {
  16714. tickPositions.push((roundedMax + roundedMin) / 2);
  16715. }
  16716. }
  16717. };
  16718. /**
  16719. * Check if there are multiple axes in the same pane.
  16720. *
  16721. * @private
  16722. * @function Highcharts.Axis#alignToOthers
  16723. *
  16724. * @return {boolean|undefined}
  16725. * True if there are other axes.
  16726. */
  16727. Axis.prototype.alignToOthers = function () {
  16728. var axis = this,
  16729. others = // Whether there is another axis to pair with this one
  16730. {},
  16731. hasOther,
  16732. options = axis.options;
  16733. if (
  16734. // Only if alignTicks is true
  16735. this.chart.options.chart.alignTicks !== false &&
  16736. options.alignTicks &&
  16737. // Disabled when startOnTick or endOnTick are false (#7604)
  16738. options.startOnTick !== false &&
  16739. options.endOnTick !== false &&
  16740. // Don't try to align ticks on a log axis, they are not evenly
  16741. // spaced (#6021)
  16742. !axis.logarithmic) {
  16743. this.chart[this.coll].forEach(function (axis) {
  16744. var otherOptions = axis.options, horiz = axis.horiz, key = [
  16745. horiz ? otherOptions.left : otherOptions.top,
  16746. otherOptions.width,
  16747. otherOptions.height,
  16748. otherOptions.pane
  16749. ].join(',');
  16750. if (axis.series.length) { // #4442
  16751. if (others[key]) {
  16752. hasOther = true; // #4201
  16753. }
  16754. else {
  16755. others[key] = 1;
  16756. }
  16757. }
  16758. });
  16759. }
  16760. return hasOther;
  16761. };
  16762. /**
  16763. * Find the max ticks of either the x and y axis collection, and record it
  16764. * in `this.tickAmount`.
  16765. *
  16766. * @private
  16767. * @function Highcharts.Axis#getTickAmount
  16768. */
  16769. Axis.prototype.getTickAmount = function () {
  16770. var axis = this,
  16771. options = this.options,
  16772. tickAmount = options.tickAmount,
  16773. tickPixelInterval = options.tickPixelInterval;
  16774. if (!defined(options.tickInterval) &&
  16775. !tickAmount &&
  16776. this.len < tickPixelInterval &&
  16777. !this.isRadial &&
  16778. !axis.logarithmic &&
  16779. options.startOnTick &&
  16780. options.endOnTick) {
  16781. tickAmount = 2;
  16782. }
  16783. if (!tickAmount && this.alignToOthers()) {
  16784. // Add 1 because 4 tick intervals require 5 ticks (including first
  16785. // and last)
  16786. tickAmount = Math.ceil(this.len / tickPixelInterval) + 1;
  16787. }
  16788. // For tick amounts of 2 and 3, compute five ticks and remove the
  16789. // intermediate ones. This prevents the axis from adding ticks that are
  16790. // too far away from the data extremes.
  16791. if (tickAmount < 4) {
  16792. this.finalTickAmt = tickAmount;
  16793. tickAmount = 5;
  16794. }
  16795. this.tickAmount = tickAmount;
  16796. };
  16797. /**
  16798. * When using multiple axes, adjust the number of ticks to match the highest
  16799. * number of ticks in that group.
  16800. *
  16801. * @private
  16802. * @function Highcharts.Axis#adjustTickAmount
  16803. */
  16804. Axis.prototype.adjustTickAmount = function () {
  16805. var axis = this,
  16806. axisOptions = axis.options,
  16807. tickInterval = axis.tickInterval,
  16808. tickPositions = axis.tickPositions,
  16809. tickAmount = axis.tickAmount,
  16810. finalTickAmt = axis.finalTickAmt,
  16811. currentTickAmount = tickPositions && tickPositions.length,
  16812. threshold = pick(axis.threshold,
  16813. axis.softThreshold ? 0 : null),
  16814. len,
  16815. i;
  16816. if (axis.hasData() && isNumber(axis.min) && isNumber(axis.max)) { // #14769
  16817. if (currentTickAmount < tickAmount) {
  16818. while (tickPositions.length < tickAmount) {
  16819. // Extend evenly for both sides unless we're on the
  16820. // threshold (#3965)
  16821. if (tickPositions.length % 2 ||
  16822. axis.min === threshold) {
  16823. // to the end
  16824. tickPositions.push(correctFloat(tickPositions[tickPositions.length - 1] +
  16825. tickInterval));
  16826. }
  16827. else {
  16828. // to the start
  16829. tickPositions.unshift(correctFloat(tickPositions[0] - tickInterval));
  16830. }
  16831. }
  16832. axis.transA *= (currentTickAmount - 1) / (tickAmount - 1);
  16833. // Do not crop when ticks are not extremes (#9841)
  16834. axis.min = axisOptions.startOnTick ?
  16835. tickPositions[0] :
  16836. Math.min(axis.min, tickPositions[0]);
  16837. axis.max = axisOptions.endOnTick ?
  16838. tickPositions[tickPositions.length - 1] :
  16839. Math.max(axis.max, tickPositions[tickPositions.length - 1]);
  16840. // We have too many ticks, run second pass to try to reduce ticks
  16841. }
  16842. else if (currentTickAmount > tickAmount) {
  16843. axis.tickInterval *= 2;
  16844. axis.setTickPositions();
  16845. }
  16846. // The finalTickAmt property is set in getTickAmount
  16847. if (defined(finalTickAmt)) {
  16848. i = len = tickPositions.length;
  16849. while (i--) {
  16850. if (
  16851. // Remove every other tick
  16852. (finalTickAmt === 3 && i % 2 === 1) ||
  16853. // Remove all but first and last
  16854. (finalTickAmt <= 2 && i > 0 && i < len - 1)) {
  16855. tickPositions.splice(i, 1);
  16856. }
  16857. }
  16858. axis.finalTickAmt = void 0;
  16859. }
  16860. }
  16861. };
  16862. /**
  16863. * Set the scale based on data min and max, user set min and max or options.
  16864. *
  16865. * @private
  16866. * @function Highcharts.Axis#setScale
  16867. *
  16868. * @fires Highcharts.Axis#event:afterSetScale
  16869. */
  16870. Axis.prototype.setScale = function () {
  16871. var axis = this,
  16872. isDirtyAxisLength,
  16873. isDirtyData = false,
  16874. isXAxisDirty = false;
  16875. axis.series.forEach(function (series) {
  16876. isDirtyData = isDirtyData || series.isDirtyData || series.isDirty;
  16877. // When x axis is dirty, we need new data extremes for y as
  16878. // well:
  16879. isXAxisDirty = (isXAxisDirty ||
  16880. (series.xAxis && series.xAxis.isDirty) ||
  16881. false);
  16882. });
  16883. // set the new axisLength
  16884. axis.setAxisSize();
  16885. isDirtyAxisLength = axis.len !== (axis.old && axis.old.len);
  16886. // do we really need to go through all this?
  16887. if (isDirtyAxisLength ||
  16888. isDirtyData ||
  16889. isXAxisDirty ||
  16890. axis.isLinked ||
  16891. axis.forceRedraw ||
  16892. axis.userMin !== (axis.old && axis.old.userMin) ||
  16893. axis.userMax !== (axis.old && axis.old.userMax) ||
  16894. axis.alignToOthers()) {
  16895. if (axis.stacking) {
  16896. axis.stacking.resetStacks();
  16897. }
  16898. axis.forceRedraw = false;
  16899. // get data extremes if needed
  16900. axis.getSeriesExtremes();
  16901. // get fixed positions based on tickInterval
  16902. axis.setTickInterval();
  16903. // Mark as dirty if it is not already set to dirty and extremes have
  16904. // changed. #595.
  16905. if (!axis.isDirty) {
  16906. axis.isDirty =
  16907. isDirtyAxisLength ||
  16908. axis.min !== (axis.old && axis.old.min) ||
  16909. axis.max !== (axis.old && axis.old.max);
  16910. }
  16911. }
  16912. else if (axis.stacking) {
  16913. axis.stacking.cleanStacks();
  16914. }
  16915. // Recalculate panning state object, when the data
  16916. // has changed. It is required when vertical panning is enabled.
  16917. if (isDirtyData && axis.panningState) {
  16918. axis.panningState.isDirty = true;
  16919. }
  16920. fireEvent(this, 'afterSetScale');
  16921. };
  16922. /**
  16923. * Set the minimum and maximum of the axes after render time. If the
  16924. * `startOnTick` and `endOnTick` options are true, the minimum and maximum
  16925. * values are rounded off to the nearest tick. To prevent this, these
  16926. * options can be set to false before calling setExtremes. Also, setExtremes
  16927. * will not allow a range lower than the `minRange` option, which by default
  16928. * is the range of five points.
  16929. *
  16930. * @sample highcharts/members/axis-setextremes/
  16931. * Set extremes from a button
  16932. * @sample highcharts/members/axis-setextremes-datetime/
  16933. * Set extremes on a datetime axis
  16934. * @sample highcharts/members/axis-setextremes-off-ticks/
  16935. * Set extremes off ticks
  16936. * @sample stock/members/axis-setextremes/
  16937. * Set extremes in Highcharts Stock
  16938. * @sample maps/members/axis-setextremes/
  16939. * Set extremes in Highmaps
  16940. *
  16941. * @function Highcharts.Axis#setExtremes
  16942. *
  16943. * @param {number} [newMin]
  16944. * The new minimum value.
  16945. *
  16946. * @param {number} [newMax]
  16947. * The new maximum value.
  16948. *
  16949. * @param {boolean} [redraw=true]
  16950. * Whether to redraw the chart or wait for an explicit call to
  16951. * {@link Highcharts.Chart#redraw}
  16952. *
  16953. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  16954. * Enable or modify animations.
  16955. *
  16956. * @param {*} [eventArguments]
  16957. * Arguments to be accessed in event handler.
  16958. *
  16959. * @fires Highcharts.Axis#event:setExtremes
  16960. */
  16961. Axis.prototype.setExtremes = function (newMin, newMax, redraw, animation, eventArguments) {
  16962. var axis = this,
  16963. chart = axis.chart;
  16964. redraw = pick(redraw, true); // defaults to true
  16965. axis.series.forEach(function (serie) {
  16966. delete serie.kdTree;
  16967. });
  16968. // Extend the arguments with min and max
  16969. eventArguments = extend(eventArguments, {
  16970. min: newMin,
  16971. max: newMax
  16972. });
  16973. // Fire the event
  16974. fireEvent(axis, 'setExtremes', eventArguments, function () {
  16975. axis.userMin = newMin;
  16976. axis.userMax = newMax;
  16977. axis.eventArgs = eventArguments;
  16978. if (redraw) {
  16979. chart.redraw(animation);
  16980. }
  16981. });
  16982. };
  16983. /**
  16984. * Overridable method for zooming chart. Pulled out in a separate method to
  16985. * allow overriding in stock charts.
  16986. * @private
  16987. * @function Highcharts.Axis#zoom
  16988. *
  16989. * @param {number} newMin
  16990. * TO-DO: parameter description
  16991. *
  16992. * @param {number} newMax
  16993. * TO-DO: parameter description
  16994. *
  16995. * @return {boolean}
  16996. */
  16997. Axis.prototype.zoom = function (newMin, newMax) {
  16998. var axis = this,
  16999. dataMin = this.dataMin,
  17000. dataMax = this.dataMax,
  17001. options = this.options,
  17002. min = Math.min(dataMin,
  17003. pick(options.min,
  17004. dataMin)),
  17005. max = Math.max(dataMax,
  17006. pick(options.max,
  17007. dataMax)),
  17008. evt = {
  17009. newMin: newMin,
  17010. newMax: newMax
  17011. };
  17012. fireEvent(this, 'zoom', evt, function (e) {
  17013. // Use e.newMin and e.newMax - event handlers may have altered them
  17014. var newMin = e.newMin,
  17015. newMax = e.newMax;
  17016. if (newMin !== axis.min || newMax !== axis.max) { // #5790
  17017. // Prevent pinch zooming out of range. Check for defined is for
  17018. // #1946. #1734.
  17019. if (!axis.allowZoomOutside) {
  17020. // #6014, sometimes newMax will be smaller than min (or
  17021. // newMin will be larger than max).
  17022. if (defined(dataMin)) {
  17023. if (newMin < min) {
  17024. newMin = min;
  17025. }
  17026. if (newMin > max) {
  17027. newMin = max;
  17028. }
  17029. }
  17030. if (defined(dataMax)) {
  17031. if (newMax < min) {
  17032. newMax = min;
  17033. }
  17034. if (newMax > max) {
  17035. newMax = max;
  17036. }
  17037. }
  17038. }
  17039. // In full view, displaying the reset zoom button is not
  17040. // required
  17041. axis.displayBtn = (typeof newMin !== 'undefined' ||
  17042. typeof newMax !== 'undefined');
  17043. // Do it
  17044. axis.setExtremes(newMin, newMax, false, void 0, { trigger: 'zoom' });
  17045. }
  17046. e.zoomed = true;
  17047. });
  17048. return evt.zoomed;
  17049. };
  17050. /**
  17051. * Update the axis metrics.
  17052. *
  17053. * @private
  17054. * @function Highcharts.Axis#setAxisSize
  17055. */
  17056. Axis.prototype.setAxisSize = function () {
  17057. var chart = this.chart,
  17058. options = this.options,
  17059. // [top, right, bottom, left]
  17060. offsets = options.offsets || [0, 0, 0, 0],
  17061. horiz = this.horiz,
  17062. // Check for percentage based input values. Rounding fixes problems
  17063. // with column overflow and plot line filtering (#4898, #4899)
  17064. width = this.width = Math.round(relativeLength(pick(options.width,
  17065. chart.plotWidth - offsets[3] + offsets[1]),
  17066. chart.plotWidth)),
  17067. height = this.height = Math.round(relativeLength(pick(options.height,
  17068. chart.plotHeight - offsets[0] + offsets[2]),
  17069. chart.plotHeight)),
  17070. top = this.top = Math.round(relativeLength(pick(options.top,
  17071. chart.plotTop + offsets[0]),
  17072. chart.plotHeight,
  17073. chart.plotTop)),
  17074. left = this.left = Math.round(relativeLength(pick(options.left,
  17075. chart.plotLeft + offsets[3]),
  17076. chart.plotWidth,
  17077. chart.plotLeft));
  17078. // Expose basic values to use in Series object and navigator
  17079. this.bottom = chart.chartHeight - height - top;
  17080. this.right = chart.chartWidth - width - left;
  17081. // Direction agnostic properties
  17082. this.len = Math.max(horiz ? width : height, 0); // Math.max fixes #905
  17083. this.pos = horiz ? left : top; // distance from SVG origin
  17084. };
  17085. /**
  17086. * Get the current extremes for the axis.
  17087. *
  17088. * @sample highcharts/members/axis-getextremes/
  17089. * Report extremes by click on a button
  17090. * @sample maps/members/axis-getextremes/
  17091. * Get extremes in Highmaps
  17092. *
  17093. * @function Highcharts.Axis#getExtremes
  17094. *
  17095. * @return {Highcharts.ExtremesObject}
  17096. * An object containing extremes information.
  17097. */
  17098. Axis.prototype.getExtremes = function () {
  17099. var axis = this;
  17100. var log = axis.logarithmic;
  17101. return {
  17102. min: log ?
  17103. correctFloat(log.lin2log(axis.min)) :
  17104. axis.min,
  17105. max: log ?
  17106. correctFloat(log.lin2log(axis.max)) :
  17107. axis.max,
  17108. dataMin: axis.dataMin,
  17109. dataMax: axis.dataMax,
  17110. userMin: axis.userMin,
  17111. userMax: axis.userMax
  17112. };
  17113. };
  17114. /**
  17115. * Get the zero plane either based on zero or on the min or max value.
  17116. * Used in bar and area plots.
  17117. *
  17118. * @function Highcharts.Axis#getThreshold
  17119. *
  17120. * @param {number} threshold
  17121. * The threshold in axis values.
  17122. *
  17123. * @return {number|undefined}
  17124. * The translated threshold position in terms of pixels, and corrected to
  17125. * stay within the axis bounds.
  17126. */
  17127. Axis.prototype.getThreshold = function (threshold) {
  17128. var axis = this,
  17129. log = axis.logarithmic,
  17130. realMin = log ? log.lin2log(axis.min) : axis.min,
  17131. realMax = log ? log.lin2log(axis.max) : axis.max;
  17132. if (threshold === null || threshold === -Infinity) {
  17133. threshold = realMin;
  17134. }
  17135. else if (threshold === Infinity) {
  17136. threshold = realMax;
  17137. }
  17138. else if (realMin > threshold) {
  17139. threshold = realMin;
  17140. }
  17141. else if (realMax < threshold) {
  17142. threshold = realMax;
  17143. }
  17144. return axis.translate(threshold, 0, 1, 0, 1);
  17145. };
  17146. /**
  17147. * Compute auto alignment for the axis label based on which side the axis is
  17148. * on and the given rotation for the label.
  17149. *
  17150. * @private
  17151. * @function Highcharts.Axis#autoLabelAlign
  17152. *
  17153. * @param {number} rotation
  17154. * The rotation in degrees as set by either the `rotation` or `autoRotation`
  17155. * options.
  17156. *
  17157. * @return {Highcharts.AlignValue}
  17158. * Can be `"center"`, `"left"` or `"right"`.
  17159. */
  17160. Axis.prototype.autoLabelAlign = function (rotation) {
  17161. var angle = (pick(rotation, 0) - (this.side * 90) + 720) % 360,
  17162. evt = { align: 'center' };
  17163. fireEvent(this, 'autoLabelAlign', evt, function (e) {
  17164. if (angle > 15 && angle < 165) {
  17165. e.align = 'right';
  17166. }
  17167. else if (angle > 195 && angle < 345) {
  17168. e.align = 'left';
  17169. }
  17170. });
  17171. return evt.align;
  17172. };
  17173. /**
  17174. * Get the tick length and width for the axis based on axis options.
  17175. * @private
  17176. * @function Highcharts.Axis#tickSize
  17177. *
  17178. * @param {string} [prefix]
  17179. * 'tick' or 'minorTick'
  17180. *
  17181. * @return {Array<number,number>|undefined}
  17182. * An array of tickLength and tickWidth
  17183. */
  17184. Axis.prototype.tickSize = function (prefix) {
  17185. var options = this.options, tickLength = options[prefix === 'tick' ? 'tickLength' : 'minorTickLength'], tickWidth = pick(options[prefix === 'tick' ? 'tickWidth' : 'minorTickWidth'],
  17186. // Default to 1 on linear and datetime X axes
  17187. prefix === 'tick' && this.isXAxis && !this.categories ? 1 : 0), e, tickSize;
  17188. if (tickWidth && tickLength) {
  17189. // Negate the length
  17190. if (options[prefix + 'Position'] === 'inside') {
  17191. tickLength = -tickLength;
  17192. }
  17193. tickSize = [tickLength, tickWidth];
  17194. }
  17195. e = { tickSize: tickSize };
  17196. fireEvent(this, 'afterTickSize', e);
  17197. return e.tickSize;
  17198. };
  17199. /**
  17200. * Return the size of the labels.
  17201. *
  17202. * @private
  17203. * @function Highcharts.Axis#labelMetrics
  17204. *
  17205. * @return {Highcharts.FontMetricsObject}
  17206. */
  17207. Axis.prototype.labelMetrics = function () {
  17208. var index = this.tickPositions && this.tickPositions[0] || 0;
  17209. return this.chart.renderer.fontMetrics(this.options.labels.style.fontSize, this.ticks[index] && this.ticks[index].label);
  17210. };
  17211. /**
  17212. * Prevent the ticks from getting so close we can't draw the labels. On a
  17213. * horizontal axis, this is handled by rotating the labels, removing ticks
  17214. * and adding ellipsis. On a vertical axis remove ticks and add ellipsis.
  17215. *
  17216. * @private
  17217. * @function Highcharts.Axis#unsquish
  17218. *
  17219. * @return {number}
  17220. */
  17221. Axis.prototype.unsquish = function () {
  17222. var labelOptions = this.options.labels,
  17223. horiz = this.horiz,
  17224. tickInterval = this.tickInterval,
  17225. newTickInterval = tickInterval,
  17226. slotSize = this.len / (((this.categories ? 1 : 0) +
  17227. this.max -
  17228. this.min) /
  17229. tickInterval),
  17230. rotation,
  17231. rotationOption = labelOptions.rotation,
  17232. labelMetrics = this.labelMetrics(),
  17233. step,
  17234. bestScore = Number.MAX_VALUE,
  17235. autoRotation,
  17236. range = Math.max(this.max - this.min, 0),
  17237. // Return the multiple of tickInterval that is needed to avoid
  17238. // collision
  17239. getStep = function (spaceNeeded) {
  17240. var step = spaceNeeded / (slotSize || 1);
  17241. step = step > 1 ? Math.ceil(step) : 1;
  17242. // Guard for very small or negative angles (#9835)
  17243. if (step * tickInterval > range &&
  17244. spaceNeeded !== Infinity &&
  17245. slotSize !== Infinity &&
  17246. range) {
  17247. step = Math.ceil(range / tickInterval);
  17248. }
  17249. return correctFloat(step * tickInterval);
  17250. };
  17251. if (horiz) {
  17252. if (!labelOptions.staggerLines && !labelOptions.step) {
  17253. if (isNumber(rotationOption)) {
  17254. autoRotation = [rotationOption];
  17255. }
  17256. else if (slotSize < labelOptions.autoRotationLimit) {
  17257. autoRotation = labelOptions.autoRotation;
  17258. }
  17259. }
  17260. if (autoRotation) {
  17261. // Loop over the given autoRotation options, and determine
  17262. // which gives the best score. The best score is that with
  17263. // the lowest number of steps and a rotation closest
  17264. // to horizontal.
  17265. autoRotation.forEach(function (rot) {
  17266. var score;
  17267. if (rot === rotationOption ||
  17268. (rot && rot >= -90 && rot <= 90)) { // #3891
  17269. step = getStep(Math.abs(labelMetrics.h / Math.sin(deg2rad * rot)));
  17270. score = step + Math.abs(rot / 360);
  17271. if (score < bestScore) {
  17272. bestScore = score;
  17273. rotation = rot;
  17274. newTickInterval = step;
  17275. }
  17276. }
  17277. });
  17278. }
  17279. }
  17280. else if (!labelOptions.step) { // #4411
  17281. newTickInterval = getStep(labelMetrics.h);
  17282. }
  17283. this.autoRotation = autoRotation;
  17284. this.labelRotation = pick(rotation, isNumber(rotationOption) ? rotationOption : 0);
  17285. return newTickInterval;
  17286. };
  17287. /**
  17288. * Get the general slot width for labels/categories on this axis. This may
  17289. * change between the pre-render (from Axis.getOffset) and the final tick
  17290. * rendering and placement.
  17291. *
  17292. * @private
  17293. * @function Highcharts.Axis#getSlotWidth
  17294. *
  17295. * @param {Highcharts.Tick} [tick] Optionally, calculate the slot width
  17296. * basing on tick label. It is used in highcharts-3d module, where the slots
  17297. * has different widths depending on perspective angles.
  17298. *
  17299. * @return {number}
  17300. * The pixel width allocated to each axis label.
  17301. */
  17302. Axis.prototype.getSlotWidth = function (tick) {
  17303. // #5086, #1580, #1931
  17304. var chart = this.chart,
  17305. horiz = this.horiz,
  17306. labelOptions = this.options.labels,
  17307. slotCount = Math.max(this.tickPositions.length - (this.categories ? 0 : 1), 1),
  17308. marginLeft = chart.margin[3];
  17309. // Used by grid axis
  17310. if (tick && isNumber(tick.slotWidth)) { // #13221, can be 0
  17311. return tick.slotWidth;
  17312. }
  17313. if (horiz && labelOptions.step < 2) {
  17314. if (labelOptions.rotation) { // #4415
  17315. return 0;
  17316. }
  17317. return ((this.staggerLines || 1) * this.len) / slotCount;
  17318. }
  17319. if (!horiz) {
  17320. // #7028
  17321. var cssWidth = labelOptions.style.width;
  17322. if (cssWidth !== void 0) {
  17323. return parseInt(String(cssWidth), 10);
  17324. }
  17325. if (marginLeft) {
  17326. return marginLeft - chart.spacing[3];
  17327. }
  17328. }
  17329. // Last resort, a fraction of the available size
  17330. return chart.chartWidth * 0.33;
  17331. };
  17332. /**
  17333. * Render the axis labels and determine whether ellipsis or rotation need to
  17334. * be applied.
  17335. *
  17336. * @private
  17337. * @function Highcharts.Axis#renderUnsquish
  17338. */
  17339. Axis.prototype.renderUnsquish = function () {
  17340. var chart = this.chart,
  17341. renderer = chart.renderer,
  17342. tickPositions = this.tickPositions,
  17343. ticks = this.ticks,
  17344. labelOptions = this.options.labels,
  17345. labelStyleOptions = labelOptions.style,
  17346. horiz = this.horiz,
  17347. slotWidth = this.getSlotWidth(),
  17348. innerWidth = Math.max(1,
  17349. Math.round(slotWidth - 2 * labelOptions.padding)),
  17350. attr = {},
  17351. labelMetrics = this.labelMetrics(),
  17352. textOverflowOption = labelStyleOptions.textOverflow,
  17353. commonWidth,
  17354. commonTextOverflow,
  17355. maxLabelLength = 0,
  17356. label,
  17357. i,
  17358. pos;
  17359. // Set rotation option unless it is "auto", like in gauges
  17360. if (!isString(labelOptions.rotation)) {
  17361. // #4443
  17362. attr.rotation = labelOptions.rotation || 0;
  17363. }
  17364. // Get the longest label length
  17365. tickPositions.forEach(function (tickPosition) {
  17366. var tick = ticks[tickPosition];
  17367. // Replace label - sorting animation
  17368. if (tick.movedLabel) {
  17369. tick.replaceMovedLabel();
  17370. }
  17371. if (tick &&
  17372. tick.label &&
  17373. tick.label.textPxLength > maxLabelLength) {
  17374. maxLabelLength = tick.label.textPxLength;
  17375. }
  17376. });
  17377. this.maxLabelLength = maxLabelLength;
  17378. // Handle auto rotation on horizontal axis
  17379. if (this.autoRotation) {
  17380. // Apply rotation only if the label is too wide for the slot, and
  17381. // the label is wider than its height.
  17382. if (maxLabelLength > innerWidth &&
  17383. maxLabelLength > labelMetrics.h) {
  17384. attr.rotation = this.labelRotation;
  17385. }
  17386. else {
  17387. this.labelRotation = 0;
  17388. }
  17389. // Handle word-wrap or ellipsis on vertical axis
  17390. }
  17391. else if (slotWidth) {
  17392. // For word-wrap or ellipsis
  17393. commonWidth = innerWidth;
  17394. if (!textOverflowOption) {
  17395. commonTextOverflow = 'clip';
  17396. // On vertical axis, only allow word wrap if there is room
  17397. // for more lines.
  17398. i = tickPositions.length;
  17399. while (!horiz && i--) {
  17400. pos = tickPositions[i];
  17401. label = ticks[pos].label;
  17402. if (label) {
  17403. // Reset ellipsis in order to get the correct
  17404. // bounding box (#4070)
  17405. if (label.styles &&
  17406. label.styles.textOverflow === 'ellipsis') {
  17407. label.css({ textOverflow: 'clip' });
  17408. // Set the correct width in order to read
  17409. // the bounding box height (#4678, #5034)
  17410. }
  17411. else if (label.textPxLength > slotWidth) {
  17412. label.css({ width: slotWidth + 'px' });
  17413. }
  17414. if (label.getBBox().height > (this.len / tickPositions.length -
  17415. (labelMetrics.h - labelMetrics.f))) {
  17416. label.specificTextOverflow = 'ellipsis';
  17417. }
  17418. }
  17419. }
  17420. }
  17421. }
  17422. // Add ellipsis if the label length is significantly longer than ideal
  17423. if (attr.rotation) {
  17424. commonWidth = (maxLabelLength > chart.chartHeight * 0.5 ?
  17425. chart.chartHeight * 0.33 :
  17426. maxLabelLength);
  17427. if (!textOverflowOption) {
  17428. commonTextOverflow = 'ellipsis';
  17429. }
  17430. }
  17431. // Set the explicit or automatic label alignment
  17432. this.labelAlign = labelOptions.align ||
  17433. this.autoLabelAlign(this.labelRotation);
  17434. if (this.labelAlign) {
  17435. attr.align = this.labelAlign;
  17436. }
  17437. // Apply general and specific CSS
  17438. tickPositions.forEach(function (pos) {
  17439. var tick = ticks[pos],
  17440. label = tick && tick.label,
  17441. widthOption = labelStyleOptions.width,
  17442. css = {};
  17443. if (label) {
  17444. // This needs to go before the CSS in old IE (#4502)
  17445. label.attr(attr);
  17446. if (tick.shortenLabel) {
  17447. tick.shortenLabel();
  17448. }
  17449. else if (commonWidth &&
  17450. !widthOption &&
  17451. // Setting width in this case messes with the bounding box
  17452. // (#7975)
  17453. labelStyleOptions.whiteSpace !== 'nowrap' &&
  17454. (
  17455. // Speed optimizing, #7656
  17456. commonWidth < label.textPxLength ||
  17457. // Resetting CSS, #4928
  17458. label.element.tagName === 'SPAN')) {
  17459. css.width = commonWidth + 'px';
  17460. if (!textOverflowOption) {
  17461. css.textOverflow = (label.specificTextOverflow ||
  17462. commonTextOverflow);
  17463. }
  17464. label.css(css);
  17465. // Reset previously shortened label (#8210)
  17466. }
  17467. else if (label.styles &&
  17468. label.styles.width &&
  17469. !css.width &&
  17470. !widthOption) {
  17471. label.css({ width: null });
  17472. }
  17473. delete label.specificTextOverflow;
  17474. tick.rotation = attr.rotation;
  17475. }
  17476. }, this);
  17477. // Note: Why is this not part of getLabelPosition?
  17478. this.tickRotCorr = renderer.rotCorr(labelMetrics.b, this.labelRotation || 0, this.side !== 0);
  17479. };
  17480. /**
  17481. * Return true if the axis has associated data.
  17482. *
  17483. * @function Highcharts.Axis#hasData
  17484. *
  17485. * @return {boolean}
  17486. * True if the axis has associated visible series and those series have
  17487. * either valid data points or explicit `min` and `max` settings.
  17488. */
  17489. Axis.prototype.hasData = function () {
  17490. return this.series.some(function (s) {
  17491. return s.hasData();
  17492. }) ||
  17493. (this.options.showEmpty &&
  17494. defined(this.min) &&
  17495. defined(this.max));
  17496. };
  17497. /**
  17498. * Adds the title defined in axis.options.title.
  17499. *
  17500. * @function Highcharts.Axis#addTitle
  17501. *
  17502. * @param {boolean} [display]
  17503. * Whether or not to display the title.
  17504. */
  17505. Axis.prototype.addTitle = function (display) {
  17506. var axis = this,
  17507. renderer = axis.chart.renderer,
  17508. horiz = axis.horiz,
  17509. opposite = axis.opposite,
  17510. options = axis.options,
  17511. axisTitleOptions = options.title,
  17512. textAlign,
  17513. styledMode = axis.chart.styledMode;
  17514. if (!axis.axisTitle) {
  17515. textAlign = axisTitleOptions.textAlign;
  17516. if (!textAlign) {
  17517. textAlign = (horiz ? {
  17518. low: 'left',
  17519. middle: 'center',
  17520. high: 'right'
  17521. } : {
  17522. low: opposite ? 'right' : 'left',
  17523. middle: 'center',
  17524. high: opposite ? 'left' : 'right'
  17525. })[axisTitleOptions.align];
  17526. }
  17527. axis.axisTitle = renderer
  17528. .text(axisTitleOptions.text || '', 0, 0, axisTitleOptions.useHTML)
  17529. .attr({
  17530. zIndex: 7,
  17531. rotation: axisTitleOptions.rotation,
  17532. align: textAlign
  17533. })
  17534. .addClass('highcharts-axis-title');
  17535. // #7814, don't mutate style option
  17536. if (!styledMode) {
  17537. axis.axisTitle.css(merge(axisTitleOptions.style));
  17538. }
  17539. axis.axisTitle.add(axis.axisGroup);
  17540. axis.axisTitle.isNew = true;
  17541. }
  17542. // Max width defaults to the length of the axis
  17543. if (!styledMode &&
  17544. !axisTitleOptions.style.width &&
  17545. !axis.isRadial) {
  17546. axis.axisTitle.css({
  17547. width: axis.len + 'px'
  17548. });
  17549. }
  17550. // hide or show the title depending on whether showEmpty is set
  17551. axis.axisTitle[display ? 'show' : 'hide'](display);
  17552. };
  17553. /**
  17554. * Generates a tick for initial positioning.
  17555. *
  17556. * @private
  17557. * @function Highcharts.Axis#generateTick
  17558. *
  17559. * @param {number} pos
  17560. * The tick position in axis values.
  17561. *
  17562. * @param {number} [i]
  17563. * The index of the tick in {@link Axis.tickPositions}.
  17564. */
  17565. Axis.prototype.generateTick = function (pos) {
  17566. var axis = this;
  17567. var ticks = axis.ticks;
  17568. if (!ticks[pos]) {
  17569. ticks[pos] = new Tick(axis, pos);
  17570. }
  17571. else {
  17572. ticks[pos].addLabel(); // update labels depending on tick interval
  17573. }
  17574. };
  17575. /**
  17576. * Render the tick labels to a preliminary position to get their sizes
  17577. *
  17578. * @private
  17579. * @function Highcharts.Axis#getOffset
  17580. *
  17581. * @fires Highcharts.Axis#event:afterGetOffset
  17582. */
  17583. Axis.prototype.getOffset = function () {
  17584. var _this = this;
  17585. var axis = this,
  17586. chart = axis.chart,
  17587. renderer = chart.renderer,
  17588. options = axis.options,
  17589. tickPositions = axis.tickPositions,
  17590. ticks = axis.ticks,
  17591. horiz = axis.horiz,
  17592. side = axis.side,
  17593. invertedSide = chart.inverted &&
  17594. !axis.isZAxis ? [1, 0, 3, 2][side] : side,
  17595. hasData,
  17596. showAxis,
  17597. titleOffset = 0,
  17598. titleOffsetOption,
  17599. titleMargin = 0,
  17600. axisTitleOptions = options.title,
  17601. labelOptions = options.labels,
  17602. labelOffset = 0, // reset
  17603. labelOffsetPadded,
  17604. axisOffset = chart.axisOffset,
  17605. clipOffset = chart.clipOffset,
  17606. clip,
  17607. directionFactor = [-1, 1, 1, -1][side],
  17608. className = options.className,
  17609. axisParent = axis.axisParent, // Used in color axis
  17610. lineHeightCorrection;
  17611. // For reuse in Axis.render
  17612. hasData = axis.hasData();
  17613. axis.showAxis = showAxis = hasData || options.showEmpty;
  17614. // Set/reset staggerLines
  17615. axis.staggerLines = (axis.horiz && labelOptions.staggerLines) || void 0;
  17616. // Create the axisGroup and gridGroup elements on first iteration
  17617. if (!axis.axisGroup) {
  17618. var createGroup = function (name,
  17619. suffix,
  17620. zIndex) { return renderer.g(name)
  17621. .attr({ zIndex: zIndex })
  17622. .addClass("highcharts-" + _this.coll.toLowerCase() + suffix + " " +
  17623. (_this.isRadial ? "highcharts-radial-axis" + suffix + " " : '') +
  17624. (className || ''))
  17625. .add(axisParent); };
  17626. axis.gridGroup = createGroup('grid', '-grid', options.gridZIndex);
  17627. axis.axisGroup = createGroup('axis', '', options.zIndex);
  17628. axis.labelGroup = createGroup('axis-labels', '-labels', labelOptions.zIndex);
  17629. }
  17630. if (hasData || axis.isLinked) {
  17631. // Generate ticks
  17632. tickPositions.forEach(function (pos, i) {
  17633. // i is not used here, but may be used in overrides
  17634. axis.generateTick(pos, i);
  17635. });
  17636. axis.renderUnsquish();
  17637. // Left side must be align: right and right side must
  17638. // have align: left for labels
  17639. axis.reserveSpaceDefault = (side === 0 ||
  17640. side === 2 ||
  17641. { 1: 'left', 3: 'right' }[side] === axis.labelAlign);
  17642. if (pick(labelOptions.reserveSpace, axis.labelAlign === 'center' ? true : null, axis.reserveSpaceDefault)) {
  17643. tickPositions.forEach(function (pos) {
  17644. // get the highest offset
  17645. labelOffset = Math.max(ticks[pos].getLabelSize(), labelOffset);
  17646. });
  17647. }
  17648. if (axis.staggerLines) {
  17649. labelOffset *= axis.staggerLines;
  17650. }
  17651. axis.labelOffset = labelOffset * (axis.opposite ? -1 : 1);
  17652. }
  17653. else { // doesn't have data
  17654. objectEach(ticks, function (tick, n) {
  17655. tick.destroy();
  17656. delete ticks[n];
  17657. });
  17658. }
  17659. if (axisTitleOptions &&
  17660. axisTitleOptions.text &&
  17661. axisTitleOptions.enabled !== false) {
  17662. axis.addTitle(showAxis);
  17663. if (showAxis && axisTitleOptions.reserveSpace !== false) {
  17664. axis.titleOffset = titleOffset =
  17665. axis.axisTitle.getBBox()[horiz ? 'height' : 'width'];
  17666. titleOffsetOption = axisTitleOptions.offset;
  17667. titleMargin = defined(titleOffsetOption) ?
  17668. 0 :
  17669. pick(axisTitleOptions.margin, horiz ? 5 : 10);
  17670. }
  17671. }
  17672. // Render the axis line
  17673. axis.renderLine();
  17674. // handle automatic or user set offset
  17675. axis.offset = directionFactor * pick(options.offset, axisOffset[side] ? axisOffset[side] + (options.margin || 0) : 0);
  17676. axis.tickRotCorr = axis.tickRotCorr || { x: 0, y: 0 }; // polar
  17677. if (side === 0) {
  17678. lineHeightCorrection = -axis.labelMetrics().h;
  17679. }
  17680. else if (side === 2) {
  17681. lineHeightCorrection = axis.tickRotCorr.y;
  17682. }
  17683. else {
  17684. lineHeightCorrection = 0;
  17685. }
  17686. // Find the padded label offset
  17687. labelOffsetPadded = Math.abs(labelOffset) + titleMargin;
  17688. if (labelOffset) {
  17689. labelOffsetPadded -= lineHeightCorrection;
  17690. labelOffsetPadded += directionFactor * (horiz ?
  17691. pick(labelOptions.y, axis.tickRotCorr.y + directionFactor * 8) :
  17692. labelOptions.x);
  17693. }
  17694. axis.axisTitleMargin = pick(titleOffsetOption, labelOffsetPadded);
  17695. if (axis.getMaxLabelDimensions) {
  17696. axis.maxLabelDimensions = axis.getMaxLabelDimensions(ticks, tickPositions);
  17697. }
  17698. // Due to GridAxis.tickSize, tickSize should be calculated after ticks
  17699. // has rendered.
  17700. var tickSize = this.tickSize('tick');
  17701. axisOffset[side] = Math.max(axisOffset[side], (axis.axisTitleMargin || 0) + titleOffset +
  17702. directionFactor * axis.offset, labelOffsetPadded, // #3027
  17703. tickPositions && tickPositions.length && tickSize ?
  17704. tickSize[0] + directionFactor * axis.offset :
  17705. 0 // #4866
  17706. );
  17707. // Decide the clipping needed to keep the graph inside
  17708. // the plot area and axis lines
  17709. clip = options.offset ?
  17710. 0 :
  17711. // #4308, #4371:
  17712. Math.floor(axis.axisLine.strokeWidth() / 2) * 2;
  17713. clipOffset[invertedSide] =
  17714. Math.max(clipOffset[invertedSide], clip);
  17715. fireEvent(this, 'afterGetOffset');
  17716. };
  17717. /**
  17718. * Internal function to get the path for the axis line. Extended for polar
  17719. * charts.
  17720. *
  17721. * @function Highcharts.Axis#getLinePath
  17722. *
  17723. * @param {number} lineWidth
  17724. * The line width in pixels.
  17725. *
  17726. * @return {Highcharts.SVGPathArray}
  17727. * The SVG path definition in array form.
  17728. */
  17729. Axis.prototype.getLinePath = function (lineWidth) {
  17730. var chart = this.chart,
  17731. opposite = this.opposite,
  17732. offset = this.offset,
  17733. horiz = this.horiz,
  17734. lineLeft = this.left + (opposite ? this.width : 0) + offset,
  17735. lineTop = chart.chartHeight - this.bottom -
  17736. (opposite ? this.height : 0) + offset;
  17737. if (opposite) {
  17738. lineWidth *= -1; // crispify the other way - #1480, #1687
  17739. }
  17740. return chart.renderer
  17741. .crispLine([
  17742. [
  17743. 'M',
  17744. horiz ?
  17745. this.left :
  17746. lineLeft,
  17747. horiz ?
  17748. lineTop :
  17749. this.top
  17750. ],
  17751. [
  17752. 'L',
  17753. horiz ?
  17754. chart.chartWidth - this.right :
  17755. lineLeft,
  17756. horiz ?
  17757. lineTop :
  17758. chart.chartHeight - this.bottom
  17759. ]
  17760. ], lineWidth);
  17761. };
  17762. /**
  17763. * Render the axis line. Called internally when rendering and redrawing the
  17764. * axis.
  17765. *
  17766. * @function Highcharts.Axis#renderLine
  17767. */
  17768. Axis.prototype.renderLine = function () {
  17769. if (!this.axisLine) {
  17770. this.axisLine = this.chart.renderer.path()
  17771. .addClass('highcharts-axis-line')
  17772. .add(this.axisGroup);
  17773. if (!this.chart.styledMode) {
  17774. this.axisLine.attr({
  17775. stroke: this.options.lineColor,
  17776. 'stroke-width': this.options.lineWidth,
  17777. zIndex: 7
  17778. });
  17779. }
  17780. }
  17781. };
  17782. /**
  17783. * Position the axis title.
  17784. *
  17785. * @private
  17786. * @function Highcharts.Axis#getTitlePosition
  17787. *
  17788. * @return {Highcharts.PositionObject}
  17789. * X and Y positions for the title.
  17790. */
  17791. Axis.prototype.getTitlePosition = function () {
  17792. // compute anchor points for each of the title align options
  17793. var horiz = this.horiz,
  17794. axisLeft = this.left,
  17795. axisTop = this.top,
  17796. axisLength = this.len,
  17797. axisTitleOptions = this.options.title,
  17798. margin = horiz ? axisLeft : axisTop,
  17799. opposite = this.opposite,
  17800. offset = this.offset,
  17801. xOption = axisTitleOptions.x,
  17802. yOption = axisTitleOptions.y,
  17803. axisTitle = this.axisTitle,
  17804. fontMetrics = this.chart.renderer.fontMetrics(axisTitleOptions.style.fontSize,
  17805. axisTitle),
  17806. // The part of a multiline text that is below the baseline of the
  17807. // first line. Subtract 1 to preserve pixel-perfectness from the
  17808. // old behaviour (v5.0.12), where only one line was allowed.
  17809. textHeightOvershoot = Math.max(axisTitle.getBBox(null, 0).height - fontMetrics.h - 1, 0),
  17810. // the position in the length direction of the axis
  17811. alongAxis = {
  17812. low: margin + (horiz ? 0 : axisLength),
  17813. middle: margin + axisLength / 2,
  17814. high: margin + (horiz ? axisLength : 0)
  17815. }[axisTitleOptions.align],
  17816. // the position in the perpendicular direction of the axis
  17817. offAxis = (horiz ? axisTop + this.height : axisLeft) +
  17818. (horiz ? 1 : -1) * // horizontal axis reverses the margin
  17819. (opposite ? -1 : 1) * // so does opposite axes
  17820. this.axisTitleMargin +
  17821. [
  17822. -textHeightOvershoot,
  17823. textHeightOvershoot,
  17824. fontMetrics.f,
  17825. -textHeightOvershoot // left
  17826. ][this.side],
  17827. titlePosition = {
  17828. x: horiz ?
  17829. alongAxis + xOption :
  17830. offAxis + (opposite ? this.width : 0) + offset + xOption,
  17831. y: horiz ?
  17832. offAxis + yOption - (opposite ? this.height : 0) + offset :
  17833. alongAxis + yOption
  17834. };
  17835. fireEvent(this, 'afterGetTitlePosition', { titlePosition: titlePosition });
  17836. return titlePosition;
  17837. };
  17838. /**
  17839. * Render a minor tick into the given position. If a minor tick already
  17840. * exists in this position, move it.
  17841. *
  17842. * @function Highcharts.Axis#renderMinorTick
  17843. *
  17844. * @param {number} pos
  17845. * The position in axis values.
  17846. */
  17847. Axis.prototype.renderMinorTick = function (pos) {
  17848. var axis = this;
  17849. var slideInTicks = axis.chart.hasRendered && axis.old;
  17850. var minorTicks = axis.minorTicks;
  17851. if (!minorTicks[pos]) {
  17852. minorTicks[pos] = new Tick(axis, pos, 'minor');
  17853. }
  17854. // Render new ticks in old position
  17855. if (slideInTicks && minorTicks[pos].isNew) {
  17856. minorTicks[pos].render(null, true);
  17857. }
  17858. minorTicks[pos].render(null, false, 1);
  17859. };
  17860. /**
  17861. * Render a major tick into the given position. If a tick already exists
  17862. * in this position, move it.
  17863. *
  17864. * @function Highcharts.Axis#renderTick
  17865. *
  17866. * @param {number} pos
  17867. * The position in axis values.
  17868. *
  17869. * @param {number} i
  17870. * The tick index.
  17871. */
  17872. Axis.prototype.renderTick = function (pos, i) {
  17873. var axis = this;
  17874. var isLinked = axis.isLinked;
  17875. var ticks = axis.ticks;
  17876. var slideInTicks = axis.chart.hasRendered && axis.old;
  17877. // Linked axes need an extra check to find out if
  17878. if (!isLinked ||
  17879. (pos >= axis.min && pos <= axis.max) ||
  17880. (axis.grid && axis.grid.isColumn)) {
  17881. if (!ticks[pos]) {
  17882. ticks[pos] = new Tick(axis, pos);
  17883. }
  17884. // NOTE this seems like overkill. Could be handled in tick.render by
  17885. // setting old position in attr, then set new position in animate.
  17886. // render new ticks in old position
  17887. if (slideInTicks && ticks[pos].isNew) {
  17888. // Start with negative opacity so that it is visible from
  17889. // halfway into the animation
  17890. ticks[pos].render(i, true, -1);
  17891. }
  17892. ticks[pos].render(i);
  17893. }
  17894. };
  17895. /**
  17896. * Render the axis.
  17897. *
  17898. * @private
  17899. * @function Highcharts.Axis#render
  17900. *
  17901. * @fires Highcharts.Axis#event:afterRender
  17902. */
  17903. Axis.prototype.render = function () {
  17904. var axis = this,
  17905. chart = axis.chart,
  17906. log = axis.logarithmic,
  17907. renderer = chart.renderer,
  17908. options = axis.options,
  17909. isLinked = axis.isLinked,
  17910. tickPositions = axis.tickPositions,
  17911. axisTitle = axis.axisTitle,
  17912. ticks = axis.ticks,
  17913. minorTicks = axis.minorTicks,
  17914. alternateBands = axis.alternateBands,
  17915. stackLabelOptions = options.stackLabels,
  17916. alternateGridColor = options.alternateGridColor,
  17917. tickmarkOffset = axis.tickmarkOffset,
  17918. axisLine = axis.axisLine,
  17919. showAxis = axis.showAxis,
  17920. animation = animObject(renderer.globalAnimation),
  17921. from,
  17922. to;
  17923. // Reset
  17924. axis.labelEdge.length = 0;
  17925. axis.overlap = false;
  17926. // Mark all elements inActive before we go over and mark the active ones
  17927. [ticks, minorTicks, alternateBands].forEach(function (coll) {
  17928. objectEach(coll, function (tick) {
  17929. tick.isActive = false;
  17930. });
  17931. });
  17932. // If the series has data draw the ticks. Else only the line and title
  17933. if (axis.hasData() || isLinked) {
  17934. // minor ticks
  17935. if (axis.minorTickInterval && !axis.categories) {
  17936. axis.getMinorTickPositions().forEach(function (pos) {
  17937. axis.renderMinorTick(pos);
  17938. });
  17939. }
  17940. // Major ticks. Pull out the first item and render it last so that
  17941. // we can get the position of the neighbour label. #808.
  17942. if (tickPositions.length) { // #1300
  17943. tickPositions.forEach(function (pos, i) {
  17944. axis.renderTick(pos, i);
  17945. });
  17946. // In a categorized axis, the tick marks are displayed
  17947. // between labels. So we need to add a tick mark and
  17948. // grid line at the left edge of the X axis.
  17949. if (tickmarkOffset && (axis.min === 0 || axis.single)) {
  17950. if (!ticks[-1]) {
  17951. ticks[-1] = new Tick(axis, -1, null, true);
  17952. }
  17953. ticks[-1].render(-1);
  17954. }
  17955. }
  17956. // alternate grid color
  17957. if (alternateGridColor) {
  17958. tickPositions.forEach(function (pos, i) {
  17959. to = typeof tickPositions[i + 1] !== 'undefined' ?
  17960. tickPositions[i + 1] + tickmarkOffset :
  17961. axis.max - tickmarkOffset;
  17962. if (i % 2 === 0 &&
  17963. pos < axis.max &&
  17964. to <= axis.max + (chart.polar ?
  17965. -tickmarkOffset :
  17966. tickmarkOffset)) { // #2248, #4660
  17967. if (!alternateBands[pos]) {
  17968. // Should be imported from PlotLineOrBand.js, but
  17969. // the dependency cycle with axis is a problem
  17970. alternateBands[pos] = new H.PlotLineOrBand(axis);
  17971. }
  17972. from = pos + tickmarkOffset; // #949
  17973. alternateBands[pos].options = {
  17974. from: log ? log.lin2log(from) : from,
  17975. to: log ? log.lin2log(to) : to,
  17976. color: alternateGridColor,
  17977. className: 'highcharts-alternate-grid'
  17978. };
  17979. alternateBands[pos].render();
  17980. alternateBands[pos].isActive = true;
  17981. }
  17982. });
  17983. }
  17984. // custom plot lines and bands
  17985. if (!axis._addedPlotLB) { // only first time
  17986. axis._addedPlotLB = true;
  17987. (options.plotLines || [])
  17988. .concat(options.plotBands || [])
  17989. .forEach(function (plotLineOptions) {
  17990. axis.addPlotBandOrLine(plotLineOptions);
  17991. });
  17992. }
  17993. } // end if hasData
  17994. // Remove inactive ticks
  17995. [ticks, minorTicks, alternateBands].forEach(function (coll) {
  17996. var i,
  17997. forDestruction = [],
  17998. delay = animation.duration,
  17999. destroyInactiveItems = function () {
  18000. i = forDestruction.length;
  18001. while (i--) {
  18002. // When resizing rapidly, the same items
  18003. // may be destroyed in different timeouts,
  18004. // or the may be reactivated
  18005. if (coll[forDestruction[i]] &&
  18006. !coll[forDestruction[i]].isActive) {
  18007. coll[forDestruction[i]].destroy();
  18008. delete coll[forDestruction[i]];
  18009. }
  18010. }
  18011. };
  18012. objectEach(coll, function (tick, pos) {
  18013. if (!tick.isActive) {
  18014. // Render to zero opacity
  18015. tick.render(pos, false, 0);
  18016. tick.isActive = false;
  18017. forDestruction.push(pos);
  18018. }
  18019. });
  18020. // When the objects are finished fading out, destroy them
  18021. syncTimeout(destroyInactiveItems, coll === alternateBands ||
  18022. !chart.hasRendered ||
  18023. !delay ?
  18024. 0 :
  18025. delay);
  18026. });
  18027. // Set the axis line path
  18028. if (axisLine) {
  18029. axisLine[axisLine.isPlaced ? 'animate' : 'attr']({
  18030. d: this.getLinePath(axisLine.strokeWidth())
  18031. });
  18032. axisLine.isPlaced = true;
  18033. // Show or hide the line depending on options.showEmpty
  18034. axisLine[showAxis ? 'show' : 'hide'](showAxis);
  18035. }
  18036. if (axisTitle && showAxis) {
  18037. var titleXy = axis.getTitlePosition();
  18038. if (isNumber(titleXy.y)) {
  18039. axisTitle[axisTitle.isNew ? 'attr' : 'animate'](titleXy);
  18040. axisTitle.isNew = false;
  18041. }
  18042. else {
  18043. axisTitle.attr('y', -9999);
  18044. axisTitle.isNew = true;
  18045. }
  18046. }
  18047. // Stacked totals:
  18048. if (stackLabelOptions && stackLabelOptions.enabled && axis.stacking) {
  18049. axis.stacking.renderStackTotals();
  18050. }
  18051. // End stacked totals
  18052. // Record old scaling for updating/animation
  18053. axis.old = {
  18054. len: axis.len,
  18055. max: axis.max,
  18056. min: axis.min,
  18057. transA: axis.transA,
  18058. userMax: axis.userMax,
  18059. userMin: axis.userMin
  18060. };
  18061. axis.isDirty = false;
  18062. fireEvent(this, 'afterRender');
  18063. };
  18064. /**
  18065. * Redraw the axis to reflect changes in the data or axis extremes. Called
  18066. * internally from Highcharts.Chart#redraw.
  18067. *
  18068. * @private
  18069. * @function Highcharts.Axis#redraw
  18070. */
  18071. Axis.prototype.redraw = function () {
  18072. if (this.visible) {
  18073. // render the axis
  18074. this.render();
  18075. // move plot lines and bands
  18076. this.plotLinesAndBands.forEach(function (plotLine) {
  18077. plotLine.render();
  18078. });
  18079. }
  18080. // mark associated series as dirty and ready for redraw
  18081. this.series.forEach(function (series) {
  18082. series.isDirty = true;
  18083. });
  18084. };
  18085. /**
  18086. * Returns an array of axis properties, that should be untouched during
  18087. * reinitialization.
  18088. *
  18089. * @private
  18090. * @function Highcharts.Axis#getKeepProps
  18091. *
  18092. * @return {Array<string>}
  18093. */
  18094. Axis.prototype.getKeepProps = function () {
  18095. return (this.keepProps || Axis.keepProps);
  18096. };
  18097. /**
  18098. * Destroys an Axis instance. See {@link Axis#remove} for the API endpoint
  18099. * to fully remove the axis.
  18100. *
  18101. * @private
  18102. * @function Highcharts.Axis#destroy
  18103. *
  18104. * @param {boolean} [keepEvents]
  18105. * Whether to preserve events, used internally in Axis.update.
  18106. */
  18107. Axis.prototype.destroy = function (keepEvents) {
  18108. var axis = this,
  18109. plotLinesAndBands = axis.plotLinesAndBands,
  18110. plotGroup,
  18111. i;
  18112. fireEvent(this, 'destroy', { keepEvents: keepEvents });
  18113. // Remove the events
  18114. if (!keepEvents) {
  18115. removeEvent(axis);
  18116. }
  18117. // Destroy collections
  18118. [axis.ticks, axis.minorTicks, axis.alternateBands].forEach(function (coll) {
  18119. destroyObjectProperties(coll);
  18120. });
  18121. if (plotLinesAndBands) {
  18122. i = plotLinesAndBands.length;
  18123. while (i--) { // #1975
  18124. plotLinesAndBands[i].destroy();
  18125. }
  18126. }
  18127. // Destroy elements
  18128. ['axisLine', 'axisTitle', 'axisGroup',
  18129. 'gridGroup', 'labelGroup', 'cross', 'scrollbar'].forEach(function (prop) {
  18130. if (axis[prop]) {
  18131. axis[prop] = axis[prop].destroy();
  18132. }
  18133. });
  18134. // Destroy each generated group for plotlines and plotbands
  18135. for (plotGroup in axis.plotLinesAndBandsGroups) { // eslint-disable-line guard-for-in
  18136. axis.plotLinesAndBandsGroups[plotGroup] =
  18137. axis.plotLinesAndBandsGroups[plotGroup].destroy();
  18138. }
  18139. // Delete all properties and fall back to the prototype.
  18140. objectEach(axis, function (val, key) {
  18141. if (axis.getKeepProps().indexOf(key) === -1) {
  18142. delete axis[key];
  18143. }
  18144. });
  18145. };
  18146. /**
  18147. * Internal function to draw a crosshair.
  18148. *
  18149. * @function Highcharts.Axis#drawCrosshair
  18150. *
  18151. * @param {Highcharts.PointerEventObject} [e]
  18152. * The event arguments from the modified pointer event, extended with
  18153. * `chartX` and `chartY`
  18154. *
  18155. * @param {Highcharts.Point} [point]
  18156. * The Point object if the crosshair snaps to points.
  18157. *
  18158. * @fires Highcharts.Axis#event:afterDrawCrosshair
  18159. * @fires Highcharts.Axis#event:drawCrosshair
  18160. */
  18161. Axis.prototype.drawCrosshair = function (e, point) {
  18162. var path,
  18163. options = this.crosshair,
  18164. snap = pick(options && options.snap,
  18165. true),
  18166. pos,
  18167. categorized,
  18168. graphic = this.cross,
  18169. crossOptions,
  18170. chart = this.chart;
  18171. fireEvent(this, 'drawCrosshair', { e: e, point: point });
  18172. // Use last available event when updating non-snapped crosshairs without
  18173. // mouse interaction (#5287)
  18174. if (!e) {
  18175. e = this.cross && this.cross.e;
  18176. }
  18177. if (
  18178. // Disabled in options
  18179. !options ||
  18180. // Snap
  18181. ((defined(point) || !snap) === false)) {
  18182. this.hideCrosshair();
  18183. }
  18184. else {
  18185. // Get the path
  18186. if (!snap) {
  18187. pos = e &&
  18188. (this.horiz ?
  18189. e.chartX - this.pos :
  18190. this.len - e.chartY + this.pos);
  18191. }
  18192. else if (defined(point)) {
  18193. // #3834
  18194. pos = pick(this.coll !== 'colorAxis' ?
  18195. point.crosshairPos : // 3D axis extension
  18196. null, this.isXAxis ?
  18197. point.plotX :
  18198. this.len - point.plotY);
  18199. }
  18200. if (defined(pos)) {
  18201. crossOptions = {
  18202. // value, only used on radial
  18203. value: point && (this.isXAxis ?
  18204. point.x :
  18205. pick(point.stackY, point.y)),
  18206. translatedValue: pos
  18207. };
  18208. if (chart.polar) {
  18209. // Additional information required for crosshairs in
  18210. // polar chart
  18211. extend(crossOptions, {
  18212. isCrosshair: true,
  18213. chartX: e && e.chartX,
  18214. chartY: e && e.chartY,
  18215. point: point
  18216. });
  18217. }
  18218. path = this.getPlotLinePath(crossOptions) ||
  18219. null; // #3189
  18220. }
  18221. if (!defined(path)) {
  18222. this.hideCrosshair();
  18223. return;
  18224. }
  18225. categorized = this.categories && !this.isRadial;
  18226. // Draw the cross
  18227. if (!graphic) {
  18228. this.cross = graphic = chart.renderer
  18229. .path()
  18230. .addClass('highcharts-crosshair highcharts-crosshair-' +
  18231. (categorized ? 'category ' : 'thin ') +
  18232. (options.className || ''))
  18233. .attr({
  18234. zIndex: pick(options.zIndex, 2)
  18235. })
  18236. .add();
  18237. // Presentational attributes
  18238. if (!chart.styledMode) {
  18239. graphic.attr({
  18240. stroke: options.color ||
  18241. (categorized ?
  18242. Color
  18243. .parse(palette.highlightColor20)
  18244. .setOpacity(0.25)
  18245. .get() :
  18246. palette.neutralColor20),
  18247. 'stroke-width': pick(options.width, 1)
  18248. }).css({
  18249. 'pointer-events': 'none'
  18250. });
  18251. if (options.dashStyle) {
  18252. graphic.attr({
  18253. dashstyle: options.dashStyle
  18254. });
  18255. }
  18256. }
  18257. }
  18258. graphic.show().attr({
  18259. d: path
  18260. });
  18261. if (categorized && !options.width) {
  18262. graphic.attr({
  18263. 'stroke-width': this.transA
  18264. });
  18265. }
  18266. this.cross.e = e;
  18267. }
  18268. fireEvent(this, 'afterDrawCrosshair', { e: e, point: point });
  18269. };
  18270. /**
  18271. * Hide the crosshair if visible.
  18272. *
  18273. * @function Highcharts.Axis#hideCrosshair
  18274. */
  18275. Axis.prototype.hideCrosshair = function () {
  18276. if (this.cross) {
  18277. this.cross.hide();
  18278. }
  18279. fireEvent(this, 'afterHideCrosshair');
  18280. };
  18281. /**
  18282. * Check whether the chart has vertical panning ('y' or 'xy' type).
  18283. *
  18284. * @private
  18285. * @function Highcharts.Axis#hasVerticalPanning
  18286. * @return {boolean}
  18287. *
  18288. */
  18289. Axis.prototype.hasVerticalPanning = function () {
  18290. var panningOptions = this.chart.options.chart.panning;
  18291. return Boolean(panningOptions &&
  18292. panningOptions.enabled && // #14624
  18293. /y/.test(panningOptions.type));
  18294. };
  18295. /**
  18296. * Check whether the given value is a positive valid axis value.
  18297. *
  18298. * @private
  18299. * @function Highcharts.Axis#validatePositiveValue
  18300. *
  18301. * @param {unknown} value
  18302. * The axis value
  18303. *
  18304. * @return {boolean}
  18305. */
  18306. Axis.prototype.validatePositiveValue = function (value) {
  18307. return isNumber(value) && value > 0;
  18308. };
  18309. /**
  18310. * Update an axis object with a new set of options. The options are merged
  18311. * with the existing options, so only new or altered options need to be
  18312. * specified.
  18313. *
  18314. * @sample highcharts/members/axis-update/
  18315. * Axis update demo
  18316. *
  18317. * @function Highcharts.Axis#update
  18318. *
  18319. * @param {Highcharts.AxisOptions} options
  18320. * The new options that will be merged in with existing options on
  18321. * the axis.
  18322. *
  18323. * @param {boolean} [redraw=true]
  18324. * Whether to redraw the chart after the axis is altered. If doing
  18325. * more operations on the chart, it is a good idea to set redraw to
  18326. * false and call {@link Chart#redraw} after.
  18327. */
  18328. Axis.prototype.update = function (options, redraw) {
  18329. var chart = this.chart,
  18330. newEvents = ((options && options.events) || {});
  18331. options = merge(this.userOptions, options);
  18332. // Remove old events, if no new exist (#8161)
  18333. objectEach(chart.options[this.coll].events, function (fn, ev) {
  18334. if (typeof newEvents[ev] === 'undefined') {
  18335. newEvents[ev] = void 0;
  18336. }
  18337. });
  18338. this.destroy(true);
  18339. this.init(chart, extend(options, { events: newEvents }));
  18340. chart.isDirtyBox = true;
  18341. if (pick(redraw, true)) {
  18342. chart.redraw();
  18343. }
  18344. };
  18345. /**
  18346. * Remove the axis from the chart.
  18347. *
  18348. * @sample highcharts/members/chart-addaxis/
  18349. * Add and remove axes
  18350. *
  18351. * @function Highcharts.Axis#remove
  18352. *
  18353. * @param {boolean} [redraw=true]
  18354. * Whether to redraw the chart following the remove.
  18355. */
  18356. Axis.prototype.remove = function (redraw) {
  18357. var chart = this.chart,
  18358. key = this.coll, // xAxis or yAxis
  18359. axisSeries = this.series,
  18360. i = axisSeries.length;
  18361. // Remove associated series (#2687)
  18362. while (i--) {
  18363. if (axisSeries[i]) {
  18364. axisSeries[i].remove(false);
  18365. }
  18366. }
  18367. // Remove the axis
  18368. erase(chart.axes, this);
  18369. erase(chart[key], this);
  18370. chart[key].forEach(function (axis, i) {
  18371. // Re-index, #1706, #8075
  18372. axis.options.index = axis.userOptions.index = i;
  18373. });
  18374. this.destroy();
  18375. chart.isDirtyBox = true;
  18376. if (pick(redraw, true)) {
  18377. chart.redraw();
  18378. }
  18379. };
  18380. /**
  18381. * Update the axis title by options after render time.
  18382. *
  18383. * @sample highcharts/members/axis-settitle/
  18384. * Set a new Y axis title
  18385. *
  18386. * @function Highcharts.Axis#setTitle
  18387. *
  18388. * @param {Highcharts.AxisTitleOptions} titleOptions
  18389. * The additional title options.
  18390. *
  18391. * @param {boolean} [redraw=true]
  18392. * Whether to redraw the chart after setting the title.
  18393. *
  18394. * @return {void}
  18395. */
  18396. Axis.prototype.setTitle = function (titleOptions, redraw) {
  18397. this.update({ title: titleOptions }, redraw);
  18398. };
  18399. /**
  18400. * Set new axis categories and optionally redraw.
  18401. *
  18402. * @sample highcharts/members/axis-setcategories/
  18403. * Set categories by click on a button
  18404. *
  18405. * @function Highcharts.Axis#setCategories
  18406. *
  18407. * @param {Array<string>} categories
  18408. * The new categories.
  18409. *
  18410. * @param {boolean} [redraw=true]
  18411. * Whether to redraw the chart.
  18412. */
  18413. Axis.prototype.setCategories = function (categories, redraw) {
  18414. this.update({ categories: categories }, redraw);
  18415. };
  18416. /* *
  18417. *
  18418. * Static Properties
  18419. *
  18420. * */
  18421. /**
  18422. * The X axis or category axis. Normally this is the horizontal axis,
  18423. * though if the chart is inverted this is the vertical axis. In case of
  18424. * multiple axes, the xAxis node is an array of configuration objects.
  18425. *
  18426. * See the [Axis class](/class-reference/Highcharts.Axis) for programmatic
  18427. * access to the axis.
  18428. *
  18429. * @productdesc {highmaps}
  18430. * In Highmaps, the axis is hidden, but it is used behind the scenes to
  18431. * control features like zooming and panning. Zooming is in effect the same
  18432. * as setting the extremes of one of the exes.
  18433. *
  18434. * @type {*|Array<*>}
  18435. * @optionparent xAxis
  18436. *
  18437. * @private
  18438. */
  18439. Axis.defaultOptions = {
  18440. /**
  18441. * When using multiple axis, the ticks of two or more opposite axes
  18442. * will automatically be aligned by adding ticks to the axis or axes
  18443. * with the least ticks, as if `tickAmount` were specified.
  18444. *
  18445. * This can be prevented by setting `alignTicks` to false. If the grid
  18446. * lines look messy, it's a good idea to hide them for the secondary
  18447. * axis by setting `gridLineWidth` to 0.
  18448. *
  18449. * If `startOnTick` or `endOnTick` in an Axis options are set to false,
  18450. * then the `alignTicks ` will be disabled for the Axis.
  18451. *
  18452. * Disabled for logarithmic axes.
  18453. *
  18454. * @product highcharts highstock gantt
  18455. */
  18456. alignTicks: true,
  18457. /**
  18458. * Whether to allow decimals in this axis' ticks. When counting
  18459. * integers, like persons or hits on a web page, decimals should
  18460. * be avoided in the labels. By default, decimals are allowed on small
  18461. * scale axes.
  18462. *
  18463. * @see [minTickInterval](#xAxis.minTickInterval)
  18464. *
  18465. * @sample {highcharts|highstock} highcharts/yaxis/allowdecimals-true/
  18466. * True by default
  18467. * @sample {highcharts|highstock} highcharts/yaxis/allowdecimals-false/
  18468. * False
  18469. *
  18470. * @type {boolean|undefined}
  18471. * @default undefined
  18472. * @since 2.0
  18473. */
  18474. allowDecimals: void 0,
  18475. /**
  18476. * When using an alternate grid color, a band is painted across the
  18477. * plot area between every other grid line.
  18478. *
  18479. * @sample {highcharts} highcharts/yaxis/alternategridcolor/
  18480. * Alternate grid color on the Y axis
  18481. * @sample {highstock} stock/xaxis/alternategridcolor/
  18482. * Alternate grid color on the Y axis
  18483. *
  18484. * @type {Highcharts.ColorType}
  18485. * @apioption xAxis.alternateGridColor
  18486. */
  18487. /**
  18488. * An array defining breaks in the axis, the sections defined will be
  18489. * left out and all the points shifted closer to each other.
  18490. *
  18491. * @productdesc {highcharts}
  18492. * Requires that the broken-axis.js module is loaded.
  18493. *
  18494. * @sample {highcharts} highcharts/axisbreak/break-simple/
  18495. * Simple break
  18496. * @sample {highcharts|highstock} highcharts/axisbreak/break-visualized/
  18497. * Advanced with callback
  18498. * @sample {highstock} stock/demo/intraday-breaks/
  18499. * Break on nights and weekends
  18500. *
  18501. * @type {Array<*>}
  18502. * @since 4.1.0
  18503. * @product highcharts highstock gantt
  18504. * @apioption xAxis.breaks
  18505. */
  18506. /**
  18507. * A number indicating how much space should be left between the start
  18508. * and the end of the break. The break size is given in axis units,
  18509. * so for instance on a `datetime` axis, a break size of 3600000 would
  18510. * indicate the equivalent of an hour.
  18511. *
  18512. * @type {number}
  18513. * @default 0
  18514. * @since 4.1.0
  18515. * @product highcharts highstock gantt
  18516. * @apioption xAxis.breaks.breakSize
  18517. */
  18518. /**
  18519. * The point where the break starts.
  18520. *
  18521. * @type {number}
  18522. * @since 4.1.0
  18523. * @product highcharts highstock gantt
  18524. * @apioption xAxis.breaks.from
  18525. */
  18526. /**
  18527. * Defines an interval after which the break appears again. By default
  18528. * the breaks do not repeat.
  18529. *
  18530. * @type {number}
  18531. * @default 0
  18532. * @since 4.1.0
  18533. * @product highcharts highstock gantt
  18534. * @apioption xAxis.breaks.repeat
  18535. */
  18536. /**
  18537. * The point where the break ends.
  18538. *
  18539. * @type {number}
  18540. * @since 4.1.0
  18541. * @product highcharts highstock gantt
  18542. * @apioption xAxis.breaks.to
  18543. */
  18544. /**
  18545. * If categories are present for the xAxis, names are used instead of
  18546. * numbers for that axis.
  18547. *
  18548. * Since Highcharts 3.0, categories can also
  18549. * be extracted by giving each point a [name](#series.data) and setting
  18550. * axis [type](#xAxis.type) to `category`. However, if you have multiple
  18551. * series, best practice remains defining the `categories` array.
  18552. *
  18553. * Example: `categories: ['Apples', 'Bananas', 'Oranges']`
  18554. *
  18555. * @sample {highcharts} highcharts/demo/line-labels/
  18556. * With
  18557. * @sample {highcharts} highcharts/xaxis/categories/
  18558. * Without
  18559. *
  18560. * @type {Array<string>}
  18561. * @product highcharts gantt
  18562. * @apioption xAxis.categories
  18563. */
  18564. /**
  18565. * The highest allowed value for automatically computed axis extremes.
  18566. *
  18567. * @see [floor](#xAxis.floor)
  18568. *
  18569. * @sample {highcharts|highstock} highcharts/yaxis/floor-ceiling/
  18570. * Floor and ceiling
  18571. *
  18572. * @type {number}
  18573. * @since 4.0
  18574. * @product highcharts highstock gantt
  18575. * @apioption xAxis.ceiling
  18576. */
  18577. /**
  18578. * A class name that opens for styling the axis by CSS, especially in
  18579. * Highcharts styled mode. The class name is applied to group elements
  18580. * for the grid, axis elements and labels.
  18581. *
  18582. * @sample {highcharts|highstock|highmaps} highcharts/css/axis/
  18583. * Multiple axes with separate styling
  18584. *
  18585. * @type {string}
  18586. * @since 5.0.0
  18587. * @apioption xAxis.className
  18588. */
  18589. /**
  18590. * Configure a crosshair that follows either the mouse pointer or the
  18591. * hovered point.
  18592. *
  18593. * In styled mode, the crosshairs are styled in the
  18594. * `.highcharts-crosshair`, `.highcharts-crosshair-thin` or
  18595. * `.highcharts-xaxis-category` classes.
  18596. *
  18597. * @productdesc {highstock}
  18598. * In Highcharts stock, by default, the crosshair is enabled on the
  18599. * X axis and disabled on the Y axis.
  18600. *
  18601. * @sample {highcharts} highcharts/xaxis/crosshair-both/
  18602. * Crosshair on both axes
  18603. * @sample {highstock} stock/xaxis/crosshairs-xy/
  18604. * Crosshair on both axes
  18605. * @sample {highmaps} highcharts/xaxis/crosshair-both/
  18606. * Crosshair on both axes
  18607. *
  18608. * @declare Highcharts.AxisCrosshairOptions
  18609. * @type {boolean|*}
  18610. * @default false
  18611. * @since 4.1
  18612. * @apioption xAxis.crosshair
  18613. */
  18614. /**
  18615. * A class name for the crosshair, especially as a hook for styling.
  18616. *
  18617. * @type {string}
  18618. * @since 5.0.0
  18619. * @apioption xAxis.crosshair.className
  18620. */
  18621. /**
  18622. * The color of the crosshair. Defaults to `#cccccc` for numeric and
  18623. * datetime axes, and `rgba(204,214,235,0.25)` for category axes, where
  18624. * the crosshair by default highlights the whole category.
  18625. *
  18626. * @sample {highcharts|highstock|highmaps} highcharts/xaxis/crosshair-customized/
  18627. * Customized crosshairs
  18628. *
  18629. * @type {Highcharts.ColorType}
  18630. * @default #cccccc
  18631. * @since 4.1
  18632. * @apioption xAxis.crosshair.color
  18633. */
  18634. /**
  18635. * The dash style for the crosshair. See
  18636. * [plotOptions.series.dashStyle](#plotOptions.series.dashStyle)
  18637. * for possible values.
  18638. *
  18639. * @sample {highcharts|highmaps} highcharts/xaxis/crosshair-dotted/
  18640. * Dotted crosshair
  18641. * @sample {highstock} stock/xaxis/crosshair-dashed/
  18642. * Dashed X axis crosshair
  18643. *
  18644. * @type {Highcharts.DashStyleValue}
  18645. * @default Solid
  18646. * @since 4.1
  18647. * @apioption xAxis.crosshair.dashStyle
  18648. */
  18649. /**
  18650. * A label on the axis next to the crosshair.
  18651. *
  18652. * In styled mode, the label is styled with the
  18653. * `.highcharts-crosshair-label` class.
  18654. *
  18655. * @sample {highstock} stock/xaxis/crosshair-label/
  18656. * Crosshair labels
  18657. * @sample {highstock} highcharts/css/crosshair-label/
  18658. * Style mode
  18659. *
  18660. * @declare Highcharts.AxisCrosshairLabelOptions
  18661. * @since 2.1
  18662. * @product highstock
  18663. * @apioption xAxis.crosshair.label
  18664. */
  18665. /**
  18666. * Alignment of the label compared to the axis. Defaults to `"left"` for
  18667. * right-side axes, `"right"` for left-side axes and `"center"` for
  18668. * horizontal axes.
  18669. *
  18670. * @type {Highcharts.AlignValue}
  18671. * @since 2.1
  18672. * @product highstock
  18673. * @apioption xAxis.crosshair.label.align
  18674. */
  18675. /**
  18676. * The background color for the label. Defaults to the related series
  18677. * color, or `#666666` if that is not available.
  18678. *
  18679. * @type {Highcharts.ColorType}
  18680. * @since 2.1
  18681. * @product highstock
  18682. * @apioption xAxis.crosshair.label.backgroundColor
  18683. */
  18684. /**
  18685. * The border color for the crosshair label
  18686. *
  18687. * @type {Highcharts.ColorType}
  18688. * @since 2.1
  18689. * @product highstock
  18690. * @apioption xAxis.crosshair.label.borderColor
  18691. */
  18692. /**
  18693. * The border corner radius of the crosshair label.
  18694. *
  18695. * @type {number}
  18696. * @default 3
  18697. * @since 2.1.10
  18698. * @product highstock
  18699. * @apioption xAxis.crosshair.label.borderRadius
  18700. */
  18701. /**
  18702. * The border width for the crosshair label.
  18703. *
  18704. * @type {number}
  18705. * @default 0
  18706. * @since 2.1
  18707. * @product highstock
  18708. * @apioption xAxis.crosshair.label.borderWidth
  18709. */
  18710. /**
  18711. * Flag to enable crosshair's label.
  18712. *
  18713. * @sample {highstock} stock/xaxis/crosshairs-xy/
  18714. * Enabled label for yAxis' crosshair
  18715. *
  18716. * @type {boolean}
  18717. * @default false
  18718. * @since 2.1
  18719. * @product highstock
  18720. * @apioption xAxis.crosshair.label.enabled
  18721. */
  18722. /**
  18723. * A format string for the crosshair label. Defaults to `{value}` for
  18724. * numeric axes and `{value:%b %d, %Y}` for datetime axes.
  18725. *
  18726. * @type {string}
  18727. * @since 2.1
  18728. * @product highstock
  18729. * @apioption xAxis.crosshair.label.format
  18730. */
  18731. /**
  18732. * Formatter function for the label text.
  18733. *
  18734. * @type {Highcharts.XAxisCrosshairLabelFormatterCallbackFunction}
  18735. * @since 2.1
  18736. * @product highstock
  18737. * @apioption xAxis.crosshair.label.formatter
  18738. */
  18739. /**
  18740. * Padding inside the crosshair label.
  18741. *
  18742. * @type {number}
  18743. * @default 8
  18744. * @since 2.1
  18745. * @product highstock
  18746. * @apioption xAxis.crosshair.label.padding
  18747. */
  18748. /**
  18749. * The shape to use for the label box.
  18750. *
  18751. * @type {string}
  18752. * @default callout
  18753. * @since 2.1
  18754. * @product highstock
  18755. * @apioption xAxis.crosshair.label.shape
  18756. */
  18757. /**
  18758. * Text styles for the crosshair label.
  18759. *
  18760. * @type {Highcharts.CSSObject}
  18761. * @default {"color": "white", "fontWeight": "normal", "fontSize": "11px", "textAlign": "center"}
  18762. * @since 2.1
  18763. * @product highstock
  18764. * @apioption xAxis.crosshair.label.style
  18765. */
  18766. /**
  18767. * Whether the crosshair should snap to the point or follow the pointer
  18768. * independent of points.
  18769. *
  18770. * @sample {highcharts|highstock} highcharts/xaxis/crosshair-snap-false/
  18771. * True by default
  18772. * @sample {highmaps} maps/demo/latlon-advanced/
  18773. * Snap is false
  18774. *
  18775. * @type {boolean}
  18776. * @default true
  18777. * @since 4.1
  18778. * @apioption xAxis.crosshair.snap
  18779. */
  18780. /**
  18781. * The pixel width of the crosshair. Defaults to 1 for numeric or
  18782. * datetime axes, and for one category width for category axes.
  18783. *
  18784. * @sample {highcharts} highcharts/xaxis/crosshair-customized/
  18785. * Customized crosshairs
  18786. * @sample {highstock} highcharts/xaxis/crosshair-customized/
  18787. * Customized crosshairs
  18788. * @sample {highmaps} highcharts/xaxis/crosshair-customized/
  18789. * Customized crosshairs
  18790. *
  18791. * @type {number}
  18792. * @default 1
  18793. * @since 4.1
  18794. * @apioption xAxis.crosshair.width
  18795. */
  18796. /**
  18797. * The Z index of the crosshair. Higher Z indices allow drawing the
  18798. * crosshair on top of the series or behind the grid lines.
  18799. *
  18800. * @type {number}
  18801. * @default 2
  18802. * @since 4.1
  18803. * @apioption xAxis.crosshair.zIndex
  18804. */
  18805. /**
  18806. * The Z index for the axis group.
  18807. */
  18808. zIndex: 2,
  18809. /**
  18810. * Whether to zoom axis. If `chart.zoomType` is set, the option allows
  18811. * to disable zooming on an individual axis.
  18812. *
  18813. * @sample {highcharts} highcharts/xaxis/zoomenabled/
  18814. * Zoom enabled is false
  18815. */
  18816. zoomEnabled: true,
  18817. /**
  18818. * For a datetime axis, the scale will automatically adjust to the
  18819. * appropriate unit. This member gives the default string
  18820. * representations used for each unit. For intermediate values,
  18821. * different units may be used, for example the `day` unit can be used
  18822. * on midnight and `hour` unit be used for intermediate values on the
  18823. * same axis.
  18824. *
  18825. * For an overview of the replacement codes, see
  18826. * [dateFormat](/class-reference/Highcharts#.dateFormat).
  18827. *
  18828. * Defaults to:
  18829. * ```js
  18830. * {
  18831. * millisecond: '%H:%M:%S.%L',
  18832. * second: '%H:%M:%S',
  18833. * minute: '%H:%M',
  18834. * hour: '%H:%M',
  18835. * day: '%e. %b',
  18836. * week: '%e. %b',
  18837. * month: '%b \'%y',
  18838. * year: '%Y'
  18839. * }
  18840. * ```
  18841. *
  18842. * @sample {highcharts} highcharts/xaxis/datetimelabelformats/
  18843. * Different day format on X axis
  18844. * @sample {highstock} stock/xaxis/datetimelabelformats/
  18845. * More information in x axis labels
  18846. *
  18847. * @declare Highcharts.AxisDateTimeLabelFormatsOptions
  18848. * @product highcharts highstock gantt
  18849. */
  18850. dateTimeLabelFormats: {
  18851. /**
  18852. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  18853. * @type {string|*}
  18854. */
  18855. millisecond: {
  18856. main: '%H:%M:%S.%L',
  18857. range: false
  18858. },
  18859. /**
  18860. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  18861. * @type {string|*}
  18862. */
  18863. second: {
  18864. main: '%H:%M:%S',
  18865. range: false
  18866. },
  18867. /**
  18868. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  18869. * @type {string|*}
  18870. */
  18871. minute: {
  18872. main: '%H:%M',
  18873. range: false
  18874. },
  18875. /**
  18876. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  18877. * @type {string|*}
  18878. */
  18879. hour: {
  18880. main: '%H:%M',
  18881. range: false
  18882. },
  18883. /**
  18884. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  18885. * @type {string|*}
  18886. */
  18887. day: {
  18888. main: '%e. %b'
  18889. },
  18890. /**
  18891. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  18892. * @type {string|*}
  18893. */
  18894. week: {
  18895. main: '%e. %b'
  18896. },
  18897. /**
  18898. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  18899. * @type {string|*}
  18900. */
  18901. month: {
  18902. main: '%b \'%y'
  18903. },
  18904. /**
  18905. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  18906. * @type {string|*}
  18907. */
  18908. year: {
  18909. main: '%Y'
  18910. }
  18911. },
  18912. /**
  18913. * Whether to force the axis to end on a tick. Use this option with
  18914. * the `maxPadding` option to control the axis end.
  18915. *
  18916. * @productdesc {highstock}
  18917. * In Highcharts Stock, `endOnTick` is always `false` when the navigator
  18918. * is enabled, to prevent jumpy scrolling.
  18919. *
  18920. * @sample {highcharts} highcharts/chart/reflow-true/
  18921. * True by default
  18922. * @sample {highcharts} highcharts/yaxis/endontick/
  18923. * False
  18924. * @sample {highstock} stock/demo/basic-line/
  18925. * True by default
  18926. * @sample {highstock} stock/xaxis/endontick/
  18927. * False
  18928. *
  18929. * @since 1.2.0
  18930. */
  18931. endOnTick: false,
  18932. /**
  18933. * Event handlers for the axis.
  18934. *
  18935. * @type {*}
  18936. * @apioption xAxis.events
  18937. */
  18938. /**
  18939. * An event fired after the breaks have rendered.
  18940. *
  18941. * @see [breaks](#xAxis.breaks)
  18942. *
  18943. * @sample {highcharts} highcharts/axisbreak/break-event/
  18944. * AfterBreak Event
  18945. *
  18946. * @type {Highcharts.AxisEventCallbackFunction}
  18947. * @since 4.1.0
  18948. * @product highcharts gantt
  18949. * @apioption xAxis.events.afterBreaks
  18950. */
  18951. /**
  18952. * As opposed to the `setExtremes` event, this event fires after the
  18953. * final min and max values are computed and corrected for `minRange`.
  18954. *
  18955. * Fires when the minimum and maximum is set for the axis, either by
  18956. * calling the `.setExtremes()` method or by selecting an area in the
  18957. * chart. One parameter, `event`, is passed to the function, containing
  18958. * common event information.
  18959. *
  18960. * The new user set minimum and maximum values can be found by
  18961. * `event.min` and `event.max`. These reflect the axis minimum and
  18962. * maximum in axis values. The actual data extremes are found in
  18963. * `event.dataMin` and `event.dataMax`.
  18964. *
  18965. * @type {Highcharts.AxisSetExtremesEventCallbackFunction}
  18966. * @since 2.3
  18967. * @context Highcharts.Axis
  18968. * @apioption xAxis.events.afterSetExtremes
  18969. */
  18970. /**
  18971. * An event fired when a break from this axis occurs on a point.
  18972. *
  18973. * @see [breaks](#xAxis.breaks)
  18974. *
  18975. * @sample {highcharts} highcharts/axisbreak/break-visualized/
  18976. * Visualization of a Break
  18977. *
  18978. * @type {Highcharts.AxisPointBreakEventCallbackFunction}
  18979. * @since 4.1.0
  18980. * @product highcharts gantt
  18981. * @context Highcharts.Axis
  18982. * @apioption xAxis.events.pointBreak
  18983. */
  18984. /**
  18985. * An event fired when a point falls inside a break from this axis.
  18986. *
  18987. * @type {Highcharts.AxisPointBreakEventCallbackFunction}
  18988. * @product highcharts highstock gantt
  18989. * @context Highcharts.Axis
  18990. * @apioption xAxis.events.pointInBreak
  18991. */
  18992. /**
  18993. * Fires when the minimum and maximum is set for the axis, either by
  18994. * calling the `.setExtremes()` method or by selecting an area in the
  18995. * chart. One parameter, `event`, is passed to the function,
  18996. * containing common event information.
  18997. *
  18998. * The new user set minimum and maximum values can be found by
  18999. * `event.min` and `event.max`. These reflect the axis minimum and
  19000. * maximum in data values. When an axis is zoomed all the way out from
  19001. * the "Reset zoom" button, `event.min` and `event.max` are null, and
  19002. * the new extremes are set based on `this.dataMin` and `this.dataMax`.
  19003. *
  19004. * @sample {highstock} stock/xaxis/events-setextremes/
  19005. * Log new extremes on x axis
  19006. *
  19007. * @type {Highcharts.AxisSetExtremesEventCallbackFunction}
  19008. * @since 1.2.0
  19009. * @context Highcharts.Axis
  19010. * @apioption xAxis.events.setExtremes
  19011. */
  19012. /**
  19013. * The lowest allowed value for automatically computed axis extremes.
  19014. *
  19015. * @see [ceiling](#yAxis.ceiling)
  19016. *
  19017. * @sample {highcharts} highcharts/yaxis/floor-ceiling/
  19018. * Floor and ceiling
  19019. * @sample {highstock} stock/demo/lazy-loading/
  19020. * Prevent negative stock price on Y axis
  19021. *
  19022. * @type {number}
  19023. * @since 4.0
  19024. * @product highcharts highstock gantt
  19025. * @apioption xAxis.floor
  19026. */
  19027. /**
  19028. * The dash or dot style of the grid lines. For possible values, see
  19029. * [this demonstration](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-dashstyle-all/).
  19030. *
  19031. * @sample {highcharts} highcharts/yaxis/gridlinedashstyle/
  19032. * Long dashes
  19033. * @sample {highstock} stock/xaxis/gridlinedashstyle/
  19034. * Long dashes
  19035. *
  19036. * @type {Highcharts.DashStyleValue}
  19037. * @since 1.2
  19038. */
  19039. gridLineDashStyle: 'Solid',
  19040. /**
  19041. * The Z index of the grid lines.
  19042. *
  19043. * @sample {highcharts|highstock} highcharts/xaxis/gridzindex/
  19044. * A Z index of 4 renders the grid above the graph
  19045. *
  19046. * @product highcharts highstock gantt
  19047. */
  19048. gridZIndex: 1,
  19049. /**
  19050. * An id for the axis. This can be used after render time to get
  19051. * a pointer to the axis object through `chart.get()`.
  19052. *
  19053. * @sample {highcharts} highcharts/xaxis/id/
  19054. * Get the object
  19055. * @sample {highstock} stock/xaxis/id/
  19056. * Get the object
  19057. *
  19058. * @type {string}
  19059. * @since 1.2.0
  19060. * @apioption xAxis.id
  19061. */
  19062. /**
  19063. * The axis labels show the number or category for each tick.
  19064. *
  19065. * Since v8.0.0: Labels are animated in categorized x-axis with
  19066. * updating data if `tickInterval` and `step` is set to 1.
  19067. *
  19068. * @productdesc {highmaps}
  19069. * X and Y axis labels are by default disabled in Highmaps, but the
  19070. * functionality is inherited from Highcharts and used on `colorAxis`,
  19071. * and can be enabled on X and Y axes too.
  19072. */
  19073. labels: {
  19074. /**
  19075. * What part of the string the given position is anchored to.
  19076. * If `left`, the left side of the string is at the axis position.
  19077. * Can be one of `"left"`, `"center"` or `"right"`. Defaults to
  19078. * an intelligent guess based on which side of the chart the axis
  19079. * is on and the rotation of the label.
  19080. *
  19081. * @see [reserveSpace](#xAxis.labels.reserveSpace)
  19082. *
  19083. * @sample {highcharts} highcharts/xaxis/labels-align-left/
  19084. * Left
  19085. * @sample {highcharts} highcharts/xaxis/labels-align-right/
  19086. * Right
  19087. * @sample {highcharts} highcharts/xaxis/labels-reservespace-true/
  19088. * Left-aligned labels on a vertical category axis
  19089. *
  19090. * @type {Highcharts.AlignValue}
  19091. * @apioption xAxis.labels.align
  19092. */
  19093. /**
  19094. * Whether to allow the axis labels to overlap.
  19095. * When false, overlapping labels are hidden.
  19096. *
  19097. * @sample {highcharts} highcharts/xaxis/labels-allowoverlap-true/
  19098. * X axis labels overlap enabled
  19099. *
  19100. * @type {boolean}
  19101. * @default false
  19102. * @apioption xAxis.labels.allowOverlap
  19103. *
  19104. */
  19105. /**
  19106. * For horizontal axes, the allowed degrees of label rotation
  19107. * to prevent overlapping labels. If there is enough space,
  19108. * labels are not rotated. As the chart gets narrower, it
  19109. * will start rotating the labels -45 degrees, then remove
  19110. * every second label and try again with rotations 0 and -45 etc.
  19111. * Set it to `undefined` to disable rotation, which will
  19112. * cause the labels to word-wrap if possible. Defaults to `[-45]``
  19113. * on bottom and top axes, `undefined` on left and right axes.
  19114. *
  19115. * @sample {highcharts|highstock} highcharts/xaxis/labels-autorotation-default/
  19116. * Default auto rotation of 0 or -45
  19117. * @sample {highcharts|highstock} highcharts/xaxis/labels-autorotation-0-90/
  19118. * Custom graded auto rotation
  19119. *
  19120. * @type {Array<number>}
  19121. * @default undefined
  19122. * @since 4.1.0
  19123. * @product highcharts highstock gantt
  19124. * @apioption xAxis.labels.autoRotation
  19125. */
  19126. autoRotation: void 0,
  19127. /**
  19128. * When each category width is more than this many pixels, we don't
  19129. * apply auto rotation. Instead, we lay out the axis label with word
  19130. * wrap. A lower limit makes sense when the label contains multiple
  19131. * short words that don't extend the available horizontal space for
  19132. * each label.
  19133. *
  19134. * @sample {highcharts} highcharts/xaxis/labels-autorotationlimit/
  19135. * Lower limit
  19136. *
  19137. * @since 4.1.5
  19138. * @product highcharts gantt
  19139. */
  19140. autoRotationLimit: 80,
  19141. /**
  19142. * Polar charts only. The label's pixel distance from the perimeter
  19143. * of the plot area.
  19144. *
  19145. * @type {number}
  19146. * @default undefined
  19147. * @product highcharts gantt
  19148. */
  19149. distance: void 0,
  19150. /**
  19151. * Enable or disable the axis labels.
  19152. *
  19153. * @sample {highcharts} highcharts/xaxis/labels-enabled/
  19154. * X axis labels disabled
  19155. * @sample {highstock} stock/xaxis/labels-enabled/
  19156. * X axis labels disabled
  19157. *
  19158. * @default {highcharts|highstock|gantt} true
  19159. * @default {highmaps} false
  19160. */
  19161. enabled: true,
  19162. /**
  19163. * A format string for the axis label. The context is available as
  19164. * format string variables. For example, you can use `{text}` to
  19165. * insert the default formatted text. The recommended way of adding
  19166. * units for the label is using `text`, for example `{text} km`.
  19167. *
  19168. * To add custom numeric or datetime formatting, use `{value}` with
  19169. * formatting, for example `{value:.1f}` or `{value:%Y-%m-%d}`.
  19170. *
  19171. * See
  19172. * [format string](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting)
  19173. * for more examples of formatting.
  19174. *
  19175. * The default value is not specified due to the dynamic
  19176. * nature of the default implementation.
  19177. *
  19178. * @sample {highcharts|highstock} highcharts/yaxis/labels-format/
  19179. * Add units to Y axis label
  19180. * @sample {highcharts} highcharts/xaxis/labels-format-linked/
  19181. * Linked category names
  19182. * @sample {highcharts} highcharts/xaxis/labels-format-custom/
  19183. * Custom number format
  19184. *
  19185. * @type {string}
  19186. * @since 3.0
  19187. * @apioption xAxis.labels.format
  19188. */
  19189. /**
  19190. * Callback JavaScript function to format the label. The value
  19191. * is given by `this.value`. Additional properties for `this` are
  19192. * `axis`, `chart`, `isFirst`, `isLast` and `text` which holds the
  19193. * value of the default formatter.
  19194. *
  19195. * Defaults to a built in function returning a formatted string
  19196. * depending on whether the axis is `category`, `datetime`,
  19197. * `numeric` or other.
  19198. *
  19199. * @sample {highcharts} highcharts/xaxis/labels-formatter-linked/
  19200. * Linked category names
  19201. * @sample {highcharts} highcharts/xaxis/labels-formatter-extended/
  19202. * Modified numeric labels
  19203. * @sample {highstock} stock/xaxis/labels-formatter/
  19204. * Added units on Y axis
  19205. *
  19206. * @type {Highcharts.AxisLabelsFormatterCallbackFunction}
  19207. * @apioption xAxis.labels.formatter
  19208. */
  19209. /**
  19210. * The number of pixels to indent the labels per level in a treegrid
  19211. * axis.
  19212. *
  19213. * @sample gantt/treegrid-axis/demo
  19214. * Indentation 10px by default.
  19215. * @sample gantt/treegrid-axis/indentation-0px
  19216. * Indentation set to 0px.
  19217. *
  19218. * @product gantt
  19219. */
  19220. indentation: 10,
  19221. /**
  19222. * Horizontal axis only. When `staggerLines` is not set,
  19223. * `maxStaggerLines` defines how many lines the axis is allowed to
  19224. * add to automatically avoid overlapping X labels. Set to `1` to
  19225. * disable overlap detection.
  19226. *
  19227. * @deprecated
  19228. * @type {number}
  19229. * @default 5
  19230. * @since 1.3.3
  19231. * @apioption xAxis.labels.maxStaggerLines
  19232. */
  19233. /**
  19234. * How to handle overflowing labels on horizontal axis. If set to
  19235. * `"allow"`, it will not be aligned at all. By default it
  19236. * `"justify"` labels inside the chart area. If there is room to
  19237. * move it, it will be aligned to the edge, else it will be removed.
  19238. *
  19239. * @since 2.2.5
  19240. * @validvalue ["allow", "justify"]
  19241. */
  19242. overflow: 'justify',
  19243. /**
  19244. * The pixel padding for axis labels, to ensure white space between
  19245. * them.
  19246. *
  19247. * @product highcharts gantt
  19248. */
  19249. padding: 5,
  19250. /**
  19251. * Whether to reserve space for the labels. By default, space is
  19252. * reserved for the labels in these cases:
  19253. *
  19254. * * On all horizontal axes.
  19255. * * On vertical axes if `label.align` is `right` on a left-side
  19256. * axis or `left` on a right-side axis.
  19257. * * On vertical axes if `label.align` is `center`.
  19258. *
  19259. * This can be turned off when for example the labels are rendered
  19260. * inside the plot area instead of outside.
  19261. *
  19262. * @see [labels.align](#xAxis.labels.align)
  19263. *
  19264. * @sample {highcharts} highcharts/xaxis/labels-reservespace/
  19265. * No reserved space, labels inside plot
  19266. * @sample {highcharts} highcharts/xaxis/labels-reservespace-true/
  19267. * Left-aligned labels on a vertical category axis
  19268. *
  19269. * @type {boolean}
  19270. * @since 4.1.10
  19271. * @product highcharts gantt
  19272. * @apioption xAxis.labels.reserveSpace
  19273. */
  19274. reserveSpace: void 0,
  19275. /**
  19276. * Rotation of the labels in degrees. When `undefined`, the
  19277. * `autoRotation` option takes precedence.
  19278. *
  19279. * @sample {highcharts} highcharts/xaxis/labels-rotation/
  19280. * X axis labels rotated 90°
  19281. *
  19282. * @type {number}
  19283. * @default 0
  19284. * @apioption xAxis.labels.rotation
  19285. */
  19286. rotation: void 0,
  19287. /**
  19288. * Horizontal axes only. The number of lines to spread the labels
  19289. * over to make room or tighter labels. 0 disables staggering.
  19290. *
  19291. * @sample {highcharts} highcharts/xaxis/labels-staggerlines/
  19292. * Show labels over two lines
  19293. * @sample {highstock} stock/xaxis/labels-staggerlines/
  19294. * Show labels over two lines
  19295. *
  19296. * @since 2.1
  19297. * @apioption xAxis.labels.staggerLines
  19298. */
  19299. staggerLines: 0,
  19300. /**
  19301. * To show only every _n_'th label on the axis, set the step to _n_.
  19302. * Setting the step to 2 shows every other label.
  19303. *
  19304. * By default, when 0, the step is calculated automatically to avoid
  19305. * overlap. To prevent this, set it to 1\. This usually only
  19306. * happens on a category axis, and is often a sign that you have
  19307. * chosen the wrong axis type.
  19308. *
  19309. * Read more at
  19310. * [Axis docs](https://www.highcharts.com/docs/chart-concepts/axes)
  19311. * => What axis should I use?
  19312. *
  19313. * @sample {highcharts} highcharts/xaxis/labels-step/
  19314. * Showing only every other axis label on a categorized
  19315. * x-axis
  19316. * @sample {highcharts} highcharts/xaxis/labels-step-auto/
  19317. * Auto steps on a category axis
  19318. *
  19319. * @since 2.1
  19320. */
  19321. step: 0,
  19322. /**
  19323. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  19324. * to render the labels.
  19325. */
  19326. useHTML: false,
  19327. /**
  19328. * The x position offset of all labels relative to the tick
  19329. * positions on the axis.
  19330. *
  19331. * @sample {highcharts} highcharts/xaxis/labels-x/
  19332. * Y axis labels placed on grid lines
  19333. */
  19334. x: 0,
  19335. /**
  19336. * The y position offset of all labels relative to the tick
  19337. * positions on the axis. The default makes it adapt to the font
  19338. * size of the bottom axis.
  19339. *
  19340. * @sample {highcharts} highcharts/xaxis/labels-x/
  19341. * Y axis labels placed on grid lines
  19342. *
  19343. * @type {number}
  19344. * @apioption xAxis.labels.y
  19345. */
  19346. /**
  19347. * The Z index for the axis labels.
  19348. */
  19349. zIndex: 7,
  19350. /**
  19351. * CSS styles for the label. Use `whiteSpace: 'nowrap'` to prevent
  19352. * wrapping of category labels. Use `textOverflow: 'none'` to
  19353. * prevent ellipsis (dots).
  19354. *
  19355. * In styled mode, the labels are styled with the
  19356. * `.highcharts-axis-labels` class.
  19357. *
  19358. * @sample {highcharts} highcharts/xaxis/labels-style/
  19359. * Red X axis labels
  19360. *
  19361. * @type {Highcharts.CSSObject}
  19362. */
  19363. style: {
  19364. /** @internal */
  19365. color: palette.neutralColor60,
  19366. /** @internal */
  19367. cursor: 'default',
  19368. /** @internal */
  19369. fontSize: '11px'
  19370. }
  19371. },
  19372. /**
  19373. * The left position as the horizontal axis. If it's a number, it is
  19374. * interpreted as pixel position relative to the chart.
  19375. *
  19376. * Since Highcharts v5.0.13: If it's a percentage string, it is
  19377. * interpreted as percentages of the plot width, offset from plot area
  19378. * left.
  19379. *
  19380. * @type {number|string}
  19381. * @product highcharts highstock
  19382. * @apioption xAxis.left
  19383. */
  19384. /**
  19385. * The top position as the vertical axis. If it's a number, it is
  19386. * interpreted as pixel position relative to the chart.
  19387. *
  19388. * Since Highcharts 2: If it's a percentage string, it is interpreted
  19389. * as percentages of the plot height, offset from plot area top.
  19390. *
  19391. * @type {number|string}
  19392. * @product highcharts highstock
  19393. * @apioption xAxis.top
  19394. */
  19395. /**
  19396. * Index of another axis that this axis is linked to. When an axis is
  19397. * linked to a master axis, it will take the same extremes as
  19398. * the master, but as assigned by min or max or by setExtremes.
  19399. * It can be used to show additional info, or to ease reading the
  19400. * chart by duplicating the scales.
  19401. *
  19402. * @sample {highcharts} highcharts/xaxis/linkedto/
  19403. * Different string formats of the same date
  19404. * @sample {highcharts} highcharts/yaxis/linkedto/
  19405. * Y values on both sides
  19406. *
  19407. * @type {number}
  19408. * @since 2.0.2
  19409. * @product highcharts highstock gantt
  19410. * @apioption xAxis.linkedTo
  19411. */
  19412. /**
  19413. * The maximum value of the axis. If `null`, the max value is
  19414. * automatically calculated.
  19415. *
  19416. * If the [endOnTick](#yAxis.endOnTick) option is true, the `max` value
  19417. * might be rounded up.
  19418. *
  19419. * If a [tickAmount](#yAxis.tickAmount) is set, the axis may be extended
  19420. * beyond the set max in order to reach the given number of ticks. The
  19421. * same may happen in a chart with multiple axes, determined by [chart.
  19422. * alignTicks](#chart), where a `tickAmount` is applied internally.
  19423. *
  19424. * @sample {highcharts} highcharts/yaxis/max-200/
  19425. * Y axis max of 200
  19426. * @sample {highcharts} highcharts/yaxis/max-logarithmic/
  19427. * Y axis max on logarithmic axis
  19428. * @sample {highstock} stock/xaxis/min-max/
  19429. * Fixed min and max on X axis
  19430. * @sample {highmaps} maps/axis/min-max/
  19431. * Pre-zoomed to a specific area
  19432. *
  19433. * @type {number|null}
  19434. * @apioption xAxis.max
  19435. */
  19436. /**
  19437. * Padding of the max value relative to the length of the axis. A
  19438. * padding of 0.05 will make a 100px axis 5px longer. This is useful
  19439. * when you don't want the highest data value to appear on the edge
  19440. * of the plot area. When the axis' `max` option is set or a max extreme
  19441. * is set using `axis.setExtremes()`, the maxPadding will be ignored.
  19442. *
  19443. * @sample {highcharts} highcharts/yaxis/maxpadding/
  19444. * Max padding of 0.25 on y axis
  19445. * @sample {highstock} stock/xaxis/minpadding-maxpadding/
  19446. * Greater min- and maxPadding
  19447. * @sample {highmaps} maps/chart/plotbackgroundcolor-gradient/
  19448. * Add some padding
  19449. *
  19450. * @default {highcharts} 0.01
  19451. * @default {highstock|highmaps} 0
  19452. * @since 1.2.0
  19453. */
  19454. maxPadding: 0.01,
  19455. /**
  19456. * Deprecated. Use `minRange` instead.
  19457. *
  19458. * @deprecated
  19459. * @type {number}
  19460. * @product highcharts highstock
  19461. * @apioption xAxis.maxZoom
  19462. */
  19463. /**
  19464. * The minimum value of the axis. If `null` the min value is
  19465. * automatically calculated.
  19466. *
  19467. * If the [startOnTick](#yAxis.startOnTick) option is true (default),
  19468. * the `min` value might be rounded down.
  19469. *
  19470. * The automatically calculated minimum value is also affected by
  19471. * [floor](#yAxis.floor), [softMin](#yAxis.softMin),
  19472. * [minPadding](#yAxis.minPadding), [minRange](#yAxis.minRange)
  19473. * as well as [series.threshold](#plotOptions.series.threshold)
  19474. * and [series.softThreshold](#plotOptions.series.softThreshold).
  19475. *
  19476. * @sample {highcharts} highcharts/yaxis/min-startontick-false/
  19477. * -50 with startOnTick to false
  19478. * @sample {highcharts} highcharts/yaxis/min-startontick-true/
  19479. * -50 with startOnTick true by default
  19480. * @sample {highstock} stock/xaxis/min-max/
  19481. * Set min and max on X axis
  19482. * @sample {highmaps} maps/axis/min-max/
  19483. * Pre-zoomed to a specific area
  19484. *
  19485. * @type {number|null}
  19486. * @apioption xAxis.min
  19487. */
  19488. /**
  19489. * The dash or dot style of the minor grid lines. For possible values,
  19490. * see [this demonstration](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-dashstyle-all/).
  19491. *
  19492. * @sample {highcharts} highcharts/yaxis/minorgridlinedashstyle/
  19493. * Long dashes on minor grid lines
  19494. * @sample {highstock} stock/xaxis/minorgridlinedashstyle/
  19495. * Long dashes on minor grid lines
  19496. *
  19497. * @type {Highcharts.DashStyleValue}
  19498. * @since 1.2
  19499. */
  19500. minorGridLineDashStyle: 'Solid',
  19501. /**
  19502. * Specific tick interval in axis units for the minor ticks. On a linear
  19503. * axis, if `"auto"`, the minor tick interval is calculated as a fifth
  19504. * of the tickInterval. If `null` or `undefined`, minor ticks are not
  19505. * shown.
  19506. *
  19507. * On logarithmic axes, the unit is the power of the value. For example,
  19508. * setting the minorTickInterval to 1 puts one tick on each of 0.1, 1,
  19509. * 10, 100 etc. Setting the minorTickInterval to 0.1 produces 9 ticks
  19510. * between 1 and 10, 10 and 100 etc.
  19511. *
  19512. * If user settings dictate minor ticks to become too dense, they don't
  19513. * make sense, and will be ignored to prevent performance problems.
  19514. *
  19515. * @sample {highcharts} highcharts/yaxis/minortickinterval-null/
  19516. * Null by default
  19517. * @sample {highcharts} highcharts/yaxis/minortickinterval-5/
  19518. * 5 units
  19519. * @sample {highcharts} highcharts/yaxis/minortickinterval-log-auto/
  19520. * "auto"
  19521. * @sample {highcharts} highcharts/yaxis/minortickinterval-log/
  19522. * 0.1
  19523. * @sample {highstock} stock/demo/basic-line/
  19524. * Null by default
  19525. * @sample {highstock} stock/xaxis/minortickinterval-auto/
  19526. * "auto"
  19527. *
  19528. * @type {number|string|null}
  19529. * @apioption xAxis.minorTickInterval
  19530. */
  19531. /**
  19532. * The pixel length of the minor tick marks.
  19533. *
  19534. * @sample {highcharts} highcharts/yaxis/minorticklength/
  19535. * 10px on Y axis
  19536. * @sample {highstock} stock/xaxis/minorticks/
  19537. * 10px on Y axis
  19538. */
  19539. minorTickLength: 2,
  19540. /**
  19541. * The position of the minor tick marks relative to the axis line.
  19542. * Can be one of `inside` and `outside`.
  19543. *
  19544. * @sample {highcharts} highcharts/yaxis/minortickposition-outside/
  19545. * Outside by default
  19546. * @sample {highcharts} highcharts/yaxis/minortickposition-inside/
  19547. * Inside
  19548. * @sample {highstock} stock/xaxis/minorticks/
  19549. * Inside
  19550. *
  19551. * @validvalue ["inside", "outside"]
  19552. */
  19553. minorTickPosition: 'outside',
  19554. /**
  19555. * Enable or disable minor ticks. Unless
  19556. * [minorTickInterval](#xAxis.minorTickInterval) is set, the tick
  19557. * interval is calculated as a fifth of the `tickInterval`.
  19558. *
  19559. * On a logarithmic axis, minor ticks are laid out based on a best
  19560. * guess, attempting to enter approximately 5 minor ticks between
  19561. * each major tick.
  19562. *
  19563. * Prior to v6.0.0, ticks were unabled in auto layout by setting
  19564. * `minorTickInterval` to `"auto"`.
  19565. *
  19566. * @productdesc {highcharts}
  19567. * On axes using [categories](#xAxis.categories), minor ticks are not
  19568. * supported.
  19569. *
  19570. * @sample {highcharts} highcharts/yaxis/minorticks-true/
  19571. * Enabled on linear Y axis
  19572. *
  19573. * @type {boolean}
  19574. * @default false
  19575. * @since 6.0.0
  19576. * @apioption xAxis.minorTicks
  19577. */
  19578. /**
  19579. * The pixel width of the minor tick mark.
  19580. *
  19581. * @sample {highcharts} highcharts/yaxis/minortickwidth/
  19582. * 3px width
  19583. * @sample {highstock} stock/xaxis/minorticks/
  19584. * 1px width
  19585. *
  19586. * @type {number}
  19587. * @default 0
  19588. * @apioption xAxis.minorTickWidth
  19589. */
  19590. /**
  19591. * Padding of the min value relative to the length of the axis. A
  19592. * padding of 0.05 will make a 100px axis 5px longer. This is useful
  19593. * when you don't want the lowest data value to appear on the edge
  19594. * of the plot area. When the axis' `min` option is set or a min extreme
  19595. * is set using `axis.setExtremes()`, the minPadding will be ignored.
  19596. *
  19597. * @sample {highcharts} highcharts/yaxis/minpadding/
  19598. * Min padding of 0.2
  19599. * @sample {highstock} stock/xaxis/minpadding-maxpadding/
  19600. * Greater min- and maxPadding
  19601. * @sample {highmaps} maps/chart/plotbackgroundcolor-gradient/
  19602. * Add some padding
  19603. *
  19604. * @default {highcharts} 0.01
  19605. * @default {highstock|highmaps} 0
  19606. * @since 1.2.0
  19607. * @product highcharts highstock gantt
  19608. */
  19609. minPadding: 0.01,
  19610. /**
  19611. * The minimum range to display on this axis. The entire axis will not
  19612. * be allowed to span over a smaller interval than this. For example,
  19613. * for a datetime axis the main unit is milliseconds. If minRange is
  19614. * set to 3600000, you can't zoom in more than to one hour.
  19615. *
  19616. * The default minRange for the x axis is five times the smallest
  19617. * interval between any of the data points.
  19618. *
  19619. * On a logarithmic axis, the unit for the minimum range is the power.
  19620. * So a minRange of 1 means that the axis can be zoomed to 10-100,
  19621. * 100-1000, 1000-10000 etc.
  19622. *
  19623. * **Note**: The `minPadding`, `maxPadding`, `startOnTick` and
  19624. * `endOnTick` settings also affect how the extremes of the axis
  19625. * are computed.
  19626. *
  19627. * @sample {highcharts} highcharts/xaxis/minrange/
  19628. * Minimum range of 5
  19629. * @sample {highstock} stock/xaxis/minrange/
  19630. * Max zoom of 6 months overrides user selections
  19631. * @sample {highmaps} maps/axis/minrange/
  19632. * Minimum range of 1000
  19633. *
  19634. * @type {number}
  19635. * @apioption xAxis.minRange
  19636. */
  19637. /**
  19638. * The minimum tick interval allowed in axis values. For example on
  19639. * zooming in on an axis with daily data, this can be used to prevent
  19640. * the axis from showing hours. Defaults to the closest distance between
  19641. * two points on the axis.
  19642. *
  19643. * @type {number}
  19644. * @since 2.3.0
  19645. * @apioption xAxis.minTickInterval
  19646. */
  19647. /**
  19648. * The distance in pixels from the plot area to the axis line.
  19649. * A positive offset moves the axis with it's line, labels and ticks
  19650. * away from the plot area. This is typically used when two or more
  19651. * axes are displayed on the same side of the plot. With multiple
  19652. * axes the offset is dynamically adjusted to avoid collision, this
  19653. * can be overridden by setting offset explicitly.
  19654. *
  19655. * @sample {highcharts} highcharts/yaxis/offset/
  19656. * Y axis offset of 70
  19657. * @sample {highcharts} highcharts/yaxis/offset-centered/
  19658. * Axes positioned in the center of the plot
  19659. * @sample {highstock} stock/xaxis/offset/
  19660. * Y axis offset by 70 px
  19661. *
  19662. */
  19663. offset: void 0,
  19664. /**
  19665. * Whether to display the axis on the opposite side of the normal. The
  19666. * normal is on the left side for vertical axes and bottom for
  19667. * horizontal, so the opposite sides will be right and top respectively.
  19668. * This is typically used with dual or multiple axes.
  19669. *
  19670. * @sample {highcharts} highcharts/yaxis/opposite/
  19671. * Secondary Y axis opposite
  19672. * @sample {highstock} stock/xaxis/opposite/
  19673. * Y axis on left side
  19674. *
  19675. * @default {highcharts|highstock|highmaps} false
  19676. * @default {gantt} true
  19677. */
  19678. opposite: false,
  19679. /**
  19680. * In an ordinal axis, the points are equally spaced in the chart
  19681. * regardless of the actual time or x distance between them. This means
  19682. * that missing data periods (e.g. nights or weekends for a stock chart)
  19683. * will not take up space in the chart.
  19684. * Having `ordinal: false` will show any gaps created by the `gapSize`
  19685. * setting proportionate to their duration.
  19686. *
  19687. * In stock charts the X axis is ordinal by default, unless
  19688. * the boost module is used and at least one of the series' data length
  19689. * exceeds the [boostThreshold](#series.line.boostThreshold).
  19690. *
  19691. * @sample {highstock} stock/xaxis/ordinal-true/
  19692. * True by default
  19693. * @sample {highstock} stock/xaxis/ordinal-false/
  19694. * False
  19695. *
  19696. * @type {boolean}
  19697. * @default true
  19698. * @since 1.1
  19699. * @product highstock
  19700. * @apioption xAxis.ordinal
  19701. */
  19702. /**
  19703. * Additional range on the right side of the xAxis. Works similar to
  19704. * `xAxis.maxPadding`, but value is set in milliseconds. Can be set for
  19705. * both main `xAxis` and the navigator's `xAxis`.
  19706. *
  19707. * @sample {highstock} stock/xaxis/overscroll/
  19708. * One minute overscroll with live data
  19709. *
  19710. * @type {number}
  19711. * @default 0
  19712. * @since 6.0.0
  19713. * @product highstock
  19714. * @apioption xAxis.overscroll
  19715. */
  19716. /**
  19717. * Refers to the index in the [panes](#panes) array. Used for circular
  19718. * gauges and polar charts. When the option is not set then first pane
  19719. * will be used.
  19720. *
  19721. * @sample highcharts/demo/gauge-vu-meter
  19722. * Two gauges with different center
  19723. *
  19724. * @type {number}
  19725. * @product highcharts
  19726. * @apioption xAxis.pane
  19727. */
  19728. /**
  19729. * The zoomed range to display when only defining one or none of `min`
  19730. * or `max`. For example, to show the latest month, a range of one month
  19731. * can be set.
  19732. *
  19733. * @sample {highstock} stock/xaxis/range/
  19734. * Setting a zoomed range when the rangeSelector is disabled
  19735. *
  19736. * @type {number}
  19737. * @product highstock
  19738. * @apioption xAxis.range
  19739. */
  19740. /**
  19741. * Whether to reverse the axis so that the highest number is closest
  19742. * to the origin. If the chart is inverted, the x axis is reversed by
  19743. * default.
  19744. *
  19745. * @sample {highcharts} highcharts/yaxis/reversed/
  19746. * Reversed Y axis
  19747. * @sample {highstock} stock/xaxis/reversed/
  19748. * Reversed Y axis
  19749. *
  19750. * @type {boolean}
  19751. * @default undefined
  19752. * @apioption xAxis.reversed
  19753. */
  19754. reversed: void 0,
  19755. /**
  19756. * This option determines how stacks should be ordered within a group.
  19757. * For example reversed xAxis also reverses stacks, so first series
  19758. * comes last in a group. To keep order like for non-reversed xAxis
  19759. * enable this option.
  19760. *
  19761. * @sample {highcharts} highcharts/xaxis/reversedstacks/
  19762. * Reversed stacks comparison
  19763. * @sample {highstock} highcharts/xaxis/reversedstacks/
  19764. * Reversed stacks comparison
  19765. *
  19766. * @since 6.1.1
  19767. * @product highcharts highstock
  19768. */
  19769. reversedStacks: false,
  19770. /**
  19771. * An optional scrollbar to display on the X axis in response to
  19772. * limiting the minimum and maximum of the axis values.
  19773. *
  19774. * In styled mode, all the presentational options for the scrollbar are
  19775. * replaced by the classes `.highcharts-scrollbar-thumb`,
  19776. * `.highcharts-scrollbar-arrow`, `.highcharts-scrollbar-button`,
  19777. * `.highcharts-scrollbar-rifles` and `.highcharts-scrollbar-track`.
  19778. *
  19779. * @sample {highstock} stock/yaxis/heatmap-scrollbars/
  19780. * Heatmap with both scrollbars
  19781. *
  19782. * @extends scrollbar
  19783. * @since 4.2.6
  19784. * @product highstock
  19785. * @apioption xAxis.scrollbar
  19786. */
  19787. /**
  19788. * Whether to show the axis line and title when the axis has no data.
  19789. *
  19790. * @sample {highcharts} highcharts/yaxis/showempty/
  19791. * When clicking the legend to hide series, one axis preserves
  19792. * line and title, the other doesn't
  19793. * @sample {highstock} highcharts/yaxis/showempty/
  19794. * When clicking the legend to hide series, one axis preserves
  19795. * line and title, the other doesn't
  19796. *
  19797. * @since 1.1
  19798. */
  19799. showEmpty: true,
  19800. /**
  19801. * Whether to show the first tick label.
  19802. *
  19803. * @sample {highcharts} highcharts/xaxis/showfirstlabel-false/
  19804. * Set to false on X axis
  19805. * @sample {highstock} stock/xaxis/showfirstlabel/
  19806. * Labels below plot lines on Y axis
  19807. */
  19808. showFirstLabel: true,
  19809. /**
  19810. * Whether to show the last tick label. Defaults to `true` on cartesian
  19811. * charts, and `false` on polar charts.
  19812. *
  19813. * @sample {highcharts} highcharts/xaxis/showlastlabel-true/
  19814. * Set to true on X axis
  19815. * @sample {highstock} stock/xaxis/showfirstlabel/
  19816. * Labels below plot lines on Y axis
  19817. *
  19818. * @product highcharts highstock gantt
  19819. */
  19820. showLastLabel: true,
  19821. /**
  19822. * A soft maximum for the axis. If the series data maximum is less than
  19823. * this, the axis will stay at this maximum, but if the series data
  19824. * maximum is higher, the axis will flex to show all data.
  19825. *
  19826. * @sample highcharts/yaxis/softmin-softmax/
  19827. * Soft min and max
  19828. *
  19829. * @type {number}
  19830. * @since 5.0.1
  19831. * @product highcharts highstock gantt
  19832. * @apioption xAxis.softMax
  19833. */
  19834. /**
  19835. * A soft minimum for the axis. If the series data minimum is greater
  19836. * than this, the axis will stay at this minimum, but if the series
  19837. * data minimum is lower, the axis will flex to show all data.
  19838. *
  19839. * @sample highcharts/yaxis/softmin-softmax/
  19840. * Soft min and max
  19841. *
  19842. * @type {number}
  19843. * @since 5.0.1
  19844. * @product highcharts highstock gantt
  19845. * @apioption xAxis.softMin
  19846. */
  19847. /**
  19848. * For datetime axes, this decides where to put the tick between weeks.
  19849. * 0 = Sunday, 1 = Monday.
  19850. *
  19851. * @sample {highcharts} highcharts/xaxis/startofweek-monday/
  19852. * Monday by default
  19853. * @sample {highcharts} highcharts/xaxis/startofweek-sunday/
  19854. * Sunday
  19855. * @sample {highstock} stock/xaxis/startofweek-1
  19856. * Monday by default
  19857. * @sample {highstock} stock/xaxis/startofweek-0
  19858. * Sunday
  19859. *
  19860. * @product highcharts highstock gantt
  19861. */
  19862. startOfWeek: 1,
  19863. /**
  19864. * Whether to force the axis to start on a tick. Use this option with
  19865. * the `minPadding` option to control the axis start.
  19866. *
  19867. * @productdesc {highstock}
  19868. * In Highcharts Stock, `startOnTick` is always `false` when
  19869. * the navigator is enabled, to prevent jumpy scrolling.
  19870. *
  19871. * @sample {highcharts} highcharts/xaxis/startontick-false/
  19872. * False by default
  19873. * @sample {highcharts} highcharts/xaxis/startontick-true/
  19874. * True
  19875. *
  19876. * @since 1.2.0
  19877. */
  19878. startOnTick: false,
  19879. /**
  19880. * The amount of ticks to draw on the axis. This opens up for aligning
  19881. * the ticks of multiple charts or panes within a chart. This option
  19882. * overrides the `tickPixelInterval` option.
  19883. *
  19884. * This option only has an effect on linear axes. Datetime, logarithmic
  19885. * or category axes are not affected.
  19886. *
  19887. * @sample {highcharts} highcharts/yaxis/tickamount/
  19888. * 8 ticks on Y axis
  19889. * @sample {highstock} highcharts/yaxis/tickamount/
  19890. * 8 ticks on Y axis
  19891. *
  19892. * @type {number}
  19893. * @since 4.1.0
  19894. * @product highcharts highstock gantt
  19895. * @apioption xAxis.tickAmount
  19896. */
  19897. /**
  19898. * The interval of the tick marks in axis units. When `undefined`, the
  19899. * tick interval is computed to approximately follow the
  19900. * [tickPixelInterval](#xAxis.tickPixelInterval) on linear and datetime
  19901. * axes. On categorized axes, a `undefined` tickInterval will default to
  19902. * 1, one category. Note that datetime axes are based on milliseconds,
  19903. * so for example an interval of one day is expressed as
  19904. * `24 * 3600 * 1000`.
  19905. *
  19906. * On logarithmic axes, the tickInterval is based on powers, so a
  19907. * tickInterval of 1 means one tick on each of 0.1, 1, 10, 100 etc. A
  19908. * tickInterval of 2 means a tick of 0.1, 10, 1000 etc. A tickInterval
  19909. * of 0.2 puts a tick on 0.1, 0.2, 0.4, 0.6, 0.8, 1, 2, 4, 6, 8, 10, 20,
  19910. * 40 etc.
  19911. *
  19912. *
  19913. * If the tickInterval is too dense for labels to be drawn, Highcharts
  19914. * may remove ticks.
  19915. *
  19916. * If the chart has multiple axes, the [alignTicks](#chart.alignTicks)
  19917. * option may interfere with the `tickInterval` setting.
  19918. *
  19919. * @see [tickPixelInterval](#xAxis.tickPixelInterval)
  19920. * @see [tickPositions](#xAxis.tickPositions)
  19921. * @see [tickPositioner](#xAxis.tickPositioner)
  19922. *
  19923. * @sample {highcharts} highcharts/xaxis/tickinterval-5/
  19924. * Tick interval of 5 on a linear axis
  19925. * @sample {highstock} stock/xaxis/tickinterval/
  19926. * Tick interval of 0.01 on Y axis
  19927. *
  19928. * @type {number}
  19929. * @apioption xAxis.tickInterval
  19930. */
  19931. /**
  19932. * The pixel length of the main tick marks.
  19933. *
  19934. * @sample {highcharts} highcharts/xaxis/ticklength/
  19935. * 20 px tick length on the X axis
  19936. * @sample {highstock} stock/xaxis/ticks/
  19937. * Formatted ticks on X axis
  19938. */
  19939. tickLength: 10,
  19940. /**
  19941. * If tickInterval is `null` this option sets the approximate pixel
  19942. * interval of the tick marks. Not applicable to categorized axis.
  19943. *
  19944. * The tick interval is also influenced by the [minTickInterval](
  19945. * #xAxis.minTickInterval) option, that, by default prevents ticks from
  19946. * being denser than the data points.
  19947. *
  19948. * @see [tickInterval](#xAxis.tickInterval)
  19949. * @see [tickPositioner](#xAxis.tickPositioner)
  19950. * @see [tickPositions](#xAxis.tickPositions)
  19951. *
  19952. * @sample {highcharts} highcharts/xaxis/tickpixelinterval-50/
  19953. * 50 px on X axis
  19954. * @sample {highstock} stock/xaxis/tickpixelinterval/
  19955. * 200 px on X axis
  19956. */
  19957. tickPixelInterval: 100,
  19958. /**
  19959. * For categorized axes only. If `on` the tick mark is placed in the
  19960. * center of the category, if `between` the tick mark is placed between
  19961. * categories. The default is `between` if the `tickInterval` is 1, else
  19962. * `on`.
  19963. *
  19964. * @sample {highcharts} highcharts/xaxis/tickmarkplacement-between/
  19965. * "between" by default
  19966. * @sample {highcharts} highcharts/xaxis/tickmarkplacement-on/
  19967. * "on"
  19968. *
  19969. * @product highcharts gantt
  19970. * @validvalue ["on", "between"]
  19971. */
  19972. tickmarkPlacement: 'between',
  19973. /**
  19974. * The position of the major tick marks relative to the axis line.
  19975. * Can be one of `inside` and `outside`.
  19976. *
  19977. * @sample {highcharts} highcharts/xaxis/tickposition-outside/
  19978. * "outside" by default
  19979. * @sample {highcharts} highcharts/xaxis/tickposition-inside/
  19980. * "inside"
  19981. * @sample {highstock} stock/xaxis/ticks/
  19982. * Formatted ticks on X axis
  19983. *
  19984. * @validvalue ["inside", "outside"]
  19985. */
  19986. tickPosition: 'outside',
  19987. /**
  19988. * A callback function returning array defining where the ticks are
  19989. * laid out on the axis. This overrides the default behaviour of
  19990. * [tickPixelInterval](#xAxis.tickPixelInterval) and [tickInterval](
  19991. * #xAxis.tickInterval). The automatic tick positions are accessible
  19992. * through `this.tickPositions` and can be modified by the callback.
  19993. *
  19994. * @see [tickPositions](#xAxis.tickPositions)
  19995. *
  19996. * @sample {highcharts} highcharts/xaxis/tickpositions-tickpositioner/
  19997. * Demo of tickPositions and tickPositioner
  19998. * @sample {highstock} highcharts/xaxis/tickpositions-tickpositioner/
  19999. * Demo of tickPositions and tickPositioner
  20000. *
  20001. * @type {Highcharts.AxisTickPositionerCallbackFunction}
  20002. * @apioption xAxis.tickPositioner
  20003. */
  20004. /**
  20005. * An array defining where the ticks are laid out on the axis. This
  20006. * overrides the default behaviour of [tickPixelInterval](
  20007. * #xAxis.tickPixelInterval) and [tickInterval](#xAxis.tickInterval).
  20008. *
  20009. * @see [tickPositioner](#xAxis.tickPositioner)
  20010. *
  20011. * @sample {highcharts} highcharts/xaxis/tickpositions-tickpositioner/
  20012. * Demo of tickPositions and tickPositioner
  20013. * @sample {highstock} highcharts/xaxis/tickpositions-tickpositioner/
  20014. * Demo of tickPositions and tickPositioner
  20015. *
  20016. * @type {Array<number>}
  20017. * @apioption xAxis.tickPositions
  20018. */
  20019. /**
  20020. * The pixel width of the major tick marks. Defaults to 0 on category
  20021. * axes, otherwise 1.
  20022. *
  20023. * In styled mode, the stroke width is given in the `.highcharts-tick`
  20024. * class, but in order for the element to be generated on category axes,
  20025. * the option must be explicitly set to 1.
  20026. *
  20027. * @sample {highcharts} highcharts/xaxis/tickwidth/
  20028. * 10 px width
  20029. * @sample {highcharts} highcharts/css/axis-grid/
  20030. * Styled mode
  20031. * @sample {highstock} stock/xaxis/ticks/
  20032. * Formatted ticks on X axis
  20033. * @sample {highstock} highcharts/css/axis-grid/
  20034. * Styled mode
  20035. *
  20036. * @type {undefined|number}
  20037. * @default {highstock} 1
  20038. * @default {highmaps} 0
  20039. * @apioption xAxis.tickWidth
  20040. */
  20041. /**
  20042. * The axis title, showing next to the axis line.
  20043. *
  20044. * @productdesc {highmaps}
  20045. * In Highmaps, the axis is hidden by default, but adding an axis title
  20046. * is still possible. X axis and Y axis titles will appear at the bottom
  20047. * and left by default.
  20048. */
  20049. title: {
  20050. /**
  20051. * Alignment of the title relative to the axis values. Possible
  20052. * values are "low", "middle" or "high".
  20053. *
  20054. * @sample {highcharts} highcharts/xaxis/title-align-low/
  20055. * "low"
  20056. * @sample {highcharts} highcharts/xaxis/title-align-center/
  20057. * "middle" by default
  20058. * @sample {highcharts} highcharts/xaxis/title-align-high/
  20059. * "high"
  20060. * @sample {highcharts} highcharts/yaxis/title-offset/
  20061. * Place the Y axis title on top of the axis
  20062. * @sample {highstock} stock/xaxis/title-align/
  20063. * Aligned to "high" value
  20064. *
  20065. * @type {Highcharts.AxisTitleAlignValue}
  20066. */
  20067. align: 'middle',
  20068. /**
  20069. * Deprecated. Set the `text` to `undefined` to disable the title.
  20070. *
  20071. * @deprecated
  20072. * @type {boolean}
  20073. * @product highcharts
  20074. * @apioption xAxis.title.enabled
  20075. */
  20076. /**
  20077. * The pixel distance between the axis labels or line and the title.
  20078. * Defaults to 0 for horizontal axes, 10 for vertical
  20079. *
  20080. * @sample {highcharts} highcharts/xaxis/title-margin/
  20081. * Y axis title margin of 60
  20082. *
  20083. * @type {number}
  20084. * @apioption xAxis.title.margin
  20085. */
  20086. /**
  20087. * The distance of the axis title from the axis line. By default,
  20088. * this distance is computed from the offset width of the labels,
  20089. * the labels' distance from the axis and the title's margin.
  20090. * However when the offset option is set, it overrides all this.
  20091. *
  20092. * @sample {highcharts} highcharts/yaxis/title-offset/
  20093. * Place the axis title on top of the axis
  20094. * @sample {highstock} highcharts/yaxis/title-offset/
  20095. * Place the axis title on top of the Y axis
  20096. *
  20097. * @type {number}
  20098. * @since 2.2.0
  20099. * @apioption xAxis.title.offset
  20100. */
  20101. /**
  20102. * Whether to reserve space for the title when laying out the axis.
  20103. *
  20104. * @type {boolean}
  20105. * @default true
  20106. * @since 5.0.11
  20107. * @product highcharts highstock gantt
  20108. * @apioption xAxis.title.reserveSpace
  20109. */
  20110. /**
  20111. * The rotation of the text in degrees. 0 is horizontal, 270 is
  20112. * vertical reading from bottom to top.
  20113. *
  20114. * @sample {highcharts} highcharts/yaxis/title-offset/
  20115. * Horizontal
  20116. */
  20117. rotation: 0,
  20118. /**
  20119. * The actual text of the axis title. It can contain basic HTML tags
  20120. * like `b`, `i` and `span` with style.
  20121. *
  20122. * @sample {highcharts} highcharts/xaxis/title-text/
  20123. * Custom HTML
  20124. * @sample {highstock} stock/xaxis/title-text/
  20125. * Titles for both axes
  20126. *
  20127. * @type {string|null}
  20128. * @apioption xAxis.title.text
  20129. */
  20130. /**
  20131. * Alignment of the text, can be `"left"`, `"right"` or `"center"`.
  20132. * Default alignment depends on the
  20133. * [title.align](xAxis.title.align):
  20134. *
  20135. * Horizontal axes:
  20136. * - for `align` = `"low"`, `textAlign` is set to `left`
  20137. * - for `align` = `"middle"`, `textAlign` is set to `center`
  20138. * - for `align` = `"high"`, `textAlign` is set to `right`
  20139. *
  20140. * Vertical axes:
  20141. * - for `align` = `"low"` and `opposite` = `true`, `textAlign` is
  20142. * set to `right`
  20143. * - for `align` = `"low"` and `opposite` = `false`, `textAlign` is
  20144. * set to `left`
  20145. * - for `align` = `"middle"`, `textAlign` is set to `center`
  20146. * - for `align` = `"high"` and `opposite` = `true` `textAlign` is
  20147. * set to `left`
  20148. * - for `align` = `"high"` and `opposite` = `false` `textAlign` is
  20149. * set to `right`
  20150. *
  20151. * @type {Highcharts.AlignValue}
  20152. * @apioption xAxis.title.textAlign
  20153. */
  20154. /**
  20155. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  20156. * to render the axis title.
  20157. *
  20158. * @product highcharts highstock gantt
  20159. */
  20160. useHTML: false,
  20161. /**
  20162. * Horizontal pixel offset of the title position.
  20163. *
  20164. * @since 4.1.6
  20165. * @product highcharts highstock gantt
  20166. */
  20167. x: 0,
  20168. /**
  20169. * Vertical pixel offset of the title position.
  20170. *
  20171. * @product highcharts highstock gantt
  20172. */
  20173. y: 0,
  20174. /**
  20175. * CSS styles for the title. If the title text is longer than the
  20176. * axis length, it will wrap to multiple lines by default. This can
  20177. * be customized by setting `textOverflow: 'ellipsis'`, by
  20178. * setting a specific `width` or by setting `whiteSpace: 'nowrap'`.
  20179. *
  20180. * In styled mode, the stroke width is given in the
  20181. * `.highcharts-axis-title` class.
  20182. *
  20183. * @sample {highcharts} highcharts/xaxis/title-style/
  20184. * Red
  20185. * @sample {highcharts} highcharts/css/axis/
  20186. * Styled mode
  20187. *
  20188. * @type {Highcharts.CSSObject}
  20189. */
  20190. style: {
  20191. /** @internal */
  20192. color: palette.neutralColor60
  20193. }
  20194. },
  20195. /**
  20196. * The type of axis. Can be one of `linear`, `logarithmic`, `datetime`
  20197. * or `category`. In a datetime axis, the numbers are given in
  20198. * milliseconds, and tick marks are placed on appropriate values like
  20199. * full hours or days. In a category axis, the
  20200. * [point names](#series.line.data.name) of the chart's series are used
  20201. * for categories, if not a [categories](#xAxis.categories) array is
  20202. * defined.
  20203. *
  20204. * @sample {highcharts} highcharts/xaxis/type-linear/
  20205. * Linear
  20206. * @sample {highcharts} highcharts/yaxis/type-log/
  20207. * Logarithmic
  20208. * @sample {highcharts} highcharts/yaxis/type-log-minorgrid/
  20209. * Logarithmic with minor grid lines
  20210. * @sample {highcharts} highcharts/xaxis/type-log-both/
  20211. * Logarithmic on two axes
  20212. * @sample {highcharts} highcharts/yaxis/type-log-negative/
  20213. * Logarithmic with extension to emulate negative values
  20214. *
  20215. * @type {Highcharts.AxisTypeValue}
  20216. * @product highcharts gantt
  20217. */
  20218. type: 'linear',
  20219. /**
  20220. * If there are multiple axes on the same side of the chart, the pixel
  20221. * margin between the axes. Defaults to 0 on vertical axes, 15 on
  20222. * horizontal axes.
  20223. *
  20224. * @type {number}
  20225. * @since 7.0.3
  20226. * @apioption xAxis.margin
  20227. */
  20228. /**
  20229. * Applies only when the axis `type` is `category`. When `uniqueNames`
  20230. * is true, points are placed on the X axis according to their names.
  20231. * If the same point name is repeated in the same or another series,
  20232. * the point is placed on the same X position as other points of the
  20233. * same name. When `uniqueNames` is false, the points are laid out in
  20234. * increasing X positions regardless of their names, and the X axis
  20235. * category will take the name of the last point in each position.
  20236. *
  20237. * @sample {highcharts} highcharts/xaxis/uniquenames-true/
  20238. * True by default
  20239. * @sample {highcharts} highcharts/xaxis/uniquenames-false/
  20240. * False
  20241. *
  20242. * @since 4.2.7
  20243. * @product highcharts gantt
  20244. */
  20245. uniqueNames: true,
  20246. /**
  20247. * Datetime axis only. An array determining what time intervals the
  20248. * ticks are allowed to fall on. Each array item is an array where the
  20249. * first value is the time unit and the second value another array of
  20250. * allowed multiples.
  20251. *
  20252. * Defaults to:
  20253. * ```js
  20254. * units: [[
  20255. * 'millisecond', // unit name
  20256. * [1, 2, 5, 10, 20, 25, 50, 100, 200, 500] // allowed multiples
  20257. * ], [
  20258. * 'second',
  20259. * [1, 2, 5, 10, 15, 30]
  20260. * ], [
  20261. * 'minute',
  20262. * [1, 2, 5, 10, 15, 30]
  20263. * ], [
  20264. * 'hour',
  20265. * [1, 2, 3, 4, 6, 8, 12]
  20266. * ], [
  20267. * 'day',
  20268. * [1, 2]
  20269. * ], [
  20270. * 'week',
  20271. * [1, 2]
  20272. * ], [
  20273. * 'month',
  20274. * [1, 2, 3, 4, 6]
  20275. * ], [
  20276. * 'year',
  20277. * null
  20278. * ]]
  20279. * ```
  20280. *
  20281. * @type {Array<Array<string,(Array<number>|null)>>}
  20282. * @product highcharts highstock gantt
  20283. * @apioption xAxis.units
  20284. */
  20285. /**
  20286. * Whether axis, including axis title, line, ticks and labels, should
  20287. * be visible.
  20288. *
  20289. * @since 4.1.9
  20290. * @product highcharts highstock gantt
  20291. */
  20292. visible: true,
  20293. /**
  20294. * Color of the minor, secondary grid lines.
  20295. *
  20296. * In styled mode, the stroke width is given in the
  20297. * `.highcharts-minor-grid-line` class.
  20298. *
  20299. * @sample {highcharts} highcharts/yaxis/minorgridlinecolor/
  20300. * Bright grey lines from Y axis
  20301. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  20302. * Styled mode
  20303. * @sample {highstock} stock/xaxis/minorgridlinecolor/
  20304. * Bright grey lines from Y axis
  20305. *
  20306. * @type {Highcharts.ColorType}
  20307. * @default #f2f2f2
  20308. */
  20309. minorGridLineColor: palette.neutralColor5,
  20310. /**
  20311. * Width of the minor, secondary grid lines.
  20312. *
  20313. * In styled mode, the stroke width is given in the
  20314. * `.highcharts-grid-line` class.
  20315. *
  20316. * @sample {highcharts} highcharts/yaxis/minorgridlinewidth/
  20317. * 2px lines from Y axis
  20318. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  20319. * Styled mode
  20320. * @sample {highstock} stock/xaxis/minorgridlinewidth/
  20321. * 2px lines from Y axis
  20322. */
  20323. minorGridLineWidth: 1,
  20324. /**
  20325. * Color for the minor tick marks.
  20326. *
  20327. * @sample {highcharts} highcharts/yaxis/minortickcolor/
  20328. * Black tick marks on Y axis
  20329. * @sample {highstock} stock/xaxis/minorticks/
  20330. * Black tick marks on Y axis
  20331. *
  20332. * @type {Highcharts.ColorType}
  20333. * @default #999999
  20334. */
  20335. minorTickColor: palette.neutralColor40,
  20336. /**
  20337. * The color of the line marking the axis itself.
  20338. *
  20339. * In styled mode, the line stroke is given in the
  20340. * `.highcharts-axis-line` or `.highcharts-xaxis-line` class.
  20341. *
  20342. * @productdesc {highmaps}
  20343. * In Highmaps, the axis line is hidden by default, because the axis is
  20344. * not visible by default.
  20345. *
  20346. * @sample {highcharts} highcharts/yaxis/linecolor/
  20347. * A red line on Y axis
  20348. * @sample {highcharts|highstock} highcharts/css/axis/
  20349. * Axes in styled mode
  20350. * @sample {highstock} stock/xaxis/linecolor/
  20351. * A red line on X axis
  20352. *
  20353. * @type {Highcharts.ColorType}
  20354. * @default #ccd6eb
  20355. */
  20356. lineColor: palette.highlightColor20,
  20357. /**
  20358. * The width of the line marking the axis itself.
  20359. *
  20360. * In styled mode, the stroke width is given in the
  20361. * `.highcharts-axis-line` or `.highcharts-xaxis-line` class.
  20362. *
  20363. * @sample {highcharts} highcharts/yaxis/linecolor/
  20364. * A 1px line on Y axis
  20365. * @sample {highcharts|highstock} highcharts/css/axis/
  20366. * Axes in styled mode
  20367. * @sample {highstock} stock/xaxis/linewidth/
  20368. * A 2px line on X axis
  20369. *
  20370. * @default {highcharts|highstock} 1
  20371. * @default {highmaps} 0
  20372. */
  20373. lineWidth: 1,
  20374. /**
  20375. * Color of the grid lines extending the ticks across the plot area.
  20376. *
  20377. * In styled mode, the stroke is given in the `.highcharts-grid-line`
  20378. * class.
  20379. *
  20380. * @productdesc {highmaps}
  20381. * In Highmaps, the grid lines are hidden by default.
  20382. *
  20383. * @sample {highcharts} highcharts/yaxis/gridlinecolor/
  20384. * Green lines
  20385. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  20386. * Styled mode
  20387. * @sample {highstock} stock/xaxis/gridlinecolor/
  20388. * Green lines
  20389. *
  20390. * @type {Highcharts.ColorType}
  20391. * @default #e6e6e6
  20392. */
  20393. gridLineColor: palette.neutralColor10,
  20394. /**
  20395. * The width of the grid lines extending the ticks across the plot area.
  20396. * Defaults to 1 on the Y axis and 0 on the X axis, except for 3d
  20397. * charts.
  20398. *
  20399. * In styled mode, the stroke width is given in the
  20400. * `.highcharts-grid-line` class.
  20401. *
  20402. * @sample {highcharts} highcharts/yaxis/gridlinewidth/
  20403. * 2px lines
  20404. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  20405. * Styled mode
  20406. * @sample {highstock} stock/xaxis/gridlinewidth/
  20407. * 2px lines
  20408. *
  20409. * @type {number}
  20410. * @apioption xAxis.gridLineWidth
  20411. */
  20412. gridLineWidth: void 0,
  20413. /**
  20414. * The height as the vertical axis. If it's a number, it is
  20415. * interpreted as pixels.
  20416. *
  20417. * Since Highcharts 2: If it's a percentage string, it is interpreted
  20418. * as percentages of the total plot height.
  20419. *
  20420. * @type {number|string}
  20421. * @product highcharts highstock
  20422. * @apioption xAxis.height
  20423. */
  20424. /**
  20425. * The width as the horizontal axis. If it's a number, it is interpreted
  20426. * as pixels.
  20427. *
  20428. * Since Highcharts v5.0.13: If it's a percentage string, it is
  20429. * interpreted as percentages of the total plot width.
  20430. *
  20431. * @type {number|string}
  20432. * @product highcharts highstock
  20433. * @apioption xAxis.width
  20434. */
  20435. /**
  20436. * Color for the main tick marks.
  20437. *
  20438. * In styled mode, the stroke is given in the `.highcharts-tick`
  20439. * class.
  20440. *
  20441. * @sample {highcharts} highcharts/xaxis/tickcolor/
  20442. * Red ticks on X axis
  20443. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  20444. * Styled mode
  20445. * @sample {highstock} stock/xaxis/ticks/
  20446. * Formatted ticks on X axis
  20447. *
  20448. * @type {Highcharts.ColorType}
  20449. * @default #ccd6eb
  20450. */
  20451. tickColor: palette.highlightColor20
  20452. // tickWidth: 1
  20453. };
  20454. /**
  20455. * The Y axis or value axis. Normally this is the vertical axis,
  20456. * though if the chart is inverted this is the horizontal axis.
  20457. * In case of multiple axes, the yAxis node is an array of
  20458. * configuration objects.
  20459. *
  20460. * See [the Axis object](/class-reference/Highcharts.Axis) for programmatic
  20461. * access to the axis.
  20462. *
  20463. * @type {*|Array<*>}
  20464. * @extends xAxis
  20465. * @excluding currentDateIndicator,ordinal,overscroll
  20466. * @optionparent yAxis
  20467. *
  20468. * @private
  20469. */
  20470. Axis.defaultYAxisOptions = {
  20471. /**
  20472. * The type of axis. Can be one of `linear`, `logarithmic`, `datetime`,
  20473. * `category` or `treegrid`. Defaults to `treegrid` for Gantt charts,
  20474. * `linear` for other chart types.
  20475. *
  20476. * In a datetime axis, the numbers are given in milliseconds, and tick
  20477. * marks are placed on appropriate values, like full hours or days. In a
  20478. * category or treegrid axis, the [point names](#series.line.data.name)
  20479. * of the chart's series are used for categories, if a
  20480. * [categories](#xAxis.categories) array is not defined.
  20481. *
  20482. * @sample {highcharts} highcharts/yaxis/type-log-minorgrid/
  20483. * Logarithmic with minor grid lines
  20484. * @sample {highcharts} highcharts/yaxis/type-log-negative/
  20485. * Logarithmic with extension to emulate negative values
  20486. * @sample {gantt} gantt/treegrid-axis/demo
  20487. * Treegrid axis
  20488. *
  20489. * @type {Highcharts.AxisTypeValue}
  20490. * @default {highcharts} linear
  20491. * @default {gantt} treegrid
  20492. * @product highcharts gantt
  20493. * @apioption yAxis.type
  20494. */
  20495. /**
  20496. * The height of the Y axis. If it's a number, it is interpreted as
  20497. * pixels.
  20498. *
  20499. * Since Highcharts 2: If it's a percentage string, it is interpreted as
  20500. * percentages of the total plot height.
  20501. *
  20502. * @see [yAxis.top](#yAxis.top)
  20503. *
  20504. * @sample {highstock} stock/demo/candlestick-and-volume/
  20505. * Percentage height panes
  20506. *
  20507. * @type {number|string}
  20508. * @product highcharts highstock
  20509. * @apioption yAxis.height
  20510. */
  20511. /**
  20512. * Solid gauge only. Unless [stops](#yAxis.stops) are set, the color
  20513. * to represent the maximum value of the Y axis.
  20514. *
  20515. * @sample {highcharts} highcharts/yaxis/mincolor-maxcolor/
  20516. * Min and max colors
  20517. *
  20518. * @type {Highcharts.ColorType}
  20519. * @default #003399
  20520. * @since 4.0
  20521. * @product highcharts
  20522. * @apioption yAxis.maxColor
  20523. */
  20524. /**
  20525. * Solid gauge only. Unless [stops](#yAxis.stops) are set, the color
  20526. * to represent the minimum value of the Y axis.
  20527. *
  20528. * @sample {highcharts} highcharts/yaxis/mincolor-maxcolor/
  20529. * Min and max color
  20530. *
  20531. * @type {Highcharts.ColorType}
  20532. * @default #e6ebf5
  20533. * @since 4.0
  20534. * @product highcharts
  20535. * @apioption yAxis.minColor
  20536. */
  20537. /**
  20538. * Whether to reverse the axis so that the highest number is closest
  20539. * to the origin.
  20540. *
  20541. * @sample {highcharts} highcharts/yaxis/reversed/
  20542. * Reversed Y axis
  20543. * @sample {highstock} stock/xaxis/reversed/
  20544. * Reversed Y axis
  20545. *
  20546. * @type {boolean}
  20547. * @default {highcharts} false
  20548. * @default {highstock} false
  20549. * @default {highmaps} true
  20550. * @default {gantt} true
  20551. * @apioption yAxis.reversed
  20552. */
  20553. /**
  20554. * If `true`, the first series in a stack will be drawn on top in a
  20555. * positive, non-reversed Y axis. If `false`, the first series is in
  20556. * the base of the stack.
  20557. *
  20558. * @sample {highcharts} highcharts/yaxis/reversedstacks-false/
  20559. * Non-reversed stacks
  20560. * @sample {highstock} highcharts/yaxis/reversedstacks-false/
  20561. * Non-reversed stacks
  20562. *
  20563. * @type {boolean}
  20564. * @default true
  20565. * @since 3.0.10
  20566. * @product highcharts highstock
  20567. * @apioption yAxis.reversedStacks
  20568. */
  20569. reversedStacks: true,
  20570. /**
  20571. * Solid gauge series only. Color stops for the solid gauge. Use this
  20572. * in cases where a linear gradient between a `minColor` and `maxColor`
  20573. * is not sufficient. The stops is an array of tuples, where the first
  20574. * item is a float between 0 and 1 assigning the relative position in
  20575. * the gradient, and the second item is the color.
  20576. *
  20577. * For solid gauges, the Y axis also inherits the concept of
  20578. * [data classes](https://api.highcharts.com/highmaps#colorAxis.dataClasses)
  20579. * from the Highmaps color axis.
  20580. *
  20581. * @see [minColor](#yAxis.minColor)
  20582. * @see [maxColor](#yAxis.maxColor)
  20583. *
  20584. * @sample {highcharts} highcharts/demo/gauge-solid/
  20585. * True by default
  20586. *
  20587. * @type {Array<Array<number,Highcharts.ColorType>>}
  20588. * @since 4.0
  20589. * @product highcharts
  20590. * @apioption yAxis.stops
  20591. */
  20592. /**
  20593. * The pixel width of the major tick marks.
  20594. *
  20595. * @sample {highcharts} highcharts/xaxis/tickwidth/ 10 px width
  20596. * @sample {highstock} stock/xaxis/ticks/ Formatted ticks on X axis
  20597. *
  20598. * @type {number}
  20599. * @default 0
  20600. * @product highcharts highstock gantt
  20601. * @apioption yAxis.tickWidth
  20602. */
  20603. /**
  20604. * Whether to force the axis to end on a tick. Use this option with
  20605. * the `maxPadding` option to control the axis end.
  20606. *
  20607. * This option is always disabled, when panning type is
  20608. * either `y` or `xy`.
  20609. *
  20610. * @see [type](#chart.panning.type)
  20611. *
  20612. *
  20613. * @sample {highcharts} highcharts/chart/reflow-true/
  20614. * True by default
  20615. * @sample {highcharts} highcharts/yaxis/endontick/
  20616. * False
  20617. * @sample {highstock} stock/demo/basic-line/
  20618. * True by default
  20619. * @sample {highstock} stock/xaxis/endontick/
  20620. * False for Y axis
  20621. *
  20622. * @since 1.2.0
  20623. */
  20624. endOnTick: true,
  20625. /**
  20626. * Padding of the max value relative to the length of the axis. A
  20627. * padding of 0.05 will make a 100px axis 5px longer. This is useful
  20628. * when you don't want the highest data value to appear on the edge
  20629. * of the plot area. When the axis' `max` option is set or a max extreme
  20630. * is set using `axis.setExtremes()`, the maxPadding will be ignored.
  20631. *
  20632. * Also the `softThreshold` option takes precedence over `maxPadding`,
  20633. * so if the data is tangent to the threshold, `maxPadding` may not
  20634. * apply unless `softThreshold` is set to false.
  20635. *
  20636. * @sample {highcharts} highcharts/yaxis/maxpadding-02/
  20637. * Max padding of 0.2
  20638. * @sample {highstock} stock/xaxis/minpadding-maxpadding/
  20639. * Greater min- and maxPadding
  20640. *
  20641. * @since 1.2.0
  20642. * @product highcharts highstock gantt
  20643. */
  20644. maxPadding: 0.05,
  20645. /**
  20646. * Padding of the min value relative to the length of the axis. A
  20647. * padding of 0.05 will make a 100px axis 5px longer. This is useful
  20648. * when you don't want the lowest data value to appear on the edge
  20649. * of the plot area. When the axis' `min` option is set or a max extreme
  20650. * is set using `axis.setExtremes()`, the maxPadding will be ignored.
  20651. *
  20652. * Also the `softThreshold` option takes precedence over `minPadding`,
  20653. * so if the data is tangent to the threshold, `minPadding` may not
  20654. * apply unless `softThreshold` is set to false.
  20655. *
  20656. * @sample {highcharts} highcharts/yaxis/minpadding/
  20657. * Min padding of 0.2
  20658. * @sample {highstock} stock/xaxis/minpadding-maxpadding/
  20659. * Greater min- and maxPadding
  20660. *
  20661. * @since 1.2.0
  20662. * @product highcharts highstock gantt
  20663. */
  20664. minPadding: 0.05,
  20665. /**
  20666. * @productdesc {highstock}
  20667. * In Highcharts Stock 1.x, the Y axis was placed
  20668. * on the left side by default.
  20669. *
  20670. * @sample {highcharts} highcharts/yaxis/opposite/
  20671. * Secondary Y axis opposite
  20672. * @sample {highstock} stock/xaxis/opposite/
  20673. * Y axis on left side
  20674. *
  20675. * @type {boolean}
  20676. * @default {highstock} true
  20677. * @default {highcharts} false
  20678. * @product highstock highcharts gantt
  20679. * @apioption yAxis.opposite
  20680. */
  20681. /**
  20682. * @see [tickInterval](#xAxis.tickInterval)
  20683. * @see [tickPositioner](#xAxis.tickPositioner)
  20684. * @see [tickPositions](#xAxis.tickPositions)
  20685. */
  20686. tickPixelInterval: 72,
  20687. showLastLabel: true,
  20688. /**
  20689. * @extends xAxis.labels
  20690. */
  20691. labels: {
  20692. /**
  20693. * Angular gauges and solid gauges only.
  20694. * The label's pixel distance from the perimeter of the plot area.
  20695. *
  20696. * Since v7.1.2: If it's a percentage string, it is interpreted the
  20697. * same as [series.radius](#plotOptions.gauge.radius), so label can be
  20698. * aligned under the gauge's shape.
  20699. *
  20700. * @sample {highcharts} highcharts/yaxis/labels-distance/
  20701. * Labels centered under the arc
  20702. *
  20703. * @type {number|string}
  20704. * @default -25
  20705. * @product highcharts
  20706. * @apioption yAxis.labels.distance
  20707. */
  20708. /**
  20709. * The y position offset of all labels relative to the tick
  20710. * positions on the axis. For polar and radial axis consider the use
  20711. * of the [distance](#yAxis.labels.distance) option.
  20712. *
  20713. * @sample {highcharts} highcharts/xaxis/labels-x/
  20714. * Y axis labels placed on grid lines
  20715. *
  20716. * @type {number}
  20717. * @default {highcharts} 3
  20718. * @default {highstock} -2
  20719. * @default {highmaps} 3
  20720. * @apioption yAxis.labels.y
  20721. */
  20722. /**
  20723. * What part of the string the given position is anchored to. Can
  20724. * be one of `"left"`, `"center"` or `"right"`. The exact position
  20725. * also depends on the `labels.x` setting.
  20726. *
  20727. * Angular gauges and solid gauges defaults to `"center"`.
  20728. * Solid gauges with two labels have additional option `"auto"`
  20729. * for automatic horizontal and vertical alignment.
  20730. *
  20731. * @see [yAxis.labels.distance](#yAxis.labels.distance)
  20732. *
  20733. * @sample {highcharts} highcharts/yaxis/labels-align-left/
  20734. * Left
  20735. * @sample {highcharts} highcharts/series-solidgauge/labels-auto-aligned/
  20736. * Solid gauge labels auto aligned
  20737. *
  20738. * @type {Highcharts.AlignValue}
  20739. * @default {highcharts|highmaps} right
  20740. * @default {highstock} left
  20741. * @apioption yAxis.labels.align
  20742. */
  20743. /**
  20744. * The x position offset of all labels relative to the tick
  20745. * positions on the axis. Defaults to -15 for left axis, 15 for
  20746. * right axis.
  20747. *
  20748. * @sample {highcharts} highcharts/xaxis/labels-x/
  20749. * Y axis labels placed on grid lines
  20750. */
  20751. x: -8
  20752. },
  20753. /**
  20754. * @productdesc {highmaps}
  20755. * In Highmaps, the axis line is hidden by default, because the axis is
  20756. * not visible by default.
  20757. *
  20758. * @type {Highcharts.ColorType}
  20759. * @apioption yAxis.lineColor
  20760. */
  20761. /**
  20762. * @sample {highcharts} highcharts/yaxis/max-200/
  20763. * Y axis max of 200
  20764. * @sample {highcharts} highcharts/yaxis/max-logarithmic/
  20765. * Y axis max on logarithmic axis
  20766. * @sample {highstock} stock/yaxis/min-max/
  20767. * Fixed min and max on Y axis
  20768. * @sample {highmaps} maps/axis/min-max/
  20769. * Pre-zoomed to a specific area
  20770. *
  20771. * @apioption yAxis.max
  20772. */
  20773. /**
  20774. * @sample {highcharts} highcharts/yaxis/min-startontick-false/
  20775. * -50 with startOnTick to false
  20776. * @sample {highcharts} highcharts/yaxis/min-startontick-true/
  20777. * -50 with startOnTick true by default
  20778. * @sample {highstock} stock/yaxis/min-max/
  20779. * Fixed min and max on Y axis
  20780. * @sample {highmaps} maps/axis/min-max/
  20781. * Pre-zoomed to a specific area
  20782. *
  20783. * @apioption yAxis.min
  20784. */
  20785. /**
  20786. * An optional scrollbar to display on the Y axis in response to
  20787. * limiting the minimum an maximum of the axis values.
  20788. *
  20789. * In styled mode, all the presentational options for the scrollbar
  20790. * are replaced by the classes `.highcharts-scrollbar-thumb`,
  20791. * `.highcharts-scrollbar-arrow`, `.highcharts-scrollbar-button`,
  20792. * `.highcharts-scrollbar-rifles` and `.highcharts-scrollbar-track`.
  20793. *
  20794. * @sample {highstock} stock/yaxis/scrollbar/
  20795. * Scrollbar on the Y axis
  20796. *
  20797. * @extends scrollbar
  20798. * @since 4.2.6
  20799. * @product highstock
  20800. * @excluding height
  20801. * @apioption yAxis.scrollbar
  20802. */
  20803. /**
  20804. * Enable the scrollbar on the Y axis.
  20805. *
  20806. * @sample {highstock} stock/yaxis/scrollbar/
  20807. * Enabled on Y axis
  20808. *
  20809. * @type {boolean}
  20810. * @default false
  20811. * @since 4.2.6
  20812. * @product highstock
  20813. * @apioption yAxis.scrollbar.enabled
  20814. */
  20815. /**
  20816. * Pixel margin between the scrollbar and the axis elements.
  20817. *
  20818. * @type {number}
  20819. * @default 10
  20820. * @since 4.2.6
  20821. * @product highstock
  20822. * @apioption yAxis.scrollbar.margin
  20823. */
  20824. /**
  20825. * Whether to show the scrollbar when it is fully zoomed out at max
  20826. * range. Setting it to `false` on the Y axis makes the scrollbar stay
  20827. * hidden until the user zooms in, like common in browsers.
  20828. *
  20829. * @type {boolean}
  20830. * @default true
  20831. * @since 4.2.6
  20832. * @product highstock
  20833. * @apioption yAxis.scrollbar.showFull
  20834. */
  20835. /**
  20836. * The width of a vertical scrollbar or height of a horizontal
  20837. * scrollbar. Defaults to 20 on touch devices.
  20838. *
  20839. * @type {number}
  20840. * @default 14
  20841. * @since 4.2.6
  20842. * @product highstock
  20843. * @apioption yAxis.scrollbar.size
  20844. */
  20845. /**
  20846. * Z index of the scrollbar elements.
  20847. *
  20848. * @type {number}
  20849. * @default 3
  20850. * @since 4.2.6
  20851. * @product highstock
  20852. * @apioption yAxis.scrollbar.zIndex
  20853. */
  20854. /**
  20855. * A soft maximum for the axis. If the series data maximum is less
  20856. * than this, the axis will stay at this maximum, but if the series
  20857. * data maximum is higher, the axis will flex to show all data.
  20858. *
  20859. * **Note**: The [series.softThreshold](
  20860. * #plotOptions.series.softThreshold) option takes precedence over this
  20861. * option.
  20862. *
  20863. * @sample highcharts/yaxis/softmin-softmax/
  20864. * Soft min and max
  20865. *
  20866. * @type {number}
  20867. * @since 5.0.1
  20868. * @product highcharts highstock gantt
  20869. * @apioption yAxis.softMax
  20870. */
  20871. /**
  20872. * A soft minimum for the axis. If the series data minimum is greater
  20873. * than this, the axis will stay at this minimum, but if the series
  20874. * data minimum is lower, the axis will flex to show all data.
  20875. *
  20876. * **Note**: The [series.softThreshold](
  20877. * #plotOptions.series.softThreshold) option takes precedence over this
  20878. * option.
  20879. *
  20880. * @sample highcharts/yaxis/softmin-softmax/
  20881. * Soft min and max
  20882. *
  20883. * @type {number}
  20884. * @since 5.0.1
  20885. * @product highcharts highstock gantt
  20886. * @apioption yAxis.softMin
  20887. */
  20888. /**
  20889. * Defines the horizontal alignment of the stack total label. Can be one
  20890. * of `"left"`, `"center"` or `"right"`. The default value is calculated
  20891. * at runtime and depends on orientation and whether the stack is
  20892. * positive or negative.
  20893. *
  20894. * @sample {highcharts} highcharts/yaxis/stacklabels-align-left/
  20895. * Aligned to the left
  20896. * @sample {highcharts} highcharts/yaxis/stacklabels-align-center/
  20897. * Aligned in center
  20898. * @sample {highcharts} highcharts/yaxis/stacklabels-align-right/
  20899. * Aligned to the right
  20900. *
  20901. * @type {Highcharts.AlignValue}
  20902. * @since 2.1.5
  20903. * @product highcharts
  20904. * @apioption yAxis.stackLabels.align
  20905. */
  20906. /**
  20907. * A format string for the data label. Available variables are the same
  20908. * as for `formatter`.
  20909. *
  20910. * @type {string}
  20911. * @default {total}
  20912. * @since 3.0.2
  20913. * @product highcharts highstock
  20914. * @apioption yAxis.stackLabels.format
  20915. */
  20916. /**
  20917. * Rotation of the labels in degrees.
  20918. *
  20919. * @sample {highcharts} highcharts/yaxis/stacklabels-rotation/
  20920. * Labels rotated 45°
  20921. *
  20922. * @type {number}
  20923. * @default 0
  20924. * @since 2.1.5
  20925. * @product highcharts
  20926. * @apioption yAxis.stackLabels.rotation
  20927. */
  20928. /**
  20929. * The text alignment for the label. While `align` determines where the
  20930. * texts anchor point is placed with regards to the stack, `textAlign`
  20931. * determines how the text is aligned against its anchor point. Possible
  20932. * values are `"left"`, `"center"` and `"right"`. The default value is
  20933. * calculated at runtime and depends on orientation and whether the
  20934. * stack is positive or negative.
  20935. *
  20936. * @sample {highcharts} highcharts/yaxis/stacklabels-textalign-left/
  20937. * Label in center position but text-aligned left
  20938. *
  20939. * @type {Highcharts.AlignValue}
  20940. * @since 2.1.5
  20941. * @product highcharts
  20942. * @apioption yAxis.stackLabels.textAlign
  20943. */
  20944. /**
  20945. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  20946. * to render the labels.
  20947. *
  20948. * @type {boolean}
  20949. * @default false
  20950. * @since 3.0
  20951. * @product highcharts highstock
  20952. * @apioption yAxis.stackLabels.useHTML
  20953. */
  20954. /**
  20955. * Defines the vertical alignment of the stack total label. Can be one
  20956. * of `"top"`, `"middle"` or `"bottom"`. The default value is calculated
  20957. * at runtime and depends on orientation and whether the stack is
  20958. * positive or negative.
  20959. *
  20960. * @sample {highcharts} highcharts/yaxis/stacklabels-verticalalign-top/
  20961. * Vertically aligned top
  20962. * @sample {highcharts} highcharts/yaxis/stacklabels-verticalalign-middle/
  20963. * Vertically aligned middle
  20964. * @sample {highcharts} highcharts/yaxis/stacklabels-verticalalign-bottom/
  20965. * Vertically aligned bottom
  20966. *
  20967. * @type {Highcharts.VerticalAlignValue}
  20968. * @since 2.1.5
  20969. * @product highcharts
  20970. * @apioption yAxis.stackLabels.verticalAlign
  20971. */
  20972. /**
  20973. * The x position offset of the label relative to the left of the
  20974. * stacked bar. The default value is calculated at runtime and depends
  20975. * on orientation and whether the stack is positive or negative.
  20976. *
  20977. * @sample {highcharts} highcharts/yaxis/stacklabels-x/
  20978. * Stack total labels with x offset
  20979. *
  20980. * @type {number}
  20981. * @since 2.1.5
  20982. * @product highcharts
  20983. * @apioption yAxis.stackLabels.x
  20984. */
  20985. /**
  20986. * The y position offset of the label relative to the tick position
  20987. * on the axis. The default value is calculated at runtime and depends
  20988. * on orientation and whether the stack is positive or negative.
  20989. *
  20990. * @sample {highcharts} highcharts/yaxis/stacklabels-y/
  20991. * Stack total labels with y offset
  20992. *
  20993. * @type {number}
  20994. * @since 2.1.5
  20995. * @product highcharts
  20996. * @apioption yAxis.stackLabels.y
  20997. */
  20998. /**
  20999. * Whether to force the axis to start on a tick. Use this option with
  21000. * the `maxPadding` option to control the axis start.
  21001. *
  21002. * This option is always disabled, when panning type is
  21003. * either `y` or `xy`.
  21004. *
  21005. * @see [type](#chart.panning.type)
  21006. *
  21007. * @sample {highcharts} highcharts/xaxis/startontick-false/
  21008. * False by default
  21009. * @sample {highcharts} highcharts/xaxis/startontick-true/
  21010. * True
  21011. * @sample {highstock} stock/xaxis/endontick/
  21012. * False for Y axis
  21013. *
  21014. * @since 1.2.0
  21015. * @product highcharts highstock gantt
  21016. */
  21017. startOnTick: true,
  21018. title: {
  21019. /**
  21020. * The pixel distance between the axis labels and the title.
  21021. * Positive values are outside the axis line, negative are inside.
  21022. *
  21023. * @sample {highcharts} highcharts/xaxis/title-margin/
  21024. * Y axis title margin of 60
  21025. *
  21026. * @type {number}
  21027. * @default 40
  21028. * @apioption yAxis.title.margin
  21029. */
  21030. /**
  21031. * The rotation of the text in degrees. 0 is horizontal, 270 is
  21032. * vertical reading from bottom to top.
  21033. *
  21034. * @sample {highcharts} highcharts/yaxis/title-offset/
  21035. * Horizontal
  21036. */
  21037. rotation: 270,
  21038. /**
  21039. * The actual text of the axis title. Horizontal texts can contain
  21040. * HTML, but rotated texts are painted using vector techniques and
  21041. * must be clean text. The Y axis title is disabled by setting the
  21042. * `text` option to `undefined`.
  21043. *
  21044. * @sample {highcharts} highcharts/xaxis/title-text/
  21045. * Custom HTML
  21046. *
  21047. * @type {string|null}
  21048. * @default {highcharts} Values
  21049. * @default {highstock} undefined
  21050. * @product highcharts highstock gantt
  21051. */
  21052. text: 'Values'
  21053. },
  21054. /**
  21055. * The top position of the Y axis. If it's a number, it is interpreted
  21056. * as pixel position relative to the chart.
  21057. *
  21058. * Since Highcharts 2: If it's a percentage string, it is interpreted as
  21059. * percentages of the plot height, offset from plot area top.
  21060. *
  21061. * @see [yAxis.height](#yAxis.height)
  21062. *
  21063. * @sample {highstock} stock/demo/candlestick-and-volume/
  21064. * Percentage height panes
  21065. *
  21066. * @type {number|string}
  21067. * @product highcharts highstock
  21068. * @apioption yAxis.top
  21069. */
  21070. /**
  21071. * The stack labels show the total value for each bar in a stacked
  21072. * column or bar chart. The label will be placed on top of positive
  21073. * columns and below negative columns. In case of an inverted column
  21074. * chart or a bar chart the label is placed to the right of positive
  21075. * bars and to the left of negative bars.
  21076. *
  21077. * @product highcharts
  21078. */
  21079. stackLabels: {
  21080. /**
  21081. * Enable or disable the initial animation when a series is
  21082. * displayed for the `stackLabels`. The animation can also be set as
  21083. * a configuration object. Please note that this option only
  21084. * applies to the initial animation.
  21085. * For other animations, see [chart.animation](#chart.animation)
  21086. * and the animation parameter under the API methods.
  21087. * The following properties are supported:
  21088. *
  21089. * - `defer`: The animation delay time in milliseconds.
  21090. *
  21091. * @sample {highcharts} highcharts/plotoptions/animation-defer/
  21092. * Animation defer settings
  21093. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  21094. * @since 8.2.0
  21095. * @apioption yAxis.stackLabels.animation
  21096. */
  21097. animation: {},
  21098. /**
  21099. * The animation delay time in milliseconds.
  21100. * Set to `0` renders stackLabel immediately.
  21101. * As `undefined` inherits defer time from the [series.animation.defer](#plotOptions.series.animation.defer).
  21102. *
  21103. * @type {number}
  21104. * @since 8.2.0
  21105. * @apioption yAxis.stackLabels.animation.defer
  21106. */
  21107. /**
  21108. * Allow the stack labels to overlap.
  21109. *
  21110. * @sample {highcharts} highcharts/yaxis/stacklabels-allowoverlap-false/
  21111. * Default false
  21112. *
  21113. * @since 5.0.13
  21114. * @product highcharts
  21115. */
  21116. allowOverlap: false,
  21117. /**
  21118. * The background color or gradient for the stack label.
  21119. *
  21120. * @sample {highcharts} highcharts/yaxis/stacklabels-box/
  21121. * Stack labels box options
  21122. * @type {Highcharts.ColorType}
  21123. * @since 8.1.0
  21124. * @apioption yAxis.stackLabels.backgroundColor
  21125. */
  21126. /**
  21127. * The border color for the stack label. Defaults to `undefined`.
  21128. *
  21129. * @sample {highcharts} highcharts/yaxis/stacklabels-box/
  21130. * Stack labels box options
  21131. * @type {Highcharts.ColorType}
  21132. * @since 8.1.0
  21133. * @apioption yAxis.stackLabels.borderColor
  21134. */
  21135. /**
  21136. * The border radius in pixels for the stack label.
  21137. *
  21138. * @sample {highcharts} highcharts/yaxis/stacklabels-box/
  21139. * Stack labels box options
  21140. * @type {number}
  21141. * @default 0
  21142. * @since 8.1.0
  21143. * @apioption yAxis.stackLabels.borderRadius
  21144. */
  21145. /**
  21146. * The border width in pixels for the stack label.
  21147. *
  21148. * @sample {highcharts} highcharts/yaxis/stacklabels-box/
  21149. * Stack labels box options
  21150. * @type {number}
  21151. * @default 0
  21152. * @since 8.1.0
  21153. * @apioption yAxis.stackLabels.borderWidth
  21154. */
  21155. /**
  21156. * Enable or disable the stack total labels.
  21157. *
  21158. * @sample {highcharts} highcharts/yaxis/stacklabels-enabled/
  21159. * Enabled stack total labels
  21160. * @sample {highcharts} highcharts/yaxis/stacklabels-enabled-waterfall/
  21161. * Enabled stack labels in waterfall chart
  21162. *
  21163. * @since 2.1.5
  21164. * @product highcharts
  21165. */
  21166. enabled: false,
  21167. /**
  21168. * Whether to hide stack labels that are outside the plot area.
  21169. * By default, the stack label is moved
  21170. * inside the plot area according to the
  21171. * [overflow](/highcharts/#yAxis/stackLabels/overflow)
  21172. * option.
  21173. *
  21174. * @type {boolean}
  21175. * @since 7.1.3
  21176. */
  21177. crop: true,
  21178. /**
  21179. * How to handle stack total labels that flow outside the plot area.
  21180. * The default is set to `"justify"`,
  21181. * which aligns them inside the plot area.
  21182. * For columns and bars, this means it will be moved inside the bar.
  21183. * To display stack labels outside the plot area,
  21184. * set `crop` to `false` and `overflow` to `"allow"`.
  21185. *
  21186. * @sample highcharts/yaxis/stacklabels-overflow/
  21187. * Stack labels flows outside the plot area.
  21188. *
  21189. * @type {Highcharts.DataLabelsOverflowValue}
  21190. * @since 7.1.3
  21191. */
  21192. overflow: 'justify',
  21193. /* eslint-disable valid-jsdoc */
  21194. /**
  21195. * Callback JavaScript function to format the label. The value is
  21196. * given by `this.total`.
  21197. *
  21198. * @sample {highcharts} highcharts/yaxis/stacklabels-formatter/
  21199. * Added units to stack total value
  21200. *
  21201. * @type {Highcharts.FormatterCallbackFunction<Highcharts.StackItemObject>}
  21202. * @since 2.1.5
  21203. * @product highcharts
  21204. */
  21205. formatter: function () {
  21206. var numberFormatter = this.axis.chart.numberFormatter;
  21207. /* eslint-enable valid-jsdoc */
  21208. return numberFormatter(this.total, -1);
  21209. },
  21210. /**
  21211. * CSS styles for the label.
  21212. *
  21213. * In styled mode, the styles are set in the
  21214. * `.highcharts-stack-label` class.
  21215. *
  21216. * @sample {highcharts} highcharts/yaxis/stacklabels-style/
  21217. * Red stack total labels
  21218. *
  21219. * @type {Highcharts.CSSObject}
  21220. * @since 2.1.5
  21221. * @product highcharts
  21222. */
  21223. style: {
  21224. /** @internal */
  21225. color: palette.neutralColor100,
  21226. /** @internal */
  21227. fontSize: '11px',
  21228. /** @internal */
  21229. fontWeight: 'bold',
  21230. /** @internal */
  21231. textOutline: '1px contrast'
  21232. }
  21233. },
  21234. gridLineWidth: 1,
  21235. lineWidth: 0
  21236. // tickWidth: 0
  21237. };
  21238. /**
  21239. * The Z axis or depth axis for 3D plots.
  21240. *
  21241. * See the [Axis class](/class-reference/Highcharts.Axis) for programmatic
  21242. * access to the axis.
  21243. *
  21244. * @sample {highcharts} highcharts/3d/scatter-zaxis-categories/
  21245. * Z-Axis with Categories
  21246. * @sample {highcharts} highcharts/3d/scatter-zaxis-grid/
  21247. * Z-Axis with styling
  21248. *
  21249. * @type {*|Array<*>}
  21250. * @extends xAxis
  21251. * @since 5.0.0
  21252. * @product highcharts
  21253. * @excluding breaks, crosshair, height, left, lineColor, lineWidth,
  21254. * nameToX, showEmpty, top, width
  21255. * @apioption zAxis
  21256. *
  21257. * @private
  21258. */
  21259. // This variable extends the defaultOptions for left axes.
  21260. Axis.defaultLeftAxisOptions = {
  21261. labels: {
  21262. x: -15
  21263. },
  21264. title: {
  21265. rotation: 270
  21266. }
  21267. };
  21268. // This variable extends the defaultOptions for right axes.
  21269. Axis.defaultRightAxisOptions = {
  21270. labels: {
  21271. x: 15
  21272. },
  21273. title: {
  21274. rotation: 90
  21275. }
  21276. };
  21277. // This variable extends the defaultOptions for bottom axes.
  21278. Axis.defaultBottomAxisOptions = {
  21279. labels: {
  21280. autoRotation: [-45],
  21281. x: 0
  21282. // overflow: undefined,
  21283. // staggerLines: null
  21284. },
  21285. margin: 15,
  21286. title: {
  21287. rotation: 0
  21288. }
  21289. };
  21290. // This variable extends the defaultOptions for top axes.
  21291. Axis.defaultTopAxisOptions = {
  21292. labels: {
  21293. autoRotation: [-45],
  21294. x: 0
  21295. // overflow: undefined
  21296. // staggerLines: null
  21297. },
  21298. margin: 15,
  21299. title: {
  21300. rotation: 0
  21301. }
  21302. };
  21303. // Properties to survive after destroy, needed for Axis.update (#4317,
  21304. // #5773, #5881).
  21305. Axis.keepProps = ['extKey', 'hcEvents', 'names', 'series', 'userMax', 'userMin'];
  21306. return Axis;
  21307. }());
  21308. H.Axis = Axis;
  21309. return H.Axis;
  21310. });
  21311. _registerModule(_modules, 'Core/Axis/DateTimeAxis.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Utilities.js']], function (Axis, U) {
  21312. /* *
  21313. *
  21314. * (c) 2010-2021 Torstein Honsi
  21315. *
  21316. * License: www.highcharts.com/license
  21317. *
  21318. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  21319. *
  21320. * */
  21321. var addEvent = U.addEvent,
  21322. getMagnitude = U.getMagnitude,
  21323. normalizeTickInterval = U.normalizeTickInterval,
  21324. timeUnits = U.timeUnits;
  21325. /* eslint-disable valid-jsdoc */
  21326. var DateTimeAxisAdditions = /** @class */ (function () {
  21327. /* *
  21328. *
  21329. * Constructors
  21330. *
  21331. * */
  21332. function DateTimeAxisAdditions(axis) {
  21333. this.axis = axis;
  21334. }
  21335. /* *
  21336. *
  21337. * Functions
  21338. *
  21339. * */
  21340. /**
  21341. * Get a normalized tick interval for dates. Returns a configuration object
  21342. * with unit range (interval), count and name. Used to prepare data for
  21343. * `getTimeTicks`. Previously this logic was part of getTimeTicks, but as
  21344. * `getTimeTicks` now runs of segments in stock charts, the normalizing
  21345. * logic was extracted in order to prevent it for running over again for
  21346. * each segment having the same interval. #662, #697.
  21347. * @private
  21348. */
  21349. /**
  21350. * Get a normalized tick interval for dates. Returns a configuration object
  21351. * with unit range (interval), count and name. Used to prepare data for
  21352. * `getTimeTicks`. Previously this logic was part of getTimeTicks, but as
  21353. * `getTimeTicks` now runs of segments in stock charts, the normalizing
  21354. * logic was extracted in order to prevent it for running over again for
  21355. * each segment having the same interval. #662, #697.
  21356. * @private
  21357. */
  21358. DateTimeAxisAdditions.prototype.normalizeTimeTickInterval = function (tickInterval, unitsOption) {
  21359. var units = unitsOption || [[
  21360. 'millisecond',
  21361. [1, 2, 5, 10, 20, 25, 50, 100, 200, 500] // allowed multiples
  21362. ],
  21363. [
  21364. 'second',
  21365. [1, 2, 5, 10, 15, 30]
  21366. ],
  21367. [
  21368. 'minute',
  21369. [1, 2, 5, 10, 15, 30]
  21370. ],
  21371. [
  21372. 'hour',
  21373. [1, 2, 3, 4, 6, 8, 12]
  21374. ],
  21375. [
  21376. 'day',
  21377. [1, 2]
  21378. ],
  21379. [
  21380. 'week',
  21381. [1, 2]
  21382. ],
  21383. [
  21384. 'month',
  21385. [1, 2, 3, 4, 6]
  21386. ],
  21387. [
  21388. 'year',
  21389. null
  21390. ]],
  21391. unit = units[units.length - 1], // default unit is years
  21392. interval = timeUnits[unit[0]],
  21393. multiples = unit[1],
  21394. count,
  21395. i;
  21396. // loop through the units to find the one that best fits the
  21397. // tickInterval
  21398. for (i = 0; i < units.length; i++) {
  21399. unit = units[i];
  21400. interval = timeUnits[unit[0]];
  21401. multiples = unit[1];
  21402. if (units[i + 1]) {
  21403. // lessThan is in the middle between the highest multiple and
  21404. // the next unit.
  21405. var lessThan = (interval *
  21406. multiples[multiples.length - 1] +
  21407. timeUnits[units[i + 1][0]]) / 2;
  21408. // break and keep the current unit
  21409. if (tickInterval <= lessThan) {
  21410. break;
  21411. }
  21412. }
  21413. }
  21414. // prevent 2.5 years intervals, though 25, 250 etc. are allowed
  21415. if (interval === timeUnits.year && tickInterval < 5 * interval) {
  21416. multiples = [1, 2, 5];
  21417. }
  21418. // get the count
  21419. count = normalizeTickInterval(tickInterval / interval, multiples, unit[0] === 'year' ? // #1913, #2360
  21420. Math.max(getMagnitude(tickInterval / interval), 1) :
  21421. 1);
  21422. return {
  21423. unitRange: interval,
  21424. count: count,
  21425. unitName: unit[0]
  21426. };
  21427. };
  21428. return DateTimeAxisAdditions;
  21429. }());
  21430. /**
  21431. * Date and time support for axes.
  21432. *
  21433. * @private
  21434. * @class
  21435. */
  21436. var DateTimeAxis = /** @class */ (function () {
  21437. function DateTimeAxis() {
  21438. }
  21439. /* *
  21440. *
  21441. * Static Functions
  21442. *
  21443. * */
  21444. /**
  21445. * Extends axis class with date and time support.
  21446. * @private
  21447. */
  21448. DateTimeAxis.compose = function (AxisClass) {
  21449. AxisClass.keepProps.push('dateTime');
  21450. var axisProto = AxisClass.prototype;
  21451. /**
  21452. * Set the tick positions to a time unit that makes sense, for example
  21453. * on the first of each month or on every Monday. Return an array with
  21454. * the time positions. Used in datetime axes as well as for grouping
  21455. * data on a datetime axis.
  21456. *
  21457. * @private
  21458. * @function Highcharts.Axis#getTimeTicks
  21459. *
  21460. * @param {Highcharts.TimeNormalizeObject} normalizedInterval
  21461. * The interval in axis values (ms) and thecount.
  21462. *
  21463. * @param {number} min
  21464. * The minimum in axis values.
  21465. *
  21466. * @param {number} max
  21467. * The maximum in axis values.
  21468. *
  21469. * @param {number} startOfWeek
  21470. *
  21471. * @return {Highcharts.AxisTickPositionsArray}
  21472. */
  21473. axisProto.getTimeTicks = function () {
  21474. return this.chart.time.getTimeTicks.apply(this.chart.time, arguments);
  21475. };
  21476. /* eslint-disable no-invalid-this */
  21477. addEvent(AxisClass, 'init', function (e) {
  21478. var axis = this;
  21479. var options = e.userOptions;
  21480. if (options.type !== 'datetime') {
  21481. axis.dateTime = void 0;
  21482. return;
  21483. }
  21484. if (!axis.dateTime) {
  21485. axis.dateTime = new DateTimeAxisAdditions(axis);
  21486. }
  21487. });
  21488. /* eslint-enable no-invalid-this */
  21489. };
  21490. /* *
  21491. *
  21492. * Static Properties
  21493. *
  21494. * */
  21495. DateTimeAxis.AdditionsClass = DateTimeAxisAdditions;
  21496. return DateTimeAxis;
  21497. }());
  21498. DateTimeAxis.compose(Axis);
  21499. return DateTimeAxis;
  21500. });
  21501. _registerModule(_modules, 'Core/Axis/LogarithmicAxis.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Utilities.js']], function (Axis, U) {
  21502. /* *
  21503. *
  21504. * (c) 2010-2021 Torstein Honsi
  21505. *
  21506. * License: www.highcharts.com/license
  21507. *
  21508. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  21509. *
  21510. * */
  21511. var addEvent = U.addEvent,
  21512. getMagnitude = U.getMagnitude,
  21513. normalizeTickInterval = U.normalizeTickInterval,
  21514. pick = U.pick;
  21515. /* eslint-disable valid-jsdoc */
  21516. /**
  21517. * Provides logarithmic support for axes.
  21518. *
  21519. * @private
  21520. * @class
  21521. */
  21522. var LogarithmicAxisAdditions = /** @class */ (function () {
  21523. /* *
  21524. *
  21525. * Constructors
  21526. *
  21527. * */
  21528. function LogarithmicAxisAdditions(axis) {
  21529. this.axis = axis;
  21530. }
  21531. /* *
  21532. *
  21533. * Functions
  21534. *
  21535. * */
  21536. /**
  21537. * Set the tick positions of a logarithmic axis.
  21538. */
  21539. LogarithmicAxisAdditions.prototype.getLogTickPositions = function (interval, min, max, minor) {
  21540. var log = this;
  21541. var axis = log.axis;
  21542. var axisLength = axis.len;
  21543. var options = axis.options;
  21544. // Since we use this method for both major and minor ticks,
  21545. // use a local variable and return the result
  21546. var positions = [];
  21547. // Reset
  21548. if (!minor) {
  21549. log.minorAutoInterval = void 0;
  21550. }
  21551. // First case: All ticks fall on whole logarithms: 1, 10, 100 etc.
  21552. if (interval >= 0.5) {
  21553. interval = Math.round(interval);
  21554. positions = axis.getLinearTickPositions(interval, min, max);
  21555. // Second case: We need intermediary ticks. For example
  21556. // 1, 2, 4, 6, 8, 10, 20, 40 etc.
  21557. }
  21558. else if (interval >= 0.08) {
  21559. var roundedMin = Math.floor(min),
  21560. intermediate = void 0,
  21561. i = void 0,
  21562. j = void 0,
  21563. len = void 0,
  21564. pos = void 0,
  21565. lastPos = void 0,
  21566. break2 = void 0;
  21567. if (interval > 0.3) {
  21568. intermediate = [1, 2, 4];
  21569. // 0.2 equals five minor ticks per 1, 10, 100 etc
  21570. }
  21571. else if (interval > 0.15) {
  21572. intermediate = [1, 2, 4, 6, 8];
  21573. }
  21574. else { // 0.1 equals ten minor ticks per 1, 10, 100 etc
  21575. intermediate = [1, 2, 3, 4, 5, 6, 7, 8, 9];
  21576. }
  21577. for (i = roundedMin; i < max + 1 && !break2; i++) {
  21578. len = intermediate.length;
  21579. for (j = 0; j < len && !break2; j++) {
  21580. pos = log.log2lin(log.lin2log(i) * intermediate[j]);
  21581. // #1670, lastPos is #3113
  21582. if (pos > min &&
  21583. (!minor || lastPos <= max) &&
  21584. typeof lastPos !== 'undefined') {
  21585. positions.push(lastPos);
  21586. }
  21587. if (lastPos > max) {
  21588. break2 = true;
  21589. }
  21590. lastPos = pos;
  21591. }
  21592. }
  21593. // Third case: We are so deep in between whole logarithmic values that
  21594. // we might as well handle the tick positions like a linear axis. For
  21595. // example 1.01, 1.02, 1.03, 1.04.
  21596. }
  21597. else {
  21598. var realMin = log.lin2log(min),
  21599. realMax = log.lin2log(max),
  21600. tickIntervalOption = minor ?
  21601. axis.getMinorTickInterval() :
  21602. options.tickInterval,
  21603. filteredTickIntervalOption = tickIntervalOption === 'auto' ?
  21604. null :
  21605. tickIntervalOption,
  21606. tickPixelIntervalOption = options.tickPixelInterval / (minor ? 5 : 1),
  21607. totalPixelLength = minor ?
  21608. axisLength / axis.tickPositions.length :
  21609. axisLength;
  21610. interval = pick(filteredTickIntervalOption, log.minorAutoInterval, (realMax - realMin) *
  21611. tickPixelIntervalOption / (totalPixelLength || 1));
  21612. interval = normalizeTickInterval(interval, void 0, getMagnitude(interval));
  21613. positions = axis.getLinearTickPositions(interval, realMin, realMax).map(log.log2lin);
  21614. if (!minor) {
  21615. log.minorAutoInterval = interval / 5;
  21616. }
  21617. }
  21618. // Set the axis-level tickInterval variable
  21619. if (!minor) {
  21620. axis.tickInterval = interval;
  21621. }
  21622. return positions;
  21623. };
  21624. LogarithmicAxisAdditions.prototype.lin2log = function (num) {
  21625. return Math.pow(10, num);
  21626. };
  21627. LogarithmicAxisAdditions.prototype.log2lin = function (num) {
  21628. return Math.log(num) / Math.LN10;
  21629. };
  21630. return LogarithmicAxisAdditions;
  21631. }());
  21632. var LogarithmicAxis = /** @class */ (function () {
  21633. function LogarithmicAxis() {
  21634. }
  21635. /**
  21636. * Provides logarithmic support for axes.
  21637. *
  21638. * @private
  21639. */
  21640. LogarithmicAxis.compose = function (AxisClass) {
  21641. AxisClass.keepProps.push('logarithmic');
  21642. /* eslint-disable no-invalid-this */
  21643. addEvent(AxisClass, 'init', function (e) {
  21644. var axis = this;
  21645. var options = e.userOptions;
  21646. var logarithmic = axis.logarithmic;
  21647. if (options.type !== 'logarithmic') {
  21648. axis.logarithmic = void 0;
  21649. }
  21650. else {
  21651. if (!logarithmic) {
  21652. logarithmic = axis.logarithmic = new LogarithmicAxisAdditions(axis);
  21653. }
  21654. }
  21655. });
  21656. addEvent(AxisClass, 'afterInit', function () {
  21657. var axis = this;
  21658. var log = axis.logarithmic;
  21659. // extend logarithmic axis
  21660. if (log) {
  21661. axis.lin2val = function (num) {
  21662. return log.lin2log(num);
  21663. };
  21664. axis.val2lin = function (num) {
  21665. return log.log2lin(num);
  21666. };
  21667. }
  21668. });
  21669. };
  21670. return LogarithmicAxis;
  21671. }());
  21672. LogarithmicAxis.compose(Axis); // @todo move to factory functions
  21673. return LogarithmicAxis;
  21674. });
  21675. _registerModule(_modules, 'Core/Axis/PlotLineOrBand.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Globals.js'], _modules['Core/Color/Palette.js'], _modules['Core/Utilities.js']], function (Axis, H, palette, U) {
  21676. /* *
  21677. *
  21678. * (c) 2010-2021 Torstein Honsi
  21679. *
  21680. * License: www.highcharts.com/license
  21681. *
  21682. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  21683. *
  21684. * */
  21685. /**
  21686. * Options for plot bands on axes.
  21687. *
  21688. * @typedef {Highcharts.XAxisPlotBandsOptions|Highcharts.YAxisPlotBandsOptions|Highcharts.ZAxisPlotBandsOptions} Highcharts.AxisPlotBandsOptions
  21689. */
  21690. /**
  21691. * Options for plot band labels on axes.
  21692. *
  21693. * @typedef {Highcharts.XAxisPlotBandsLabelOptions|Highcharts.YAxisPlotBandsLabelOptions|Highcharts.ZAxisPlotBandsLabelOptions} Highcharts.AxisPlotBandsLabelOptions
  21694. */
  21695. /**
  21696. * Options for plot lines on axes.
  21697. *
  21698. * @typedef {Highcharts.XAxisPlotLinesOptions|Highcharts.YAxisPlotLinesOptions|Highcharts.ZAxisPlotLinesOptions} Highcharts.AxisPlotLinesOptions
  21699. */
  21700. /**
  21701. * Options for plot line labels on axes.
  21702. *
  21703. * @typedef {Highcharts.XAxisPlotLinesLabelOptions|Highcharts.YAxisPlotLinesLabelOptions|Highcharts.ZAxisPlotLinesLabelOptions} Highcharts.AxisPlotLinesLabelOptions
  21704. */
  21705. var arrayMax = U.arrayMax,
  21706. arrayMin = U.arrayMin,
  21707. defined = U.defined,
  21708. destroyObjectProperties = U.destroyObjectProperties,
  21709. erase = U.erase,
  21710. extend = U.extend,
  21711. fireEvent = U.fireEvent,
  21712. isNumber = U.isNumber,
  21713. merge = U.merge,
  21714. objectEach = U.objectEach,
  21715. pick = U.pick;
  21716. /* eslint-disable no-invalid-this, valid-jsdoc */
  21717. /**
  21718. * The object wrapper for plot lines and plot bands
  21719. *
  21720. * @class
  21721. * @name Highcharts.PlotLineOrBand
  21722. *
  21723. * @param {Highcharts.Axis} axis
  21724. *
  21725. * @param {Highcharts.AxisPlotLinesOptions|Highcharts.AxisPlotBandsOptions} [options]
  21726. */
  21727. var PlotLineOrBand = /** @class */ (function () {
  21728. function PlotLineOrBand(axis, options) {
  21729. this.axis = axis;
  21730. if (options) {
  21731. this.options = options;
  21732. this.id = options.id;
  21733. }
  21734. }
  21735. /**
  21736. * Render the plot line or plot band. If it is already existing,
  21737. * move it.
  21738. *
  21739. * @private
  21740. * @function Highcharts.PlotLineOrBand#render
  21741. * @return {Highcharts.PlotLineOrBand|undefined}
  21742. */
  21743. PlotLineOrBand.prototype.render = function () {
  21744. fireEvent(this, 'render');
  21745. var plotLine = this,
  21746. axis = plotLine.axis,
  21747. horiz = axis.horiz,
  21748. log = axis.logarithmic,
  21749. options = plotLine.options,
  21750. optionsLabel = options.label,
  21751. label = plotLine.label,
  21752. to = options.to,
  21753. from = options.from,
  21754. value = options.value,
  21755. isBand = defined(from) && defined(to),
  21756. isLine = defined(value),
  21757. svgElem = plotLine.svgElem,
  21758. isNew = !svgElem,
  21759. path = [],
  21760. color = options.color,
  21761. zIndex = pick(options.zIndex, 0),
  21762. events = options.events,
  21763. attribs = {
  21764. 'class': 'highcharts-plot-' + (isBand ? 'band ' : 'line ') +
  21765. (options.className || '')
  21766. },
  21767. groupAttribs = {},
  21768. renderer = axis.chart.renderer,
  21769. groupName = isBand ? 'bands' : 'lines',
  21770. group;
  21771. // logarithmic conversion
  21772. if (log) {
  21773. from = log.log2lin(from);
  21774. to = log.log2lin(to);
  21775. value = log.log2lin(value);
  21776. }
  21777. // Set the presentational attributes
  21778. if (!axis.chart.styledMode) {
  21779. if (isLine) {
  21780. attribs.stroke = color || palette.neutralColor40;
  21781. attribs['stroke-width'] = pick(options.width, 1);
  21782. if (options.dashStyle) {
  21783. attribs.dashstyle =
  21784. options.dashStyle;
  21785. }
  21786. }
  21787. else if (isBand) { // plot band
  21788. attribs.fill = color || palette.highlightColor10;
  21789. if (options.borderWidth) {
  21790. attribs.stroke = options.borderColor;
  21791. attribs['stroke-width'] = options.borderWidth;
  21792. }
  21793. }
  21794. }
  21795. // Grouping and zIndex
  21796. groupAttribs.zIndex = zIndex;
  21797. groupName += '-' + zIndex;
  21798. group = axis.plotLinesAndBandsGroups[groupName];
  21799. if (!group) {
  21800. axis.plotLinesAndBandsGroups[groupName] = group =
  21801. renderer.g('plot-' + groupName)
  21802. .attr(groupAttribs).add();
  21803. }
  21804. // Create the path
  21805. if (isNew) {
  21806. /**
  21807. * SVG element of the plot line or band.
  21808. *
  21809. * @name Highcharts.PlotLineOrBand#svgElement
  21810. * @type {Highcharts.SVGElement}
  21811. */
  21812. plotLine.svgElem = svgElem = renderer
  21813. .path()
  21814. .attr(attribs)
  21815. .add(group);
  21816. }
  21817. // Set the path or return
  21818. if (isLine) {
  21819. path = axis.getPlotLinePath({
  21820. value: value,
  21821. lineWidth: svgElem.strokeWidth(),
  21822. acrossPanes: options.acrossPanes
  21823. });
  21824. }
  21825. else if (isBand) { // plot band
  21826. path = axis.getPlotBandPath(from, to, options);
  21827. }
  21828. else {
  21829. return;
  21830. }
  21831. // common for lines and bands
  21832. // Add events only if they were not added before.
  21833. if (!plotLine.eventsAdded && events) {
  21834. objectEach(events, function (event, eventType) {
  21835. svgElem.on(eventType, function (e) {
  21836. events[eventType].apply(plotLine, [e]);
  21837. });
  21838. });
  21839. plotLine.eventsAdded = true;
  21840. }
  21841. if ((isNew || !svgElem.d) && path && path.length) {
  21842. svgElem.attr({ d: path });
  21843. }
  21844. else if (svgElem) {
  21845. if (path) {
  21846. svgElem.show(true);
  21847. svgElem.animate({ d: path });
  21848. }
  21849. else if (svgElem.d) {
  21850. svgElem.hide();
  21851. if (label) {
  21852. plotLine.label = label = label.destroy();
  21853. }
  21854. }
  21855. }
  21856. // the plot band/line label
  21857. if (optionsLabel &&
  21858. (defined(optionsLabel.text) || defined(optionsLabel.formatter)) &&
  21859. path &&
  21860. path.length &&
  21861. axis.width > 0 &&
  21862. axis.height > 0 &&
  21863. !path.isFlat) {
  21864. // apply defaults
  21865. optionsLabel = merge({
  21866. align: horiz && isBand && 'center',
  21867. x: horiz ? !isBand && 4 : 10,
  21868. verticalAlign: !horiz && isBand && 'middle',
  21869. y: horiz ? isBand ? 16 : 10 : isBand ? 6 : -4,
  21870. rotation: horiz && !isBand && 90
  21871. }, optionsLabel);
  21872. this.renderLabel(optionsLabel, path, isBand, zIndex);
  21873. }
  21874. else if (label) { // move out of sight
  21875. label.hide();
  21876. }
  21877. // chainable
  21878. return plotLine;
  21879. };
  21880. /**
  21881. * Render and align label for plot line or band.
  21882. *
  21883. * @private
  21884. * @function Highcharts.PlotLineOrBand#renderLabel
  21885. * @param {Highcharts.AxisPlotLinesLabelOptions|Highcharts.AxisPlotBandsLabelOptions} optionsLabel
  21886. * @param {Highcharts.SVGPathArray} path
  21887. * @param {boolean} [isBand]
  21888. * @param {number} [zIndex]
  21889. * @return {void}
  21890. */
  21891. PlotLineOrBand.prototype.renderLabel = function (optionsLabel, path, isBand, zIndex) {
  21892. var plotLine = this,
  21893. label = plotLine.label,
  21894. renderer = plotLine.axis.chart.renderer,
  21895. attribs,
  21896. xBounds,
  21897. yBounds,
  21898. x,
  21899. y,
  21900. labelText;
  21901. // add the SVG element
  21902. if (!label) {
  21903. attribs = {
  21904. align: optionsLabel.textAlign || optionsLabel.align,
  21905. rotation: optionsLabel.rotation,
  21906. 'class': 'highcharts-plot-' + (isBand ? 'band' : 'line') +
  21907. '-label ' + (optionsLabel.className || '')
  21908. };
  21909. attribs.zIndex = zIndex;
  21910. labelText = this.getLabelText(optionsLabel);
  21911. /**
  21912. * SVG element of the label.
  21913. *
  21914. * @name Highcharts.PlotLineOrBand#label
  21915. * @type {Highcharts.SVGElement}
  21916. */
  21917. plotLine.label = label = renderer
  21918. .text(labelText, 0, 0, optionsLabel.useHTML)
  21919. .attr(attribs)
  21920. .add();
  21921. if (!this.axis.chart.styledMode) {
  21922. label.css(optionsLabel.style);
  21923. }
  21924. }
  21925. // get the bounding box and align the label
  21926. // #3000 changed to better handle choice between plotband or plotline
  21927. xBounds = path.xBounds ||
  21928. [path[0][1], path[1][1], (isBand ? path[2][1] : path[0][1])];
  21929. yBounds = path.yBounds ||
  21930. [path[0][2], path[1][2], (isBand ? path[2][2] : path[0][2])];
  21931. x = arrayMin(xBounds);
  21932. y = arrayMin(yBounds);
  21933. label.align(optionsLabel, false, {
  21934. x: x,
  21935. y: y,
  21936. width: arrayMax(xBounds) - x,
  21937. height: arrayMax(yBounds) - y
  21938. });
  21939. label.show(true);
  21940. };
  21941. /**
  21942. * Get label's text content.
  21943. *
  21944. * @private
  21945. * @function Highcharts.PlotLineOrBand#getLabelText
  21946. * @param {Highcharts.AxisPlotLinesLabelOptions|Highcharts.AxisPlotBandsLabelOptions} optionsLabel
  21947. * @return {string}
  21948. */
  21949. PlotLineOrBand.prototype.getLabelText = function (optionsLabel) {
  21950. return defined(optionsLabel.formatter) ?
  21951. optionsLabel.formatter
  21952. .call(this) :
  21953. optionsLabel.text;
  21954. };
  21955. /**
  21956. * Remove the plot line or band.
  21957. *
  21958. * @function Highcharts.PlotLineOrBand#destroy
  21959. * @return {void}
  21960. */
  21961. PlotLineOrBand.prototype.destroy = function () {
  21962. // remove it from the lookup
  21963. erase(this.axis.plotLinesAndBands, this);
  21964. delete this.axis;
  21965. destroyObjectProperties(this);
  21966. };
  21967. return PlotLineOrBand;
  21968. }());
  21969. /* eslint-enable no-invalid-this, valid-jsdoc */
  21970. // Object with members for extending the Axis prototype
  21971. extend(Axis.prototype, /** @lends Highcharts.Axis.prototype */ {
  21972. /**
  21973. * An array of colored bands stretching across the plot area marking an
  21974. * interval on the axis.
  21975. *
  21976. * In styled mode, the plot bands are styled by the `.highcharts-plot-band`
  21977. * class in addition to the `className` option.
  21978. *
  21979. * @productdesc {highcharts}
  21980. * In a gauge, a plot band on the Y axis (value axis) will stretch along the
  21981. * perimeter of the gauge.
  21982. *
  21983. * @type {Array<*>}
  21984. * @product highcharts highstock gantt
  21985. * @apioption xAxis.plotBands
  21986. */
  21987. /**
  21988. * Flag to decide if plotBand should be rendered across all panes.
  21989. *
  21990. * @since 7.1.2
  21991. * @product highstock
  21992. * @type {boolean}
  21993. * @default true
  21994. * @apioption xAxis.plotBands.acrossPanes
  21995. */
  21996. /**
  21997. * Border color for the plot band. Also requires `borderWidth` to be set.
  21998. *
  21999. * @type {Highcharts.ColorString}
  22000. * @apioption xAxis.plotBands.borderColor
  22001. */
  22002. /**
  22003. * Border width for the plot band. Also requires `borderColor` to be set.
  22004. *
  22005. * @type {number}
  22006. * @default 0
  22007. * @apioption xAxis.plotBands.borderWidth
  22008. */
  22009. /**
  22010. * A custom class name, in addition to the default `highcharts-plot-band`,
  22011. * to apply to each individual band.
  22012. *
  22013. * @type {string}
  22014. * @since 5.0.0
  22015. * @apioption xAxis.plotBands.className
  22016. */
  22017. /**
  22018. * The color of the plot band.
  22019. *
  22020. * @sample {highcharts} highcharts/xaxis/plotbands-color/
  22021. * Color band
  22022. * @sample {highstock} stock/xaxis/plotbands/
  22023. * Plot band on Y axis
  22024. *
  22025. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  22026. * @default ${palette.highlightColor10}
  22027. * @apioption xAxis.plotBands.color
  22028. */
  22029. /**
  22030. * An object defining mouse events for the plot band. Supported properties
  22031. * are `click`, `mouseover`, `mouseout`, `mousemove`.
  22032. *
  22033. * @sample {highcharts} highcharts/xaxis/plotbands-events/
  22034. * Mouse events demonstrated
  22035. *
  22036. * @since 1.2
  22037. * @apioption xAxis.plotBands.events
  22038. */
  22039. /**
  22040. * Click event on a plot band.
  22041. *
  22042. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  22043. * @apioption xAxis.plotBands.events.click
  22044. */
  22045. /**
  22046. * Mouse move event on a plot band.
  22047. *
  22048. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  22049. * @apioption xAxis.plotBands.events.mousemove
  22050. */
  22051. /**
  22052. * Mouse out event on the corner of a plot band.
  22053. *
  22054. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  22055. * @apioption xAxis.plotBands.events.mouseout
  22056. */
  22057. /**
  22058. * Mouse over event on a plot band.
  22059. *
  22060. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  22061. * @apioption xAxis.plotBands.events.mouseover
  22062. */
  22063. /**
  22064. * The start position of the plot band in axis units.
  22065. *
  22066. * @sample {highcharts} highcharts/xaxis/plotbands-color/
  22067. * Datetime axis
  22068. * @sample {highcharts} highcharts/xaxis/plotbands-from/
  22069. * Categorized axis
  22070. * @sample {highstock} stock/xaxis/plotbands/
  22071. * Plot band on Y axis
  22072. *
  22073. * @type {number}
  22074. * @apioption xAxis.plotBands.from
  22075. */
  22076. /**
  22077. * An id used for identifying the plot band in Axis.removePlotBand.
  22078. *
  22079. * @sample {highcharts} highcharts/xaxis/plotbands-id/
  22080. * Remove plot band by id
  22081. * @sample {highstock} highcharts/xaxis/plotbands-id/
  22082. * Remove plot band by id
  22083. *
  22084. * @type {string}
  22085. * @apioption xAxis.plotBands.id
  22086. */
  22087. /**
  22088. * The end position of the plot band in axis units.
  22089. *
  22090. * @sample {highcharts} highcharts/xaxis/plotbands-color/
  22091. * Datetime axis
  22092. * @sample {highcharts} highcharts/xaxis/plotbands-from/
  22093. * Categorized axis
  22094. * @sample {highstock} stock/xaxis/plotbands/
  22095. * Plot band on Y axis
  22096. *
  22097. * @type {number}
  22098. * @apioption xAxis.plotBands.to
  22099. */
  22100. /**
  22101. * The z index of the plot band within the chart, relative to other
  22102. * elements. Using the same z index as another element may give
  22103. * unpredictable results, as the last rendered element will be on top.
  22104. * Values from 0 to 20 make sense.
  22105. *
  22106. * @sample {highcharts} highcharts/xaxis/plotbands-color/
  22107. * Behind plot lines by default
  22108. * @sample {highcharts} highcharts/xaxis/plotbands-zindex/
  22109. * Above plot lines
  22110. * @sample {highcharts} highcharts/xaxis/plotbands-zindex-above-series/
  22111. * Above plot lines and series
  22112. *
  22113. * @type {number}
  22114. * @since 1.2
  22115. * @apioption xAxis.plotBands.zIndex
  22116. */
  22117. /**
  22118. * Text labels for the plot bands
  22119. *
  22120. * @product highcharts highstock gantt
  22121. * @apioption xAxis.plotBands.label
  22122. */
  22123. /**
  22124. * Horizontal alignment of the label. Can be one of "left", "center" or
  22125. * "right".
  22126. *
  22127. * @sample {highcharts} highcharts/xaxis/plotbands-label-align/
  22128. * Aligned to the right
  22129. * @sample {highstock} stock/xaxis/plotbands-label/
  22130. * Plot band with labels
  22131. *
  22132. * @type {Highcharts.AlignValue}
  22133. * @default center
  22134. * @since 2.1
  22135. * @apioption xAxis.plotBands.label.align
  22136. */
  22137. /**
  22138. * Rotation of the text label in degrees .
  22139. *
  22140. * @sample {highcharts} highcharts/xaxis/plotbands-label-rotation/
  22141. * Vertical text
  22142. *
  22143. * @type {number}
  22144. * @default 0
  22145. * @since 2.1
  22146. * @apioption xAxis.plotBands.label.rotation
  22147. */
  22148. /**
  22149. * CSS styles for the text label.
  22150. *
  22151. * In styled mode, the labels are styled by the
  22152. * `.highcharts-plot-band-label` class.
  22153. *
  22154. * @sample {highcharts} highcharts/xaxis/plotbands-label-style/
  22155. * Blue and bold label
  22156. *
  22157. * @type {Highcharts.CSSObject}
  22158. * @since 2.1
  22159. * @apioption xAxis.plotBands.label.style
  22160. */
  22161. /**
  22162. * The string text itself. A subset of HTML is supported.
  22163. *
  22164. * @type {string}
  22165. * @since 2.1
  22166. * @apioption xAxis.plotBands.label.text
  22167. */
  22168. /**
  22169. * The text alignment for the label. While `align` determines where the
  22170. * texts anchor point is placed within the plot band, `textAlign` determines
  22171. * how the text is aligned against its anchor point. Possible values are
  22172. * "left", "center" and "right". Defaults to the same as the `align` option.
  22173. *
  22174. * @sample {highcharts} highcharts/xaxis/plotbands-label-rotation/
  22175. * Vertical text in center position but text-aligned left
  22176. *
  22177. * @type {Highcharts.AlignValue}
  22178. * @since 2.1
  22179. * @apioption xAxis.plotBands.label.textAlign
  22180. */
  22181. /**
  22182. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  22183. * to render the labels.
  22184. *
  22185. * @type {boolean}
  22186. * @default false
  22187. * @since 3.0.3
  22188. * @apioption xAxis.plotBands.label.useHTML
  22189. */
  22190. /**
  22191. * Vertical alignment of the label relative to the plot band. Can be one of
  22192. * "top", "middle" or "bottom".
  22193. *
  22194. * @sample {highcharts} highcharts/xaxis/plotbands-label-verticalalign/
  22195. * Vertically centered label
  22196. * @sample {highstock} stock/xaxis/plotbands-label/
  22197. * Plot band with labels
  22198. *
  22199. * @type {Highcharts.VerticalAlignValue}
  22200. * @default top
  22201. * @since 2.1
  22202. * @apioption xAxis.plotBands.label.verticalAlign
  22203. */
  22204. /**
  22205. * Horizontal position relative the alignment. Default varies by
  22206. * orientation.
  22207. *
  22208. * @sample {highcharts} highcharts/xaxis/plotbands-label-align/
  22209. * Aligned 10px from the right edge
  22210. * @sample {highstock} stock/xaxis/plotbands-label/
  22211. * Plot band with labels
  22212. *
  22213. * @type {number}
  22214. * @since 2.1
  22215. * @apioption xAxis.plotBands.label.x
  22216. */
  22217. /**
  22218. * Vertical position of the text baseline relative to the alignment. Default
  22219. * varies by orientation.
  22220. *
  22221. * @sample {highcharts} highcharts/xaxis/plotbands-label-y/
  22222. * Label on x axis
  22223. * @sample {highstock} stock/xaxis/plotbands-label/
  22224. * Plot band with labels
  22225. *
  22226. * @type {number}
  22227. * @since 2.1
  22228. * @apioption xAxis.plotBands.label.y
  22229. */
  22230. /**
  22231. * An array of lines stretching across the plot area, marking a specific
  22232. * value on one of the axes.
  22233. *
  22234. * In styled mode, the plot lines are styled by the
  22235. * `.highcharts-plot-line` class in addition to the `className` option.
  22236. *
  22237. * @type {Array<*>}
  22238. * @product highcharts highstock gantt
  22239. * @sample {highcharts} highcharts/xaxis/plotlines-color/
  22240. * Basic plot line
  22241. * @sample {highcharts} highcharts/series-solidgauge/labels-auto-aligned/
  22242. * Solid gauge plot line
  22243. * @apioption xAxis.plotLines
  22244. */
  22245. /**
  22246. * Flag to decide if plotLine should be rendered across all panes.
  22247. *
  22248. * @sample {highstock} stock/xaxis/plotlines-acrosspanes/
  22249. * Plot lines on different panes
  22250. *
  22251. * @since 7.1.2
  22252. * @product highstock
  22253. * @type {boolean}
  22254. * @default true
  22255. * @apioption xAxis.plotLines.acrossPanes
  22256. */
  22257. /**
  22258. * A custom class name, in addition to the default `highcharts-plot-line`,
  22259. * to apply to each individual line.
  22260. *
  22261. * @type {string}
  22262. * @since 5.0.0
  22263. * @apioption xAxis.plotLines.className
  22264. */
  22265. /**
  22266. * The color of the line.
  22267. *
  22268. * @sample {highcharts} highcharts/xaxis/plotlines-color/
  22269. * A red line from X axis
  22270. * @sample {highstock} stock/xaxis/plotlines/
  22271. * Plot line on Y axis
  22272. *
  22273. * @type {Highcharts.ColorString}
  22274. * @default ${palette.neutralColor40}
  22275. * @apioption xAxis.plotLines.color
  22276. */
  22277. /**
  22278. * The dashing or dot style for the plot line. For possible values see
  22279. * [this overview](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-dashstyle-all/).
  22280. *
  22281. * @sample {highcharts} highcharts/xaxis/plotlines-dashstyle/
  22282. * Dash and dot pattern
  22283. * @sample {highstock} stock/xaxis/plotlines/
  22284. * Plot line on Y axis
  22285. *
  22286. * @type {Highcharts.DashStyleValue}
  22287. * @default Solid
  22288. * @since 1.2
  22289. * @apioption xAxis.plotLines.dashStyle
  22290. */
  22291. /**
  22292. * An object defining mouse events for the plot line. Supported
  22293. * properties are `click`, `mouseover`, `mouseout`, `mousemove`.
  22294. *
  22295. * @sample {highcharts} highcharts/xaxis/plotlines-events/
  22296. * Mouse events demonstrated
  22297. *
  22298. * @since 1.2
  22299. * @apioption xAxis.plotLines.events
  22300. */
  22301. /**
  22302. * Click event on a plot band.
  22303. *
  22304. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  22305. * @apioption xAxis.plotLines.events.click
  22306. */
  22307. /**
  22308. * Mouse move event on a plot band.
  22309. *
  22310. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  22311. * @apioption xAxis.plotLines.events.mousemove
  22312. */
  22313. /**
  22314. * Mouse out event on the corner of a plot band.
  22315. *
  22316. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  22317. * @apioption xAxis.plotLines.events.mouseout
  22318. */
  22319. /**
  22320. * Mouse over event on a plot band.
  22321. *
  22322. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  22323. * @apioption xAxis.plotLines.events.mouseover
  22324. */
  22325. /**
  22326. * An id used for identifying the plot line in Axis.removePlotLine.
  22327. *
  22328. * @sample {highcharts} highcharts/xaxis/plotlines-id/
  22329. * Remove plot line by id
  22330. *
  22331. * @type {string}
  22332. * @apioption xAxis.plotLines.id
  22333. */
  22334. /**
  22335. * The position of the line in axis units.
  22336. *
  22337. * @sample {highcharts} highcharts/xaxis/plotlines-color/
  22338. * Between two categories on X axis
  22339. * @sample {highstock} stock/xaxis/plotlines/
  22340. * Plot line on Y axis
  22341. *
  22342. * @type {number}
  22343. * @apioption xAxis.plotLines.value
  22344. */
  22345. /**
  22346. * The width or thickness of the plot line.
  22347. *
  22348. * @sample {highcharts} highcharts/xaxis/plotlines-color/
  22349. * 2px wide line from X axis
  22350. * @sample {highstock} stock/xaxis/plotlines/
  22351. * Plot line on Y axis
  22352. *
  22353. * @type {number}
  22354. * @default 2
  22355. * @apioption xAxis.plotLines.width
  22356. */
  22357. /**
  22358. * The z index of the plot line within the chart.
  22359. *
  22360. * @sample {highcharts} highcharts/xaxis/plotlines-zindex-behind/
  22361. * Behind plot lines by default
  22362. * @sample {highcharts} highcharts/xaxis/plotlines-zindex-above/
  22363. * Above plot lines
  22364. * @sample {highcharts} highcharts/xaxis/plotlines-zindex-above-all/
  22365. * Above plot lines and series
  22366. *
  22367. * @type {number}
  22368. * @since 1.2
  22369. * @apioption xAxis.plotLines.zIndex
  22370. */
  22371. /**
  22372. * Text labels for the plot bands
  22373. *
  22374. * @apioption xAxis.plotLines.label
  22375. */
  22376. /**
  22377. * Horizontal alignment of the label. Can be one of "left", "center" or
  22378. * "right".
  22379. *
  22380. * @sample {highcharts} highcharts/xaxis/plotlines-label-align-right/
  22381. * Aligned to the right
  22382. * @sample {highstock} stock/xaxis/plotlines/
  22383. * Plot line on Y axis
  22384. *
  22385. * @type {Highcharts.AlignValue}
  22386. * @default left
  22387. * @since 2.1
  22388. * @apioption xAxis.plotLines.label.align
  22389. */
  22390. /**
  22391. * Callback JavaScript function to format the label. Useful properties like
  22392. * the value of plot line or the range of plot band (`from` & `to`
  22393. * properties) can be found in `this.options` object.
  22394. *
  22395. * @sample {highcharts} highcharts/xaxis/plotlines-plotbands-label-formatter
  22396. * Label formatters for plot line and plot band.
  22397. * @type {Highcharts.FormatterCallbackFunction<Highcharts.PlotLineOrBand>}
  22398. * @apioption xAxis.plotLines.label.formatter
  22399. */
  22400. /**
  22401. * Rotation of the text label in degrees. Defaults to 0 for horizontal plot
  22402. * lines and 90 for vertical lines.
  22403. *
  22404. * @sample {highcharts} highcharts/xaxis/plotlines-label-verticalalign-middle/
  22405. * Slanted text
  22406. *
  22407. * @type {number}
  22408. * @since 2.1
  22409. * @apioption xAxis.plotLines.label.rotation
  22410. */
  22411. /**
  22412. * CSS styles for the text label.
  22413. *
  22414. * In styled mode, the labels are styled by the
  22415. * `.highcharts-plot-line-label` class.
  22416. *
  22417. * @sample {highcharts} highcharts/xaxis/plotlines-label-style/
  22418. * Blue and bold label
  22419. *
  22420. * @type {Highcharts.CSSObject}
  22421. * @since 2.1
  22422. * @apioption xAxis.plotLines.label.style
  22423. */
  22424. /**
  22425. * The text itself. A subset of HTML is supported.
  22426. *
  22427. * @type {string}
  22428. * @since 2.1
  22429. * @apioption xAxis.plotLines.label.text
  22430. */
  22431. /**
  22432. * The text alignment for the label. While `align` determines where the
  22433. * texts anchor point is placed within the plot band, `textAlign` determines
  22434. * how the text is aligned against its anchor point. Possible values are
  22435. * "left", "center" and "right". Defaults to the same as the `align` option.
  22436. *
  22437. * @sample {highcharts} highcharts/xaxis/plotlines-label-textalign/
  22438. * Text label in bottom position
  22439. *
  22440. * @type {Highcharts.AlignValue}
  22441. * @since 2.1
  22442. * @apioption xAxis.plotLines.label.textAlign
  22443. */
  22444. /**
  22445. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  22446. * to render the labels.
  22447. *
  22448. * @type {boolean}
  22449. * @default false
  22450. * @since 3.0.3
  22451. * @apioption xAxis.plotLines.label.useHTML
  22452. */
  22453. /**
  22454. * Vertical alignment of the label relative to the plot line. Can be
  22455. * one of "top", "middle" or "bottom".
  22456. *
  22457. * @sample {highcharts} highcharts/xaxis/plotlines-label-verticalalign-middle/
  22458. * Vertically centered label
  22459. *
  22460. * @type {Highcharts.VerticalAlignValue}
  22461. * @default {highcharts} top
  22462. * @default {highstock} top
  22463. * @since 2.1
  22464. * @apioption xAxis.plotLines.label.verticalAlign
  22465. */
  22466. /**
  22467. * Horizontal position relative the alignment. Default varies by
  22468. * orientation.
  22469. *
  22470. * @sample {highcharts} highcharts/xaxis/plotlines-label-align-right/
  22471. * Aligned 10px from the right edge
  22472. * @sample {highstock} stock/xaxis/plotlines/
  22473. * Plot line on Y axis
  22474. *
  22475. * @type {number}
  22476. * @since 2.1
  22477. * @apioption xAxis.plotLines.label.x
  22478. */
  22479. /**
  22480. * Vertical position of the text baseline relative to the alignment. Default
  22481. * varies by orientation.
  22482. *
  22483. * @sample {highcharts} highcharts/xaxis/plotlines-label-y/
  22484. * Label below the plot line
  22485. * @sample {highstock} stock/xaxis/plotlines/
  22486. * Plot line on Y axis
  22487. *
  22488. * @type {number}
  22489. * @since 2.1
  22490. * @apioption xAxis.plotLines.label.y
  22491. */
  22492. /**
  22493. *
  22494. * @type {Array<*>}
  22495. * @extends xAxis.plotBands
  22496. * @apioption yAxis.plotBands
  22497. */
  22498. /**
  22499. * In a gauge chart, this option determines the inner radius of the
  22500. * plot band that stretches along the perimeter. It can be given as
  22501. * a percentage string, like `"100%"`, or as a pixel number, like `100`.
  22502. * By default, the inner radius is controlled by the [thickness](
  22503. * #yAxis.plotBands.thickness) option.
  22504. *
  22505. * @sample {highcharts} highcharts/xaxis/plotbands-gauge
  22506. * Gauge plot band
  22507. *
  22508. * @type {number|string}
  22509. * @since 2.3
  22510. * @product highcharts
  22511. * @apioption yAxis.plotBands.innerRadius
  22512. */
  22513. /**
  22514. * In a gauge chart, this option determines the outer radius of the
  22515. * plot band that stretches along the perimeter. It can be given as
  22516. * a percentage string, like `"100%"`, or as a pixel number, like `100`.
  22517. *
  22518. * @sample {highcharts} highcharts/xaxis/plotbands-gauge
  22519. * Gauge plot band
  22520. *
  22521. * @type {number|string}
  22522. * @default 100%
  22523. * @since 2.3
  22524. * @product highcharts
  22525. * @apioption yAxis.plotBands.outerRadius
  22526. */
  22527. /**
  22528. * In a gauge chart, this option sets the width of the plot band
  22529. * stretching along the perimeter. It can be given as a percentage
  22530. * string, like `"10%"`, or as a pixel number, like `10`. The default
  22531. * value 10 is the same as the default [tickLength](#yAxis.tickLength),
  22532. * thus making the plot band act as a background for the tick markers.
  22533. *
  22534. * @sample {highcharts} highcharts/xaxis/plotbands-gauge
  22535. * Gauge plot band
  22536. *
  22537. * @type {number|string}
  22538. * @default 10
  22539. * @since 2.3
  22540. * @product highcharts
  22541. * @apioption yAxis.plotBands.thickness
  22542. */
  22543. /**
  22544. * @type {Array<*>}
  22545. * @extends xAxis.plotLines
  22546. * @apioption yAxis.plotLines
  22547. */
  22548. /* eslint-disable no-invalid-this, valid-jsdoc */
  22549. /**
  22550. * Internal function to create the SVG path definition for a plot band.
  22551. *
  22552. * @function Highcharts.Axis#getPlotBandPath
  22553. *
  22554. * @param {number} from
  22555. * The axis value to start from.
  22556. *
  22557. * @param {number} to
  22558. * The axis value to end on.
  22559. *
  22560. * @param {Highcharts.AxisPlotBandsOptions|Highcharts.AxisPlotLinesOptions} options
  22561. * The plotBand or plotLine configuration object.
  22562. *
  22563. * @return {Highcharts.SVGPathArray}
  22564. * The SVG path definition in array form.
  22565. */
  22566. getPlotBandPath: function (from, to, options) {
  22567. if (options === void 0) { options = this.options; }
  22568. var toPath = this.getPlotLinePath({
  22569. value: to,
  22570. force: true,
  22571. acrossPanes: options.acrossPanes
  22572. }),
  22573. path = this.getPlotLinePath({
  22574. value: from,
  22575. force: true,
  22576. acrossPanes: options.acrossPanes
  22577. }),
  22578. result = [],
  22579. i,
  22580. // #4964 check if chart is inverted or plotband is on yAxis
  22581. horiz = this.horiz,
  22582. plus = 1,
  22583. isFlat,
  22584. outside = !isNumber(this.min) ||
  22585. !isNumber(this.max) ||
  22586. (from < this.min && to < this.min) ||
  22587. (from > this.max && to > this.max);
  22588. if (path && toPath) {
  22589. // Flat paths don't need labels (#3836)
  22590. if (outside) {
  22591. isFlat = path.toString() === toPath.toString();
  22592. plus = 0;
  22593. }
  22594. // Go over each subpath - for panes in Highcharts Stock
  22595. for (i = 0; i < path.length; i += 2) {
  22596. var pathStart = path[i],
  22597. pathEnd = path[i + 1],
  22598. toPathStart = toPath[i],
  22599. toPathEnd = toPath[i + 1];
  22600. // Type checking all affected path segments. Consider something
  22601. // smarter.
  22602. if ((pathStart[0] === 'M' || pathStart[0] === 'L') &&
  22603. (pathEnd[0] === 'M' || pathEnd[0] === 'L') &&
  22604. (toPathStart[0] === 'M' || toPathStart[0] === 'L') &&
  22605. (toPathEnd[0] === 'M' || toPathEnd[0] === 'L')) {
  22606. // Add 1 pixel when coordinates are the same
  22607. if (horiz && toPathStart[1] === pathStart[1]) {
  22608. toPathStart[1] += plus;
  22609. toPathEnd[1] += plus;
  22610. }
  22611. else if (!horiz && toPathStart[2] === pathStart[2]) {
  22612. toPathStart[2] += plus;
  22613. toPathEnd[2] += plus;
  22614. }
  22615. result.push(['M', pathStart[1], pathStart[2]], ['L', pathEnd[1], pathEnd[2]], ['L', toPathEnd[1], toPathEnd[2]], ['L', toPathStart[1], toPathStart[2]], ['Z']);
  22616. }
  22617. result.isFlat = isFlat;
  22618. }
  22619. }
  22620. else { // outside the axis area
  22621. path = null;
  22622. }
  22623. return result;
  22624. },
  22625. /**
  22626. * Add a plot band after render time.
  22627. *
  22628. * @sample highcharts/members/axis-addplotband/
  22629. * Toggle the plot band from a button
  22630. *
  22631. * @function Highcharts.Axis#addPlotBand
  22632. *
  22633. * @param {Highcharts.AxisPlotBandsOptions} options
  22634. * A configuration object for the plot band, as defined in
  22635. * [xAxis.plotBands](https://api.highcharts.com/highcharts/xAxis.plotBands).
  22636. *
  22637. * @return {Highcharts.PlotLineOrBand|undefined}
  22638. * The added plot band.
  22639. */
  22640. addPlotBand: function (options) {
  22641. return this.addPlotBandOrLine(options, 'plotBands');
  22642. },
  22643. /**
  22644. * Add a plot line after render time.
  22645. *
  22646. * @sample highcharts/members/axis-addplotline/
  22647. * Toggle the plot line from a button
  22648. *
  22649. * @function Highcharts.Axis#addPlotLine
  22650. *
  22651. * @param {Highcharts.AxisPlotLinesOptions} options
  22652. * A configuration object for the plot line, as defined in
  22653. * [xAxis.plotLines](https://api.highcharts.com/highcharts/xAxis.plotLines).
  22654. *
  22655. * @return {Highcharts.PlotLineOrBand|undefined}
  22656. * The added plot line.
  22657. */
  22658. addPlotLine: function (options) {
  22659. return this.addPlotBandOrLine(options, 'plotLines');
  22660. },
  22661. /**
  22662. * Add a plot band or plot line after render time. Called from addPlotBand
  22663. * and addPlotLine internally.
  22664. *
  22665. * @private
  22666. * @function Highcharts.Axis#addPlotBandOrLine
  22667. *
  22668. * @param {Highcharts.AxisPlotBandsOptions|Highcharts.AxisPlotLinesOptions} options
  22669. * The plotBand or plotLine configuration object.
  22670. *
  22671. * @param {"plotBands"|"plotLines"} [coll]
  22672. *
  22673. * @return {Highcharts.PlotLineOrBand|undefined}
  22674. */
  22675. addPlotBandOrLine: function (options, coll) {
  22676. var _this = this;
  22677. var obj = new H.PlotLineOrBand(this,
  22678. options),
  22679. userOptions = this.userOptions;
  22680. if (this.visible) {
  22681. obj = obj.render();
  22682. }
  22683. if (obj) { // #2189
  22684. if (!this._addedPlotLB) {
  22685. this._addedPlotLB = true;
  22686. (userOptions.plotLines || [])
  22687. .concat(userOptions.plotBands || [])
  22688. .forEach(function (plotLineOptions) {
  22689. _this.addPlotBandOrLine(plotLineOptions);
  22690. });
  22691. }
  22692. // Add it to the user options for exporting and Axis.update
  22693. if (coll) {
  22694. // Workaround Microsoft/TypeScript issue #32693
  22695. var updatedOptions = (userOptions[coll] || []);
  22696. updatedOptions.push(options);
  22697. userOptions[coll] = updatedOptions;
  22698. }
  22699. this.plotLinesAndBands.push(obj);
  22700. }
  22701. return obj;
  22702. },
  22703. /**
  22704. * Remove a plot band or plot line from the chart by id. Called internally
  22705. * from `removePlotBand` and `removePlotLine`.
  22706. *
  22707. * @private
  22708. * @function Highcharts.Axis#removePlotBandOrLine
  22709. * @param {string} id
  22710. * @return {void}
  22711. */
  22712. removePlotBandOrLine: function (id) {
  22713. var plotLinesAndBands = this.plotLinesAndBands,
  22714. options = this.options,
  22715. userOptions = this.userOptions,
  22716. i = plotLinesAndBands.length;
  22717. while (i--) {
  22718. if (plotLinesAndBands[i].id === id) {
  22719. plotLinesAndBands[i].destroy();
  22720. }
  22721. }
  22722. ([
  22723. options.plotLines || [],
  22724. userOptions.plotLines || [],
  22725. options.plotBands || [],
  22726. userOptions.plotBands || []
  22727. ]).forEach(function (arr) {
  22728. i = arr.length;
  22729. while (i--) {
  22730. if ((arr[i] || {}).id === id) {
  22731. erase(arr, arr[i]);
  22732. }
  22733. }
  22734. });
  22735. },
  22736. /**
  22737. * Remove a plot band by its id.
  22738. *
  22739. * @sample highcharts/members/axis-removeplotband/
  22740. * Remove plot band by id
  22741. * @sample highcharts/members/axis-addplotband/
  22742. * Toggle the plot band from a button
  22743. *
  22744. * @function Highcharts.Axis#removePlotBand
  22745. *
  22746. * @param {string} id
  22747. * The plot band's `id` as given in the original configuration
  22748. * object or in the `addPlotBand` option.
  22749. *
  22750. * @return {void}
  22751. */
  22752. removePlotBand: function (id) {
  22753. this.removePlotBandOrLine(id);
  22754. },
  22755. /**
  22756. * Remove a plot line by its id.
  22757. *
  22758. * @sample highcharts/xaxis/plotlines-id/
  22759. * Remove plot line by id
  22760. * @sample highcharts/members/axis-addplotline/
  22761. * Toggle the plot line from a button
  22762. *
  22763. * @function Highcharts.Axis#removePlotLine
  22764. *
  22765. * @param {string} id
  22766. * The plot line's `id` as given in the original configuration
  22767. * object or in the `addPlotLine` option.
  22768. */
  22769. removePlotLine: function (id) {
  22770. this.removePlotBandOrLine(id);
  22771. }
  22772. });
  22773. H.PlotLineOrBand = PlotLineOrBand;
  22774. return H.PlotLineOrBand;
  22775. });
  22776. _registerModule(_modules, 'Core/Tooltip.js', [_modules['Core/FormatUtilities.js'], _modules['Core/Globals.js'], _modules['Core/Color/Palette.js'], _modules['Core/Utilities.js']], function (F, H, palette, U) {
  22777. /* *
  22778. *
  22779. * (c) 2010-2021 Torstein Honsi
  22780. *
  22781. * License: www.highcharts.com/license
  22782. *
  22783. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  22784. *
  22785. * */
  22786. var format = F.format;
  22787. var doc = H.doc;
  22788. var clamp = U.clamp,
  22789. css = U.css,
  22790. defined = U.defined,
  22791. discardElement = U.discardElement,
  22792. extend = U.extend,
  22793. fireEvent = U.fireEvent,
  22794. isArray = U.isArray,
  22795. isNumber = U.isNumber,
  22796. isString = U.isString,
  22797. merge = U.merge,
  22798. pick = U.pick,
  22799. splat = U.splat,
  22800. syncTimeout = U.syncTimeout,
  22801. timeUnits = U.timeUnits;
  22802. /**
  22803. * Callback function to format the text of the tooltip from scratch.
  22804. *
  22805. * In case of single or shared tooltips, a string should be be returned. In case
  22806. * of splitted tooltips, it should return an array where the first item is the
  22807. * header, and subsequent items are mapped to the points. Return `false` to
  22808. * disable tooltip for a specific point on series.
  22809. *
  22810. * @callback Highcharts.TooltipFormatterCallbackFunction
  22811. *
  22812. * @param {Highcharts.TooltipFormatterContextObject} this
  22813. * Context to format
  22814. *
  22815. * @param {Highcharts.Tooltip} tooltip
  22816. * The tooltip instance
  22817. *
  22818. * @return {false|string|Array<(string|null|undefined)>|null|undefined}
  22819. * Formatted text or false
  22820. */
  22821. /**
  22822. * @interface Highcharts.TooltipFormatterContextObject
  22823. */ /**
  22824. * @name Highcharts.TooltipFormatterContextObject#color
  22825. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  22826. */ /**
  22827. * @name Highcharts.TooltipFormatterContextObject#colorIndex
  22828. * @type {number|undefined}
  22829. */ /**
  22830. * @name Highcharts.TooltipFormatterContextObject#key
  22831. * @type {number}
  22832. */ /**
  22833. * @name Highcharts.TooltipFormatterContextObject#percentage
  22834. * @type {number|undefined}
  22835. */ /**
  22836. * @name Highcharts.TooltipFormatterContextObject#point
  22837. * @type {Highcharts.Point}
  22838. */ /**
  22839. * @name Highcharts.TooltipFormatterContextObject#points
  22840. * @type {Array<Highcharts.TooltipFormatterContextObject>|undefined}
  22841. */ /**
  22842. * @name Highcharts.TooltipFormatterContextObject#series
  22843. * @type {Highcharts.Series}
  22844. */ /**
  22845. * @name Highcharts.TooltipFormatterContextObject#total
  22846. * @type {number|undefined}
  22847. */ /**
  22848. * @name Highcharts.TooltipFormatterContextObject#x
  22849. * @type {number}
  22850. */ /**
  22851. * @name Highcharts.TooltipFormatterContextObject#y
  22852. * @type {number}
  22853. */
  22854. /**
  22855. * A callback function to place the tooltip in a specific position.
  22856. *
  22857. * @callback Highcharts.TooltipPositionerCallbackFunction
  22858. *
  22859. * @param {Highcharts.Tooltip} this
  22860. * Tooltip context of the callback.
  22861. *
  22862. * @param {number} labelWidth
  22863. * Width of the tooltip.
  22864. *
  22865. * @param {number} labelHeight
  22866. * Height of the tooltip.
  22867. *
  22868. * @param {Highcharts.TooltipPositionerPointObject} point
  22869. * Point information for positioning a tooltip.
  22870. *
  22871. * @return {Highcharts.PositionObject}
  22872. * New position for the tooltip.
  22873. */
  22874. /**
  22875. * Point information for positioning a tooltip.
  22876. *
  22877. * @interface Highcharts.TooltipPositionerPointObject
  22878. * @extends Highcharts.Point
  22879. */ /**
  22880. * If `tooltip.split` option is enabled and positioner is called for each of the
  22881. * boxes separately, this property indicates the call on the xAxis header, which
  22882. * is not a point itself.
  22883. * @name Highcharts.TooltipPositionerPointObject#isHeader
  22884. * @type {boolean}
  22885. */ /**
  22886. * The reference point relative to the plot area. Add chart.plotLeft to get the
  22887. * full coordinates.
  22888. * @name Highcharts.TooltipPositionerPointObject#plotX
  22889. * @type {number}
  22890. */ /**
  22891. * The reference point relative to the plot area. Add chart.plotTop to get the
  22892. * full coordinates.
  22893. * @name Highcharts.TooltipPositionerPointObject#plotY
  22894. * @type {number}
  22895. */
  22896. /**
  22897. * @typedef {"callout"|"circle"|"square"} Highcharts.TooltipShapeValue
  22898. */
  22899. ''; // separates doclets above from variables below
  22900. /* eslint-disable no-invalid-this, valid-jsdoc */
  22901. /**
  22902. * Tooltip of a chart.
  22903. *
  22904. * @class
  22905. * @name Highcharts.Tooltip
  22906. *
  22907. * @param {Highcharts.Chart} chart
  22908. * The chart instance.
  22909. *
  22910. * @param {Highcharts.TooltipOptions} options
  22911. * Tooltip options.
  22912. */
  22913. var Tooltip = /** @class */ (function () {
  22914. /* *
  22915. *
  22916. * Constructors
  22917. *
  22918. * */
  22919. function Tooltip(chart, options) {
  22920. this.container = void 0;
  22921. this.crosshairs = [];
  22922. this.distance = 0;
  22923. this.isHidden = true;
  22924. this.isSticky = false;
  22925. this.now = {};
  22926. this.options = {};
  22927. this.outside = false;
  22928. this.chart = chart;
  22929. this.init(chart, options);
  22930. }
  22931. /* *
  22932. *
  22933. * Functions
  22934. *
  22935. * */
  22936. /**
  22937. * In styled mode, apply the default filter for the tooltip drop-shadow. It
  22938. * needs to have an id specific to the chart, otherwise there will be issues
  22939. * when one tooltip adopts the filter of a different chart, specifically one
  22940. * where the container is hidden.
  22941. *
  22942. * @private
  22943. * @function Highcharts.Tooltip#applyFilter
  22944. */
  22945. Tooltip.prototype.applyFilter = function () {
  22946. var chart = this.chart;
  22947. chart.renderer.definition({
  22948. tagName: 'filter',
  22949. attributes: {
  22950. id: 'drop-shadow-' + chart.index,
  22951. opacity: 0.5
  22952. },
  22953. children: [{
  22954. tagName: 'feGaussianBlur',
  22955. attributes: {
  22956. 'in': 'SourceAlpha',
  22957. stdDeviation: 1
  22958. }
  22959. }, {
  22960. tagName: 'feOffset',
  22961. attributes: {
  22962. dx: 1,
  22963. dy: 1
  22964. }
  22965. }, {
  22966. tagName: 'feComponentTransfer',
  22967. children: [{
  22968. tagName: 'feFuncA',
  22969. attributes: {
  22970. type: 'linear',
  22971. slope: 0.3
  22972. }
  22973. }]
  22974. }, {
  22975. tagName: 'feMerge',
  22976. children: [{
  22977. tagName: 'feMergeNode'
  22978. }, {
  22979. tagName: 'feMergeNode',
  22980. attributes: {
  22981. 'in': 'SourceGraphic'
  22982. }
  22983. }]
  22984. }]
  22985. });
  22986. chart.renderer.definition({
  22987. tagName: 'style',
  22988. textContent: '.highcharts-tooltip-' + chart.index + '{' +
  22989. 'filter:url(#drop-shadow-' + chart.index + ')' +
  22990. '}'
  22991. });
  22992. };
  22993. /**
  22994. * Build the body (lines) of the tooltip by iterating over the items and
  22995. * returning one entry for each item, abstracting this functionality allows
  22996. * to easily overwrite and extend it.
  22997. *
  22998. * @private
  22999. * @function Highcharts.Tooltip#bodyFormatter
  23000. * @param {Array<(Highcharts.Point|Highcharts.Series)>} items
  23001. * @return {Array<string>}
  23002. */
  23003. Tooltip.prototype.bodyFormatter = function (items) {
  23004. return items.map(function (item) {
  23005. var tooltipOptions = item.series.tooltipOptions;
  23006. return (tooltipOptions[(item.point.formatPrefix || 'point') + 'Formatter'] ||
  23007. item.point.tooltipFormatter).call(item.point, tooltipOptions[(item.point.formatPrefix || 'point') + 'Format'] || '');
  23008. });
  23009. };
  23010. /**
  23011. * Destroy the single tooltips in a split tooltip.
  23012. * If the tooltip is active then it is not destroyed, unless forced to.
  23013. *
  23014. * @private
  23015. * @function Highcharts.Tooltip#cleanSplit
  23016. *
  23017. * @param {boolean} [force]
  23018. * Force destroy all tooltips.
  23019. */
  23020. Tooltip.prototype.cleanSplit = function (force) {
  23021. this.chart.series.forEach(function (series) {
  23022. var tt = series && series.tt;
  23023. if (tt) {
  23024. if (!tt.isActive || force) {
  23025. series.tt = tt.destroy();
  23026. }
  23027. else {
  23028. tt.isActive = false;
  23029. }
  23030. }
  23031. });
  23032. };
  23033. /**
  23034. * In case no user defined formatter is given, this will be used. Note that
  23035. * the context here is an object holding point, series, x, y etc.
  23036. *
  23037. * @function Highcharts.Tooltip#defaultFormatter
  23038. *
  23039. * @param {Highcharts.Tooltip} tooltip
  23040. *
  23041. * @return {Array<string>}
  23042. */
  23043. Tooltip.prototype.defaultFormatter = function (tooltip) {
  23044. var items = this.points || splat(this),
  23045. s;
  23046. // Build the header
  23047. s = [tooltip.tooltipFooterHeaderFormatter(items[0])];
  23048. // build the values
  23049. s = s.concat(tooltip.bodyFormatter(items));
  23050. // footer
  23051. s.push(tooltip.tooltipFooterHeaderFormatter(items[0], true));
  23052. return s;
  23053. };
  23054. /**
  23055. * Removes and destroys the tooltip and its elements.
  23056. *
  23057. * @function Highcharts.Tooltip#destroy
  23058. */
  23059. Tooltip.prototype.destroy = function () {
  23060. // Destroy and clear local variables
  23061. if (this.label) {
  23062. this.label = this.label.destroy();
  23063. }
  23064. if (this.split && this.tt) {
  23065. this.cleanSplit(this.chart, true);
  23066. this.tt = this.tt.destroy();
  23067. }
  23068. if (this.renderer) {
  23069. this.renderer = this.renderer.destroy();
  23070. discardElement(this.container);
  23071. }
  23072. U.clearTimeout(this.hideTimer);
  23073. U.clearTimeout(this.tooltipTimeout);
  23074. };
  23075. /**
  23076. * Extendable method to get the anchor position of the tooltip
  23077. * from a point or set of points
  23078. *
  23079. * @private
  23080. * @function Highcharts.Tooltip#getAnchor
  23081. *
  23082. * @param {Highcharts.Point|Array<Highcharts.Point>} points
  23083. *
  23084. * @param {Highcharts.PointerEventObject} [mouseEvent]
  23085. *
  23086. * @return {Array<number>}
  23087. */
  23088. Tooltip.prototype.getAnchor = function (points, mouseEvent) {
  23089. var ret,
  23090. chart = this.chart,
  23091. pointer = chart.pointer,
  23092. inverted = chart.inverted,
  23093. plotTop = chart.plotTop,
  23094. plotLeft = chart.plotLeft,
  23095. plotX = 0,
  23096. plotY = 0,
  23097. yAxis,
  23098. xAxis;
  23099. points = splat(points);
  23100. // When tooltip follows mouse, relate the position to the mouse
  23101. if (this.followPointer && mouseEvent) {
  23102. if (typeof mouseEvent.chartX === 'undefined') {
  23103. mouseEvent = pointer.normalize(mouseEvent);
  23104. }
  23105. ret = [
  23106. mouseEvent.chartX - plotLeft,
  23107. mouseEvent.chartY - plotTop
  23108. ];
  23109. // Some series types use a specificly calculated tooltip position for
  23110. // each point
  23111. }
  23112. else if (points[0].tooltipPos) {
  23113. ret = points[0].tooltipPos;
  23114. // Calculate the average position and adjust for axis positions
  23115. }
  23116. else {
  23117. points.forEach(function (point) {
  23118. yAxis = point.series.yAxis;
  23119. xAxis = point.series.xAxis;
  23120. plotX += point.plotX || 0;
  23121. plotY += (point.plotLow ?
  23122. (point.plotLow + (point.plotHigh || 0)) / 2 :
  23123. (point.plotY || 0));
  23124. // Adjust position for positioned axes (top/left settings)
  23125. if (xAxis && yAxis) {
  23126. if (!inverted) { // #1151
  23127. plotX += xAxis.pos - plotLeft;
  23128. plotY += yAxis.pos - plotTop;
  23129. }
  23130. else { // #14771
  23131. plotX += plotTop + chart.plotHeight - xAxis.len - xAxis.pos;
  23132. plotY += plotLeft + chart.plotWidth - yAxis.len - yAxis.pos;
  23133. }
  23134. }
  23135. });
  23136. plotX /= points.length;
  23137. plotY /= points.length;
  23138. // Use the average position for multiple points
  23139. ret = [
  23140. inverted ? chart.plotWidth - plotY : plotX,
  23141. inverted ? chart.plotHeight - plotX : plotY
  23142. ];
  23143. // When shared, place the tooltip next to the mouse (#424)
  23144. if (this.shared && points.length > 1 && mouseEvent) {
  23145. if (inverted) {
  23146. ret[0] = mouseEvent.chartX - plotLeft;
  23147. }
  23148. else {
  23149. ret[1] = mouseEvent.chartY - plotTop;
  23150. }
  23151. }
  23152. }
  23153. return ret.map(Math.round);
  23154. };
  23155. /**
  23156. * Get the optimal date format for a point, based on a range.
  23157. *
  23158. * @private
  23159. * @function Highcharts.Tooltip#getDateFormat
  23160. *
  23161. * @param {number} range
  23162. * The time range
  23163. *
  23164. * @param {number} date
  23165. * The date of the point in question
  23166. *
  23167. * @param {number} startOfWeek
  23168. * An integer representing the first day of the week, where 0 is
  23169. * Sunday.
  23170. *
  23171. * @param {Highcharts.Dictionary<string>} dateTimeLabelFormats
  23172. * A map of time units to formats.
  23173. *
  23174. * @return {string}
  23175. * The optimal date format for a point.
  23176. */
  23177. Tooltip.prototype.getDateFormat = function (range, date, startOfWeek, dateTimeLabelFormats) {
  23178. var time = this.chart.time, dateStr = time.dateFormat('%m-%d %H:%M:%S.%L', date), format, n, blank = '01-01 00:00:00.000', strpos = {
  23179. millisecond: 15,
  23180. second: 12,
  23181. minute: 9,
  23182. hour: 6,
  23183. day: 3
  23184. }, lastN = 'millisecond'; // for sub-millisecond data, #4223
  23185. for (n in timeUnits) { // eslint-disable-line guard-for-in
  23186. // If the range is exactly one week and we're looking at a
  23187. // Sunday/Monday, go for the week format
  23188. if (range === timeUnits.week &&
  23189. +time.dateFormat('%w', date) === startOfWeek &&
  23190. dateStr.substr(6) === blank.substr(6)) {
  23191. n = 'week';
  23192. break;
  23193. }
  23194. // The first format that is too great for the range
  23195. if (timeUnits[n] > range) {
  23196. n = lastN;
  23197. break;
  23198. }
  23199. // If the point is placed every day at 23:59, we need to show
  23200. // the minutes as well. #2637.
  23201. if (strpos[n] &&
  23202. dateStr.substr(strpos[n]) !== blank.substr(strpos[n])) {
  23203. break;
  23204. }
  23205. // Weeks are outside the hierarchy, only apply them on
  23206. // Mondays/Sundays like in the first condition
  23207. if (n !== 'week') {
  23208. lastN = n;
  23209. }
  23210. }
  23211. if (n) {
  23212. format = time.resolveDTLFormat(dateTimeLabelFormats[n]).main;
  23213. }
  23214. return format;
  23215. };
  23216. /**
  23217. * Creates the Tooltip label element if it does not exist, then returns it.
  23218. *
  23219. * @function Highcharts.Tooltip#getLabel
  23220. * @return {Highcharts.SVGElement}
  23221. */
  23222. Tooltip.prototype.getLabel = function () {
  23223. var tooltip = this,
  23224. renderer = this.chart.renderer,
  23225. styledMode = this.chart.styledMode,
  23226. options = this.options,
  23227. className = ('tooltip' + (defined(options.className) ?
  23228. ' ' + options.className :
  23229. '')),
  23230. pointerEvents = ((options.style && options.style.pointerEvents) ||
  23231. (!this.followPointer && options.stickOnContact ? 'auto' : 'none')),
  23232. container,
  23233. onMouseEnter = function () {
  23234. tooltip.inContact = true;
  23235. }, onMouseLeave = function () {
  23236. var series = tooltip.chart.hoverSeries;
  23237. tooltip.inContact = false;
  23238. if (series &&
  23239. series.onMouseOut) {
  23240. series.onMouseOut();
  23241. }
  23242. };
  23243. if (!this.label) {
  23244. if (this.outside) {
  23245. var chartStyle = this.chart.options.chart.style;
  23246. /**
  23247. * Reference to the tooltip's container, when
  23248. * [Highcharts.Tooltip#outside] is set to true, otherwise
  23249. * it's undefined.
  23250. *
  23251. * @name Highcharts.Tooltip#container
  23252. * @type {Highcharts.HTMLDOMElement|undefined}
  23253. */
  23254. this.container = container = H.doc.createElement('div');
  23255. container.className = 'highcharts-tooltip-container';
  23256. css(container, {
  23257. position: 'absolute',
  23258. top: '1px',
  23259. pointerEvents: pointerEvents,
  23260. zIndex: Math.max((this.options.style && this.options.style.zIndex || 0), (chartStyle && chartStyle.zIndex || 0) + 3)
  23261. });
  23262. H.doc.body.appendChild(container);
  23263. /**
  23264. * Reference to the tooltip's renderer, when
  23265. * [Highcharts.Tooltip#outside] is set to true, otherwise
  23266. * it's undefined.
  23267. *
  23268. * @name Highcharts.Tooltip#renderer
  23269. * @type {Highcharts.SVGRenderer|undefined}
  23270. */
  23271. this.renderer = renderer = new H.Renderer(container, 0, 0, chartStyle, void 0, void 0, renderer.styledMode);
  23272. }
  23273. // Create the label
  23274. if (this.split) {
  23275. this.label = renderer.g(className);
  23276. }
  23277. else {
  23278. this.label = renderer
  23279. .label('', 0, 0, options.shape || 'callout', null, null, options.useHTML, null, className)
  23280. .attr({
  23281. padding: options.padding,
  23282. r: options.borderRadius
  23283. });
  23284. if (!styledMode) {
  23285. this.label
  23286. .attr({
  23287. fill: options.backgroundColor,
  23288. 'stroke-width': options.borderWidth
  23289. })
  23290. // #2301, #2657
  23291. .css(options.style)
  23292. .css({ pointerEvents: pointerEvents })
  23293. .shadow(options.shadow);
  23294. }
  23295. }
  23296. if (styledMode) {
  23297. // Apply the drop-shadow filter
  23298. this.applyFilter();
  23299. this.label.addClass('highcharts-tooltip-' + this.chart.index);
  23300. }
  23301. // Split tooltip use updateTooltipContainer to position the tooltip
  23302. // container.
  23303. if (tooltip.outside && !tooltip.split) {
  23304. var label_1 = this.label;
  23305. var xSetter_1 = label_1.xSetter,
  23306. ySetter_1 = label_1.ySetter;
  23307. label_1.xSetter = function (value) {
  23308. xSetter_1.call(label_1, tooltip.distance);
  23309. container.style.left = value + 'px';
  23310. };
  23311. label_1.ySetter = function (value) {
  23312. ySetter_1.call(label_1, tooltip.distance);
  23313. container.style.top = value + 'px';
  23314. };
  23315. }
  23316. this.label
  23317. .on('mouseenter', onMouseEnter)
  23318. .on('mouseleave', onMouseLeave)
  23319. .attr({ zIndex: 8 })
  23320. .add();
  23321. }
  23322. return this.label;
  23323. };
  23324. /**
  23325. * Place the tooltip in a chart without spilling over
  23326. * and not covering the point it self.
  23327. *
  23328. * @private
  23329. * @function Highcharts.Tooltip#getPosition
  23330. *
  23331. * @param {number} boxWidth
  23332. *
  23333. * @param {number} boxHeight
  23334. *
  23335. * @param {Highcharts.Point} point
  23336. *
  23337. * @return {Highcharts.PositionObject}
  23338. */
  23339. Tooltip.prototype.getPosition = function (boxWidth, boxHeight, point) {
  23340. var chart = this.chart,
  23341. distance = this.distance,
  23342. ret = {},
  23343. // Don't use h if chart isn't inverted (#7242) ???
  23344. h = (chart.inverted && point.h) || 0, // #4117 ???
  23345. swapped,
  23346. outside = this.outside,
  23347. outerWidth = outside ?
  23348. // substract distance to prevent scrollbars
  23349. doc.documentElement.clientWidth - 2 * distance :
  23350. chart.chartWidth,
  23351. outerHeight = outside ?
  23352. Math.max(doc.body.scrollHeight,
  23353. doc.documentElement.scrollHeight,
  23354. doc.body.offsetHeight,
  23355. doc.documentElement.offsetHeight,
  23356. doc.documentElement.clientHeight) :
  23357. chart.chartHeight,
  23358. chartPosition = chart.pointer.getChartPosition(),
  23359. scaleX = function (val) { return ( // eslint-disable-line no-confusing-arrow
  23360. val * chartPosition.scaleX); },
  23361. scaleY = function (val) { return ( // eslint-disable-line no-confusing-arrow
  23362. val * chartPosition.scaleY); },
  23363. // Build parameter arrays for firstDimension()/secondDimension()
  23364. buildDimensionArray = function (dim) {
  23365. var isX = dim === 'x';
  23366. return [
  23367. dim,
  23368. isX ? outerWidth : outerHeight,
  23369. isX ? boxWidth : boxHeight
  23370. ].concat(outside ? [
  23371. // If we are using tooltip.outside, we need to scale the
  23372. // position to match scaling of the container in case there
  23373. // is a transform/zoom on the container. #11329
  23374. isX ? scaleX(boxWidth) : scaleY(boxHeight),
  23375. isX ? chartPosition.left - distance +
  23376. scaleX(point.plotX + chart.plotLeft) :
  23377. chartPosition.top - distance +
  23378. scaleY(point.plotY + chart.plotTop),
  23379. 0,
  23380. isX ? outerWidth : outerHeight
  23381. ] : [
  23382. // Not outside, no scaling is needed
  23383. isX ? boxWidth : boxHeight,
  23384. isX ? point.plotX + chart.plotLeft :
  23385. point.plotY + chart.plotTop,
  23386. isX ? chart.plotLeft : chart.plotTop,
  23387. isX ? chart.plotLeft + chart.plotWidth :
  23388. chart.plotTop + chart.plotHeight
  23389. ]);
  23390. }, first = buildDimensionArray('y'), second = buildDimensionArray('x'),
  23391. // The far side is right or bottom
  23392. preferFarSide = !this.followPointer && pick(point.ttBelow, !chart.inverted === !!point.negative), // #4984
  23393. /*
  23394. * Handle the preferred dimension. When the preferred dimension is
  23395. * tooltip on top or bottom of the point, it will look for space
  23396. * there.
  23397. *
  23398. * @private
  23399. */
  23400. firstDimension = function (dim, outerSize, innerSize, scaledInnerSize, // #11329
  23401. point, min, max) {
  23402. var scaledDist = outside ?
  23403. (dim === 'y' ? scaleY(distance) : scaleX(distance)) :
  23404. distance,
  23405. scaleDiff = (innerSize - scaledInnerSize) / 2,
  23406. roomLeft = scaledInnerSize < point - distance,
  23407. roomRight = point + distance + scaledInnerSize < outerSize,
  23408. alignedLeft = point - scaledDist - innerSize + scaleDiff,
  23409. alignedRight = point + scaledDist - scaleDiff;
  23410. if (preferFarSide && roomRight) {
  23411. ret[dim] = alignedRight;
  23412. }
  23413. else if (!preferFarSide && roomLeft) {
  23414. ret[dim] = alignedLeft;
  23415. }
  23416. else if (roomLeft) {
  23417. ret[dim] = Math.min(max - scaledInnerSize, alignedLeft - h < 0 ? alignedLeft : alignedLeft - h);
  23418. }
  23419. else if (roomRight) {
  23420. ret[dim] = Math.max(min, alignedRight + h + innerSize > outerSize ?
  23421. alignedRight :
  23422. alignedRight + h);
  23423. }
  23424. else {
  23425. return false;
  23426. }
  23427. },
  23428. /*
  23429. * Handle the secondary dimension. If the preferred dimension is
  23430. * tooltip on top or bottom of the point, the second dimension is to
  23431. * align the tooltip above the point, trying to align center but
  23432. * allowing left or right align within the chart box.
  23433. *
  23434. * @private
  23435. */
  23436. secondDimension = function (dim, outerSize, innerSize, scaledInnerSize, // #11329
  23437. point) {
  23438. var retVal;
  23439. // Too close to the edge, return false and swap dimensions
  23440. if (point < distance || point > outerSize - distance) {
  23441. retVal = false;
  23442. // Align left/top
  23443. }
  23444. else if (point < innerSize / 2) {
  23445. ret[dim] = 1;
  23446. // Align right/bottom
  23447. }
  23448. else if (point > outerSize - scaledInnerSize / 2) {
  23449. ret[dim] = outerSize - scaledInnerSize - 2;
  23450. // Align center
  23451. }
  23452. else {
  23453. ret[dim] = point - innerSize / 2;
  23454. }
  23455. return retVal;
  23456. },
  23457. /*
  23458. * Swap the dimensions
  23459. */
  23460. swap = function (count) {
  23461. var temp = first;
  23462. first = second;
  23463. second = temp;
  23464. swapped = count;
  23465. }, run = function () {
  23466. if (firstDimension.apply(0, first) !== false) {
  23467. if (secondDimension.apply(0, second) === false &&
  23468. !swapped) {
  23469. swap(true);
  23470. run();
  23471. }
  23472. }
  23473. else if (!swapped) {
  23474. swap(true);
  23475. run();
  23476. }
  23477. else {
  23478. ret.x = ret.y = 0;
  23479. }
  23480. };
  23481. // Under these conditions, prefer the tooltip on the side of the point
  23482. if (chart.inverted || this.len > 1) {
  23483. swap();
  23484. }
  23485. run();
  23486. return ret;
  23487. };
  23488. /**
  23489. * Get the best X date format based on the closest point range on the axis.
  23490. *
  23491. * @private
  23492. * @function Highcharts.Tooltip#getXDateFormat
  23493. *
  23494. * @param {Highcharts.Point} point
  23495. *
  23496. * @param {Highcharts.TooltipOptions} options
  23497. *
  23498. * @param {Highcharts.Axis} xAxis
  23499. *
  23500. * @return {string}
  23501. */
  23502. Tooltip.prototype.getXDateFormat = function (point, options, xAxis) {
  23503. var xDateFormat,
  23504. dateTimeLabelFormats = options.dateTimeLabelFormats,
  23505. closestPointRange = xAxis && xAxis.closestPointRange;
  23506. if (closestPointRange) {
  23507. xDateFormat = this.getDateFormat(closestPointRange, point.x, xAxis.options.startOfWeek, dateTimeLabelFormats);
  23508. }
  23509. else {
  23510. xDateFormat = dateTimeLabelFormats.day;
  23511. }
  23512. return xDateFormat || dateTimeLabelFormats.year; // #2546, 2581
  23513. };
  23514. /**
  23515. * Hides the tooltip with a fade out animation.
  23516. *
  23517. * @function Highcharts.Tooltip#hide
  23518. *
  23519. * @param {number} [delay]
  23520. * The fade out in milliseconds. If no value is provided the value
  23521. * of the tooltip.hideDelay option is used. A value of 0 disables
  23522. * the fade out animation.
  23523. */
  23524. Tooltip.prototype.hide = function (delay) {
  23525. var tooltip = this;
  23526. // disallow duplicate timers (#1728, #1766)
  23527. U.clearTimeout(this.hideTimer);
  23528. delay = pick(delay, this.options.hideDelay, 500);
  23529. if (!this.isHidden) {
  23530. this.hideTimer = syncTimeout(function () {
  23531. // If there is a delay, do fadeOut with the default duration. If
  23532. // the hideDelay is 0, we assume no animation is wanted, so we
  23533. // pass 0 duration. #12994.
  23534. tooltip.getLabel().fadeOut(delay ? void 0 : delay);
  23535. tooltip.isHidden = true;
  23536. }, delay);
  23537. }
  23538. };
  23539. /**
  23540. * @private
  23541. * @function Highcharts.Tooltip#init
  23542. *
  23543. * @param {Highcharts.Chart} chart
  23544. * The chart instance.
  23545. *
  23546. * @param {Highcharts.TooltipOptions} options
  23547. * Tooltip options.
  23548. */
  23549. Tooltip.prototype.init = function (chart, options) {
  23550. /**
  23551. * Chart of the tooltip.
  23552. *
  23553. * @readonly
  23554. * @name Highcharts.Tooltip#chart
  23555. * @type {Highcharts.Chart}
  23556. */
  23557. this.chart = chart;
  23558. /**
  23559. * Used tooltip options.
  23560. *
  23561. * @readonly
  23562. * @name Highcharts.Tooltip#options
  23563. * @type {Highcharts.TooltipOptions}
  23564. */
  23565. this.options = options;
  23566. /**
  23567. * List of crosshairs.
  23568. *
  23569. * @private
  23570. * @readonly
  23571. * @name Highcharts.Tooltip#crosshairs
  23572. * @type {Array<null>}
  23573. */
  23574. this.crosshairs = [];
  23575. /**
  23576. * Current values of x and y when animating.
  23577. *
  23578. * @private
  23579. * @readonly
  23580. * @name Highcharts.Tooltip#now
  23581. * @type {Highcharts.PositionObject}
  23582. */
  23583. this.now = { x: 0, y: 0 };
  23584. /**
  23585. * Tooltips are initially hidden.
  23586. *
  23587. * @private
  23588. * @readonly
  23589. * @name Highcharts.Tooltip#isHidden
  23590. * @type {boolean}
  23591. */
  23592. this.isHidden = true;
  23593. /**
  23594. * True, if the tooltip is split into one label per series, with the
  23595. * header close to the axis.
  23596. *
  23597. * @readonly
  23598. * @name Highcharts.Tooltip#split
  23599. * @type {boolean|undefined}
  23600. */
  23601. this.split = options.split && !chart.inverted && !chart.polar;
  23602. /**
  23603. * When the tooltip is shared, the entire plot area will capture mouse
  23604. * movement or touch events.
  23605. *
  23606. * @readonly
  23607. * @name Highcharts.Tooltip#shared
  23608. * @type {boolean|undefined}
  23609. */
  23610. this.shared = options.shared || this.split;
  23611. /**
  23612. * Whether to allow the tooltip to render outside the chart's SVG
  23613. * element box. By default (false), the tooltip is rendered within the
  23614. * chart's SVG element, which results in the tooltip being aligned
  23615. * inside the chart area.
  23616. *
  23617. * @readonly
  23618. * @name Highcharts.Tooltip#outside
  23619. * @type {boolean}
  23620. *
  23621. * @todo
  23622. * Split tooltip does not support outside in the first iteration. Should
  23623. * not be too complicated to implement.
  23624. */
  23625. this.outside = pick(options.outside, Boolean(chart.scrollablePixelsX || chart.scrollablePixelsY));
  23626. };
  23627. /**
  23628. * Returns true, if the pointer is in contact with the tooltip tracker.
  23629. */
  23630. Tooltip.prototype.isStickyOnContact = function () {
  23631. return !!(!this.followPointer &&
  23632. this.options.stickOnContact &&
  23633. this.inContact);
  23634. };
  23635. /**
  23636. * Moves the tooltip with a soft animation to a new position.
  23637. *
  23638. * @private
  23639. * @function Highcharts.Tooltip#move
  23640. *
  23641. * @param {number} x
  23642. *
  23643. * @param {number} y
  23644. *
  23645. * @param {number} anchorX
  23646. *
  23647. * @param {number} anchorY
  23648. */
  23649. Tooltip.prototype.move = function (x, y, anchorX, anchorY) {
  23650. var tooltip = this,
  23651. now = tooltip.now,
  23652. animate = tooltip.options.animation !== false &&
  23653. !tooltip.isHidden &&
  23654. // When we get close to the target position, abort animation and
  23655. // land on the right place (#3056)
  23656. (Math.abs(x - now.x) > 1 || Math.abs(y - now.y) > 1),
  23657. skipAnchor = tooltip.followPointer || tooltip.len > 1;
  23658. // Get intermediate values for animation
  23659. extend(now, {
  23660. x: animate ? (2 * now.x + x) / 3 : x,
  23661. y: animate ? (now.y + y) / 2 : y,
  23662. anchorX: skipAnchor ?
  23663. void 0 :
  23664. animate ? (2 * now.anchorX + anchorX) / 3 : anchorX,
  23665. anchorY: skipAnchor ?
  23666. void 0 :
  23667. animate ? (now.anchorY + anchorY) / 2 : anchorY
  23668. });
  23669. // Move to the intermediate value
  23670. tooltip.getLabel().attr(now);
  23671. tooltip.drawTracker();
  23672. // Run on next tick of the mouse tracker
  23673. if (animate) {
  23674. // Never allow two timeouts
  23675. U.clearTimeout(this.tooltipTimeout);
  23676. // Set the fixed interval ticking for the smooth tooltip
  23677. this.tooltipTimeout = setTimeout(function () {
  23678. // The interval function may still be running during destroy,
  23679. // so check that the chart is really there before calling.
  23680. if (tooltip) {
  23681. tooltip.move(x, y, anchorX, anchorY);
  23682. }
  23683. }, 32);
  23684. }
  23685. };
  23686. /**
  23687. * Refresh the tooltip's text and position.
  23688. *
  23689. * @function Highcharts.Tooltip#refresh
  23690. *
  23691. * @param {Highcharts.Point|Array<Highcharts.Point>} pointOrPoints
  23692. * Either a point or an array of points.
  23693. *
  23694. * @param {Highcharts.PointerEventObject} [mouseEvent]
  23695. * Mouse event, that is responsible for the refresh and should be
  23696. * used for the tooltip update.
  23697. */
  23698. Tooltip.prototype.refresh = function (pointOrPoints, mouseEvent) {
  23699. var tooltip = this,
  23700. chart = this.chart,
  23701. options = tooltip.options,
  23702. x,
  23703. y,
  23704. points = splat(pointOrPoints),
  23705. point = points[0],
  23706. anchor,
  23707. textConfig = {},
  23708. text,
  23709. pointConfig = [],
  23710. formatter = options.formatter || tooltip.defaultFormatter,
  23711. shared = tooltip.shared,
  23712. styledMode = chart.styledMode;
  23713. if (!options.enabled) {
  23714. return;
  23715. }
  23716. U.clearTimeout(this.hideTimer);
  23717. // get the reference point coordinates (pie charts use tooltipPos)
  23718. tooltip.followPointer = !tooltip.split && point.series.tooltipOptions.followPointer;
  23719. anchor = tooltip.getAnchor(pointOrPoints, mouseEvent);
  23720. x = anchor[0];
  23721. y = anchor[1];
  23722. // shared tooltip, array is sent over
  23723. if (shared &&
  23724. !(!isArray(pointOrPoints) &&
  23725. pointOrPoints.series &&
  23726. pointOrPoints.series.noSharedTooltip)) {
  23727. chart.pointer.applyInactiveState(points);
  23728. // Now set hover state for the choosen ones:
  23729. points.forEach(function (item) {
  23730. item.setState('hover');
  23731. pointConfig.push(item.getLabelConfig());
  23732. });
  23733. textConfig = {
  23734. x: point.category,
  23735. y: point.y
  23736. };
  23737. textConfig.points = pointConfig;
  23738. // single point tooltip
  23739. }
  23740. else {
  23741. textConfig = point.getLabelConfig();
  23742. }
  23743. this.len = pointConfig.length; // #6128
  23744. text = formatter.call(textConfig, tooltip);
  23745. // register the current series
  23746. var currentSeries = point.series;
  23747. this.distance = pick(currentSeries.tooltipOptions.distance, 16);
  23748. // update the inner HTML
  23749. if (text === false) {
  23750. this.hide();
  23751. }
  23752. else {
  23753. // update text
  23754. if (tooltip.split) {
  23755. this.renderSplit(text, points);
  23756. }
  23757. else {
  23758. var checkX = x;
  23759. var checkY = y;
  23760. if (mouseEvent && chart.pointer.isDirectTouch) {
  23761. checkX = mouseEvent.chartX - chart.plotLeft;
  23762. checkY = mouseEvent.chartY - chart.plotTop;
  23763. }
  23764. // #11493, #13095
  23765. if (chart.polar ||
  23766. currentSeries.options.clip === false ||
  23767. currentSeries.shouldShowTooltip(checkX, checkY)) {
  23768. var label = tooltip.getLabel();
  23769. // Prevent the tooltip from flowing over the chart box
  23770. // (#6659)
  23771. if (!options.style.width || styledMode) {
  23772. label.css({
  23773. width: this.chart.spacingBox.width + 'px'
  23774. });
  23775. }
  23776. label.attr({
  23777. text: text && text.join ?
  23778. text.join('') :
  23779. text
  23780. });
  23781. // Set the stroke color of the box to reflect the point
  23782. label.removeClass(/highcharts-color-[\d]+/g)
  23783. .addClass('highcharts-color-' +
  23784. pick(point.colorIndex, currentSeries.colorIndex));
  23785. if (!styledMode) {
  23786. label.attr({
  23787. stroke: (options.borderColor ||
  23788. point.color ||
  23789. currentSeries.color ||
  23790. palette.neutralColor60)
  23791. });
  23792. }
  23793. tooltip.updatePosition({
  23794. plotX: x,
  23795. plotY: y,
  23796. negative: point.negative,
  23797. ttBelow: point.ttBelow,
  23798. h: anchor[2] || 0
  23799. });
  23800. }
  23801. else {
  23802. tooltip.hide();
  23803. return;
  23804. }
  23805. }
  23806. // show it
  23807. if (tooltip.isHidden && tooltip.label) {
  23808. tooltip.label.attr({
  23809. opacity: 1
  23810. }).show();
  23811. }
  23812. tooltip.isHidden = false;
  23813. }
  23814. fireEvent(this, 'refresh');
  23815. };
  23816. /**
  23817. * Render the split tooltip. Loops over each point's text and adds
  23818. * a label next to the point, then uses the distribute function to
  23819. * find best non-overlapping positions.
  23820. *
  23821. * @private
  23822. * @function Highcharts.Tooltip#renderSplit
  23823. *
  23824. * @param {string|Array<(boolean|string)>} labels
  23825. *
  23826. * @param {Array<Highcharts.Point>} points
  23827. */
  23828. Tooltip.prototype.renderSplit = function (labels, points) {
  23829. var tooltip = this;
  23830. var chart = tooltip.chart,
  23831. _a = tooltip.chart,
  23832. chartWidth = _a.chartWidth,
  23833. chartHeight = _a.chartHeight,
  23834. plotHeight = _a.plotHeight,
  23835. plotLeft = _a.plotLeft,
  23836. plotTop = _a.plotTop,
  23837. pointer = _a.pointer,
  23838. _b = _a.scrollablePixelsY,
  23839. scrollablePixelsY = _b === void 0 ? 0 : _b,
  23840. scrollablePixelsX = _a.scrollablePixelsX,
  23841. _c = _a.scrollingContainer,
  23842. _d = _c === void 0 ? { scrollLeft: 0,
  23843. scrollTop: 0 } : _c,
  23844. scrollLeft = _d.scrollLeft,
  23845. scrollTop = _d.scrollTop,
  23846. styledMode = _a.styledMode,
  23847. distance = tooltip.distance,
  23848. options = tooltip.options,
  23849. positioner = tooltip.options.positioner;
  23850. // The area which the tooltip should be limited to. Limit to scrollable
  23851. // plot area if enabled, otherwise limit to the chart container.
  23852. // If outside is true it should be the whole viewport
  23853. var bounds = tooltip.outside && typeof scrollablePixelsX !== 'number' ?
  23854. doc.documentElement.getBoundingClientRect() : {
  23855. left: scrollLeft,
  23856. right: scrollLeft + chartWidth,
  23857. top: scrollTop,
  23858. bottom: scrollTop + chartHeight
  23859. };
  23860. var tooltipLabel = tooltip.getLabel();
  23861. var ren = this.renderer || chart.renderer;
  23862. var headerTop = Boolean(chart.xAxis[0] && chart.xAxis[0].opposite);
  23863. var _e = pointer.getChartPosition(),
  23864. chartLeft = _e.left,
  23865. chartTop = _e.top;
  23866. var distributionBoxTop = plotTop + scrollTop;
  23867. var headerHeight = 0;
  23868. var adjustedPlotHeight = plotHeight - scrollablePixelsY;
  23869. /**
  23870. * Calculates the anchor position for the partial tooltip
  23871. *
  23872. * @private
  23873. * @param {Highcharts.Point} point The point related to the tooltip
  23874. * @return {object} Returns an object with anchorX and anchorY
  23875. */
  23876. function getAnchor(point) {
  23877. var isHeader = point.isHeader,
  23878. _a = point.plotX,
  23879. plotX = _a === void 0 ? 0 : _a,
  23880. _b = point.plotY,
  23881. plotY = _b === void 0 ? 0 : _b,
  23882. series = point.series;
  23883. var anchorX;
  23884. var anchorY;
  23885. if (isHeader) {
  23886. // Set anchorX to plotX
  23887. anchorX = plotLeft + plotX;
  23888. // Set anchorY to center of visible plot area.
  23889. anchorY = plotTop + plotHeight / 2;
  23890. }
  23891. else {
  23892. var xAxis = series.xAxis,
  23893. yAxis = series.yAxis;
  23894. // Set anchorX to plotX. Limit to within xAxis.
  23895. anchorX = xAxis.pos + clamp(plotX, -distance, xAxis.len + distance);
  23896. // Set anchorY, limit to the scrollable plot area
  23897. if (series.shouldShowTooltip(0, yAxis.pos - plotTop + plotY, {
  23898. ignoreX: true
  23899. })) {
  23900. anchorY = yAxis.pos + plotY;
  23901. }
  23902. }
  23903. // Limit values to plot area
  23904. anchorX = clamp(anchorX, bounds.left - distance, bounds.right + distance);
  23905. return { anchorX: anchorX, anchorY: anchorY };
  23906. }
  23907. /**
  23908. * Calculates the position of the partial tooltip
  23909. *
  23910. * @private
  23911. * @param {number} anchorX The partial tooltip anchor x position
  23912. * @param {number} anchorY The partial tooltip anchor y position
  23913. * @param {boolean} isHeader Whether the partial tooltip is a header
  23914. * @param {number} boxWidth Width of the partial tooltip
  23915. * @return {Highcharts.PositionObject} Returns the partial tooltip x and
  23916. * y position
  23917. */
  23918. function defaultPositioner(anchorX, anchorY, isHeader, boxWidth, alignedLeft) {
  23919. if (alignedLeft === void 0) { alignedLeft = true; }
  23920. var y;
  23921. var x;
  23922. if (isHeader) {
  23923. y = headerTop ? 0 : adjustedPlotHeight;
  23924. x = clamp(anchorX - (boxWidth / 2), bounds.left, bounds.right - boxWidth - (tooltip.outside ? chartLeft : 0));
  23925. }
  23926. else {
  23927. y = anchorY - distributionBoxTop;
  23928. x = alignedLeft ?
  23929. anchorX - boxWidth - distance :
  23930. anchorX + distance;
  23931. x = clamp(x, alignedLeft ? x : bounds.left, bounds.right);
  23932. }
  23933. // NOTE: y is relative to distributionBoxTop
  23934. return { x: x, y: y };
  23935. }
  23936. /**
  23937. * Updates the attributes and styling of the partial tooltip. Creates a
  23938. * new partial tooltip if it does not exists.
  23939. *
  23940. * @private
  23941. * @param {Highcharts.SVGElement|undefined} partialTooltip
  23942. * The partial tooltip to update
  23943. * @param {Highcharts.Point} point
  23944. * The point related to the partial tooltip
  23945. * @param {boolean|string} str The text for the partial tooltip
  23946. * @return {Highcharts.SVGElement} Returns the updated partial tooltip
  23947. */
  23948. function updatePartialTooltip(partialTooltip, point, str) {
  23949. var tt = partialTooltip;
  23950. var isHeader = point.isHeader,
  23951. series = point.series;
  23952. var colorClass = 'highcharts-color-' + pick(point.colorIndex, series.colorIndex, 'none');
  23953. if (!tt) {
  23954. var attribs = {
  23955. padding: options.padding,
  23956. r: options.borderRadius
  23957. };
  23958. if (!styledMode) {
  23959. attribs.fill = options.backgroundColor;
  23960. attribs['stroke-width'] = options.borderWidth;
  23961. }
  23962. tt = ren
  23963. .label('', 0, 0, (options[isHeader ? 'headerShape' : 'shape']) ||
  23964. 'callout', void 0, void 0, options.useHTML)
  23965. .addClass((isHeader ? 'highcharts-tooltip-header ' : '') +
  23966. 'highcharts-tooltip-box ' +
  23967. colorClass)
  23968. .attr(attribs)
  23969. .add(tooltipLabel);
  23970. }
  23971. tt.isActive = true;
  23972. tt.attr({
  23973. text: str
  23974. });
  23975. if (!styledMode) {
  23976. tt.css(options.style)
  23977. .shadow(options.shadow)
  23978. .attr({
  23979. stroke: (options.borderColor ||
  23980. point.color ||
  23981. series.color ||
  23982. palette.neutralColor80)
  23983. });
  23984. }
  23985. return tt;
  23986. }
  23987. // Graceful degradation for legacy formatters
  23988. if (isString(labels)) {
  23989. labels = [false, labels];
  23990. }
  23991. // Create the individual labels for header and points, ignore footer
  23992. var boxes = labels.slice(0,
  23993. points.length + 1).reduce(function (boxes,
  23994. str,
  23995. i) {
  23996. if (str !== false && str !== '') {
  23997. var point = (points[i - 1] ||
  23998. {
  23999. // Item 0 is the header. Instead of this, we could also
  24000. // use the crosshair label
  24001. isHeader: true,
  24002. plotX: points[0].plotX,
  24003. plotY: plotHeight,
  24004. series: {}
  24005. });
  24006. var isHeader = point.isHeader;
  24007. // Store the tooltip label referance on the series
  24008. var owner = isHeader ? tooltip : point.series;
  24009. var tt = owner.tt = updatePartialTooltip(owner.tt,
  24010. point,
  24011. str.toString());
  24012. // Get X position now, so we can move all to the other side in
  24013. // case of overflow
  24014. var bBox = tt.getBBox();
  24015. var boxWidth = bBox.width + tt.strokeWidth();
  24016. if (isHeader) {
  24017. headerHeight = bBox.height;
  24018. adjustedPlotHeight += headerHeight;
  24019. if (headerTop) {
  24020. distributionBoxTop -= headerHeight;
  24021. }
  24022. }
  24023. var _a = getAnchor(point),
  24024. anchorX = _a.anchorX,
  24025. anchorY = _a.anchorY;
  24026. if (typeof anchorY === 'number') {
  24027. var size = bBox.height + 1;
  24028. var boxPosition = (positioner ?
  24029. positioner.call(tooltip,
  24030. boxWidth,
  24031. size,
  24032. point) :
  24033. defaultPositioner(anchorX,
  24034. anchorY,
  24035. isHeader,
  24036. boxWidth));
  24037. boxes.push({
  24038. // 0-align to the top, 1-align to the bottom
  24039. align: positioner ? 0 : void 0,
  24040. anchorX: anchorX,
  24041. anchorY: anchorY,
  24042. boxWidth: boxWidth,
  24043. point: point,
  24044. rank: pick(boxPosition.rank, isHeader ? 1 : 0),
  24045. size: size,
  24046. target: boxPosition.y,
  24047. tt: tt,
  24048. x: boxPosition.x
  24049. });
  24050. }
  24051. else {
  24052. // Hide tooltips which anchorY is outside the visible plot
  24053. // area
  24054. tt.isActive = false;
  24055. }
  24056. }
  24057. return boxes;
  24058. }, []);
  24059. // Realign the tooltips towards the right if there is not enough
  24060. // space to the left and there is space to to the right
  24061. if (!positioner && boxes.some(function (box) {
  24062. // Always realign if the beginning of a label is outside bounds
  24063. var outside = tooltip.outside;
  24064. var boxStart = (outside ? chartLeft : 0) + box.anchorX;
  24065. if (boxStart < bounds.left && boxStart + box.boxWidth < bounds.right) {
  24066. return true;
  24067. }
  24068. // Otherwise, check if there is more space available to the right
  24069. return boxStart < (chartLeft - bounds.left) + box.boxWidth &&
  24070. bounds.right - boxStart > boxStart;
  24071. })) {
  24072. boxes = boxes.map(function (box) {
  24073. var _a = defaultPositioner(box.anchorX,
  24074. box.anchorY,
  24075. box.point.isHeader,
  24076. box.boxWidth,
  24077. false),
  24078. x = _a.x,
  24079. y = _a.y;
  24080. return extend(box, {
  24081. target: y,
  24082. x: x
  24083. });
  24084. });
  24085. }
  24086. // Clean previous run (for missing points)
  24087. tooltip.cleanSplit();
  24088. // Distribute and put in place
  24089. H.distribute(boxes, adjustedPlotHeight);
  24090. var boxExtremes = {
  24091. left: chartLeft,
  24092. right: chartLeft
  24093. };
  24094. // Get the extremes from series tooltips
  24095. boxes.forEach(function (box) {
  24096. var x = box.x,
  24097. boxWidth = box.boxWidth,
  24098. isHeader = box.isHeader;
  24099. if (!isHeader) {
  24100. if (tooltip.outside && chartLeft + x < boxExtremes.left) {
  24101. boxExtremes.left = chartLeft + x;
  24102. }
  24103. if (!isHeader && tooltip.outside && boxExtremes.left + boxWidth > boxExtremes.right) {
  24104. boxExtremes.right = chartLeft + x;
  24105. }
  24106. }
  24107. });
  24108. boxes.forEach(function (box) {
  24109. var x = box.x,
  24110. anchorX = box.anchorX,
  24111. anchorY = box.anchorY,
  24112. pos = box.pos,
  24113. isHeader = box.point.isHeader;
  24114. var attributes = {
  24115. visibility: typeof pos === 'undefined' ? 'hidden' : 'inherit',
  24116. x: x,
  24117. /* NOTE: y should equal pos to be consistent with !split
  24118. * tooltip,
  24119. but is currently relative to plotTop. Is left as is
  24120. * to avoid breaking change. Remove distributionBoxTop to make
  24121. * it consistent.
  24122. */
  24123. y: pos + distributionBoxTop,
  24124. anchorX: anchorX,
  24125. anchorY: anchorY
  24126. };
  24127. // Handle left-aligned tooltips overflowing the chart area
  24128. if (tooltip.outside && x < anchorX) {
  24129. var offset = chartLeft - boxExtremes.left;
  24130. // Skip this if there is no overflow
  24131. if (offset > 0) {
  24132. if (!isHeader) {
  24133. attributes.x = x + offset;
  24134. attributes.anchorX = anchorX + offset;
  24135. }
  24136. if (isHeader) {
  24137. attributes.x = (boxExtremes.right - boxExtremes.left) / 2;
  24138. attributes.anchorX = anchorX + offset;
  24139. }
  24140. }
  24141. }
  24142. // Put the label in place
  24143. box.tt.attr(attributes);
  24144. });
  24145. /* If we have a seperate tooltip container, then update the necessary
  24146. * container properties.
  24147. * Test that tooltip has its own container and renderer before executing
  24148. * the operation.
  24149. */
  24150. var container = tooltip.container,
  24151. outside = tooltip.outside,
  24152. renderer = tooltip.renderer;
  24153. if (outside && container && renderer) {
  24154. // Set container size to fit the bounds
  24155. var _f = tooltipLabel.getBBox(),
  24156. width = _f.width,
  24157. height = _f.height,
  24158. x = _f.x,
  24159. y = _f.y;
  24160. renderer.setSize(width + x, height + y, false);
  24161. // Position the tooltip container to the chart container
  24162. container.style.left = boxExtremes.left + 'px';
  24163. container.style.top = chartTop + 'px';
  24164. }
  24165. };
  24166. /**
  24167. * If the `stickOnContact` option is active, this will add a tracker shape.
  24168. *
  24169. * @private
  24170. * @function Highcharts.Tooltip#drawTracker
  24171. */
  24172. Tooltip.prototype.drawTracker = function () {
  24173. var tooltip = this;
  24174. if (tooltip.followPointer ||
  24175. !tooltip.options.stickOnContact) {
  24176. if (tooltip.tracker) {
  24177. tooltip.tracker.destroy();
  24178. }
  24179. return;
  24180. }
  24181. var chart = tooltip.chart;
  24182. var label = tooltip.label;
  24183. var point = chart.hoverPoint;
  24184. if (!label || !point) {
  24185. return;
  24186. }
  24187. var box = {
  24188. x: 0,
  24189. y: 0,
  24190. width: 0,
  24191. height: 0
  24192. };
  24193. // Combine anchor and tooltip
  24194. var anchorPos = this.getAnchor(point);
  24195. var labelBBox = label.getBBox();
  24196. anchorPos[0] += chart.plotLeft - label.translateX;
  24197. anchorPos[1] += chart.plotTop - label.translateY;
  24198. // When the mouse pointer is between the anchor point and the label,
  24199. // the label should stick.
  24200. box.x = Math.min(0, anchorPos[0]);
  24201. box.y = Math.min(0, anchorPos[1]);
  24202. box.width = (anchorPos[0] < 0 ?
  24203. Math.max(Math.abs(anchorPos[0]), (labelBBox.width - anchorPos[0])) :
  24204. Math.max(Math.abs(anchorPos[0]), labelBBox.width));
  24205. box.height = (anchorPos[1] < 0 ?
  24206. Math.max(Math.abs(anchorPos[1]), (labelBBox.height - Math.abs(anchorPos[1]))) :
  24207. Math.max(Math.abs(anchorPos[1]), labelBBox.height));
  24208. if (tooltip.tracker) {
  24209. tooltip.tracker.attr(box);
  24210. }
  24211. else {
  24212. tooltip.tracker = label.renderer
  24213. .rect(box)
  24214. .addClass('highcharts-tracker')
  24215. .add(label);
  24216. if (!chart.styledMode) {
  24217. tooltip.tracker.attr({
  24218. fill: 'rgba(0,0,0,0)'
  24219. });
  24220. }
  24221. }
  24222. };
  24223. /**
  24224. * @private
  24225. */
  24226. Tooltip.prototype.styledModeFormat = function (formatString) {
  24227. return formatString
  24228. .replace('style="font-size: 10px"', 'class="highcharts-header"')
  24229. .replace(/style="color:{(point|series)\.color}"/g, 'class="highcharts-color-{$1.colorIndex}"');
  24230. };
  24231. /**
  24232. * Format the footer/header of the tooltip
  24233. * #3397: abstraction to enable formatting of footer and header
  24234. *
  24235. * @private
  24236. * @function Highcharts.Tooltip#tooltipFooterHeaderFormatter
  24237. * @param {Highcharts.PointLabelObject} labelConfig
  24238. * @param {boolean} [isFooter]
  24239. * @return {string}
  24240. */
  24241. Tooltip.prototype.tooltipFooterHeaderFormatter = function (labelConfig, isFooter) {
  24242. var footOrHead = isFooter ? 'footer' : 'header',
  24243. series = labelConfig.series,
  24244. tooltipOptions = series.tooltipOptions,
  24245. xDateFormat = tooltipOptions.xDateFormat,
  24246. xAxis = series.xAxis,
  24247. isDateTime = (xAxis &&
  24248. xAxis.options.type === 'datetime' &&
  24249. isNumber(labelConfig.key)),
  24250. formatString = tooltipOptions[footOrHead + 'Format'],
  24251. e = {
  24252. isFooter: isFooter,
  24253. labelConfig: labelConfig
  24254. };
  24255. fireEvent(this, 'headerFormatter', e, function (e) {
  24256. // Guess the best date format based on the closest point distance
  24257. // (#568, #3418)
  24258. if (isDateTime && !xDateFormat) {
  24259. xDateFormat = this.getXDateFormat(labelConfig, tooltipOptions, xAxis);
  24260. }
  24261. // Insert the footer date format if any
  24262. if (isDateTime && xDateFormat) {
  24263. ((labelConfig.point && labelConfig.point.tooltipDateKeys) ||
  24264. ['key']).forEach(function (key) {
  24265. formatString = formatString.replace('{point.' + key + '}', '{point.' + key + ':' + xDateFormat + '}');
  24266. });
  24267. }
  24268. // Replace default header style with class name
  24269. if (series.chart.styledMode) {
  24270. formatString = this.styledModeFormat(formatString);
  24271. }
  24272. e.text = format(formatString, {
  24273. point: labelConfig,
  24274. series: series
  24275. }, this.chart);
  24276. });
  24277. return e.text;
  24278. };
  24279. /**
  24280. * Updates the tooltip with the provided tooltip options.
  24281. *
  24282. * @function Highcharts.Tooltip#update
  24283. *
  24284. * @param {Highcharts.TooltipOptions} options
  24285. * The tooltip options to update.
  24286. */
  24287. Tooltip.prototype.update = function (options) {
  24288. this.destroy();
  24289. // Update user options (#6218)
  24290. merge(true, this.chart.options.tooltip.userOptions, options);
  24291. this.init(this.chart, merge(true, this.options, options));
  24292. };
  24293. /**
  24294. * Find the new position and perform the move
  24295. *
  24296. * @private
  24297. * @function Highcharts.Tooltip#updatePosition
  24298. *
  24299. * @param {Highcharts.Point} point
  24300. */
  24301. Tooltip.prototype.updatePosition = function (point) {
  24302. var chart = this.chart,
  24303. pointer = chart.pointer,
  24304. label = this.getLabel(),
  24305. pos,
  24306. anchorX = point.plotX + chart.plotLeft,
  24307. anchorY = point.plotY + chart.plotTop,
  24308. pad;
  24309. // Needed for outside: true (#11688)
  24310. var chartPosition = pointer.getChartPosition();
  24311. pos = (this.options.positioner || this.getPosition).call(this, label.width, label.height, point);
  24312. // Set the renderer size dynamically to prevent document size to change
  24313. if (this.outside) {
  24314. pad = (this.options.borderWidth || 0) + 2 * this.distance;
  24315. this.renderer.setSize(label.width + pad, label.height + pad, false);
  24316. // Anchor and tooltip container need scaling if chart container has
  24317. // scale transform/css zoom. #11329.
  24318. if (chartPosition.scaleX !== 1 || chartPosition.scaleY !== 1) {
  24319. css(this.container, {
  24320. transform: "scale(" + chartPosition.scaleX + ", " + chartPosition.scaleY + ")"
  24321. });
  24322. anchorX *= chartPosition.scaleX;
  24323. anchorY *= chartPosition.scaleY;
  24324. }
  24325. anchorX += chartPosition.left - pos.x;
  24326. anchorY += chartPosition.top - pos.y;
  24327. }
  24328. // do the move
  24329. this.move(Math.round(pos.x), Math.round(pos.y || 0), // can be undefined (#3977)
  24330. anchorX, anchorY);
  24331. };
  24332. return Tooltip;
  24333. }());
  24334. H.Tooltip = Tooltip;
  24335. return H.Tooltip;
  24336. });
  24337. _registerModule(_modules, 'Core/Pointer.js', [_modules['Core/Color/Color.js'], _modules['Core/Globals.js'], _modules['Core/Color/Palette.js'], _modules['Core/Tooltip.js'], _modules['Core/Utilities.js']], function (Color, H, palette, Tooltip, U) {
  24338. /* *
  24339. *
  24340. * (c) 2010-2021 Torstein Honsi
  24341. *
  24342. * License: www.highcharts.com/license
  24343. *
  24344. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  24345. *
  24346. * */
  24347. var color = Color.parse;
  24348. var charts = H.charts,
  24349. noop = H.noop;
  24350. var addEvent = U.addEvent,
  24351. attr = U.attr,
  24352. css = U.css,
  24353. defined = U.defined,
  24354. extend = U.extend,
  24355. find = U.find,
  24356. fireEvent = U.fireEvent,
  24357. isNumber = U.isNumber,
  24358. isObject = U.isObject,
  24359. objectEach = U.objectEach,
  24360. offset = U.offset,
  24361. pick = U.pick,
  24362. splat = U.splat;
  24363. /**
  24364. * One position in relation to an axis.
  24365. *
  24366. * @interface Highcharts.PointerAxisCoordinateObject
  24367. */ /**
  24368. * Related axis.
  24369. *
  24370. * @name Highcharts.PointerAxisCoordinateObject#axis
  24371. * @type {Highcharts.Axis}
  24372. */ /**
  24373. * Axis value.
  24374. *
  24375. * @name Highcharts.PointerAxisCoordinateObject#value
  24376. * @type {number}
  24377. */
  24378. /**
  24379. * Positions in terms of axis values.
  24380. *
  24381. * @interface Highcharts.PointerAxisCoordinatesObject
  24382. */ /**
  24383. * Positions on the x-axis.
  24384. * @name Highcharts.PointerAxisCoordinatesObject#xAxis
  24385. * @type {Array<Highcharts.PointerAxisCoordinateObject>}
  24386. */ /**
  24387. * Positions on the y-axis.
  24388. * @name Highcharts.PointerAxisCoordinatesObject#yAxis
  24389. * @type {Array<Highcharts.PointerAxisCoordinateObject>}
  24390. */
  24391. /**
  24392. * Pointer coordinates.
  24393. *
  24394. * @interface Highcharts.PointerCoordinatesObject
  24395. */ /**
  24396. * @name Highcharts.PointerCoordinatesObject#chartX
  24397. * @type {number}
  24398. */ /**
  24399. * @name Highcharts.PointerCoordinatesObject#chartY
  24400. * @type {number}
  24401. */
  24402. /**
  24403. * A native browser mouse or touch event, extended with position information
  24404. * relative to the {@link Chart.container}.
  24405. *
  24406. * @interface Highcharts.PointerEventObject
  24407. * @extends global.PointerEvent
  24408. */ /**
  24409. * The X coordinate of the pointer interaction relative to the chart.
  24410. *
  24411. * @name Highcharts.PointerEventObject#chartX
  24412. * @type {number}
  24413. */ /**
  24414. * The Y coordinate of the pointer interaction relative to the chart.
  24415. *
  24416. * @name Highcharts.PointerEventObject#chartY
  24417. * @type {number}
  24418. */
  24419. /**
  24420. * Axis-specific data of a selection.
  24421. *
  24422. * @interface Highcharts.SelectDataObject
  24423. */ /**
  24424. * @name Highcharts.SelectDataObject#axis
  24425. * @type {Highcharts.Axis}
  24426. */ /**
  24427. * @name Highcharts.SelectDataObject#max
  24428. * @type {number}
  24429. */ /**
  24430. * @name Highcharts.SelectDataObject#min
  24431. * @type {number}
  24432. */
  24433. /**
  24434. * Object for select events.
  24435. *
  24436. * @interface Highcharts.SelectEventObject
  24437. */ /**
  24438. * @name Highcharts.SelectEventObject#originalEvent
  24439. * @type {global.Event}
  24440. */ /**
  24441. * @name Highcharts.SelectEventObject#xAxis
  24442. * @type {Array<Highcharts.SelectDataObject>}
  24443. */ /**
  24444. * @name Highcharts.SelectEventObject#yAxis
  24445. * @type {Array<Highcharts.SelectDataObject>}
  24446. */
  24447. /**
  24448. * Chart position and scale.
  24449. *
  24450. * @interface Highcharts.ChartPositionObject
  24451. */ /**
  24452. * @name Highcharts.ChartPositionObject#left
  24453. * @type {number}
  24454. */ /**
  24455. * @name Highcharts.ChartPositionObject#scaleX
  24456. * @type {number}
  24457. */ /**
  24458. * @name Highcharts.ChartPositionObject#scaleY
  24459. * @type {number}
  24460. */ /**
  24461. * @name Highcharts.ChartPositionObject#top
  24462. * @type {number}
  24463. */
  24464. ''; // detach doclets above
  24465. /* eslint-disable no-invalid-this, valid-jsdoc */
  24466. /**
  24467. * The mouse and touch tracker object. Each {@link Chart} item has one
  24468. * assosiated Pointer item that can be accessed from the {@link Chart.pointer}
  24469. * property.
  24470. *
  24471. * @class
  24472. * @name Highcharts.Pointer
  24473. *
  24474. * @param {Highcharts.Chart} chart
  24475. * The chart instance.
  24476. *
  24477. * @param {Highcharts.Options} options
  24478. * The root options object. The pointer uses options from the chart and
  24479. * tooltip structures.
  24480. */
  24481. var Pointer = /** @class */ (function () {
  24482. /* *
  24483. *
  24484. * Constructors
  24485. *
  24486. * */
  24487. function Pointer(chart, options) {
  24488. this.lastValidTouch = {};
  24489. this.pinchDown = [];
  24490. this.runChartClick = false;
  24491. this.eventsToUnbind = [];
  24492. this.chart = chart;
  24493. this.hasDragged = false;
  24494. this.options = options;
  24495. this.init(chart, options);
  24496. }
  24497. /* *
  24498. *
  24499. * Functions
  24500. *
  24501. * */
  24502. /**
  24503. * Set inactive state to all series that are not currently hovered,
  24504. * or, if `inactiveOtherPoints` is set to true, set inactive state to
  24505. * all points within that series.
  24506. *
  24507. * @private
  24508. * @function Highcharts.Pointer#applyInactiveState
  24509. * @param {Array<Highcharts.Point>} points
  24510. * Currently hovered points
  24511. */
  24512. Pointer.prototype.applyInactiveState = function (points) {
  24513. var activeSeries = [],
  24514. series;
  24515. // Get all active series from the hovered points
  24516. (points || []).forEach(function (item) {
  24517. series = item.series;
  24518. // Include itself
  24519. activeSeries.push(series);
  24520. // Include parent series
  24521. if (series.linkedParent) {
  24522. activeSeries.push(series.linkedParent);
  24523. }
  24524. // Include all child series
  24525. if (series.linkedSeries) {
  24526. activeSeries = activeSeries.concat(series.linkedSeries);
  24527. }
  24528. // Include navigator series
  24529. if (series.navigatorSeries) {
  24530. activeSeries.push(series.navigatorSeries);
  24531. }
  24532. });
  24533. // Now loop over all series, filtering out active series
  24534. this.chart.series.forEach(function (inactiveSeries) {
  24535. if (activeSeries.indexOf(inactiveSeries) === -1) {
  24536. // Inactive series
  24537. inactiveSeries.setState('inactive', true);
  24538. }
  24539. else if (inactiveSeries.options.inactiveOtherPoints) {
  24540. // Active series, but other points should be inactivated
  24541. inactiveSeries.setAllPointsToState('inactive');
  24542. }
  24543. });
  24544. };
  24545. /**
  24546. * Destroys the Pointer object and disconnects DOM events.
  24547. *
  24548. * @function Highcharts.Pointer#destroy
  24549. */
  24550. Pointer.prototype.destroy = function () {
  24551. var pointer = this;
  24552. this.eventsToUnbind.forEach(function (unbind) { return unbind(); });
  24553. this.eventsToUnbind = [];
  24554. if (!H.chartCount) {
  24555. if (H.unbindDocumentMouseUp) {
  24556. H.unbindDocumentMouseUp = H.unbindDocumentMouseUp();
  24557. }
  24558. if (H.unbindDocumentTouchEnd) {
  24559. H.unbindDocumentTouchEnd = H.unbindDocumentTouchEnd();
  24560. }
  24561. }
  24562. // memory and CPU leak
  24563. clearInterval(pointer.tooltipTimeout);
  24564. objectEach(pointer, function (_val, prop) {
  24565. pointer[prop] = void 0;
  24566. });
  24567. };
  24568. /**
  24569. * Perform a drag operation in response to a mousemove event while the mouse
  24570. * is down.
  24571. *
  24572. * @private
  24573. * @function Highcharts.Pointer#drag
  24574. */
  24575. Pointer.prototype.drag = function (e) {
  24576. var chart = this.chart,
  24577. chartOptions = chart.options.chart,
  24578. chartX = e.chartX,
  24579. chartY = e.chartY,
  24580. zoomHor = this.zoomHor,
  24581. zoomVert = this.zoomVert,
  24582. plotLeft = chart.plotLeft,
  24583. plotTop = chart.plotTop,
  24584. plotWidth = chart.plotWidth,
  24585. plotHeight = chart.plotHeight,
  24586. clickedInside,
  24587. size,
  24588. selectionMarker = this.selectionMarker,
  24589. mouseDownX = (this.mouseDownX || 0),
  24590. mouseDownY = (this.mouseDownY || 0),
  24591. panningEnabled = isObject(chartOptions.panning) ?
  24592. chartOptions.panning && chartOptions.panning.enabled :
  24593. chartOptions.panning,
  24594. panKey = (chartOptions.panKey && e[chartOptions.panKey + 'Key']);
  24595. // If the device supports both touch and mouse (like IE11), and we are
  24596. // touch-dragging inside the plot area, don't handle the mouse event.
  24597. // #4339.
  24598. if (selectionMarker && selectionMarker.touch) {
  24599. return;
  24600. }
  24601. // If the mouse is outside the plot area, adjust to cooordinates
  24602. // inside to prevent the selection marker from going outside
  24603. if (chartX < plotLeft) {
  24604. chartX = plotLeft;
  24605. }
  24606. else if (chartX > plotLeft + plotWidth) {
  24607. chartX = plotLeft + plotWidth;
  24608. }
  24609. if (chartY < plotTop) {
  24610. chartY = plotTop;
  24611. }
  24612. else if (chartY > plotTop + plotHeight) {
  24613. chartY = plotTop + plotHeight;
  24614. }
  24615. // determine if the mouse has moved more than 10px
  24616. this.hasDragged = Math.sqrt(Math.pow(mouseDownX - chartX, 2) +
  24617. Math.pow(mouseDownY - chartY, 2));
  24618. if (this.hasDragged > 10) {
  24619. clickedInside = chart.isInsidePlot(mouseDownX - plotLeft, mouseDownY - plotTop, {
  24620. visiblePlotOnly: true
  24621. });
  24622. // make a selection
  24623. if (chart.hasCartesianSeries &&
  24624. (this.zoomX || this.zoomY) &&
  24625. clickedInside &&
  24626. !panKey) {
  24627. if (!selectionMarker) {
  24628. this.selectionMarker = selectionMarker =
  24629. chart.renderer.rect(plotLeft, plotTop, zoomHor ? 1 : plotWidth, zoomVert ? 1 : plotHeight, 0)
  24630. .attr({
  24631. 'class': 'highcharts-selection-marker',
  24632. zIndex: 7
  24633. })
  24634. .add();
  24635. if (!chart.styledMode) {
  24636. selectionMarker.attr({
  24637. fill: (chartOptions.selectionMarkerFill ||
  24638. color(palette.highlightColor80)
  24639. .setOpacity(0.25).get())
  24640. });
  24641. }
  24642. }
  24643. }
  24644. // adjust the width of the selection marker
  24645. if (selectionMarker && zoomHor) {
  24646. size = chartX - mouseDownX;
  24647. selectionMarker.attr({
  24648. width: Math.abs(size),
  24649. x: (size > 0 ? 0 : size) + mouseDownX
  24650. });
  24651. }
  24652. // adjust the height of the selection marker
  24653. if (selectionMarker && zoomVert) {
  24654. size = chartY - mouseDownY;
  24655. selectionMarker.attr({
  24656. height: Math.abs(size),
  24657. y: (size > 0 ? 0 : size) + mouseDownY
  24658. });
  24659. }
  24660. // panning
  24661. if (clickedInside &&
  24662. !selectionMarker &&
  24663. panningEnabled) {
  24664. chart.pan(e, chartOptions.panning);
  24665. }
  24666. }
  24667. };
  24668. /**
  24669. * Start a drag operation.
  24670. *
  24671. * @private
  24672. * @function Highcharts.Pointer#dragStart
  24673. */
  24674. Pointer.prototype.dragStart = function (e) {
  24675. var chart = this.chart;
  24676. // Record the start position
  24677. chart.mouseIsDown = e.type;
  24678. chart.cancelClick = false;
  24679. chart.mouseDownX = this.mouseDownX = e.chartX;
  24680. chart.mouseDownY = this.mouseDownY = e.chartY;
  24681. };
  24682. /**
  24683. * On mouse up or touch end across the entire document, drop the selection.
  24684. *
  24685. * @private
  24686. * @function Highcharts.Pointer#drop
  24687. *
  24688. * @param {global.Event} e
  24689. */
  24690. Pointer.prototype.drop = function (e) {
  24691. var pointer = this,
  24692. chart = this.chart,
  24693. hasPinched = this.hasPinched;
  24694. if (this.selectionMarker) {
  24695. var selectionData_1 = {
  24696. originalEvent: e,
  24697. xAxis: [],
  24698. yAxis: []
  24699. },
  24700. selectionBox = this.selectionMarker,
  24701. selectionLeft_1 = selectionBox.attr ?
  24702. selectionBox.attr('x') :
  24703. selectionBox.x,
  24704. selectionTop_1 = selectionBox.attr ?
  24705. selectionBox.attr('y') :
  24706. selectionBox.y,
  24707. selectionWidth_1 = selectionBox.attr ?
  24708. selectionBox.attr('width') :
  24709. selectionBox.width,
  24710. selectionHeight_1 = selectionBox.attr ?
  24711. selectionBox.attr('height') :
  24712. selectionBox.height,
  24713. runZoom_1;
  24714. // a selection has been made
  24715. if (this.hasDragged || hasPinched) {
  24716. // record each axis' min and max
  24717. chart.axes.forEach(function (axis) {
  24718. if (axis.zoomEnabled &&
  24719. defined(axis.min) &&
  24720. (hasPinched ||
  24721. pointer[{
  24722. xAxis: 'zoomX',
  24723. yAxis: 'zoomY'
  24724. }[axis.coll]]) &&
  24725. isNumber(selectionLeft_1) &&
  24726. isNumber(selectionTop_1)) { // #859, #3569
  24727. var horiz = axis.horiz,
  24728. minPixelPadding = e.type === 'touchend' ?
  24729. axis.minPixelPadding :
  24730. 0, // #1207, #3075
  24731. selectionMin = axis.toValue((horiz ? selectionLeft_1 : selectionTop_1) +
  24732. minPixelPadding),
  24733. selectionMax = axis.toValue((horiz ?
  24734. selectionLeft_1 + selectionWidth_1 :
  24735. selectionTop_1 + selectionHeight_1) - minPixelPadding);
  24736. selectionData_1[axis.coll].push({
  24737. axis: axis,
  24738. // Min/max for reversed axes
  24739. min: Math.min(selectionMin, selectionMax),
  24740. max: Math.max(selectionMin, selectionMax)
  24741. });
  24742. runZoom_1 = true;
  24743. }
  24744. });
  24745. if (runZoom_1) {
  24746. fireEvent(chart, 'selection', selectionData_1, function (args) {
  24747. chart.zoom(extend(args, hasPinched ?
  24748. { animation: false } :
  24749. null));
  24750. });
  24751. }
  24752. }
  24753. if (isNumber(chart.index)) {
  24754. this.selectionMarker = this.selectionMarker.destroy();
  24755. }
  24756. // Reset scaling preview
  24757. if (hasPinched) {
  24758. this.scaleGroups();
  24759. }
  24760. }
  24761. // Reset all. Check isNumber because it may be destroyed on mouse up
  24762. // (#877)
  24763. if (chart && isNumber(chart.index)) {
  24764. css(chart.container, { cursor: chart._cursor });
  24765. chart.cancelClick = this.hasDragged > 10; // #370
  24766. chart.mouseIsDown = this.hasDragged = this.hasPinched = false;
  24767. this.pinchDown = [];
  24768. }
  24769. };
  24770. /**
  24771. * Finds the closest point to a set of coordinates, using the k-d-tree
  24772. * algorithm.
  24773. *
  24774. * @function Highcharts.Pointer#findNearestKDPoint
  24775. *
  24776. * @param {Array<Highcharts.Series>} series
  24777. * All the series to search in.
  24778. *
  24779. * @param {boolean|undefined} shared
  24780. * Whether it is a shared tooltip or not.
  24781. *
  24782. * @param {Highcharts.PointerEventObject} e
  24783. * The pointer event object, containing chart coordinates of the
  24784. * pointer.
  24785. *
  24786. * @return {Highcharts.Point|undefined}
  24787. * The point closest to given coordinates.
  24788. */
  24789. Pointer.prototype.findNearestKDPoint = function (series, shared, e) {
  24790. var chart = this.chart;
  24791. var hoverPoint = chart.hoverPoint;
  24792. var tooltip = chart.tooltip;
  24793. if (hoverPoint &&
  24794. tooltip &&
  24795. tooltip.isStickyOnContact()) {
  24796. return hoverPoint;
  24797. }
  24798. var closest;
  24799. /** @private */
  24800. function sort(p1, p2) {
  24801. var isCloserX = p1.distX - p2.distX,
  24802. isCloser = p1.dist - p2.dist,
  24803. isAbove = (p2.series.group && p2.series.group.zIndex) -
  24804. (p1.series.group && p1.series.group.zIndex),
  24805. result;
  24806. // We have two points which are not in the same place on xAxis
  24807. // and shared tooltip:
  24808. if (isCloserX !== 0 && shared) { // #5721
  24809. result = isCloserX;
  24810. // Points are not exactly in the same place on x/yAxis:
  24811. }
  24812. else if (isCloser !== 0) {
  24813. result = isCloser;
  24814. // The same xAxis and yAxis position, sort by z-index:
  24815. }
  24816. else if (isAbove !== 0) {
  24817. result = isAbove;
  24818. // The same zIndex, sort by array index:
  24819. }
  24820. else {
  24821. result =
  24822. p1.series.index > p2.series.index ?
  24823. -1 :
  24824. 1;
  24825. }
  24826. return result;
  24827. }
  24828. series.forEach(function (s) {
  24829. var noSharedTooltip = s.noSharedTooltip && shared,
  24830. compareX = (!noSharedTooltip &&
  24831. s.options.findNearestPointBy.indexOf('y') < 0),
  24832. point = s.searchPoint(e,
  24833. compareX);
  24834. if ( // Check that we actually found a point on the series.
  24835. isObject(point, true) && point.series &&
  24836. // Use the new point if it is closer.
  24837. (!isObject(closest, true) ||
  24838. (sort(closest, point) > 0))) {
  24839. closest = point;
  24840. }
  24841. });
  24842. return closest;
  24843. };
  24844. /**
  24845. * @private
  24846. * @function Highcharts.Pointer#getChartCoordinatesFromPoint
  24847. * @param {Highcharts.Point} point
  24848. * @param {boolean} [inverted]
  24849. * @return {Highcharts.PointerCoordinatesObject|undefined}
  24850. */
  24851. Pointer.prototype.getChartCoordinatesFromPoint = function (point, inverted) {
  24852. var series = point.series,
  24853. xAxis = series.xAxis,
  24854. yAxis = series.yAxis,
  24855. shapeArgs = point.shapeArgs;
  24856. if (xAxis && yAxis) {
  24857. var x = pick(point.clientX,
  24858. point.plotX);
  24859. var y = point.plotY || 0;
  24860. if (point.isNode &&
  24861. shapeArgs &&
  24862. isNumber(shapeArgs.x) &&
  24863. isNumber(shapeArgs.y)) {
  24864. x = shapeArgs.x;
  24865. y = shapeArgs.y;
  24866. }
  24867. return inverted ? {
  24868. chartX: yAxis.len + yAxis.pos - y,
  24869. chartY: xAxis.len + xAxis.pos - x
  24870. } : {
  24871. chartX: x + xAxis.pos,
  24872. chartY: y + yAxis.pos
  24873. };
  24874. }
  24875. if (shapeArgs && shapeArgs.x && shapeArgs.y) {
  24876. // E.g. pies do not have axes
  24877. return {
  24878. chartX: shapeArgs.x,
  24879. chartY: shapeArgs.y
  24880. };
  24881. }
  24882. };
  24883. /**
  24884. * Return the cached chartPosition if it is available on the Pointer,
  24885. * otherwise find it. Running offset is quite expensive, so it should be
  24886. * avoided when we know the chart hasn't moved.
  24887. *
  24888. * @function Highcharts.Pointer#getChartPosition
  24889. *
  24890. * @return {Highcharts.ChartPositionObject}
  24891. * The offset of the chart container within the page
  24892. */
  24893. Pointer.prototype.getChartPosition = function () {
  24894. if (this.chartPosition) {
  24895. return this.chartPosition;
  24896. }
  24897. var container = this.chart.container;
  24898. var pos = offset(container);
  24899. this.chartPosition = {
  24900. left: pos.left,
  24901. top: pos.top,
  24902. scaleX: 1,
  24903. scaleY: 1
  24904. };
  24905. var offsetWidth = container.offsetWidth;
  24906. var offsetHeight = container.offsetHeight;
  24907. // #13342 - tooltip was not visible in Chrome, when chart
  24908. // updates height.
  24909. if (offsetWidth > 2 && // #13342
  24910. offsetHeight > 2 // #13342
  24911. ) {
  24912. this.chartPosition.scaleX = pos.width / offsetWidth;
  24913. this.chartPosition.scaleY = pos.height / offsetHeight;
  24914. }
  24915. return this.chartPosition;
  24916. };
  24917. /**
  24918. * Get the click position in terms of axis values.
  24919. *
  24920. * @function Highcharts.Pointer#getCoordinates
  24921. *
  24922. * @param {Highcharts.PointerEventObject} e
  24923. * Pointer event, extended with `chartX` and `chartY` properties.
  24924. *
  24925. * @return {Highcharts.PointerAxisCoordinatesObject}
  24926. */
  24927. Pointer.prototype.getCoordinates = function (e) {
  24928. var coordinates = {
  24929. xAxis: [],
  24930. yAxis: []
  24931. };
  24932. this.chart.axes.forEach(function (axis) {
  24933. coordinates[axis.isXAxis ? 'xAxis' : 'yAxis'].push({
  24934. axis: axis,
  24935. value: axis.toValue(e[axis.horiz ? 'chartX' : 'chartY'])
  24936. });
  24937. });
  24938. return coordinates;
  24939. };
  24940. /**
  24941. * Calculates what is the current hovered point/points and series.
  24942. *
  24943. * @private
  24944. * @function Highcharts.Pointer#getHoverData
  24945. *
  24946. * @param {Highcharts.Point|undefined} existingHoverPoint
  24947. * The point currrently beeing hovered.
  24948. *
  24949. * @param {Highcharts.Series|undefined} existingHoverSeries
  24950. * The series currently beeing hovered.
  24951. *
  24952. * @param {Array<Highcharts.Series>} series
  24953. * All the series in the chart.
  24954. *
  24955. * @param {boolean} isDirectTouch
  24956. * Is the pointer directly hovering the point.
  24957. *
  24958. * @param {boolean|undefined} shared
  24959. * Whether it is a shared tooltip or not.
  24960. *
  24961. * @param {Highcharts.PointerEventObject} [e]
  24962. * The triggering event, containing chart coordinates of the pointer.
  24963. *
  24964. * @return {object}
  24965. * Object containing resulting hover data: hoverPoint, hoverSeries,
  24966. * and hoverPoints.
  24967. */
  24968. Pointer.prototype.getHoverData = function (existingHoverPoint, existingHoverSeries, series, isDirectTouch, shared, e) {
  24969. var hoverPoint,
  24970. hoverPoints = [],
  24971. hoverSeries = existingHoverSeries,
  24972. useExisting = !!(isDirectTouch && existingHoverPoint),
  24973. notSticky = hoverSeries && !hoverSeries.stickyTracking,
  24974. // Which series to look in for the hover point
  24975. searchSeries,
  24976. // Parameters needed for beforeGetHoverData event.
  24977. eventArgs = {
  24978. chartX: e ? e.chartX : void 0,
  24979. chartY: e ? e.chartY : void 0,
  24980. shared: shared
  24981. },
  24982. filter = function (s) {
  24983. return (s.visible &&
  24984. !(!shared && s.directTouch) && // #3821
  24985. pick(s.options.enableMouseTracking,
  24986. true));
  24987. };
  24988. // Find chart.hoverPane and update filter method in polar.
  24989. fireEvent(this, 'beforeGetHoverData', eventArgs);
  24990. searchSeries = notSticky ?
  24991. // Only search on hovered series if it has stickyTracking false
  24992. [hoverSeries] :
  24993. // Filter what series to look in.
  24994. series.filter(function (s) {
  24995. return eventArgs.filter ? eventArgs.filter(s) : filter(s) &&
  24996. s.stickyTracking;
  24997. });
  24998. // Use existing hovered point or find the one closest to coordinates.
  24999. hoverPoint = useExisting || !e ?
  25000. existingHoverPoint :
  25001. this.findNearestKDPoint(searchSeries, shared, e);
  25002. // Assign hover series
  25003. hoverSeries = hoverPoint && hoverPoint.series;
  25004. // If we have a hoverPoint, assign hoverPoints.
  25005. if (hoverPoint) {
  25006. // When tooltip is shared, it displays more than one point
  25007. if (shared && !hoverSeries.noSharedTooltip) {
  25008. searchSeries = series.filter(function (s) {
  25009. return eventArgs.filter ?
  25010. eventArgs.filter(s) : filter(s) && !s.noSharedTooltip;
  25011. });
  25012. // Get all points with the same x value as the hoverPoint
  25013. searchSeries.forEach(function (s) {
  25014. var point = find(s.points,
  25015. function (p) {
  25016. return p.x === hoverPoint.x && !p.isNull;
  25017. });
  25018. if (isObject(point)) {
  25019. /*
  25020. * Boost returns a minimal point. Convert it to a usable
  25021. * point for tooltip and states.
  25022. */
  25023. if (s.chart.isBoosting) {
  25024. point = s.getPoint(point);
  25025. }
  25026. hoverPoints.push(point);
  25027. }
  25028. });
  25029. }
  25030. else {
  25031. hoverPoints.push(hoverPoint);
  25032. }
  25033. }
  25034. // Check whether the hoverPoint is inside pane we are hovering over.
  25035. eventArgs = { hoverPoint: hoverPoint };
  25036. fireEvent(this, 'afterGetHoverData', eventArgs);
  25037. return {
  25038. hoverPoint: eventArgs.hoverPoint,
  25039. hoverSeries: hoverSeries,
  25040. hoverPoints: hoverPoints
  25041. };
  25042. };
  25043. /**
  25044. * @private
  25045. * @function Highcharts.Pointer#getPointFromEvent
  25046. *
  25047. * @param {global.Event} e
  25048. *
  25049. * @return {Highcharts.Point|undefined}
  25050. */
  25051. Pointer.prototype.getPointFromEvent = function (e) {
  25052. var target = e.target,
  25053. point;
  25054. while (target && !point) {
  25055. point = target.point;
  25056. target = target.parentNode;
  25057. }
  25058. return point;
  25059. };
  25060. /**
  25061. * @private
  25062. * @function Highcharts.Pointer#onTrackerMouseOut
  25063. */
  25064. Pointer.prototype.onTrackerMouseOut = function (e) {
  25065. var chart = this.chart;
  25066. var relatedTarget = e.relatedTarget || e.toElement;
  25067. var series = chart.hoverSeries;
  25068. this.isDirectTouch = false;
  25069. if (series &&
  25070. relatedTarget &&
  25071. !series.stickyTracking &&
  25072. !this.inClass(relatedTarget, 'highcharts-tooltip') &&
  25073. (!this.inClass(relatedTarget, 'highcharts-series-' + series.index) || // #2499, #4465, #5553
  25074. !this.inClass(relatedTarget, 'highcharts-tracker'))) {
  25075. series.onMouseOut();
  25076. }
  25077. };
  25078. /**
  25079. * Utility to detect whether an element has, or has a parent with, a
  25080. * specificclass name. Used on detection of tracker objects and on deciding
  25081. * whether hovering the tooltip should cause the active series to mouse out.
  25082. *
  25083. * @function Highcharts.Pointer#inClass
  25084. *
  25085. * @param {Highcharts.SVGDOMElement|Highcharts.HTMLDOMElement} element
  25086. * The element to investigate.
  25087. *
  25088. * @param {string} className
  25089. * The class name to look for.
  25090. *
  25091. * @return {boolean|undefined}
  25092. * True if either the element or one of its parents has the given
  25093. * class name.
  25094. */
  25095. Pointer.prototype.inClass = function (element, className) {
  25096. var elemClassName;
  25097. while (element) {
  25098. elemClassName = attr(element, 'class');
  25099. if (elemClassName) {
  25100. if (elemClassName.indexOf(className) !== -1) {
  25101. return true;
  25102. }
  25103. if (elemClassName.indexOf('highcharts-container') !== -1) {
  25104. return false;
  25105. }
  25106. }
  25107. element = element.parentNode;
  25108. }
  25109. };
  25110. /**
  25111. * Initialize the Pointer.
  25112. *
  25113. * @private
  25114. * @function Highcharts.Pointer#init
  25115. *
  25116. * @param {Highcharts.Chart} chart
  25117. * The Chart instance.
  25118. *
  25119. * @param {Highcharts.Options} options
  25120. * The root options object. The pointer uses options from the chart
  25121. * and tooltip structures.
  25122. *
  25123. * @return {void}
  25124. */
  25125. Pointer.prototype.init = function (chart, options) {
  25126. // Store references
  25127. this.options = options;
  25128. this.chart = chart;
  25129. // Do we need to handle click on a touch device?
  25130. this.runChartClick = Boolean(options.chart.events && options.chart.events.click);
  25131. this.pinchDown = [];
  25132. this.lastValidTouch = {};
  25133. if (Tooltip) {
  25134. /**
  25135. * Tooltip object for points of series.
  25136. *
  25137. * @name Highcharts.Chart#tooltip
  25138. * @type {Highcharts.Tooltip}
  25139. */
  25140. chart.tooltip = new Tooltip(chart, options.tooltip);
  25141. this.followTouchMove = pick(options.tooltip.followTouchMove, true);
  25142. }
  25143. this.setDOMEvents();
  25144. };
  25145. /**
  25146. * Takes a browser event object and extends it with custom Highcharts
  25147. * properties `chartX` and `chartY` in order to work on the internal
  25148. * coordinate system.
  25149. *
  25150. * @function Highcharts.Pointer#normalize
  25151. *
  25152. * @param {global.MouseEvent|global.PointerEvent|global.TouchEvent} e
  25153. * Event object in standard browsers.
  25154. *
  25155. * @param {Highcharts.OffsetObject} [chartPosition]
  25156. * Additional chart offset.
  25157. *
  25158. * @return {Highcharts.PointerEventObject}
  25159. * A browser event with extended properties `chartX` and `chartY`.
  25160. */
  25161. Pointer.prototype.normalize = function (e, chartPosition) {
  25162. var touches = e.touches;
  25163. // iOS (#2757)
  25164. var ePos = (touches ?
  25165. touches.length ?
  25166. touches.item(0) :
  25167. (pick(// #13534
  25168. touches.changedTouches,
  25169. e.changedTouches))[0] :
  25170. e);
  25171. // Get mouse position
  25172. if (!chartPosition) {
  25173. chartPosition = this.getChartPosition();
  25174. }
  25175. var chartX = ePos.pageX - chartPosition.left,
  25176. chartY = ePos.pageY - chartPosition.top;
  25177. // #11329 - when there is scaling on a parent element, we need to take
  25178. // this into account
  25179. chartX /= chartPosition.scaleX;
  25180. chartY /= chartPosition.scaleY;
  25181. return extend(e, {
  25182. chartX: Math.round(chartX),
  25183. chartY: Math.round(chartY)
  25184. });
  25185. };
  25186. /**
  25187. * @private
  25188. * @function Highcharts.Pointer#onContainerClick
  25189. */
  25190. Pointer.prototype.onContainerClick = function (e) {
  25191. var chart = this.chart;
  25192. var hoverPoint = chart.hoverPoint;
  25193. var pEvt = this.normalize(e);
  25194. var plotLeft = chart.plotLeft;
  25195. var plotTop = chart.plotTop;
  25196. if (!chart.cancelClick) {
  25197. // On tracker click, fire the series and point events. #783, #1583
  25198. if (hoverPoint &&
  25199. this.inClass(pEvt.target, 'highcharts-tracker')) {
  25200. // the series click event
  25201. fireEvent(hoverPoint.series, 'click', extend(pEvt, {
  25202. point: hoverPoint
  25203. }));
  25204. // the point click event
  25205. if (chart.hoverPoint) { // it may be destroyed (#1844)
  25206. hoverPoint.firePointEvent('click', pEvt);
  25207. }
  25208. // When clicking outside a tracker, fire a chart event
  25209. }
  25210. else {
  25211. extend(pEvt, this.getCoordinates(pEvt));
  25212. // fire a click event in the chart
  25213. if (chart.isInsidePlot(pEvt.chartX - plotLeft, pEvt.chartY - plotTop, {
  25214. visiblePlotOnly: true
  25215. })) {
  25216. fireEvent(chart, 'click', pEvt);
  25217. }
  25218. }
  25219. }
  25220. };
  25221. /**
  25222. * @private
  25223. * @function Highcharts.Pointer#onContainerMouseDown
  25224. *
  25225. * @param {global.MouseEvent} e
  25226. */
  25227. Pointer.prototype.onContainerMouseDown = function (e) {
  25228. var isPrimaryButton = ((e.buttons || e.button) & 1) === 1;
  25229. // Normalize before the 'if' for the legacy IE (#7850)
  25230. e = this.normalize(e);
  25231. // #11635, Firefox does not reliable fire move event after click scroll
  25232. if (H.isFirefox &&
  25233. e.button !== 0) {
  25234. this.onContainerMouseMove(e);
  25235. }
  25236. // #11635, limiting to primary button (incl. IE 8 support)
  25237. if (typeof e.button === 'undefined' ||
  25238. isPrimaryButton) {
  25239. this.zoomOption(e);
  25240. // #295, #13737 solve conflict between container drag and chart zoom
  25241. if (isPrimaryButton &&
  25242. e.preventDefault) {
  25243. e.preventDefault();
  25244. }
  25245. this.dragStart(e);
  25246. }
  25247. };
  25248. /**
  25249. * When mouse leaves the container, hide the tooltip.
  25250. *
  25251. * @private
  25252. * @function Highcharts.Pointer#onContainerMouseLeave
  25253. *
  25254. * @param {global.MouseEvent} e
  25255. *
  25256. * @return {void}
  25257. */
  25258. Pointer.prototype.onContainerMouseLeave = function (e) {
  25259. var chart = charts[pick(H.hoverChartIndex, -1)];
  25260. var tooltip = this.chart.tooltip;
  25261. e = this.normalize(e);
  25262. // #4886, MS Touch end fires mouseleave but with no related target
  25263. if (chart &&
  25264. (e.relatedTarget || e.toElement)) {
  25265. chart.pointer.reset();
  25266. // Also reset the chart position, used in #149 fix
  25267. chart.pointer.chartPosition = void 0;
  25268. }
  25269. if ( // #11635, Firefox wheel scroll does not fire out events consistently
  25270. tooltip &&
  25271. !tooltip.isHidden) {
  25272. this.reset();
  25273. }
  25274. };
  25275. /**
  25276. * When mouse enters the container, delete pointer's chartPosition.
  25277. *
  25278. * @private
  25279. * @function Highcharts.Pointer#onContainerMouseEnter
  25280. *
  25281. * @param {global.MouseEvent} e
  25282. *
  25283. * @return {void}
  25284. */
  25285. Pointer.prototype.onContainerMouseEnter = function (e) {
  25286. delete this.chartPosition;
  25287. };
  25288. /**
  25289. * The mousemove, touchmove and touchstart event handler
  25290. *
  25291. * @private
  25292. * @function Highcharts.Pointer#onContainerMouseMove
  25293. *
  25294. * @param {global.MouseEvent} e
  25295. *
  25296. * @return {void}
  25297. */
  25298. Pointer.prototype.onContainerMouseMove = function (e) {
  25299. var chart = this.chart;
  25300. var pEvt = this.normalize(e);
  25301. this.setHoverChartIndex();
  25302. // In IE8 we apparently need this returnValue set to false in order to
  25303. // avoid text being selected. But in Chrome, e.returnValue is prevented,
  25304. // plus we don't need to run e.preventDefault to prevent selected text
  25305. // in modern browsers. So we set it conditionally. Remove it when IE8 is
  25306. // no longer needed. #2251, #3224.
  25307. if (!pEvt.preventDefault) {
  25308. pEvt.returnValue = false;
  25309. }
  25310. if (chart.mouseIsDown === 'mousedown' || this.touchSelect(pEvt)) {
  25311. this.drag(pEvt);
  25312. }
  25313. // Show the tooltip and run mouse over events (#977)
  25314. if (!chart.openMenu &&
  25315. (this.inClass(pEvt.target, 'highcharts-tracker') ||
  25316. chart.isInsidePlot(pEvt.chartX - chart.plotLeft, pEvt.chartY - chart.plotTop, {
  25317. visiblePlotOnly: true
  25318. }))) {
  25319. this.runPointActions(pEvt);
  25320. }
  25321. };
  25322. /**
  25323. * @private
  25324. * @function Highcharts.Pointer#onDocumentTouchEnd
  25325. *
  25326. * @param {Highcharts.PointerEventObject} e
  25327. *
  25328. * @return {void}
  25329. */
  25330. Pointer.prototype.onDocumentTouchEnd = function (e) {
  25331. if (charts[H.hoverChartIndex]) {
  25332. charts[H.hoverChartIndex].pointer.drop(e);
  25333. }
  25334. };
  25335. /**
  25336. * @private
  25337. * @function Highcharts.Pointer#onContainerTouchMove
  25338. *
  25339. * @param {Highcharts.PointerEventObject} e
  25340. *
  25341. * @return {void}
  25342. */
  25343. Pointer.prototype.onContainerTouchMove = function (e) {
  25344. if (this.touchSelect(e)) {
  25345. this.onContainerMouseMove(e);
  25346. }
  25347. else {
  25348. this.touch(e);
  25349. }
  25350. };
  25351. /**
  25352. * @private
  25353. * @function Highcharts.Pointer#onContainerTouchStart
  25354. *
  25355. * @param {Highcharts.PointerEventObject} e
  25356. *
  25357. * @return {void}
  25358. */
  25359. Pointer.prototype.onContainerTouchStart = function (e) {
  25360. if (this.touchSelect(e)) {
  25361. this.onContainerMouseDown(e);
  25362. }
  25363. else {
  25364. this.zoomOption(e);
  25365. this.touch(e, true);
  25366. }
  25367. };
  25368. /**
  25369. * Special handler for mouse move that will hide the tooltip when the mouse
  25370. * leaves the plotarea. Issue #149 workaround. The mouseleave event does not
  25371. * always fire.
  25372. *
  25373. * @private
  25374. * @function Highcharts.Pointer#onDocumentMouseMove
  25375. *
  25376. * @param {global.MouseEvent} e
  25377. *
  25378. * @return {void}
  25379. */
  25380. Pointer.prototype.onDocumentMouseMove = function (e) {
  25381. var chart = this.chart;
  25382. var chartPosition = this.chartPosition;
  25383. var pEvt = this.normalize(e,
  25384. chartPosition);
  25385. var tooltip = chart.tooltip;
  25386. // If we're outside, hide the tooltip
  25387. if (chartPosition &&
  25388. (!tooltip ||
  25389. !tooltip.isStickyOnContact()) &&
  25390. !chart.isInsidePlot(pEvt.chartX - chart.plotLeft, pEvt.chartY - chart.plotTop, {
  25391. visiblePlotOnly: true
  25392. }) &&
  25393. !this.inClass(pEvt.target, 'highcharts-tracker')) {
  25394. this.reset();
  25395. }
  25396. };
  25397. /**
  25398. * @private
  25399. * @function Highcharts.Pointer#onDocumentMouseUp
  25400. *
  25401. * @param {global.MouseEvent} e
  25402. *
  25403. * @return {void}
  25404. */
  25405. Pointer.prototype.onDocumentMouseUp = function (e) {
  25406. var chart = charts[pick(H.hoverChartIndex, -1)];
  25407. if (chart) {
  25408. chart.pointer.drop(e);
  25409. }
  25410. };
  25411. /**
  25412. * Handle touch events with two touches
  25413. *
  25414. * @private
  25415. * @function Highcharts.Pointer#pinch
  25416. *
  25417. * @param {Highcharts.PointerEventObject} e
  25418. *
  25419. * @return {void}
  25420. */
  25421. Pointer.prototype.pinch = function (e) {
  25422. var self = this,
  25423. chart = self.chart,
  25424. pinchDown = self.pinchDown,
  25425. touches = (e.touches || []),
  25426. touchesLength = touches.length,
  25427. lastValidTouch = self.lastValidTouch,
  25428. hasZoom = self.hasZoom,
  25429. selectionMarker = self.selectionMarker,
  25430. transform = {},
  25431. fireClickEvent = touchesLength === 1 && ((self.inClass(e.target, 'highcharts-tracker') &&
  25432. chart.runTrackerClick) ||
  25433. self.runChartClick),
  25434. clip = {};
  25435. // Don't initiate panning until the user has pinched. This prevents us
  25436. // from blocking page scrolling as users scroll down a long page
  25437. // (#4210).
  25438. if (touchesLength > 1) {
  25439. self.initiated = true;
  25440. }
  25441. // On touch devices, only proceed to trigger click if a handler is
  25442. // defined
  25443. if (hasZoom && self.initiated && !fireClickEvent && e.cancelable !== false) {
  25444. e.preventDefault();
  25445. }
  25446. // Normalize each touch
  25447. [].map.call(touches, function (e) {
  25448. return self.normalize(e);
  25449. });
  25450. // Register the touch start position
  25451. if (e.type === 'touchstart') {
  25452. [].forEach.call(touches, function (e, i) {
  25453. pinchDown[i] = { chartX: e.chartX, chartY: e.chartY };
  25454. });
  25455. lastValidTouch.x = [pinchDown[0].chartX, pinchDown[1] &&
  25456. pinchDown[1].chartX];
  25457. lastValidTouch.y = [pinchDown[0].chartY, pinchDown[1] &&
  25458. pinchDown[1].chartY];
  25459. // Identify the data bounds in pixels
  25460. chart.axes.forEach(function (axis) {
  25461. if (axis.zoomEnabled) {
  25462. var bounds = chart.bounds[axis.horiz ? 'h' : 'v'],
  25463. minPixelPadding = axis.minPixelPadding,
  25464. min = axis.toPixels(Math.min(pick(axis.options.min,
  25465. axis.dataMin),
  25466. axis.dataMin)),
  25467. max = axis.toPixels(Math.max(pick(axis.options.max,
  25468. axis.dataMax),
  25469. axis.dataMax)),
  25470. absMin = Math.min(min,
  25471. max),
  25472. absMax = Math.max(min,
  25473. max);
  25474. // Store the bounds for use in the touchmove handler
  25475. bounds.min = Math.min(axis.pos, absMin - minPixelPadding);
  25476. bounds.max = Math.max(axis.pos + axis.len, absMax + minPixelPadding);
  25477. }
  25478. });
  25479. self.res = true; // reset on next move
  25480. // Optionally move the tooltip on touchmove
  25481. }
  25482. else if (self.followTouchMove && touchesLength === 1) {
  25483. this.runPointActions(self.normalize(e));
  25484. // Event type is touchmove, handle panning and pinching
  25485. }
  25486. else if (pinchDown.length) { // can be 0 when releasing, if touchend
  25487. // fires first
  25488. // Set the marker
  25489. if (!selectionMarker) {
  25490. // @todo It's a mock object, so maybe we need a separate
  25491. // interface
  25492. self.selectionMarker = selectionMarker = extend({
  25493. destroy: noop,
  25494. touch: true
  25495. }, chart.plotBox);
  25496. }
  25497. self.pinchTranslate(pinchDown, touches, transform, selectionMarker, clip, lastValidTouch);
  25498. self.hasPinched = hasZoom;
  25499. // Scale and translate the groups to provide visual feedback during
  25500. // pinching
  25501. self.scaleGroups(transform, clip);
  25502. if (self.res) {
  25503. self.res = false;
  25504. this.reset(false, 0);
  25505. }
  25506. }
  25507. };
  25508. /**
  25509. * Run translation operations
  25510. *
  25511. * @private
  25512. * @function Highcharts.Pointer#pinchTranslate
  25513. *
  25514. * @param {Array<*>} pinchDown
  25515. *
  25516. * @param {Array<Highcharts.PointerEventObject>} touches
  25517. *
  25518. * @param {*} transform
  25519. *
  25520. * @param {*} selectionMarker
  25521. *
  25522. * @param {*} clip
  25523. *
  25524. * @param {*} lastValidTouch
  25525. *
  25526. * @return {void}
  25527. */
  25528. Pointer.prototype.pinchTranslate = function (pinchDown, touches, transform, selectionMarker, clip, lastValidTouch) {
  25529. if (this.zoomHor) {
  25530. this.pinchTranslateDirection(true, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch);
  25531. }
  25532. if (this.zoomVert) {
  25533. this.pinchTranslateDirection(false, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch);
  25534. }
  25535. };
  25536. /**
  25537. * Run translation operations for each direction (horizontal and vertical)
  25538. * independently.
  25539. *
  25540. * @private
  25541. * @function Highcharts.Pointer#pinchTranslateDirection
  25542. *
  25543. * @param {boolean} horiz
  25544. *
  25545. * @param {Array<*>} pinchDown
  25546. *
  25547. * @param {Array<Highcharts.PointerEventObject>} touches
  25548. *
  25549. * @param {*} transform
  25550. *
  25551. * @param {*} selectionMarker
  25552. *
  25553. * @param {*} clip
  25554. *
  25555. * @param {*} lastValidTouch
  25556. *
  25557. * @param {number|undefined} [forcedScale=1]
  25558. *
  25559. * @return {void}
  25560. */
  25561. Pointer.prototype.pinchTranslateDirection = function (horiz, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch, forcedScale) {
  25562. var chart = this.chart, xy = horiz ? 'x' : 'y', XY = horiz ? 'X' : 'Y', sChartXY = ('chart' + XY), wh = horiz ? 'width' : 'height', plotLeftTop = chart['plot' + (horiz ? 'Left' : 'Top')], selectionWH, selectionXY, clipXY, scale = forcedScale || 1, inverted = chart.inverted, bounds = chart.bounds[horiz ? 'h' : 'v'], singleTouch = pinchDown.length === 1, touch0Start = pinchDown[0][sChartXY], touch0Now = touches[0][sChartXY], touch1Start = !singleTouch && pinchDown[1][sChartXY], touch1Now = !singleTouch && touches[1][sChartXY], outOfBounds, transformScale, scaleKey, setScale = function () {
  25563. // Don't zoom if fingers are too close on this axis
  25564. if (typeof touch1Now === 'number' &&
  25565. Math.abs(touch0Start - touch1Start) > 20) {
  25566. scale = forcedScale ||
  25567. Math.abs(touch0Now - touch1Now) /
  25568. Math.abs(touch0Start - touch1Start);
  25569. }
  25570. clipXY = ((plotLeftTop - touch0Now) / scale) + touch0Start;
  25571. selectionWH = chart['plot' + (horiz ? 'Width' : 'Height')] / scale;
  25572. };
  25573. // Set the scale, first pass
  25574. setScale();
  25575. // The clip position (x or y) is altered if out of bounds, the selection
  25576. // position is not
  25577. selectionXY = clipXY;
  25578. // Out of bounds
  25579. if (selectionXY < bounds.min) {
  25580. selectionXY = bounds.min;
  25581. outOfBounds = true;
  25582. }
  25583. else if (selectionXY + selectionWH > bounds.max) {
  25584. selectionXY = bounds.max - selectionWH;
  25585. outOfBounds = true;
  25586. }
  25587. // Is the chart dragged off its bounds, determined by dataMin and
  25588. // dataMax?
  25589. if (outOfBounds) {
  25590. // Modify the touchNow position in order to create an elastic drag
  25591. // movement. This indicates to the user that the chart is responsive
  25592. // but can't be dragged further.
  25593. touch0Now -= 0.8 * (touch0Now - lastValidTouch[xy][0]);
  25594. if (typeof touch1Now === 'number') {
  25595. touch1Now -= 0.8 * (touch1Now - lastValidTouch[xy][1]);
  25596. }
  25597. // Set the scale, second pass to adapt to the modified touchNow
  25598. // positions
  25599. setScale();
  25600. }
  25601. else {
  25602. lastValidTouch[xy] = [touch0Now, touch1Now];
  25603. }
  25604. // Set geometry for clipping, selection and transformation
  25605. if (!inverted) {
  25606. clip[xy] = clipXY - plotLeftTop;
  25607. clip[wh] = selectionWH;
  25608. }
  25609. scaleKey = inverted ? (horiz ? 'scaleY' : 'scaleX') : 'scale' + XY;
  25610. transformScale = inverted ? 1 / scale : scale;
  25611. selectionMarker[wh] = selectionWH;
  25612. selectionMarker[xy] = selectionXY;
  25613. transform[scaleKey] = scale;
  25614. transform['translate' + XY] = (transformScale * plotLeftTop) +
  25615. (touch0Now - (transformScale * touch0Start));
  25616. };
  25617. /**
  25618. * Reset the tracking by hiding the tooltip, the hover series state and the
  25619. * hover point
  25620. *
  25621. * @function Highcharts.Pointer#reset
  25622. *
  25623. * @param {boolean} [allowMove]
  25624. * Instead of destroying the tooltip altogether, allow moving it if
  25625. * possible.
  25626. *
  25627. * @param {number} [delay]
  25628. *
  25629. * @return {void}
  25630. */
  25631. Pointer.prototype.reset = function (allowMove, delay) {
  25632. var pointer = this,
  25633. chart = pointer.chart,
  25634. hoverSeries = chart.hoverSeries,
  25635. hoverPoint = chart.hoverPoint,
  25636. hoverPoints = chart.hoverPoints,
  25637. tooltip = chart.tooltip,
  25638. tooltipPoints = tooltip && tooltip.shared ?
  25639. hoverPoints :
  25640. hoverPoint;
  25641. // Check if the points have moved outside the plot area (#1003, #4736,
  25642. // #5101)
  25643. if (allowMove && tooltipPoints) {
  25644. splat(tooltipPoints).forEach(function (point) {
  25645. if (point.series.isCartesian &&
  25646. typeof point.plotX === 'undefined') {
  25647. allowMove = false;
  25648. }
  25649. });
  25650. }
  25651. // Just move the tooltip, #349
  25652. if (allowMove) {
  25653. if (tooltip && tooltipPoints && splat(tooltipPoints).length) {
  25654. tooltip.refresh(tooltipPoints);
  25655. if (tooltip.shared && hoverPoints) { // #8284
  25656. hoverPoints.forEach(function (point) {
  25657. point.setState(point.state, true);
  25658. if (point.series.isCartesian) {
  25659. if (point.series.xAxis.crosshair) {
  25660. point.series.xAxis
  25661. .drawCrosshair(null, point);
  25662. }
  25663. if (point.series.yAxis.crosshair) {
  25664. point.series.yAxis
  25665. .drawCrosshair(null, point);
  25666. }
  25667. }
  25668. });
  25669. }
  25670. else if (hoverPoint) { // #2500
  25671. hoverPoint.setState(hoverPoint.state, true);
  25672. chart.axes.forEach(function (axis) {
  25673. if (axis.crosshair &&
  25674. hoverPoint.series[axis.coll] === axis) {
  25675. axis.drawCrosshair(null, hoverPoint);
  25676. }
  25677. });
  25678. }
  25679. }
  25680. // Full reset
  25681. }
  25682. else {
  25683. if (hoverPoint) {
  25684. hoverPoint.onMouseOut();
  25685. }
  25686. if (hoverPoints) {
  25687. hoverPoints.forEach(function (point) {
  25688. point.setState();
  25689. });
  25690. }
  25691. if (hoverSeries) {
  25692. hoverSeries.onMouseOut();
  25693. }
  25694. if (tooltip) {
  25695. tooltip.hide(delay);
  25696. }
  25697. if (pointer.unDocMouseMove) {
  25698. pointer.unDocMouseMove = pointer.unDocMouseMove();
  25699. }
  25700. // Remove crosshairs
  25701. chart.axes.forEach(function (axis) {
  25702. axis.hideCrosshair();
  25703. });
  25704. pointer.hoverX = chart.hoverPoints = chart.hoverPoint = null;
  25705. }
  25706. };
  25707. /**
  25708. * With line type charts with a single tracker, get the point closest to the
  25709. * mouse. Run Point.onMouseOver and display tooltip for the point or points.
  25710. *
  25711. * @private
  25712. * @function Highcharts.Pointer#runPointActions
  25713. *
  25714. * @fires Highcharts.Point#event:mouseOut
  25715. * @fires Highcharts.Point#event:mouseOver
  25716. */
  25717. Pointer.prototype.runPointActions = function (e, p) {
  25718. var pointer = this,
  25719. chart = pointer.chart,
  25720. series = chart.series,
  25721. tooltip = (chart.tooltip && chart.tooltip.options.enabled ?
  25722. chart.tooltip :
  25723. void 0),
  25724. shared = (tooltip ?
  25725. tooltip.shared :
  25726. false),
  25727. hoverPoint = p || chart.hoverPoint,
  25728. hoverSeries = hoverPoint && hoverPoint.series || chart.hoverSeries,
  25729. // onMouseOver or already hovering a series with directTouch
  25730. isDirectTouch = (!e || e.type !== 'touchmove') && (!!p || ((hoverSeries && hoverSeries.directTouch) &&
  25731. pointer.isDirectTouch)),
  25732. hoverData = this.getHoverData(hoverPoint,
  25733. hoverSeries,
  25734. series,
  25735. isDirectTouch,
  25736. shared,
  25737. e),
  25738. useSharedTooltip,
  25739. followPointer,
  25740. points;
  25741. // Update variables from hoverData.
  25742. hoverPoint = hoverData.hoverPoint;
  25743. points = hoverData.hoverPoints;
  25744. hoverSeries = hoverData.hoverSeries;
  25745. followPointer = hoverSeries &&
  25746. hoverSeries.tooltipOptions.followPointer &&
  25747. !hoverSeries.tooltipOptions.split;
  25748. useSharedTooltip = (shared &&
  25749. hoverSeries &&
  25750. !hoverSeries.noSharedTooltip);
  25751. // Refresh tooltip for kdpoint if new hover point or tooltip was hidden
  25752. // #3926, #4200
  25753. if (hoverPoint &&
  25754. // !(hoverSeries && hoverSeries.directTouch) &&
  25755. (hoverPoint !== chart.hoverPoint || (tooltip && tooltip.isHidden))) {
  25756. (chart.hoverPoints || []).forEach(function (p) {
  25757. if (points.indexOf(p) === -1) {
  25758. p.setState();
  25759. }
  25760. });
  25761. // Set normal state to previous series
  25762. if (chart.hoverSeries !== hoverSeries) {
  25763. hoverSeries.onMouseOver();
  25764. }
  25765. pointer.applyInactiveState(points);
  25766. // Do mouseover on all points (#3919, #3985, #4410, #5622)
  25767. (points || []).forEach(function (p) {
  25768. p.setState('hover');
  25769. });
  25770. // If tracking is on series in stead of on each point,
  25771. // fire mouseOver on hover point. // #4448
  25772. if (chart.hoverPoint) {
  25773. chart.hoverPoint.firePointEvent('mouseOut');
  25774. }
  25775. // Hover point may have been destroyed in the event handlers (#7127)
  25776. if (!hoverPoint.series) {
  25777. return;
  25778. }
  25779. /**
  25780. * Contains all hovered points.
  25781. *
  25782. * @name Highcharts.Chart#hoverPoints
  25783. * @type {Array<Highcharts.Point>|null}
  25784. */
  25785. chart.hoverPoints = points;
  25786. /**
  25787. * Contains the original hovered point.
  25788. *
  25789. * @name Highcharts.Chart#hoverPoint
  25790. * @type {Highcharts.Point|null}
  25791. */
  25792. chart.hoverPoint = hoverPoint;
  25793. /**
  25794. * Hover state should not be lost when axis is updated (#12569)
  25795. * Axis.update runs pointer.reset which uses chart.hoverPoint.state
  25796. * to apply state which does not exist in hoverPoint yet.
  25797. * The mouseOver event should be triggered when hoverPoint
  25798. * is correct.
  25799. */
  25800. hoverPoint.firePointEvent('mouseOver');
  25801. // Draw tooltip if necessary
  25802. if (tooltip) {
  25803. tooltip.refresh(useSharedTooltip ? points : hoverPoint, e);
  25804. }
  25805. // Update positions (regardless of kdpoint or hoverPoint)
  25806. }
  25807. else if (followPointer && tooltip && !tooltip.isHidden) {
  25808. var anchor = tooltip.getAnchor([{}],
  25809. e);
  25810. if (chart.isInsidePlot(anchor[0], anchor[1], {
  25811. visiblePlotOnly: true
  25812. })) {
  25813. tooltip.updatePosition({ plotX: anchor[0], plotY: anchor[1] });
  25814. }
  25815. }
  25816. // Start the event listener to pick up the tooltip and crosshairs
  25817. if (!pointer.unDocMouseMove) {
  25818. pointer.unDocMouseMove = addEvent(chart.container.ownerDocument, 'mousemove', function (e) {
  25819. var chart = charts[H.hoverChartIndex];
  25820. if (chart) {
  25821. chart.pointer.onDocumentMouseMove(e);
  25822. }
  25823. });
  25824. pointer.eventsToUnbind.push(pointer.unDocMouseMove);
  25825. }
  25826. // Issues related to crosshair #4927, #5269 #5066, #5658
  25827. chart.axes.forEach(function drawAxisCrosshair(axis) {
  25828. var snap = pick((axis.crosshair || {}).snap,
  25829. true);
  25830. var point;
  25831. if (snap) {
  25832. point = chart.hoverPoint; // #13002
  25833. if (!point || point.series[axis.coll] !== axis) {
  25834. point = find(points, function (p) {
  25835. return p.series[axis.coll] === axis;
  25836. });
  25837. }
  25838. }
  25839. // Axis has snapping crosshairs, and one of the hover points belongs
  25840. // to axis. Always call drawCrosshair when it is not snap.
  25841. if (point || !snap) {
  25842. axis.drawCrosshair(e, point);
  25843. // Axis has snapping crosshairs, but no hover point belongs to axis
  25844. }
  25845. else {
  25846. axis.hideCrosshair();
  25847. }
  25848. });
  25849. };
  25850. /**
  25851. * Scale series groups to a certain scale and translation.
  25852. *
  25853. * @private
  25854. * @function Highcharts.Pointer#scaleGroups
  25855. */
  25856. Pointer.prototype.scaleGroups = function (attribs, clip) {
  25857. var chart = this.chart,
  25858. seriesAttribs;
  25859. // Scale each series
  25860. chart.series.forEach(function (series) {
  25861. seriesAttribs = attribs || series.getPlotBox(); // #1701
  25862. if (series.xAxis && series.xAxis.zoomEnabled && series.group) {
  25863. series.group.attr(seriesAttribs);
  25864. if (series.markerGroup) {
  25865. series.markerGroup.attr(seriesAttribs);
  25866. series.markerGroup.clip(clip ? chart.clipRect : null);
  25867. }
  25868. if (series.dataLabelsGroup) {
  25869. series.dataLabelsGroup.attr(seriesAttribs);
  25870. }
  25871. }
  25872. });
  25873. // Clip
  25874. chart.clipRect.attr(clip || chart.clipBox);
  25875. };
  25876. /**
  25877. * Set the JS DOM events on the container and document. This method should
  25878. * contain a one-to-one assignment between methods and their handlers. Any
  25879. * advanced logic should be moved to the handler reflecting the event's
  25880. * name.
  25881. *
  25882. * @private
  25883. * @function Highcharts.Pointer#setDOMEvents
  25884. */
  25885. Pointer.prototype.setDOMEvents = function () {
  25886. var _this = this;
  25887. var container = this.chart.container,
  25888. ownerDoc = container.ownerDocument;
  25889. container.onmousedown = this.onContainerMouseDown.bind(this);
  25890. container.onmousemove = this.onContainerMouseMove.bind(this);
  25891. container.onclick = this.onContainerClick.bind(this);
  25892. this.eventsToUnbind.push(addEvent(container, 'mouseenter', this.onContainerMouseEnter.bind(this)));
  25893. this.eventsToUnbind.push(addEvent(container, 'mouseleave', this.onContainerMouseLeave.bind(this)));
  25894. if (!H.unbindDocumentMouseUp) {
  25895. H.unbindDocumentMouseUp = addEvent(ownerDoc, 'mouseup', this.onDocumentMouseUp.bind(this));
  25896. }
  25897. // In case we are dealing with overflow, reset the chart position when
  25898. // scrolling parent elements
  25899. var parent = this.chart.renderTo.parentElement;
  25900. while (parent && parent.tagName !== 'BODY') {
  25901. this.eventsToUnbind.push(addEvent(parent, 'scroll', function () {
  25902. delete _this.chartPosition;
  25903. }));
  25904. parent = parent.parentElement;
  25905. }
  25906. if (H.hasTouch) {
  25907. this.eventsToUnbind.push(addEvent(container, 'touchstart', this.onContainerTouchStart.bind(this), { passive: false }));
  25908. this.eventsToUnbind.push(addEvent(container, 'touchmove', this.onContainerTouchMove.bind(this), { passive: false }));
  25909. if (!H.unbindDocumentTouchEnd) {
  25910. H.unbindDocumentTouchEnd = addEvent(ownerDoc, 'touchend', this.onDocumentTouchEnd.bind(this), { passive: false });
  25911. }
  25912. }
  25913. };
  25914. /**
  25915. * Sets the index of the hovered chart and leaves the previous hovered
  25916. * chart, to reset states like tooltip.
  25917. *
  25918. * @private
  25919. * @function Highcharts.Pointer#setHoverChartIndex
  25920. */
  25921. Pointer.prototype.setHoverChartIndex = function () {
  25922. var chart = this.chart;
  25923. var hoverChart = H.charts[pick(H.hoverChartIndex, -1)];
  25924. if (hoverChart &&
  25925. hoverChart !== chart) {
  25926. hoverChart.pointer.onContainerMouseLeave({ relatedTarget: true });
  25927. }
  25928. if (!hoverChart ||
  25929. !hoverChart.mouseIsDown) {
  25930. H.hoverChartIndex = chart.index;
  25931. }
  25932. };
  25933. /**
  25934. * General touch handler shared by touchstart and touchmove.
  25935. *
  25936. * @private
  25937. * @function Highcharts.Pointer#touch
  25938. */
  25939. Pointer.prototype.touch = function (e, start) {
  25940. var chart = this.chart,
  25941. hasMoved,
  25942. pinchDown,
  25943. isInside;
  25944. this.setHoverChartIndex();
  25945. if (e.touches.length === 1) {
  25946. e = this.normalize(e);
  25947. isInside = chart.isInsidePlot(e.chartX - chart.plotLeft, e.chartY - chart.plotTop, {
  25948. visiblePlotOnly: true
  25949. });
  25950. if (isInside && !chart.openMenu) {
  25951. // Run mouse events and display tooltip etc
  25952. if (start) {
  25953. this.runPointActions(e);
  25954. }
  25955. // Android fires touchmove events after the touchstart even if
  25956. // the finger hasn't moved, or moved only a pixel or two. In iOS
  25957. // however, the touchmove doesn't fire unless the finger moves
  25958. // more than ~4px. So we emulate this behaviour in Android by
  25959. // checking how much it moved, and cancelling on small
  25960. // distances. #3450.
  25961. if (e.type === 'touchmove') {
  25962. pinchDown = this.pinchDown;
  25963. hasMoved = pinchDown[0] ? Math.sqrt(// #5266
  25964. Math.pow(pinchDown[0].chartX - e.chartX, 2) +
  25965. Math.pow(pinchDown[0].chartY - e.chartY, 2)) >= 4 : false;
  25966. }
  25967. if (pick(hasMoved, true)) {
  25968. this.pinch(e);
  25969. }
  25970. }
  25971. else if (start) {
  25972. // Hide the tooltip on touching outside the plot area (#1203)
  25973. this.reset();
  25974. }
  25975. }
  25976. else if (e.touches.length === 2) {
  25977. this.pinch(e);
  25978. }
  25979. };
  25980. /**
  25981. * Returns true if the chart is set up for zooming by single touch and the
  25982. * event is capable
  25983. * @param {PointEvent} e
  25984. * Event object
  25985. */
  25986. Pointer.prototype.touchSelect = function (e) {
  25987. return Boolean(this.chart.options.chart.zoomBySingleTouch &&
  25988. e.touches &&
  25989. e.touches.length === 1);
  25990. };
  25991. /**
  25992. * Resolve the zoomType option, this is reset on all touch start and mouse
  25993. * down events.
  25994. *
  25995. * @private
  25996. * @function Highcharts.Pointer#zoomOption
  25997. *
  25998. * @param {global.Event} e
  25999. * Event object.
  26000. *
  26001. * @param {void}
  26002. */
  26003. Pointer.prototype.zoomOption = function (e) {
  26004. var chart = this.chart,
  26005. options = chart.options.chart,
  26006. zoomType = options.zoomType || '',
  26007. inverted = chart.inverted,
  26008. zoomX,
  26009. zoomY;
  26010. // Look for the pinchType option
  26011. if (/touch/.test(e.type)) {
  26012. zoomType = pick(options.pinchType, zoomType);
  26013. }
  26014. this.zoomX = zoomX = /x/.test(zoomType);
  26015. this.zoomY = zoomY = /y/.test(zoomType);
  26016. this.zoomHor = (zoomX && !inverted) || (zoomY && inverted);
  26017. this.zoomVert = (zoomY && !inverted) || (zoomX && inverted);
  26018. this.hasZoom = zoomX || zoomY;
  26019. };
  26020. return Pointer;
  26021. }());
  26022. H.Pointer = Pointer;
  26023. return Pointer;
  26024. });
  26025. _registerModule(_modules, 'Core/MSPointer.js', [_modules['Core/Globals.js'], _modules['Core/Pointer.js'], _modules['Core/Utilities.js']], function (H, Pointer, U) {
  26026. /* *
  26027. *
  26028. * (c) 2010-2021 Torstein Honsi
  26029. *
  26030. * License: www.highcharts.com/license
  26031. *
  26032. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  26033. *
  26034. * */
  26035. var __extends = (this && this.__extends) || (function () {
  26036. var extendStatics = function (d,
  26037. b) {
  26038. extendStatics = Object.setPrototypeOf ||
  26039. ({ __proto__: [] } instanceof Array && function (d,
  26040. b) { d.__proto__ = b; }) ||
  26041. function (d,
  26042. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  26043. return extendStatics(d, b);
  26044. };
  26045. return function (d, b) {
  26046. extendStatics(d, b);
  26047. function __() { this.constructor = d; }
  26048. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  26049. };
  26050. })();
  26051. var charts = H.charts,
  26052. doc = H.doc,
  26053. noop = H.noop,
  26054. win = H.win;
  26055. var addEvent = U.addEvent,
  26056. css = U.css,
  26057. objectEach = U.objectEach,
  26058. removeEvent = U.removeEvent;
  26059. /* globals MSPointerEvent, PointerEvent */
  26060. // The touches object keeps track of the points being touched at all times
  26061. var touches = {};
  26062. var hasPointerEvent = !!win.PointerEvent;
  26063. /* eslint-disable valid-jsdoc */
  26064. /** @private */
  26065. function getWebkitTouches() {
  26066. var fake = [];
  26067. fake.item = function (i) {
  26068. return this[i];
  26069. };
  26070. objectEach(touches, function (touch) {
  26071. fake.push({
  26072. pageX: touch.pageX,
  26073. pageY: touch.pageY,
  26074. target: touch.target
  26075. });
  26076. });
  26077. return fake;
  26078. }
  26079. /** @private */
  26080. function translateMSPointer(e, method, wktype, func) {
  26081. var p;
  26082. if ((e.pointerType === 'touch' ||
  26083. e.pointerType === e.MSPOINTER_TYPE_TOUCH) && charts[H.hoverChartIndex]) {
  26084. func(e);
  26085. p = charts[H.hoverChartIndex].pointer;
  26086. p[method]({
  26087. type: wktype,
  26088. target: e.currentTarget,
  26089. preventDefault: noop,
  26090. touches: getWebkitTouches()
  26091. });
  26092. }
  26093. }
  26094. /** @private */
  26095. var MSPointer = /** @class */ (function (_super) {
  26096. __extends(MSPointer, _super);
  26097. function MSPointer() {
  26098. return _super !== null && _super.apply(this, arguments) || this;
  26099. }
  26100. /* *
  26101. *
  26102. * Functions
  26103. *
  26104. * */
  26105. /**
  26106. * Add or remove the MS Pointer specific events
  26107. *
  26108. * @private
  26109. * @function Highcharts.Pointer#batchMSEvents
  26110. *
  26111. * @param {Function} fn
  26112. *
  26113. * @return {void}
  26114. */
  26115. MSPointer.prototype.batchMSEvents = function (fn) {
  26116. fn(this.chart.container, hasPointerEvent ? 'pointerdown' : 'MSPointerDown', this.onContainerPointerDown);
  26117. fn(this.chart.container, hasPointerEvent ? 'pointermove' : 'MSPointerMove', this.onContainerPointerMove);
  26118. fn(doc, hasPointerEvent ? 'pointerup' : 'MSPointerUp', this.onDocumentPointerUp);
  26119. };
  26120. // Destroy MS events also
  26121. MSPointer.prototype.destroy = function () {
  26122. this.batchMSEvents(removeEvent);
  26123. _super.prototype.destroy.call(this);
  26124. };
  26125. // Disable default IE actions for pinch and such on chart element
  26126. MSPointer.prototype.init = function (chart, options) {
  26127. _super.prototype.init.call(this, chart, options);
  26128. if (this.hasZoom) { // #4014
  26129. css(chart.container, {
  26130. '-ms-touch-action': 'none',
  26131. 'touch-action': 'none'
  26132. });
  26133. }
  26134. };
  26135. /**
  26136. * @private
  26137. * @function Highcharts.Pointer#onContainerPointerDown
  26138. *
  26139. * @param {Highcharts.PointerEventObject} e
  26140. *
  26141. * @return {void}
  26142. */
  26143. MSPointer.prototype.onContainerPointerDown = function (e) {
  26144. translateMSPointer(e, 'onContainerTouchStart', 'touchstart', function (e) {
  26145. touches[e.pointerId] = {
  26146. pageX: e.pageX,
  26147. pageY: e.pageY,
  26148. target: e.currentTarget
  26149. };
  26150. });
  26151. };
  26152. /**
  26153. * @private
  26154. * @function Highcharts.Pointer#onContainerPointerMove
  26155. *
  26156. * @param {Highcharts.PointerEventObject} e
  26157. *
  26158. * @return {void}
  26159. */
  26160. MSPointer.prototype.onContainerPointerMove = function (e) {
  26161. translateMSPointer(e, 'onContainerTouchMove', 'touchmove', function (e) {
  26162. touches[e.pointerId] = ({ pageX: e.pageX, pageY: e.pageY });
  26163. if (!touches[e.pointerId].target) {
  26164. touches[e.pointerId].target = e.currentTarget;
  26165. }
  26166. });
  26167. };
  26168. /**
  26169. * @private
  26170. * @function Highcharts.Pointer#onDocumentPointerUp
  26171. *
  26172. * @param {Highcharts.PointerEventObject} e
  26173. *
  26174. * @return {void}
  26175. */
  26176. MSPointer.prototype.onDocumentPointerUp = function (e) {
  26177. translateMSPointer(e, 'onDocumentTouchEnd', 'touchend', function (e) {
  26178. delete touches[e.pointerId];
  26179. });
  26180. };
  26181. // Add IE specific touch events to chart
  26182. MSPointer.prototype.setDOMEvents = function () {
  26183. _super.prototype.setDOMEvents.call(this);
  26184. if (this.hasZoom || this.followTouchMove) {
  26185. this.batchMSEvents(addEvent);
  26186. }
  26187. };
  26188. return MSPointer;
  26189. }(Pointer));
  26190. return MSPointer;
  26191. });
  26192. _registerModule(_modules, 'Core/Series/Point.js', [_modules['Core/Renderer/HTML/AST.js'], _modules['Core/Animation/AnimationUtilities.js'], _modules['Core/FormatUtilities.js'], _modules['Core/Globals.js'], _modules['Core/Options.js'], _modules['Core/Utilities.js']], function (AST, A, F, H, O, U) {
  26193. /* *
  26194. *
  26195. * (c) 2010-2021 Torstein Honsi
  26196. *
  26197. * License: www.highcharts.com/license
  26198. *
  26199. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  26200. *
  26201. * */
  26202. var animObject = A.animObject;
  26203. var format = F.format;
  26204. var defaultOptions = O.defaultOptions;
  26205. var addEvent = U.addEvent,
  26206. defined = U.defined,
  26207. erase = U.erase,
  26208. extend = U.extend,
  26209. fireEvent = U.fireEvent,
  26210. getNestedProperty = U.getNestedProperty,
  26211. isArray = U.isArray,
  26212. isFunction = U.isFunction,
  26213. isNumber = U.isNumber,
  26214. isObject = U.isObject,
  26215. merge = U.merge,
  26216. objectEach = U.objectEach,
  26217. pick = U.pick,
  26218. syncTimeout = U.syncTimeout,
  26219. removeEvent = U.removeEvent,
  26220. uniqueKey = U.uniqueKey;
  26221. /**
  26222. * Function callback when a series point is clicked. Return false to cancel the
  26223. * action.
  26224. *
  26225. * @callback Highcharts.PointClickCallbackFunction
  26226. *
  26227. * @param {Highcharts.Point} this
  26228. * The point where the event occured.
  26229. *
  26230. * @param {Highcharts.PointClickEventObject} event
  26231. * Event arguments.
  26232. */
  26233. /**
  26234. * Common information for a click event on a series point.
  26235. *
  26236. * @interface Highcharts.PointClickEventObject
  26237. * @extends Highcharts.PointerEventObject
  26238. */ /**
  26239. * Clicked point.
  26240. * @name Highcharts.PointClickEventObject#point
  26241. * @type {Highcharts.Point}
  26242. */
  26243. /**
  26244. * Configuration hash for the data label and tooltip formatters.
  26245. *
  26246. * @interface Highcharts.PointLabelObject
  26247. */ /**
  26248. * The point's current color.
  26249. * @name Highcharts.PointLabelObject#color
  26250. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject|undefined}
  26251. */ /**
  26252. * The point's current color index, used in styled mode instead of `color`. The
  26253. * color index is inserted in class names used for styling.
  26254. * @name Highcharts.PointLabelObject#colorIndex
  26255. * @type {number}
  26256. */ /**
  26257. * The name of the related point.
  26258. * @name Highcharts.PointLabelObject#key
  26259. * @type {string|undefined}
  26260. */ /**
  26261. * The percentage for related points in a stacked series or pies.
  26262. * @name Highcharts.PointLabelObject#percentage
  26263. * @type {number}
  26264. */ /**
  26265. * The related point. The point name, if defined, is available through
  26266. * `this.point.name`.
  26267. * @name Highcharts.PointLabelObject#point
  26268. * @type {Highcharts.Point}
  26269. */ /**
  26270. * The related series. The series name is available through `this.series.name`.
  26271. * @name Highcharts.PointLabelObject#series
  26272. * @type {Highcharts.Series}
  26273. */ /**
  26274. * The total of values in either a stack for stacked series, or a pie in a pie
  26275. * series.
  26276. * @name Highcharts.PointLabelObject#total
  26277. * @type {number|undefined}
  26278. */ /**
  26279. * For categorized axes this property holds the category name for the point. For
  26280. * other axes it holds the X value.
  26281. * @name Highcharts.PointLabelObject#x
  26282. * @type {number|string|undefined}
  26283. */ /**
  26284. * The y value of the point.
  26285. * @name Highcharts.PointLabelObject#y
  26286. * @type {number|undefined}
  26287. */
  26288. /**
  26289. * Gets fired when the mouse leaves the area close to the point.
  26290. *
  26291. * @callback Highcharts.PointMouseOutCallbackFunction
  26292. *
  26293. * @param {Highcharts.Point} this
  26294. * Point where the event occured.
  26295. *
  26296. * @param {global.PointerEvent} event
  26297. * Event that occured.
  26298. */
  26299. /**
  26300. * Gets fired when the mouse enters the area close to the point.
  26301. *
  26302. * @callback Highcharts.PointMouseOverCallbackFunction
  26303. *
  26304. * @param {Highcharts.Point} this
  26305. * Point where the event occured.
  26306. *
  26307. * @param {global.Event} event
  26308. * Event that occured.
  26309. */
  26310. /**
  26311. * The generic point options for all series.
  26312. *
  26313. * In TypeScript you have to extend `PointOptionsObject` with an additional
  26314. * declaration to allow custom data options:
  26315. *
  26316. * ```
  26317. * declare interface PointOptionsObject {
  26318. * customProperty: string;
  26319. * }
  26320. * ```
  26321. *
  26322. * @interface Highcharts.PointOptionsObject
  26323. */
  26324. /**
  26325. * Possible option types for a data point. Use `null` to indicate a gap.
  26326. *
  26327. * @typedef {number|string|Highcharts.PointOptionsObject|Array<(number|string|null)>|null} Highcharts.PointOptionsType
  26328. */
  26329. /**
  26330. * Gets fired when the point is removed using the `.remove()` method.
  26331. *
  26332. * @callback Highcharts.PointRemoveCallbackFunction
  26333. *
  26334. * @param {Highcharts.Point} this
  26335. * Point where the event occured.
  26336. *
  26337. * @param {global.Event} event
  26338. * Event that occured.
  26339. */
  26340. /**
  26341. * Possible key values for the point state options.
  26342. *
  26343. * @typedef {"hover"|"inactive"|"normal"|"select"} Highcharts.PointStateValue
  26344. */
  26345. /**
  26346. * Gets fired when the point is updated programmatically through the `.update()`
  26347. * method.
  26348. *
  26349. * @callback Highcharts.PointUpdateCallbackFunction
  26350. *
  26351. * @param {Highcharts.Point} this
  26352. * Point where the event occured.
  26353. *
  26354. * @param {Highcharts.PointUpdateEventObject} event
  26355. * Event that occured.
  26356. */
  26357. /**
  26358. * Information about the update event.
  26359. *
  26360. * @interface Highcharts.PointUpdateEventObject
  26361. * @extends global.Event
  26362. */ /**
  26363. * Options data of the update event.
  26364. * @name Highcharts.PointUpdateEventObject#options
  26365. * @type {Highcharts.PointOptionsType}
  26366. */
  26367. /**
  26368. * @interface Highcharts.PointEventsOptionsObject
  26369. */ /**
  26370. * Fires when the point is selected either programmatically or following a click
  26371. * on the point. One parameter, `event`, is passed to the function. Returning
  26372. * `false` cancels the operation.
  26373. * @name Highcharts.PointEventsOptionsObject#select
  26374. * @type {Highcharts.PointSelectCallbackFunction|undefined}
  26375. */ /**
  26376. * Fires when the point is unselected either programmatically or following a
  26377. * click on the point. One parameter, `event`, is passed to the function.
  26378. * Returning `false` cancels the operation.
  26379. * @name Highcharts.PointEventsOptionsObject#unselect
  26380. * @type {Highcharts.PointUnselectCallbackFunction|undefined}
  26381. */
  26382. /**
  26383. * Information about the select/unselect event.
  26384. *
  26385. * @interface Highcharts.PointInteractionEventObject
  26386. * @extends global.Event
  26387. */ /**
  26388. * @name Highcharts.PointInteractionEventObject#accumulate
  26389. * @type {boolean}
  26390. */
  26391. /**
  26392. * Gets fired when the point is selected either programmatically or following a
  26393. * click on the point.
  26394. *
  26395. * @callback Highcharts.PointSelectCallbackFunction
  26396. *
  26397. * @param {Highcharts.Point} this
  26398. * Point where the event occured.
  26399. *
  26400. * @param {Highcharts.PointInteractionEventObject} event
  26401. * Event that occured.
  26402. */
  26403. /**
  26404. * Fires when the point is unselected either programmatically or following a
  26405. * click on the point.
  26406. *
  26407. * @callback Highcharts.PointUnselectCallbackFunction
  26408. *
  26409. * @param {Highcharts.Point} this
  26410. * Point where the event occured.
  26411. *
  26412. * @param {Highcharts.PointInteractionEventObject} event
  26413. * Event that occured.
  26414. */
  26415. ''; // detach doclet above
  26416. /* eslint-disable no-invalid-this, valid-jsdoc */
  26417. /**
  26418. * The Point object. The point objects are generated from the `series.data`
  26419. * configuration objects or raw numbers. They can be accessed from the
  26420. * `Series.points` array. Other ways to instantiate points are through {@link
  26421. * Highcharts.Series#addPoint} or {@link Highcharts.Series#setData}.
  26422. *
  26423. * @class
  26424. * @name Highcharts.Point
  26425. */
  26426. var Point = /** @class */ (function () {
  26427. function Point() {
  26428. /* *
  26429. *
  26430. * Properties
  26431. *
  26432. * */
  26433. /**
  26434. * For categorized axes this property holds the category name for the
  26435. * point. For other axes it holds the X value.
  26436. *
  26437. * @name Highcharts.Point#category
  26438. * @type {string}
  26439. */
  26440. this.category = void 0;
  26441. /**
  26442. * The point's current color index, used in styled mode instead of
  26443. * `color`. The color index is inserted in class names used for styling.
  26444. *
  26445. * @name Highcharts.Point#colorIndex
  26446. * @type {number}
  26447. */
  26448. this.colorIndex = void 0;
  26449. this.formatPrefix = 'point';
  26450. this.id = void 0;
  26451. this.isNull = false;
  26452. /**
  26453. * The name of the point. The name can be given as the first position of the
  26454. * point configuration array, or as a `name` property in the configuration:
  26455. *
  26456. * @example
  26457. * // Array config
  26458. * data: [
  26459. * ['John', 1],
  26460. * ['Jane', 2]
  26461. * ]
  26462. *
  26463. * // Object config
  26464. * data: [{
  26465. * name: 'John',
  26466. * y: 1
  26467. * }, {
  26468. * name: 'Jane',
  26469. * y: 2
  26470. * }]
  26471. *
  26472. * @name Highcharts.Point#name
  26473. * @type {string}
  26474. */
  26475. this.name = void 0;
  26476. /**
  26477. * The point's options as applied in the initial configuration, or
  26478. * extended through `Point.update`.
  26479. *
  26480. * In TypeScript you have to extend `PointOptionsObject` via an
  26481. * additional interface to allow custom data options:
  26482. *
  26483. * ```
  26484. * declare interface PointOptionsObject {
  26485. * customProperty: string;
  26486. * }
  26487. * ```
  26488. *
  26489. * @name Highcharts.Point#options
  26490. * @type {Highcharts.PointOptionsObject}
  26491. */
  26492. this.options = void 0;
  26493. /**
  26494. * The percentage for points in a stacked series or pies.
  26495. *
  26496. * @name Highcharts.Point#percentage
  26497. * @type {number|undefined}
  26498. */
  26499. this.percentage = void 0;
  26500. this.selected = false;
  26501. /**
  26502. * The series object associated with the point.
  26503. *
  26504. * @name Highcharts.Point#series
  26505. * @type {Highcharts.Series}
  26506. */
  26507. this.series = void 0;
  26508. /**
  26509. * The total of values in either a stack for stacked series, or a pie in a
  26510. * pie series.
  26511. *
  26512. * @name Highcharts.Point#total
  26513. * @type {number|undefined}
  26514. */
  26515. this.total = void 0;
  26516. /**
  26517. * For certain series types, like pie charts, where individual points can
  26518. * be shown or hidden.
  26519. *
  26520. * @name Highcharts.Point#visible
  26521. * @type {boolean}
  26522. * @default true
  26523. */
  26524. this.visible = true;
  26525. this.x = void 0;
  26526. }
  26527. /* *
  26528. *
  26529. * Functions
  26530. *
  26531. * */
  26532. /**
  26533. * Animate SVG elements associated with the point.
  26534. *
  26535. * @private
  26536. * @function Highcharts.Point#animateBeforeDestroy
  26537. */
  26538. Point.prototype.animateBeforeDestroy = function () {
  26539. var point = this,
  26540. animateParams = { x: point.startXPos,
  26541. opacity: 0 },
  26542. isDataLabel,
  26543. graphicalProps = point.getGraphicalProps();
  26544. graphicalProps.singular.forEach(function (prop) {
  26545. isDataLabel = prop === 'dataLabel';
  26546. point[prop] = point[prop].animate(isDataLabel ? {
  26547. x: point[prop].startXPos,
  26548. y: point[prop].startYPos,
  26549. opacity: 0
  26550. } : animateParams);
  26551. });
  26552. graphicalProps.plural.forEach(function (plural) {
  26553. point[plural].forEach(function (item) {
  26554. if (item.element) {
  26555. item.animate(extend({ x: point.startXPos }, (item.startYPos ? {
  26556. x: item.startXPos,
  26557. y: item.startYPos
  26558. } : {})));
  26559. }
  26560. });
  26561. });
  26562. };
  26563. /**
  26564. * Apply the options containing the x and y data and possible some extra
  26565. * properties. Called on point init or from point.update.
  26566. *
  26567. * @private
  26568. * @function Highcharts.Point#applyOptions
  26569. *
  26570. * @param {Highcharts.PointOptionsType} options
  26571. * The point options as defined in series.data.
  26572. *
  26573. * @param {number} [x]
  26574. * Optionally, the x value.
  26575. *
  26576. * @return {Highcharts.Point}
  26577. * The Point instance.
  26578. */
  26579. Point.prototype.applyOptions = function (options, x) {
  26580. var point = this,
  26581. series = point.series,
  26582. pointValKey = series.options.pointValKey || series.pointValKey;
  26583. options = Point.prototype.optionsToObject.call(this, options);
  26584. // copy options directly to point
  26585. extend(point, options);
  26586. point.options = point.options ? extend(point.options, options) : options;
  26587. // Since options are copied into the Point instance, some accidental
  26588. // options must be shielded (#5681)
  26589. if (options.group) {
  26590. delete point.group;
  26591. }
  26592. if (options.dataLabels) {
  26593. delete point.dataLabels;
  26594. }
  26595. /**
  26596. * The y value of the point.
  26597. * @name Highcharts.Point#y
  26598. * @type {number|undefined}
  26599. */
  26600. // For higher dimension series types. For instance, for ranges, point.y
  26601. // is mapped to point.low.
  26602. if (pointValKey) {
  26603. point.y = Point.prototype.getNestedProperty.call(point, pointValKey);
  26604. }
  26605. point.isNull = pick(point.isValid && !point.isValid(), point.x === null || !isNumber(point.y)); // #3571, check for NaN
  26606. point.formatPrefix = point.isNull ? 'null' : 'point'; // #9233, #10874
  26607. // The point is initially selected by options (#5777)
  26608. if (point.selected) {
  26609. point.state = 'select';
  26610. }
  26611. /**
  26612. * The x value of the point.
  26613. * @name Highcharts.Point#x
  26614. * @type {number}
  26615. */
  26616. // If no x is set by now, get auto incremented value. All points must
  26617. // have an x value, however the y value can be null to create a gap in
  26618. // the series
  26619. if ('name' in point &&
  26620. typeof x === 'undefined' &&
  26621. series.xAxis &&
  26622. series.xAxis.hasNames) {
  26623. point.x = series.xAxis.nameToX(point);
  26624. }
  26625. if (typeof point.x === 'undefined' && series) {
  26626. if (typeof x === 'undefined') {
  26627. point.x = series.autoIncrement(point);
  26628. }
  26629. else {
  26630. point.x = x;
  26631. }
  26632. }
  26633. return point;
  26634. };
  26635. /**
  26636. * Destroy a point to clear memory. Its reference still stays in
  26637. * `series.data`.
  26638. *
  26639. * @private
  26640. * @function Highcharts.Point#destroy
  26641. */
  26642. Point.prototype.destroy = function () {
  26643. var point = this,
  26644. series = point.series,
  26645. chart = series.chart,
  26646. dataSorting = series.options.dataSorting,
  26647. hoverPoints = chart.hoverPoints,
  26648. globalAnimation = point.series.chart.renderer.globalAnimation,
  26649. animation = animObject(globalAnimation),
  26650. prop;
  26651. /**
  26652. * Allow to call after animation.
  26653. * @private
  26654. */
  26655. function destroyPoint() {
  26656. // Remove all events and elements
  26657. if (point.graphic || point.dataLabel || point.dataLabels) {
  26658. removeEvent(point);
  26659. point.destroyElements();
  26660. }
  26661. for (prop in point) { // eslint-disable-line guard-for-in
  26662. point[prop] = null;
  26663. }
  26664. }
  26665. if (point.legendItem) { // pies have legend items
  26666. chart.legend.destroyItem(point);
  26667. }
  26668. if (hoverPoints) {
  26669. point.setState();
  26670. erase(hoverPoints, point);
  26671. if (!hoverPoints.length) {
  26672. chart.hoverPoints = null;
  26673. }
  26674. }
  26675. if (point === chart.hoverPoint) {
  26676. point.onMouseOut();
  26677. }
  26678. // Remove properties after animation
  26679. if (!dataSorting || !dataSorting.enabled) {
  26680. destroyPoint();
  26681. }
  26682. else {
  26683. this.animateBeforeDestroy();
  26684. syncTimeout(destroyPoint, animation.duration);
  26685. }
  26686. chart.pointCount--;
  26687. };
  26688. /**
  26689. * Destroy SVG elements associated with the point.
  26690. *
  26691. * @private
  26692. * @function Highcharts.Point#destroyElements
  26693. * @param {Highcharts.Dictionary<number>} [kinds]
  26694. */
  26695. Point.prototype.destroyElements = function (kinds) {
  26696. var point = this,
  26697. props = point.getGraphicalProps(kinds);
  26698. props.singular.forEach(function (prop) {
  26699. point[prop] = point[prop].destroy();
  26700. });
  26701. props.plural.forEach(function (plural) {
  26702. point[plural].forEach(function (item) {
  26703. if (item.element) {
  26704. item.destroy();
  26705. }
  26706. });
  26707. delete point[plural];
  26708. });
  26709. };
  26710. /**
  26711. * Fire an event on the Point object.
  26712. *
  26713. * @private
  26714. * @function Highcharts.Point#firePointEvent
  26715. *
  26716. * @param {string} eventType
  26717. * Type of the event.
  26718. *
  26719. * @param {Highcharts.Dictionary<any>|Event} [eventArgs]
  26720. * Additional event arguments.
  26721. *
  26722. * @param {Highcharts.EventCallbackFunction<Highcharts.Point>|Function} [defaultFunction]
  26723. * Default event handler.
  26724. *
  26725. * @fires Highcharts.Point#event:*
  26726. */
  26727. Point.prototype.firePointEvent = function (eventType, eventArgs, defaultFunction) {
  26728. var point = this,
  26729. series = this.series,
  26730. seriesOptions = series.options;
  26731. // load event handlers on demand to save time on mouseover/out
  26732. if (seriesOptions.point.events[eventType] ||
  26733. (point.options &&
  26734. point.options.events &&
  26735. point.options.events[eventType])) {
  26736. point.importEvents();
  26737. }
  26738. // add default handler if in selection mode
  26739. if (eventType === 'click' && seriesOptions.allowPointSelect) {
  26740. defaultFunction = function (event) {
  26741. // Control key is for Windows, meta (= Cmd key) for Mac, Shift
  26742. // for Opera.
  26743. if (point.select) { // #2911
  26744. point.select(null, event.ctrlKey || event.metaKey || event.shiftKey);
  26745. }
  26746. };
  26747. }
  26748. fireEvent(point, eventType, eventArgs, defaultFunction);
  26749. };
  26750. /**
  26751. * Get the CSS class names for individual points. Used internally where the
  26752. * returned value is set on every point.
  26753. *
  26754. * @function Highcharts.Point#getClassName
  26755. *
  26756. * @return {string}
  26757. * The class names.
  26758. */
  26759. Point.prototype.getClassName = function () {
  26760. var point = this;
  26761. return 'highcharts-point' +
  26762. (point.selected ? ' highcharts-point-select' : '') +
  26763. (point.negative ? ' highcharts-negative' : '') +
  26764. (point.isNull ? ' highcharts-null-point' : '') +
  26765. (typeof point.colorIndex !== 'undefined' ?
  26766. ' highcharts-color-' + point.colorIndex : '') +
  26767. (point.options.className ? ' ' + point.options.className : '') +
  26768. (point.zone && point.zone.className ? ' ' +
  26769. point.zone.className.replace('highcharts-negative', '') : '');
  26770. };
  26771. /**
  26772. * Get props of all existing graphical point elements.
  26773. *
  26774. * @private
  26775. * @function Highcharts.Point#getGraphicalProps
  26776. * @param {Highcharts.Dictionary<number>} [kinds]
  26777. * @return {Highcharts.PointGraphicalProps}
  26778. */
  26779. Point.prototype.getGraphicalProps = function (kinds) {
  26780. var point = this,
  26781. props = [],
  26782. prop,
  26783. i,
  26784. graphicalProps = { singular: [],
  26785. plural: [] };
  26786. kinds = kinds || { graphic: 1, dataLabel: 1 };
  26787. if (kinds.graphic) {
  26788. props.push('graphic', 'upperGraphic', 'shadowGroup');
  26789. }
  26790. if (kinds.dataLabel) {
  26791. props.push('dataLabel', 'dataLabelUpper', 'connector');
  26792. }
  26793. i = props.length;
  26794. while (i--) {
  26795. prop = props[i];
  26796. if (point[prop]) {
  26797. graphicalProps.singular.push(prop);
  26798. }
  26799. }
  26800. ['dataLabel', 'connector'].forEach(function (prop) {
  26801. var plural = prop + 's';
  26802. if (kinds[prop] && point[plural]) {
  26803. graphicalProps.plural.push(plural);
  26804. }
  26805. });
  26806. return graphicalProps;
  26807. };
  26808. /**
  26809. * Return the configuration hash needed for the data label and tooltip
  26810. * formatters.
  26811. *
  26812. * @function Highcharts.Point#getLabelConfig
  26813. *
  26814. * @return {Highcharts.PointLabelObject}
  26815. * Abstract object used in formatters and formats.
  26816. */
  26817. Point.prototype.getLabelConfig = function () {
  26818. return {
  26819. x: this.category,
  26820. y: this.y,
  26821. color: this.color,
  26822. colorIndex: this.colorIndex,
  26823. key: this.name || this.category,
  26824. series: this.series,
  26825. point: this,
  26826. percentage: this.percentage,
  26827. total: this.total || this.stackTotal
  26828. };
  26829. };
  26830. /**
  26831. * Returns the value of the point property for a given value.
  26832. * @private
  26833. */
  26834. Point.prototype.getNestedProperty = function (key) {
  26835. if (!key) {
  26836. return;
  26837. }
  26838. if (key.indexOf('custom.') === 0) {
  26839. return getNestedProperty(key, this.options);
  26840. }
  26841. return this[key];
  26842. };
  26843. /**
  26844. * In a series with `zones`, return the zone that the point belongs to.
  26845. *
  26846. * @function Highcharts.Point#getZone
  26847. *
  26848. * @return {Highcharts.SeriesZonesOptionsObject}
  26849. * The zone item.
  26850. */
  26851. Point.prototype.getZone = function () {
  26852. var series = this.series,
  26853. zones = series.zones,
  26854. zoneAxis = series.zoneAxis || 'y',
  26855. i = 0,
  26856. zone;
  26857. zone = zones[i];
  26858. while (this[zoneAxis] >= zone.value) {
  26859. zone = zones[++i];
  26860. }
  26861. // For resetting or reusing the point (#8100)
  26862. if (!this.nonZonedColor) {
  26863. this.nonZonedColor = this.color;
  26864. }
  26865. if (zone && zone.color && !this.options.color) {
  26866. this.color = zone.color;
  26867. }
  26868. else {
  26869. this.color = this.nonZonedColor;
  26870. }
  26871. return zone;
  26872. };
  26873. /**
  26874. * Utility to check if point has new shape type. Used in column series and
  26875. * all others that are based on column series.
  26876. *
  26877. * @return boolean|undefined
  26878. */
  26879. Point.prototype.hasNewShapeType = function () {
  26880. var point = this;
  26881. var oldShapeType = point.graphic &&
  26882. (point.graphic.symbolName || point.graphic.element.nodeName);
  26883. return oldShapeType !== this.shapeType;
  26884. };
  26885. /**
  26886. * Initialize the point. Called internally based on the `series.data`
  26887. * option.
  26888. *
  26889. * @function Highcharts.Point#init
  26890. *
  26891. * @param {Highcharts.Series} series
  26892. * The series object containing this point.
  26893. *
  26894. * @param {Highcharts.PointOptionsType} options
  26895. * The data in either number, array or object format.
  26896. *
  26897. * @param {number} [x]
  26898. * Optionally, the X value of the point.
  26899. *
  26900. * @return {Highcharts.Point}
  26901. * The Point instance.
  26902. *
  26903. * @fires Highcharts.Point#event:afterInit
  26904. */
  26905. Point.prototype.init = function (series, options, x) {
  26906. this.series = series;
  26907. this.applyOptions(options, x);
  26908. // Add a unique ID to the point if none is assigned
  26909. this.id = defined(this.id) ? this.id : uniqueKey();
  26910. this.resolveColor();
  26911. series.chart.pointCount++;
  26912. fireEvent(this, 'afterInit');
  26913. return this;
  26914. };
  26915. /**
  26916. * Transform number or array configs into objects. Also called for object
  26917. * configs. Used internally to unify the different configuration formats for
  26918. * points. For example, a simple number `10` in a line series will be
  26919. * transformed to `{ y: 10 }`, and an array config like `[1, 10]` in a
  26920. * scatter series will be transformed to `{ x: 1, y: 10 }`.
  26921. *
  26922. * @function Highcharts.Point#optionsToObject
  26923. *
  26924. * @param {Highcharts.PointOptionsType} options
  26925. * The input option.
  26926. *
  26927. * @return {Highcharts.Dictionary<*>}
  26928. * Transformed options.
  26929. */
  26930. Point.prototype.optionsToObject = function (options) {
  26931. var ret = {},
  26932. series = this.series,
  26933. keys = series.options.keys,
  26934. pointArrayMap = keys || series.pointArrayMap || ['y'],
  26935. valueCount = pointArrayMap.length,
  26936. firstItemType,
  26937. i = 0,
  26938. j = 0;
  26939. if (isNumber(options) || options === null) {
  26940. ret[pointArrayMap[0]] = options;
  26941. }
  26942. else if (isArray(options)) {
  26943. // with leading x value
  26944. if (!keys && options.length > valueCount) {
  26945. firstItemType = typeof options[0];
  26946. if (firstItemType === 'string') {
  26947. ret.name = options[0];
  26948. }
  26949. else if (firstItemType === 'number') {
  26950. ret.x = options[0];
  26951. }
  26952. i++;
  26953. }
  26954. while (j < valueCount) {
  26955. // Skip undefined positions for keys
  26956. if (!keys || typeof options[i] !== 'undefined') {
  26957. if (pointArrayMap[j].indexOf('.') > 0) {
  26958. // Handle nested keys, e.g. ['color.pattern.image']
  26959. // Avoid function call unless necessary.
  26960. Point.prototype.setNestedProperty(ret, options[i], pointArrayMap[j]);
  26961. }
  26962. else {
  26963. ret[pointArrayMap[j]] = options[i];
  26964. }
  26965. }
  26966. i++;
  26967. j++;
  26968. }
  26969. }
  26970. else if (typeof options === 'object') {
  26971. ret = options;
  26972. // This is the fastest way to detect if there are individual point
  26973. // dataLabels that need to be considered in drawDataLabels. These
  26974. // can only occur in object configs.
  26975. if (options.dataLabels) {
  26976. series._hasPointLabels = true;
  26977. }
  26978. // Same approach as above for markers
  26979. if (options.marker) {
  26980. series._hasPointMarkers = true;
  26981. }
  26982. }
  26983. return ret;
  26984. };
  26985. /**
  26986. * @private
  26987. * @function Highcharts.Point#resolveColor
  26988. * @return {void}
  26989. */
  26990. Point.prototype.resolveColor = function () {
  26991. var series = this.series,
  26992. colors,
  26993. optionsChart = series.chart.options.chart,
  26994. colorCount = optionsChart.colorCount,
  26995. styledMode = series.chart.styledMode,
  26996. colorIndex,
  26997. color;
  26998. // remove points nonZonedColor for later recalculation
  26999. delete this.nonZonedColor;
  27000. if (series.options.colorByPoint) {
  27001. if (!styledMode) {
  27002. colors = series.options.colors || series.chart.options.colors;
  27003. color = colors[series.colorCounter];
  27004. colorCount = colors.length;
  27005. }
  27006. colorIndex = series.colorCounter;
  27007. series.colorCounter++;
  27008. // loop back to zero
  27009. if (series.colorCounter === colorCount) {
  27010. series.colorCounter = 0;
  27011. }
  27012. }
  27013. else {
  27014. if (!styledMode) {
  27015. color = series.color;
  27016. }
  27017. colorIndex = series.colorIndex;
  27018. }
  27019. this.colorIndex = pick(this.options.colorIndex, colorIndex);
  27020. /**
  27021. * The point's current color.
  27022. *
  27023. * @name Highcharts.Point#color
  27024. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject|undefined}
  27025. */
  27026. this.color = pick(this.options.color, color);
  27027. };
  27028. /**
  27029. * Set a value in an object, on the property defined by key. The key
  27030. * supports nested properties using dot notation. The function modifies the
  27031. * input object and does not make a copy.
  27032. *
  27033. * @function Highcharts.Point#setNestedProperty<T>
  27034. *
  27035. * @param {T} object
  27036. * The object to set the value on.
  27037. *
  27038. * @param {*} value
  27039. * The value to set.
  27040. *
  27041. * @param {string} key
  27042. * Key to the property to set.
  27043. *
  27044. * @return {T}
  27045. * The modified object.
  27046. */
  27047. Point.prototype.setNestedProperty = function (object, value, key) {
  27048. var nestedKeys = key.split('.');
  27049. nestedKeys.reduce(function (result, key, i, arr) {
  27050. var isLastKey = arr.length - 1 === i;
  27051. result[key] = (isLastKey ?
  27052. value :
  27053. isObject(result[key], true) ?
  27054. result[key] :
  27055. {});
  27056. return result[key];
  27057. }, object);
  27058. return object;
  27059. };
  27060. /**
  27061. * Extendable method for formatting each point's tooltip line.
  27062. *
  27063. * @function Highcharts.Point#tooltipFormatter
  27064. *
  27065. * @param {string} pointFormat
  27066. * The point format.
  27067. *
  27068. * @return {string}
  27069. * A string to be concatenated in to the common tooltip text.
  27070. */
  27071. Point.prototype.tooltipFormatter = function (pointFormat) {
  27072. // Insert options for valueDecimals, valuePrefix, and valueSuffix
  27073. var series = this.series, seriesTooltipOptions = series.tooltipOptions, valueDecimals = pick(seriesTooltipOptions.valueDecimals, ''), valuePrefix = seriesTooltipOptions.valuePrefix || '', valueSuffix = seriesTooltipOptions.valueSuffix || '';
  27074. // Replace default point style with class name
  27075. if (series.chart.styledMode) {
  27076. pointFormat =
  27077. series.chart.tooltip.styledModeFormat(pointFormat);
  27078. }
  27079. // Loop over the point array map and replace unformatted values with
  27080. // sprintf formatting markup
  27081. (series.pointArrayMap || ['y']).forEach(function (key) {
  27082. key = '{point.' + key; // without the closing bracket
  27083. if (valuePrefix || valueSuffix) {
  27084. pointFormat = pointFormat.replace(RegExp(key + '}', 'g'), valuePrefix + key + '}' + valueSuffix);
  27085. }
  27086. pointFormat = pointFormat.replace(RegExp(key + '}', 'g'), key + ':,.' + valueDecimals + 'f}');
  27087. });
  27088. return format(pointFormat, {
  27089. point: this,
  27090. series: this.series
  27091. }, series.chart);
  27092. };
  27093. /**
  27094. * Update point with new options (typically x/y data) and optionally redraw
  27095. * the series.
  27096. *
  27097. * @sample highcharts/members/point-update-column/
  27098. * Update column value
  27099. * @sample highcharts/members/point-update-pie/
  27100. * Update pie slice
  27101. * @sample maps/members/point-update/
  27102. * Update map area value in Highmaps
  27103. *
  27104. * @function Highcharts.Point#update
  27105. *
  27106. * @param {Highcharts.PointOptionsType} options
  27107. * The point options. Point options are handled as described under
  27108. * the `series.type.data` item for each series type. For example
  27109. * for a line series, if options is a single number, the point will
  27110. * be given that number as the marin y value. If it is an array, it
  27111. * will be interpreted as x and y values respectively. If it is an
  27112. * object, advanced options are applied.
  27113. *
  27114. * @param {boolean} [redraw=true]
  27115. * Whether to redraw the chart after the point is updated. If doing
  27116. * more operations on the chart, it is best practice to set
  27117. * `redraw` to false and call `chart.redraw()` after.
  27118. *
  27119. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  27120. * Whether to apply animation, and optionally animation
  27121. * configuration.
  27122. *
  27123. * @fires Highcharts.Point#event:update
  27124. */
  27125. Point.prototype.update = function (options, redraw, animation, runEvent) {
  27126. var point = this,
  27127. series = point.series,
  27128. graphic = point.graphic,
  27129. i,
  27130. chart = series.chart,
  27131. seriesOptions = series.options;
  27132. redraw = pick(redraw, true);
  27133. /**
  27134. * @private
  27135. */
  27136. function update() {
  27137. point.applyOptions(options);
  27138. // Update visuals, #4146
  27139. // Handle dummy graphic elements for a11y, #12718
  27140. var hasDummyGraphic = graphic && point.hasDummyGraphic;
  27141. var shouldDestroyGraphic = point.y === null ? !hasDummyGraphic : hasDummyGraphic;
  27142. if (graphic && shouldDestroyGraphic) {
  27143. point.graphic = graphic.destroy();
  27144. delete point.hasDummyGraphic;
  27145. }
  27146. if (isObject(options, true)) {
  27147. // Destroy so we can get new elements
  27148. if (graphic && graphic.element) {
  27149. // "null" is also a valid symbol
  27150. if (options &&
  27151. options.marker &&
  27152. typeof options.marker.symbol !== 'undefined') {
  27153. point.graphic = graphic.destroy();
  27154. }
  27155. }
  27156. if (options && options.dataLabels && point.dataLabel) {
  27157. point.dataLabel = point.dataLabel.destroy(); // #2468
  27158. }
  27159. if (point.connector) {
  27160. point.connector = point.connector.destroy(); // #7243
  27161. }
  27162. }
  27163. // record changes in the parallel arrays
  27164. i = point.index;
  27165. series.updateParallelArrays(point, i);
  27166. // Record the options to options.data. If the old or the new config
  27167. // is an object, use point options, otherwise use raw options
  27168. // (#4701, #4916).
  27169. seriesOptions.data[i] = (isObject(seriesOptions.data[i], true) ||
  27170. isObject(options, true)) ?
  27171. point.options :
  27172. pick(options, seriesOptions.data[i]);
  27173. // redraw
  27174. series.isDirty = series.isDirtyData = true;
  27175. if (!series.fixedBox && series.hasCartesianSeries) { // #1906, #2320
  27176. chart.isDirtyBox = true;
  27177. }
  27178. if (seriesOptions.legendType === 'point') { // #1831, #1885
  27179. chart.isDirtyLegend = true;
  27180. }
  27181. if (redraw) {
  27182. chart.redraw(animation);
  27183. }
  27184. }
  27185. // Fire the event with a default handler of doing the update
  27186. if (runEvent === false) { // When called from setData
  27187. update();
  27188. }
  27189. else {
  27190. point.firePointEvent('update', { options: options }, update);
  27191. }
  27192. };
  27193. /**
  27194. * Remove a point and optionally redraw the series and if necessary the axes
  27195. *
  27196. * @sample highcharts/plotoptions/series-point-events-remove/
  27197. * Remove point and confirm
  27198. * @sample highcharts/members/point-remove/
  27199. * Remove pie slice
  27200. * @sample maps/members/point-remove/
  27201. * Remove selected points in Highmaps
  27202. *
  27203. * @function Highcharts.Point#remove
  27204. *
  27205. * @param {boolean} [redraw=true]
  27206. * Whether to redraw the chart or wait for an explicit call. When
  27207. * doing more operations on the chart, for example running
  27208. * `point.remove()` in a loop, it is best practice to set `redraw`
  27209. * to false and call `chart.redraw()` after.
  27210. *
  27211. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=false]
  27212. * Whether to apply animation, and optionally animation
  27213. * configuration.
  27214. */
  27215. Point.prototype.remove = function (redraw, animation) {
  27216. this.series.removePoint(this.series.data.indexOf(this), redraw, animation);
  27217. };
  27218. /**
  27219. * Toggle the selection status of a point.
  27220. *
  27221. * @see Highcharts.Chart#getSelectedPoints
  27222. *
  27223. * @sample highcharts/members/point-select/
  27224. * Select a point from a button
  27225. * @sample highcharts/chart/events-selection-points/
  27226. * Select a range of points through a drag selection
  27227. * @sample maps/series/data-id/
  27228. * Select a point in Highmaps
  27229. *
  27230. * @function Highcharts.Point#select
  27231. *
  27232. * @param {boolean} [selected]
  27233. * When `true`, the point is selected. When `false`, the point is
  27234. * unselected. When `null` or `undefined`, the selection state is toggled.
  27235. *
  27236. * @param {boolean} [accumulate=false]
  27237. * When `true`, the selection is added to other selected points.
  27238. * When `false`, other selected points are deselected. Internally in
  27239. * Highcharts, when
  27240. * [allowPointSelect](https://api.highcharts.com/highcharts/plotOptions.series.allowPointSelect)
  27241. * is `true`, selected points are accumulated on Control, Shift or Cmd
  27242. * clicking the point.
  27243. *
  27244. * @fires Highcharts.Point#event:select
  27245. * @fires Highcharts.Point#event:unselect
  27246. */
  27247. Point.prototype.select = function (selected, accumulate) {
  27248. var point = this,
  27249. series = point.series,
  27250. chart = series.chart;
  27251. selected = pick(selected, !point.selected);
  27252. this.selectedStaging = selected;
  27253. // fire the event with the default handler
  27254. point.firePointEvent(selected ? 'select' : 'unselect', { accumulate: accumulate }, function () {
  27255. /**
  27256. * Whether the point is selected or not.
  27257. *
  27258. * @see Point#select
  27259. * @see Chart#getSelectedPoints
  27260. *
  27261. * @name Highcharts.Point#selected
  27262. * @type {boolean}
  27263. */
  27264. point.selected = point.options.selected = selected;
  27265. series.options.data[series.data.indexOf(point)] =
  27266. point.options;
  27267. point.setState(selected && 'select');
  27268. // unselect all other points unless Ctrl or Cmd + click
  27269. if (!accumulate) {
  27270. chart.getSelectedPoints().forEach(function (loopPoint) {
  27271. var loopSeries = loopPoint.series;
  27272. if (loopPoint.selected && loopPoint !== point) {
  27273. loopPoint.selected = loopPoint.options.selected =
  27274. false;
  27275. loopSeries.options.data[loopSeries.data.indexOf(loopPoint)] = loopPoint.options;
  27276. // Programatically selecting a point should restore
  27277. // normal state, but when click happened on other
  27278. // point, set inactive state to match other points
  27279. loopPoint.setState(chart.hoverPoints &&
  27280. loopSeries.options.inactiveOtherPoints ?
  27281. 'inactive' : '');
  27282. loopPoint.firePointEvent('unselect');
  27283. }
  27284. });
  27285. }
  27286. });
  27287. delete this.selectedStaging;
  27288. };
  27289. /**
  27290. * Runs on mouse over the point. Called internally from mouse and touch
  27291. * events.
  27292. *
  27293. * @function Highcharts.Point#onMouseOver
  27294. *
  27295. * @param {Highcharts.PointerEventObject} [e]
  27296. * The event arguments.
  27297. */
  27298. Point.prototype.onMouseOver = function (e) {
  27299. var point = this,
  27300. series = point.series,
  27301. chart = series.chart,
  27302. pointer = chart.pointer;
  27303. e = e ?
  27304. pointer.normalize(e) :
  27305. // In cases where onMouseOver is called directly without an event
  27306. pointer.getChartCoordinatesFromPoint(point, chart.inverted);
  27307. pointer.runPointActions(e, point);
  27308. };
  27309. /**
  27310. * Runs on mouse out from the point. Called internally from mouse and touch
  27311. * events.
  27312. *
  27313. * @function Highcharts.Point#onMouseOut
  27314. * @fires Highcharts.Point#event:mouseOut
  27315. */
  27316. Point.prototype.onMouseOut = function () {
  27317. var point = this,
  27318. chart = point.series.chart;
  27319. point.firePointEvent('mouseOut');
  27320. if (!point.series.options.inactiveOtherPoints) {
  27321. (chart.hoverPoints || []).forEach(function (p) {
  27322. p.setState();
  27323. });
  27324. }
  27325. chart.hoverPoints = chart.hoverPoint = null;
  27326. };
  27327. /**
  27328. * Import events from the series' and point's options. Only do it on
  27329. * demand, to save processing time on hovering.
  27330. *
  27331. * @private
  27332. * @function Highcharts.Point#importEvents
  27333. */
  27334. Point.prototype.importEvents = function () {
  27335. if (!this.hasImportedEvents) {
  27336. var point_1 = this,
  27337. options = merge(point_1.series.options.point,
  27338. point_1.options),
  27339. events = options.events;
  27340. point_1.events = events;
  27341. objectEach(events, function (event, eventType) {
  27342. if (isFunction(event)) {
  27343. addEvent(point_1, eventType, event);
  27344. }
  27345. });
  27346. this.hasImportedEvents = true;
  27347. }
  27348. };
  27349. /**
  27350. * Set the point's state.
  27351. *
  27352. * @function Highcharts.Point#setState
  27353. *
  27354. * @param {Highcharts.PointStateValue|""} [state]
  27355. * The new state, can be one of `'hover'`, `'select'`, `'inactive'`,
  27356. * or `''` (an empty string), `'normal'` or `undefined` to set to
  27357. * normal state.
  27358. * @param {boolean} [move]
  27359. * State for animation.
  27360. *
  27361. * @fires Highcharts.Point#event:afterSetState
  27362. */
  27363. Point.prototype.setState = function (state, move) {
  27364. var point = this,
  27365. series = point.series,
  27366. previousState = point.state,
  27367. stateOptions = (series.options.states[state || 'normal'] ||
  27368. {}),
  27369. markerOptions = (defaultOptions.plotOptions[series.type].marker &&
  27370. series.options.marker),
  27371. normalDisabled = (markerOptions && markerOptions.enabled === false),
  27372. markerStateOptions = ((markerOptions &&
  27373. markerOptions.states &&
  27374. markerOptions.states[state || 'normal']) || {}),
  27375. stateDisabled = markerStateOptions.enabled === false,
  27376. stateMarkerGraphic = series.stateMarkerGraphic,
  27377. pointMarker = point.marker || {},
  27378. chart = series.chart,
  27379. halo = series.halo,
  27380. haloOptions,
  27381. markerAttribs,
  27382. pointAttribs,
  27383. pointAttribsAnimation,
  27384. hasMarkers = (markerOptions && series.markerAttribs),
  27385. newSymbol;
  27386. state = state || ''; // empty string
  27387. if (
  27388. // already has this state
  27389. (state === point.state && !move) ||
  27390. // selected points don't respond to hover
  27391. (point.selected && state !== 'select') ||
  27392. // series' state options is disabled
  27393. (stateOptions.enabled === false) ||
  27394. // general point marker's state options is disabled
  27395. (state && (stateDisabled ||
  27396. (normalDisabled &&
  27397. markerStateOptions.enabled === false))) ||
  27398. // individual point marker's state options is disabled
  27399. (state &&
  27400. pointMarker.states &&
  27401. pointMarker.states[state] &&
  27402. pointMarker.states[state].enabled === false) // #1610
  27403. ) {
  27404. return;
  27405. }
  27406. point.state = state;
  27407. if (hasMarkers) {
  27408. markerAttribs = series.markerAttribs(point, state);
  27409. }
  27410. // Apply hover styles to the existing point
  27411. // Prevent from dummy null points (#14966)
  27412. if (point.graphic && !point.hasDummyGraphic) {
  27413. if (previousState) {
  27414. point.graphic.removeClass('highcharts-point-' + previousState);
  27415. }
  27416. if (state) {
  27417. point.graphic.addClass('highcharts-point-' + state);
  27418. }
  27419. if (!chart.styledMode) {
  27420. pointAttribs = series.pointAttribs(point, state);
  27421. pointAttribsAnimation = pick(chart.options.chart.animation, stateOptions.animation);
  27422. // Some inactive points (e.g. slices in pie) should apply
  27423. // oppacity also for it's labels
  27424. if (series.options.inactiveOtherPoints && isNumber(pointAttribs.opacity)) {
  27425. (point.dataLabels || []).forEach(function (label) {
  27426. if (label) {
  27427. label.animate({
  27428. opacity: pointAttribs.opacity
  27429. }, pointAttribsAnimation);
  27430. }
  27431. });
  27432. if (point.connector) {
  27433. point.connector.animate({
  27434. opacity: pointAttribs.opacity
  27435. }, pointAttribsAnimation);
  27436. }
  27437. }
  27438. point.graphic.animate(pointAttribs, pointAttribsAnimation);
  27439. }
  27440. if (markerAttribs) {
  27441. point.graphic.animate(markerAttribs, pick(
  27442. // Turn off globally:
  27443. chart.options.chart.animation, markerStateOptions.animation, markerOptions.animation));
  27444. }
  27445. // Zooming in from a range with no markers to a range with markers
  27446. if (stateMarkerGraphic) {
  27447. stateMarkerGraphic.hide();
  27448. }
  27449. }
  27450. else {
  27451. // if a graphic is not applied to each point in the normal state,
  27452. // create a shared graphic for the hover state
  27453. if (state && markerStateOptions) {
  27454. newSymbol = pointMarker.symbol || series.symbol;
  27455. // If the point has another symbol than the previous one, throw
  27456. // away the state marker graphic and force a new one (#1459)
  27457. if (stateMarkerGraphic &&
  27458. stateMarkerGraphic.currentSymbol !== newSymbol) {
  27459. stateMarkerGraphic = stateMarkerGraphic.destroy();
  27460. }
  27461. // Add a new state marker graphic
  27462. if (markerAttribs) {
  27463. if (!stateMarkerGraphic) {
  27464. if (newSymbol) {
  27465. series.stateMarkerGraphic = stateMarkerGraphic =
  27466. chart.renderer
  27467. .symbol(newSymbol, markerAttribs.x, markerAttribs.y, markerAttribs.width, markerAttribs.height)
  27468. .add(series.markerGroup);
  27469. stateMarkerGraphic.currentSymbol = newSymbol;
  27470. }
  27471. // Move the existing graphic
  27472. }
  27473. else {
  27474. stateMarkerGraphic[move ? 'animate' : 'attr']({
  27475. x: markerAttribs.x,
  27476. y: markerAttribs.y
  27477. });
  27478. }
  27479. }
  27480. if (!chart.styledMode && stateMarkerGraphic) {
  27481. stateMarkerGraphic.attr(series.pointAttribs(point, state));
  27482. }
  27483. }
  27484. if (stateMarkerGraphic) {
  27485. stateMarkerGraphic[state && point.isInside ? 'show' : 'hide'](); // #2450
  27486. stateMarkerGraphic.element.point = point; // #4310
  27487. }
  27488. }
  27489. // Show me your halo
  27490. haloOptions = stateOptions.halo;
  27491. var markerGraphic = (point.graphic || stateMarkerGraphic);
  27492. var markerVisibility = (markerGraphic && markerGraphic.visibility || 'inherit');
  27493. if (haloOptions &&
  27494. haloOptions.size &&
  27495. markerGraphic &&
  27496. markerVisibility !== 'hidden' &&
  27497. !point.isCluster) {
  27498. if (!halo) {
  27499. series.halo = halo = chart.renderer.path()
  27500. // #5818, #5903, #6705
  27501. .add(markerGraphic.parentGroup);
  27502. }
  27503. halo.show()[move ? 'animate' : 'attr']({
  27504. d: point.haloPath(haloOptions.size)
  27505. });
  27506. halo.attr({
  27507. 'class': 'highcharts-halo highcharts-color-' +
  27508. pick(point.colorIndex, series.colorIndex) +
  27509. (point.className ? ' ' + point.className : ''),
  27510. 'visibility': markerVisibility,
  27511. 'zIndex': -1 // #4929, #8276
  27512. });
  27513. halo.point = point; // #6055
  27514. if (!chart.styledMode) {
  27515. halo.attr(extend({
  27516. 'fill': point.color || series.color,
  27517. 'fill-opacity': haloOptions.opacity
  27518. }, AST.filterUserAttributes(haloOptions.attributes || {})));
  27519. }
  27520. }
  27521. else if (halo && halo.point && halo.point.haloPath) {
  27522. // Animate back to 0 on the current halo point (#6055)
  27523. halo.animate({ d: halo.point.haloPath(0) }, null,
  27524. // Hide after unhovering. The `complete` callback runs in the
  27525. // halo's context (#7681).
  27526. halo.hide);
  27527. }
  27528. fireEvent(point, 'afterSetState', { state: state });
  27529. };
  27530. /**
  27531. * Get the path definition for the halo, which is usually a shadow-like
  27532. * circle around the currently hovered point.
  27533. *
  27534. * @function Highcharts.Point#haloPath
  27535. *
  27536. * @param {number} size
  27537. * The radius of the circular halo.
  27538. *
  27539. * @return {Highcharts.SVGPathArray}
  27540. * The path definition.
  27541. */
  27542. Point.prototype.haloPath = function (size) {
  27543. var series = this.series,
  27544. chart = series.chart;
  27545. return chart.renderer.symbols.circle(Math.floor(this.plotX) - size, this.plotY - size, size * 2, size * 2);
  27546. };
  27547. return Point;
  27548. }());
  27549. H.Point = Point;
  27550. return Point;
  27551. });
  27552. _registerModule(_modules, 'Core/Legend.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/FormatUtilities.js'], _modules['Core/Globals.js'], _modules['Core/Series/Point.js'], _modules['Core/Utilities.js']], function (A, F, H, Point, U) {
  27553. /* *
  27554. *
  27555. * (c) 2010-2021 Torstein Honsi
  27556. *
  27557. * License: www.highcharts.com/license
  27558. *
  27559. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  27560. *
  27561. * */
  27562. var animObject = A.animObject,
  27563. setAnimation = A.setAnimation;
  27564. var format = F.format;
  27565. var isFirefox = H.isFirefox,
  27566. marginNames = H.marginNames,
  27567. win = H.win;
  27568. var addEvent = U.addEvent,
  27569. createElement = U.createElement,
  27570. css = U.css,
  27571. defined = U.defined,
  27572. discardElement = U.discardElement,
  27573. find = U.find,
  27574. fireEvent = U.fireEvent,
  27575. isNumber = U.isNumber,
  27576. merge = U.merge,
  27577. pick = U.pick,
  27578. relativeLength = U.relativeLength,
  27579. stableSort = U.stableSort,
  27580. syncTimeout = U.syncTimeout,
  27581. wrap = U.wrap;
  27582. /**
  27583. * Gets fired when the legend item belonging to a point is clicked. The default
  27584. * action is to toggle the visibility of the point. This can be prevented by
  27585. * returning `false` or calling `event.preventDefault()`.
  27586. *
  27587. * @callback Highcharts.PointLegendItemClickCallbackFunction
  27588. *
  27589. * @param {Highcharts.Point} this
  27590. * The point on which the event occured.
  27591. *
  27592. * @param {Highcharts.PointLegendItemClickEventObject} event
  27593. * The event that occured.
  27594. */
  27595. /**
  27596. * Information about the legend click event.
  27597. *
  27598. * @interface Highcharts.PointLegendItemClickEventObject
  27599. */ /**
  27600. * Related browser event.
  27601. * @name Highcharts.PointLegendItemClickEventObject#browserEvent
  27602. * @type {Highcharts.PointerEvent}
  27603. */ /**
  27604. * Prevent the default action of toggle the visibility of the point.
  27605. * @name Highcharts.PointLegendItemClickEventObject#preventDefault
  27606. * @type {Function}
  27607. */ /**
  27608. * Related point.
  27609. * @name Highcharts.PointLegendItemClickEventObject#target
  27610. * @type {Highcharts.Point}
  27611. */ /**
  27612. * Event type.
  27613. * @name Highcharts.PointLegendItemClickEventObject#type
  27614. * @type {"legendItemClick"}
  27615. */
  27616. /**
  27617. * Gets fired when the legend item belonging to a series is clicked. The default
  27618. * action is to toggle the visibility of the series. This can be prevented by
  27619. * returning `false` or calling `event.preventDefault()`.
  27620. *
  27621. * @callback Highcharts.SeriesLegendItemClickCallbackFunction
  27622. *
  27623. * @param {Highcharts.Series} this
  27624. * The series where the event occured.
  27625. *
  27626. * @param {Highcharts.SeriesLegendItemClickEventObject} event
  27627. * The event that occured.
  27628. */
  27629. /**
  27630. * Information about the legend click event.
  27631. *
  27632. * @interface Highcharts.SeriesLegendItemClickEventObject
  27633. */ /**
  27634. * Related browser event.
  27635. * @name Highcharts.SeriesLegendItemClickEventObject#browserEvent
  27636. * @type {Highcharts.PointerEvent}
  27637. */ /**
  27638. * Prevent the default action of toggle the visibility of the series.
  27639. * @name Highcharts.SeriesLegendItemClickEventObject#preventDefault
  27640. * @type {Function}
  27641. */ /**
  27642. * Related series.
  27643. * @name Highcharts.SeriesLegendItemClickEventObject#target
  27644. * @type {Highcharts.Series}
  27645. */ /**
  27646. * Event type.
  27647. * @name Highcharts.SeriesLegendItemClickEventObject#type
  27648. * @type {"legendItemClick"}
  27649. */
  27650. /* eslint-disable no-invalid-this, valid-jsdoc */
  27651. /**
  27652. * The overview of the chart's series. The legend object is instanciated
  27653. * internally in the chart constructor, and is available from the `chart.legend`
  27654. * property. Each chart has only one legend.
  27655. *
  27656. * @class
  27657. * @name Highcharts.Legend
  27658. *
  27659. * @param {Highcharts.Chart} chart
  27660. * The chart instance.
  27661. *
  27662. * @param {Highcharts.LegendOptions} options
  27663. * Legend options.
  27664. */
  27665. var Legend = /** @class */ (function () {
  27666. /* *
  27667. *
  27668. * Constructors
  27669. *
  27670. * */
  27671. function Legend(chart, options) {
  27672. /* *
  27673. *
  27674. * Properties
  27675. *
  27676. * */
  27677. this.allItems = [];
  27678. this.box = void 0;
  27679. this.contentGroup = void 0;
  27680. this.display = false;
  27681. this.group = void 0;
  27682. this.initialItemY = 0;
  27683. this.itemHeight = 0;
  27684. this.itemMarginBottom = 0;
  27685. this.itemMarginTop = 0;
  27686. this.itemX = 0;
  27687. this.itemY = 0;
  27688. this.lastItemY = 0;
  27689. this.lastLineHeight = 0;
  27690. this.legendHeight = 0;
  27691. this.legendWidth = 0;
  27692. this.maxItemWidth = 0;
  27693. this.maxLegendWidth = 0;
  27694. this.offsetWidth = 0;
  27695. this.options = {};
  27696. this.padding = 0;
  27697. this.pages = [];
  27698. this.proximate = false;
  27699. this.scrollGroup = void 0;
  27700. this.symbolHeight = 0;
  27701. this.symbolWidth = 0;
  27702. this.titleHeight = 0;
  27703. this.totalItemWidth = 0;
  27704. this.widthOption = 0;
  27705. this.chart = chart;
  27706. this.init(chart, options);
  27707. }
  27708. /* *
  27709. *
  27710. * Functions
  27711. *
  27712. * */
  27713. /**
  27714. * Initialize the legend.
  27715. *
  27716. * @private
  27717. * @function Highcharts.Legend#init
  27718. *
  27719. * @param {Highcharts.Chart} chart
  27720. * The chart instance.
  27721. *
  27722. * @param {Highcharts.LegendOptions} options
  27723. * Legend options.
  27724. */
  27725. Legend.prototype.init = function (chart, options) {
  27726. /**
  27727. * Chart of this legend.
  27728. *
  27729. * @readonly
  27730. * @name Highcharts.Legend#chart
  27731. * @type {Highcharts.Chart}
  27732. */
  27733. this.chart = chart;
  27734. this.setOptions(options);
  27735. if (options.enabled) {
  27736. // Render it
  27737. this.render();
  27738. // move checkboxes
  27739. addEvent(this.chart, 'endResize', function () {
  27740. this.legend.positionCheckboxes();
  27741. });
  27742. if (this.proximate) {
  27743. this.unchartrender = addEvent(this.chart, 'render', function () {
  27744. this.legend.proximatePositions();
  27745. this.legend.positionItems();
  27746. });
  27747. }
  27748. else if (this.unchartrender) {
  27749. this.unchartrender();
  27750. }
  27751. }
  27752. };
  27753. /**
  27754. * @private
  27755. * @function Highcharts.Legend#setOptions
  27756. * @param {Highcharts.LegendOptions} options
  27757. */
  27758. Legend.prototype.setOptions = function (options) {
  27759. var padding = pick(options.padding, 8);
  27760. /**
  27761. * Legend options.
  27762. *
  27763. * @readonly
  27764. * @name Highcharts.Legend#options
  27765. * @type {Highcharts.LegendOptions}
  27766. */
  27767. this.options = options;
  27768. if (!this.chart.styledMode) {
  27769. this.itemStyle = options.itemStyle;
  27770. this.itemHiddenStyle = merge(this.itemStyle, options.itemHiddenStyle);
  27771. }
  27772. this.itemMarginTop = options.itemMarginTop || 0;
  27773. this.itemMarginBottom = options.itemMarginBottom || 0;
  27774. this.padding = padding;
  27775. this.initialItemY = padding - 5; // 5 is pixels above the text
  27776. this.symbolWidth = pick(options.symbolWidth, 16);
  27777. this.pages = [];
  27778. this.proximate = options.layout === 'proximate' && !this.chart.inverted;
  27779. this.baseline = void 0; // #12705: baseline has to be reset on every update
  27780. };
  27781. /**
  27782. * Update the legend with new options. Equivalent to running `chart.update`
  27783. * with a legend configuration option.
  27784. *
  27785. * @sample highcharts/legend/legend-update/
  27786. * Legend update
  27787. *
  27788. * @function Highcharts.Legend#update
  27789. *
  27790. * @param {Highcharts.LegendOptions} options
  27791. * Legend options.
  27792. *
  27793. * @param {boolean} [redraw=true]
  27794. * Whether to redraw the chart after the axis is altered. If doing more
  27795. * operations on the chart, it is a good idea to set redraw to false and
  27796. * call {@link Chart#redraw} after. Whether to redraw the chart.
  27797. *
  27798. * @fires Highcharts.Legends#event:afterUpdate
  27799. */
  27800. Legend.prototype.update = function (options, redraw) {
  27801. var chart = this.chart;
  27802. this.setOptions(merge(true, this.options, options));
  27803. this.destroy();
  27804. chart.isDirtyLegend = chart.isDirtyBox = true;
  27805. if (pick(redraw, true)) {
  27806. chart.redraw();
  27807. }
  27808. fireEvent(this, 'afterUpdate');
  27809. };
  27810. /**
  27811. * Set the colors for the legend item.
  27812. *
  27813. * @private
  27814. * @function Highcharts.Legend#colorizeItem
  27815. * @param {Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series} item
  27816. * A Series or Point instance
  27817. * @param {boolean} [visible=false]
  27818. * Dimmed or colored
  27819. *
  27820. * @todo
  27821. * Make events official: Fires the event `afterColorizeItem`.
  27822. */
  27823. Legend.prototype.colorizeItem = function (item, visible) {
  27824. item.legendGroup[visible ? 'removeClass' : 'addClass']('highcharts-legend-item-hidden');
  27825. if (!this.chart.styledMode) {
  27826. var legend = this,
  27827. options = legend.options,
  27828. legendItem = item.legendItem,
  27829. legendLine = item.legendLine,
  27830. legendSymbol = item.legendSymbol,
  27831. hiddenColor = legend.itemHiddenStyle.color,
  27832. textColor = visible ?
  27833. options.itemStyle.color :
  27834. hiddenColor,
  27835. symbolColor = visible ?
  27836. (item.color || hiddenColor) :
  27837. hiddenColor,
  27838. markerOptions = item.options && item.options.marker,
  27839. symbolAttr = { fill: symbolColor };
  27840. if (legendItem) {
  27841. legendItem.css({
  27842. fill: textColor,
  27843. color: textColor // #1553, oldIE
  27844. });
  27845. }
  27846. if (legendLine) {
  27847. legendLine.attr({ stroke: symbolColor });
  27848. }
  27849. if (legendSymbol) {
  27850. // Apply marker options
  27851. if (markerOptions && legendSymbol.isMarker) { // #585
  27852. symbolAttr = item.pointAttribs();
  27853. if (!visible) {
  27854. // #6769
  27855. symbolAttr.stroke = symbolAttr.fill = hiddenColor;
  27856. }
  27857. }
  27858. legendSymbol.attr(symbolAttr);
  27859. }
  27860. }
  27861. fireEvent(this, 'afterColorizeItem', { item: item, visible: visible });
  27862. };
  27863. /**
  27864. * @private
  27865. * @function Highcharts.Legend#positionItems
  27866. */
  27867. Legend.prototype.positionItems = function () {
  27868. // Now that the legend width and height are established, put the items
  27869. // in the final position
  27870. this.allItems.forEach(this.positionItem, this);
  27871. if (!this.chart.isResizing) {
  27872. this.positionCheckboxes();
  27873. }
  27874. };
  27875. /**
  27876. * Position the legend item.
  27877. *
  27878. * @private
  27879. * @function Highcharts.Legend#positionItem
  27880. * @param {Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series} item
  27881. * The item to position
  27882. */
  27883. Legend.prototype.positionItem = function (item) {
  27884. var _this = this;
  27885. var legend = this,
  27886. options = legend.options,
  27887. symbolPadding = options.symbolPadding,
  27888. ltr = !options.rtl,
  27889. legendItemPos = item._legendItemPos,
  27890. itemX = legendItemPos[0],
  27891. itemY = legendItemPos[1],
  27892. checkbox = item.checkbox,
  27893. legendGroup = item.legendGroup;
  27894. if (legendGroup && legendGroup.element) {
  27895. var attribs = {
  27896. translateX: ltr ?
  27897. itemX :
  27898. legend.legendWidth - itemX - 2 * symbolPadding - 4,
  27899. translateY: itemY
  27900. };
  27901. var complete = function () {
  27902. fireEvent(_this, 'afterPositionItem', { item: item });
  27903. };
  27904. if (defined(legendGroup.translateY)) {
  27905. legendGroup.animate(attribs, void 0, complete);
  27906. }
  27907. else {
  27908. legendGroup.attr(attribs);
  27909. complete();
  27910. }
  27911. }
  27912. if (checkbox) {
  27913. checkbox.x = itemX;
  27914. checkbox.y = itemY;
  27915. }
  27916. };
  27917. /**
  27918. * Destroy a single legend item, used internally on removing series items.
  27919. *
  27920. * @private
  27921. * @function Highcharts.Legend#destroyItem
  27922. * @param {Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series} item
  27923. * The item to remove
  27924. */
  27925. Legend.prototype.destroyItem = function (item) {
  27926. var checkbox = item.checkbox;
  27927. // destroy SVG elements
  27928. ['legendItem', 'legendLine', 'legendSymbol', 'legendGroup'].forEach(function (key) {
  27929. if (item[key]) {
  27930. item[key] = item[key].destroy();
  27931. }
  27932. });
  27933. if (checkbox) {
  27934. discardElement(item.checkbox);
  27935. }
  27936. };
  27937. /**
  27938. * Destroy the legend. Used internally. To reflow objects, `chart.redraw`
  27939. * must be called after destruction.
  27940. *
  27941. * @private
  27942. * @function Highcharts.Legend#destroy
  27943. */
  27944. Legend.prototype.destroy = function () {
  27945. /**
  27946. * @private
  27947. * @param {string} key
  27948. * @return {void}
  27949. */
  27950. function destroyItems(key) {
  27951. if (this[key]) {
  27952. this[key] = this[key].destroy();
  27953. }
  27954. }
  27955. // Destroy items
  27956. this.getAllItems().forEach(function (item) {
  27957. ['legendItem', 'legendGroup'].forEach(destroyItems, item);
  27958. });
  27959. // Destroy legend elements
  27960. [
  27961. 'clipRect',
  27962. 'up',
  27963. 'down',
  27964. 'pager',
  27965. 'nav',
  27966. 'box',
  27967. 'title',
  27968. 'group'
  27969. ].forEach(destroyItems, this);
  27970. this.display = null; // Reset in .render on update.
  27971. };
  27972. /**
  27973. * Position the checkboxes after the width is determined.
  27974. *
  27975. * @private
  27976. * @function Highcharts.Legend#positionCheckboxes
  27977. */
  27978. Legend.prototype.positionCheckboxes = function () {
  27979. var alignAttr = this.group && this.group.alignAttr,
  27980. translateY,
  27981. clipHeight = this.clipHeight || this.legendHeight,
  27982. titleHeight = this.titleHeight;
  27983. if (alignAttr) {
  27984. translateY = alignAttr.translateY;
  27985. this.allItems.forEach(function (item) {
  27986. var checkbox = item.checkbox,
  27987. top;
  27988. if (checkbox) {
  27989. top = translateY + titleHeight + checkbox.y +
  27990. (this.scrollOffset || 0) + 3;
  27991. css(checkbox, {
  27992. left: (alignAttr.translateX + item.checkboxOffset +
  27993. checkbox.x - 20) + 'px',
  27994. top: top + 'px',
  27995. display: this.proximate || (top > translateY - 6 &&
  27996. top < translateY + clipHeight - 6) ?
  27997. '' :
  27998. 'none'
  27999. });
  28000. }
  28001. }, this);
  28002. }
  28003. };
  28004. /**
  28005. * Render the legend title on top of the legend.
  28006. *
  28007. * @private
  28008. * @function Highcharts.Legend#renderTitle
  28009. */
  28010. Legend.prototype.renderTitle = function () {
  28011. var options = this.options,
  28012. padding = this.padding,
  28013. titleOptions = options.title,
  28014. titleHeight = 0,
  28015. bBox;
  28016. if (titleOptions.text) {
  28017. if (!this.title) {
  28018. /**
  28019. * SVG element of the legend title.
  28020. *
  28021. * @readonly
  28022. * @name Highcharts.Legend#title
  28023. * @type {Highcharts.SVGElement}
  28024. */
  28025. this.title = this.chart.renderer.label(titleOptions.text, padding - 3, padding - 4, null, null, null, options.useHTML, null, 'legend-title')
  28026. .attr({ zIndex: 1 });
  28027. if (!this.chart.styledMode) {
  28028. this.title.css(titleOptions.style);
  28029. }
  28030. this.title.add(this.group);
  28031. }
  28032. // Set the max title width (#7253)
  28033. if (!titleOptions.width) {
  28034. this.title.css({
  28035. width: this.maxLegendWidth + 'px'
  28036. });
  28037. }
  28038. bBox = this.title.getBBox();
  28039. titleHeight = bBox.height;
  28040. this.offsetWidth = bBox.width; // #1717
  28041. this.contentGroup.attr({ translateY: titleHeight });
  28042. }
  28043. this.titleHeight = titleHeight;
  28044. };
  28045. /**
  28046. * Set the legend item text.
  28047. *
  28048. * @function Highcharts.Legend#setText
  28049. * @param {Highcharts.Point|Highcharts.Series} item
  28050. * The item for which to update the text in the legend.
  28051. */
  28052. Legend.prototype.setText = function (item) {
  28053. var options = this.options;
  28054. item.legendItem.attr({
  28055. text: options.labelFormat ?
  28056. format(options.labelFormat, item, this.chart) :
  28057. options.labelFormatter.call(item)
  28058. });
  28059. };
  28060. /**
  28061. * Render a single specific legend item. Called internally from the `render`
  28062. * function.
  28063. *
  28064. * @private
  28065. * @function Highcharts.Legend#renderItem
  28066. * @param {Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series} item
  28067. * The item to render.
  28068. */
  28069. Legend.prototype.renderItem = function (item) {
  28070. var legend = this,
  28071. chart = legend.chart,
  28072. renderer = chart.renderer,
  28073. options = legend.options,
  28074. horizontal = options.layout === 'horizontal',
  28075. symbolWidth = legend.symbolWidth,
  28076. symbolPadding = options.symbolPadding || 0,
  28077. itemStyle = legend.itemStyle,
  28078. itemHiddenStyle = legend.itemHiddenStyle,
  28079. itemDistance = horizontal ? pick(options.itemDistance, 20) : 0,
  28080. ltr = !options.rtl,
  28081. bBox,
  28082. li = item.legendItem,
  28083. isSeries = !item.series,
  28084. series = !isSeries && item.series.drawLegendSymbol ?
  28085. item.series :
  28086. item,
  28087. seriesOptions = series.options,
  28088. showCheckbox = legend.createCheckboxForItem &&
  28089. seriesOptions &&
  28090. seriesOptions.showCheckbox,
  28091. // full width minus text width
  28092. itemExtraWidth = symbolWidth + symbolPadding +
  28093. itemDistance + (showCheckbox ? 20 : 0),
  28094. useHTML = options.useHTML,
  28095. itemClassName = item.options.className;
  28096. if (!li) { // generate it once, later move it
  28097. // Generate the group box, a group to hold the symbol and text. Text
  28098. // is to be appended in Legend class.
  28099. item.legendGroup = renderer
  28100. .g('legend-item')
  28101. .addClass('highcharts-' + series.type + '-series ' +
  28102. 'highcharts-color-' + item.colorIndex +
  28103. (itemClassName ? ' ' + itemClassName : '') +
  28104. (isSeries ?
  28105. ' highcharts-series-' + item.index :
  28106. ''))
  28107. .attr({ zIndex: 1 })
  28108. .add(legend.scrollGroup);
  28109. // Generate the list item text and add it to the group
  28110. item.legendItem = li = renderer.text('', ltr ?
  28111. symbolWidth + symbolPadding :
  28112. -symbolPadding, legend.baseline || 0, useHTML);
  28113. if (!chart.styledMode) {
  28114. // merge to prevent modifying original (#1021)
  28115. li.css(merge(item.visible ?
  28116. itemStyle :
  28117. itemHiddenStyle));
  28118. }
  28119. li
  28120. .attr({
  28121. align: ltr ? 'left' : 'right',
  28122. zIndex: 2
  28123. })
  28124. .add(item.legendGroup);
  28125. // Get the baseline for the first item - the font size is equal for
  28126. // all
  28127. if (!legend.baseline) {
  28128. legend.fontMetrics = renderer.fontMetrics(chart.styledMode ? 12 : itemStyle.fontSize, li);
  28129. legend.baseline =
  28130. legend.fontMetrics.f + 3 + legend.itemMarginTop;
  28131. li.attr('y', legend.baseline);
  28132. legend.symbolHeight =
  28133. options.symbolHeight || legend.fontMetrics.f;
  28134. if (options.squareSymbol) {
  28135. legend.symbolWidth = pick(options.symbolWidth, Math.max(legend.symbolHeight, 16));
  28136. itemExtraWidth = legend.symbolWidth + symbolPadding +
  28137. itemDistance + (showCheckbox ? 20 : 0);
  28138. if (ltr) {
  28139. li.attr('x', legend.symbolWidth + symbolPadding);
  28140. }
  28141. }
  28142. }
  28143. // Draw the legend symbol inside the group box
  28144. series.drawLegendSymbol(legend, item);
  28145. if (legend.setItemEvents) {
  28146. legend.setItemEvents(item, li, useHTML);
  28147. }
  28148. }
  28149. // Add the HTML checkbox on top
  28150. if (showCheckbox && !item.checkbox && legend.createCheckboxForItem) {
  28151. legend.createCheckboxForItem(item);
  28152. }
  28153. // Colorize the items
  28154. legend.colorizeItem(item, item.visible);
  28155. // Take care of max width and text overflow (#6659)
  28156. if (chart.styledMode || !itemStyle.width) {
  28157. li.css({
  28158. width: ((options.itemWidth ||
  28159. legend.widthOption ||
  28160. chart.spacingBox.width) - itemExtraWidth) + 'px'
  28161. });
  28162. }
  28163. // Always update the text
  28164. legend.setText(item);
  28165. // calculate the positions for the next line
  28166. bBox = li.getBBox();
  28167. item.itemWidth = item.checkboxOffset =
  28168. options.itemWidth ||
  28169. item.legendItemWidth ||
  28170. bBox.width + itemExtraWidth;
  28171. legend.maxItemWidth = Math.max(legend.maxItemWidth, item.itemWidth);
  28172. legend.totalItemWidth += item.itemWidth;
  28173. legend.itemHeight = item.itemHeight = Math.round(item.legendItemHeight || bBox.height || legend.symbolHeight);
  28174. };
  28175. /**
  28176. * Get the position of the item in the layout. We now know the
  28177. * maxItemWidth from the previous loop.
  28178. *
  28179. * @private
  28180. * @function Highcharts.Legend#layoutItem
  28181. * @param {Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series} item
  28182. */
  28183. Legend.prototype.layoutItem = function (item) {
  28184. var options = this.options,
  28185. padding = this.padding,
  28186. horizontal = options.layout === 'horizontal',
  28187. itemHeight = item.itemHeight,
  28188. itemMarginBottom = this.itemMarginBottom,
  28189. itemMarginTop = this.itemMarginTop,
  28190. itemDistance = horizontal ? pick(options.itemDistance, 20) : 0,
  28191. maxLegendWidth = this.maxLegendWidth,
  28192. itemWidth = (options.alignColumns &&
  28193. this.totalItemWidth > maxLegendWidth) ?
  28194. this.maxItemWidth :
  28195. item.itemWidth;
  28196. // If the item exceeds the width, start a new line
  28197. if (horizontal &&
  28198. this.itemX - padding + itemWidth > maxLegendWidth) {
  28199. this.itemX = padding;
  28200. if (this.lastLineHeight) { // Not for the first line (#10167)
  28201. this.itemY += (itemMarginTop +
  28202. this.lastLineHeight +
  28203. itemMarginBottom);
  28204. }
  28205. this.lastLineHeight = 0; // reset for next line (#915, #3976)
  28206. }
  28207. // Set the edge positions
  28208. this.lastItemY = itemMarginTop + this.itemY + itemMarginBottom;
  28209. this.lastLineHeight = Math.max(// #915
  28210. itemHeight, this.lastLineHeight);
  28211. // cache the position of the newly generated or reordered items
  28212. item._legendItemPos = [this.itemX, this.itemY];
  28213. // advance
  28214. if (horizontal) {
  28215. this.itemX += itemWidth;
  28216. }
  28217. else {
  28218. this.itemY +=
  28219. itemMarginTop + itemHeight + itemMarginBottom;
  28220. this.lastLineHeight = itemHeight;
  28221. }
  28222. // the width of the widest item
  28223. this.offsetWidth = this.widthOption || Math.max((horizontal ? this.itemX - padding - (item.checkbox ?
  28224. // decrease by itemDistance only when no checkbox #4853
  28225. 0 :
  28226. itemDistance) : itemWidth) + padding, this.offsetWidth);
  28227. };
  28228. /**
  28229. * Get all items, which is one item per series for most series and one
  28230. * item per point for pie series and its derivatives. Fires the event
  28231. * `afterGetAllItems`.
  28232. *
  28233. * @private
  28234. * @function Highcharts.Legend#getAllItems
  28235. * @return {Array<(Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series)>}
  28236. * The current items in the legend.
  28237. * @fires Highcharts.Legend#event:afterGetAllItems
  28238. */
  28239. Legend.prototype.getAllItems = function () {
  28240. var allItems = [];
  28241. this.chart.series.forEach(function (series) {
  28242. var seriesOptions = series && series.options;
  28243. // Handle showInLegend. If the series is linked to another series,
  28244. // defaults to false.
  28245. if (series && pick(seriesOptions.showInLegend, !defined(seriesOptions.linkedTo) ? void 0 : false, true)) {
  28246. // Use points or series for the legend item depending on
  28247. // legendType
  28248. allItems = allItems.concat(series.legendItems ||
  28249. (seriesOptions.legendType === 'point' ?
  28250. series.data :
  28251. series));
  28252. }
  28253. });
  28254. fireEvent(this, 'afterGetAllItems', { allItems: allItems });
  28255. return allItems;
  28256. };
  28257. /**
  28258. * Get a short, three letter string reflecting the alignment and layout.
  28259. *
  28260. * @private
  28261. * @function Highcharts.Legend#getAlignment
  28262. * @return {string}
  28263. * The alignment, empty string if floating
  28264. */
  28265. Legend.prototype.getAlignment = function () {
  28266. var options = this.options;
  28267. // Use the first letter of each alignment option in order to detect
  28268. // the side. (#4189 - use charAt(x) notation instead of [x] for IE7)
  28269. if (this.proximate) {
  28270. return options.align.charAt(0) + 'tv';
  28271. }
  28272. return options.floating ? '' : (options.align.charAt(0) +
  28273. options.verticalAlign.charAt(0) +
  28274. options.layout.charAt(0));
  28275. };
  28276. /**
  28277. * Adjust the chart margins by reserving space for the legend on only one
  28278. * side of the chart. If the position is set to a corner, top or bottom is
  28279. * reserved for horizontal legends and left or right for vertical ones.
  28280. *
  28281. * @private
  28282. * @function Highcharts.Legend#adjustMargins
  28283. * @param {Array<number>} margin
  28284. * @param {Array<number>} spacing
  28285. */
  28286. Legend.prototype.adjustMargins = function (margin, spacing) {
  28287. var chart = this.chart,
  28288. options = this.options,
  28289. alignment = this.getAlignment();
  28290. if (alignment) {
  28291. ([
  28292. /(lth|ct|rth)/,
  28293. /(rtv|rm|rbv)/,
  28294. /(rbh|cb|lbh)/,
  28295. /(lbv|lm|ltv)/
  28296. ]).forEach(function (alignments, side) {
  28297. if (alignments.test(alignment) && !defined(margin[side])) {
  28298. // Now we have detected on which side of the chart we should
  28299. // reserve space for the legend
  28300. chart[marginNames[side]] = Math.max(chart[marginNames[side]], (chart.legend[(side + 1) % 2 ? 'legendHeight' : 'legendWidth'] +
  28301. [1, -1, -1, 1][side] * options[(side % 2) ? 'x' : 'y'] +
  28302. pick(options.margin, 12) +
  28303. spacing[side] +
  28304. (chart.titleOffset[side] || 0)));
  28305. }
  28306. });
  28307. }
  28308. };
  28309. /**
  28310. * @private
  28311. * @function Highcharts.Legend#proximatePositions
  28312. */
  28313. Legend.prototype.proximatePositions = function () {
  28314. var chart = this.chart,
  28315. boxes = [],
  28316. alignLeft = this.options.align === 'left';
  28317. this.allItems.forEach(function (item) {
  28318. var lastPoint,
  28319. height,
  28320. useFirstPoint = alignLeft,
  28321. target,
  28322. top;
  28323. if (item.yAxis) {
  28324. if (item.xAxis.options.reversed) {
  28325. useFirstPoint = !useFirstPoint;
  28326. }
  28327. if (item.points) {
  28328. lastPoint = find(useFirstPoint ?
  28329. item.points :
  28330. item.points.slice(0).reverse(), function (item) {
  28331. return isNumber(item.plotY);
  28332. });
  28333. }
  28334. height = this.itemMarginTop +
  28335. item.legendItem.getBBox().height +
  28336. this.itemMarginBottom;
  28337. top = item.yAxis.top - chart.plotTop;
  28338. if (item.visible) {
  28339. target = lastPoint ?
  28340. lastPoint.plotY :
  28341. item.yAxis.height;
  28342. target += top - 0.3 * height;
  28343. }
  28344. else {
  28345. target = top + item.yAxis.height;
  28346. }
  28347. boxes.push({
  28348. target: target,
  28349. size: height,
  28350. item: item
  28351. });
  28352. }
  28353. }, this);
  28354. H.distribute(boxes, chart.plotHeight);
  28355. boxes.forEach(function (box) {
  28356. box.item._legendItemPos[1] =
  28357. chart.plotTop - chart.spacing[0] + box.pos;
  28358. });
  28359. };
  28360. /**
  28361. * Render the legend. This method can be called both before and after
  28362. * `chart.render`. If called after, it will only rearrange items instead
  28363. * of creating new ones. Called internally on initial render and after
  28364. * redraws.
  28365. *
  28366. * @private
  28367. * @function Highcharts.Legend#render
  28368. */
  28369. Legend.prototype.render = function () {
  28370. var legend = this,
  28371. chart = legend.chart,
  28372. renderer = chart.renderer,
  28373. legendGroup = legend.group,
  28374. allItems,
  28375. display,
  28376. legendWidth,
  28377. legendHeight,
  28378. box = legend.box,
  28379. options = legend.options,
  28380. padding = legend.padding,
  28381. allowedWidth;
  28382. legend.itemX = padding;
  28383. legend.itemY = legend.initialItemY;
  28384. legend.offsetWidth = 0;
  28385. legend.lastItemY = 0;
  28386. legend.widthOption = relativeLength(options.width, chart.spacingBox.width - padding);
  28387. // Compute how wide the legend is allowed to be
  28388. allowedWidth =
  28389. chart.spacingBox.width - 2 * padding - options.x;
  28390. if (['rm', 'lm'].indexOf(legend.getAlignment().substring(0, 2)) > -1) {
  28391. allowedWidth /= 2;
  28392. }
  28393. legend.maxLegendWidth = legend.widthOption || allowedWidth;
  28394. if (!legendGroup) {
  28395. /**
  28396. * SVG group of the legend.
  28397. *
  28398. * @readonly
  28399. * @name Highcharts.Legend#group
  28400. * @type {Highcharts.SVGElement}
  28401. */
  28402. legend.group = legendGroup = renderer.g('legend')
  28403. .attr({ zIndex: 7 })
  28404. .add();
  28405. legend.contentGroup = renderer.g()
  28406. .attr({ zIndex: 1 }) // above background
  28407. .add(legendGroup);
  28408. legend.scrollGroup = renderer.g()
  28409. .add(legend.contentGroup);
  28410. }
  28411. legend.renderTitle();
  28412. // add each series or point
  28413. allItems = legend.getAllItems();
  28414. // sort by legendIndex
  28415. stableSort(allItems, function (a, b) {
  28416. return ((a.options && a.options.legendIndex) || 0) -
  28417. ((b.options && b.options.legendIndex) || 0);
  28418. });
  28419. // reversed legend
  28420. if (options.reversed) {
  28421. allItems.reverse();
  28422. }
  28423. /**
  28424. * All items for the legend, which is an array of series for most series
  28425. * and an array of points for pie series and its derivatives.
  28426. *
  28427. * @readonly
  28428. * @name Highcharts.Legend#allItems
  28429. * @type {Array<(Highcharts.Point|Highcharts.Series)>}
  28430. */
  28431. legend.allItems = allItems;
  28432. legend.display = display = !!allItems.length;
  28433. // Render the items. First we run a loop to set the text and properties
  28434. // and read all the bounding boxes. The next loop computes the item
  28435. // positions based on the bounding boxes.
  28436. legend.lastLineHeight = 0;
  28437. legend.maxItemWidth = 0;
  28438. legend.totalItemWidth = 0;
  28439. legend.itemHeight = 0;
  28440. allItems.forEach(legend.renderItem, legend);
  28441. allItems.forEach(legend.layoutItem, legend);
  28442. // Get the box
  28443. legendWidth = (legend.widthOption || legend.offsetWidth) + padding;
  28444. legendHeight = legend.lastItemY + legend.lastLineHeight +
  28445. legend.titleHeight;
  28446. legendHeight = legend.handleOverflow(legendHeight);
  28447. legendHeight += padding;
  28448. // Draw the border and/or background
  28449. if (!box) {
  28450. /**
  28451. * SVG element of the legend box.
  28452. *
  28453. * @readonly
  28454. * @name Highcharts.Legend#box
  28455. * @type {Highcharts.SVGElement}
  28456. */
  28457. legend.box = box = renderer.rect()
  28458. .addClass('highcharts-legend-box')
  28459. .attr({
  28460. r: options.borderRadius
  28461. })
  28462. .add(legendGroup);
  28463. box.isNew = true;
  28464. }
  28465. // Presentational
  28466. if (!chart.styledMode) {
  28467. box
  28468. .attr({
  28469. stroke: options.borderColor,
  28470. 'stroke-width': options.borderWidth || 0,
  28471. fill: options.backgroundColor || 'none'
  28472. })
  28473. .shadow(options.shadow);
  28474. }
  28475. if (legendWidth > 0 && legendHeight > 0) {
  28476. box[box.isNew ? 'attr' : 'animate'](box.crisp.call({}, {
  28477. x: 0,
  28478. y: 0,
  28479. width: legendWidth,
  28480. height: legendHeight
  28481. }, box.strokeWidth()));
  28482. box.isNew = false;
  28483. }
  28484. // hide the border if no items
  28485. box[display ? 'show' : 'hide']();
  28486. // Open for responsiveness
  28487. if (chart.styledMode && legendGroup.getStyle('display') === 'none') {
  28488. legendWidth = legendHeight = 0;
  28489. }
  28490. legend.legendWidth = legendWidth;
  28491. legend.legendHeight = legendHeight;
  28492. if (display) {
  28493. legend.align();
  28494. }
  28495. if (!this.proximate) {
  28496. this.positionItems();
  28497. }
  28498. fireEvent(this, 'afterRender');
  28499. };
  28500. /**
  28501. * Align the legend to chart's box.
  28502. *
  28503. * @private
  28504. * @function Highcharts.align
  28505. * @param {Highcharts.BBoxObject} alignTo
  28506. * @return {void}
  28507. */
  28508. Legend.prototype.align = function (alignTo) {
  28509. if (alignTo === void 0) { alignTo = this.chart.spacingBox; }
  28510. var chart = this.chart,
  28511. options = this.options;
  28512. // If aligning to the top and the layout is horizontal, adjust for
  28513. // the title (#7428)
  28514. var y = alignTo.y;
  28515. if (/(lth|ct|rth)/.test(this.getAlignment()) &&
  28516. chart.titleOffset[0] > 0) {
  28517. y += chart.titleOffset[0];
  28518. }
  28519. else if (/(lbh|cb|rbh)/.test(this.getAlignment()) &&
  28520. chart.titleOffset[2] > 0) {
  28521. y -= chart.titleOffset[2];
  28522. }
  28523. if (y !== alignTo.y) {
  28524. alignTo = merge(alignTo, { y: y });
  28525. }
  28526. this.group.align(merge(options, {
  28527. width: this.legendWidth,
  28528. height: this.legendHeight,
  28529. verticalAlign: this.proximate ? 'top' : options.verticalAlign
  28530. }), true, alignTo);
  28531. };
  28532. /**
  28533. * Set up the overflow handling by adding navigation with up and down arrows
  28534. * below the legend.
  28535. *
  28536. * @private
  28537. * @function Highcharts.Legend#handleOverflow
  28538. * @param {number} legendHeight
  28539. * @return {number}
  28540. */
  28541. Legend.prototype.handleOverflow = function (legendHeight) {
  28542. var legend = this,
  28543. chart = this.chart,
  28544. renderer = chart.renderer,
  28545. options = this.options,
  28546. optionsY = options.y,
  28547. alignTop = options.verticalAlign === 'top',
  28548. padding = this.padding,
  28549. spaceHeight = (chart.spacingBox.height +
  28550. (alignTop ? -optionsY : optionsY) - padding),
  28551. maxHeight = options.maxHeight,
  28552. clipHeight,
  28553. clipRect = this.clipRect,
  28554. navOptions = options.navigation,
  28555. animation = pick(navOptions.animation,
  28556. true),
  28557. arrowSize = navOptions.arrowSize || 12,
  28558. nav = this.nav,
  28559. pages = this.pages,
  28560. lastY,
  28561. allItems = this.allItems,
  28562. clipToHeight = function (height) {
  28563. if (typeof height === 'number') {
  28564. clipRect.attr({
  28565. height: height
  28566. });
  28567. }
  28568. else if (clipRect) { // Reset (#5912)
  28569. legend.clipRect = clipRect.destroy();
  28570. legend.contentGroup.clip();
  28571. }
  28572. // useHTML
  28573. if (legend.contentGroup.div) {
  28574. legend.contentGroup.div.style.clip = height ?
  28575. 'rect(' + padding + 'px,9999px,' +
  28576. (padding + height) + 'px,0)' :
  28577. 'auto';
  28578. }
  28579. }, addTracker = function (key) {
  28580. legend[key] = renderer
  28581. .circle(0, 0, arrowSize * 1.3)
  28582. .translate(arrowSize / 2, arrowSize / 2)
  28583. .add(nav);
  28584. if (!chart.styledMode) {
  28585. legend[key].attr('fill', 'rgba(0,0,0,0.0001)');
  28586. }
  28587. return legend[key];
  28588. };
  28589. // Adjust the height
  28590. if (options.layout === 'horizontal' &&
  28591. options.verticalAlign !== 'middle' &&
  28592. !options.floating) {
  28593. spaceHeight /= 2;
  28594. }
  28595. if (maxHeight) {
  28596. spaceHeight = Math.min(spaceHeight, maxHeight);
  28597. }
  28598. // Reset the legend height and adjust the clipping rectangle
  28599. pages.length = 0;
  28600. if (legendHeight &&
  28601. spaceHeight > 0 &&
  28602. legendHeight > spaceHeight &&
  28603. navOptions.enabled !== false) {
  28604. this.clipHeight = clipHeight =
  28605. Math.max(spaceHeight - 20 - this.titleHeight - padding, 0);
  28606. this.currentPage = pick(this.currentPage, 1);
  28607. this.fullHeight = legendHeight;
  28608. // Fill pages with Y positions so that the top of each a legend item
  28609. // defines the scroll top for each page (#2098)
  28610. allItems.forEach(function (item, i) {
  28611. var y = item._legendItemPos[1],
  28612. h = Math.round(item.legendItem.getBBox().height),
  28613. len = pages.length;
  28614. if (!len || (y - pages[len - 1] > clipHeight &&
  28615. (lastY || y) !== pages[len - 1])) {
  28616. pages.push(lastY || y);
  28617. len++;
  28618. }
  28619. // Keep track of which page each item is on
  28620. item.pageIx = len - 1;
  28621. if (lastY) {
  28622. allItems[i - 1].pageIx = len - 1;
  28623. }
  28624. if (i === allItems.length - 1 &&
  28625. y + h - pages[len - 1] > clipHeight &&
  28626. y !== lastY // #2617
  28627. ) {
  28628. pages.push(y);
  28629. item.pageIx = len;
  28630. }
  28631. if (y !== lastY) {
  28632. lastY = y;
  28633. }
  28634. });
  28635. // Only apply clipping if needed. Clipping causes blurred legend in
  28636. // PDF export (#1787)
  28637. if (!clipRect) {
  28638. clipRect = legend.clipRect =
  28639. renderer.clipRect(0, padding, 9999, 0);
  28640. legend.contentGroup.clip(clipRect);
  28641. }
  28642. clipToHeight(clipHeight);
  28643. // Add navigation elements
  28644. if (!nav) {
  28645. this.nav = nav = renderer.g()
  28646. .attr({ zIndex: 1 })
  28647. .add(this.group);
  28648. this.up = renderer
  28649. .symbol('triangle', 0, 0, arrowSize, arrowSize)
  28650. .add(nav);
  28651. addTracker('upTracker')
  28652. .on('click', function () {
  28653. legend.scroll(-1, animation);
  28654. });
  28655. this.pager = renderer.text('', 15, 10)
  28656. .addClass('highcharts-legend-navigation');
  28657. if (!chart.styledMode) {
  28658. this.pager.css(navOptions.style);
  28659. }
  28660. this.pager.add(nav);
  28661. this.down = renderer
  28662. .symbol('triangle-down', 0, 0, arrowSize, arrowSize)
  28663. .add(nav);
  28664. addTracker('downTracker')
  28665. .on('click', function () {
  28666. legend.scroll(1, animation);
  28667. });
  28668. }
  28669. // Set initial position
  28670. legend.scroll(0);
  28671. legendHeight = spaceHeight;
  28672. // Reset
  28673. }
  28674. else if (nav) {
  28675. clipToHeight();
  28676. this.nav = nav.destroy(); // #6322
  28677. this.scrollGroup.attr({
  28678. translateY: 1
  28679. });
  28680. this.clipHeight = 0; // #1379
  28681. }
  28682. return legendHeight;
  28683. };
  28684. /**
  28685. * Scroll the legend by a number of pages.
  28686. *
  28687. * @private
  28688. * @function Highcharts.Legend#scroll
  28689. *
  28690. * @param {number} scrollBy
  28691. * The number of pages to scroll.
  28692. *
  28693. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  28694. * Whether and how to apply animation.
  28695. *
  28696. * @return {void}
  28697. */
  28698. Legend.prototype.scroll = function (scrollBy, animation) {
  28699. var _this = this;
  28700. var chart = this.chart,
  28701. pages = this.pages,
  28702. pageCount = pages.length,
  28703. currentPage = this.currentPage + scrollBy,
  28704. clipHeight = this.clipHeight,
  28705. navOptions = this.options.navigation,
  28706. pager = this.pager,
  28707. padding = this.padding;
  28708. // When resizing while looking at the last page
  28709. if (currentPage > pageCount) {
  28710. currentPage = pageCount;
  28711. }
  28712. if (currentPage > 0) {
  28713. if (typeof animation !== 'undefined') {
  28714. setAnimation(animation, chart);
  28715. }
  28716. this.nav.attr({
  28717. translateX: padding,
  28718. translateY: clipHeight + this.padding + 7 + this.titleHeight,
  28719. visibility: 'visible'
  28720. });
  28721. [this.up, this.upTracker].forEach(function (elem) {
  28722. elem.attr({
  28723. 'class': currentPage === 1 ?
  28724. 'highcharts-legend-nav-inactive' :
  28725. 'highcharts-legend-nav-active'
  28726. });
  28727. });
  28728. pager.attr({
  28729. text: currentPage + '/' + pageCount
  28730. });
  28731. [this.down, this.downTracker].forEach(function (elem) {
  28732. elem.attr({
  28733. // adjust to text width
  28734. x: 18 + this.pager.getBBox().width,
  28735. 'class': currentPage === pageCount ?
  28736. 'highcharts-legend-nav-inactive' :
  28737. 'highcharts-legend-nav-active'
  28738. });
  28739. }, this);
  28740. if (!chart.styledMode) {
  28741. this.up
  28742. .attr({
  28743. fill: currentPage === 1 ?
  28744. navOptions.inactiveColor :
  28745. navOptions.activeColor
  28746. });
  28747. this.upTracker
  28748. .css({
  28749. cursor: currentPage === 1 ? 'default' : 'pointer'
  28750. });
  28751. this.down
  28752. .attr({
  28753. fill: currentPage === pageCount ?
  28754. navOptions.inactiveColor :
  28755. navOptions.activeColor
  28756. });
  28757. this.downTracker
  28758. .css({
  28759. cursor: currentPage === pageCount ?
  28760. 'default' :
  28761. 'pointer'
  28762. });
  28763. }
  28764. this.scrollOffset = -pages[currentPage - 1] + this.initialItemY;
  28765. this.scrollGroup.animate({
  28766. translateY: this.scrollOffset
  28767. });
  28768. this.currentPage = currentPage;
  28769. this.positionCheckboxes();
  28770. // Fire event after scroll animation is complete
  28771. var animOptions = animObject(pick(animation,
  28772. chart.renderer.globalAnimation,
  28773. true));
  28774. syncTimeout(function () {
  28775. fireEvent(_this, 'afterScroll', { currentPage: currentPage });
  28776. }, animOptions.duration);
  28777. }
  28778. };
  28779. /**
  28780. * @private
  28781. * @function Highcharts.Legend#setItemEvents
  28782. * @param {Highcharts.BubbleLegend|Point|Highcharts.Series} item
  28783. * @param {Highcharts.SVGElement} legendItem
  28784. * @param {boolean} [useHTML=false]
  28785. * @fires Highcharts.Point#event:legendItemClick
  28786. * @fires Highcharts.Series#event:legendItemClick
  28787. */
  28788. Legend.prototype.setItemEvents = function (item, legendItem, useHTML) {
  28789. var legend = this,
  28790. boxWrapper = legend.chart.renderer.boxWrapper,
  28791. isPoint = item instanceof Point,
  28792. activeClass = 'highcharts-legend-' +
  28793. (isPoint ? 'point' : 'series') + '-active',
  28794. styledMode = legend.chart.styledMode,
  28795. // When `useHTML`, the symbol is rendered in other group, so
  28796. // we need to apply events listeners to both places
  28797. legendItems = useHTML ?
  28798. [legendItem,
  28799. item.legendSymbol] :
  28800. [item.legendGroup];
  28801. // Set the events on the item group, or in case of useHTML, the item
  28802. // itself (#1249)
  28803. legendItems.forEach(function (element) {
  28804. if (element) {
  28805. element
  28806. .on('mouseover', function () {
  28807. if (item.visible) {
  28808. legend.allItems.forEach(function (inactiveItem) {
  28809. if (item !== inactiveItem) {
  28810. inactiveItem.setState('inactive', !isPoint);
  28811. }
  28812. });
  28813. }
  28814. item.setState('hover');
  28815. // A CSS class to dim or hide other than the hovered
  28816. // series.
  28817. // Works only if hovered series is visible (#10071).
  28818. if (item.visible) {
  28819. boxWrapper.addClass(activeClass);
  28820. }
  28821. if (!styledMode) {
  28822. legendItem.css(legend.options.itemHoverStyle);
  28823. }
  28824. })
  28825. .on('mouseout', function () {
  28826. if (!legend.chart.styledMode) {
  28827. legendItem.css(merge(item.visible ?
  28828. legend.itemStyle :
  28829. legend.itemHiddenStyle));
  28830. }
  28831. legend.allItems.forEach(function (inactiveItem) {
  28832. if (item !== inactiveItem) {
  28833. inactiveItem.setState('', !isPoint);
  28834. }
  28835. });
  28836. // A CSS class to dim or hide other than the hovered
  28837. // series.
  28838. boxWrapper.removeClass(activeClass);
  28839. item.setState();
  28840. })
  28841. .on('click', function (event) {
  28842. var strLegendItemClick = 'legendItemClick',
  28843. fnLegendItemClick = function () {
  28844. if (item.setVisible) {
  28845. item.setVisible();
  28846. }
  28847. // Reset inactive state
  28848. legend.allItems.forEach(function (inactiveItem) {
  28849. if (item !== inactiveItem) {
  28850. inactiveItem.setState(item.visible ? 'inactive' : '', !isPoint);
  28851. }
  28852. });
  28853. };
  28854. // A CSS class to dim or hide other than the hovered
  28855. // series. Event handling in iOS causes the activeClass
  28856. // to be added prior to click in some cases (#7418).
  28857. boxWrapper.removeClass(activeClass);
  28858. // Pass over the click/touch event. #4.
  28859. event = {
  28860. browserEvent: event
  28861. };
  28862. // click the name or symbol
  28863. if (item.firePointEvent) { // point
  28864. item.firePointEvent(strLegendItemClick, event, fnLegendItemClick);
  28865. }
  28866. else {
  28867. fireEvent(item, strLegendItemClick, event, fnLegendItemClick);
  28868. }
  28869. });
  28870. }
  28871. });
  28872. };
  28873. /**
  28874. * @private
  28875. * @function Highcharts.Legend#createCheckboxForItem
  28876. * @param {Highcharts.BubbleLegend|Point|Highcharts.Series} item
  28877. * @fires Highcharts.Series#event:checkboxClick
  28878. */
  28879. Legend.prototype.createCheckboxForItem = function (item) {
  28880. var legend = this;
  28881. item.checkbox = createElement('input', {
  28882. type: 'checkbox',
  28883. className: 'highcharts-legend-checkbox',
  28884. checked: item.selected,
  28885. defaultChecked: item.selected // required by IE7
  28886. }, legend.options.itemCheckboxStyle, legend.chart.container);
  28887. addEvent(item.checkbox, 'click', function (event) {
  28888. var target = event.target;
  28889. fireEvent(item.series || item, 'checkboxClick', {
  28890. checked: target.checked,
  28891. item: item
  28892. }, function () {
  28893. item.select();
  28894. });
  28895. });
  28896. };
  28897. return Legend;
  28898. }());
  28899. // Workaround for #2030, horizontal legend items not displaying in IE11 Preview,
  28900. // and for #2580, a similar drawing flaw in Firefox 26.
  28901. // Explore if there's a general cause for this. The problem may be related
  28902. // to nested group elements, as the legend item texts are within 4 group
  28903. // elements.
  28904. if (/Trident\/7\.0/.test(win.navigator && win.navigator.userAgent) ||
  28905. isFirefox) {
  28906. wrap(Legend.prototype, 'positionItem', function (proceed, item) {
  28907. var legend = this,
  28908. // If chart destroyed in sync, this is undefined (#2030)
  28909. runPositionItem = function () {
  28910. if (item._legendItemPos) {
  28911. proceed.call(legend,
  28912. item);
  28913. }
  28914. };
  28915. // Do it now, for export and to get checkbox placement
  28916. runPositionItem();
  28917. // Do it after to work around the core issue
  28918. if (!legend.bubbleLegend) {
  28919. setTimeout(runPositionItem);
  28920. }
  28921. });
  28922. }
  28923. H.Legend = Legend;
  28924. return H.Legend;
  28925. });
  28926. _registerModule(_modules, 'Core/Series/SeriesRegistry.js', [_modules['Core/Globals.js'], _modules['Core/Options.js'], _modules['Core/Series/Point.js'], _modules['Core/Utilities.js']], function (H, O, Point, U) {
  28927. /* *
  28928. *
  28929. * (c) 2010-2021 Torstein Honsi
  28930. *
  28931. * License: www.highcharts.com/license
  28932. *
  28933. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  28934. *
  28935. * */
  28936. var defaultOptions = O.defaultOptions;
  28937. var error = U.error,
  28938. extendClass = U.extendClass,
  28939. merge = U.merge;
  28940. /* *
  28941. *
  28942. * Namespace
  28943. *
  28944. * */
  28945. var SeriesRegistry;
  28946. (function (SeriesRegistry) {
  28947. /* *
  28948. *
  28949. * Static Properties
  28950. *
  28951. * */
  28952. /**
  28953. * @internal
  28954. * @todo Move `Globals.seriesTypes` code to her.
  28955. */
  28956. SeriesRegistry.seriesTypes = H.seriesTypes;
  28957. /* *
  28958. *
  28959. * Static Functions
  28960. *
  28961. * */
  28962. /* eslint-disable valid-jsdoc */
  28963. /**
  28964. * Internal function to initialize an individual series.
  28965. * @private
  28966. */
  28967. function getSeries(chart, options) {
  28968. if (options === void 0) { options = {}; }
  28969. var optionsChart = chart.options.chart,
  28970. type = (options.type ||
  28971. optionsChart.type ||
  28972. optionsChart.defaultSeriesType ||
  28973. ''),
  28974. SeriesClass = SeriesRegistry.seriesTypes[type];
  28975. // No such series type
  28976. if (!SeriesRegistry) {
  28977. error(17, true, chart, { missingModuleFor: type });
  28978. }
  28979. var series = new SeriesClass();
  28980. if (typeof series.init === 'function') {
  28981. series.init(chart, options);
  28982. }
  28983. return series;
  28984. }
  28985. SeriesRegistry.getSeries = getSeries;
  28986. /**
  28987. * Registers class pattern of a series.
  28988. *
  28989. * @private
  28990. */
  28991. function registerSeriesType(seriesType, seriesClass) {
  28992. var defaultPlotOptions = defaultOptions.plotOptions || {},
  28993. seriesOptions = seriesClass.defaultOptions;
  28994. if (!seriesClass.prototype.pointClass) {
  28995. seriesClass.prototype.pointClass = Point;
  28996. }
  28997. seriesClass.prototype.type = seriesType;
  28998. if (seriesOptions) {
  28999. defaultPlotOptions[seriesType] = seriesOptions;
  29000. }
  29001. SeriesRegistry.seriesTypes[seriesType] = seriesClass;
  29002. }
  29003. SeriesRegistry.registerSeriesType = registerSeriesType;
  29004. /**
  29005. * Old factory to create new series prototypes.
  29006. *
  29007. * @deprecated
  29008. * @function Highcharts.seriesType
  29009. *
  29010. * @param {string} type
  29011. * The series type name.
  29012. *
  29013. * @param {string} parent
  29014. * The parent series type name. Use `line` to inherit from the basic
  29015. * {@link Series} object.
  29016. *
  29017. * @param {Highcharts.SeriesOptionsType|Highcharts.Dictionary<*>} options
  29018. * The additional default options that are merged with the parent's options.
  29019. *
  29020. * @param {Highcharts.Dictionary<*>} [props]
  29021. * The properties (functions and primitives) to set on the new prototype.
  29022. *
  29023. * @param {Highcharts.Dictionary<*>} [pointProps]
  29024. * Members for a series-specific extension of the {@link Point} prototype if
  29025. * needed.
  29026. *
  29027. * @return {Highcharts.Series}
  29028. * The newly created prototype as extended from {@link Series} or its
  29029. * derivatives.
  29030. */
  29031. function seriesType(type, parent, options, seriesProto, pointProto) {
  29032. var defaultPlotOptions = defaultOptions.plotOptions || {};
  29033. parent = parent || '';
  29034. // Merge the options
  29035. defaultPlotOptions[type] = merge(defaultPlotOptions[parent], options);
  29036. // Create the class
  29037. registerSeriesType(type, extendClass(SeriesRegistry.seriesTypes[parent] || function () { }, seriesProto));
  29038. SeriesRegistry.seriesTypes[type].prototype.type = type;
  29039. // Create the point class if needed
  29040. if (pointProto) {
  29041. SeriesRegistry.seriesTypes[type].prototype.pointClass =
  29042. extendClass(Point, pointProto);
  29043. }
  29044. return SeriesRegistry.seriesTypes[type];
  29045. }
  29046. SeriesRegistry.seriesType = seriesType;
  29047. /* eslint-enable valid-jsdoc */
  29048. })(SeriesRegistry || (SeriesRegistry = {}));
  29049. /* *
  29050. *
  29051. * Compatibility
  29052. *
  29053. * */
  29054. H.seriesType = SeriesRegistry.seriesType;
  29055. /* *
  29056. *
  29057. * Export
  29058. *
  29059. * */
  29060. return SeriesRegistry;
  29061. });
  29062. _registerModule(_modules, 'Core/Chart/Chart.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Axis/Axis.js'], _modules['Core/FormatUtilities.js'], _modules['Core/Globals.js'], _modules['Core/Legend.js'], _modules['Core/MSPointer.js'], _modules['Core/Options.js'], _modules['Core/Color/Palette.js'], _modules['Core/Pointer.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Time.js'], _modules['Core/Utilities.js'], _modules['Core/Renderer/HTML/AST.js']], function (A, Axis, F, H, Legend, MSPointer, O, palette, Pointer, SeriesRegistry, Time, U, AST) {
  29063. /* *
  29064. *
  29065. * (c) 2010-2021 Torstein Honsi
  29066. *
  29067. * License: www.highcharts.com/license
  29068. *
  29069. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  29070. *
  29071. * */
  29072. var animate = A.animate,
  29073. animObject = A.animObject,
  29074. setAnimation = A.setAnimation;
  29075. var numberFormat = F.numberFormat;
  29076. var charts = H.charts,
  29077. doc = H.doc,
  29078. win = H.win;
  29079. var defaultOptions = O.defaultOptions,
  29080. defaultTime = O.defaultTime;
  29081. var seriesTypes = SeriesRegistry.seriesTypes;
  29082. var addEvent = U.addEvent,
  29083. attr = U.attr,
  29084. cleanRecursively = U.cleanRecursively,
  29085. createElement = U.createElement,
  29086. css = U.css,
  29087. defined = U.defined,
  29088. discardElement = U.discardElement,
  29089. erase = U.erase,
  29090. error = U.error,
  29091. extend = U.extend,
  29092. find = U.find,
  29093. fireEvent = U.fireEvent,
  29094. getStyle = U.getStyle,
  29095. isArray = U.isArray,
  29096. isFunction = U.isFunction,
  29097. isNumber = U.isNumber,
  29098. isObject = U.isObject,
  29099. isString = U.isString,
  29100. merge = U.merge,
  29101. objectEach = U.objectEach,
  29102. pick = U.pick,
  29103. pInt = U.pInt,
  29104. relativeLength = U.relativeLength,
  29105. removeEvent = U.removeEvent,
  29106. splat = U.splat,
  29107. syncTimeout = U.syncTimeout,
  29108. uniqueKey = U.uniqueKey;
  29109. var marginNames = H.marginNames;
  29110. /* eslint-disable no-invalid-this, valid-jsdoc */
  29111. /**
  29112. * The Chart class. The recommended constructor is {@link Highcharts#chart}.
  29113. *
  29114. * @example
  29115. * let chart = Highcharts.chart('container', {
  29116. * title: {
  29117. * text: 'My chart'
  29118. * },
  29119. * series: [{
  29120. * data: [1, 3, 2, 4]
  29121. * }]
  29122. * })
  29123. *
  29124. * @class
  29125. * @name Highcharts.Chart
  29126. *
  29127. * @param {string|Highcharts.HTMLDOMElement} [renderTo]
  29128. * The DOM element to render to, or its id.
  29129. *
  29130. * @param {Highcharts.Options} options
  29131. * The chart options structure.
  29132. *
  29133. * @param {Highcharts.ChartCallbackFunction} [callback]
  29134. * Function to run when the chart has loaded and and all external images
  29135. * are loaded. Defining a
  29136. * [chart.events.load](https://api.highcharts.com/highcharts/chart.events.load)
  29137. * handler is equivalent.
  29138. */
  29139. var Chart = /** @class */ (function () {
  29140. function Chart(a, b, c) {
  29141. this.axes = void 0;
  29142. this.axisOffset = void 0;
  29143. this.bounds = void 0;
  29144. this.chartHeight = void 0;
  29145. this.chartWidth = void 0;
  29146. this.clipBox = void 0;
  29147. this.colorCounter = void 0;
  29148. this.container = void 0;
  29149. this.index = void 0;
  29150. this.isResizing = void 0;
  29151. this.labelCollectors = void 0;
  29152. this.legend = void 0;
  29153. this.margin = void 0;
  29154. this.numberFormatter = void 0;
  29155. this.options = void 0;
  29156. this.plotBox = void 0;
  29157. this.plotHeight = void 0;
  29158. this.plotLeft = void 0;
  29159. this.plotTop = void 0;
  29160. this.plotWidth = void 0;
  29161. this.pointCount = void 0;
  29162. this.pointer = void 0;
  29163. this.renderer = void 0;
  29164. this.renderTo = void 0;
  29165. this.series = void 0;
  29166. this.sharedClips = {};
  29167. this.spacing = void 0;
  29168. this.spacingBox = void 0;
  29169. this.symbolCounter = void 0;
  29170. this.time = void 0;
  29171. this.titleOffset = void 0;
  29172. this.userOptions = void 0;
  29173. this.xAxis = void 0;
  29174. this.yAxis = void 0;
  29175. this.getArgs(a, b, c);
  29176. }
  29177. /* *
  29178. *
  29179. * Functions
  29180. *
  29181. * */
  29182. /**
  29183. * Handle the arguments passed to the constructor.
  29184. *
  29185. * @private
  29186. * @function Highcharts.Chart#getArgs
  29187. *
  29188. * @param {...Array<*>} arguments
  29189. * All arguments for the constructor.
  29190. *
  29191. * @fires Highcharts.Chart#event:init
  29192. * @fires Highcharts.Chart#event:afterInit
  29193. */
  29194. Chart.prototype.getArgs = function (a, b, c) {
  29195. // Remove the optional first argument, renderTo, and
  29196. // set it on this.
  29197. if (isString(a) || a.nodeName) {
  29198. this.renderTo = a;
  29199. this.init(b, c);
  29200. }
  29201. else {
  29202. this.init(a, b);
  29203. }
  29204. };
  29205. /**
  29206. * Overridable function that initializes the chart. The constructor's
  29207. * arguments are passed on directly.
  29208. *
  29209. * @function Highcharts.Chart#init
  29210. *
  29211. * @param {Highcharts.Options} userOptions
  29212. * Custom options.
  29213. *
  29214. * @param {Function} [callback]
  29215. * Function to run when the chart has loaded and and all external
  29216. * images are loaded.
  29217. *
  29218. * @return {void}
  29219. *
  29220. * @fires Highcharts.Chart#event:init
  29221. * @fires Highcharts.Chart#event:afterInit
  29222. */
  29223. Chart.prototype.init = function (userOptions, callback) {
  29224. // Handle regular options
  29225. var userPlotOptions = userOptions.plotOptions || {};
  29226. // Fire the event with a default function
  29227. fireEvent(this, 'init', { args: arguments }, function () {
  29228. var options = merge(defaultOptions,
  29229. userOptions); // do the merge
  29230. var optionsChart = options.chart;
  29231. // Override (by copy of user options) or clear tooltip options
  29232. // in chart.options.plotOptions (#6218)
  29233. objectEach(options.plotOptions, function (typeOptions, type) {
  29234. if (isObject(typeOptions)) { // #8766
  29235. typeOptions.tooltip = (userPlotOptions[type] && // override by copy:
  29236. merge(userPlotOptions[type].tooltip)) || void 0; // or clear
  29237. }
  29238. });
  29239. // User options have higher priority than default options
  29240. // (#6218). In case of exporting: path is changed
  29241. options.tooltip.userOptions = (userOptions.chart &&
  29242. userOptions.chart.forExport &&
  29243. userOptions.tooltip.userOptions) || userOptions.tooltip;
  29244. /**
  29245. * The original options given to the constructor or a chart factory
  29246. * like {@link Highcharts.chart} and {@link Highcharts.stockChart}.
  29247. *
  29248. * @name Highcharts.Chart#userOptions
  29249. * @type {Highcharts.Options}
  29250. */
  29251. this.userOptions = userOptions;
  29252. var chartEvents = optionsChart.events;
  29253. this.margin = [];
  29254. this.spacing = [];
  29255. // Pixel data bounds for touch zoom
  29256. this.bounds = { h: {}, v: {} };
  29257. // An array of functions that returns labels that should be
  29258. // considered for anti-collision
  29259. this.labelCollectors = [];
  29260. this.callback = callback;
  29261. this.isResizing = 0;
  29262. /**
  29263. * The options structure for the chart after merging
  29264. * {@link #defaultOptions} and {@link #userOptions}. It contains
  29265. * members for the sub elements like series, legend, tooltip etc.
  29266. *
  29267. * @name Highcharts.Chart#options
  29268. * @type {Highcharts.Options}
  29269. */
  29270. this.options = options;
  29271. /**
  29272. * All the axes in the chart.
  29273. *
  29274. * @see Highcharts.Chart.xAxis
  29275. * @see Highcharts.Chart.yAxis
  29276. *
  29277. * @name Highcharts.Chart#axes
  29278. * @type {Array<Highcharts.Axis>}
  29279. */
  29280. this.axes = [];
  29281. /**
  29282. * All the current series in the chart.
  29283. *
  29284. * @name Highcharts.Chart#series
  29285. * @type {Array<Highcharts.Series>}
  29286. */
  29287. this.series = [];
  29288. /**
  29289. * The `Time` object associated with the chart. Since v6.0.5,
  29290. * time settings can be applied individually for each chart. If
  29291. * no individual settings apply, the `Time` object is shared by
  29292. * all instances.
  29293. *
  29294. * @name Highcharts.Chart#time
  29295. * @type {Highcharts.Time}
  29296. */
  29297. this.time =
  29298. userOptions.time && Object.keys(userOptions.time).length ?
  29299. new Time(userOptions.time) :
  29300. H.time;
  29301. /**
  29302. * Callback function to override the default function that formats
  29303. * all the numbers in the chart. Returns a string with the formatted
  29304. * number.
  29305. *
  29306. * @name Highcharts.Chart#numberFormatter
  29307. * @type {Highcharts.NumberFormatterCallbackFunction}
  29308. */
  29309. this.numberFormatter = optionsChart.numberFormatter || numberFormat;
  29310. /**
  29311. * Whether the chart is in styled mode, meaning all presentatinoal
  29312. * attributes are avoided.
  29313. *
  29314. * @name Highcharts.Chart#styledMode
  29315. * @type {boolean}
  29316. */
  29317. this.styledMode = optionsChart.styledMode;
  29318. this.hasCartesianSeries = optionsChart.showAxes;
  29319. var chart = this;
  29320. /**
  29321. * Index position of the chart in the {@link Highcharts#charts}
  29322. * property.
  29323. *
  29324. * @name Highcharts.Chart#index
  29325. * @type {number}
  29326. * @readonly
  29327. */
  29328. chart.index = charts.length; // Add the chart to the global lookup
  29329. charts.push(chart);
  29330. H.chartCount++;
  29331. // Chart event handlers
  29332. if (chartEvents) {
  29333. objectEach(chartEvents, function (event, eventType) {
  29334. if (isFunction(event)) {
  29335. addEvent(chart, eventType, event);
  29336. }
  29337. });
  29338. }
  29339. /**
  29340. * A collection of the X axes in the chart.
  29341. *
  29342. * @name Highcharts.Chart#xAxis
  29343. * @type {Array<Highcharts.Axis>}
  29344. */
  29345. chart.xAxis = [];
  29346. /**
  29347. * A collection of the Y axes in the chart.
  29348. *
  29349. * @name Highcharts.Chart#yAxis
  29350. * @type {Array<Highcharts.Axis>}
  29351. *
  29352. * @todo
  29353. * Make events official: Fire the event `afterInit`.
  29354. */
  29355. chart.yAxis = [];
  29356. chart.pointCount = chart.colorCounter = chart.symbolCounter = 0;
  29357. // Fire after init but before first render, before axes and series
  29358. // have been initialized.
  29359. fireEvent(chart, 'afterInit');
  29360. chart.firstRender();
  29361. });
  29362. };
  29363. /**
  29364. * Internal function to unitialize an individual series.
  29365. *
  29366. * @private
  29367. * @function Highcharts.Chart#initSeries
  29368. */
  29369. Chart.prototype.initSeries = function (options) {
  29370. var chart = this,
  29371. optionsChart = chart.options.chart,
  29372. type = (options.type ||
  29373. optionsChart.type ||
  29374. optionsChart.defaultSeriesType),
  29375. series,
  29376. SeriesClass = seriesTypes[type];
  29377. // No such series type
  29378. if (!SeriesClass) {
  29379. error(17, true, chart, { missingModuleFor: type });
  29380. }
  29381. series = new SeriesClass();
  29382. if (typeof series.init === 'function') {
  29383. series.init(chart, options);
  29384. }
  29385. return series;
  29386. };
  29387. /**
  29388. * Internal function to set data for all series with enabled sorting.
  29389. *
  29390. * @private
  29391. * @function Highcharts.Chart#setSeriesData
  29392. */
  29393. Chart.prototype.setSeriesData = function () {
  29394. this.getSeriesOrderByLinks().forEach(function (series) {
  29395. // We need to set data for series with sorting after series init
  29396. if (!series.points && !series.data && series.enabledDataSorting) {
  29397. series.setData(series.options.data, false);
  29398. }
  29399. });
  29400. };
  29401. /**
  29402. * Sort and return chart series in order depending on the number of linked
  29403. * series.
  29404. *
  29405. * @private
  29406. * @function Highcharts.Series#getSeriesOrderByLinks
  29407. * @return {Array<Highcharts.Series>}
  29408. */
  29409. Chart.prototype.getSeriesOrderByLinks = function () {
  29410. return this.series.concat().sort(function (a, b) {
  29411. if (a.linkedSeries.length || b.linkedSeries.length) {
  29412. return b.linkedSeries.length - a.linkedSeries.length;
  29413. }
  29414. return 0;
  29415. });
  29416. };
  29417. /**
  29418. * Order all series above a given index. When series are added and ordered
  29419. * by configuration, only the last series is handled (#248, #1123, #2456,
  29420. * #6112). This function is called on series initialization and destroy.
  29421. *
  29422. * @private
  29423. * @function Highcharts.Series#orderSeries
  29424. * @param {number} [fromIndex]
  29425. * If this is given, only the series above this index are handled.
  29426. */
  29427. Chart.prototype.orderSeries = function (fromIndex) {
  29428. var series = this.series,
  29429. i = fromIndex || 0;
  29430. for (; i < series.length; i++) {
  29431. if (series[i]) {
  29432. /**
  29433. * Contains the series' index in the `Chart.series` array.
  29434. *
  29435. * @name Highcharts.Series#index
  29436. * @type {number}
  29437. * @readonly
  29438. */
  29439. series[i].index = i;
  29440. series[i].name = series[i].getName();
  29441. }
  29442. }
  29443. };
  29444. /**
  29445. * Check whether a given point is within the plot area.
  29446. *
  29447. * @function Highcharts.Chart#isInsidePlot
  29448. *
  29449. * @param {number} plotX
  29450. * Pixel x relative to the plot area.
  29451. *
  29452. * @param {number} plotY
  29453. * Pixel y relative to the plot area.
  29454. *
  29455. * @param {Highcharts.ChartIsInsideOptionsObject} [options]
  29456. * Options object.
  29457. *
  29458. * @return {boolean}
  29459. * Returns true if the given point is inside the plot area.
  29460. */
  29461. Chart.prototype.isInsidePlot = function (plotX, plotY, options) {
  29462. if (options === void 0) { options = {}; }
  29463. var _a = this,
  29464. inverted = _a.inverted,
  29465. plotBox = _a.plotBox,
  29466. plotLeft = _a.plotLeft,
  29467. plotTop = _a.plotTop,
  29468. scrollablePlotBox = _a.scrollablePlotBox,
  29469. _b = _a.scrollingContainer,
  29470. _c = _b === void 0 ? {
  29471. scrollLeft: 0,
  29472. scrollTop: 0
  29473. } : _b,
  29474. scrollLeft = _c.scrollLeft,
  29475. scrollTop = _c.scrollTop;
  29476. var series = options.series;
  29477. var box = (options.visiblePlotOnly && scrollablePlotBox) || plotBox;
  29478. var x = options.inverted ? plotY : plotX;
  29479. var y = options.inverted ? plotX : plotY;
  29480. var e = {
  29481. x: x,
  29482. y: y,
  29483. isInsidePlot: true
  29484. };
  29485. if (!options.ignoreX) {
  29486. var xAxis = (series && (inverted ? series.yAxis : series.xAxis)) || {
  29487. pos: plotLeft,
  29488. len: Infinity
  29489. };
  29490. var chartX = options.paneCoordinates ? xAxis.pos + x : plotLeft + x;
  29491. if (!(chartX >= Math.max(scrollLeft + plotLeft, xAxis.pos) &&
  29492. chartX <= Math.min(scrollLeft + plotLeft + box.width, xAxis.pos + xAxis.len))) {
  29493. e.isInsidePlot = false;
  29494. }
  29495. }
  29496. if (!options.ignoreY && e.isInsidePlot) {
  29497. var yAxis = (series && (inverted ? series.xAxis : series.yAxis)) || {
  29498. pos: plotTop,
  29499. len: Infinity
  29500. };
  29501. var chartY = options.paneCoordinates ? yAxis.pos + y : plotTop + y;
  29502. if (!(chartY >= Math.max(scrollTop + plotTop, yAxis.pos) &&
  29503. chartY <= Math.min(scrollTop + plotTop + box.height, yAxis.pos + yAxis.len))) {
  29504. e.isInsidePlot = false;
  29505. }
  29506. }
  29507. fireEvent(this, 'afterIsInsidePlot', e);
  29508. return e.isInsidePlot;
  29509. };
  29510. /**
  29511. * Redraw the chart after changes have been done to the data, axis extremes
  29512. * chart size or chart elements. All methods for updating axes, series or
  29513. * points have a parameter for redrawing the chart. This is `true` by
  29514. * default. But in many cases you want to do more than one operation on the
  29515. * chart before redrawing, for example add a number of points. In those
  29516. * cases it is a waste of resources to redraw the chart for each new point
  29517. * added. So you add the points and call `chart.redraw()` after.
  29518. *
  29519. * @function Highcharts.Chart#redraw
  29520. *
  29521. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  29522. * If or how to apply animation to the redraw.
  29523. *
  29524. * @fires Highcharts.Chart#event:afterSetExtremes
  29525. * @fires Highcharts.Chart#event:beforeRedraw
  29526. * @fires Highcharts.Chart#event:predraw
  29527. * @fires Highcharts.Chart#event:redraw
  29528. * @fires Highcharts.Chart#event:render
  29529. * @fires Highcharts.Chart#event:updatedData
  29530. */
  29531. Chart.prototype.redraw = function (animation) {
  29532. fireEvent(this, 'beforeRedraw');
  29533. var chart = this,
  29534. axes = chart.hasCartesianSeries ? chart.axes : chart.colorAxis || [],
  29535. series = chart.series,
  29536. pointer = chart.pointer,
  29537. legend = chart.legend,
  29538. legendUserOptions = chart.userOptions.legend,
  29539. redrawLegend = chart.isDirtyLegend,
  29540. hasStackedSeries,
  29541. hasDirtyStacks,
  29542. isDirtyBox = chart.isDirtyBox,
  29543. i,
  29544. serie,
  29545. renderer = chart.renderer,
  29546. isHiddenChart = renderer.isHidden(),
  29547. afterRedraw = [];
  29548. // Handle responsive rules, not only on resize (#6130)
  29549. if (chart.setResponsive) {
  29550. chart.setResponsive(false);
  29551. }
  29552. // Set the global animation. When chart.hasRendered is not true, the
  29553. // redraw call comes from a responsive rule and animation should not
  29554. // occur.
  29555. setAnimation(chart.hasRendered ? animation : false, chart);
  29556. if (isHiddenChart) {
  29557. chart.temporaryDisplay();
  29558. }
  29559. // Adjust title layout (reflow multiline text)
  29560. chart.layOutTitles();
  29561. // link stacked series
  29562. i = series.length;
  29563. while (i--) {
  29564. serie = series[i];
  29565. if (serie.options.stacking || serie.options.centerInCategory) {
  29566. hasStackedSeries = true;
  29567. if (serie.isDirty) {
  29568. hasDirtyStacks = true;
  29569. break;
  29570. }
  29571. }
  29572. }
  29573. if (hasDirtyStacks) { // mark others as dirty
  29574. i = series.length;
  29575. while (i--) {
  29576. serie = series[i];
  29577. if (serie.options.stacking) {
  29578. serie.isDirty = true;
  29579. }
  29580. }
  29581. }
  29582. // Handle updated data in the series
  29583. series.forEach(function (serie) {
  29584. if (serie.isDirty) {
  29585. if (serie.options.legendType === 'point') {
  29586. if (typeof serie.updateTotals === 'function') {
  29587. serie.updateTotals();
  29588. }
  29589. redrawLegend = true;
  29590. }
  29591. else if (legendUserOptions &&
  29592. (legendUserOptions.labelFormatter ||
  29593. legendUserOptions.labelFormat)) {
  29594. redrawLegend = true; // #2165
  29595. }
  29596. }
  29597. if (serie.isDirtyData) {
  29598. fireEvent(serie, 'updatedData');
  29599. }
  29600. });
  29601. // handle added or removed series
  29602. if (redrawLegend && legend && legend.options.enabled) {
  29603. // draw legend graphics
  29604. legend.render();
  29605. chart.isDirtyLegend = false;
  29606. }
  29607. // reset stacks
  29608. if (hasStackedSeries) {
  29609. chart.getStacks();
  29610. }
  29611. // set axes scales
  29612. axes.forEach(function (axis) {
  29613. axis.updateNames();
  29614. axis.setScale();
  29615. });
  29616. chart.getMargins(); // #3098
  29617. // If one axis is dirty, all axes must be redrawn (#792, #2169)
  29618. axes.forEach(function (axis) {
  29619. if (axis.isDirty) {
  29620. isDirtyBox = true;
  29621. }
  29622. });
  29623. // redraw axes
  29624. axes.forEach(function (axis) {
  29625. // Fire 'afterSetExtremes' only if extremes are set
  29626. var key = axis.min + ',' + axis.max;
  29627. if (axis.extKey !== key) { // #821, #4452
  29628. axis.extKey = key;
  29629. // prevent a recursive call to chart.redraw() (#1119)
  29630. afterRedraw.push(function () {
  29631. fireEvent(axis, 'afterSetExtremes', extend(axis.eventArgs, axis.getExtremes())); // #747, #751
  29632. delete axis.eventArgs;
  29633. });
  29634. }
  29635. if (isDirtyBox || hasStackedSeries) {
  29636. axis.redraw();
  29637. }
  29638. });
  29639. // the plot areas size has changed
  29640. if (isDirtyBox) {
  29641. chart.drawChartBox();
  29642. }
  29643. // Fire an event before redrawing series, used by the boost module to
  29644. // clear previous series renderings.
  29645. fireEvent(chart, 'predraw');
  29646. // redraw affected series
  29647. series.forEach(function (serie) {
  29648. if ((isDirtyBox || serie.isDirty) && serie.visible) {
  29649. serie.redraw();
  29650. }
  29651. // Set it here, otherwise we will have unlimited 'updatedData' calls
  29652. // for a hidden series after setData(). Fixes #6012
  29653. serie.isDirtyData = false;
  29654. });
  29655. // move tooltip or reset
  29656. if (pointer) {
  29657. pointer.reset(true);
  29658. }
  29659. // redraw if canvas
  29660. renderer.draw();
  29661. // Fire the events
  29662. fireEvent(chart, 'redraw');
  29663. fireEvent(chart, 'render');
  29664. if (isHiddenChart) {
  29665. chart.temporaryDisplay(true);
  29666. }
  29667. // Fire callbacks that are put on hold until after the redraw
  29668. afterRedraw.forEach(function (callback) {
  29669. callback.call();
  29670. });
  29671. };
  29672. /**
  29673. * Get an axis, series or point object by `id` as given in the configuration
  29674. * options. Returns `undefined` if no item is found.
  29675. *
  29676. * @sample highcharts/plotoptions/series-id/
  29677. * Get series by id
  29678. *
  29679. * @function Highcharts.Chart#get
  29680. *
  29681. * @param {string} id
  29682. * The id as given in the configuration options.
  29683. *
  29684. * @return {Highcharts.Axis|Highcharts.Series|Highcharts.Point|undefined}
  29685. * The retrieved item.
  29686. */
  29687. Chart.prototype.get = function (id) {
  29688. var ret,
  29689. series = this.series,
  29690. i;
  29691. /**
  29692. * @private
  29693. * @param {Highcharts.Axis|Highcharts.Series} item
  29694. * @return {boolean}
  29695. */
  29696. function itemById(item) {
  29697. return (item.id === id ||
  29698. (item.options && item.options.id === id));
  29699. }
  29700. ret =
  29701. // Search axes
  29702. find(this.axes, itemById) ||
  29703. // Search series
  29704. find(this.series, itemById);
  29705. // Search points
  29706. for (i = 0; !ret && i < series.length; i++) {
  29707. ret = find(series[i].points || [], itemById);
  29708. }
  29709. return ret;
  29710. };
  29711. /**
  29712. * Create the Axis instances based on the config options.
  29713. *
  29714. * @private
  29715. * @function Highcharts.Chart#getAxes
  29716. * @fires Highcharts.Chart#event:afterGetAxes
  29717. * @fires Highcharts.Chart#event:getAxes
  29718. */
  29719. Chart.prototype.getAxes = function () {
  29720. var chart = this,
  29721. options = this.options,
  29722. xAxisOptions = options.xAxis = splat(options.xAxis || {}),
  29723. yAxisOptions = options.yAxis = splat(options.yAxis || {}),
  29724. optionsArray;
  29725. fireEvent(this, 'getAxes');
  29726. // make sure the options are arrays and add some members
  29727. xAxisOptions.forEach(function (axis, i) {
  29728. axis.index = i;
  29729. axis.isX = true;
  29730. });
  29731. yAxisOptions.forEach(function (axis, i) {
  29732. axis.index = i;
  29733. });
  29734. // concatenate all axis options into one array
  29735. optionsArray = xAxisOptions.concat(yAxisOptions);
  29736. optionsArray.forEach(function (axisOptions) {
  29737. new Axis(chart, axisOptions); // eslint-disable-line no-new
  29738. });
  29739. fireEvent(this, 'afterGetAxes');
  29740. };
  29741. /**
  29742. * Returns an array of all currently selected points in the chart. Points
  29743. * can be selected by clicking or programmatically by the
  29744. * {@link Highcharts.Point#select}
  29745. * function.
  29746. *
  29747. * @sample highcharts/plotoptions/series-allowpointselect-line/
  29748. * Get selected points
  29749. *
  29750. * @function Highcharts.Chart#getSelectedPoints
  29751. *
  29752. * @return {Array<Highcharts.Point>}
  29753. * The currently selected points.
  29754. */
  29755. Chart.prototype.getSelectedPoints = function () {
  29756. var points = [];
  29757. this.series.forEach(function (serie) {
  29758. // For one-to-one points inspect series.data in order to retrieve
  29759. // points outside the visible range (#6445). For grouped data,
  29760. // inspect the generated series.points.
  29761. points = points.concat(serie.getPointsCollection().filter(function (point) {
  29762. return pick(point.selectedStaging, point.selected);
  29763. }));
  29764. });
  29765. return points;
  29766. };
  29767. /**
  29768. * Returns an array of all currently selected series in the chart. Series
  29769. * can be selected either programmatically by the
  29770. * {@link Highcharts.Series#select}
  29771. * function or by checking the checkbox next to the legend item if
  29772. * [series.showCheckBox](https://api.highcharts.com/highcharts/plotOptions.series.showCheckbox)
  29773. * is true.
  29774. *
  29775. * @sample highcharts/members/chart-getselectedseries/
  29776. * Get selected series
  29777. *
  29778. * @function Highcharts.Chart#getSelectedSeries
  29779. *
  29780. * @return {Array<Highcharts.Series>}
  29781. * The currently selected series.
  29782. */
  29783. Chart.prototype.getSelectedSeries = function () {
  29784. return this.series.filter(function (serie) {
  29785. return serie.selected;
  29786. });
  29787. };
  29788. /**
  29789. * Set a new title or subtitle for the chart.
  29790. *
  29791. * @sample highcharts/members/chart-settitle/
  29792. * Set title text and styles
  29793. *
  29794. * @function Highcharts.Chart#setTitle
  29795. *
  29796. * @param {Highcharts.TitleOptions} [titleOptions]
  29797. * New title options. The title text itself is set by the
  29798. * `titleOptions.text` property.
  29799. *
  29800. * @param {Highcharts.SubtitleOptions} [subtitleOptions]
  29801. * New subtitle options. The subtitle text itself is set by the
  29802. * `subtitleOptions.text` property.
  29803. *
  29804. * @param {boolean} [redraw]
  29805. * Whether to redraw the chart or wait for a later call to
  29806. * `chart.redraw()`.
  29807. */
  29808. Chart.prototype.setTitle = function (titleOptions, subtitleOptions, redraw) {
  29809. this.applyDescription('title', titleOptions);
  29810. this.applyDescription('subtitle', subtitleOptions);
  29811. // The initial call also adds the caption. On update, chart.update will
  29812. // relay to Chart.setCaption.
  29813. this.applyDescription('caption', void 0);
  29814. this.layOutTitles(redraw);
  29815. };
  29816. /**
  29817. * Apply a title, subtitle or caption for the chart
  29818. *
  29819. * @private
  29820. * @function Highcharts.Chart#applyDescription
  29821. * @param name {string}
  29822. * Either title, subtitle or caption
  29823. * @param {Highcharts.TitleOptions|Highcharts.SubtitleOptions|Highcharts.CaptionOptions|undefined} explicitOptions
  29824. * The options to set, will be merged with default options.
  29825. */
  29826. Chart.prototype.applyDescription = function (name, explicitOptions) {
  29827. var chart = this;
  29828. // Default style
  29829. var style = name === 'title' ? {
  29830. color: palette.neutralColor80,
  29831. fontSize: this.options.isStock ? '16px' : '18px' // #2944
  29832. } : {
  29833. color: palette.neutralColor60
  29834. };
  29835. // Merge default options with explicit options
  29836. var options = this.options[name] = merge(
  29837. // Default styles
  29838. (!this.styledMode && { style: style }),
  29839. this.options[name],
  29840. explicitOptions);
  29841. var elem = this[name];
  29842. if (elem && explicitOptions) {
  29843. this[name] = elem = elem.destroy(); // remove old
  29844. }
  29845. if (options && !elem) {
  29846. elem = this.renderer.text(options.text, 0, 0, options.useHTML)
  29847. .attr({
  29848. align: options.align,
  29849. 'class': 'highcharts-' + name,
  29850. zIndex: options.zIndex || 4
  29851. })
  29852. .add();
  29853. // Update methods, shortcut to Chart.setTitle, Chart.setSubtitle and
  29854. // Chart.setCaption
  29855. elem.update = function (updateOptions) {
  29856. var fn = {
  29857. title: 'setTitle',
  29858. subtitle: 'setSubtitle',
  29859. caption: 'setCaption'
  29860. }[name];
  29861. chart[fn](updateOptions);
  29862. };
  29863. // Presentational
  29864. if (!this.styledMode) {
  29865. elem.css(options.style);
  29866. }
  29867. /**
  29868. * The chart title. The title has an `update` method that allows
  29869. * modifying the options directly or indirectly via
  29870. * `chart.update`.
  29871. *
  29872. * @sample highcharts/members/title-update/
  29873. * Updating titles
  29874. *
  29875. * @name Highcharts.Chart#title
  29876. * @type {Highcharts.TitleObject}
  29877. */
  29878. /**
  29879. * The chart subtitle. The subtitle has an `update` method that
  29880. * allows modifying the options directly or indirectly via
  29881. * `chart.update`.
  29882. *
  29883. * @name Highcharts.Chart#subtitle
  29884. * @type {Highcharts.SubtitleObject}
  29885. */
  29886. this[name] = elem;
  29887. }
  29888. };
  29889. /**
  29890. * Internal function to lay out the chart title, subtitle and caption, and
  29891. * cache the full offset height for use in `getMargins`. The result is
  29892. * stored in `this.titleOffset`.
  29893. *
  29894. * @private
  29895. * @function Highcharts.Chart#layOutTitles
  29896. *
  29897. * @param {boolean} [redraw=true]
  29898. * @fires Highcharts.Chart#event:afterLayOutTitles
  29899. */
  29900. Chart.prototype.layOutTitles = function (redraw) {
  29901. var titleOffset = [0, 0, 0],
  29902. requiresDirtyBox,
  29903. renderer = this.renderer,
  29904. spacingBox = this.spacingBox;
  29905. // Lay out the title and the subtitle respectively
  29906. ['title', 'subtitle', 'caption'].forEach(function (key) {
  29907. var title = this[key], titleOptions = this.options[key], verticalAlign = titleOptions.verticalAlign || 'top', offset = key === 'title' ? -3 :
  29908. // Floating subtitle (#6574)
  29909. verticalAlign === 'top' ? titleOffset[0] + 2 : 0, titleSize, height;
  29910. if (title) {
  29911. if (!this.styledMode) {
  29912. titleSize = titleOptions.style.fontSize;
  29913. }
  29914. titleSize = renderer.fontMetrics(titleSize, title).b;
  29915. title
  29916. .css({
  29917. width: (titleOptions.width ||
  29918. spacingBox.width + (titleOptions.widthAdjust || 0)) + 'px'
  29919. });
  29920. // Skip the cache for HTML (#3481, #11666)
  29921. height = Math.round(title.getBBox(titleOptions.useHTML).height);
  29922. title.align(extend({
  29923. y: verticalAlign === 'bottom' ?
  29924. titleSize :
  29925. offset + titleSize,
  29926. height: height
  29927. }, titleOptions), false, 'spacingBox');
  29928. if (!titleOptions.floating) {
  29929. if (verticalAlign === 'top') {
  29930. titleOffset[0] = Math.ceil(titleOffset[0] +
  29931. height);
  29932. }
  29933. else if (verticalAlign === 'bottom') {
  29934. titleOffset[2] = Math.ceil(titleOffset[2] +
  29935. height);
  29936. }
  29937. }
  29938. }
  29939. }, this);
  29940. // Handle title.margin and caption.margin
  29941. if (titleOffset[0] &&
  29942. (this.options.title.verticalAlign || 'top') === 'top') {
  29943. titleOffset[0] += this.options.title.margin;
  29944. }
  29945. if (titleOffset[2] &&
  29946. this.options.caption.verticalAlign === 'bottom') {
  29947. titleOffset[2] += this.options.caption.margin;
  29948. }
  29949. requiresDirtyBox = (!this.titleOffset ||
  29950. this.titleOffset.join(',') !== titleOffset.join(','));
  29951. // Used in getMargins
  29952. this.titleOffset = titleOffset;
  29953. fireEvent(this, 'afterLayOutTitles');
  29954. if (!this.isDirtyBox && requiresDirtyBox) {
  29955. this.isDirtyBox = this.isDirtyLegend = requiresDirtyBox;
  29956. // Redraw if necessary (#2719, #2744)
  29957. if (this.hasRendered && pick(redraw, true) && this.isDirtyBox) {
  29958. this.redraw();
  29959. }
  29960. }
  29961. };
  29962. /**
  29963. * Internal function to get the chart width and height according to options
  29964. * and container size. Sets {@link Chart.chartWidth} and
  29965. * {@link Chart.chartHeight}.
  29966. *
  29967. * @private
  29968. * @function Highcharts.Chart#getChartSize
  29969. */
  29970. Chart.prototype.getChartSize = function () {
  29971. var chart = this,
  29972. optionsChart = chart.options.chart,
  29973. widthOption = optionsChart.width,
  29974. heightOption = optionsChart.height,
  29975. renderTo = chart.renderTo;
  29976. // Get inner width and height
  29977. if (!defined(widthOption)) {
  29978. chart.containerWidth = getStyle(renderTo, 'width');
  29979. }
  29980. if (!defined(heightOption)) {
  29981. chart.containerHeight = getStyle(renderTo, 'height');
  29982. }
  29983. /**
  29984. * The current pixel width of the chart.
  29985. *
  29986. * @name Highcharts.Chart#chartWidth
  29987. * @type {number}
  29988. */
  29989. chart.chartWidth = Math.max(// #1393
  29990. 0, widthOption || chart.containerWidth || 600 // #1460
  29991. );
  29992. /**
  29993. * The current pixel height of the chart.
  29994. *
  29995. * @name Highcharts.Chart#chartHeight
  29996. * @type {number}
  29997. */
  29998. chart.chartHeight = Math.max(0, relativeLength(heightOption, chart.chartWidth) ||
  29999. (chart.containerHeight > 1 ?
  30000. chart.containerHeight :
  30001. 400));
  30002. };
  30003. /**
  30004. * If the renderTo element has no offsetWidth, most likely one or more of
  30005. * its parents are hidden. Loop up the DOM tree to temporarily display the
  30006. * parents, then save the original display properties, and when the true
  30007. * size is retrieved, reset them. Used on first render and on redraws.
  30008. *
  30009. * @private
  30010. * @function Highcharts.Chart#temporaryDisplay
  30011. *
  30012. * @param {boolean} [revert]
  30013. * Revert to the saved original styles.
  30014. */
  30015. Chart.prototype.temporaryDisplay = function (revert) {
  30016. var node = this.renderTo,
  30017. tempStyle;
  30018. if (!revert) {
  30019. while (node && node.style) {
  30020. // When rendering to a detached node, it needs to be temporarily
  30021. // attached in order to read styling and bounding boxes (#5783,
  30022. // #7024).
  30023. if (!doc.body.contains(node) && !node.parentNode) {
  30024. node.hcOrigDetached = true;
  30025. doc.body.appendChild(node);
  30026. }
  30027. if (getStyle(node, 'display', false) === 'none' ||
  30028. node.hcOricDetached) {
  30029. node.hcOrigStyle = {
  30030. display: node.style.display,
  30031. height: node.style.height,
  30032. overflow: node.style.overflow
  30033. };
  30034. tempStyle = {
  30035. display: 'block',
  30036. overflow: 'hidden'
  30037. };
  30038. if (node !== this.renderTo) {
  30039. tempStyle.height = 0;
  30040. }
  30041. css(node, tempStyle);
  30042. // If it still doesn't have an offset width after setting
  30043. // display to block, it probably has an !important priority
  30044. // #2631, 6803
  30045. if (!node.offsetWidth) {
  30046. node.style.setProperty('display', 'block', 'important');
  30047. }
  30048. }
  30049. node = node.parentNode;
  30050. if (node === doc.body) {
  30051. break;
  30052. }
  30053. }
  30054. }
  30055. else {
  30056. while (node && node.style) {
  30057. if (node.hcOrigStyle) {
  30058. css(node, node.hcOrigStyle);
  30059. delete node.hcOrigStyle;
  30060. }
  30061. if (node.hcOrigDetached) {
  30062. doc.body.removeChild(node);
  30063. node.hcOrigDetached = false;
  30064. }
  30065. node = node.parentNode;
  30066. }
  30067. }
  30068. };
  30069. /**
  30070. * Set the {@link Chart.container|chart container's} class name, in
  30071. * addition to `highcharts-container`.
  30072. *
  30073. * @function Highcharts.Chart#setClassName
  30074. *
  30075. * @param {string} [className]
  30076. * The additional class name.
  30077. */
  30078. Chart.prototype.setClassName = function (className) {
  30079. this.container.className = 'highcharts-container ' + (className || '');
  30080. };
  30081. /**
  30082. * Get the containing element, determine the size and create the inner
  30083. * container div to hold the chart.
  30084. *
  30085. * @private
  30086. * @function Highcharts.Chart#afterGetContainer
  30087. * @fires Highcharts.Chart#event:afterGetContainer
  30088. */
  30089. Chart.prototype.getContainer = function () {
  30090. var chart = this,
  30091. container,
  30092. options = chart.options,
  30093. optionsChart = options.chart,
  30094. chartWidth,
  30095. chartHeight,
  30096. renderTo = chart.renderTo,
  30097. indexAttrName = 'data-highcharts-chart',
  30098. oldChartIndex,
  30099. Ren,
  30100. containerId = uniqueKey(),
  30101. containerStyle,
  30102. key;
  30103. if (!renderTo) {
  30104. chart.renderTo = renderTo =
  30105. optionsChart.renderTo;
  30106. }
  30107. if (isString(renderTo)) {
  30108. chart.renderTo = renderTo =
  30109. doc.getElementById(renderTo);
  30110. }
  30111. // Display an error if the renderTo is wrong
  30112. if (!renderTo) {
  30113. error(13, true, chart);
  30114. }
  30115. // If the container already holds a chart, destroy it. The check for
  30116. // hasRendered is there because web pages that are saved to disk from
  30117. // the browser, will preserve the data-highcharts-chart attribute and
  30118. // the SVG contents, but not an interactive chart. So in this case,
  30119. // charts[oldChartIndex] will point to the wrong chart if any (#2609).
  30120. oldChartIndex = pInt(attr(renderTo, indexAttrName));
  30121. if (isNumber(oldChartIndex) &&
  30122. charts[oldChartIndex] &&
  30123. charts[oldChartIndex].hasRendered) {
  30124. charts[oldChartIndex].destroy();
  30125. }
  30126. // Make a reference to the chart from the div
  30127. attr(renderTo, indexAttrName, chart.index);
  30128. // remove previous chart
  30129. renderTo.innerHTML = '';
  30130. // If the container doesn't have an offsetWidth, it has or is a child of
  30131. // a node that has display:none. We need to temporarily move it out to a
  30132. // visible state to determine the size, else the legend and tooltips
  30133. // won't render properly. The skipClone option is used in sparklines as
  30134. // a micro optimization, saving about 1-2 ms each chart.
  30135. if (!optionsChart.skipClone && !renderTo.offsetWidth) {
  30136. chart.temporaryDisplay();
  30137. }
  30138. // get the width and height
  30139. chart.getChartSize();
  30140. chartWidth = chart.chartWidth;
  30141. chartHeight = chart.chartHeight;
  30142. // Allow table cells and flex-boxes to shrink without the chart blocking
  30143. // them out (#6427)
  30144. css(renderTo, { overflow: 'hidden' });
  30145. // Create the inner container
  30146. if (!chart.styledMode) {
  30147. containerStyle = extend({
  30148. position: 'relative',
  30149. // needed for context menu (avoidscrollbars) and content
  30150. // overflow in IE
  30151. overflow: 'hidden',
  30152. width: chartWidth + 'px',
  30153. height: chartHeight + 'px',
  30154. textAlign: 'left',
  30155. lineHeight: 'normal',
  30156. zIndex: 0,
  30157. '-webkit-tap-highlight-color': 'rgba(0,0,0,0)',
  30158. userSelect: 'none',
  30159. 'touch-action': 'manipulation',
  30160. outline: 'none'
  30161. }, optionsChart.style || {});
  30162. }
  30163. /**
  30164. * The containing HTML element of the chart. The container is
  30165. * dynamically inserted into the element given as the `renderTo`
  30166. * parameter in the {@link Highcharts#chart} constructor.
  30167. *
  30168. * @name Highcharts.Chart#container
  30169. * @type {Highcharts.HTMLDOMElement}
  30170. */
  30171. container = createElement('div', {
  30172. id: containerId
  30173. }, containerStyle, renderTo);
  30174. chart.container = container;
  30175. // cache the cursor (#1650)
  30176. chart._cursor = container.style.cursor;
  30177. // Initialize the renderer
  30178. Ren = H[optionsChart.renderer] || H.Renderer;
  30179. /**
  30180. * The renderer instance of the chart. Each chart instance has only one
  30181. * associated renderer.
  30182. *
  30183. * @name Highcharts.Chart#renderer
  30184. * @type {Highcharts.SVGRenderer}
  30185. */
  30186. chart.renderer = new Ren(container, chartWidth, chartHeight, null, optionsChart.forExport, options.exporting && options.exporting.allowHTML, chart.styledMode);
  30187. // Set the initial animation from the options
  30188. setAnimation(void 0, chart);
  30189. chart.setClassName(optionsChart.className);
  30190. if (!chart.styledMode) {
  30191. chart.renderer.setStyle(optionsChart.style);
  30192. }
  30193. else {
  30194. // Initialize definitions
  30195. for (key in options.defs) { // eslint-disable-line guard-for-in
  30196. this.renderer.definition(options.defs[key]);
  30197. }
  30198. }
  30199. // Add a reference to the charts index
  30200. chart.renderer.chartIndex = chart.index;
  30201. fireEvent(this, 'afterGetContainer');
  30202. };
  30203. /**
  30204. * Calculate margins by rendering axis labels in a preliminary position.
  30205. * Title, subtitle and legend have already been rendered at this stage, but
  30206. * will be moved into their final positions.
  30207. *
  30208. * @private
  30209. * @function Highcharts.Chart#getMargins
  30210. * @fires Highcharts.Chart#event:getMargins
  30211. */
  30212. Chart.prototype.getMargins = function (skipAxes) {
  30213. var _a = this,
  30214. spacing = _a.spacing,
  30215. margin = _a.margin,
  30216. titleOffset = _a.titleOffset;
  30217. this.resetMargins();
  30218. // Adjust for title and subtitle
  30219. if (titleOffset[0] && !defined(margin[0])) {
  30220. this.plotTop = Math.max(this.plotTop, titleOffset[0] + spacing[0]);
  30221. }
  30222. if (titleOffset[2] && !defined(margin[2])) {
  30223. this.marginBottom = Math.max(this.marginBottom, titleOffset[2] + spacing[2]);
  30224. }
  30225. // Adjust for legend
  30226. if (this.legend && this.legend.display) {
  30227. this.legend.adjustMargins(margin, spacing);
  30228. }
  30229. fireEvent(this, 'getMargins');
  30230. if (!skipAxes) {
  30231. this.getAxisMargins();
  30232. }
  30233. };
  30234. /**
  30235. * @private
  30236. * @function Highcharts.Chart#getAxisMargins
  30237. */
  30238. Chart.prototype.getAxisMargins = function () {
  30239. var chart = this,
  30240. // [top, right, bottom, left]
  30241. axisOffset = chart.axisOffset = [0, 0, 0, 0],
  30242. colorAxis = chart.colorAxis,
  30243. margin = chart.margin,
  30244. getOffset = function (axes) {
  30245. axes.forEach(function (axis) {
  30246. if (axis.visible) {
  30247. axis.getOffset();
  30248. }
  30249. });
  30250. };
  30251. // pre-render axes to get labels offset width
  30252. if (chart.hasCartesianSeries) {
  30253. getOffset(chart.axes);
  30254. }
  30255. else if (colorAxis && colorAxis.length) {
  30256. getOffset(colorAxis);
  30257. }
  30258. // Add the axis offsets
  30259. marginNames.forEach(function (m, side) {
  30260. if (!defined(margin[side])) {
  30261. chart[m] += axisOffset[side];
  30262. }
  30263. });
  30264. chart.setChartSize();
  30265. };
  30266. /**
  30267. * Reflows the chart to its container. By default, the chart reflows
  30268. * automatically to its container following a `window.resize` event, as per
  30269. * the [chart.reflow](https://api.highcharts.com/highcharts/chart.reflow)
  30270. * option. However, there are no reliable events for div resize, so if the
  30271. * container is resized without a window resize event, this must be called
  30272. * explicitly.
  30273. *
  30274. * @sample highcharts/members/chart-reflow/
  30275. * Resize div and reflow
  30276. * @sample highcharts/chart/events-container/
  30277. * Pop up and reflow
  30278. *
  30279. * @function Highcharts.Chart#reflow
  30280. *
  30281. * @param {global.Event} [e]
  30282. * Event arguments. Used primarily when the function is called
  30283. * internally as a response to window resize.
  30284. */
  30285. Chart.prototype.reflow = function (e) {
  30286. var chart = this, optionsChart = chart.options.chart, renderTo = chart.renderTo, hasUserSize = (defined(optionsChart.width) &&
  30287. defined(optionsChart.height)), width = optionsChart.width || getStyle(renderTo, 'width'), height = optionsChart.height || getStyle(renderTo, 'height'), target = e ? e.target : win;
  30288. delete chart.pointer.chartPosition;
  30289. // Width and height checks for display:none. Target is doc in IE8 and
  30290. // Opera, win in Firefox, Chrome and IE9.
  30291. if (!hasUserSize &&
  30292. !chart.isPrinting &&
  30293. width &&
  30294. height &&
  30295. (target === win || target === doc)) {
  30296. if (width !== chart.containerWidth ||
  30297. height !== chart.containerHeight) {
  30298. U.clearTimeout(chart.reflowTimeout);
  30299. // When called from window.resize, e is set, else it's called
  30300. // directly (#2224)
  30301. chart.reflowTimeout = syncTimeout(function () {
  30302. // Set size, it may have been destroyed in the meantime
  30303. // (#1257)
  30304. if (chart.container) {
  30305. chart.setSize(void 0, void 0, false);
  30306. }
  30307. }, e ? 100 : 0);
  30308. }
  30309. chart.containerWidth = width;
  30310. chart.containerHeight = height;
  30311. }
  30312. };
  30313. /**
  30314. * Toggle the event handlers necessary for auto resizing, depending on the
  30315. * `chart.reflow` option.
  30316. *
  30317. * @private
  30318. * @function Highcharts.Chart#setReflow
  30319. */
  30320. Chart.prototype.setReflow = function (reflow) {
  30321. var chart = this;
  30322. if (reflow !== false && !this.unbindReflow) {
  30323. this.unbindReflow = addEvent(win, 'resize', function (e) {
  30324. // a removed event listener still runs in Edge and IE if the
  30325. // listener was removed while the event runs, so check if the
  30326. // chart is not destroyed (#11609)
  30327. if (chart.options) {
  30328. chart.reflow(e);
  30329. }
  30330. });
  30331. addEvent(this, 'destroy', this.unbindReflow);
  30332. }
  30333. else if (reflow === false && this.unbindReflow) {
  30334. // Unbind and unset
  30335. this.unbindReflow = this.unbindReflow();
  30336. }
  30337. // The following will add listeners to re-fit the chart before and after
  30338. // printing (#2284). However it only works in WebKit. Should have worked
  30339. // in Firefox, but not supported in IE.
  30340. /*
  30341. if (win.matchMedia) {
  30342. win.matchMedia('print').addListener(function reflow() {
  30343. chart.reflow();
  30344. });
  30345. }
  30346. //*/
  30347. };
  30348. /**
  30349. * Resize the chart to a given width and height. In order to set the width
  30350. * only, the height argument may be skipped. To set the height only, pass
  30351. * `undefined` for the width.
  30352. *
  30353. * @sample highcharts/members/chart-setsize-button/
  30354. * Test resizing from buttons
  30355. * @sample highcharts/members/chart-setsize-jquery-resizable/
  30356. * Add a jQuery UI resizable
  30357. * @sample stock/members/chart-setsize/
  30358. * Highcharts Stock with UI resizable
  30359. *
  30360. * @function Highcharts.Chart#setSize
  30361. *
  30362. * @param {number|null} [width]
  30363. * The new pixel width of the chart. Since v4.2.6, the argument can
  30364. * be `undefined` in order to preserve the current value (when
  30365. * setting height only), or `null` to adapt to the width of the
  30366. * containing element.
  30367. *
  30368. * @param {number|null} [height]
  30369. * The new pixel height of the chart. Since v4.2.6, the argument can
  30370. * be `undefined` in order to preserve the current value, or `null`
  30371. * in order to adapt to the height of the containing element.
  30372. *
  30373. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  30374. * Whether and how to apply animation.
  30375. *
  30376. * @return {void}
  30377. *
  30378. * @fires Highcharts.Chart#event:endResize
  30379. * @fires Highcharts.Chart#event:resize
  30380. */
  30381. Chart.prototype.setSize = function (width, height, animation) {
  30382. var chart = this,
  30383. renderer = chart.renderer,
  30384. globalAnimation;
  30385. // Handle the isResizing counter
  30386. chart.isResizing += 1;
  30387. // set the animation for the current process
  30388. setAnimation(animation, chart);
  30389. globalAnimation = renderer.globalAnimation;
  30390. chart.oldChartHeight = chart.chartHeight;
  30391. chart.oldChartWidth = chart.chartWidth;
  30392. if (typeof width !== 'undefined') {
  30393. chart.options.chart.width = width;
  30394. }
  30395. if (typeof height !== 'undefined') {
  30396. chart.options.chart.height = height;
  30397. }
  30398. chart.getChartSize();
  30399. // Resize the container with the global animation applied if enabled
  30400. // (#2503)
  30401. if (!chart.styledMode) {
  30402. (globalAnimation ? animate : css)(chart.container, {
  30403. width: chart.chartWidth + 'px',
  30404. height: chart.chartHeight + 'px'
  30405. }, globalAnimation);
  30406. }
  30407. chart.setChartSize(true);
  30408. renderer.setSize(chart.chartWidth, chart.chartHeight, globalAnimation);
  30409. // handle axes
  30410. chart.axes.forEach(function (axis) {
  30411. axis.isDirty = true;
  30412. axis.setScale();
  30413. });
  30414. chart.isDirtyLegend = true; // force legend redraw
  30415. chart.isDirtyBox = true; // force redraw of plot and chart border
  30416. chart.layOutTitles(); // #2857
  30417. chart.getMargins();
  30418. chart.redraw(globalAnimation);
  30419. chart.oldChartHeight = null;
  30420. fireEvent(chart, 'resize');
  30421. // Fire endResize and set isResizing back. If animation is disabled,
  30422. // fire without delay
  30423. syncTimeout(function () {
  30424. if (chart) {
  30425. fireEvent(chart, 'endResize', null, function () {
  30426. chart.isResizing -= 1;
  30427. });
  30428. }
  30429. }, animObject(globalAnimation).duration);
  30430. };
  30431. /**
  30432. * Set the public chart properties. This is done before and after the
  30433. * pre-render to determine margin sizes.
  30434. *
  30435. * @private
  30436. * @function Highcharts.Chart#setChartSize
  30437. * @fires Highcharts.Chart#event:afterSetChartSize
  30438. */
  30439. Chart.prototype.setChartSize = function (skipAxes) {
  30440. var chart = this,
  30441. inverted = chart.inverted,
  30442. renderer = chart.renderer,
  30443. chartWidth = chart.chartWidth,
  30444. chartHeight = chart.chartHeight,
  30445. optionsChart = chart.options.chart,
  30446. spacing = chart.spacing,
  30447. clipOffset = chart.clipOffset,
  30448. clipX,
  30449. clipY,
  30450. plotLeft,
  30451. plotTop,
  30452. plotWidth,
  30453. plotHeight,
  30454. plotBorderWidth;
  30455. /**
  30456. * The current left position of the plot area in pixels.
  30457. *
  30458. * @name Highcharts.Chart#plotLeft
  30459. * @type {number}
  30460. */
  30461. chart.plotLeft = plotLeft = Math.round(chart.plotLeft);
  30462. /**
  30463. * The current top position of the plot area in pixels.
  30464. *
  30465. * @name Highcharts.Chart#plotTop
  30466. * @type {number}
  30467. */
  30468. chart.plotTop = plotTop = Math.round(chart.plotTop);
  30469. /**
  30470. * The current width of the plot area in pixels.
  30471. *
  30472. * @name Highcharts.Chart#plotWidth
  30473. * @type {number}
  30474. */
  30475. chart.plotWidth = plotWidth = Math.max(0, Math.round(chartWidth - plotLeft - chart.marginRight));
  30476. /**
  30477. * The current height of the plot area in pixels.
  30478. *
  30479. * @name Highcharts.Chart#plotHeight
  30480. * @type {number}
  30481. */
  30482. chart.plotHeight = plotHeight = Math.max(0, Math.round(chartHeight - plotTop - chart.marginBottom));
  30483. chart.plotSizeX = inverted ? plotHeight : plotWidth;
  30484. chart.plotSizeY = inverted ? plotWidth : plotHeight;
  30485. chart.plotBorderWidth = optionsChart.plotBorderWidth || 0;
  30486. // Set boxes used for alignment
  30487. chart.spacingBox = renderer.spacingBox = {
  30488. x: spacing[3],
  30489. y: spacing[0],
  30490. width: chartWidth - spacing[3] - spacing[1],
  30491. height: chartHeight - spacing[0] - spacing[2]
  30492. };
  30493. chart.plotBox = renderer.plotBox = {
  30494. x: plotLeft,
  30495. y: plotTop,
  30496. width: plotWidth,
  30497. height: plotHeight
  30498. };
  30499. plotBorderWidth = 2 * Math.floor(chart.plotBorderWidth / 2);
  30500. clipX = Math.ceil(Math.max(plotBorderWidth, clipOffset[3]) / 2);
  30501. clipY = Math.ceil(Math.max(plotBorderWidth, clipOffset[0]) / 2);
  30502. chart.clipBox = {
  30503. x: clipX,
  30504. y: clipY,
  30505. width: Math.floor(chart.plotSizeX -
  30506. Math.max(plotBorderWidth, clipOffset[1]) / 2 -
  30507. clipX),
  30508. height: Math.max(0, Math.floor(chart.plotSizeY -
  30509. Math.max(plotBorderWidth, clipOffset[2]) / 2 -
  30510. clipY))
  30511. };
  30512. if (!skipAxes) {
  30513. chart.axes.forEach(function (axis) {
  30514. axis.setAxisSize();
  30515. axis.setAxisTranslation();
  30516. });
  30517. renderer.alignElements();
  30518. }
  30519. fireEvent(chart, 'afterSetChartSize', { skipAxes: skipAxes });
  30520. };
  30521. /**
  30522. * Initial margins before auto size margins are applied.
  30523. *
  30524. * @private
  30525. * @function Highcharts.Chart#resetMargins
  30526. */
  30527. Chart.prototype.resetMargins = function () {
  30528. fireEvent(this, 'resetMargins');
  30529. var chart = this,
  30530. chartOptions = chart.options.chart;
  30531. // Create margin and spacing array
  30532. ['margin', 'spacing'].forEach(function splashArrays(target) {
  30533. var value = chartOptions[target],
  30534. values = isObject(value) ? value : [value,
  30535. value,
  30536. value,
  30537. value];
  30538. [
  30539. 'Top',
  30540. 'Right',
  30541. 'Bottom',
  30542. 'Left'
  30543. ].forEach(function (sideName, side) {
  30544. chart[target][side] = pick(chartOptions[target + sideName], values[side]);
  30545. });
  30546. });
  30547. // Set margin names like chart.plotTop, chart.plotLeft,
  30548. // chart.marginRight, chart.marginBottom.
  30549. marginNames.forEach(function (m, side) {
  30550. chart[m] = pick(chart.margin[side], chart.spacing[side]);
  30551. });
  30552. chart.axisOffset = [0, 0, 0, 0]; // top, right, bottom, left
  30553. chart.clipOffset = [0, 0, 0, 0];
  30554. };
  30555. /**
  30556. * Internal function to draw or redraw the borders and backgrounds for chart
  30557. * and plot area.
  30558. *
  30559. * @private
  30560. * @function Highcharts.Chart#drawChartBox
  30561. * @fires Highcharts.Chart#event:afterDrawChartBox
  30562. */
  30563. Chart.prototype.drawChartBox = function () {
  30564. var chart = this,
  30565. optionsChart = chart.options.chart,
  30566. renderer = chart.renderer,
  30567. chartWidth = chart.chartWidth,
  30568. chartHeight = chart.chartHeight,
  30569. chartBackground = chart.chartBackground,
  30570. plotBackground = chart.plotBackground,
  30571. plotBorder = chart.plotBorder,
  30572. chartBorderWidth,
  30573. styledMode = chart.styledMode,
  30574. plotBGImage = chart.plotBGImage,
  30575. chartBackgroundColor = optionsChart.backgroundColor,
  30576. plotBackgroundColor = optionsChart.plotBackgroundColor,
  30577. plotBackgroundImage = optionsChart.plotBackgroundImage,
  30578. mgn,
  30579. bgAttr,
  30580. plotLeft = chart.plotLeft,
  30581. plotTop = chart.plotTop,
  30582. plotWidth = chart.plotWidth,
  30583. plotHeight = chart.plotHeight,
  30584. plotBox = chart.plotBox,
  30585. clipRect = chart.clipRect,
  30586. clipBox = chart.clipBox,
  30587. verb = 'animate';
  30588. // Chart area
  30589. if (!chartBackground) {
  30590. chart.chartBackground = chartBackground = renderer.rect()
  30591. .addClass('highcharts-background')
  30592. .add();
  30593. verb = 'attr';
  30594. }
  30595. if (!styledMode) {
  30596. // Presentational
  30597. chartBorderWidth = optionsChart.borderWidth || 0;
  30598. mgn = chartBorderWidth + (optionsChart.shadow ? 8 : 0);
  30599. bgAttr = {
  30600. fill: chartBackgroundColor || 'none'
  30601. };
  30602. if (chartBorderWidth || chartBackground['stroke-width']) { // #980
  30603. bgAttr.stroke = optionsChart.borderColor;
  30604. bgAttr['stroke-width'] = chartBorderWidth;
  30605. }
  30606. chartBackground
  30607. .attr(bgAttr)
  30608. .shadow(optionsChart.shadow);
  30609. }
  30610. else {
  30611. chartBorderWidth = mgn = chartBackground.strokeWidth();
  30612. }
  30613. chartBackground[verb]({
  30614. x: mgn / 2,
  30615. y: mgn / 2,
  30616. width: chartWidth - mgn - chartBorderWidth % 2,
  30617. height: chartHeight - mgn - chartBorderWidth % 2,
  30618. r: optionsChart.borderRadius
  30619. });
  30620. // Plot background
  30621. verb = 'animate';
  30622. if (!plotBackground) {
  30623. verb = 'attr';
  30624. chart.plotBackground = plotBackground = renderer.rect()
  30625. .addClass('highcharts-plot-background')
  30626. .add();
  30627. }
  30628. plotBackground[verb](plotBox);
  30629. if (!styledMode) {
  30630. // Presentational attributes for the background
  30631. plotBackground
  30632. .attr({
  30633. fill: plotBackgroundColor || 'none'
  30634. })
  30635. .shadow(optionsChart.plotShadow);
  30636. // Create the background image
  30637. if (plotBackgroundImage) {
  30638. if (!plotBGImage) {
  30639. chart.plotBGImage = renderer.image(plotBackgroundImage, plotLeft, plotTop, plotWidth, plotHeight).add();
  30640. }
  30641. else {
  30642. if (plotBackgroundImage !== plotBGImage.attr('href')) {
  30643. plotBGImage.attr('href', plotBackgroundImage);
  30644. }
  30645. plotBGImage.animate(plotBox);
  30646. }
  30647. }
  30648. }
  30649. // Plot clip
  30650. if (!clipRect) {
  30651. chart.clipRect = renderer.clipRect(clipBox);
  30652. }
  30653. else {
  30654. clipRect.animate({
  30655. width: clipBox.width,
  30656. height: clipBox.height
  30657. });
  30658. }
  30659. // Plot area border
  30660. verb = 'animate';
  30661. if (!plotBorder) {
  30662. verb = 'attr';
  30663. chart.plotBorder = plotBorder = renderer.rect()
  30664. .addClass('highcharts-plot-border')
  30665. .attr({
  30666. zIndex: 1 // Above the grid
  30667. })
  30668. .add();
  30669. }
  30670. if (!styledMode) {
  30671. // Presentational
  30672. plotBorder.attr({
  30673. stroke: optionsChart.plotBorderColor,
  30674. 'stroke-width': optionsChart.plotBorderWidth || 0,
  30675. fill: 'none'
  30676. });
  30677. }
  30678. plotBorder[verb](plotBorder.crisp({
  30679. x: plotLeft,
  30680. y: plotTop,
  30681. width: plotWidth,
  30682. height: plotHeight
  30683. }, -plotBorder.strokeWidth())); // #3282 plotBorder should be negative;
  30684. // reset
  30685. chart.isDirtyBox = false;
  30686. fireEvent(this, 'afterDrawChartBox');
  30687. };
  30688. /**
  30689. * Detect whether a certain chart property is needed based on inspecting its
  30690. * options and series. This mainly applies to the chart.inverted property,
  30691. * and in extensions to the chart.angular and chart.polar properties.
  30692. *
  30693. * @private
  30694. * @function Highcharts.Chart#propFromSeries
  30695. * @return {void}
  30696. */
  30697. Chart.prototype.propFromSeries = function () {
  30698. var chart = this,
  30699. optionsChart = chart.options.chart,
  30700. klass,
  30701. seriesOptions = chart.options.series,
  30702. i,
  30703. value;
  30704. /**
  30705. * The flag is set to `true` if a series of the chart is inverted.
  30706. *
  30707. * @name Highcharts.Chart#inverted
  30708. * @type {boolean|undefined}
  30709. */
  30710. ['inverted', 'angular', 'polar'].forEach(function (key) {
  30711. // The default series type's class
  30712. klass = seriesTypes[(optionsChart.type || optionsChart.defaultSeriesType)];
  30713. // Get the value from available chart-wide properties
  30714. value =
  30715. // It is set in the options:
  30716. optionsChart[key] ||
  30717. // The default series class:
  30718. (klass && klass.prototype[key]);
  30719. // requires it
  30720. // 4. Check if any the chart's series require it
  30721. i = seriesOptions && seriesOptions.length;
  30722. while (!value && i--) {
  30723. klass = seriesTypes[seriesOptions[i].type];
  30724. if (klass && klass.prototype[key]) {
  30725. value = true;
  30726. }
  30727. }
  30728. // Set the chart property
  30729. chart[key] = value;
  30730. });
  30731. };
  30732. /**
  30733. * Internal function to link two or more series together, based on the
  30734. * `linkedTo` option. This is done from `Chart.render`, and after
  30735. * `Chart.addSeries` and `Series.remove`.
  30736. *
  30737. * @private
  30738. * @function Highcharts.Chart#linkSeries
  30739. * @fires Highcharts.Chart#event:afterLinkSeries
  30740. */
  30741. Chart.prototype.linkSeries = function () {
  30742. var chart = this,
  30743. chartSeries = chart.series;
  30744. // Reset links
  30745. chartSeries.forEach(function (series) {
  30746. series.linkedSeries.length = 0;
  30747. });
  30748. // Apply new links
  30749. chartSeries.forEach(function (series) {
  30750. var linkedTo = series.options.linkedTo;
  30751. if (isString(linkedTo)) {
  30752. if (linkedTo === ':previous') {
  30753. linkedTo = chart.series[series.index - 1];
  30754. }
  30755. else {
  30756. linkedTo = chart.get(linkedTo);
  30757. }
  30758. // #3341 avoid mutual linking
  30759. if (linkedTo && linkedTo.linkedParent !== series) {
  30760. linkedTo.linkedSeries.push(series);
  30761. series.linkedParent = linkedTo;
  30762. if (linkedTo.enabledDataSorting) {
  30763. series.setDataSortingOptions();
  30764. }
  30765. series.visible = pick(series.options.visible, linkedTo.options.visible, series.visible); // #3879
  30766. }
  30767. }
  30768. });
  30769. fireEvent(this, 'afterLinkSeries');
  30770. };
  30771. /**
  30772. * Render series for the chart.
  30773. *
  30774. * @private
  30775. * @function Highcharts.Chart#renderSeries
  30776. */
  30777. Chart.prototype.renderSeries = function () {
  30778. this.series.forEach(function (serie) {
  30779. serie.translate();
  30780. serie.render();
  30781. });
  30782. };
  30783. /**
  30784. * Render labels for the chart.
  30785. *
  30786. * @private
  30787. * @function Highcharts.Chart#renderLabels
  30788. */
  30789. Chart.prototype.renderLabels = function () {
  30790. var chart = this,
  30791. labels = chart.options.labels;
  30792. if (labels.items) {
  30793. labels.items.forEach(function (label) {
  30794. var style = extend(labels.style,
  30795. label.style),
  30796. x = pInt(style.left) + chart.plotLeft,
  30797. y = pInt(style.top) + chart.plotTop + 12;
  30798. // delete to prevent rewriting in IE
  30799. delete style.left;
  30800. delete style.top;
  30801. chart.renderer.text(label.html, x, y)
  30802. .attr({ zIndex: 2 })
  30803. .css(style)
  30804. .add();
  30805. });
  30806. }
  30807. };
  30808. /**
  30809. * Render all graphics for the chart. Runs internally on initialization.
  30810. *
  30811. * @private
  30812. * @function Highcharts.Chart#render
  30813. */
  30814. Chart.prototype.render = function () {
  30815. var chart = this,
  30816. axes = chart.axes,
  30817. colorAxis = chart.colorAxis,
  30818. renderer = chart.renderer,
  30819. options = chart.options,
  30820. correction = 0, // correction for X axis labels
  30821. tempWidth,
  30822. tempHeight,
  30823. redoHorizontal,
  30824. redoVertical,
  30825. renderAxes = function (axes) {
  30826. axes.forEach(function (axis) {
  30827. if (axis.visible) {
  30828. axis.render();
  30829. }
  30830. });
  30831. };
  30832. // Title
  30833. chart.setTitle();
  30834. /**
  30835. * The overview of the chart's series.
  30836. *
  30837. * @name Highcharts.Chart#legend
  30838. * @type {Highcharts.Legend}
  30839. */
  30840. chart.legend = new Legend(chart, options.legend);
  30841. // Get stacks
  30842. if (chart.getStacks) {
  30843. chart.getStacks();
  30844. }
  30845. // Get chart margins
  30846. chart.getMargins(true);
  30847. chart.setChartSize();
  30848. // Record preliminary dimensions for later comparison
  30849. tempWidth = chart.plotWidth;
  30850. axes.some(function (axis) {
  30851. if (axis.horiz &&
  30852. axis.visible &&
  30853. axis.options.labels.enabled &&
  30854. axis.series.length) {
  30855. // 21 is the most common correction for X axis labels
  30856. correction = 21;
  30857. return true;
  30858. }
  30859. });
  30860. // use Math.max to prevent negative plotHeight
  30861. chart.plotHeight = Math.max(chart.plotHeight - correction, 0);
  30862. tempHeight = chart.plotHeight;
  30863. // Get margins by pre-rendering axes
  30864. axes.forEach(function (axis) {
  30865. axis.setScale();
  30866. });
  30867. chart.getAxisMargins();
  30868. // If the plot area size has changed significantly, calculate tick
  30869. // positions again
  30870. redoHorizontal = tempWidth / chart.plotWidth > 1.1;
  30871. // Height is more sensitive, use lower threshold
  30872. redoVertical = tempHeight / chart.plotHeight > 1.05;
  30873. if (redoHorizontal || redoVertical) {
  30874. axes.forEach(function (axis) {
  30875. if ((axis.horiz && redoHorizontal) ||
  30876. (!axis.horiz && redoVertical)) {
  30877. // update to reflect the new margins
  30878. axis.setTickInterval(true);
  30879. }
  30880. });
  30881. chart.getMargins(); // second pass to check for new labels
  30882. }
  30883. // Draw the borders and backgrounds
  30884. chart.drawChartBox();
  30885. // Axes
  30886. if (chart.hasCartesianSeries) {
  30887. renderAxes(axes);
  30888. }
  30889. else if (colorAxis && colorAxis.length) {
  30890. renderAxes(colorAxis);
  30891. }
  30892. // The series
  30893. if (!chart.seriesGroup) {
  30894. chart.seriesGroup = renderer.g('series-group')
  30895. .attr({ zIndex: 3 })
  30896. .add();
  30897. }
  30898. chart.renderSeries();
  30899. // Labels
  30900. chart.renderLabels();
  30901. // Credits
  30902. chart.addCredits();
  30903. // Handle responsiveness
  30904. if (chart.setResponsive) {
  30905. chart.setResponsive();
  30906. }
  30907. // Set flag
  30908. chart.hasRendered = true;
  30909. };
  30910. /**
  30911. * Set a new credits label for the chart.
  30912. *
  30913. * @sample highcharts/credits/credits-update/
  30914. * Add and update credits
  30915. *
  30916. * @function Highcharts.Chart#addCredits
  30917. *
  30918. * @param {Highcharts.CreditsOptions} [credits]
  30919. * A configuration object for the new credits.
  30920. */
  30921. Chart.prototype.addCredits = function (credits) {
  30922. var chart = this,
  30923. creds = merge(true,
  30924. this.options.credits,
  30925. credits);
  30926. if (creds.enabled && !this.credits) {
  30927. /**
  30928. * The chart's credits label. The label has an `update` method that
  30929. * allows setting new options as per the
  30930. * [credits options set](https://api.highcharts.com/highcharts/credits).
  30931. *
  30932. * @name Highcharts.Chart#credits
  30933. * @type {Highcharts.SVGElement}
  30934. */
  30935. this.credits = this.renderer.text(creds.text + (this.mapCredits || ''), 0, 0)
  30936. .addClass('highcharts-credits')
  30937. .on('click', function () {
  30938. if (creds.href) {
  30939. win.location.href = creds.href;
  30940. }
  30941. })
  30942. .attr({
  30943. align: creds.position.align,
  30944. zIndex: 8
  30945. });
  30946. if (!chart.styledMode) {
  30947. this.credits.css(creds.style);
  30948. }
  30949. this.credits
  30950. .add()
  30951. .align(creds.position);
  30952. // Dynamically update
  30953. this.credits.update = function (options) {
  30954. chart.credits = chart.credits.destroy();
  30955. chart.addCredits(options);
  30956. };
  30957. }
  30958. };
  30959. /**
  30960. * Remove the chart and purge memory. This method is called internally
  30961. * before adding a second chart into the same container, as well as on
  30962. * window unload to prevent leaks.
  30963. *
  30964. * @sample highcharts/members/chart-destroy/
  30965. * Destroy the chart from a button
  30966. * @sample stock/members/chart-destroy/
  30967. * Destroy with Highcharts Stock
  30968. *
  30969. * @function Highcharts.Chart#destroy
  30970. *
  30971. * @fires Highcharts.Chart#event:destroy
  30972. */
  30973. Chart.prototype.destroy = function () {
  30974. var chart = this,
  30975. axes = chart.axes,
  30976. series = chart.series,
  30977. container = chart.container,
  30978. i,
  30979. parentNode = container && container.parentNode;
  30980. // fire the chart.destoy event
  30981. fireEvent(chart, 'destroy');
  30982. // Delete the chart from charts lookup array
  30983. if (chart.renderer.forExport) {
  30984. erase(charts, chart); // #6569
  30985. }
  30986. else {
  30987. charts[chart.index] = void 0;
  30988. }
  30989. H.chartCount--;
  30990. chart.renderTo.removeAttribute('data-highcharts-chart');
  30991. // remove events
  30992. removeEvent(chart);
  30993. // ==== Destroy collections:
  30994. // Destroy axes
  30995. i = axes.length;
  30996. while (i--) {
  30997. axes[i] = axes[i].destroy();
  30998. }
  30999. // Destroy scroller & scroller series before destroying base series
  31000. if (this.scroller && this.scroller.destroy) {
  31001. this.scroller.destroy();
  31002. }
  31003. // Destroy each series
  31004. i = series.length;
  31005. while (i--) {
  31006. series[i] = series[i].destroy();
  31007. }
  31008. // ==== Destroy chart properties:
  31009. [
  31010. 'title', 'subtitle', 'chartBackground', 'plotBackground',
  31011. 'plotBGImage', 'plotBorder', 'seriesGroup', 'clipRect', 'credits',
  31012. 'pointer', 'rangeSelector', 'legend', 'resetZoomButton', 'tooltip',
  31013. 'renderer'
  31014. ].forEach(function (name) {
  31015. var prop = chart[name];
  31016. if (prop && prop.destroy) {
  31017. chart[name] = prop.destroy();
  31018. }
  31019. });
  31020. // Remove container and all SVG, check container as it can break in IE
  31021. // when destroyed before finished loading
  31022. if (container) {
  31023. container.innerHTML = '';
  31024. removeEvent(container);
  31025. if (parentNode) {
  31026. discardElement(container);
  31027. }
  31028. }
  31029. // clean it all up
  31030. objectEach(chart, function (val, key) {
  31031. delete chart[key];
  31032. });
  31033. };
  31034. /**
  31035. * Prepare for first rendering after all data are loaded.
  31036. *
  31037. * @private
  31038. * @function Highcharts.Chart#firstRender
  31039. * @fires Highcharts.Chart#event:beforeRender
  31040. */
  31041. Chart.prototype.firstRender = function () {
  31042. var chart = this,
  31043. options = chart.options;
  31044. // Hook for oldIE to check whether the chart is ready to render
  31045. if (chart.isReadyToRender && !chart.isReadyToRender()) {
  31046. return;
  31047. }
  31048. // Create the container
  31049. chart.getContainer();
  31050. chart.resetMargins();
  31051. chart.setChartSize();
  31052. // Set the common chart properties (mainly invert) from the given series
  31053. chart.propFromSeries();
  31054. // get axes
  31055. chart.getAxes();
  31056. // Initialize the series
  31057. (isArray(options.series) ? options.series : []).forEach(
  31058. // #9680
  31059. function (serieOptions) {
  31060. chart.initSeries(serieOptions);
  31061. });
  31062. chart.linkSeries();
  31063. chart.setSeriesData();
  31064. // Run an event after axes and series are initialized, but before
  31065. // render. At this stage, the series data is indexed and cached in the
  31066. // xData and yData arrays, so we can access those before rendering. Used
  31067. // in Highcharts Stock.
  31068. fireEvent(chart, 'beforeRender');
  31069. // depends on inverted and on margins being set
  31070. if (Pointer) {
  31071. if (!H.hasTouch && (win.PointerEvent || win.MSPointerEvent)) {
  31072. chart.pointer = new MSPointer(chart, options);
  31073. }
  31074. else {
  31075. /**
  31076. * The Pointer that keeps track of mouse and touch interaction.
  31077. *
  31078. * @memberof Highcharts.Chart
  31079. * @name pointer
  31080. * @type {Highcharts.Pointer}
  31081. * @instance
  31082. */
  31083. chart.pointer = new Pointer(chart, options);
  31084. }
  31085. }
  31086. chart.render();
  31087. chart.pointer.getChartPosition(); // #14973
  31088. // Fire the load event if there are no external images
  31089. if (!chart.renderer.imgCount && !chart.hasLoaded) {
  31090. chart.onload();
  31091. }
  31092. // If the chart was rendered outside the top container, put it back in
  31093. // (#3679)
  31094. chart.temporaryDisplay(true);
  31095. };
  31096. /**
  31097. * Internal function that runs on chart load, async if any images are loaded
  31098. * in the chart. Runs the callbacks and triggers the `load` and `render`
  31099. * events.
  31100. *
  31101. * @private
  31102. * @function Highcharts.Chart#onload
  31103. * @fires Highcharts.Chart#event:load
  31104. * @fires Highcharts.Chart#event:render
  31105. */
  31106. Chart.prototype.onload = function () {
  31107. // Run callbacks, first the ones registered by modules, then user's one
  31108. this.callbacks.concat([this.callback]).forEach(function (fn) {
  31109. // Chart destroyed in its own callback (#3600)
  31110. if (fn && typeof this.index !== 'undefined') {
  31111. fn.apply(this, [this]);
  31112. }
  31113. }, this);
  31114. fireEvent(this, 'load');
  31115. fireEvent(this, 'render');
  31116. // Set up auto resize, check for not destroyed (#6068)
  31117. if (defined(this.index)) {
  31118. this.setReflow(this.options.chart.reflow);
  31119. }
  31120. // Don't run again
  31121. this.hasLoaded = true;
  31122. };
  31123. /**
  31124. * Add a series to the chart after render time. Note that this method should
  31125. * never be used when adding data synchronously at chart render time, as it
  31126. * adds expense to the calculations and rendering. When adding data at the
  31127. * same time as the chart is initialized, add the series as a configuration
  31128. * option instead. With multiple axes, the `offset` is dynamically adjusted.
  31129. *
  31130. * @sample highcharts/members/chart-addseries/
  31131. * Add a series from a button
  31132. * @sample stock/members/chart-addseries/
  31133. * Add a series in Highcharts Stock
  31134. *
  31135. * @function Highcharts.Chart#addSeries
  31136. *
  31137. * @param {Highcharts.SeriesOptionsType} options
  31138. * The config options for the series.
  31139. *
  31140. * @param {boolean} [redraw=true]
  31141. * Whether to redraw the chart after adding.
  31142. *
  31143. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  31144. * Whether to apply animation, and optionally animation
  31145. * configuration.
  31146. *
  31147. * @return {Highcharts.Series}
  31148. * The newly created series object.
  31149. *
  31150. * @fires Highcharts.Chart#event:addSeries
  31151. * @fires Highcharts.Chart#event:afterAddSeries
  31152. */
  31153. Chart.prototype.addSeries = function (options, redraw, animation) {
  31154. var series,
  31155. chart = this;
  31156. if (options) { // <- not necessary
  31157. redraw = pick(redraw, true); // defaults to true
  31158. fireEvent(chart, 'addSeries', { options: options }, function () {
  31159. series = chart.initSeries(options);
  31160. chart.isDirtyLegend = true;
  31161. chart.linkSeries();
  31162. if (series.enabledDataSorting) {
  31163. // We need to call `setData` after `linkSeries`
  31164. series.setData(options.data, false);
  31165. }
  31166. fireEvent(chart, 'afterAddSeries', { series: series });
  31167. if (redraw) {
  31168. chart.redraw(animation);
  31169. }
  31170. });
  31171. }
  31172. return series;
  31173. };
  31174. /**
  31175. * Add an axis to the chart after render time. Note that this method should
  31176. * never be used when adding data synchronously at chart render time, as it
  31177. * adds expense to the calculations and rendering. When adding data at the
  31178. * same time as the chart is initialized, add the axis as a configuration
  31179. * option instead.
  31180. *
  31181. * @sample highcharts/members/chart-addaxis/
  31182. * Add and remove axes
  31183. *
  31184. * @function Highcharts.Chart#addAxis
  31185. *
  31186. * @param {Highcharts.AxisOptions} options
  31187. * The axis options.
  31188. *
  31189. * @param {boolean} [isX=false]
  31190. * Whether it is an X axis or a value axis.
  31191. *
  31192. * @param {boolean} [redraw=true]
  31193. * Whether to redraw the chart after adding.
  31194. *
  31195. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  31196. * Whether and how to apply animation in the redraw.
  31197. *
  31198. * @return {Highcharts.Axis}
  31199. * The newly generated Axis object.
  31200. */
  31201. Chart.prototype.addAxis = function (options, isX, redraw, animation) {
  31202. return this.createAxis(isX ? 'xAxis' : 'yAxis', { axis: options, redraw: redraw, animation: animation });
  31203. };
  31204. /**
  31205. * Add a color axis to the chart after render time. Note that this method
  31206. * should never be used when adding data synchronously at chart render time,
  31207. * as it adds expense to the calculations and rendering. When adding data at
  31208. * the same time as the chart is initialized, add the axis as a
  31209. * configuration option instead.
  31210. *
  31211. * @sample highcharts/members/chart-addaxis/
  31212. * Add and remove axes
  31213. *
  31214. * @function Highcharts.Chart#addColorAxis
  31215. *
  31216. * @param {Highcharts.ColorAxisOptions} options
  31217. * The axis options.
  31218. *
  31219. * @param {boolean} [redraw=true]
  31220. * Whether to redraw the chart after adding.
  31221. *
  31222. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  31223. * Whether and how to apply animation in the redraw.
  31224. *
  31225. * @return {Highcharts.ColorAxis}
  31226. * The newly generated Axis object.
  31227. */
  31228. Chart.prototype.addColorAxis = function (options, redraw, animation) {
  31229. return this.createAxis('colorAxis', { axis: options, redraw: redraw, animation: animation });
  31230. };
  31231. /**
  31232. * Factory for creating different axis types.
  31233. *
  31234. * @private
  31235. * @function Highcharts.Chart#createAxis
  31236. *
  31237. * @param {string} type
  31238. * An axis type.
  31239. *
  31240. * @param {...Array<*>} arguments
  31241. * All arguments for the constructor.
  31242. *
  31243. * @return {Highcharts.Axis | Highcharts.ColorAxis}
  31244. * The newly generated Axis object.
  31245. */
  31246. Chart.prototype.createAxis = function (type, options) {
  31247. var chartOptions = this.options,
  31248. isColorAxis = type === 'colorAxis',
  31249. axisOptions = options.axis,
  31250. redraw = options.redraw,
  31251. animation = options.animation,
  31252. userOptions = merge(axisOptions, {
  31253. index: this[type].length,
  31254. isX: type === 'xAxis'
  31255. }),
  31256. axis;
  31257. if (isColorAxis) {
  31258. axis = new H.ColorAxis(this, userOptions);
  31259. }
  31260. else {
  31261. axis = new Axis(this, userOptions);
  31262. }
  31263. if (isColorAxis) {
  31264. this.isDirtyLegend = true;
  31265. // Clear before 'bindAxes' (#11924)
  31266. this.axes.forEach(function (axis) {
  31267. axis.series = [];
  31268. });
  31269. this.series.forEach(function (series) {
  31270. series.bindAxes();
  31271. series.isDirtyData = true;
  31272. });
  31273. }
  31274. if (pick(redraw, true)) {
  31275. this.redraw(animation);
  31276. }
  31277. return axis;
  31278. };
  31279. /**
  31280. * Dim the chart and show a loading text or symbol. Options for the loading
  31281. * screen are defined in {@link
  31282. * https://api.highcharts.com/highcharts/loading|the loading options}.
  31283. *
  31284. * @sample highcharts/members/chart-hideloading/
  31285. * Show and hide loading from a button
  31286. * @sample highcharts/members/chart-showloading/
  31287. * Apply different text labels
  31288. * @sample stock/members/chart-show-hide-loading/
  31289. * Toggle loading in Highcharts Stock
  31290. *
  31291. * @function Highcharts.Chart#showLoading
  31292. *
  31293. * @param {string} [str]
  31294. * An optional text to show in the loading label instead of the
  31295. * default one. The default text is set in
  31296. * [lang.loading](https://api.highcharts.com/highcharts/lang.loading).
  31297. */
  31298. Chart.prototype.showLoading = function (str) {
  31299. var chart = this,
  31300. options = chart.options,
  31301. loadingDiv = chart.loadingDiv,
  31302. loadingSpan = chart.loadingSpan,
  31303. loadingOptions = options.loading,
  31304. setLoadingSize = function () {
  31305. if (loadingDiv) {
  31306. css(loadingDiv, {
  31307. left: chart.plotLeft + 'px',
  31308. top: chart.plotTop + 'px',
  31309. width: chart.plotWidth + 'px',
  31310. height: chart.plotHeight + 'px'
  31311. });
  31312. }
  31313. };
  31314. // create the layer at the first call
  31315. if (!loadingDiv) {
  31316. chart.loadingDiv = loadingDiv = createElement('div', {
  31317. className: 'highcharts-loading highcharts-loading-hidden'
  31318. }, null, chart.container);
  31319. }
  31320. if (!loadingSpan) {
  31321. chart.loadingSpan = loadingSpan = createElement('span', { className: 'highcharts-loading-inner' }, null, loadingDiv);
  31322. addEvent(chart, 'redraw', setLoadingSize); // #1080
  31323. }
  31324. loadingDiv.className = 'highcharts-loading';
  31325. // Update text
  31326. AST.setElementHTML(loadingSpan, pick(str, options.lang.loading, ''));
  31327. if (!chart.styledMode) {
  31328. // Update visuals
  31329. css(loadingDiv, extend(loadingOptions.style, {
  31330. zIndex: 10
  31331. }));
  31332. css(loadingSpan, loadingOptions.labelStyle);
  31333. // Show it
  31334. if (!chart.loadingShown) {
  31335. css(loadingDiv, {
  31336. opacity: 0,
  31337. display: ''
  31338. });
  31339. animate(loadingDiv, {
  31340. opacity: loadingOptions.style.opacity || 0.5
  31341. }, {
  31342. duration: loadingOptions.showDuration || 0
  31343. });
  31344. }
  31345. }
  31346. chart.loadingShown = true;
  31347. setLoadingSize();
  31348. };
  31349. /**
  31350. * Hide the loading layer.
  31351. *
  31352. * @see Highcharts.Chart#showLoading
  31353. *
  31354. * @sample highcharts/members/chart-hideloading/
  31355. * Show and hide loading from a button
  31356. * @sample stock/members/chart-show-hide-loading/
  31357. * Toggle loading in Highcharts Stock
  31358. *
  31359. * @function Highcharts.Chart#hideLoading
  31360. */
  31361. Chart.prototype.hideLoading = function () {
  31362. var options = this.options,
  31363. loadingDiv = this.loadingDiv;
  31364. if (loadingDiv) {
  31365. loadingDiv.className =
  31366. 'highcharts-loading highcharts-loading-hidden';
  31367. if (!this.styledMode) {
  31368. animate(loadingDiv, {
  31369. opacity: 0
  31370. }, {
  31371. duration: options.loading.hideDuration || 100,
  31372. complete: function () {
  31373. css(loadingDiv, { display: 'none' });
  31374. }
  31375. });
  31376. }
  31377. }
  31378. this.loadingShown = false;
  31379. };
  31380. /**
  31381. * A generic function to update any element of the chart. Elements can be
  31382. * enabled and disabled, moved, re-styled, re-formatted etc.
  31383. *
  31384. * A special case is configuration objects that take arrays, for example
  31385. * [xAxis](https://api.highcharts.com/highcharts/xAxis),
  31386. * [yAxis](https://api.highcharts.com/highcharts/yAxis) or
  31387. * [series](https://api.highcharts.com/highcharts/series). For these
  31388. * collections, an `id` option is used to map the new option set to an
  31389. * existing object. If an existing object of the same id is not found, the
  31390. * corresponding item is updated. So for example, running `chart.update`
  31391. * with a series item without an id, will cause the existing chart's series
  31392. * with the same index in the series array to be updated. When the
  31393. * `oneToOne` parameter is true, `chart.update` will also take care of
  31394. * adding and removing items from the collection. Read more under the
  31395. * parameter description below.
  31396. *
  31397. * Note that when changing series data, `chart.update` may mutate the passed
  31398. * data options.
  31399. *
  31400. * See also the
  31401. * [responsive option set](https://api.highcharts.com/highcharts/responsive).
  31402. * Switching between `responsive.rules` basically runs `chart.update` under
  31403. * the hood.
  31404. *
  31405. * @sample highcharts/members/chart-update/
  31406. * Update chart geometry
  31407. *
  31408. * @function Highcharts.Chart#update
  31409. *
  31410. * @param {Highcharts.Options} options
  31411. * A configuration object for the new chart options.
  31412. *
  31413. * @param {boolean} [redraw=true]
  31414. * Whether to redraw the chart.
  31415. *
  31416. * @param {boolean} [oneToOne=false]
  31417. * When `true`, the `series`, `xAxis`, `yAxis` and `annotations`
  31418. * collections will be updated one to one, and items will be either
  31419. * added or removed to match the new updated options. For example,
  31420. * if the chart has two series and we call `chart.update` with a
  31421. * configuration containing three series, one will be added. If we
  31422. * call `chart.update` with one series, one will be removed. Setting
  31423. * an empty `series` array will remove all series, but leaving out
  31424. * the`series` property will leave all series untouched. If the
  31425. * series have id's, the new series options will be matched by id,
  31426. * and the remaining ones removed.
  31427. *
  31428. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  31429. * Whether to apply animation, and optionally animation
  31430. * configuration.
  31431. *
  31432. * @fires Highcharts.Chart#event:update
  31433. * @fires Highcharts.Chart#event:afterUpdate
  31434. */
  31435. Chart.prototype.update = function (options, redraw, oneToOne, animation) {
  31436. var chart = this,
  31437. adders = {
  31438. credits: 'addCredits',
  31439. title: 'setTitle',
  31440. subtitle: 'setSubtitle',
  31441. caption: 'setCaption'
  31442. },
  31443. optionsChart,
  31444. updateAllAxes,
  31445. updateAllSeries,
  31446. newWidth,
  31447. newHeight,
  31448. runSetSize,
  31449. isResponsiveOptions = options.isResponsiveOptions,
  31450. itemsForRemoval = [];
  31451. fireEvent(chart, 'update', { options: options });
  31452. // If there are responsive rules in action, undo the responsive rules
  31453. // before we apply the updated options and replay the responsive rules
  31454. // on top from the chart.redraw function (#9617).
  31455. if (!isResponsiveOptions) {
  31456. chart.setResponsive(false, true);
  31457. }
  31458. options = cleanRecursively(options, chart.options);
  31459. chart.userOptions = merge(chart.userOptions, options);
  31460. // If the top-level chart option is present, some special updates are
  31461. // required
  31462. optionsChart = options.chart;
  31463. if (optionsChart) {
  31464. merge(true, chart.options.chart, optionsChart);
  31465. // Setter function
  31466. if ('className' in optionsChart) {
  31467. chart.setClassName(optionsChart.className);
  31468. }
  31469. if ('reflow' in optionsChart) {
  31470. chart.setReflow(optionsChart.reflow);
  31471. }
  31472. if ('inverted' in optionsChart ||
  31473. 'polar' in optionsChart ||
  31474. 'type' in optionsChart) {
  31475. // Parse options.chart.inverted and options.chart.polar together
  31476. // with the available series.
  31477. chart.propFromSeries();
  31478. updateAllAxes = true;
  31479. }
  31480. if ('alignTicks' in optionsChart) { // #6452
  31481. updateAllAxes = true;
  31482. }
  31483. objectEach(optionsChart, function (val, key) {
  31484. if (chart.propsRequireUpdateSeries.indexOf('chart.' + key) !==
  31485. -1) {
  31486. updateAllSeries = true;
  31487. }
  31488. // Only dirty box
  31489. if (chart.propsRequireDirtyBox.indexOf(key) !== -1) {
  31490. chart.isDirtyBox = true;
  31491. }
  31492. // Chart setSize
  31493. if (chart.propsRequireReflow.indexOf(key) !== -1) {
  31494. if (isResponsiveOptions) {
  31495. chart.isDirtyBox = true;
  31496. }
  31497. else {
  31498. runSetSize = true;
  31499. }
  31500. }
  31501. });
  31502. if (!chart.styledMode && 'style' in optionsChart) {
  31503. chart.renderer.setStyle(optionsChart.style);
  31504. }
  31505. }
  31506. // Moved up, because tooltip needs updated plotOptions (#6218)
  31507. if (!chart.styledMode && options.colors) {
  31508. this.options.colors = options.colors;
  31509. }
  31510. if (options.time) {
  31511. // Maintaining legacy global time. If the chart is instanciated
  31512. // first with global time, then updated with time options, we need
  31513. // to create a new Time instance to avoid mutating the global time
  31514. // (#10536).
  31515. if (this.time === defaultTime) {
  31516. this.time = new Time(options.time);
  31517. }
  31518. // If we're updating, the time class is different from other chart
  31519. // classes (chart.legend, chart.tooltip etc) in that it doesn't know
  31520. // about the chart. The other chart[something].update functions also
  31521. // set the chart.options[something]. For the time class however we
  31522. // need to update the chart options separately. #14230.
  31523. merge(true, chart.options.time, options.time);
  31524. }
  31525. // Some option stuctures correspond one-to-one to chart objects that
  31526. // have update methods, for example
  31527. // options.credits => chart.credits
  31528. // options.legend => chart.legend
  31529. // options.title => chart.title
  31530. // options.tooltip => chart.tooltip
  31531. // options.subtitle => chart.subtitle
  31532. // options.mapNavigation => chart.mapNavigation
  31533. // options.navigator => chart.navigator
  31534. // options.scrollbar => chart.scrollbar
  31535. objectEach(options, function (val, key) {
  31536. if (chart[key] &&
  31537. typeof chart[key].update === 'function') {
  31538. chart[key].update(val, false);
  31539. // If a one-to-one object does not exist, look for an adder function
  31540. }
  31541. else if (typeof chart[adders[key]] === 'function') {
  31542. chart[adders[key]](val);
  31543. // Else, just merge the options. For nodes like loading, noData,
  31544. // plotOptions
  31545. }
  31546. else if (key !== 'colors' &&
  31547. chart.collectionsWithUpdate.indexOf(key) === -1) {
  31548. merge(true, chart.options[key], options[key]);
  31549. }
  31550. if (key !== 'chart' &&
  31551. chart.propsRequireUpdateSeries.indexOf(key) !== -1) {
  31552. updateAllSeries = true;
  31553. }
  31554. });
  31555. // Setters for collections. For axes and series, each item is referred
  31556. // by an id. If the id is not found, it defaults to the corresponding
  31557. // item in the collection, so setting one series without an id, will
  31558. // update the first series in the chart. Setting two series without
  31559. // an id will update the first and the second respectively (#6019)
  31560. // chart.update and responsive.
  31561. this.collectionsWithUpdate.forEach(function (coll) {
  31562. var indexMap;
  31563. if (options[coll]) {
  31564. // In stock charts, the navigator series are also part of the
  31565. // chart.series array, but those series should not be handled
  31566. // here (#8196) and neither should the navigator axis (#9671).
  31567. indexMap = [];
  31568. chart[coll].forEach(function (s, i) {
  31569. if (!s.options.isInternal) {
  31570. indexMap.push(pick(s.options.index, i));
  31571. }
  31572. });
  31573. splat(options[coll]).forEach(function (newOptions, i) {
  31574. var hasId = defined(newOptions.id);
  31575. var item;
  31576. // Match by id
  31577. if (hasId) {
  31578. item = chart.get(newOptions.id);
  31579. }
  31580. // No match by id found, match by index instead
  31581. if (!item && chart[coll]) {
  31582. item = chart[coll][indexMap ? indexMap[i] : i];
  31583. // Check if we grabbed an item with an exising but
  31584. // different id (#13541)
  31585. if (item && hasId && defined(item.options.id)) {
  31586. item = void 0;
  31587. }
  31588. }
  31589. if (item && item.coll === coll) {
  31590. item.update(newOptions, false);
  31591. if (oneToOne) {
  31592. item.touched = true;
  31593. }
  31594. }
  31595. // If oneToOne and no matching item is found, add one
  31596. if (!item && oneToOne && chart.collectionsWithInit[coll]) {
  31597. chart.collectionsWithInit[coll][0].apply(chart,
  31598. // [newOptions, ...extraArguments, redraw=false]
  31599. [
  31600. newOptions
  31601. ].concat(
  31602. // Not all initializers require extra args
  31603. chart.collectionsWithInit[coll][1] || []).concat([
  31604. false
  31605. ])).touched = true;
  31606. }
  31607. });
  31608. // Add items for removal
  31609. if (oneToOne) {
  31610. chart[coll].forEach(function (item) {
  31611. if (!item.touched && !item.options.isInternal) {
  31612. itemsForRemoval.push(item);
  31613. }
  31614. else {
  31615. delete item.touched;
  31616. }
  31617. });
  31618. }
  31619. }
  31620. });
  31621. itemsForRemoval.forEach(function (item) {
  31622. if (item.chart) { // #9097, avoid removing twice
  31623. item.remove(false);
  31624. }
  31625. });
  31626. if (updateAllAxes) {
  31627. chart.axes.forEach(function (axis) {
  31628. axis.update({}, false);
  31629. });
  31630. }
  31631. // Certain options require the whole series structure to be thrown away
  31632. // and rebuilt
  31633. if (updateAllSeries) {
  31634. chart.getSeriesOrderByLinks().forEach(function (series) {
  31635. // Avoid removed navigator series
  31636. if (series.chart) {
  31637. series.update({}, false);
  31638. }
  31639. }, this);
  31640. }
  31641. // Update size. Redraw is forced.
  31642. newWidth = optionsChart && optionsChart.width;
  31643. newHeight = optionsChart && optionsChart.height;
  31644. if (isString(newHeight)) {
  31645. newHeight = relativeLength(newHeight, newWidth || chart.chartWidth);
  31646. }
  31647. if (
  31648. // In this case, run chart.setSize with newWidth and newHeight which
  31649. // are undefined, only for reflowing chart elements because margin
  31650. // or spacing has been set (#8190)
  31651. runSetSize ||
  31652. // In this case, the size is actually set
  31653. (isNumber(newWidth) && newWidth !== chart.chartWidth) ||
  31654. (isNumber(newHeight) && newHeight !== chart.chartHeight)) {
  31655. chart.setSize(newWidth, newHeight, animation);
  31656. }
  31657. else if (pick(redraw, true)) {
  31658. chart.redraw(animation);
  31659. }
  31660. fireEvent(chart, 'afterUpdate', {
  31661. options: options,
  31662. redraw: redraw,
  31663. animation: animation
  31664. });
  31665. };
  31666. /**
  31667. * Shortcut to set the subtitle options. This can also be done from {@link
  31668. * Chart#update} or {@link Chart#setTitle}.
  31669. *
  31670. * @function Highcharts.Chart#setSubtitle
  31671. *
  31672. * @param {Highcharts.SubtitleOptions} options
  31673. * New subtitle options. The subtitle text itself is set by the
  31674. * `options.text` property.
  31675. */
  31676. Chart.prototype.setSubtitle = function (options, redraw) {
  31677. this.applyDescription('subtitle', options);
  31678. this.layOutTitles(redraw);
  31679. };
  31680. /**
  31681. * Set the caption options. This can also be done from {@link
  31682. * Chart#update}.
  31683. *
  31684. * @function Highcharts.Chart#setCaption
  31685. *
  31686. * @param {Highcharts.CaptionOptions} options
  31687. * New caption options. The caption text itself is set by the
  31688. * `options.text` property.
  31689. */
  31690. Chart.prototype.setCaption = function (options, redraw) {
  31691. this.applyDescription('caption', options);
  31692. this.layOutTitles(redraw);
  31693. };
  31694. /**
  31695. * Display the zoom button, so users can reset zoom to the default view
  31696. * settings.
  31697. *
  31698. * @function Highcharts.Chart#showResetZoom
  31699. *
  31700. * @fires Highcharts.Chart#event:afterShowResetZoom
  31701. * @fires Highcharts.Chart#event:beforeShowResetZoom
  31702. */
  31703. Chart.prototype.showResetZoom = function () {
  31704. var chart = this,
  31705. lang = defaultOptions.lang,
  31706. btnOptions = chart.options.chart.resetZoomButton,
  31707. theme = btnOptions.theme,
  31708. states = theme.states,
  31709. alignTo = (btnOptions.relativeTo === 'chart' ||
  31710. btnOptions.relativeTo === 'spacingBox' ?
  31711. null :
  31712. 'scrollablePlotBox');
  31713. /**
  31714. * @private
  31715. */
  31716. function zoomOut() {
  31717. chart.zoomOut();
  31718. }
  31719. fireEvent(this, 'beforeShowResetZoom', null, function () {
  31720. chart.resetZoomButton = chart.renderer
  31721. .button(lang.resetZoom, null, null, zoomOut, theme, states && states.hover)
  31722. .attr({
  31723. align: btnOptions.position.align,
  31724. title: lang.resetZoomTitle
  31725. })
  31726. .addClass('highcharts-reset-zoom')
  31727. .add()
  31728. .align(btnOptions.position, false, alignTo);
  31729. });
  31730. fireEvent(this, 'afterShowResetZoom');
  31731. };
  31732. /**
  31733. * Zoom the chart out after a user has zoomed in. See also
  31734. * [Axis.setExtremes](/class-reference/Highcharts.Axis#setExtremes).
  31735. *
  31736. * @function Highcharts.Chart#zoomOut
  31737. *
  31738. * @fires Highcharts.Chart#event:selection
  31739. */
  31740. Chart.prototype.zoomOut = function () {
  31741. fireEvent(this, 'selection', { resetSelection: true }, this.zoom);
  31742. };
  31743. /**
  31744. * Zoom into a given portion of the chart given by axis coordinates.
  31745. *
  31746. * @private
  31747. * @function Highcharts.Chart#zoom
  31748. * @param {Highcharts.SelectEventObject} event
  31749. */
  31750. Chart.prototype.zoom = function (event) {
  31751. var chart = this,
  31752. hasZoomed,
  31753. pointer = chart.pointer,
  31754. displayButton = false,
  31755. mouseDownPos = chart.inverted ? pointer.mouseDownX : pointer.mouseDownY,
  31756. resetZoomButton;
  31757. // If zoom is called with no arguments, reset the axes
  31758. if (!event || event.resetSelection) {
  31759. chart.axes.forEach(function (axis) {
  31760. hasZoomed = axis.zoom();
  31761. });
  31762. pointer.initiated = false; // #6804
  31763. }
  31764. else { // else, zoom in on all axes
  31765. event.xAxis.concat(event.yAxis).forEach(function (axisData) {
  31766. var axis = axisData.axis,
  31767. axisStartPos = chart.inverted ? axis.left : axis.top,
  31768. axisEndPos = chart.inverted ?
  31769. axisStartPos + axis.width : axisStartPos + axis.height,
  31770. isXAxis = axis.isXAxis,
  31771. isWithinPane = false;
  31772. // Check if zoomed area is within the pane (#1289).
  31773. // In case of multiple panes only one pane should be zoomed.
  31774. if ((!isXAxis &&
  31775. mouseDownPos >= axisStartPos &&
  31776. mouseDownPos <= axisEndPos) ||
  31777. isXAxis ||
  31778. !defined(mouseDownPos)) {
  31779. isWithinPane = true;
  31780. }
  31781. // don't zoom more than minRange
  31782. if (pointer[isXAxis ? 'zoomX' : 'zoomY'] && isWithinPane) {
  31783. hasZoomed = axis.zoom(axisData.min, axisData.max);
  31784. if (axis.displayBtn) {
  31785. displayButton = true;
  31786. }
  31787. }
  31788. });
  31789. }
  31790. // Show or hide the Reset zoom button
  31791. resetZoomButton = chart.resetZoomButton;
  31792. if (displayButton && !resetZoomButton) {
  31793. chart.showResetZoom();
  31794. }
  31795. else if (!displayButton && isObject(resetZoomButton)) {
  31796. chart.resetZoomButton = resetZoomButton.destroy();
  31797. }
  31798. // Redraw
  31799. if (hasZoomed) {
  31800. chart.redraw(pick(chart.options.chart.animation, event && event.animation, chart.pointCount < 100));
  31801. }
  31802. };
  31803. /**
  31804. * Pan the chart by dragging the mouse across the pane. This function is
  31805. * called on mouse move, and the distance to pan is computed from chartX
  31806. * compared to the first chartX position in the dragging operation.
  31807. *
  31808. * @private
  31809. * @function Highcharts.Chart#pan
  31810. * @param {Highcharts.PointerEventObject} e
  31811. * @param {string} panning
  31812. */
  31813. Chart.prototype.pan = function (e, panning) {
  31814. var chart = this,
  31815. hoverPoints = chart.hoverPoints,
  31816. panningOptions,
  31817. chartOptions = chart.options.chart,
  31818. hasMapNavigation = chart.options.mapNavigation &&
  31819. chart.options.mapNavigation.enabled,
  31820. doRedraw,
  31821. type;
  31822. if (typeof panning === 'object') {
  31823. panningOptions = panning;
  31824. }
  31825. else {
  31826. panningOptions = {
  31827. enabled: panning,
  31828. type: 'x'
  31829. };
  31830. }
  31831. if (chartOptions && chartOptions.panning) {
  31832. chartOptions.panning = panningOptions;
  31833. }
  31834. type = panningOptions.type;
  31835. fireEvent(this, 'pan', { originalEvent: e }, function () {
  31836. // remove active points for shared tooltip
  31837. if (hoverPoints) {
  31838. hoverPoints.forEach(function (point) {
  31839. point.setState();
  31840. });
  31841. }
  31842. // panning axis mapping
  31843. var xy = [1]; // x
  31844. if (type === 'xy') {
  31845. xy = [1, 0];
  31846. }
  31847. else if (type === 'y') {
  31848. xy = [0];
  31849. }
  31850. xy.forEach(function (isX) {
  31851. var axis = chart[isX ? 'xAxis' : 'yAxis'][0], horiz = axis.horiz, mousePos = e[horiz ? 'chartX' : 'chartY'], mouseDown = horiz ? 'mouseDownX' : 'mouseDownY', startPos = chart[mouseDown], halfPointRange = (axis.pointRange || 0) / 2, pointRangeDirection = (axis.reversed && !chart.inverted) ||
  31852. (!axis.reversed && chart.inverted) ?
  31853. -1 :
  31854. 1, extremes = axis.getExtremes(), panMin = axis.toValue(startPos - mousePos, true) +
  31855. halfPointRange * pointRangeDirection, panMax = axis.toValue(startPos + axis.len - mousePos, true) -
  31856. halfPointRange * pointRangeDirection, flipped = panMax < panMin, newMin = flipped ? panMax : panMin, newMax = flipped ? panMin : panMax, hasVerticalPanning = axis.hasVerticalPanning(), paddedMin, paddedMax, spill, panningState = axis.panningState;
  31857. // General calculations of panning state.
  31858. // This is related to using vertical panning. (#11315).
  31859. if (hasVerticalPanning &&
  31860. !isX && (!panningState || panningState.isDirty)) {
  31861. axis.series.forEach(function (series) {
  31862. var processedData = series.getProcessedData(true),
  31863. dataExtremes = series.getExtremes(processedData.yData,
  31864. true);
  31865. if (!panningState) {
  31866. panningState = {
  31867. startMin: Number.MAX_VALUE,
  31868. startMax: -Number.MAX_VALUE
  31869. };
  31870. }
  31871. if (isNumber(dataExtremes.dataMin) &&
  31872. isNumber(dataExtremes.dataMax)) {
  31873. panningState.startMin = Math.min(pick(series.options.threshold, Infinity), dataExtremes.dataMin, panningState.startMin);
  31874. panningState.startMax = Math.max(pick(series.options.threshold, -Infinity), dataExtremes.dataMax, panningState.startMax);
  31875. }
  31876. });
  31877. }
  31878. paddedMin = Math.min(pick(panningState && panningState.startMin, extremes.dataMin), halfPointRange ?
  31879. extremes.min :
  31880. axis.toValue(axis.toPixels(extremes.min) -
  31881. axis.minPixelPadding));
  31882. paddedMax = Math.max(pick(panningState && panningState.startMax, extremes.dataMax), halfPointRange ?
  31883. extremes.max :
  31884. axis.toValue(axis.toPixels(extremes.max) +
  31885. axis.minPixelPadding));
  31886. axis.panningState = panningState;
  31887. // It is not necessary to calculate extremes on ordinal axis,
  31888. // because they are already calculated, so we don't want to
  31889. // override them.
  31890. if (!axis.isOrdinal) {
  31891. // If the new range spills over, either to the min or max,
  31892. // adjust the new range.
  31893. spill = paddedMin - newMin;
  31894. if (spill > 0) {
  31895. newMax += spill;
  31896. newMin = paddedMin;
  31897. }
  31898. spill = newMax - paddedMax;
  31899. if (spill > 0) {
  31900. newMax = paddedMax;
  31901. newMin -= spill;
  31902. }
  31903. // Set new extremes if they are actually new
  31904. if (axis.series.length &&
  31905. newMin !== extremes.min &&
  31906. newMax !== extremes.max &&
  31907. newMin >= paddedMin &&
  31908. newMax <= paddedMax) {
  31909. axis.setExtremes(newMin, newMax, false, false, { trigger: 'pan' });
  31910. if (!chart.resetZoomButton &&
  31911. !hasMapNavigation &&
  31912. // Show reset zoom button only when both newMin and
  31913. // newMax values are between padded axis range.
  31914. newMin !== paddedMin &&
  31915. newMax !== paddedMax &&
  31916. type.match('y')) {
  31917. chart.showResetZoom();
  31918. axis.displayBtn = false;
  31919. }
  31920. doRedraw = true;
  31921. }
  31922. // set new reference for next run:
  31923. chart[mouseDown] = mousePos;
  31924. }
  31925. });
  31926. if (doRedraw) {
  31927. chart.redraw(false);
  31928. }
  31929. css(chart.container, { cursor: 'move' });
  31930. });
  31931. };
  31932. return Chart;
  31933. }());
  31934. extend(Chart.prototype, {
  31935. // Hook for adding callbacks in modules
  31936. callbacks: [],
  31937. /**
  31938. * These collections (arrays) implement `Chart.addSomethig` method used in
  31939. * chart.update() to create new object in the collection. Equivalent for
  31940. * deleting is resolved by simple `Somethig.remove()`.
  31941. *
  31942. * Note: We need to define these references after initializers are bound to
  31943. * chart's prototype.
  31944. */
  31945. collectionsWithInit: {
  31946. // collectionName: [ initializingMethod, [extraArguments] ]
  31947. xAxis: [Chart.prototype.addAxis, [true]],
  31948. yAxis: [Chart.prototype.addAxis, [false]],
  31949. series: [Chart.prototype.addSeries]
  31950. },
  31951. /**
  31952. * These collections (arrays) implement update() methods with support for
  31953. * one-to-one option.
  31954. */
  31955. collectionsWithUpdate: [
  31956. 'xAxis',
  31957. 'yAxis',
  31958. 'zAxis',
  31959. 'series'
  31960. ],
  31961. /**
  31962. * These properties cause isDirtyBox to be set to true when updating. Can be
  31963. * extended from plugins.
  31964. */
  31965. propsRequireDirtyBox: [
  31966. 'backgroundColor',
  31967. 'borderColor',
  31968. 'borderWidth',
  31969. 'borderRadius',
  31970. 'plotBackgroundColor',
  31971. 'plotBackgroundImage',
  31972. 'plotBorderColor',
  31973. 'plotBorderWidth',
  31974. 'plotShadow',
  31975. 'shadow'
  31976. ],
  31977. /**
  31978. * These properties require a full reflow of chart elements, best
  31979. * implemented through running `Chart.setSize` internally (#8190).
  31980. * @type {Array}
  31981. */
  31982. propsRequireReflow: [
  31983. 'margin',
  31984. 'marginTop',
  31985. 'marginRight',
  31986. 'marginBottom',
  31987. 'marginLeft',
  31988. 'spacing',
  31989. 'spacingTop',
  31990. 'spacingRight',
  31991. 'spacingBottom',
  31992. 'spacingLeft'
  31993. ],
  31994. /**
  31995. * These properties cause all series to be updated when updating. Can be
  31996. * extended from plugins.
  31997. */
  31998. propsRequireUpdateSeries: [
  31999. 'chart.inverted',
  32000. 'chart.polar',
  32001. 'chart.ignoreHiddenSeries',
  32002. 'chart.type',
  32003. 'colors',
  32004. 'plotOptions',
  32005. 'time',
  32006. 'tooltip'
  32007. ]
  32008. });
  32009. /**
  32010. * Factory function for basic charts.
  32011. *
  32012. * @example
  32013. * // Render a chart in to div#container
  32014. * let chart = Highcharts.chart('container', {
  32015. * title: {
  32016. * text: 'My chart'
  32017. * },
  32018. * series: [{
  32019. * data: [1, 3, 2, 4]
  32020. * }]
  32021. * });
  32022. *
  32023. * @function Highcharts.chart
  32024. *
  32025. * @param {string|Highcharts.HTMLDOMElement} [renderTo]
  32026. * The DOM element to render to, or its id.
  32027. *
  32028. * @param {Highcharts.Options} options
  32029. * The chart options structure.
  32030. *
  32031. * @param {Highcharts.ChartCallbackFunction} [callback]
  32032. * Function to run when the chart has loaded and and all external images
  32033. * are loaded. Defining a
  32034. * [chart.events.load](https://api.highcharts.com/highcharts/chart.events.load)
  32035. * handler is equivalent.
  32036. *
  32037. * @return {Highcharts.Chart}
  32038. * Returns the Chart object.
  32039. */
  32040. function chart(a, b, c) {
  32041. return new Chart(a, b, c);
  32042. }
  32043. H.chart = chart;
  32044. H.Chart = Chart;
  32045. /* *
  32046. *
  32047. * Export
  32048. *
  32049. * */
  32050. /* *
  32051. *
  32052. * API Declarations
  32053. *
  32054. * */
  32055. /**
  32056. * Callback for chart constructors.
  32057. *
  32058. * @callback Highcharts.ChartCallbackFunction
  32059. *
  32060. * @param {Highcharts.Chart} chart
  32061. * Created chart.
  32062. */
  32063. /**
  32064. * Format a number and return a string based on input settings.
  32065. *
  32066. * @callback Highcharts.NumberFormatterCallbackFunction
  32067. *
  32068. * @param {number} number
  32069. * The input number to format.
  32070. *
  32071. * @param {number} decimals
  32072. * The amount of decimals. A value of -1 preserves the amount in the
  32073. * input number.
  32074. *
  32075. * @param {string} [decimalPoint]
  32076. * The decimal point, defaults to the one given in the lang options, or
  32077. * a dot.
  32078. *
  32079. * @param {string} [thousandsSep]
  32080. * The thousands separator, defaults to the one given in the lang
  32081. * options, or a space character.
  32082. *
  32083. * @return {string} The formatted number.
  32084. */
  32085. /**
  32086. * The chart title. The title has an `update` method that allows modifying the
  32087. * options directly or indirectly via `chart.update`.
  32088. *
  32089. * @interface Highcharts.TitleObject
  32090. * @extends Highcharts.SVGElement
  32091. */ /**
  32092. * Modify options for the title.
  32093. *
  32094. * @function Highcharts.TitleObject#update
  32095. *
  32096. * @param {Highcharts.TitleOptions} titleOptions
  32097. * Options to modify.
  32098. *
  32099. * @param {boolean} [redraw=true]
  32100. * Whether to redraw the chart after the title is altered. If doing more
  32101. * operations on the chart, it is a good idea to set redraw to false and
  32102. * call {@link Chart#redraw} after.
  32103. */
  32104. /**
  32105. * The chart subtitle. The subtitle has an `update` method that
  32106. * allows modifying the options directly or indirectly via
  32107. * `chart.update`.
  32108. *
  32109. * @interface Highcharts.SubtitleObject
  32110. * @extends Highcharts.SVGElement
  32111. */ /**
  32112. * Modify options for the subtitle.
  32113. *
  32114. * @function Highcharts.SubtitleObject#update
  32115. *
  32116. * @param {Highcharts.SubtitleOptions} subtitleOptions
  32117. * Options to modify.
  32118. *
  32119. * @param {boolean} [redraw=true]
  32120. * Whether to redraw the chart after the subtitle is altered. If doing
  32121. * more operations on the chart, it is a good idea to set redraw to false
  32122. * and call {@link Chart#redraw} after.
  32123. */
  32124. /**
  32125. * The chart caption. The caption has an `update` method that
  32126. * allows modifying the options directly or indirectly via
  32127. * `chart.update`.
  32128. *
  32129. * @interface Highcharts.CaptionObject
  32130. * @extends Highcharts.SVGElement
  32131. */ /**
  32132. * Modify options for the caption.
  32133. *
  32134. * @function Highcharts.CaptionObject#update
  32135. *
  32136. * @param {Highcharts.CaptionOptions} captionOptions
  32137. * Options to modify.
  32138. *
  32139. * @param {boolean} [redraw=true]
  32140. * Whether to redraw the chart after the caption is altered. If doing
  32141. * more operations on the chart, it is a good idea to set redraw to false
  32142. * and call {@link Chart#redraw} after.
  32143. */
  32144. /**
  32145. * @interface Highcharts.ChartIsInsideOptionsObject
  32146. */ /**
  32147. * @name Highcharts.ChartIsInsideOptionsObject#ignoreX
  32148. * @type {boolean|undefined}
  32149. */ /**
  32150. * @name Highcharts.ChartIsInsideOptionsObject#ignoreY
  32151. * @type {boolean|undefined}
  32152. */ /**
  32153. * @name Highcharts.ChartIsInsideOptionsObject#inverted
  32154. * @type {boolean|undefined}
  32155. */ /**
  32156. * @name Highcharts.ChartIsInsideOptionsObject#paneCoordinates
  32157. * @type {boolean|undefined}
  32158. */ /**
  32159. * @name Highcharts.ChartIsInsideOptionsObject#series
  32160. * @type {Highcharts.Series|undefined}
  32161. */ /**
  32162. * @name Highcharts.ChartIsInsideOptionsObject#visiblePlotOnly
  32163. * @type {boolean|undefined}
  32164. */
  32165. ''; // include doclets above in transpilat
  32166. return Chart;
  32167. });
  32168. _registerModule(_modules, 'Mixins/LegendSymbol.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  32169. /* *
  32170. *
  32171. * (c) 2010-2021 Torstein Honsi
  32172. *
  32173. * License: www.highcharts.com/license
  32174. *
  32175. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  32176. *
  32177. * */
  32178. var merge = U.merge,
  32179. pick = U.pick;
  32180. /* eslint-disable valid-jsdoc */
  32181. /**
  32182. * Legend symbol mixin.
  32183. *
  32184. * @private
  32185. * @mixin Highcharts.LegendSymbolMixin
  32186. */
  32187. var LegendSymbolMixin = H.LegendSymbolMixin = {
  32188. /**
  32189. * Get the series' symbol in the legend
  32190. *
  32191. * @private
  32192. * @function Highcharts.LegendSymbolMixin.drawRectangle
  32193. *
  32194. * @param {Highcharts.Legend} legend
  32195. * The legend object
  32196. *
  32197. * @param {Highcharts.Point|Highcharts.Series} item
  32198. * The series (this) or point
  32199. */
  32200. drawRectangle: function (legend,
  32201. item) {
  32202. var options = legend.options,
  32203. symbolHeight = legend.symbolHeight,
  32204. square = options.squareSymbol,
  32205. symbolWidth = square ? symbolHeight : legend.symbolWidth;
  32206. item.legendSymbol = this.chart.renderer.rect(square ? (legend.symbolWidth - symbolHeight) / 2 : 0, legend.baseline - symbolHeight + 1, // #3988
  32207. symbolWidth, symbolHeight, pick(legend.options.symbolRadius, symbolHeight / 2))
  32208. .addClass('highcharts-point')
  32209. .attr({
  32210. zIndex: 3
  32211. }).add(item.legendGroup);
  32212. },
  32213. /**
  32214. * Get the series' symbol in the legend. This method should be overridable
  32215. * to create custom symbols through
  32216. * Highcharts.seriesTypes[type].prototype.drawLegendSymbols.
  32217. *
  32218. * @private
  32219. * @function Highcharts.LegendSymbolMixin.drawLineMarker
  32220. *
  32221. * @param {Highcharts.Legend} legend
  32222. * The legend object.
  32223. */
  32224. drawLineMarker: function (legend) {
  32225. var options = this.options,
  32226. markerOptions = options.marker,
  32227. radius,
  32228. legendSymbol,
  32229. symbolWidth = legend.symbolWidth,
  32230. symbolHeight = legend.symbolHeight,
  32231. generalRadius = symbolHeight / 2,
  32232. renderer = this.chart.renderer,
  32233. legendItemGroup = this.legendGroup,
  32234. verticalCenter = legend.baseline -
  32235. Math.round(legend.fontMetrics.b * 0.3),
  32236. attr = {};
  32237. // Draw the line
  32238. if (!this.chart.styledMode) {
  32239. attr = {
  32240. 'stroke-width': options.lineWidth || 0
  32241. };
  32242. if (options.dashStyle) {
  32243. attr.dashstyle = options.dashStyle;
  32244. }
  32245. }
  32246. this.legendLine = renderer
  32247. .path([
  32248. ['M', 0, verticalCenter],
  32249. ['L', symbolWidth, verticalCenter]
  32250. ])
  32251. .addClass('highcharts-graph')
  32252. .attr(attr)
  32253. .add(legendItemGroup);
  32254. // Draw the marker
  32255. if (markerOptions && markerOptions.enabled !== false && symbolWidth) {
  32256. // Do not allow the marker to be larger than the symbolHeight
  32257. radius = Math.min(pick(markerOptions.radius, generalRadius), generalRadius);
  32258. // Restrict symbol markers size
  32259. if (this.symbol.indexOf('url') === 0) {
  32260. markerOptions = merge(markerOptions, {
  32261. width: symbolHeight,
  32262. height: symbolHeight
  32263. });
  32264. radius = 0;
  32265. }
  32266. this.legendSymbol = legendSymbol = renderer.symbol(this.symbol, (symbolWidth / 2) - radius, verticalCenter - radius, 2 * radius, 2 * radius, markerOptions)
  32267. .addClass('highcharts-point')
  32268. .add(legendItemGroup);
  32269. legendSymbol.isMarker = true;
  32270. }
  32271. }
  32272. };
  32273. return LegendSymbolMixin;
  32274. });
  32275. _registerModule(_modules, 'Core/Series/Series.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Globals.js'], _modules['Mixins/LegendSymbol.js'], _modules['Core/Options.js'], _modules['Core/Color/Palette.js'], _modules['Core/Series/Point.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Renderer/SVG/SVGElement.js'], _modules['Core/Utilities.js']], function (A, H, LegendSymbolMixin, O, palette, Point, SeriesRegistry, SVGElement, U) {
  32276. /* *
  32277. *
  32278. * (c) 2010-2021 Torstein Honsi
  32279. *
  32280. * License: www.highcharts.com/license
  32281. *
  32282. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  32283. *
  32284. * */
  32285. var animObject = A.animObject,
  32286. setAnimation = A.setAnimation;
  32287. var hasTouch = H.hasTouch,
  32288. svg = H.svg,
  32289. win = H.win;
  32290. var defaultOptions = O.defaultOptions;
  32291. var seriesTypes = SeriesRegistry.seriesTypes;
  32292. var addEvent = U.addEvent,
  32293. arrayMax = U.arrayMax,
  32294. arrayMin = U.arrayMin,
  32295. clamp = U.clamp,
  32296. cleanRecursively = U.cleanRecursively,
  32297. correctFloat = U.correctFloat,
  32298. defined = U.defined,
  32299. erase = U.erase,
  32300. error = U.error,
  32301. extend = U.extend,
  32302. find = U.find,
  32303. fireEvent = U.fireEvent,
  32304. getNestedProperty = U.getNestedProperty,
  32305. isArray = U.isArray,
  32306. isFunction = U.isFunction,
  32307. isNumber = U.isNumber,
  32308. isString = U.isString,
  32309. merge = U.merge,
  32310. objectEach = U.objectEach,
  32311. pick = U.pick,
  32312. removeEvent = U.removeEvent,
  32313. splat = U.splat,
  32314. syncTimeout = U.syncTimeout;
  32315. /* *
  32316. *
  32317. * Class
  32318. *
  32319. * */
  32320. /**
  32321. * This is the base series prototype that all other series types inherit from.
  32322. * A new series is initialized either through the
  32323. * [series](https://api.highcharts.com/highcharts/series)
  32324. * option structure, or after the chart is initialized, through
  32325. * {@link Highcharts.Chart#addSeries}.
  32326. *
  32327. * The object can be accessed in a number of ways. All series and point event
  32328. * handlers give a reference to the `series` object. The chart object has a
  32329. * {@link Highcharts.Chart#series|series} property that is a collection of all
  32330. * the chart's series. The point objects and axis objects also have the same
  32331. * reference.
  32332. *
  32333. * Another way to reference the series programmatically is by `id`. Add an id
  32334. * in the series configuration options, and get the series object by
  32335. * {@link Highcharts.Chart#get}.
  32336. *
  32337. * Configuration options for the series are given in three levels. Options for
  32338. * all series in a chart are given in the
  32339. * [plotOptions.series](https://api.highcharts.com/highcharts/plotOptions.series)
  32340. * object. Then options for all series of a specific type
  32341. * are given in the plotOptions of that type, for example `plotOptions.line`.
  32342. * Next, options for one single series are given in the series array, or as
  32343. * arguments to `chart.addSeries`.
  32344. *
  32345. * The data in the series is stored in various arrays.
  32346. *
  32347. * - First, `series.options.data` contains all the original config options for
  32348. * each point whether added by options or methods like `series.addPoint`.
  32349. *
  32350. * - Next, `series.data` contains those values converted to points, but in case
  32351. * the series data length exceeds the `cropThreshold`, or if the data is
  32352. * grouped, `series.data` doesn't contain all the points. It only contains the
  32353. * points that have been created on demand.
  32354. *
  32355. * - Then there's `series.points` that contains all currently visible point
  32356. * objects. In case of cropping, the cropped-away points are not part of this
  32357. * array. The `series.points` array starts at `series.cropStart` compared to
  32358. * `series.data` and `series.options.data`. If however the series data is
  32359. * grouped, these can't be correlated one to one.
  32360. *
  32361. * - `series.xData` and `series.processedXData` contain clean x values,
  32362. * equivalent to `series.data` and `series.points`.
  32363. *
  32364. * - `series.yData` and `series.processedYData` contain clean y values,
  32365. * equivalent to `series.data` and `series.points`.
  32366. *
  32367. * @class
  32368. * @name Highcharts.Series
  32369. *
  32370. * @param {Highcharts.Chart} chart
  32371. * The chart instance.
  32372. *
  32373. * @param {Highcharts.SeriesOptionsType|object} options
  32374. * The series options.
  32375. */
  32376. var Series = /** @class */ (function () {
  32377. function Series() {
  32378. /* *
  32379. *
  32380. * Static Functions
  32381. *
  32382. * */
  32383. this._i = void 0;
  32384. this.chart = void 0;
  32385. this.data = void 0;
  32386. this.eventOptions = void 0;
  32387. this.eventsToUnbind = void 0;
  32388. this.index = void 0;
  32389. this.linkedSeries = void 0;
  32390. this.options = void 0;
  32391. this.points = void 0;
  32392. this.processedXData = void 0;
  32393. this.processedYData = void 0;
  32394. this.tooltipOptions = void 0;
  32395. this.userOptions = void 0;
  32396. this.xAxis = void 0;
  32397. this.yAxis = void 0;
  32398. this.zones = void 0;
  32399. /** eslint-enable valid-jsdoc */
  32400. }
  32401. /* *
  32402. *
  32403. * Functions
  32404. *
  32405. * */
  32406. /* eslint-disable valid-jsdoc */
  32407. Series.prototype.init = function (chart, userOptions) {
  32408. fireEvent(this, 'init', { options: userOptions });
  32409. var series = this,
  32410. events,
  32411. chartSeries = chart.series,
  32412. lastSeries;
  32413. // A lookup over those events that are added by _options_ (not
  32414. // programmatically). These are updated through Series.update()
  32415. // (#10861).
  32416. this.eventOptions = this.eventOptions || {};
  32417. // The 'eventsToUnbind' property moved from prototype into the
  32418. // Series init to avoid reference to the same array between
  32419. // the different series and charts. #12959, #13937
  32420. this.eventsToUnbind = [];
  32421. /**
  32422. * Read only. The chart that the series belongs to.
  32423. *
  32424. * @name Highcharts.Series#chart
  32425. * @type {Highcharts.Chart}
  32426. */
  32427. series.chart = chart;
  32428. /**
  32429. * Read only. The series' type, like "line", "area", "column" etc.
  32430. * The type in the series options anc can be altered using
  32431. * {@link Series#update}.
  32432. *
  32433. * @name Highcharts.Series#type
  32434. * @type {string}
  32435. */
  32436. /**
  32437. * Read only. The series' current options. To update, use
  32438. * {@link Series#update}.
  32439. *
  32440. * @name Highcharts.Series#options
  32441. * @type {Highcharts.SeriesOptionsType}
  32442. */
  32443. series.options = series.setOptions(userOptions);
  32444. var options = series.options;
  32445. series.linkedSeries = [];
  32446. // bind the axes
  32447. series.bindAxes();
  32448. extend(series, {
  32449. /**
  32450. * The series name as given in the options. Defaults to
  32451. * "Series {n}".
  32452. *
  32453. * @name Highcharts.Series#name
  32454. * @type {string}
  32455. */
  32456. name: options.name,
  32457. state: '',
  32458. /**
  32459. * Read only. The series' visibility state as set by {@link
  32460. * Series#show}, {@link Series#hide}, or in the initial
  32461. * configuration.
  32462. *
  32463. * @name Highcharts.Series#visible
  32464. * @type {boolean}
  32465. */
  32466. visible: options.visible !== false,
  32467. /**
  32468. * Read only. The series' selected state as set by {@link
  32469. * Highcharts.Series#select}.
  32470. *
  32471. * @name Highcharts.Series#selected
  32472. * @type {boolean}
  32473. */
  32474. selected: options.selected === true // false by default
  32475. });
  32476. // Register event listeners
  32477. events = options.events;
  32478. objectEach(events, function (event, eventType) {
  32479. if (isFunction(event)) {
  32480. // If event does not exist, or is changed by Series.update
  32481. if (series.eventOptions[eventType] !== event) {
  32482. // Remove existing if set by option
  32483. if (isFunction(series.eventOptions[eventType])) {
  32484. removeEvent(series, eventType, series.eventOptions[eventType]);
  32485. }
  32486. series.eventOptions[eventType] = event;
  32487. addEvent(series, eventType, event);
  32488. }
  32489. }
  32490. });
  32491. if ((events && events.click) ||
  32492. (options.point &&
  32493. options.point.events &&
  32494. options.point.events.click) ||
  32495. options.allowPointSelect) {
  32496. chart.runTrackerClick = true;
  32497. }
  32498. series.getColor();
  32499. series.getSymbol();
  32500. // Initialize the parallel data arrays
  32501. series.parallelArrays.forEach(function (key) {
  32502. if (!series[key + 'Data']) {
  32503. series[key + 'Data'] = [];
  32504. }
  32505. });
  32506. // Mark cartesian
  32507. if (series.isCartesian) {
  32508. chart.hasCartesianSeries = true;
  32509. }
  32510. // Get the index and register the series in the chart. The index is
  32511. // one more than the current latest series index (#5960).
  32512. if (chartSeries.length) {
  32513. lastSeries = chartSeries[chartSeries.length - 1];
  32514. }
  32515. series._i = pick(lastSeries && lastSeries._i, -1) + 1;
  32516. series.opacity = series.options.opacity;
  32517. // Insert the series and re-order all series above the insertion
  32518. // point.
  32519. chart.orderSeries(this.insert(chartSeries));
  32520. // Set options for series with sorting and set data later.
  32521. if (options.dataSorting && options.dataSorting.enabled) {
  32522. series.setDataSortingOptions();
  32523. }
  32524. else if (!series.points && !series.data) {
  32525. series.setData(options.data, false);
  32526. }
  32527. fireEvent(this, 'afterInit');
  32528. };
  32529. /**
  32530. * Check whether the series item is itself or inherits from a certain
  32531. * series type.
  32532. *
  32533. * @function Highcharts.Series#is
  32534. * @param {string} type The type of series to check for, can be either
  32535. * featured or custom series types. For example `column`, `pie`,
  32536. * `ohlc` etc.
  32537. *
  32538. * @return {boolean}
  32539. * True if this item is or inherits from the given type.
  32540. */
  32541. Series.prototype.is = function (type) {
  32542. return seriesTypes[type] && this instanceof seriesTypes[type];
  32543. };
  32544. /**
  32545. * Insert the series in a collection with other series, either the chart
  32546. * series or yAxis series, in the correct order according to the index
  32547. * option. Used internally when adding series.
  32548. *
  32549. * @private
  32550. * @function Highcharts.Series#insert
  32551. * @param {Array<Highcharts.Series>} collection
  32552. * A collection of series, like `chart.series` or `xAxis.series`.
  32553. * @return {number}
  32554. * The index of the series in the collection.
  32555. */
  32556. Series.prototype.insert = function (collection) {
  32557. var indexOption = this.options.index,
  32558. i;
  32559. // Insert by index option
  32560. if (isNumber(indexOption)) {
  32561. i = collection.length;
  32562. while (i--) {
  32563. // Loop down until the interted element has higher index
  32564. if (indexOption >=
  32565. pick(collection[i].options.index, collection[i]._i)) {
  32566. collection.splice(i + 1, 0, this);
  32567. break;
  32568. }
  32569. }
  32570. if (i === -1) {
  32571. collection.unshift(this);
  32572. }
  32573. i = i + 1;
  32574. // Or just push it to the end
  32575. }
  32576. else {
  32577. collection.push(this);
  32578. }
  32579. return pick(i, collection.length - 1);
  32580. };
  32581. /**
  32582. * Set the xAxis and yAxis properties of cartesian series, and register
  32583. * the series in the `axis.series` array.
  32584. *
  32585. * @private
  32586. * @function Highcharts.Series#bindAxes
  32587. */
  32588. Series.prototype.bindAxes = function () {
  32589. var series = this,
  32590. seriesOptions = series.options,
  32591. chart = series.chart,
  32592. axisOptions;
  32593. fireEvent(this, 'bindAxes', null, function () {
  32594. // repeat for xAxis and yAxis
  32595. (series.axisTypes || []).forEach(function (AXIS) {
  32596. var index = 0;
  32597. // loop through the chart's axis objects
  32598. chart[AXIS].forEach(function (axis) {
  32599. axisOptions = axis.options;
  32600. // apply if the series xAxis or yAxis option mathches
  32601. // the number of the axis, or if undefined, use the
  32602. // first axis
  32603. if ((seriesOptions[AXIS] === index &&
  32604. !axisOptions.isInternal) ||
  32605. (typeof seriesOptions[AXIS] !==
  32606. 'undefined' &&
  32607. seriesOptions[AXIS] === axisOptions.id) ||
  32608. (typeof seriesOptions[AXIS] ===
  32609. 'undefined' &&
  32610. axisOptions.index === 0)) {
  32611. // register this series in the axis.series lookup
  32612. series.insert(axis.series);
  32613. // set this series.xAxis or series.yAxis reference
  32614. /**
  32615. * Read only. The unique xAxis object associated
  32616. * with the series.
  32617. *
  32618. * @name Highcharts.Series#xAxis
  32619. * @type {Highcharts.Axis}
  32620. */
  32621. /**
  32622. * Read only. The unique yAxis object associated
  32623. * with the series.
  32624. *
  32625. * @name Highcharts.Series#yAxis
  32626. * @type {Highcharts.Axis}
  32627. */
  32628. series[AXIS] = axis;
  32629. // mark dirty for redraw
  32630. axis.isDirty = true;
  32631. }
  32632. if (!axisOptions.isInternal) {
  32633. index++;
  32634. }
  32635. });
  32636. // The series needs an X and an Y axis
  32637. if (!series[AXIS] &&
  32638. series.optionalAxis !== AXIS) {
  32639. error(18, true, chart);
  32640. }
  32641. });
  32642. });
  32643. fireEvent(this, 'afterBindAxes');
  32644. };
  32645. /**
  32646. * For simple series types like line and column, the data values are
  32647. * held in arrays like xData and yData for quick lookup to find extremes
  32648. * and more. For multidimensional series like bubble and map, this can
  32649. * be extended with arrays like zData and valueData by adding to the
  32650. * `series.parallelArrays` array.
  32651. *
  32652. * @private
  32653. * @function Highcharts.Series#updateParallelArrays
  32654. */
  32655. Series.prototype.updateParallelArrays = function (point, i) {
  32656. var series = point.series,
  32657. args = arguments,
  32658. fn = isNumber(i) ?
  32659. // Insert the value in the given position
  32660. function (key) {
  32661. var val = key === 'y' && series.toYData ?
  32662. series.toYData(point) :
  32663. point[key];
  32664. series[key + 'Data'][i] = val;
  32665. } :
  32666. // Apply the method specified in i with the following
  32667. // arguments as arguments
  32668. function (key) {
  32669. Array.prototype[i].apply(series[key + 'Data'], Array.prototype.slice.call(args, 2));
  32670. };
  32671. series.parallelArrays.forEach(fn);
  32672. };
  32673. /**
  32674. * Define hasData functions for series. These return true if there
  32675. * are data points on this series within the plot area.
  32676. *
  32677. * @private
  32678. * @function Highcharts.Series#hasData
  32679. * @return {boolean}
  32680. */
  32681. Series.prototype.hasData = function () {
  32682. return ((this.visible &&
  32683. typeof this.dataMax !== 'undefined' &&
  32684. typeof this.dataMin !== 'undefined') || ( // #3703
  32685. this.visible &&
  32686. this.yData &&
  32687. this.yData.length > 0) // #9758
  32688. );
  32689. };
  32690. /**
  32691. * Return an auto incremented x value based on the pointStart and
  32692. * pointInterval options. This is only used if an x value is not given
  32693. * for the point that calls autoIncrement.
  32694. *
  32695. * @private
  32696. * @function Highcharts.Series#autoIncrement
  32697. * @return {number}
  32698. */
  32699. Series.prototype.autoIncrement = function () {
  32700. var options = this.options,
  32701. xIncrement = this.xIncrement,
  32702. date,
  32703. pointInterval,
  32704. pointIntervalUnit = options.pointIntervalUnit,
  32705. time = this.chart.time;
  32706. xIncrement = pick(xIncrement, options.pointStart, 0);
  32707. this.pointInterval = pointInterval = pick(this.pointInterval, options.pointInterval, 1);
  32708. // Added code for pointInterval strings
  32709. if (pointIntervalUnit) {
  32710. date = new time.Date(xIncrement);
  32711. if (pointIntervalUnit === 'day') {
  32712. time.set('Date', date, time.get('Date', date) + pointInterval);
  32713. }
  32714. else if (pointIntervalUnit === 'month') {
  32715. time.set('Month', date, time.get('Month', date) + pointInterval);
  32716. }
  32717. else if (pointIntervalUnit === 'year') {
  32718. time.set('FullYear', date, time.get('FullYear', date) + pointInterval);
  32719. }
  32720. pointInterval = date.getTime() - xIncrement;
  32721. }
  32722. this.xIncrement = xIncrement + pointInterval;
  32723. return xIncrement;
  32724. };
  32725. /**
  32726. * Internal function to set properties for series if data sorting is
  32727. * enabled.
  32728. *
  32729. * @private
  32730. * @function Highcharts.Series#setDataSortingOptions
  32731. */
  32732. Series.prototype.setDataSortingOptions = function () {
  32733. var options = this.options;
  32734. extend(this, {
  32735. requireSorting: false,
  32736. sorted: false,
  32737. enabledDataSorting: true,
  32738. allowDG: false
  32739. });
  32740. // To allow unsorted data for column series.
  32741. if (!defined(options.pointRange)) {
  32742. options.pointRange = 1;
  32743. }
  32744. };
  32745. /**
  32746. * Set the series options by merging from the options tree. Called
  32747. * internally on initializing and updating series. This function will
  32748. * not redraw the series. For API usage, use {@link Series#update}.
  32749. * @private
  32750. * @function Highcharts.Series#setOptions
  32751. *
  32752. * @param {Highcharts.SeriesOptionsType} itemOptions
  32753. * The series options.
  32754. *
  32755. * @return {Highcharts.SeriesOptionsType}
  32756. *
  32757. * @fires Highcharts.Series#event:afterSetOptions
  32758. */
  32759. Series.prototype.setOptions = function (itemOptions) {
  32760. var chart = this.chart,
  32761. chartOptions = chart.options,
  32762. plotOptions = chartOptions.plotOptions,
  32763. userOptions = chart.userOptions || {},
  32764. seriesUserOptions = merge(itemOptions),
  32765. options,
  32766. zones,
  32767. zone,
  32768. styledMode = chart.styledMode,
  32769. e = {
  32770. plotOptions: plotOptions,
  32771. userOptions: seriesUserOptions
  32772. };
  32773. fireEvent(this, 'setOptions', e);
  32774. // These may be modified by the event
  32775. var typeOptions = e.plotOptions[this.type],
  32776. userPlotOptions = (userOptions.plotOptions || {});
  32777. // use copy to prevent undetected changes (#9762)
  32778. /**
  32779. * Contains series options by the user without defaults.
  32780. * @name Highcharts.Series#userOptions
  32781. * @type {Highcharts.SeriesOptionsType}
  32782. */
  32783. this.userOptions = e.userOptions;
  32784. options = merge(typeOptions, plotOptions.series,
  32785. // #3881, chart instance plotOptions[type] should trump
  32786. // plotOptions.series
  32787. userOptions.plotOptions &&
  32788. userOptions.plotOptions[this.type], seriesUserOptions);
  32789. // The tooltip options are merged between global and series specific
  32790. // options. Importance order asscendingly:
  32791. // globals: (1)tooltip, (2)plotOptions.series,
  32792. // (3)plotOptions[this.type]
  32793. // init userOptions with possible later updates: 4-6 like 1-3 and
  32794. // (7)this series options
  32795. this.tooltipOptions = merge(defaultOptions.tooltip, // 1
  32796. defaultOptions.plotOptions.series &&
  32797. defaultOptions.plotOptions.series.tooltip, // 2
  32798. defaultOptions.plotOptions[this.type].tooltip, // 3
  32799. chartOptions.tooltip.userOptions, // 4
  32800. plotOptions.series &&
  32801. plotOptions.series.tooltip, // 5
  32802. plotOptions[this.type].tooltip, // 6
  32803. seriesUserOptions.tooltip // 7
  32804. );
  32805. // When shared tooltip, stickyTracking is true by default,
  32806. // unless user says otherwise.
  32807. this.stickyTracking = pick(seriesUserOptions.stickyTracking, userPlotOptions[this.type] &&
  32808. userPlotOptions[this.type].stickyTracking, userPlotOptions.series && userPlotOptions.series.stickyTracking, (this.tooltipOptions.shared && !this.noSharedTooltip ?
  32809. true :
  32810. options.stickyTracking));
  32811. // Delete marker object if not allowed (#1125)
  32812. if (typeOptions.marker === null) {
  32813. delete options.marker;
  32814. }
  32815. // Handle color zones
  32816. this.zoneAxis = options.zoneAxis;
  32817. zones = this.zones = (options.zones || []).slice();
  32818. if ((options.negativeColor || options.negativeFillColor) &&
  32819. !options.zones) {
  32820. zone = {
  32821. value: options[this.zoneAxis + 'Threshold'] ||
  32822. options.threshold ||
  32823. 0,
  32824. className: 'highcharts-negative'
  32825. };
  32826. if (!styledMode) {
  32827. zone.color = options.negativeColor;
  32828. zone.fillColor = options.negativeFillColor;
  32829. }
  32830. zones.push(zone);
  32831. }
  32832. if (zones.length) { // Push one extra zone for the rest
  32833. if (defined(zones[zones.length - 1].value)) {
  32834. zones.push(styledMode ? {} : {
  32835. color: this.color,
  32836. fillColor: this.fillColor
  32837. });
  32838. }
  32839. }
  32840. fireEvent(this, 'afterSetOptions', { options: options });
  32841. return options;
  32842. };
  32843. /**
  32844. * Return series name in "Series {Number}" format or the one defined by
  32845. * a user. This method can be simply overridden as series name format
  32846. * can vary (e.g. technical indicators).
  32847. *
  32848. * @function Highcharts.Series#getName
  32849. *
  32850. * @return {string}
  32851. * The series name.
  32852. */
  32853. Series.prototype.getName = function () {
  32854. // #4119
  32855. return pick(this.options.name, 'Series ' + (this.index + 1));
  32856. };
  32857. /**
  32858. * @private
  32859. * @function Highcharts.Series#getCyclic
  32860. */
  32861. Series.prototype.getCyclic = function (prop, value, defaults) {
  32862. var i, chart = this.chart, userOptions = this.userOptions, indexName = prop + 'Index', counterName = prop + 'Counter', len = defaults ? defaults.length : pick(chart.options.chart[prop + 'Count'], chart[prop + 'Count']), setting;
  32863. if (!value) {
  32864. // Pick up either the colorIndex option, or the _colorIndex
  32865. // after Series.update()
  32866. setting = pick(userOptions[indexName], userOptions['_' + indexName]);
  32867. if (defined(setting)) { // after Series.update()
  32868. i = setting;
  32869. }
  32870. else {
  32871. // #6138
  32872. if (!chart.series.length) {
  32873. chart[counterName] = 0;
  32874. }
  32875. userOptions['_' + indexName] = i =
  32876. chart[counterName] % len;
  32877. chart[counterName] += 1;
  32878. }
  32879. if (defaults) {
  32880. value = defaults[i];
  32881. }
  32882. }
  32883. // Set the colorIndex
  32884. if (typeof i !== 'undefined') {
  32885. this[indexName] = i;
  32886. }
  32887. this[prop] = value;
  32888. };
  32889. /**
  32890. * Get the series' color based on either the options or pulled from
  32891. * global options.
  32892. *
  32893. * @private
  32894. * @function Highcharts.Series#getColor
  32895. */
  32896. Series.prototype.getColor = function () {
  32897. if (this.chart.styledMode) {
  32898. this.getCyclic('color');
  32899. }
  32900. else if (this.options.colorByPoint) {
  32901. this.color = palette.neutralColor20;
  32902. }
  32903. else {
  32904. this.getCyclic('color', this.options.color ||
  32905. defaultOptions.plotOptions[this.type].color, this.chart.options.colors);
  32906. }
  32907. };
  32908. /**
  32909. * Get all points' instances created for this series.
  32910. *
  32911. * @private
  32912. * @function Highcharts.Series#getPointsCollection
  32913. * @return {Array<Highcharts.Point>}
  32914. */
  32915. Series.prototype.getPointsCollection = function () {
  32916. return (this.hasGroupedData ? this.points : this.data) || [];
  32917. };
  32918. /**
  32919. * Get the series' symbol based on either the options or pulled from
  32920. * global options.
  32921. *
  32922. * @private
  32923. * @function Highcharts.Series#getSymbol
  32924. * @return {void}
  32925. */
  32926. Series.prototype.getSymbol = function () {
  32927. var seriesMarkerOption = this.options.marker;
  32928. this.getCyclic('symbol', seriesMarkerOption.symbol, this.chart.options.symbols);
  32929. };
  32930. /**
  32931. * Finds the index of an existing point that matches the given point
  32932. * options.
  32933. *
  32934. * @private
  32935. * @function Highcharts.Series#findPointIndex
  32936. * @param {Highcharts.PointOptionsObject} optionsObject
  32937. * The options of the point.
  32938. * @param {number} fromIndex
  32939. * The index to start searching from, used for optimizing
  32940. * series with required sorting.
  32941. * @returns {number|undefined}
  32942. * Returns the index of a matching point, or undefined if no
  32943. * match is found.
  32944. */
  32945. Series.prototype.findPointIndex = function (optionsObject, fromIndex) {
  32946. var id = optionsObject.id,
  32947. x = optionsObject.x,
  32948. oldData = this.points,
  32949. matchingPoint,
  32950. matchedById,
  32951. pointIndex,
  32952. matchKey,
  32953. dataSorting = this.options.dataSorting;
  32954. if (id) {
  32955. matchingPoint = this.chart.get(id);
  32956. }
  32957. else if (this.linkedParent || this.enabledDataSorting) {
  32958. matchKey = (dataSorting && dataSorting.matchByName) ?
  32959. 'name' : 'index';
  32960. matchingPoint = find(oldData, function (oldPoint) {
  32961. return !oldPoint.touched && oldPoint[matchKey] ===
  32962. optionsObject[matchKey];
  32963. });
  32964. // Add unmatched point as a new point
  32965. if (!matchingPoint) {
  32966. return void 0;
  32967. }
  32968. }
  32969. if (matchingPoint) {
  32970. pointIndex = matchingPoint && matchingPoint.index;
  32971. if (typeof pointIndex !== 'undefined') {
  32972. matchedById = true;
  32973. }
  32974. }
  32975. // Search for the same X in the existing data set
  32976. if (typeof pointIndex === 'undefined' && isNumber(x)) {
  32977. pointIndex = this.xData.indexOf(x, fromIndex);
  32978. }
  32979. // Reduce pointIndex if data is cropped
  32980. if (pointIndex !== -1 &&
  32981. typeof pointIndex !== 'undefined' &&
  32982. this.cropped) {
  32983. pointIndex = (pointIndex >= this.cropStart) ?
  32984. pointIndex - this.cropStart : pointIndex;
  32985. }
  32986. if (!matchedById &&
  32987. oldData[pointIndex] && oldData[pointIndex].touched) {
  32988. pointIndex = void 0;
  32989. }
  32990. return pointIndex;
  32991. };
  32992. /**
  32993. * Internal function called from setData. If the point count is the same
  32994. * as is was, or if there are overlapping X values, just run
  32995. * Point.update which is cheaper, allows animation, and keeps references
  32996. * to points. This also allows adding or removing points if the X-es
  32997. * don't match.
  32998. *
  32999. * @private
  33000. * @function Highcharts.Series#updateData
  33001. */
  33002. Series.prototype.updateData = function (data, animation) {
  33003. var options = this.options,
  33004. dataSorting = options.dataSorting,
  33005. oldData = this.points,
  33006. pointsToAdd = [],
  33007. hasUpdatedByKey,
  33008. i,
  33009. point,
  33010. lastIndex,
  33011. requireSorting = this.requireSorting,
  33012. equalLength = data.length === oldData.length,
  33013. succeeded = true;
  33014. this.xIncrement = null;
  33015. // Iterate the new data
  33016. data.forEach(function (pointOptions, i) {
  33017. var id,
  33018. x,
  33019. pointIndex,
  33020. optionsObject = (defined(pointOptions) &&
  33021. this.pointClass.prototype.optionsToObject.call({ series: this },
  33022. pointOptions)) || {};
  33023. // Get the x of the new data point
  33024. x = optionsObject.x;
  33025. id = optionsObject.id;
  33026. if (id || isNumber(x)) {
  33027. pointIndex = this.findPointIndex(optionsObject, lastIndex);
  33028. // Matching X not found
  33029. // or used already due to ununique x values (#8995),
  33030. // add point (but later)
  33031. if (pointIndex === -1 ||
  33032. typeof pointIndex === 'undefined') {
  33033. pointsToAdd.push(pointOptions);
  33034. // Matching X found, update
  33035. }
  33036. else if (oldData[pointIndex] &&
  33037. pointOptions !== options.data[pointIndex]) {
  33038. oldData[pointIndex].update(pointOptions, false, null, false);
  33039. // Mark it touched, below we will remove all points that
  33040. // are not touched.
  33041. oldData[pointIndex].touched = true;
  33042. // Speed optimize by only searching after last known
  33043. // index. Performs ~20% bettor on large data sets.
  33044. if (requireSorting) {
  33045. lastIndex = pointIndex + 1;
  33046. }
  33047. // Point exists, no changes, don't remove it
  33048. }
  33049. else if (oldData[pointIndex]) {
  33050. oldData[pointIndex].touched = true;
  33051. }
  33052. // If the length is equal and some of the nodes had a
  33053. // match in the same position, we don't want to remove
  33054. // non-matches.
  33055. if (!equalLength ||
  33056. i !== pointIndex ||
  33057. (dataSorting && dataSorting.enabled) ||
  33058. this.hasDerivedData) {
  33059. hasUpdatedByKey = true;
  33060. }
  33061. }
  33062. else {
  33063. // Gather all points that are not matched
  33064. pointsToAdd.push(pointOptions);
  33065. }
  33066. }, this);
  33067. // Remove points that don't exist in the updated data set
  33068. if (hasUpdatedByKey) {
  33069. i = oldData.length;
  33070. while (i--) {
  33071. point = oldData[i];
  33072. if (point && !point.touched && point.remove) {
  33073. point.remove(false, animation);
  33074. }
  33075. }
  33076. // If we did not find keys (ids or x-values), and the length is the
  33077. // same, update one-to-one
  33078. }
  33079. else if (equalLength && (!dataSorting || !dataSorting.enabled)) {
  33080. data.forEach(function (point, i) {
  33081. // .update doesn't exist on a linked, hidden series (#3709)
  33082. // (#10187)
  33083. if (oldData[i].update && point !== oldData[i].y) {
  33084. oldData[i].update(point, false, null, false);
  33085. }
  33086. });
  33087. // Don't add new points since those configs are used above
  33088. pointsToAdd.length = 0;
  33089. // Did not succeed in updating data
  33090. }
  33091. else {
  33092. succeeded = false;
  33093. }
  33094. oldData.forEach(function (point) {
  33095. if (point) {
  33096. point.touched = false;
  33097. }
  33098. });
  33099. if (!succeeded) {
  33100. return false;
  33101. }
  33102. // Add new points
  33103. pointsToAdd.forEach(function (point) {
  33104. this.addPoint(point, false, null, null, false);
  33105. }, this);
  33106. if (this.xIncrement === null &&
  33107. this.xData &&
  33108. this.xData.length) {
  33109. this.xIncrement = arrayMax(this.xData);
  33110. this.autoIncrement();
  33111. }
  33112. return true;
  33113. };
  33114. /**
  33115. * Apply a new set of data to the series and optionally redraw it. The
  33116. * new data array is passed by reference (except in case of
  33117. * `updatePoints`), and may later be mutated when updating the chart
  33118. * data.
  33119. *
  33120. * Note the difference in behaviour when setting the same amount of
  33121. * points, or a different amount of points, as handled by the
  33122. * `updatePoints` parameter.
  33123. *
  33124. * @sample highcharts/members/series-setdata/
  33125. * Set new data from a button
  33126. * @sample highcharts/members/series-setdata-pie/
  33127. * Set data in a pie
  33128. * @sample stock/members/series-setdata/
  33129. * Set new data in Highcharts Stock
  33130. * @sample maps/members/series-setdata/
  33131. * Set new data in Highmaps
  33132. *
  33133. * @function Highcharts.Series#setData
  33134. *
  33135. * @param {Array<Highcharts.PointOptionsType>} data
  33136. * Takes an array of data in the same format as described under
  33137. * `series.{type}.data` for the given series type, for example a
  33138. * line series would take data in the form described under
  33139. * [series.line.data](https://api.highcharts.com/highcharts/series.line.data).
  33140. *
  33141. * @param {boolean} [redraw=true]
  33142. * Whether to redraw the chart after the series is altered. If
  33143. * doing more operations on the chart, it is a good idea to set
  33144. * redraw to false and call {@link Chart#redraw} after.
  33145. *
  33146. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  33147. * When the updated data is the same length as the existing data,
  33148. * points will be updated by default, and animation visualizes
  33149. * how the points are changed. Set false to disable animation, or
  33150. * a configuration object to set duration or easing.
  33151. *
  33152. * @param {boolean} [updatePoints=true]
  33153. * When this is true, points will be updated instead of replaced
  33154. * whenever possible. This occurs a) when the updated data is the
  33155. * same length as the existing data, b) when points are matched
  33156. * by their id's, or c) when points can be matched by X values.
  33157. * This allows updating with animation and performs better. In
  33158. * this case, the original array is not passed by reference. Set
  33159. * `false` to prevent.
  33160. */
  33161. Series.prototype.setData = function (data, redraw, animation, updatePoints) {
  33162. var series = this,
  33163. oldData = series.points,
  33164. oldDataLength = (oldData && oldData.length) || 0,
  33165. dataLength,
  33166. options = series.options,
  33167. chart = series.chart,
  33168. dataSorting = options.dataSorting,
  33169. firstPoint = null,
  33170. xAxis = series.xAxis,
  33171. i,
  33172. turboThreshold = options.turboThreshold,
  33173. pt,
  33174. xData = this.xData,
  33175. yData = this.yData,
  33176. pointArrayMap = series.pointArrayMap,
  33177. valueCount = pointArrayMap && pointArrayMap.length,
  33178. keys = options.keys,
  33179. indexOfX = 0,
  33180. indexOfY = 1,
  33181. updatedData;
  33182. data = data || [];
  33183. dataLength = data.length;
  33184. redraw = pick(redraw, true);
  33185. if (dataSorting && dataSorting.enabled) {
  33186. data = this.sortData(data);
  33187. }
  33188. // First try to run Point.update which is cheaper, allows animation,
  33189. // and keeps references to points.
  33190. if (updatePoints !== false &&
  33191. dataLength &&
  33192. oldDataLength &&
  33193. !series.cropped &&
  33194. !series.hasGroupedData &&
  33195. series.visible &&
  33196. // Soft updating has no benefit in boost, and causes JS error
  33197. // (#8355)
  33198. !series.isSeriesBoosting) {
  33199. updatedData = this.updateData(data, animation);
  33200. }
  33201. if (!updatedData) {
  33202. // Reset properties
  33203. series.xIncrement = null;
  33204. series.colorCounter = 0; // for series with colorByPoint (#1547)
  33205. // Update parallel arrays
  33206. this.parallelArrays.forEach(function (key) {
  33207. series[key + 'Data'].length = 0;
  33208. });
  33209. // In turbo mode, only one- or twodimensional arrays of numbers
  33210. // are allowed. The first value is tested, and we assume that
  33211. // all the rest are defined the same way. Although the 'for'
  33212. // loops are similar, they are repeated inside each if-else
  33213. // conditional for max performance.
  33214. if (turboThreshold && dataLength > turboThreshold) {
  33215. firstPoint = series.getFirstValidPoint(data);
  33216. if (isNumber(firstPoint)) { // assume all points are numbers
  33217. for (i = 0; i < dataLength; i++) {
  33218. xData[i] = this.autoIncrement();
  33219. yData[i] = data[i];
  33220. }
  33221. // Assume all points are arrays when first point is
  33222. }
  33223. else if (isArray(firstPoint)) {
  33224. if (valueCount) { // [x, low, high] or [x, o, h, l, c]
  33225. for (i = 0; i < dataLength; i++) {
  33226. pt = data[i];
  33227. xData[i] = pt[0];
  33228. yData[i] =
  33229. pt.slice(1, valueCount + 1);
  33230. }
  33231. }
  33232. else { // [x, y]
  33233. if (keys) {
  33234. indexOfX = keys.indexOf('x');
  33235. indexOfY = keys.indexOf('y');
  33236. indexOfX = indexOfX >= 0 ? indexOfX : 0;
  33237. indexOfY = indexOfY >= 0 ? indexOfY : 1;
  33238. }
  33239. for (i = 0; i < dataLength; i++) {
  33240. pt = data[i];
  33241. xData[i] = pt[indexOfX];
  33242. yData[i] = pt[indexOfY];
  33243. }
  33244. }
  33245. }
  33246. else {
  33247. // Highcharts expects configs to be numbers or arrays in
  33248. // turbo mode
  33249. error(12, false, chart);
  33250. }
  33251. }
  33252. else {
  33253. for (i = 0; i < dataLength; i++) {
  33254. // stray commas in oldIE:
  33255. if (typeof data[i] !== 'undefined') {
  33256. pt = { series: series };
  33257. series.pointClass.prototype.applyOptions.apply(pt, [data[i]]);
  33258. series.updateParallelArrays(pt, i);
  33259. }
  33260. }
  33261. }
  33262. // Forgetting to cast strings to numbers is a common caveat when
  33263. // handling CSV or JSON
  33264. if (yData && isString(yData[0])) {
  33265. error(14, true, chart);
  33266. }
  33267. series.data = [];
  33268. series.options.data = series.userOptions.data = data;
  33269. // destroy old points
  33270. i = oldDataLength;
  33271. while (i--) {
  33272. if (oldData[i] && oldData[i].destroy) {
  33273. oldData[i].destroy();
  33274. }
  33275. }
  33276. // reset minRange (#878)
  33277. if (xAxis) {
  33278. xAxis.minRange = xAxis.userMinRange;
  33279. }
  33280. // redraw
  33281. series.isDirty = chart.isDirtyBox = true;
  33282. series.isDirtyData = !!oldData;
  33283. animation = false;
  33284. }
  33285. // Typically for pie series, points need to be processed and
  33286. // generated prior to rendering the legend
  33287. if (options.legendType === 'point') {
  33288. this.processData();
  33289. this.generatePoints();
  33290. }
  33291. if (redraw) {
  33292. chart.redraw(animation);
  33293. }
  33294. };
  33295. /**
  33296. * Internal function to sort series data
  33297. *
  33298. * @private
  33299. * @function Highcharts.Series#sortData
  33300. *
  33301. * @param {Array<Highcharts.PointOptionsType>} data
  33302. * Force data grouping.
  33303. *
  33304. * @return {Array<Highcharts.PointOptionsObject>}
  33305. */
  33306. Series.prototype.sortData = function (data) {
  33307. var series = this,
  33308. options = series.options,
  33309. dataSorting = options.dataSorting,
  33310. sortKey = dataSorting.sortKey || 'y',
  33311. sortedData,
  33312. getPointOptionsObject = function (series,
  33313. pointOptions) {
  33314. return (defined(pointOptions) &&
  33315. series.pointClass.prototype.optionsToObject.call({
  33316. series: series
  33317. },
  33318. pointOptions)) || {};
  33319. };
  33320. data.forEach(function (pointOptions, i) {
  33321. data[i] = getPointOptionsObject(series, pointOptions);
  33322. data[i].index = i;
  33323. }, this);
  33324. // Sorting
  33325. sortedData = data.concat().sort(function (a, b) {
  33326. var aValue = getNestedProperty(sortKey,
  33327. a);
  33328. var bValue = getNestedProperty(sortKey,
  33329. b);
  33330. return bValue < aValue ? -1 : bValue > aValue ? 1 : 0;
  33331. });
  33332. // Set x value depending on the position in the array
  33333. sortedData.forEach(function (point, i) {
  33334. point.x = i;
  33335. }, this);
  33336. // Set the same x for linked series points if they don't have their
  33337. // own sorting
  33338. if (series.linkedSeries) {
  33339. series.linkedSeries.forEach(function (linkedSeries) {
  33340. var options = linkedSeries.options,
  33341. seriesData = options.data;
  33342. if ((!options.dataSorting ||
  33343. !options.dataSorting.enabled) &&
  33344. seriesData) {
  33345. seriesData.forEach(function (pointOptions, i) {
  33346. seriesData[i] = getPointOptionsObject(linkedSeries, pointOptions);
  33347. if (data[i]) {
  33348. seriesData[i].x = data[i].x;
  33349. seriesData[i].index = i;
  33350. }
  33351. });
  33352. linkedSeries.setData(seriesData, false);
  33353. }
  33354. });
  33355. }
  33356. return data;
  33357. };
  33358. /**
  33359. * Internal function to process the data by cropping away unused data
  33360. * points if the series is longer than the crop threshold. This saves
  33361. * computing time for large series.
  33362. *
  33363. * @private
  33364. * @function Highcharts.Series#getProcessedData
  33365. * @param {boolean} [forceExtremesFromAll]
  33366. * Force getting extremes of a total series data range.
  33367. * @return {Highcharts.SeriesProcessedDataObject}
  33368. */
  33369. Series.prototype.getProcessedData = function (forceExtremesFromAll) {
  33370. var series = this,
  33371. // copied during slice operation:
  33372. processedXData = series.xData,
  33373. processedYData = series.yData,
  33374. dataLength = processedXData.length,
  33375. croppedData,
  33376. cropStart = 0,
  33377. cropped,
  33378. distance,
  33379. closestPointRange,
  33380. xAxis = series.xAxis,
  33381. i, // loop variable
  33382. options = series.options,
  33383. cropThreshold = options.cropThreshold,
  33384. getExtremesFromAll = forceExtremesFromAll ||
  33385. series.getExtremesFromAll ||
  33386. options.getExtremesFromAll, // #4599
  33387. isCartesian = series.isCartesian,
  33388. xExtremes,
  33389. val2lin = xAxis && xAxis.val2lin,
  33390. isLog = !!(xAxis && xAxis.logarithmic),
  33391. throwOnUnsorted = series.requireSorting,
  33392. min,
  33393. max;
  33394. if (xAxis) {
  33395. // corrected for log axis (#3053)
  33396. xExtremes = xAxis.getExtremes();
  33397. min = xExtremes.min;
  33398. max = xExtremes.max;
  33399. }
  33400. // optionally filter out points outside the plot area
  33401. if (isCartesian &&
  33402. series.sorted &&
  33403. !getExtremesFromAll &&
  33404. (!cropThreshold ||
  33405. dataLength > cropThreshold ||
  33406. series.forceCrop)) {
  33407. // it's outside current extremes
  33408. if (processedXData[dataLength - 1] < min ||
  33409. processedXData[0] > max) {
  33410. processedXData = [];
  33411. processedYData = [];
  33412. // only crop if it's actually spilling out
  33413. }
  33414. else if (series.yData && (processedXData[0] < min ||
  33415. processedXData[dataLength - 1] > max)) {
  33416. croppedData = this.cropData(series.xData, series.yData, min, max);
  33417. processedXData = croppedData.xData;
  33418. processedYData = croppedData.yData;
  33419. cropStart = croppedData.start;
  33420. cropped = true;
  33421. }
  33422. }
  33423. // Find the closest distance between processed points
  33424. i = processedXData.length || 1;
  33425. while (--i) {
  33426. distance = (isLog ?
  33427. (val2lin(processedXData[i]) -
  33428. val2lin(processedXData[i - 1])) :
  33429. (processedXData[i] -
  33430. processedXData[i - 1]));
  33431. if (distance > 0 &&
  33432. (typeof closestPointRange === 'undefined' ||
  33433. distance < closestPointRange)) {
  33434. closestPointRange = distance;
  33435. // Unsorted data is not supported by the line tooltip, as well
  33436. // as data grouping and navigation in Stock charts (#725) and
  33437. // width calculation of columns (#1900)
  33438. }
  33439. else if (distance < 0 && throwOnUnsorted) {
  33440. error(15, false, series.chart);
  33441. throwOnUnsorted = false; // Only once
  33442. }
  33443. }
  33444. return {
  33445. xData: processedXData,
  33446. yData: processedYData,
  33447. cropped: cropped,
  33448. cropStart: cropStart,
  33449. closestPointRange: closestPointRange
  33450. };
  33451. };
  33452. /**
  33453. * Internal function to apply processed data.
  33454. * In Highcharts Stock, this function is extended to provide data grouping.
  33455. *
  33456. * @private
  33457. * @function Highcharts.Series#processData
  33458. * @param {boolean} [force]
  33459. * Force data grouping.
  33460. * @return {boolean|undefined}
  33461. */
  33462. Series.prototype.processData = function (force) {
  33463. var series = this,
  33464. xAxis = series.xAxis,
  33465. processedData;
  33466. // If the series data or axes haven't changed, don't go through
  33467. // this. Return false to pass the message on to override methods
  33468. // like in data grouping.
  33469. if (series.isCartesian &&
  33470. !series.isDirty &&
  33471. !xAxis.isDirty &&
  33472. !series.yAxis.isDirty &&
  33473. !force) {
  33474. return false;
  33475. }
  33476. processedData = series.getProcessedData();
  33477. // Record the properties
  33478. series.cropped = processedData.cropped; // undefined or true
  33479. series.cropStart = processedData.cropStart;
  33480. series.processedXData = processedData.xData;
  33481. series.processedYData = processedData.yData;
  33482. series.closestPointRange = series.basePointRange = processedData.closestPointRange;
  33483. };
  33484. /**
  33485. * Iterate over xData and crop values between min and max. Returns
  33486. * object containing crop start/end cropped xData with corresponding
  33487. * part of yData, dataMin and dataMax within the cropped range.
  33488. *
  33489. * @private
  33490. * @function Highcharts.Series#cropData
  33491. * @param {Array<number>} xData
  33492. * @param {Array<number>} yData
  33493. * @param {number} min
  33494. * @param {number} max
  33495. * @param {number} [cropShoulder]
  33496. * @return {Highcharts.SeriesCropDataObject}
  33497. */
  33498. Series.prototype.cropData = function (xData, yData, min, max, cropShoulder) {
  33499. var dataLength = xData.length,
  33500. cropStart = 0,
  33501. cropEnd = dataLength,
  33502. i,
  33503. j;
  33504. // line-type series need one point outside
  33505. cropShoulder = pick(cropShoulder, this.cropShoulder);
  33506. // iterate up to find slice start
  33507. for (i = 0; i < dataLength; i++) {
  33508. if (xData[i] >= min) {
  33509. cropStart = Math.max(0, i - cropShoulder);
  33510. break;
  33511. }
  33512. }
  33513. // proceed to find slice end
  33514. for (j = i; j < dataLength; j++) {
  33515. if (xData[j] > max) {
  33516. cropEnd = j + cropShoulder;
  33517. break;
  33518. }
  33519. }
  33520. return {
  33521. xData: xData.slice(cropStart, cropEnd),
  33522. yData: yData.slice(cropStart, cropEnd),
  33523. start: cropStart,
  33524. end: cropEnd
  33525. };
  33526. };
  33527. /**
  33528. * Generate the data point after the data has been processed by cropping
  33529. * away unused points and optionally grouped in Highcharts Stock.
  33530. *
  33531. * @private
  33532. * @function Highcharts.Series#generatePoints
  33533. */
  33534. Series.prototype.generatePoints = function () {
  33535. var series = this,
  33536. options = series.options,
  33537. dataOptions = options.data,
  33538. data = series.data,
  33539. dataLength,
  33540. processedXData = series.processedXData,
  33541. processedYData = series.processedYData,
  33542. PointClass = series.pointClass,
  33543. processedDataLength = processedXData.length,
  33544. cropStart = series.cropStart || 0,
  33545. cursor,
  33546. hasGroupedData = series.hasGroupedData,
  33547. keys = options.keys,
  33548. point,
  33549. points = [],
  33550. i,
  33551. groupCropStartIndex = (options.dataGrouping &&
  33552. options.dataGrouping.groupAll ?
  33553. cropStart :
  33554. 0);
  33555. if (!data && !hasGroupedData) {
  33556. var arr = [];
  33557. arr.length = dataOptions.length;
  33558. data = series.data = arr;
  33559. }
  33560. if (keys && hasGroupedData) {
  33561. // grouped data has already applied keys (#6590)
  33562. series.options.keys = false;
  33563. }
  33564. for (i = 0; i < processedDataLength; i++) {
  33565. cursor = cropStart + i;
  33566. if (!hasGroupedData) {
  33567. point = data[cursor];
  33568. // #970:
  33569. if (!point &&
  33570. typeof dataOptions[cursor] !== 'undefined') {
  33571. data[cursor] = point = (new PointClass()).init(series, dataOptions[cursor], processedXData[i]);
  33572. }
  33573. }
  33574. else {
  33575. // splat the y data in case of ohlc data array
  33576. point = (new PointClass()).init(series, [processedXData[i]].concat(splat(processedYData[i])));
  33577. /**
  33578. * Highcharts Stock only. If a point object is created by data
  33579. * grouping, it doesn't reflect actual points in the raw
  33580. * data. In this case, the `dataGroup` property holds
  33581. * information that points back to the raw data.
  33582. *
  33583. * - `dataGroup.start` is the index of the first raw data
  33584. * point in the group.
  33585. *
  33586. * - `dataGroup.length` is the amount of points in the
  33587. * group.
  33588. *
  33589. * @product highstock
  33590. *
  33591. * @name Highcharts.Point#dataGroup
  33592. * @type {Highcharts.DataGroupingInfoObject|undefined}
  33593. */
  33594. point.dataGroup = series.groupMap[groupCropStartIndex + i];
  33595. if (point.dataGroup.options) {
  33596. point.options = point.dataGroup.options;
  33597. extend(point, point.dataGroup.options);
  33598. // Collision of props and options (#9770)
  33599. delete point.dataLabels;
  33600. }
  33601. }
  33602. if (point) { // #6279
  33603. /**
  33604. * Contains the point's index in the `Series.points` array.
  33605. *
  33606. * @name Highcharts.Point#index
  33607. * @type {number}
  33608. * @readonly
  33609. */
  33610. // For faster access in Point.update
  33611. point.index = hasGroupedData ? (groupCropStartIndex + i) : cursor;
  33612. points[i] = point;
  33613. }
  33614. }
  33615. // restore keys options (#6590)
  33616. series.options.keys = keys;
  33617. // Hide cropped-away points - this only runs when the number of
  33618. // points is above cropThreshold, or when swithching view from
  33619. // non-grouped data to grouped data (#637)
  33620. if (data &&
  33621. (processedDataLength !== (dataLength = data.length) ||
  33622. hasGroupedData)) {
  33623. for (i = 0; i < dataLength; i++) {
  33624. // when has grouped data, clear all points
  33625. if (i === cropStart && !hasGroupedData) {
  33626. i += processedDataLength;
  33627. }
  33628. if (data[i]) {
  33629. data[i].destroyElements();
  33630. data[i].plotX = void 0; // #1003
  33631. }
  33632. }
  33633. }
  33634. /**
  33635. * Read only. An array containing those values converted to points.
  33636. * In case the series data length exceeds the `cropThreshold`, or if
  33637. * the data is grouped, `series.data` doesn't contain all the
  33638. * points. Also, in case a series is hidden, the `data` array may be
  33639. * empty. To access raw values, `series.options.data` will always be
  33640. * up to date. `Series.data` only contains the points that have been
  33641. * created on demand. To modify the data, use
  33642. * {@link Highcharts.Series#setData} or
  33643. * {@link Highcharts.Point#update}.
  33644. *
  33645. * @see Series.points
  33646. *
  33647. * @name Highcharts.Series#data
  33648. * @type {Array<Highcharts.Point>}
  33649. */
  33650. series.data = data;
  33651. /**
  33652. * An array containing all currently visible point objects. In case
  33653. * of cropping, the cropped-away points are not part of this array.
  33654. * The `series.points` array starts at `series.cropStart` compared
  33655. * to `series.data` and `series.options.data`. If however the series
  33656. * data is grouped, these can't be correlated one to one. To modify
  33657. * the data, use {@link Highcharts.Series#setData} or
  33658. * {@link Highcharts.Point#update}.
  33659. *
  33660. * @name Highcharts.Series#points
  33661. * @type {Array<Highcharts.Point>}
  33662. */
  33663. series.points = points;
  33664. fireEvent(this, 'afterGeneratePoints');
  33665. };
  33666. /**
  33667. * Get current X extremes for the visible data.
  33668. *
  33669. * @private
  33670. * @function Highcharts.Series#getXExtremes
  33671. *
  33672. * @param {Array<number>} xData
  33673. * The data to inspect. Defaults to the current data within the visible
  33674. * range.
  33675. *
  33676. * @return {Highcharts.RangeObject}
  33677. */
  33678. Series.prototype.getXExtremes = function (xData) {
  33679. return {
  33680. min: arrayMin(xData),
  33681. max: arrayMax(xData)
  33682. };
  33683. };
  33684. /**
  33685. * Calculate Y extremes for the visible data. The result is returned
  33686. * as an object with `dataMin` and `dataMax` properties.
  33687. *
  33688. * @private
  33689. * @function Highcharts.Series#getExtremes
  33690. *
  33691. * @param {Array<number>} [yData]
  33692. * The data to inspect. Defaults to the current data within the visible
  33693. * range.
  33694. * @param {boolean} [forceExtremesFromAll]
  33695. * Force getting extremes of a total series data range.
  33696. *
  33697. * @return {Highcharts.DataExtremesObject}
  33698. */
  33699. Series.prototype.getExtremes = function (yData, forceExtremesFromAll) {
  33700. var xAxis = this.xAxis,
  33701. yAxis = this.yAxis,
  33702. xData = this.processedXData || this.xData,
  33703. yDataLength,
  33704. activeYData = [],
  33705. activeCounter = 0,
  33706. // #2117, need to compensate for log X axis
  33707. xExtremes,
  33708. xMin = 0,
  33709. xMax = 0,
  33710. validValue,
  33711. withinRange,
  33712. // Handle X outside the viewed area. This does not work with
  33713. // non-sorted data like scatter (#7639).
  33714. shoulder = this.requireSorting ? this.cropShoulder : 0,
  33715. positiveValuesOnly = yAxis ? yAxis.positiveValuesOnly : false,
  33716. x,
  33717. y,
  33718. i,
  33719. j;
  33720. yData = yData || this.stackedYData || this.processedYData || [];
  33721. yDataLength = yData.length;
  33722. if (xAxis) {
  33723. xExtremes = xAxis.getExtremes();
  33724. xMin = xExtremes.min;
  33725. xMax = xExtremes.max;
  33726. }
  33727. for (i = 0; i < yDataLength; i++) {
  33728. x = xData[i];
  33729. y = yData[i];
  33730. // For points within the visible range, including the first
  33731. // point outside the visible range (#7061), consider y extremes.
  33732. validValue = ((isNumber(y) || isArray(y)) &&
  33733. ((y.length || y > 0) || !positiveValuesOnly));
  33734. withinRange = (forceExtremesFromAll ||
  33735. this.getExtremesFromAll ||
  33736. this.options.getExtremesFromAll ||
  33737. this.cropped ||
  33738. !xAxis || // for colorAxis support
  33739. ((xData[i + shoulder] || x) >= xMin &&
  33740. (xData[i - shoulder] || x) <= xMax));
  33741. if (validValue && withinRange) {
  33742. j = y.length;
  33743. if (j) { // array, like ohlc or range data
  33744. while (j--) {
  33745. if (isNumber(y[j])) { // #7380, #11513
  33746. activeYData[activeCounter++] = y[j];
  33747. }
  33748. }
  33749. }
  33750. else {
  33751. activeYData[activeCounter++] = y;
  33752. }
  33753. }
  33754. }
  33755. var dataExtremes = {
  33756. dataMin: arrayMin(activeYData),
  33757. dataMax: arrayMax(activeYData)
  33758. };
  33759. fireEvent(this, 'afterGetExtremes', { dataExtremes: dataExtremes });
  33760. return dataExtremes;
  33761. };
  33762. /**
  33763. * Set the current data extremes as `dataMin` and `dataMax` on the
  33764. * Series item. Use this only when the series properties should be
  33765. * updated.
  33766. *
  33767. * @private
  33768. * @function Highcharts.Series#applyExtremes
  33769. */
  33770. Series.prototype.applyExtremes = function () {
  33771. var dataExtremes = this.getExtremes();
  33772. /**
  33773. * Contains the minimum value of the series' data point. Some series
  33774. * types like `networkgraph` do not support this property as they
  33775. * lack a `y`-value.
  33776. * @name Highcharts.Series#dataMin
  33777. * @type {number|undefined}
  33778. * @readonly
  33779. */
  33780. this.dataMin = dataExtremes.dataMin;
  33781. /**
  33782. * Contains the maximum value of the series' data point. Some series
  33783. * types like `networkgraph` do not support this property as they
  33784. * lack a `y`-value.
  33785. * @name Highcharts.Series#dataMax
  33786. * @type {number|undefined}
  33787. * @readonly
  33788. */
  33789. this.dataMax = dataExtremes.dataMax;
  33790. return dataExtremes;
  33791. };
  33792. /**
  33793. * Find and return the first non null point in the data
  33794. *
  33795. * @private
  33796. * @function Highcharts.Series.getFirstValidPoint
  33797. *
  33798. * @param {Array<Highcharts.PointOptionsType>} data
  33799. * Array of options for points
  33800. *
  33801. * @return {Highcharts.PointOptionsType}
  33802. */
  33803. Series.prototype.getFirstValidPoint = function (data) {
  33804. var firstPoint = null,
  33805. dataLength = data.length,
  33806. i = 0;
  33807. while (firstPoint === null && i < dataLength) {
  33808. firstPoint = data[i];
  33809. i++;
  33810. }
  33811. return firstPoint;
  33812. };
  33813. /**
  33814. * Translate data points from raw data values to chart specific
  33815. * positioning data needed later in the `drawPoints` and `drawGraph`
  33816. * functions. This function can be overridden in plugins and custom
  33817. * series type implementations.
  33818. *
  33819. * @function Highcharts.Series#translate
  33820. *
  33821. * @fires Highcharts.Series#events:translate
  33822. */
  33823. Series.prototype.translate = function () {
  33824. if (!this.processedXData) { // hidden series
  33825. this.processData();
  33826. }
  33827. this.generatePoints();
  33828. var series = this,
  33829. options = series.options,
  33830. stacking = options.stacking,
  33831. xAxis = series.xAxis,
  33832. categories = xAxis.categories,
  33833. enabledDataSorting = series.enabledDataSorting,
  33834. yAxis = series.yAxis,
  33835. points = series.points,
  33836. dataLength = points.length,
  33837. hasModifyValue = !!series.modifyValue,
  33838. i,
  33839. pointPlacement = series.pointPlacementToXValue(), // #7860
  33840. dynamicallyPlaced = Boolean(pointPlacement),
  33841. threshold = options.threshold,
  33842. stackThreshold = options.startFromThreshold ? threshold : 0,
  33843. plotX,
  33844. lastPlotX,
  33845. stackIndicator,
  33846. zoneAxis = this.zoneAxis || 'y',
  33847. closestPointRangePx = Number.MAX_VALUE;
  33848. /**
  33849. * Plotted coordinates need to be within a limited range. Drawing
  33850. * too far outside the viewport causes various rendering issues
  33851. * (#3201, #3923, #7555).
  33852. * @private
  33853. */
  33854. function limitedRange(val) {
  33855. return clamp(val, -1e5, 1e5);
  33856. }
  33857. // Translate each point
  33858. for (i = 0; i < dataLength; i++) {
  33859. var point = points[i],
  33860. xValue = point.x,
  33861. yValue = point.y,
  33862. yBottom = point.low,
  33863. stack = stacking && yAxis.stacking && yAxis.stacking.stacks[(series.negStacks &&
  33864. yValue <
  33865. (stackThreshold ? 0 : threshold) ?
  33866. '-' :
  33867. '') + series.stackKey],
  33868. pointStack = void 0,
  33869. stackValues = void 0;
  33870. if (yAxis.positiveValuesOnly && !yAxis.validatePositiveValue(yValue) ||
  33871. xAxis.positiveValuesOnly && !xAxis.validatePositiveValue(xValue)) {
  33872. point.isNull = true;
  33873. }
  33874. // Get the plotX translation
  33875. point.plotX = plotX = correctFloat(// #5236
  33876. limitedRange(xAxis.translate(// #3923
  33877. xValue, 0, 0, 0, 1, pointPlacement, this.type === 'flags')) // #3923
  33878. );
  33879. // Calculate the bottom y value for stacked series
  33880. if (stacking &&
  33881. series.visible &&
  33882. stack &&
  33883. stack[xValue]) {
  33884. stackIndicator = series.getStackIndicator(stackIndicator, xValue, series.index);
  33885. if (!point.isNull) {
  33886. pointStack = stack[xValue];
  33887. stackValues =
  33888. pointStack.points[stackIndicator.key];
  33889. }
  33890. }
  33891. if (isArray(stackValues)) {
  33892. yBottom = stackValues[0];
  33893. yValue = stackValues[1];
  33894. if (yBottom === stackThreshold &&
  33895. stackIndicator.key ===
  33896. stack[xValue].base) {
  33897. yBottom = pick((isNumber(threshold) && threshold), yAxis.min);
  33898. }
  33899. // #1200, #1232
  33900. if (yAxis.positiveValuesOnly && yBottom <= 0) {
  33901. yBottom = null;
  33902. }
  33903. point.total = point.stackTotal = pointStack.total;
  33904. point.percentage =
  33905. pointStack.total &&
  33906. (point.y / pointStack.total * 100);
  33907. point.stackY = yValue;
  33908. // Place the stack label
  33909. // in case of variwide series (where widths of points are
  33910. // different in most cases), stack labels are positioned
  33911. // wrongly, so the call of the setOffset is omited here and
  33912. // labels are correctly positioned later, at the end of the
  33913. // variwide's translate function (#10962)
  33914. if (!series.irregularWidths) {
  33915. pointStack.setOffset(series.pointXOffset || 0, series.barW || 0);
  33916. }
  33917. }
  33918. // Set translated yBottom or remove it
  33919. point.yBottom = defined(yBottom) ?
  33920. limitedRange(yAxis.translate(yBottom, 0, 1, 0, 1)) :
  33921. null;
  33922. // general hook, used for Highcharts Stock compare mode
  33923. if (hasModifyValue) {
  33924. yValue = series.modifyValue(yValue, point);
  33925. }
  33926. // Set the the plotY value, reset it for redraws
  33927. // #3201
  33928. point.plotY = void 0;
  33929. if (isNumber(yValue)) {
  33930. var translated = yAxis.translate(yValue,
  33931. false,
  33932. true,
  33933. false,
  33934. true);
  33935. if (typeof translated !== 'undefined') {
  33936. point.plotY = limitedRange(translated);
  33937. }
  33938. }
  33939. point.isInside = this.isPointInside(point);
  33940. // Set client related positions for mouse tracking
  33941. point.clientX = dynamicallyPlaced ?
  33942. correctFloat(xAxis.translate(xValue, 0, 0, 0, 1, pointPlacement)) :
  33943. plotX; // #1514, #5383, #5518
  33944. // Negative points. For bubble charts, this means negative z
  33945. // values (#9728)
  33946. point.negative = point[zoneAxis] < (options[zoneAxis + 'Threshold'] ||
  33947. threshold ||
  33948. 0);
  33949. // some API data
  33950. point.category = (categories &&
  33951. typeof categories[point.x] !== 'undefined' ?
  33952. categories[point.x] :
  33953. point.x);
  33954. // Determine auto enabling of markers (#3635, #5099)
  33955. if (!point.isNull && point.visible !== false) {
  33956. if (typeof lastPlotX !== 'undefined') {
  33957. closestPointRangePx = Math.min(closestPointRangePx, Math.abs(plotX - lastPlotX));
  33958. }
  33959. lastPlotX = plotX;
  33960. }
  33961. // Find point zone
  33962. point.zone = (this.zones.length && point.getZone());
  33963. // Animate new points with data sorting
  33964. if (!point.graphic && series.group && enabledDataSorting) {
  33965. point.isNew = true;
  33966. }
  33967. }
  33968. series.closestPointRangePx = closestPointRangePx;
  33969. fireEvent(this, 'afterTranslate');
  33970. };
  33971. /**
  33972. * Return the series points with null points filtered out.
  33973. *
  33974. * @function Highcharts.Series#getValidPoints
  33975. *
  33976. * @param {Array<Highcharts.Point>} [points]
  33977. * The points to inspect, defaults to {@link Series.points}.
  33978. *
  33979. * @param {boolean} [insideOnly=false]
  33980. * Whether to inspect only the points that are inside the visible view.
  33981. *
  33982. * @param {boolean} [allowNull=false]
  33983. * Whether to allow null points to pass as valid points.
  33984. *
  33985. * @return {Array<Highcharts.Point>}
  33986. * The valid points.
  33987. */
  33988. Series.prototype.getValidPoints = function (points, insideOnly, allowNull) {
  33989. var chart = this.chart;
  33990. // #3916, #5029, #5085
  33991. return (points || this.points || []).filter(function (point) {
  33992. if (insideOnly && !chart.isInsidePlot(point.plotX, point.plotY, { inverted: chart.inverted })) {
  33993. return false;
  33994. }
  33995. return point.visible !== false &&
  33996. (allowNull || !point.isNull);
  33997. });
  33998. };
  33999. /**
  34000. * Get the clipping for the series. Could be called for a series to
  34001. * initiate animating the clip or to set the final clip (only width
  34002. * and x).
  34003. *
  34004. * @private
  34005. * @function Highcharts.Series#getClip
  34006. *
  34007. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  34008. * Initialize the animation.
  34009. *
  34010. * @param {boolean} [finalBox]
  34011. * Final size for the clip - end state for the animation.
  34012. *
  34013. * @return {Highcharts.Dictionary<number>}
  34014. */
  34015. Series.prototype.getClipBox = function (animation, finalBox) {
  34016. var series = this,
  34017. options = series.options,
  34018. chart = series.chart,
  34019. inverted = chart.inverted,
  34020. xAxis = series.xAxis,
  34021. yAxis = xAxis && series.yAxis,
  34022. clipBox,
  34023. scrollablePlotAreaOptions = chart.options.chart.scrollablePlotArea || {};
  34024. if (animation && options.clip === false && yAxis) {
  34025. // support for not clipped series animation (#10450)
  34026. clipBox = inverted ? {
  34027. y: -chart.chartWidth + yAxis.len + yAxis.pos,
  34028. height: chart.chartWidth,
  34029. width: chart.chartHeight,
  34030. x: -chart.chartHeight + xAxis.len + xAxis.pos
  34031. } : {
  34032. y: -yAxis.pos,
  34033. height: chart.chartHeight,
  34034. width: chart.chartWidth,
  34035. x: -xAxis.pos
  34036. };
  34037. // x and width will be changed later when setting for animation
  34038. // initial state in Series.setClip
  34039. }
  34040. else {
  34041. clipBox = series.clipBox || chart.clipBox;
  34042. if (finalBox) {
  34043. clipBox.width = chart.plotSizeX;
  34044. clipBox.x = (chart.scrollablePixelsX || 0) *
  34045. (scrollablePlotAreaOptions.scrollPositionX || 0);
  34046. }
  34047. }
  34048. return !finalBox ? clipBox : {
  34049. width: clipBox.width,
  34050. x: clipBox.x
  34051. };
  34052. };
  34053. /**
  34054. * Get the shared clip key, creating it if it doesn't exist.
  34055. *
  34056. * @private
  34057. * @function Highcharts.Series#getSharedClipKey
  34058. */
  34059. Series.prototype.getSharedClipKey = function (animation) {
  34060. if (this.sharedClipKey) {
  34061. return this.sharedClipKey;
  34062. }
  34063. var sharedClipKey = [
  34064. animation && animation.duration,
  34065. animation && animation.easing,
  34066. animation && animation.defer,
  34067. this.getClipBox(animation).height,
  34068. this.options.xAxis,
  34069. this.options.yAxis
  34070. ].join(',');
  34071. if (this.options.clip !== false || animation) {
  34072. this.sharedClipKey = sharedClipKey;
  34073. }
  34074. return sharedClipKey;
  34075. };
  34076. /**
  34077. * Set the clipping for the series. For animated series it is called
  34078. * twice, first to initiate animating the clip then the second time
  34079. * without the animation to set the final clip.
  34080. *
  34081. * @private
  34082. * @function Highcharts.Series#setClip
  34083. */
  34084. Series.prototype.setClip = function (animation) {
  34085. var chart = this.chart,
  34086. options = this.options,
  34087. renderer = chart.renderer,
  34088. inverted = chart.inverted,
  34089. seriesClipBox = this.clipBox,
  34090. clipBox = this.getClipBox(animation),
  34091. sharedClipKey = this.getSharedClipKey(animation), // #4526
  34092. clipRect = chart.sharedClips[sharedClipKey],
  34093. markerClipRect = chart.sharedClips[sharedClipKey + 'm'];
  34094. if (animation) {
  34095. clipBox.width = 0;
  34096. if (inverted) {
  34097. clipBox.x = chart.plotHeight +
  34098. (options.clip !== false ? 0 : chart.plotTop);
  34099. }
  34100. }
  34101. // If a clipping rectangle with the same properties is currently
  34102. // present in the chart, use that.
  34103. if (!clipRect) {
  34104. // When animation is set, prepare the initial positions
  34105. if (animation) {
  34106. chart.sharedClips[sharedClipKey + 'm'] = markerClipRect =
  34107. renderer.clipRect(
  34108. // include the width of the first marker
  34109. inverted ? (chart.plotSizeX || 0) + 99 : -99, inverted ? -chart.plotLeft : -chart.plotTop, 99, inverted ? chart.chartWidth : chart.chartHeight);
  34110. }
  34111. chart.sharedClips[sharedClipKey] = clipRect = renderer.clipRect(clipBox);
  34112. // Create hashmap for series indexes
  34113. clipRect.count = { length: 0 };
  34114. // When the series is rendered again before starting animating, in
  34115. // compliance to a responsive rule
  34116. }
  34117. else if (!chart.hasLoaded) {
  34118. clipRect.attr(clipBox);
  34119. }
  34120. if (animation) {
  34121. if (!clipRect.count[this.index]) {
  34122. clipRect.count[this.index] = true;
  34123. clipRect.count.length += 1;
  34124. }
  34125. }
  34126. if (options.clip !== false || animation) {
  34127. this.group.clip(animation || seriesClipBox ? clipRect : chart.clipRect);
  34128. this.markerGroup.clip(markerClipRect);
  34129. }
  34130. // Remove the shared clipping rectangle when all series are shown
  34131. if (!animation) {
  34132. if (clipRect.count[this.index]) {
  34133. delete clipRect.count[this.index];
  34134. clipRect.count.length -= 1;
  34135. }
  34136. if (clipRect.count.length === 0) {
  34137. if (!seriesClipBox) {
  34138. chart.sharedClips[sharedClipKey] = clipRect.destroy();
  34139. }
  34140. if (markerClipRect) {
  34141. chart.sharedClips[sharedClipKey + 'm'] = markerClipRect.destroy();
  34142. }
  34143. }
  34144. }
  34145. };
  34146. /**
  34147. * Animate in the series. Called internally twice. First with the `init`
  34148. * parameter set to true, which sets up the initial state of the
  34149. * animation. Then when ready, it is called with the `init` parameter
  34150. * undefined, in order to perform the actual animation. After the
  34151. * second run, the function is removed.
  34152. *
  34153. * @function Highcharts.Series#animate
  34154. *
  34155. * @param {boolean} [init]
  34156. * Initialize the animation.
  34157. */
  34158. Series.prototype.animate = function (init) {
  34159. var series = this,
  34160. chart = series.chart,
  34161. animation = animObject(series.options.animation),
  34162. sharedClipKey = this.sharedClipKey;
  34163. // Initialize the animation. Set up the clipping rectangle.
  34164. if (init) {
  34165. series.setClip(animation);
  34166. // Run the animation
  34167. }
  34168. else if (sharedClipKey) {
  34169. var clipRect = chart.sharedClips[sharedClipKey];
  34170. var markerClipRect = chart.sharedClips[sharedClipKey + 'm'];
  34171. var finalBox = series.getClipBox(animation,
  34172. true);
  34173. if (clipRect) {
  34174. clipRect.animate(finalBox, animation);
  34175. }
  34176. if (markerClipRect) {
  34177. markerClipRect.animate({
  34178. width: finalBox.width + 99,
  34179. x: finalBox.x - (chart.inverted ? 0 : 99)
  34180. }, animation);
  34181. }
  34182. }
  34183. };
  34184. /**
  34185. * This runs after animation to land on the final plot clipping.
  34186. *
  34187. * @private
  34188. * @function Highcharts.Series#afterAnimate
  34189. *
  34190. * @fires Highcharts.Series#event:afterAnimate
  34191. */
  34192. Series.prototype.afterAnimate = function () {
  34193. this.setClip();
  34194. fireEvent(this, 'afterAnimate');
  34195. this.finishedAnimating = true;
  34196. };
  34197. /**
  34198. * Draw the markers for line-like series types, and columns or other
  34199. * graphical representation for {@link Point} objects for other series
  34200. * types. The resulting element is typically stored as
  34201. * {@link Point.graphic}, and is created on the first call and updated
  34202. * and moved on subsequent calls.
  34203. *
  34204. * @function Highcharts.Series#drawPoints
  34205. */
  34206. Series.prototype.drawPoints = function () {
  34207. var series = this,
  34208. points = series.points,
  34209. chart = series.chart,
  34210. i,
  34211. point,
  34212. graphic,
  34213. verb,
  34214. options = series.options,
  34215. seriesMarkerOptions = options.marker,
  34216. pointMarkerOptions,
  34217. hasPointMarker,
  34218. markerGroup = (series[series.specialGroup] ||
  34219. series.markerGroup),
  34220. xAxis = series.xAxis,
  34221. markerAttribs,
  34222. globallyEnabled = pick(seriesMarkerOptions.enabled, !xAxis || xAxis.isRadial ? true : null,
  34223. // Use larger or equal as radius is null in bubbles (#6321)
  34224. series.closestPointRangePx >= (seriesMarkerOptions.enabledThreshold *
  34225. seriesMarkerOptions.radius));
  34226. if (seriesMarkerOptions.enabled !== false ||
  34227. series._hasPointMarkers) {
  34228. for (i = 0; i < points.length; i++) {
  34229. point = points[i];
  34230. graphic = point.graphic;
  34231. verb = graphic ? 'animate' : 'attr';
  34232. pointMarkerOptions = point.marker || {};
  34233. hasPointMarker = !!point.marker;
  34234. var shouldDrawMarker = ((globallyEnabled &&
  34235. typeof pointMarkerOptions.enabled === 'undefined') || pointMarkerOptions.enabled) && !point.isNull && point.visible !== false;
  34236. // only draw the point if y is defined
  34237. if (shouldDrawMarker) {
  34238. // Shortcuts
  34239. var symbol = pick(pointMarkerOptions.symbol,
  34240. series.symbol);
  34241. markerAttribs = series.markerAttribs(point, (point.selected && 'select'));
  34242. // Set starting position for point sliding animation.
  34243. if (series.enabledDataSorting) {
  34244. point.startXPos = xAxis.reversed ?
  34245. -(markerAttribs.width || 0) :
  34246. xAxis.width;
  34247. }
  34248. var isInside = point.isInside !== false;
  34249. if (graphic) { // update
  34250. // Since the marker group isn't clipped, each
  34251. // individual marker must be toggled
  34252. graphic[isInside ? 'show' : 'hide'](isInside)
  34253. .animate(markerAttribs);
  34254. }
  34255. else if (isInside &&
  34256. ((markerAttribs.width || 0) > 0 || point.hasImage)) {
  34257. /**
  34258. * The graphic representation of the point.
  34259. * Typically this is a simple shape, like a `rect`
  34260. * for column charts or `path` for line markers, but
  34261. * for some complex series types like boxplot or 3D
  34262. * charts, the graphic may be a `g` element
  34263. * containing other shapes. The graphic is generated
  34264. * the first time {@link Series#drawPoints} runs,
  34265. * and updated and moved on subsequent runs.
  34266. *
  34267. * @name Point#graphic
  34268. * @type {SVGElement}
  34269. */
  34270. point.graphic = graphic = chart.renderer
  34271. .symbol(symbol, markerAttribs.x, markerAttribs.y, markerAttribs.width, markerAttribs.height, hasPointMarker ?
  34272. pointMarkerOptions :
  34273. seriesMarkerOptions)
  34274. .add(markerGroup);
  34275. // Sliding animation for new points
  34276. if (series.enabledDataSorting &&
  34277. chart.hasRendered) {
  34278. graphic.attr({
  34279. x: point.startXPos
  34280. });
  34281. verb = 'animate';
  34282. }
  34283. }
  34284. if (graphic && verb === 'animate') { // update
  34285. // Since the marker group isn't clipped, each
  34286. // individual marker must be toggled
  34287. graphic[isInside ? 'show' : 'hide'](isInside)
  34288. .animate(markerAttribs);
  34289. }
  34290. // Presentational attributes
  34291. if (graphic && !chart.styledMode) {
  34292. graphic[verb](series.pointAttribs(point, (point.selected && 'select')));
  34293. }
  34294. if (graphic) {
  34295. graphic.addClass(point.getClassName(), true);
  34296. }
  34297. }
  34298. else if (graphic) {
  34299. point.graphic = graphic.destroy(); // #1269
  34300. }
  34301. }
  34302. }
  34303. };
  34304. /**
  34305. * Get non-presentational attributes for a point. Used internally for
  34306. * both styled mode and classic. Can be overridden for different series
  34307. * types.
  34308. *
  34309. * @see Series#pointAttribs
  34310. *
  34311. * @function Highcharts.Series#markerAttribs
  34312. *
  34313. * @param {Highcharts.Point} point
  34314. * The Point to inspect.
  34315. *
  34316. * @param {string} [state]
  34317. * The state, can be either `hover`, `select` or undefined.
  34318. *
  34319. * @return {Highcharts.SVGAttributes}
  34320. * A hash containing those attributes that are not settable from CSS.
  34321. */
  34322. Series.prototype.markerAttribs = function (point, state) {
  34323. var seriesOptions = this.options,
  34324. seriesMarkerOptions = seriesOptions.marker,
  34325. seriesStateOptions,
  34326. pointMarkerOptions = point.marker || {},
  34327. symbol = (pointMarkerOptions.symbol ||
  34328. seriesMarkerOptions.symbol),
  34329. pointStateOptions,
  34330. radius = pick(pointMarkerOptions.radius,
  34331. seriesMarkerOptions.radius),
  34332. attribs;
  34333. // Handle hover and select states
  34334. if (state) {
  34335. seriesStateOptions = seriesMarkerOptions.states[state];
  34336. pointStateOptions = pointMarkerOptions.states &&
  34337. pointMarkerOptions.states[state];
  34338. radius = pick(pointStateOptions && pointStateOptions.radius, seriesStateOptions && seriesStateOptions.radius, radius + (seriesStateOptions && seriesStateOptions.radiusPlus ||
  34339. 0));
  34340. }
  34341. point.hasImage = symbol && symbol.indexOf('url') === 0;
  34342. if (point.hasImage) {
  34343. radius = 0; // and subsequently width and height is not set
  34344. }
  34345. attribs = {
  34346. // Math.floor for #1843:
  34347. x: seriesOptions.crisp ?
  34348. Math.floor(point.plotX - radius) :
  34349. point.plotX - radius,
  34350. y: point.plotY - radius
  34351. };
  34352. if (radius) {
  34353. attribs.width = attribs.height = 2 * radius;
  34354. }
  34355. return attribs;
  34356. };
  34357. /**
  34358. * Internal function to get presentational attributes for each point.
  34359. * Unlike {@link Series#markerAttribs}, this function should return
  34360. * those attributes that can also be set in CSS. In styled mode,
  34361. * `pointAttribs` won't be called.
  34362. *
  34363. * @private
  34364. * @function Highcharts.Series#pointAttribs
  34365. *
  34366. * @param {Highcharts.Point} [point]
  34367. * The point instance to inspect.
  34368. *
  34369. * @param {string} [state]
  34370. * The point state, can be either `hover`, `select` or 'normal'. If
  34371. * undefined, normal state is assumed.
  34372. *
  34373. * @return {Highcharts.SVGAttributes}
  34374. * The presentational attributes to be set on the point.
  34375. */
  34376. Series.prototype.pointAttribs = function (point, state) {
  34377. var seriesMarkerOptions = this.options.marker,
  34378. seriesStateOptions,
  34379. pointOptions = point && point.options,
  34380. pointMarkerOptions = ((pointOptions && pointOptions.marker) || {}),
  34381. pointStateOptions,
  34382. color = this.color,
  34383. pointColorOption = pointOptions && pointOptions.color,
  34384. pointColor = point && point.color,
  34385. strokeWidth = pick(pointMarkerOptions.lineWidth,
  34386. seriesMarkerOptions.lineWidth),
  34387. zoneColor = point && point.zone && point.zone.color,
  34388. fill,
  34389. stroke,
  34390. opacity = 1;
  34391. color = (pointColorOption ||
  34392. zoneColor ||
  34393. pointColor ||
  34394. color);
  34395. fill = (pointMarkerOptions.fillColor ||
  34396. seriesMarkerOptions.fillColor ||
  34397. color);
  34398. stroke = (pointMarkerOptions.lineColor ||
  34399. seriesMarkerOptions.lineColor ||
  34400. color);
  34401. // Handle hover and select states
  34402. state = state || 'normal';
  34403. if (state) {
  34404. seriesStateOptions = seriesMarkerOptions.states[state];
  34405. pointStateOptions = (pointMarkerOptions.states &&
  34406. pointMarkerOptions.states[state]) || {};
  34407. strokeWidth = pick(pointStateOptions.lineWidth, seriesStateOptions.lineWidth, strokeWidth + pick(pointStateOptions.lineWidthPlus, seriesStateOptions.lineWidthPlus, 0));
  34408. fill = (pointStateOptions.fillColor ||
  34409. seriesStateOptions.fillColor ||
  34410. fill);
  34411. stroke = (pointStateOptions.lineColor ||
  34412. seriesStateOptions.lineColor ||
  34413. stroke);
  34414. opacity = pick(pointStateOptions.opacity, seriesStateOptions.opacity, opacity);
  34415. }
  34416. return {
  34417. 'stroke': stroke,
  34418. 'stroke-width': strokeWidth,
  34419. 'fill': fill,
  34420. 'opacity': opacity
  34421. };
  34422. };
  34423. /**
  34424. * Clear DOM objects and free up memory.
  34425. *
  34426. * @private
  34427. * @function Highcharts.Series#destroy
  34428. *
  34429. * @fires Highcharts.Series#event:destroy
  34430. */
  34431. Series.prototype.destroy = function (keepEventsForUpdate) {
  34432. var series = this,
  34433. chart = series.chart,
  34434. issue134 = /AppleWebKit\/533/.test(win.navigator.userAgent),
  34435. destroy,
  34436. i,
  34437. data = series.data || [],
  34438. point,
  34439. axis;
  34440. // add event hook
  34441. fireEvent(series, 'destroy');
  34442. // remove events
  34443. this.removeEvents(keepEventsForUpdate);
  34444. // erase from axes
  34445. (series.axisTypes || []).forEach(function (AXIS) {
  34446. axis = series[AXIS];
  34447. if (axis && axis.series) {
  34448. erase(axis.series, series);
  34449. axis.isDirty = axis.forceRedraw = true;
  34450. }
  34451. });
  34452. // remove legend items
  34453. if (series.legendItem) {
  34454. series.chart.legend.destroyItem(series);
  34455. }
  34456. // destroy all points with their elements
  34457. i = data.length;
  34458. while (i--) {
  34459. point = data[i];
  34460. if (point && point.destroy) {
  34461. point.destroy();
  34462. }
  34463. }
  34464. if (series.clips) {
  34465. series.clips.forEach(function (clip) { return clip.destroy(); });
  34466. }
  34467. // Clear the animation timeout if we are destroying the series
  34468. // during initial animation
  34469. U.clearTimeout(series.animationTimeout);
  34470. // Destroy all SVGElements associated to the series
  34471. objectEach(series, function (val, prop) {
  34472. // Survive provides a hook for not destroying
  34473. if (val instanceof SVGElement && !val.survive) {
  34474. // issue 134 workaround
  34475. destroy = issue134 && prop === 'group' ?
  34476. 'hide' :
  34477. 'destroy';
  34478. val[destroy]();
  34479. }
  34480. });
  34481. // remove from hoverSeries
  34482. if (chart.hoverSeries === series) {
  34483. chart.hoverSeries = void 0;
  34484. }
  34485. erase(chart.series, series);
  34486. chart.orderSeries();
  34487. // clear all members
  34488. objectEach(series, function (val, prop) {
  34489. if (!keepEventsForUpdate || prop !== 'hcEvents') {
  34490. delete series[prop];
  34491. }
  34492. });
  34493. };
  34494. /**
  34495. * Clip the graphs into zones for colors and styling.
  34496. *
  34497. * @private
  34498. * @function Highcharts.Series#applyZones
  34499. */
  34500. Series.prototype.applyZones = function () {
  34501. var series = this,
  34502. chart = this.chart,
  34503. renderer = chart.renderer,
  34504. zones = this.zones,
  34505. translatedFrom,
  34506. translatedTo,
  34507. clips = (this.clips || []),
  34508. clipAttr,
  34509. graph = this.graph,
  34510. area = this.area,
  34511. chartSizeMax = Math.max(chart.chartWidth,
  34512. chart.chartHeight),
  34513. axis = this[(this.zoneAxis || 'y') + 'Axis'],
  34514. extremes,
  34515. reversed,
  34516. inverted = chart.inverted,
  34517. horiz,
  34518. pxRange,
  34519. pxPosMin,
  34520. pxPosMax,
  34521. ignoreZones = false,
  34522. zoneArea,
  34523. zoneGraph;
  34524. if (zones.length &&
  34525. (graph || area) &&
  34526. axis &&
  34527. typeof axis.min !== 'undefined') {
  34528. reversed = axis.reversed;
  34529. horiz = axis.horiz;
  34530. // The use of the Color Threshold assumes there are no gaps
  34531. // so it is safe to hide the original graph and area
  34532. // unless it is not waterfall series, then use showLine property
  34533. // to set lines between columns to be visible (#7862)
  34534. if (graph && !this.showLine) {
  34535. graph.hide();
  34536. }
  34537. if (area) {
  34538. area.hide();
  34539. }
  34540. // Create the clips
  34541. extremes = axis.getExtremes();
  34542. zones.forEach(function (threshold, i) {
  34543. translatedFrom = reversed ?
  34544. (horiz ? chart.plotWidth : 0) :
  34545. (horiz ? 0 : (axis.toPixels(extremes.min) || 0));
  34546. translatedFrom = clamp(pick(translatedTo, translatedFrom), 0, chartSizeMax);
  34547. translatedTo = clamp(Math.round(axis.toPixels(pick(threshold.value, extremes.max), true) || 0), 0, chartSizeMax);
  34548. if (ignoreZones) {
  34549. translatedFrom = translatedTo =
  34550. axis.toPixels(extremes.max);
  34551. }
  34552. pxRange = Math.abs(translatedFrom - translatedTo);
  34553. pxPosMin = Math.min(translatedFrom, translatedTo);
  34554. pxPosMax = Math.max(translatedFrom, translatedTo);
  34555. if (axis.isXAxis) {
  34556. clipAttr = {
  34557. x: inverted ? pxPosMax : pxPosMin,
  34558. y: 0,
  34559. width: pxRange,
  34560. height: chartSizeMax
  34561. };
  34562. if (!horiz) {
  34563. clipAttr.x = chart.plotHeight - clipAttr.x;
  34564. }
  34565. }
  34566. else {
  34567. clipAttr = {
  34568. x: 0,
  34569. y: inverted ? pxPosMax : pxPosMin,
  34570. width: chartSizeMax,
  34571. height: pxRange
  34572. };
  34573. if (horiz) {
  34574. clipAttr.y = chart.plotWidth - clipAttr.y;
  34575. }
  34576. }
  34577. // VML SUPPPORT
  34578. if (inverted && renderer.isVML) {
  34579. if (axis.isXAxis) {
  34580. clipAttr = {
  34581. x: 0,
  34582. y: reversed ? pxPosMin : pxPosMax,
  34583. height: clipAttr.width,
  34584. width: chart.chartWidth
  34585. };
  34586. }
  34587. else {
  34588. clipAttr = {
  34589. x: (clipAttr.y -
  34590. chart.plotLeft -
  34591. chart.spacingBox.x),
  34592. y: 0,
  34593. width: clipAttr.height,
  34594. height: chart.chartHeight
  34595. };
  34596. }
  34597. }
  34598. // END OF VML SUPPORT
  34599. if (clips[i]) {
  34600. clips[i].animate(clipAttr);
  34601. }
  34602. else {
  34603. clips[i] = renderer.clipRect(clipAttr);
  34604. }
  34605. // when no data, graph zone is not applied and after setData
  34606. // clip was ignored. As a result, it should be applied each
  34607. // time.
  34608. zoneArea = series['zone-area-' + i];
  34609. zoneGraph = series['zone-graph-' + i];
  34610. if (graph && zoneGraph) {
  34611. zoneGraph.clip(clips[i]);
  34612. }
  34613. if (area && zoneArea) {
  34614. zoneArea.clip(clips[i]);
  34615. }
  34616. // if this zone extends out of the axis, ignore the others
  34617. ignoreZones = threshold.value > extremes.max;
  34618. // Clear translatedTo for indicators
  34619. if (series.resetZones && translatedTo === 0) {
  34620. translatedTo = void 0;
  34621. }
  34622. });
  34623. this.clips = clips;
  34624. }
  34625. else if (series.visible) {
  34626. // If zones were removed, restore graph and area
  34627. if (graph) {
  34628. graph.show(true);
  34629. }
  34630. if (area) {
  34631. area.show(true);
  34632. }
  34633. }
  34634. };
  34635. /**
  34636. * Initialize and perform group inversion on series.group and
  34637. * series.markerGroup.
  34638. *
  34639. * @private
  34640. * @function Highcharts.Series#invertGroups
  34641. */
  34642. Series.prototype.invertGroups = function (inverted) {
  34643. var series = this,
  34644. chart = series.chart;
  34645. /**
  34646. * @private
  34647. */
  34648. function setInvert() {
  34649. ['group', 'markerGroup'].forEach(function (groupName) {
  34650. if (series[groupName]) {
  34651. // VML/HTML needs explicit attributes for flipping
  34652. if (chart.renderer.isVML) {
  34653. series[groupName].attr({
  34654. width: series.yAxis.len,
  34655. height: series.xAxis.len
  34656. });
  34657. }
  34658. series[groupName].width = series.yAxis.len;
  34659. series[groupName].height = series.xAxis.len;
  34660. // If inverted polar, don't invert series group
  34661. series[groupName].invert(series.isRadialSeries ? false : inverted);
  34662. }
  34663. });
  34664. }
  34665. // Pie, go away (#1736)
  34666. if (!series.xAxis) {
  34667. return;
  34668. }
  34669. // A fixed size is needed for inversion to work
  34670. series.eventsToUnbind.push(addEvent(chart, 'resize', setInvert));
  34671. // Do it now
  34672. setInvert();
  34673. // On subsequent render and redraw, just do setInvert without
  34674. // setting up events again
  34675. series.invertGroups = setInvert;
  34676. };
  34677. /**
  34678. * General abstraction for creating plot groups like series.group,
  34679. * series.dataLabelsGroup and series.markerGroup. On subsequent calls,
  34680. * the group will only be adjusted to the updated plot size.
  34681. *
  34682. * @private
  34683. * @function Highcharts.Series#plotGroup
  34684. */
  34685. Series.prototype.plotGroup = function (prop, name, visibility, zIndex, parent) {
  34686. var group = this[prop],
  34687. isNew = !group,
  34688. attrs = {
  34689. visibility: visibility,
  34690. zIndex: zIndex || 0.1 // IE8 and pointer logic use this
  34691. };
  34692. // Avoid setting undefined opacity, or in styled mode
  34693. if (typeof this.opacity !== 'undefined' &&
  34694. !this.chart.styledMode && this.state !== 'inactive' // #13719
  34695. ) {
  34696. attrs.opacity = this.opacity;
  34697. }
  34698. // Generate it on first call
  34699. if (isNew) {
  34700. this[prop] = group = this.chart.renderer
  34701. .g()
  34702. .add(parent);
  34703. }
  34704. // Add the class names, and replace existing ones as response to
  34705. // Series.update (#6660)
  34706. group.addClass(('highcharts-' + name +
  34707. ' highcharts-series-' + this.index +
  34708. ' highcharts-' + this.type + '-series ' +
  34709. (defined(this.colorIndex) ?
  34710. 'highcharts-color-' + this.colorIndex + ' ' :
  34711. '') +
  34712. (this.options.className || '') +
  34713. (group.hasClass('highcharts-tracker') ?
  34714. ' highcharts-tracker' :
  34715. '')), true);
  34716. // Place it on first and subsequent (redraw) calls
  34717. group.attr(attrs)[isNew ? 'attr' : 'animate'](this.getPlotBox());
  34718. return group;
  34719. };
  34720. /**
  34721. * Get the translation and scale for the plot area of this series.
  34722. *
  34723. * @function Highcharts.Series#getPlotBox
  34724. *
  34725. * @return {Highcharts.SeriesPlotBoxObject}
  34726. */
  34727. Series.prototype.getPlotBox = function () {
  34728. var chart = this.chart,
  34729. xAxis = this.xAxis,
  34730. yAxis = this.yAxis;
  34731. // Swap axes for inverted (#2339)
  34732. if (chart.inverted) {
  34733. xAxis = yAxis;
  34734. yAxis = this.xAxis;
  34735. }
  34736. return {
  34737. translateX: xAxis ? xAxis.left : chart.plotLeft,
  34738. translateY: yAxis ? yAxis.top : chart.plotTop,
  34739. scaleX: 1,
  34740. scaleY: 1
  34741. };
  34742. };
  34743. /**
  34744. * Removes the event handlers attached previously with addEvents.
  34745. * @private
  34746. * @function Highcharts.Series#removeEvents
  34747. */
  34748. Series.prototype.removeEvents = function (keepEventsForUpdate) {
  34749. var series = this;
  34750. if (!keepEventsForUpdate) {
  34751. // remove all events
  34752. removeEvent(series);
  34753. }
  34754. if (series.eventsToUnbind.length) {
  34755. // remove only internal events for proper update
  34756. // #12355 - solves problem with multiple destroy events
  34757. series.eventsToUnbind.forEach(function (unbind) {
  34758. unbind();
  34759. });
  34760. series.eventsToUnbind.length = 0;
  34761. }
  34762. };
  34763. /**
  34764. * Render the graph and markers. Called internally when first rendering
  34765. * and later when redrawing the chart. This function can be extended in
  34766. * plugins, but normally shouldn't be called directly.
  34767. *
  34768. * @function Highcharts.Series#render
  34769. *
  34770. * @fires Highcharts.Series#event:afterRender
  34771. */
  34772. Series.prototype.render = function () {
  34773. var series = this,
  34774. chart = series.chart,
  34775. group,
  34776. options = series.options,
  34777. animOptions = animObject(options.animation),
  34778. // Animation doesn't work in IE8 quirks when the group div is
  34779. // hidden, and looks bad in other oldIE
  34780. animDuration = (!series.finishedAnimating &&
  34781. chart.renderer.isSVG &&
  34782. animOptions.duration),
  34783. visibility = series.visible ?
  34784. 'inherit' : 'hidden', // #2597
  34785. zIndex = options.zIndex,
  34786. hasRendered = series.hasRendered,
  34787. chartSeriesGroup = chart.seriesGroup,
  34788. inverted = chart.inverted;
  34789. fireEvent(this, 'render');
  34790. // the group
  34791. group = series.plotGroup('group', 'series', visibility, zIndex, chartSeriesGroup);
  34792. series.markerGroup = series.plotGroup('markerGroup', 'markers', visibility, zIndex, chartSeriesGroup);
  34793. // initiate the animation
  34794. if (animDuration && series.animate) {
  34795. series.animate(true);
  34796. }
  34797. // SVGRenderer needs to know this before drawing elements (#1089,
  34798. // #1795)
  34799. group.inverted = pick(series.invertible, series.isCartesian) ?
  34800. inverted : false;
  34801. // Draw the graph if any
  34802. if (series.drawGraph) {
  34803. series.drawGraph();
  34804. series.applyZones();
  34805. }
  34806. // Draw the points
  34807. if (series.visible) {
  34808. series.drawPoints();
  34809. }
  34810. /* series.points.forEach(function (point) {
  34811. if (point.redraw) {
  34812. point.redraw();
  34813. }
  34814. }); */
  34815. // Draw the data labels
  34816. if (series.drawDataLabels) {
  34817. series.drawDataLabels();
  34818. }
  34819. // In pie charts, slices are added to the DOM, but actual rendering
  34820. // is postponed until labels reserved their space
  34821. if (series.redrawPoints) {
  34822. series.redrawPoints();
  34823. }
  34824. // draw the mouse tracking area
  34825. if (series.drawTracker &&
  34826. series.options.enableMouseTracking !== false) {
  34827. series.drawTracker();
  34828. }
  34829. // Handle inverted series and tracker groups
  34830. series.invertGroups(inverted);
  34831. // Initial clipping, must be defined after inverting groups for VML.
  34832. // Applies to columns etc. (#3839).
  34833. if (options.clip !== false &&
  34834. !series.sharedClipKey &&
  34835. !hasRendered) {
  34836. group.clip(chart.clipRect);
  34837. }
  34838. // Run the animation
  34839. if (animDuration && series.animate) {
  34840. series.animate();
  34841. }
  34842. // Call the afterAnimate function on animation complete (but don't
  34843. // overwrite the animation.complete option which should be available
  34844. // to the user).
  34845. if (!hasRendered) {
  34846. // Additional time if defer is defined before afterAnimate
  34847. // will be triggered
  34848. if (animDuration && animOptions.defer) {
  34849. animDuration += animOptions.defer;
  34850. }
  34851. series.animationTimeout = syncTimeout(function () {
  34852. series.afterAnimate();
  34853. }, animDuration || 0);
  34854. }
  34855. // Means data is in accordance with what you see
  34856. series.isDirty = false;
  34857. // (See #322) series.isDirty = series.isDirtyData = false; // means
  34858. // data is in accordance with what you see
  34859. series.hasRendered = true;
  34860. fireEvent(series, 'afterRender');
  34861. };
  34862. /**
  34863. * Redraw the series. This function is called internally from
  34864. * `chart.redraw` and normally shouldn't be called directly.
  34865. * @private
  34866. * @function Highcharts.Series#redraw
  34867. */
  34868. Series.prototype.redraw = function () {
  34869. var series = this,
  34870. chart = series.chart,
  34871. // cache it here as it is set to false in render, but used after
  34872. wasDirty = series.isDirty || series.isDirtyData,
  34873. group = series.group,
  34874. xAxis = series.xAxis,
  34875. yAxis = series.yAxis;
  34876. // reposition on resize
  34877. if (group) {
  34878. if (chart.inverted) {
  34879. group.attr({
  34880. width: chart.plotWidth,
  34881. height: chart.plotHeight
  34882. });
  34883. }
  34884. group.animate({
  34885. translateX: pick(xAxis && xAxis.left, chart.plotLeft),
  34886. translateY: pick(yAxis && yAxis.top, chart.plotTop)
  34887. });
  34888. }
  34889. series.translate();
  34890. series.render();
  34891. if (wasDirty) { // #3868, #3945
  34892. delete this.kdTree;
  34893. }
  34894. };
  34895. /**
  34896. * @private
  34897. * @function Highcharts.Series#searchPoint
  34898. */
  34899. Series.prototype.searchPoint = function (e, compareX) {
  34900. var series = this,
  34901. xAxis = series.xAxis,
  34902. yAxis = series.yAxis,
  34903. inverted = series.chart.inverted;
  34904. return this.searchKDTree({
  34905. clientX: inverted ?
  34906. xAxis.len - e.chartY + xAxis.pos :
  34907. e.chartX - xAxis.pos,
  34908. plotY: inverted ?
  34909. yAxis.len - e.chartX + yAxis.pos :
  34910. e.chartY - yAxis.pos
  34911. }, compareX, e);
  34912. };
  34913. /**
  34914. * Build the k-d-tree that is used by mouse and touch interaction to get
  34915. * the closest point. Line-like series typically have a one-dimensional
  34916. * tree where points are searched along the X axis, while scatter-like
  34917. * series typically search in two dimensions, X and Y.
  34918. *
  34919. * @private
  34920. * @function Highcharts.Series#buildKDTree
  34921. */
  34922. Series.prototype.buildKDTree = function (e) {
  34923. // Prevent multiple k-d-trees from being built simultaneously
  34924. // (#6235)
  34925. this.buildingKdTree = true;
  34926. var series = this,
  34927. dimensions = series.options.findNearestPointBy
  34928. .indexOf('y') > -1 ? 2 : 1;
  34929. /**
  34930. * Internal function
  34931. * @private
  34932. */
  34933. function _kdtree(points, depth, dimensions) {
  34934. var axis,
  34935. median,
  34936. length = points && points.length;
  34937. if (length) {
  34938. // alternate between the axis
  34939. axis = series.kdAxisArray[depth % dimensions];
  34940. // sort point array
  34941. points.sort(function (a, b) {
  34942. return a[axis] - b[axis];
  34943. });
  34944. median = Math.floor(length / 2);
  34945. // build and return nod
  34946. return {
  34947. point: points[median],
  34948. left: _kdtree(points.slice(0, median), depth + 1, dimensions),
  34949. right: _kdtree(points.slice(median + 1), depth + 1, dimensions)
  34950. };
  34951. }
  34952. }
  34953. /**
  34954. * Start the recursive build process with a clone of the points
  34955. * array and null points filtered out. (#3873)
  34956. * @private
  34957. */
  34958. function startRecursive() {
  34959. series.kdTree = _kdtree(series.getValidPoints(null,
  34960. // For line-type series restrict to plot area, but
  34961. // column-type series not (#3916, #4511)
  34962. !series.directTouch), dimensions, dimensions);
  34963. series.buildingKdTree = false;
  34964. }
  34965. delete series.kdTree;
  34966. // For testing tooltips, don't build async. Also if touchstart, we
  34967. // may be dealing with click events on mobile, so don't delay
  34968. // (#6817).
  34969. syncTimeout(startRecursive, series.options.kdNow || (e && e.type === 'touchstart') ? 0 : 1);
  34970. };
  34971. /**
  34972. * @private
  34973. * @function Highcharts.Series#searchKDTree
  34974. */
  34975. Series.prototype.searchKDTree = function (point, compareX, e) {
  34976. var series = this,
  34977. kdX = this.kdAxisArray[0],
  34978. kdY = this.kdAxisArray[1],
  34979. kdComparer = compareX ? 'distX' : 'dist',
  34980. kdDimensions = series.options.findNearestPointBy
  34981. .indexOf('y') > -1 ? 2 : 1;
  34982. /**
  34983. * Set the one and two dimensional distance on the point object.
  34984. * @private
  34985. */
  34986. function setDistance(p1, p2) {
  34987. var x = (defined(p1[kdX]) &&
  34988. defined(p2[kdX])) ?
  34989. Math.pow(p1[kdX] - p2[kdX], 2) :
  34990. null,
  34991. y = (defined(p1[kdY]) &&
  34992. defined(p2[kdY])) ?
  34993. Math.pow(p1[kdY] - p2[kdY], 2) :
  34994. null,
  34995. r = (x || 0) + (y || 0);
  34996. p2.dist = defined(r) ? Math.sqrt(r) : Number.MAX_VALUE;
  34997. p2.distX = defined(x) ? Math.sqrt(x) : Number.MAX_VALUE;
  34998. }
  34999. /**
  35000. * @private
  35001. */
  35002. function _search(search, tree, depth, dimensions) {
  35003. var point = tree.point,
  35004. axis = series.kdAxisArray[depth % dimensions],
  35005. tdist,
  35006. sideA,
  35007. sideB,
  35008. ret = point,
  35009. nPoint1,
  35010. nPoint2;
  35011. setDistance(search, point);
  35012. // Pick side based on distance to splitting point
  35013. tdist = search[axis] - point[axis];
  35014. sideA = tdist < 0 ? 'left' : 'right';
  35015. sideB = tdist < 0 ? 'right' : 'left';
  35016. // End of tree
  35017. if (tree[sideA]) {
  35018. nPoint1 = _search(search, tree[sideA], depth + 1, dimensions);
  35019. ret = (nPoint1[kdComparer] <
  35020. ret[kdComparer] ?
  35021. nPoint1 :
  35022. point);
  35023. }
  35024. if (tree[sideB]) {
  35025. // compare distance to current best to splitting point to
  35026. // decide wether to check side B or not
  35027. if (Math.sqrt(tdist * tdist) < ret[kdComparer]) {
  35028. nPoint2 = _search(search, tree[sideB], depth + 1, dimensions);
  35029. ret = (nPoint2[kdComparer] <
  35030. ret[kdComparer] ?
  35031. nPoint2 :
  35032. ret);
  35033. }
  35034. }
  35035. return ret;
  35036. }
  35037. if (!this.kdTree && !this.buildingKdTree) {
  35038. this.buildKDTree(e);
  35039. }
  35040. if (this.kdTree) {
  35041. return _search(point, this.kdTree, kdDimensions, kdDimensions);
  35042. }
  35043. };
  35044. /**
  35045. * @private
  35046. * @function Highcharts.Series#pointPlacementToXValue
  35047. */
  35048. Series.prototype.pointPlacementToXValue = function () {
  35049. var _a = this,
  35050. _b = _a.options,
  35051. pointPlacement = _b.pointPlacement,
  35052. pointRange = _b.pointRange,
  35053. axis = _a.xAxis;
  35054. var factor = pointPlacement;
  35055. // Point placement is relative to each series pointRange (#5889)
  35056. if (factor === 'between') {
  35057. factor = axis.reversed ? -0.5 : 0.5; // #11955
  35058. }
  35059. return isNumber(factor) ?
  35060. factor * (pointRange || axis.pointRange) :
  35061. 0;
  35062. };
  35063. /**
  35064. * @private
  35065. * @function Highcharts.Series#isPointInside
  35066. */
  35067. Series.prototype.isPointInside = function (point) {
  35068. var isInside = typeof point.plotY !== 'undefined' &&
  35069. typeof point.plotX !== 'undefined' &&
  35070. point.plotY >= 0 &&
  35071. point.plotY <= this.yAxis.len && // #3519
  35072. point.plotX >= 0 &&
  35073. point.plotX <= this.xAxis.len;
  35074. return isInside;
  35075. };
  35076. /**
  35077. * Draw the tracker object that sits above all data labels and markers to
  35078. * track mouse events on the graph or points. For the line type charts
  35079. * the tracker uses the same graphPath, but with a greater stroke width
  35080. * for better control.
  35081. * @private
  35082. */
  35083. Series.prototype.drawTracker = function () {
  35084. var series = this,
  35085. options = series.options,
  35086. trackByArea = options.trackByArea,
  35087. trackerPath = [].concat(trackByArea ?
  35088. series.areaPath :
  35089. series.graphPath),
  35090. // trackerPathLength = trackerPath.length,
  35091. chart = series.chart,
  35092. pointer = chart.pointer,
  35093. renderer = chart.renderer,
  35094. snap = chart.options.tooltip.snap,
  35095. tracker = series.tracker,
  35096. i,
  35097. onMouseOver = function (e) {
  35098. if (chart.hoverSeries !== series) {
  35099. series.onMouseOver();
  35100. }
  35101. },
  35102. /*
  35103. * Empirical lowest possible opacities for TRACKER_FILL for an
  35104. * element to stay invisible but clickable
  35105. * IE6: 0.002
  35106. * IE7: 0.002
  35107. * IE8: 0.002
  35108. * IE9: 0.00000000001 (unlimited)
  35109. * IE10: 0.0001 (exporting only)
  35110. * FF: 0.00000000001 (unlimited)
  35111. * Chrome: 0.000001
  35112. * Safari: 0.000001
  35113. * Opera: 0.00000000001 (unlimited)
  35114. */
  35115. TRACKER_FILL = 'rgba(192,192,192,' + (svg ? 0.0001 : 0.002) + ')';
  35116. // Draw the tracker
  35117. if (tracker) {
  35118. tracker.attr({ d: trackerPath });
  35119. }
  35120. else if (series.graph) { // create
  35121. series.tracker = renderer.path(trackerPath)
  35122. .attr({
  35123. visibility: series.visible ? 'visible' : 'hidden',
  35124. zIndex: 2
  35125. })
  35126. .addClass(trackByArea ?
  35127. 'highcharts-tracker-area' :
  35128. 'highcharts-tracker-line')
  35129. .add(series.group);
  35130. if (!chart.styledMode) {
  35131. series.tracker.attr({
  35132. 'stroke-linecap': 'round',
  35133. 'stroke-linejoin': 'round',
  35134. stroke: TRACKER_FILL,
  35135. fill: trackByArea ? TRACKER_FILL : 'none',
  35136. 'stroke-width': series.graph.strokeWidth() +
  35137. (trackByArea ? 0 : 2 * snap)
  35138. });
  35139. }
  35140. // The tracker is added to the series group, which is clipped, but
  35141. // is covered by the marker group. So the marker group also needs to
  35142. // capture events.
  35143. [
  35144. series.tracker,
  35145. series.markerGroup,
  35146. series.dataLabelsGroup
  35147. ].forEach(function (tracker) {
  35148. if (tracker) {
  35149. tracker.addClass('highcharts-tracker')
  35150. .on('mouseover', onMouseOver)
  35151. .on('mouseout', function (e) {
  35152. pointer.onTrackerMouseOut(e);
  35153. });
  35154. if (options.cursor && !chart.styledMode) {
  35155. tracker.css({ cursor: options.cursor });
  35156. }
  35157. if (hasTouch) {
  35158. tracker.on('touchstart', onMouseOver);
  35159. }
  35160. }
  35161. });
  35162. }
  35163. fireEvent(this, 'afterDrawTracker');
  35164. };
  35165. /**
  35166. * Add a point to the series after render time. The point can be added at
  35167. * the end, or by giving it an X value, to the start or in the middle of the
  35168. * series.
  35169. *
  35170. * @sample highcharts/members/series-addpoint-append/
  35171. * Append point
  35172. * @sample highcharts/members/series-addpoint-append-and-shift/
  35173. * Append and shift
  35174. * @sample highcharts/members/series-addpoint-x-and-y/
  35175. * Both X and Y values given
  35176. * @sample highcharts/members/series-addpoint-pie/
  35177. * Append pie slice
  35178. * @sample stock/members/series-addpoint/
  35179. * Append 100 points in Highcharts Stock
  35180. * @sample stock/members/series-addpoint-shift/
  35181. * Append and shift in Highcharts Stock
  35182. * @sample maps/members/series-addpoint/
  35183. * Add a point in Highmaps
  35184. *
  35185. * @function Highcharts.Series#addPoint
  35186. *
  35187. * @param {Highcharts.PointOptionsType} options
  35188. * The point options. If options is a single number, a point with
  35189. * that y value is appended to the series. If it is an array, it will
  35190. * be interpreted as x and y values respectively. If it is an
  35191. * object, advanced options as outlined under `series.data` are
  35192. * applied.
  35193. *
  35194. * @param {boolean} [redraw=true]
  35195. * Whether to redraw the chart after the point is added. When adding
  35196. * more than one point, it is highly recommended that the redraw
  35197. * option be set to false, and instead {@link Chart#redraw} is
  35198. * explicitly called after the adding of points is finished.
  35199. * Otherwise, the chart will redraw after adding each point.
  35200. *
  35201. * @param {boolean} [shift=false]
  35202. * If true, a point is shifted off the start of the series as one is
  35203. * appended to the end.
  35204. *
  35205. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  35206. * Whether to apply animation, and optionally animation
  35207. * configuration.
  35208. *
  35209. * @param {boolean} [withEvent=true]
  35210. * Used internally, whether to fire the series `addPoint` event.
  35211. *
  35212. * @fires Highcharts.Series#event:addPoint
  35213. */
  35214. Series.prototype.addPoint = function (options, redraw, shift, animation, withEvent) {
  35215. var series = this,
  35216. seriesOptions = series.options,
  35217. data = series.data,
  35218. chart = series.chart,
  35219. xAxis = series.xAxis,
  35220. names = xAxis && xAxis.hasNames && xAxis.names,
  35221. dataOptions = seriesOptions.data,
  35222. point,
  35223. xData = series.xData,
  35224. isInTheMiddle,
  35225. i,
  35226. x;
  35227. // Optional redraw, defaults to true
  35228. redraw = pick(redraw, true);
  35229. // Get options and push the point to xData, yData and series.options. In
  35230. // series.generatePoints the Point instance will be created on demand
  35231. // and pushed to the series.data array.
  35232. point = { series: series };
  35233. series.pointClass.prototype.applyOptions.apply(point, [options]);
  35234. x = point.x;
  35235. // Get the insertion point
  35236. i = xData.length;
  35237. if (series.requireSorting && x < xData[i - 1]) {
  35238. isInTheMiddle = true;
  35239. while (i && xData[i - 1] > x) {
  35240. i--;
  35241. }
  35242. }
  35243. // Insert undefined item
  35244. series.updateParallelArrays(point, 'splice', i, 0, 0);
  35245. // Update it
  35246. series.updateParallelArrays(point, i);
  35247. if (names && point.name) {
  35248. names[x] = point.name;
  35249. }
  35250. dataOptions.splice(i, 0, options);
  35251. if (isInTheMiddle) {
  35252. series.data.splice(i, 0, null);
  35253. series.processData();
  35254. }
  35255. // Generate points to be added to the legend (#1329)
  35256. if (seriesOptions.legendType === 'point') {
  35257. series.generatePoints();
  35258. }
  35259. // Shift the first point off the parallel arrays
  35260. if (shift) {
  35261. if (data[0] && data[0].remove) {
  35262. data[0].remove(false);
  35263. }
  35264. else {
  35265. data.shift();
  35266. series.updateParallelArrays(point, 'shift');
  35267. dataOptions.shift();
  35268. }
  35269. }
  35270. // Fire event
  35271. if (withEvent !== false) {
  35272. fireEvent(series, 'addPoint', { point: point });
  35273. }
  35274. // redraw
  35275. series.isDirty = true;
  35276. series.isDirtyData = true;
  35277. if (redraw) {
  35278. chart.redraw(animation); // Animation is set anyway on redraw, #5665
  35279. }
  35280. };
  35281. /**
  35282. * Remove a point from the series. Unlike the
  35283. * {@link Highcharts.Point#remove} method, this can also be done on a point
  35284. * that is not instanciated because it is outside the view or subject to
  35285. * Highcharts Stock data grouping.
  35286. *
  35287. * @sample highcharts/members/series-removepoint/
  35288. * Remove cropped point
  35289. *
  35290. * @function Highcharts.Series#removePoint
  35291. *
  35292. * @param {number} i
  35293. * The index of the point in the {@link Highcharts.Series.data|data}
  35294. * array.
  35295. *
  35296. * @param {boolean} [redraw=true]
  35297. * Whether to redraw the chart after the point is added. When
  35298. * removing more than one point, it is highly recommended that the
  35299. * `redraw` option be set to `false`, and instead {@link
  35300. * Highcharts.Chart#redraw} is explicitly called after the adding of
  35301. * points is finished.
  35302. *
  35303. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  35304. * Whether and optionally how the series should be animated.
  35305. *
  35306. * @fires Highcharts.Point#event:remove
  35307. */
  35308. Series.prototype.removePoint = function (i, redraw, animation) {
  35309. var series = this,
  35310. data = series.data,
  35311. point = data[i],
  35312. points = series.points,
  35313. chart = series.chart,
  35314. remove = function () {
  35315. if (points && points.length === data.length) { // #4935
  35316. points.splice(i, 1);
  35317. }
  35318. data.splice(i, 1);
  35319. series.options.data.splice(i, 1);
  35320. series.updateParallelArrays(point || { series: series }, 'splice', i, 1);
  35321. if (point) {
  35322. point.destroy();
  35323. }
  35324. // redraw
  35325. series.isDirty = true;
  35326. series.isDirtyData = true;
  35327. if (redraw) {
  35328. chart.redraw();
  35329. }
  35330. };
  35331. setAnimation(animation, chart);
  35332. redraw = pick(redraw, true);
  35333. // Fire the event with a default handler of removing the point
  35334. if (point) {
  35335. point.firePointEvent('remove', null, remove);
  35336. }
  35337. else {
  35338. remove();
  35339. }
  35340. };
  35341. /**
  35342. * Remove a series and optionally redraw the chart.
  35343. *
  35344. * @sample highcharts/members/series-remove/
  35345. * Remove first series from a button
  35346. *
  35347. * @function Highcharts.Series#remove
  35348. *
  35349. * @param {boolean} [redraw=true]
  35350. * Whether to redraw the chart or wait for an explicit call to
  35351. * {@link Highcharts.Chart#redraw}.
  35352. *
  35353. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  35354. * Whether to apply animation, and optionally animation
  35355. * configuration.
  35356. *
  35357. * @param {boolean} [withEvent=true]
  35358. * Used internally, whether to fire the series `remove` event.
  35359. *
  35360. * @fires Highcharts.Series#event:remove
  35361. */
  35362. Series.prototype.remove = function (redraw, animation, withEvent, keepEvents) {
  35363. var series = this,
  35364. chart = series.chart;
  35365. /**
  35366. * @private
  35367. */
  35368. function remove() {
  35369. // Destroy elements
  35370. series.destroy(keepEvents);
  35371. // Redraw
  35372. chart.isDirtyLegend = chart.isDirtyBox = true;
  35373. chart.linkSeries();
  35374. if (pick(redraw, true)) {
  35375. chart.redraw(animation);
  35376. }
  35377. }
  35378. // Fire the event with a default handler of removing the point
  35379. if (withEvent !== false) {
  35380. fireEvent(series, 'remove', null, remove);
  35381. }
  35382. else {
  35383. remove();
  35384. }
  35385. };
  35386. /**
  35387. * Update the series with a new set of options. For a clean and precise
  35388. * handling of new options, all methods and elements from the series are
  35389. * removed, and it is initialized from scratch. Therefore, this method is
  35390. * more performance expensive than some other utility methods like {@link
  35391. * Series#setData} or {@link Series#setVisible}.
  35392. *
  35393. * Note that `Series.update` may mutate the passed `data` options.
  35394. *
  35395. * @sample highcharts/members/series-update/
  35396. * Updating series options
  35397. * @sample maps/members/series-update/
  35398. * Update series options in Highmaps
  35399. *
  35400. * @function Highcharts.Series#update
  35401. *
  35402. * @param {Highcharts.SeriesOptionsType} options
  35403. * New options that will be merged with the series' existing options.
  35404. *
  35405. * @param {boolean} [redraw=true]
  35406. * Whether to redraw the chart after the series is altered. If doing
  35407. * more operations on the chart, it is a good idea to set redraw to
  35408. * false and call {@link Chart#redraw} after.
  35409. *
  35410. * @fires Highcharts.Series#event:update
  35411. * @fires Highcharts.Series#event:afterUpdate
  35412. */
  35413. Series.prototype.update = function (options, redraw) {
  35414. options = cleanRecursively(options, this.userOptions);
  35415. fireEvent(this, 'update', { options: options });
  35416. var series = this,
  35417. chart = series.chart,
  35418. // must use user options when changing type because series.options
  35419. // is merged in with type specific plotOptions
  35420. oldOptions = series.userOptions,
  35421. seriesOptions,
  35422. initialType = series.initialType || series.type,
  35423. plotOptions = chart.options.plotOptions,
  35424. newType = (options.type ||
  35425. oldOptions.type ||
  35426. chart.options.chart.type),
  35427. keepPoints = !(
  35428. // Indicators, histograms etc recalculate the data. It should be
  35429. // possible to omit this.
  35430. this.hasDerivedData ||
  35431. // New type requires new point classes
  35432. (newType && newType !== this.type) ||
  35433. // New options affecting how the data points are built
  35434. typeof options.pointStart !== 'undefined' ||
  35435. typeof options.pointInterval !== 'undefined' ||
  35436. // Changes to data grouping requires new points in new group
  35437. series.hasOptionChanged('dataGrouping') ||
  35438. series.hasOptionChanged('pointStart') ||
  35439. series.hasOptionChanged('pointInterval') ||
  35440. series.hasOptionChanged('pointIntervalUnit') ||
  35441. series.hasOptionChanged('keys')),
  35442. initialSeriesProto = seriesTypes[initialType].prototype,
  35443. n,
  35444. groups = [
  35445. 'group',
  35446. 'markerGroup',
  35447. 'dataLabelsGroup',
  35448. 'transformGroup'
  35449. ],
  35450. preserve = [
  35451. 'eventOptions',
  35452. 'navigatorSeries',
  35453. 'baseSeries'
  35454. ],
  35455. // Animation must be enabled when calling update before the initial
  35456. // animation has first run. This happens when calling update
  35457. // directly after chart initialization, or when applying responsive
  35458. // rules (#6912).
  35459. animation = series.finishedAnimating && { animation: false },
  35460. kinds = {};
  35461. newType = newType || initialType;
  35462. if (keepPoints) {
  35463. preserve.push('data', 'isDirtyData', 'points', 'processedXData', 'processedYData', 'xIncrement', 'cropped', '_hasPointMarkers', '_hasPointLabels', 'clips', // #15420
  35464. // Networkgraph (#14397)
  35465. 'nodes', 'layout',
  35466. // Map specific, consider moving it to series-specific preserve-
  35467. // properties (#10617)
  35468. 'mapMap', 'mapData', 'minY', 'maxY', 'minX', 'maxX');
  35469. if (options.visible !== false) {
  35470. preserve.push('area', 'graph');
  35471. }
  35472. series.parallelArrays.forEach(function (key) {
  35473. preserve.push(key + 'Data');
  35474. });
  35475. if (options.data) {
  35476. // setData uses dataSorting options so we need to update them
  35477. // earlier
  35478. if (options.dataSorting) {
  35479. extend(series.options.dataSorting, options.dataSorting);
  35480. }
  35481. this.setData(options.data, false);
  35482. }
  35483. }
  35484. // Do the merge, with some forced options
  35485. options = merge(oldOptions, animation, {
  35486. // When oldOptions.index is null it should't be cleared.
  35487. // Otherwise navigator series will have wrong indexes (#10193).
  35488. index: typeof oldOptions.index === 'undefined' ?
  35489. series.index : oldOptions.index,
  35490. pointStart: pick(
  35491. // when updating from blank (#7933)
  35492. plotOptions && plotOptions.series && plotOptions.series.pointStart, oldOptions.pointStart,
  35493. // when updating after addPoint
  35494. series.xData[0])
  35495. }, (!keepPoints && { data: series.options.data }), options);
  35496. // Merge does not merge arrays, but replaces them. Since points were
  35497. // updated, `series.options.data` has correct merged options, use it:
  35498. if (keepPoints && options.data) {
  35499. options.data = series.options.data;
  35500. }
  35501. // Make sure preserved properties are not destroyed (#3094)
  35502. preserve = groups.concat(preserve);
  35503. preserve.forEach(function (prop) {
  35504. preserve[prop] = series[prop];
  35505. delete series[prop];
  35506. });
  35507. var casting = false;
  35508. if (seriesTypes[newType]) {
  35509. casting = newType !== series.type;
  35510. // Destroy the series and delete all properties, it will be
  35511. // reinserted within the `init` call below
  35512. series.remove(false, false, false, true);
  35513. if (casting) {
  35514. // Modern browsers including IE11
  35515. // @todo slow, consider alternatives mentioned:
  35516. // https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf
  35517. if (Object.setPrototypeOf) {
  35518. Object.setPrototypeOf(series, seriesTypes[newType].prototype);
  35519. // Legacy (IE < 11)
  35520. }
  35521. else {
  35522. var ownEvents = Object.hasOwnProperty.call(series, 'hcEvents') &&
  35523. series.hcEvents;
  35524. for (n in initialSeriesProto) { // eslint-disable-line guard-for-in
  35525. series[n] = void 0;
  35526. }
  35527. // Reinsert all methods and properties from the new type
  35528. // prototype (#2270, #3719).
  35529. extend(series, seriesTypes[newType].prototype);
  35530. // The events are tied to the prototype chain, don't copy if
  35531. // they're not the series' own
  35532. if (ownEvents) {
  35533. series.hcEvents = ownEvents;
  35534. }
  35535. else {
  35536. delete series.hcEvents;
  35537. }
  35538. }
  35539. }
  35540. }
  35541. else {
  35542. error(17, true, chart, { missingModuleFor: newType });
  35543. }
  35544. // Re-register groups (#3094) and other preserved properties
  35545. preserve.forEach(function (prop) {
  35546. series[prop] = preserve[prop];
  35547. });
  35548. series.init(chart, options);
  35549. // Remove particular elements of the points. Check `series.options`
  35550. // because we need to consider the options being set on plotOptions as
  35551. // well.
  35552. if (keepPoints && this.points) {
  35553. seriesOptions = series.options;
  35554. // What kind of elements to destroy
  35555. if (seriesOptions.visible === false) {
  35556. kinds.graphic = 1;
  35557. kinds.dataLabel = 1;
  35558. }
  35559. else if (!series._hasPointLabels) {
  35560. var marker = seriesOptions.marker,
  35561. dataLabels = seriesOptions.dataLabels;
  35562. if (marker && (marker.enabled === false ||
  35563. 'symbol' in marker // #10870
  35564. )) {
  35565. kinds.graphic = 1;
  35566. }
  35567. if (dataLabels &&
  35568. dataLabels.enabled === false) {
  35569. kinds.dataLabel = 1;
  35570. }
  35571. }
  35572. this.points.forEach(function (point) {
  35573. if (point && point.series) {
  35574. point.resolveColor();
  35575. // Destroy elements in order to recreate based on updated
  35576. // series options.
  35577. if (Object.keys(kinds).length) {
  35578. point.destroyElements(kinds);
  35579. }
  35580. if (seriesOptions.showInLegend === false &&
  35581. point.legendItem) {
  35582. chart.legend.destroyItem(point);
  35583. }
  35584. }
  35585. }, this);
  35586. }
  35587. series.initialType = initialType;
  35588. chart.linkSeries(); // Links are lost in series.remove (#3028)
  35589. // #15383: Fire updatedData if the type has changed to keep linked
  35590. // series such as indicators updated
  35591. if (casting && series.linkedSeries.length) {
  35592. series.isDirtyData = true;
  35593. }
  35594. fireEvent(this, 'afterUpdate');
  35595. if (pick(redraw, true)) {
  35596. chart.redraw(keepPoints ? void 0 : false);
  35597. }
  35598. };
  35599. /**
  35600. * Used from within series.update
  35601. * @private
  35602. */
  35603. Series.prototype.setName = function (name) {
  35604. this.name = this.options.name = this.userOptions.name = name;
  35605. this.chart.isDirtyLegend = true;
  35606. };
  35607. /**
  35608. * Check if the option has changed.
  35609. * @private
  35610. */
  35611. Series.prototype.hasOptionChanged = function (optionName) {
  35612. var chart = this.chart,
  35613. option = this.options[optionName],
  35614. plotOptions = chart.options.plotOptions,
  35615. oldOption = this.userOptions[optionName];
  35616. if (oldOption) {
  35617. return option !== oldOption;
  35618. }
  35619. return option !==
  35620. pick(plotOptions && plotOptions[this.type] && plotOptions[this.type][optionName], plotOptions && plotOptions.series && plotOptions.series[optionName], option);
  35621. };
  35622. /**
  35623. * Runs on mouse over the series graphical items.
  35624. *
  35625. * @function Highcharts.Series#onMouseOver
  35626. * @fires Highcharts.Series#event:mouseOver
  35627. */
  35628. Series.prototype.onMouseOver = function () {
  35629. var series = this,
  35630. chart = series.chart,
  35631. hoverSeries = chart.hoverSeries,
  35632. pointer = chart.pointer;
  35633. pointer.setHoverChartIndex();
  35634. // set normal state to previous series
  35635. if (hoverSeries && hoverSeries !== series) {
  35636. hoverSeries.onMouseOut();
  35637. }
  35638. // trigger the event, but to save processing time,
  35639. // only if defined
  35640. if (series.options.events.mouseOver) {
  35641. fireEvent(series, 'mouseOver');
  35642. }
  35643. // hover this
  35644. series.setState('hover');
  35645. /**
  35646. * Contains the original hovered series.
  35647. *
  35648. * @name Highcharts.Chart#hoverSeries
  35649. * @type {Highcharts.Series|null}
  35650. */
  35651. chart.hoverSeries = series;
  35652. };
  35653. /**
  35654. * Runs on mouse out of the series graphical items.
  35655. *
  35656. * @function Highcharts.Series#onMouseOut
  35657. *
  35658. * @fires Highcharts.Series#event:mouseOut
  35659. */
  35660. Series.prototype.onMouseOut = function () {
  35661. // trigger the event only if listeners exist
  35662. var series = this,
  35663. options = series.options,
  35664. chart = series.chart,
  35665. tooltip = chart.tooltip,
  35666. hoverPoint = chart.hoverPoint;
  35667. // #182, set to null before the mouseOut event fires
  35668. chart.hoverSeries = null;
  35669. // trigger mouse out on the point, which must be in this series
  35670. if (hoverPoint) {
  35671. hoverPoint.onMouseOut();
  35672. }
  35673. // fire the mouse out event
  35674. if (series && options.events.mouseOut) {
  35675. fireEvent(series, 'mouseOut');
  35676. }
  35677. // hide the tooltip
  35678. if (tooltip &&
  35679. !series.stickyTracking &&
  35680. (!tooltip.shared || series.noSharedTooltip)) {
  35681. tooltip.hide();
  35682. }
  35683. // Reset all inactive states
  35684. chart.series.forEach(function (s) {
  35685. s.setState('', true);
  35686. });
  35687. };
  35688. /**
  35689. * Set the state of the series. Called internally on mouse interaction
  35690. * operations, but it can also be called directly to visually
  35691. * highlight a series.
  35692. *
  35693. * @function Highcharts.Series#setState
  35694. *
  35695. * @param {Highcharts.SeriesStateValue|""} [state]
  35696. * The new state, can be either `'hover'`, `'inactive'`, `'select'`,
  35697. * or `''` (an empty string), `'normal'` or `undefined` to set to
  35698. * normal state.
  35699. * @param {boolean} [inherit]
  35700. * Determines if state should be inherited by points too.
  35701. */
  35702. Series.prototype.setState = function (state, inherit) {
  35703. var series = this,
  35704. options = series.options,
  35705. graph = series.graph,
  35706. inactiveOtherPoints = options.inactiveOtherPoints,
  35707. stateOptions = options.states,
  35708. lineWidth = options.lineWidth,
  35709. opacity = options.opacity,
  35710. // By default a quick animation to hover/inactive,
  35711. // slower to un-hover
  35712. stateAnimation = pick((stateOptions[state || 'normal'] &&
  35713. stateOptions[state || 'normal'].animation),
  35714. series.chart.options.chart.animation),
  35715. attribs,
  35716. i = 0;
  35717. state = state || '';
  35718. if (series.state !== state) {
  35719. // Toggle class names
  35720. [
  35721. series.group,
  35722. series.markerGroup,
  35723. series.dataLabelsGroup
  35724. ].forEach(function (group) {
  35725. if (group) {
  35726. // Old state
  35727. if (series.state) {
  35728. group.removeClass('highcharts-series-' + series.state);
  35729. }
  35730. // New state
  35731. if (state) {
  35732. group.addClass('highcharts-series-' + state);
  35733. }
  35734. }
  35735. });
  35736. series.state = state;
  35737. if (!series.chart.styledMode) {
  35738. if (stateOptions[state] &&
  35739. stateOptions[state].enabled === false) {
  35740. return;
  35741. }
  35742. if (state) {
  35743. lineWidth = (stateOptions[state].lineWidth ||
  35744. lineWidth + (stateOptions[state].lineWidthPlus || 0)); // #4035
  35745. opacity = pick(stateOptions[state].opacity, opacity);
  35746. }
  35747. if (graph && !graph.dashstyle) {
  35748. attribs = {
  35749. 'stroke-width': lineWidth
  35750. };
  35751. // Animate the graph stroke-width.
  35752. graph.animate(attribs, stateAnimation);
  35753. while (series['zone-graph-' + i]) {
  35754. series['zone-graph-' + i].animate(attribs, stateAnimation);
  35755. i = i + 1;
  35756. }
  35757. }
  35758. // For some types (pie, networkgraph, sankey) opacity is
  35759. // resolved on a point level
  35760. if (!inactiveOtherPoints) {
  35761. [
  35762. series.group,
  35763. series.markerGroup,
  35764. series.dataLabelsGroup,
  35765. series.labelBySeries
  35766. ].forEach(function (group) {
  35767. if (group) {
  35768. group.animate({
  35769. opacity: opacity
  35770. }, stateAnimation);
  35771. }
  35772. });
  35773. }
  35774. }
  35775. }
  35776. // Don't loop over points on a series that doesn't apply inactive state
  35777. // to siblings markers (e.g. line, column)
  35778. if (inherit && inactiveOtherPoints && series.points) {
  35779. series.setAllPointsToState(state || void 0);
  35780. }
  35781. };
  35782. /**
  35783. * Set the state for all points in the series.
  35784. *
  35785. * @function Highcharts.Series#setAllPointsToState
  35786. *
  35787. * @private
  35788. *
  35789. * @param {string} [state]
  35790. * Can be either `hover` or undefined to set to normal state.
  35791. */
  35792. Series.prototype.setAllPointsToState = function (state) {
  35793. this.points.forEach(function (point) {
  35794. if (point.setState) {
  35795. point.setState(state);
  35796. }
  35797. });
  35798. };
  35799. /**
  35800. * Show or hide the series.
  35801. *
  35802. * @function Highcharts.Series#setVisible
  35803. *
  35804. * @param {boolean} [visible]
  35805. * True to show the series, false to hide. If undefined, the visibility is
  35806. * toggled.
  35807. *
  35808. * @param {boolean} [redraw=true]
  35809. * Whether to redraw the chart after the series is altered. If doing more
  35810. * operations on the chart, it is a good idea to set redraw to false and
  35811. * call {@link Chart#redraw|chart.redraw()} after.
  35812. *
  35813. * @fires Highcharts.Series#event:hide
  35814. * @fires Highcharts.Series#event:show
  35815. */
  35816. Series.prototype.setVisible = function (vis, redraw) {
  35817. var series = this,
  35818. chart = series.chart,
  35819. legendItem = series.legendItem,
  35820. showOrHide,
  35821. ignoreHiddenSeries = chart.options.chart.ignoreHiddenSeries,
  35822. oldVisibility = series.visible;
  35823. // if called without an argument, toggle visibility
  35824. series.visible =
  35825. vis =
  35826. series.options.visible =
  35827. series.userOptions.visible =
  35828. typeof vis === 'undefined' ? !oldVisibility : vis; // #5618
  35829. showOrHide = vis ? 'show' : 'hide';
  35830. // show or hide elements
  35831. [
  35832. 'group',
  35833. 'dataLabelsGroup',
  35834. 'markerGroup',
  35835. 'tracker',
  35836. 'tt'
  35837. ].forEach(function (key) {
  35838. if (series[key]) {
  35839. series[key][showOrHide]();
  35840. }
  35841. });
  35842. // hide tooltip (#1361)
  35843. if (chart.hoverSeries === series ||
  35844. (chart.hoverPoint && chart.hoverPoint.series) === series) {
  35845. series.onMouseOut();
  35846. }
  35847. if (legendItem) {
  35848. chart.legend.colorizeItem(series, vis);
  35849. }
  35850. // rescale or adapt to resized chart
  35851. series.isDirty = true;
  35852. // in a stack, all other series are affected
  35853. if (series.options.stacking) {
  35854. chart.series.forEach(function (otherSeries) {
  35855. if (otherSeries.options.stacking && otherSeries.visible) {
  35856. otherSeries.isDirty = true;
  35857. }
  35858. });
  35859. }
  35860. // show or hide linked series
  35861. series.linkedSeries.forEach(function (otherSeries) {
  35862. otherSeries.setVisible(vis, false);
  35863. });
  35864. if (ignoreHiddenSeries) {
  35865. chart.isDirtyBox = true;
  35866. }
  35867. fireEvent(series, showOrHide);
  35868. if (redraw !== false) {
  35869. chart.redraw();
  35870. }
  35871. };
  35872. /**
  35873. * Show the series if hidden.
  35874. *
  35875. * @sample highcharts/members/series-hide/
  35876. * Toggle visibility from a button
  35877. *
  35878. * @function Highcharts.Series#show
  35879. * @fires Highcharts.Series#event:show
  35880. */
  35881. Series.prototype.show = function () {
  35882. this.setVisible(true);
  35883. };
  35884. /**
  35885. * Hide the series if visible. If the
  35886. * [chart.ignoreHiddenSeries](https://api.highcharts.com/highcharts/chart.ignoreHiddenSeries)
  35887. * option is true, the chart is redrawn without this series.
  35888. *
  35889. * @sample highcharts/members/series-hide/
  35890. * Toggle visibility from a button
  35891. *
  35892. * @function Highcharts.Series#hide
  35893. * @fires Highcharts.Series#event:hide
  35894. */
  35895. Series.prototype.hide = function () {
  35896. this.setVisible(false);
  35897. };
  35898. /**
  35899. * Select or unselect the series. This means its
  35900. * {@link Highcharts.Series.selected|selected}
  35901. * property is set, the checkbox in the legend is toggled and when selected,
  35902. * the series is returned by the {@link Highcharts.Chart#getSelectedSeries}
  35903. * function.
  35904. *
  35905. * @sample highcharts/members/series-select/
  35906. * Select a series from a button
  35907. *
  35908. * @function Highcharts.Series#select
  35909. *
  35910. * @param {boolean} [selected]
  35911. * True to select the series, false to unselect. If undefined, the selection
  35912. * state is toggled.
  35913. *
  35914. * @fires Highcharts.Series#event:select
  35915. * @fires Highcharts.Series#event:unselect
  35916. */
  35917. Series.prototype.select = function (selected) {
  35918. var series = this;
  35919. series.selected =
  35920. selected =
  35921. this.options.selected = (typeof selected === 'undefined' ?
  35922. !series.selected :
  35923. selected);
  35924. if (series.checkbox) {
  35925. series.checkbox.checked = selected;
  35926. }
  35927. fireEvent(series, selected ? 'select' : 'unselect');
  35928. };
  35929. /**
  35930. * Checks if a tooltip should be shown for a given point.
  35931. *
  35932. * @private
  35933. * @param {number} plotX
  35934. * @param {number} plotY
  35935. * @param {Highcharts.ChartIsInsideOptionsObject} [options]
  35936. * @return {boolean}
  35937. */
  35938. Series.prototype.shouldShowTooltip = function (plotX, plotY, options) {
  35939. if (options === void 0) { options = {}; }
  35940. options.series = this;
  35941. options.visiblePlotOnly = true;
  35942. return this.chart.isInsidePlot(plotX, plotY, options);
  35943. };
  35944. /**
  35945. * General options for all series types.
  35946. *
  35947. * @optionparent plotOptions.series
  35948. */
  35949. Series.defaultOptions = {
  35950. // base series options
  35951. /**
  35952. * The SVG value used for the `stroke-linecap` and `stroke-linejoin`
  35953. * of a line graph. Round means that lines are rounded in the ends and
  35954. * bends.
  35955. *
  35956. * @type {Highcharts.SeriesLinecapValue}
  35957. * @default round
  35958. * @since 3.0.7
  35959. * @apioption plotOptions.line.linecap
  35960. */
  35961. /**
  35962. * Pixel width of the graph line.
  35963. *
  35964. * @see In styled mode, the line stroke-width can be set with the
  35965. * `.highcharts-graph` class name.
  35966. *
  35967. * @sample {highcharts} highcharts/plotoptions/series-linewidth-general/
  35968. * On all series
  35969. * @sample {highcharts} highcharts/plotoptions/series-linewidth-specific/
  35970. * On one single series
  35971. *
  35972. * @product highcharts highstock
  35973. *
  35974. * @private
  35975. */
  35976. lineWidth: 2,
  35977. /**
  35978. * For some series, there is a limit that shuts down initial animation
  35979. * by default when the total number of points in the chart is too high.
  35980. * For example, for a column chart and its derivatives, animation does
  35981. * not run if there is more than 250 points totally. To disable this
  35982. * cap, set `animationLimit` to `Infinity`.
  35983. *
  35984. * @type {number}
  35985. * @apioption plotOptions.series.animationLimit
  35986. */
  35987. /**
  35988. * Allow this series' points to be selected by clicking on the graphic
  35989. * (columns, point markers, pie slices, map areas etc).
  35990. *
  35991. * The selected points can be handled by point select and unselect
  35992. * events, or collectively by the [getSelectedPoints
  35993. * ](/class-reference/Highcharts.Chart#getSelectedPoints) function.
  35994. *
  35995. * And alternative way of selecting points is through dragging.
  35996. *
  35997. * @sample {highcharts} highcharts/plotoptions/series-allowpointselect-line/
  35998. * Line
  35999. * @sample {highcharts} highcharts/plotoptions/series-allowpointselect-column/
  36000. * Column
  36001. * @sample {highcharts} highcharts/plotoptions/series-allowpointselect-pie/
  36002. * Pie
  36003. * @sample {highcharts} highcharts/chart/events-selection-points/
  36004. * Select a range of points through a drag selection
  36005. * @sample {highmaps} maps/plotoptions/series-allowpointselect/
  36006. * Map area
  36007. * @sample {highmaps} maps/plotoptions/mapbubble-allowpointselect/
  36008. * Map bubble
  36009. *
  36010. * @since 1.2.0
  36011. *
  36012. * @private
  36013. */
  36014. allowPointSelect: false,
  36015. /**
  36016. * When true, each point or column edge is rounded to its nearest pixel
  36017. * in order to render sharp on screen. In some cases, when there are a
  36018. * lot of densely packed columns, this leads to visible difference
  36019. * in column widths or distance between columns. In these cases,
  36020. * setting `crisp` to `false` may look better, even though each column
  36021. * is rendered blurry.
  36022. *
  36023. * @sample {highcharts} highcharts/plotoptions/column-crisp-false/
  36024. * Crisp is false
  36025. *
  36026. * @since 5.0.10
  36027. * @product highcharts highstock gantt
  36028. *
  36029. * @private
  36030. */
  36031. crisp: true,
  36032. /**
  36033. * If true, a checkbox is displayed next to the legend item to allow
  36034. * selecting the series. The state of the checkbox is determined by
  36035. * the `selected` option.
  36036. *
  36037. * @productdesc {highmaps}
  36038. * Note that if a `colorAxis` is defined, the color axis is represented
  36039. * in the legend, not the series.
  36040. *
  36041. * @sample {highcharts} highcharts/plotoptions/series-showcheckbox-true/
  36042. * Show select box
  36043. *
  36044. * @since 1.2.0
  36045. *
  36046. * @private
  36047. */
  36048. showCheckbox: false,
  36049. /**
  36050. * Enable or disable the initial animation when a series is displayed.
  36051. * The animation can also be set as a configuration object. Please
  36052. * note that this option only applies to the initial animation of the
  36053. * series itself. For other animations, see [chart.animation](
  36054. * #chart.animation) and the animation parameter under the API methods.
  36055. * The following properties are supported:
  36056. *
  36057. * - `defer`: The animation delay time in milliseconds.
  36058. *
  36059. * - `duration`: The duration of the animation in milliseconds.
  36060. *
  36061. * - `easing`: Can be a string reference to an easing function set on
  36062. * the `Math` object or a function. See the _Custom easing function_
  36063. * demo below.
  36064. *
  36065. * Due to poor performance, animation is disabled in old IE browsers
  36066. * for several chart types.
  36067. *
  36068. * @sample {highcharts} highcharts/plotoptions/series-animation-disabled/
  36069. * Animation disabled
  36070. * @sample {highcharts} highcharts/plotoptions/series-animation-slower/
  36071. * Slower animation
  36072. * @sample {highcharts} highcharts/plotoptions/series-animation-easing/
  36073. * Custom easing function
  36074. * @sample {highstock} stock/plotoptions/animation-slower/
  36075. * Slower animation
  36076. * @sample {highstock} stock/plotoptions/animation-easing/
  36077. * Custom easing function
  36078. * @sample {highmaps} maps/plotoptions/series-animation-true/
  36079. * Animation enabled on map series
  36080. * @sample {highmaps} maps/plotoptions/mapbubble-animation-false/
  36081. * Disabled on mapbubble series
  36082. *
  36083. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  36084. * @default {highcharts} true
  36085. * @default {highstock} true
  36086. * @default {highmaps} false
  36087. *
  36088. * @private
  36089. */
  36090. animation: {
  36091. /** @internal */
  36092. duration: 1000
  36093. },
  36094. /**
  36095. * @default 0
  36096. * @type {number}
  36097. * @since 8.2.0
  36098. * @apioption plotOptions.series.animation.defer
  36099. */
  36100. /**
  36101. * An additional class name to apply to the series' graphical elements.
  36102. * This option does not replace default class names of the graphical
  36103. * element.
  36104. *
  36105. * @type {string}
  36106. * @since 5.0.0
  36107. * @apioption plotOptions.series.className
  36108. */
  36109. /**
  36110. * Disable this option to allow series rendering in the whole plotting
  36111. * area.
  36112. *
  36113. * **Note:** Clipping should be always enabled when
  36114. * [chart.zoomType](#chart.zoomType) is set
  36115. *
  36116. * @sample {highcharts} highcharts/plotoptions/series-clip/
  36117. * Disabled clipping
  36118. *
  36119. * @default true
  36120. * @type {boolean}
  36121. * @since 3.0.0
  36122. * @apioption plotOptions.series.clip
  36123. */
  36124. /**
  36125. * The main color of the series. In line type series it applies to the
  36126. * line and the point markers unless otherwise specified. In bar type
  36127. * series it applies to the bars unless a color is specified per point.
  36128. * The default value is pulled from the `options.colors` array.
  36129. *
  36130. * In styled mode, the color can be defined by the
  36131. * [colorIndex](#plotOptions.series.colorIndex) option. Also, the series
  36132. * color can be set with the `.highcharts-series`,
  36133. * `.highcharts-color-{n}`, `.highcharts-{type}-series` or
  36134. * `.highcharts-series-{n}` class, or individual classes given by the
  36135. * `className` option.
  36136. *
  36137. * @productdesc {highmaps}
  36138. * In maps, the series color is rarely used, as most choropleth maps use
  36139. * the color to denote the value of each point. The series color can
  36140. * however be used in a map with multiple series holding categorized
  36141. * data.
  36142. *
  36143. * @sample {highcharts} highcharts/plotoptions/series-color-general/
  36144. * General plot option
  36145. * @sample {highcharts} highcharts/plotoptions/series-color-specific/
  36146. * One specific series
  36147. * @sample {highcharts} highcharts/plotoptions/series-color-area/
  36148. * Area color
  36149. * @sample {highcharts} highcharts/series/infographic/
  36150. * Pattern fill
  36151. * @sample {highmaps} maps/demo/category-map/
  36152. * Category map by multiple series
  36153. *
  36154. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  36155. * @apioption plotOptions.series.color
  36156. */
  36157. /**
  36158. * Styled mode only. A specific color index to use for the series, so
  36159. * its graphic representations are given the class name
  36160. * `highcharts-color-{n}`.
  36161. *
  36162. * @type {number}
  36163. * @since 5.0.0
  36164. * @apioption plotOptions.series.colorIndex
  36165. */
  36166. /**
  36167. * Whether to connect a graph line across null points, or render a gap
  36168. * between the two points on either side of the null.
  36169. *
  36170. * @sample {highcharts} highcharts/plotoptions/series-connectnulls-false/
  36171. * False by default
  36172. * @sample {highcharts} highcharts/plotoptions/series-connectnulls-true/
  36173. * True
  36174. *
  36175. * @type {boolean}
  36176. * @default false
  36177. * @product highcharts highstock
  36178. * @apioption plotOptions.series.connectNulls
  36179. */
  36180. /**
  36181. * You can set the cursor to "pointer" if you have click events attached
  36182. * to the series, to signal to the user that the points and lines can
  36183. * be clicked.
  36184. *
  36185. * In styled mode, the series cursor can be set with the same classes
  36186. * as listed under [series.color](#plotOptions.series.color).
  36187. *
  36188. * @sample {highcharts} highcharts/plotoptions/series-cursor-line/
  36189. * On line graph
  36190. * @sample {highcharts} highcharts/plotoptions/series-cursor-column/
  36191. * On columns
  36192. * @sample {highcharts} highcharts/plotoptions/series-cursor-scatter/
  36193. * On scatter markers
  36194. * @sample {highstock} stock/plotoptions/cursor/
  36195. * Pointer on a line graph
  36196. * @sample {highmaps} maps/plotoptions/series-allowpointselect/
  36197. * Map area
  36198. * @sample {highmaps} maps/plotoptions/mapbubble-allowpointselect/
  36199. * Map bubble
  36200. *
  36201. * @type {string|Highcharts.CursorValue}
  36202. * @apioption plotOptions.series.cursor
  36203. */
  36204. /**
  36205. * A reserved subspace to store options and values for customized
  36206. * functionality. Here you can add additional data for your own event
  36207. * callbacks and formatter callbacks.
  36208. *
  36209. * @sample {highcharts} highcharts/point/custom/
  36210. * Point and series with custom data
  36211. *
  36212. * @type {Highcharts.Dictionary<*>}
  36213. * @apioption plotOptions.series.custom
  36214. */
  36215. /**
  36216. * Name of the dash style to use for the graph, or for some series types
  36217. * the outline of each shape.
  36218. *
  36219. * In styled mode, the
  36220. * [stroke dash-array](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/css/series-dashstyle/)
  36221. * can be set with the same classes as listed under
  36222. * [series.color](#plotOptions.series.color).
  36223. *
  36224. * @sample {highcharts} highcharts/plotoptions/series-dashstyle-all/
  36225. * Possible values demonstrated
  36226. * @sample {highcharts} highcharts/plotoptions/series-dashstyle/
  36227. * Chart suitable for printing in black and white
  36228. * @sample {highstock} highcharts/plotoptions/series-dashstyle-all/
  36229. * Possible values demonstrated
  36230. * @sample {highmaps} highcharts/plotoptions/series-dashstyle-all/
  36231. * Possible values demonstrated
  36232. * @sample {highmaps} maps/plotoptions/series-dashstyle/
  36233. * Dotted borders on a map
  36234. *
  36235. * @type {Highcharts.DashStyleValue}
  36236. * @default Solid
  36237. * @since 2.1
  36238. * @apioption plotOptions.series.dashStyle
  36239. */
  36240. /**
  36241. * A description of the series to add to the screen reader information
  36242. * about the series.
  36243. *
  36244. * @type {string}
  36245. * @since 5.0.0
  36246. * @requires modules/accessibility
  36247. * @apioption plotOptions.series.description
  36248. */
  36249. /**
  36250. * Options for the series data sorting.
  36251. *
  36252. * @type {Highcharts.DataSortingOptionsObject}
  36253. * @since 8.0.0
  36254. * @product highcharts highstock
  36255. * @apioption plotOptions.series.dataSorting
  36256. */
  36257. /**
  36258. * Enable or disable data sorting for the series. Use [xAxis.reversed](
  36259. * #xAxis.reversed) to change the sorting order.
  36260. *
  36261. * @sample {highcharts} highcharts/datasorting/animation/
  36262. * Data sorting in scatter-3d
  36263. * @sample {highcharts} highcharts/datasorting/labels-animation/
  36264. * Axis labels animation
  36265. * @sample {highcharts} highcharts/datasorting/dependent-sorting/
  36266. * Dependent series sorting
  36267. * @sample {highcharts} highcharts/datasorting/independent-sorting/
  36268. * Independent series sorting
  36269. *
  36270. * @type {boolean}
  36271. * @since 8.0.0
  36272. * @apioption plotOptions.series.dataSorting.enabled
  36273. */
  36274. /**
  36275. * Whether to allow matching points by name in an update. If this option
  36276. * is disabled, points will be matched by order.
  36277. *
  36278. * @sample {highcharts} highcharts/datasorting/match-by-name/
  36279. * Enabled match by name
  36280. *
  36281. * @type {boolean}
  36282. * @since 8.0.0
  36283. * @apioption plotOptions.series.dataSorting.matchByName
  36284. */
  36285. /**
  36286. * Determines what data value should be used to sort by.
  36287. *
  36288. * @sample {highcharts} highcharts/datasorting/sort-key/
  36289. * Sort key as `z` value
  36290. *
  36291. * @type {string}
  36292. * @since 8.0.0
  36293. * @default y
  36294. * @apioption plotOptions.series.dataSorting.sortKey
  36295. */
  36296. /**
  36297. * Enable or disable the mouse tracking for a specific series. This
  36298. * includes point tooltips and click events on graphs and points. For
  36299. * large datasets it improves performance.
  36300. *
  36301. * @sample {highcharts} highcharts/plotoptions/series-enablemousetracking-false/
  36302. * No mouse tracking
  36303. * @sample {highmaps} maps/plotoptions/series-enablemousetracking-false/
  36304. * No mouse tracking
  36305. *
  36306. * @type {boolean}
  36307. * @default true
  36308. * @apioption plotOptions.series.enableMouseTracking
  36309. */
  36310. /**
  36311. * Whether to use the Y extremes of the total chart width or only the
  36312. * zoomed area when zooming in on parts of the X axis. By default, the
  36313. * Y axis adjusts to the min and max of the visible data. Cartesian
  36314. * series only.
  36315. *
  36316. * @type {boolean}
  36317. * @default false
  36318. * @since 4.1.6
  36319. * @product highcharts highstock gantt
  36320. * @apioption plotOptions.series.getExtremesFromAll
  36321. */
  36322. /**
  36323. * An array specifying which option maps to which key in the data point
  36324. * array. This makes it convenient to work with unstructured data arrays
  36325. * from different sources.
  36326. *
  36327. * @see [series.data](#series.line.data)
  36328. *
  36329. * @sample {highcharts|highstock} highcharts/series/data-keys/
  36330. * An extended data array with keys
  36331. * @sample {highcharts|highstock} highcharts/series/data-nested-keys/
  36332. * Nested keys used to access object properties
  36333. *
  36334. * @type {Array<string>}
  36335. * @since 4.1.6
  36336. * @apioption plotOptions.series.keys
  36337. */
  36338. /**
  36339. * The line cap used for line ends and line joins on the graph.
  36340. *
  36341. * @type {Highcharts.SeriesLinecapValue}
  36342. * @default round
  36343. * @product highcharts highstock
  36344. * @apioption plotOptions.series.linecap
  36345. */
  36346. /**
  36347. * The [id](#series.id) of another series to link to. Additionally,
  36348. * the value can be ":previous" to link to the previous series. When
  36349. * two series are linked, only the first one appears in the legend.
  36350. * Toggling the visibility of this also toggles the linked series.
  36351. *
  36352. * If master series uses data sorting and linked series does not have
  36353. * its own sorting definition, the linked series will be sorted in the
  36354. * same order as the master one.
  36355. *
  36356. * @sample {highcharts|highstock} highcharts/demo/arearange-line/
  36357. * Linked series
  36358. *
  36359. * @type {string}
  36360. * @since 3.0
  36361. * @product highcharts highstock gantt
  36362. * @apioption plotOptions.series.linkedTo
  36363. */
  36364. /**
  36365. * Options for the corresponding navigator series if `showInNavigator`
  36366. * is `true` for this series. Available options are the same as any
  36367. * series, documented at [plotOptions](#plotOptions.series) and
  36368. * [series](#series).
  36369. *
  36370. * These options are merged with options in [navigator.series](
  36371. * #navigator.series), and will take precedence if the same option is
  36372. * defined both places.
  36373. *
  36374. * @see [navigator.series](#navigator.series)
  36375. *
  36376. * @type {Highcharts.PlotSeriesOptions}
  36377. * @since 5.0.0
  36378. * @product highstock
  36379. * @apioption plotOptions.series.navigatorOptions
  36380. */
  36381. /**
  36382. * The color for the parts of the graph or points that are below the
  36383. * [threshold](#plotOptions.series.threshold). Note that `zones` takes
  36384. * precedence over the negative color. Using `negativeColor` is
  36385. * equivalent to applying a zone with value of 0.
  36386. *
  36387. * @see In styled mode, a negative color is applied by setting this option
  36388. * to `true` combined with the `.highcharts-negative` class name.
  36389. *
  36390. * @sample {highcharts} highcharts/plotoptions/series-negative-color/
  36391. * Spline, area and column
  36392. * @sample {highcharts} highcharts/plotoptions/arearange-negativecolor/
  36393. * Arearange
  36394. * @sample {highcharts} highcharts/css/series-negative-color/
  36395. * Styled mode
  36396. * @sample {highstock} highcharts/plotoptions/series-negative-color/
  36397. * Spline, area and column
  36398. * @sample {highstock} highcharts/plotoptions/arearange-negativecolor/
  36399. * Arearange
  36400. * @sample {highmaps} highcharts/plotoptions/series-negative-color/
  36401. * Spline, area and column
  36402. * @sample {highmaps} highcharts/plotoptions/arearange-negativecolor/
  36403. * Arearange
  36404. *
  36405. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  36406. * @since 3.0
  36407. * @apioption plotOptions.series.negativeColor
  36408. */
  36409. /**
  36410. * Same as
  36411. * [accessibility.pointDescriptionFormatter](#accessibility.pointDescriptionFormatter),
  36412. * but for an individual series. Overrides the chart wide configuration.
  36413. *
  36414. * @type {Function}
  36415. * @since 5.0.12
  36416. * @apioption plotOptions.series.pointDescriptionFormatter
  36417. */
  36418. /**
  36419. * If no x values are given for the points in a series, `pointInterval`
  36420. * defines the interval of the x values. For example, if a series
  36421. * contains one value every decade starting from year 0, set
  36422. * `pointInterval` to `10`. In true `datetime` axes, the `pointInterval`
  36423. * is set in milliseconds.
  36424. *
  36425. * It can be also be combined with `pointIntervalUnit` to draw irregular
  36426. * time intervals.
  36427. *
  36428. * Please note that this options applies to the _series data_, not the
  36429. * interval of the axis ticks, which is independent.
  36430. *
  36431. * @sample {highcharts} highcharts/plotoptions/series-pointstart-datetime/
  36432. * Datetime X axis
  36433. * @sample {highstock} stock/plotoptions/pointinterval-pointstart/
  36434. * Using pointStart and pointInterval
  36435. *
  36436. * @type {number}
  36437. * @default 1
  36438. * @product highcharts highstock gantt
  36439. * @apioption plotOptions.series.pointInterval
  36440. */
  36441. /**
  36442. * On datetime series, this allows for setting the
  36443. * [pointInterval](#plotOptions.series.pointInterval) to irregular time
  36444. * units, `day`, `month` and `year`. A day is usually the same as 24
  36445. * hours, but `pointIntervalUnit` also takes the DST crossover into
  36446. * consideration when dealing with local time. Combine this option with
  36447. * `pointInterval` to draw weeks, quarters, 6 months, 10 years etc.
  36448. *
  36449. * Please note that this options applies to the _series data_, not the
  36450. * interval of the axis ticks, which is independent.
  36451. *
  36452. * @sample {highcharts} highcharts/plotoptions/series-pointintervalunit/
  36453. * One point a month
  36454. * @sample {highstock} highcharts/plotoptions/series-pointintervalunit/
  36455. * One point a month
  36456. *
  36457. * @type {string}
  36458. * @since 4.1.0
  36459. * @product highcharts highstock gantt
  36460. * @validvalue ["day", "month", "year"]
  36461. * @apioption plotOptions.series.pointIntervalUnit
  36462. */
  36463. /**
  36464. * Possible values: `"on"`, `"between"`, `number`.
  36465. *
  36466. * In a column chart, when pointPlacement is `"on"`, the point will not
  36467. * create any padding of the X axis. In a polar column chart this means
  36468. * that the first column points directly north. If the pointPlacement is
  36469. * `"between"`, the columns will be laid out between ticks. This is
  36470. * useful for example for visualising an amount between two points in
  36471. * time or in a certain sector of a polar chart.
  36472. *
  36473. * Since Highcharts 3.0.2, the point placement can also be numeric,
  36474. * where 0 is on the axis value, -0.5 is between this value and the
  36475. * previous, and 0.5 is between this value and the next. Unlike the
  36476. * textual options, numeric point placement options won't affect axis
  36477. * padding.
  36478. *
  36479. * Note that pointPlacement needs a [pointRange](
  36480. * #plotOptions.series.pointRange) to work. For column series this is
  36481. * computed, but for line-type series it needs to be set.
  36482. *
  36483. * For the `xrange` series type and gantt charts, if the Y axis is a
  36484. * category axis, the `pointPlacement` applies to the Y axis rather than
  36485. * the (typically datetime) X axis.
  36486. *
  36487. * Defaults to `undefined` in cartesian charts, `"between"` in polar
  36488. * charts.
  36489. *
  36490. * @see [xAxis.tickmarkPlacement](#xAxis.tickmarkPlacement)
  36491. *
  36492. * @sample {highcharts|highstock} highcharts/plotoptions/series-pointplacement-between/
  36493. * Between in a column chart
  36494. * @sample {highcharts|highstock} highcharts/plotoptions/series-pointplacement-numeric/
  36495. * Numeric placement for custom layout
  36496. * @sample {highcharts|highstock} maps/plotoptions/heatmap-pointplacement/
  36497. * Placement in heatmap
  36498. *
  36499. * @type {string|number}
  36500. * @since 2.3.0
  36501. * @product highcharts highstock gantt
  36502. * @apioption plotOptions.series.pointPlacement
  36503. */
  36504. /**
  36505. * If no x values are given for the points in a series, pointStart
  36506. * defines on what value to start. For example, if a series contains one
  36507. * yearly value starting from 1945, set pointStart to 1945.
  36508. *
  36509. * @sample {highcharts} highcharts/plotoptions/series-pointstart-linear/
  36510. * Linear
  36511. * @sample {highcharts} highcharts/plotoptions/series-pointstart-datetime/
  36512. * Datetime
  36513. * @sample {highstock} stock/plotoptions/pointinterval-pointstart/
  36514. * Using pointStart and pointInterval
  36515. *
  36516. * @type {number}
  36517. * @default 0
  36518. * @product highcharts highstock gantt
  36519. * @apioption plotOptions.series.pointStart
  36520. */
  36521. /**
  36522. * Whether to select the series initially. If `showCheckbox` is true,
  36523. * the checkbox next to the series name in the legend will be checked
  36524. * for a selected series.
  36525. *
  36526. * @sample {highcharts} highcharts/plotoptions/series-selected/
  36527. * One out of two series selected
  36528. *
  36529. * @type {boolean}
  36530. * @default false
  36531. * @since 1.2.0
  36532. * @apioption plotOptions.series.selected
  36533. */
  36534. /**
  36535. * Whether to apply a drop shadow to the graph line. Since 2.3 the
  36536. * shadow can be an object configuration containing `color`, `offsetX`,
  36537. * `offsetY`, `opacity` and `width`.
  36538. *
  36539. * @sample {highcharts} highcharts/plotoptions/series-shadow/
  36540. * Shadow enabled
  36541. *
  36542. * @type {boolean|Highcharts.ShadowOptionsObject}
  36543. * @default false
  36544. * @apioption plotOptions.series.shadow
  36545. */
  36546. /**
  36547. * Whether to display this particular series or series type in the
  36548. * legend. Standalone series are shown in legend by default, and linked
  36549. * series are not. Since v7.2.0 it is possible to show series that use
  36550. * colorAxis by setting this option to `true`.
  36551. *
  36552. * @sample {highcharts} highcharts/plotoptions/series-showinlegend/
  36553. * One series in the legend, one hidden
  36554. *
  36555. * @type {boolean}
  36556. * @apioption plotOptions.series.showInLegend
  36557. */
  36558. /**
  36559. * Whether or not to show the series in the navigator. Takes precedence
  36560. * over [navigator.baseSeries](#navigator.baseSeries) if defined.
  36561. *
  36562. * @type {boolean}
  36563. * @since 5.0.0
  36564. * @product highstock
  36565. * @apioption plotOptions.series.showInNavigator
  36566. */
  36567. /**
  36568. * If set to `true`, the accessibility module will skip past the points
  36569. * in this series for keyboard navigation.
  36570. *
  36571. * @type {boolean}
  36572. * @since 5.0.12
  36573. * @apioption plotOptions.series.skipKeyboardNavigation
  36574. */
  36575. /**
  36576. * Whether to stack the values of each series on top of each other.
  36577. * Possible values are `undefined` to disable, `"normal"` to stack by
  36578. * value or `"percent"`.
  36579. *
  36580. * When stacking is enabled, data must be sorted
  36581. * in ascending X order.
  36582. *
  36583. * Some stacking options are related to specific series types. In the
  36584. * streamgraph series type, the stacking option is set to `"stream"`.
  36585. * The second one is `"overlap"`, which only applies to waterfall
  36586. * series.
  36587. *
  36588. * @see [yAxis.reversedStacks](#yAxis.reversedStacks)
  36589. *
  36590. * @sample {highcharts} highcharts/plotoptions/series-stacking-line/
  36591. * Line
  36592. * @sample {highcharts} highcharts/plotoptions/series-stacking-column/
  36593. * Column
  36594. * @sample {highcharts} highcharts/plotoptions/series-stacking-bar/
  36595. * Bar
  36596. * @sample {highcharts} highcharts/plotoptions/series-stacking-area/
  36597. * Area
  36598. * @sample {highcharts} highcharts/plotoptions/series-stacking-percent-line/
  36599. * Line
  36600. * @sample {highcharts} highcharts/plotoptions/series-stacking-percent-column/
  36601. * Column
  36602. * @sample {highcharts} highcharts/plotoptions/series-stacking-percent-bar/
  36603. * Bar
  36604. * @sample {highcharts} highcharts/plotoptions/series-stacking-percent-area/
  36605. * Area
  36606. * @sample {highcharts} highcharts/plotoptions/series-waterfall-with-normal-stacking
  36607. * Waterfall with normal stacking
  36608. * @sample {highcharts} highcharts/plotoptions/series-waterfall-with-overlap-stacking
  36609. * Waterfall with overlap stacking
  36610. * @sample {highstock} stock/plotoptions/stacking/
  36611. * Area
  36612. *
  36613. * @type {string}
  36614. * @product highcharts highstock
  36615. * @validvalue ["normal", "overlap", "percent", "stream"]
  36616. * @apioption plotOptions.series.stacking
  36617. */
  36618. /**
  36619. * Whether to apply steps to the line. Possible values are `left`,
  36620. * `center` and `right`.
  36621. *
  36622. * @sample {highcharts} highcharts/plotoptions/line-step/
  36623. * Different step line options
  36624. * @sample {highcharts} highcharts/plotoptions/area-step/
  36625. * Stepped, stacked area
  36626. * @sample {highstock} stock/plotoptions/line-step/
  36627. * Step line
  36628. *
  36629. * @type {string}
  36630. * @since 1.2.5
  36631. * @product highcharts highstock
  36632. * @validvalue ["left", "center", "right"]
  36633. * @apioption plotOptions.series.step
  36634. */
  36635. /**
  36636. * The threshold, also called zero level or base level. For line type
  36637. * series this is only used in conjunction with
  36638. * [negativeColor](#plotOptions.series.negativeColor).
  36639. *
  36640. * @see [softThreshold](#plotOptions.series.softThreshold).
  36641. *
  36642. * @type {number|null}
  36643. * @default 0
  36644. * @since 3.0
  36645. * @product highcharts highstock
  36646. * @apioption plotOptions.series.threshold
  36647. */
  36648. /**
  36649. * Set the initial visibility of the series.
  36650. *
  36651. * @sample {highcharts} highcharts/plotoptions/series-visible/
  36652. * Two series, one hidden and one visible
  36653. * @sample {highstock} stock/plotoptions/series-visibility/
  36654. * Hidden series
  36655. *
  36656. * @type {boolean}
  36657. * @default true
  36658. * @apioption plotOptions.series.visible
  36659. */
  36660. /**
  36661. * Defines the Axis on which the zones are applied.
  36662. *
  36663. * @see [zones](#plotOptions.series.zones)
  36664. *
  36665. * @sample {highcharts} highcharts/series/color-zones-zoneaxis-x/
  36666. * Zones on the X-Axis
  36667. * @sample {highstock} highcharts/series/color-zones-zoneaxis-x/
  36668. * Zones on the X-Axis
  36669. *
  36670. * @type {string}
  36671. * @default y
  36672. * @since 4.1.0
  36673. * @product highcharts highstock
  36674. * @apioption plotOptions.series.zoneAxis
  36675. */
  36676. /**
  36677. * General event handlers for the series items. These event hooks can
  36678. * also be attached to the series at run time using the
  36679. * `Highcharts.addEvent` function.
  36680. *
  36681. * @declare Highcharts.SeriesEventsOptionsObject
  36682. *
  36683. * @private
  36684. */
  36685. events: {},
  36686. /**
  36687. * Fires after the series has finished its initial animation, or in case
  36688. * animation is disabled, immediately as the series is displayed.
  36689. *
  36690. * @sample {highcharts} highcharts/plotoptions/series-events-afteranimate/
  36691. * Show label after animate
  36692. * @sample {highstock} highcharts/plotoptions/series-events-afteranimate/
  36693. * Show label after animate
  36694. *
  36695. * @type {Highcharts.SeriesAfterAnimateCallbackFunction}
  36696. * @since 4.0
  36697. * @product highcharts highstock gantt
  36698. * @context Highcharts.Series
  36699. * @apioption plotOptions.series.events.afterAnimate
  36700. */
  36701. /**
  36702. * Fires when the checkbox next to the series' name in the legend is
  36703. * clicked. One parameter, `event`, is passed to the function. The state
  36704. * of the checkbox is found by `event.checked`. The checked item is
  36705. * found by `event.item`. Return `false` to prevent the default action
  36706. * which is to toggle the select state of the series.
  36707. *
  36708. * @sample {highcharts} highcharts/plotoptions/series-events-checkboxclick/
  36709. * Alert checkbox status
  36710. *
  36711. * @type {Highcharts.SeriesCheckboxClickCallbackFunction}
  36712. * @since 1.2.0
  36713. * @context Highcharts.Series
  36714. * @apioption plotOptions.series.events.checkboxClick
  36715. */
  36716. /**
  36717. * Fires when the series is clicked. One parameter, `event`, is passed
  36718. * to the function, containing common event information. Additionally,
  36719. * `event.point` holds a pointer to the nearest point on the graph.
  36720. *
  36721. * @sample {highcharts} highcharts/plotoptions/series-events-click/
  36722. * Alert click info
  36723. * @sample {highstock} stock/plotoptions/series-events-click/
  36724. * Alert click info
  36725. * @sample {highmaps} maps/plotoptions/series-events-click/
  36726. * Display click info in subtitle
  36727. *
  36728. * @type {Highcharts.SeriesClickCallbackFunction}
  36729. * @context Highcharts.Series
  36730. * @apioption plotOptions.series.events.click
  36731. */
  36732. /**
  36733. * Fires when the series is hidden after chart generation time, either
  36734. * by clicking the legend item or by calling `.hide()`.
  36735. *
  36736. * @sample {highcharts} highcharts/plotoptions/series-events-hide/
  36737. * Alert when the series is hidden by clicking the legend item
  36738. *
  36739. * @type {Highcharts.SeriesHideCallbackFunction}
  36740. * @since 1.2.0
  36741. * @context Highcharts.Series
  36742. * @apioption plotOptions.series.events.hide
  36743. */
  36744. /**
  36745. * Fires when the legend item belonging to the series is clicked. One
  36746. * parameter, `event`, is passed to the function. The default action
  36747. * is to toggle the visibility of the series. This can be prevented
  36748. * by returning `false` or calling `event.preventDefault()`.
  36749. *
  36750. * @sample {highcharts} highcharts/plotoptions/series-events-legenditemclick/
  36751. * Confirm hiding and showing
  36752. *
  36753. * @type {Highcharts.SeriesLegendItemClickCallbackFunction}
  36754. * @context Highcharts.Series
  36755. * @apioption plotOptions.series.events.legendItemClick
  36756. */
  36757. /**
  36758. * Fires when the mouse leaves the graph. One parameter, `event`, is
  36759. * passed to the function, containing common event information. If the
  36760. * [stickyTracking](#plotOptions.series) option is true, `mouseOut`
  36761. * doesn't happen before the mouse enters another graph or leaves the
  36762. * plot area.
  36763. *
  36764. * @sample {highcharts} highcharts/plotoptions/series-events-mouseover-sticky/
  36765. * With sticky tracking by default
  36766. * @sample {highcharts} highcharts/plotoptions/series-events-mouseover-no-sticky/
  36767. * Without sticky tracking
  36768. *
  36769. * @type {Highcharts.SeriesMouseOutCallbackFunction}
  36770. * @context Highcharts.Series
  36771. * @apioption plotOptions.series.events.mouseOut
  36772. */
  36773. /**
  36774. * Fires when the mouse enters the graph. One parameter, `event`, is
  36775. * passed to the function, containing common event information.
  36776. *
  36777. * @sample {highcharts} highcharts/plotoptions/series-events-mouseover-sticky/
  36778. * With sticky tracking by default
  36779. * @sample {highcharts} highcharts/plotoptions/series-events-mouseover-no-sticky/
  36780. * Without sticky tracking
  36781. *
  36782. * @type {Highcharts.SeriesMouseOverCallbackFunction}
  36783. * @context Highcharts.Series
  36784. * @apioption plotOptions.series.events.mouseOver
  36785. */
  36786. /**
  36787. * Fires when the series is shown after chart generation time, either
  36788. * by clicking the legend item or by calling `.show()`.
  36789. *
  36790. * @sample {highcharts} highcharts/plotoptions/series-events-show/
  36791. * Alert when the series is shown by clicking the legend item.
  36792. *
  36793. * @type {Highcharts.SeriesShowCallbackFunction}
  36794. * @since 1.2.0
  36795. * @context Highcharts.Series
  36796. * @apioption plotOptions.series.events.show
  36797. */
  36798. /**
  36799. * Options for the point markers of line-like series. Properties like
  36800. * `fillColor`, `lineColor` and `lineWidth` define the visual appearance
  36801. * of the markers. Other series types, like column series, don't have
  36802. * markers, but have visual options on the series level instead.
  36803. *
  36804. * In styled mode, the markers can be styled with the
  36805. * `.highcharts-point`, `.highcharts-point-hover` and
  36806. * `.highcharts-point-select` class names.
  36807. *
  36808. * @declare Highcharts.PointMarkerOptionsObject
  36809. *
  36810. * @private
  36811. */
  36812. marker: {
  36813. /**
  36814. * Enable or disable the point marker. If `undefined`, the markers
  36815. * are hidden when the data is dense, and shown for more widespread
  36816. * data points.
  36817. *
  36818. * @sample {highcharts} highcharts/plotoptions/series-marker-enabled/
  36819. * Disabled markers
  36820. * @sample {highcharts} highcharts/plotoptions/series-marker-enabled-false/
  36821. * Disabled in normal state but enabled on hover
  36822. * @sample {highstock} stock/plotoptions/series-marker/
  36823. * Enabled markers
  36824. *
  36825. * @type {boolean}
  36826. * @default {highcharts} undefined
  36827. * @default {highstock} false
  36828. * @apioption plotOptions.series.marker.enabled
  36829. */
  36830. /**
  36831. * The threshold for how dense the point markers should be before
  36832. * they are hidden, given that `enabled` is not defined. The number
  36833. * indicates the horizontal distance between the two closest points
  36834. * in the series, as multiples of the `marker.radius`. In other
  36835. * words, the default value of 2 means points are hidden if
  36836. * overlapping horizontally.
  36837. *
  36838. * @sample highcharts/plotoptions/series-marker-enabledthreshold
  36839. * A higher threshold
  36840. *
  36841. * @since 6.0.5
  36842. */
  36843. enabledThreshold: 2,
  36844. /**
  36845. * The fill color of the point marker. When `undefined`, the series'
  36846. * or point's color is used.
  36847. *
  36848. * @sample {highcharts} highcharts/plotoptions/series-marker-fillcolor/
  36849. * White fill
  36850. *
  36851. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  36852. * @apioption plotOptions.series.marker.fillColor
  36853. */
  36854. /**
  36855. * Image markers only. Set the image width explicitly. When using
  36856. * this option, a `width` must also be set.
  36857. *
  36858. * @sample {highcharts} highcharts/plotoptions/series-marker-width-height/
  36859. * Fixed width and height
  36860. * @sample {highstock} highcharts/plotoptions/series-marker-width-height/
  36861. * Fixed width and height
  36862. *
  36863. * @type {number}
  36864. * @since 4.0.4
  36865. * @apioption plotOptions.series.marker.height
  36866. */
  36867. /**
  36868. * The color of the point marker's outline. When `undefined`, the
  36869. * series' or point's color is used.
  36870. *
  36871. * @sample {highcharts} highcharts/plotoptions/series-marker-fillcolor/
  36872. * Inherit from series color (undefined)
  36873. *
  36874. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  36875. */
  36876. lineColor: palette.backgroundColor,
  36877. /**
  36878. * The width of the point marker's outline.
  36879. *
  36880. * @sample {highcharts} highcharts/plotoptions/series-marker-fillcolor/
  36881. * 2px blue marker
  36882. */
  36883. lineWidth: 0,
  36884. /**
  36885. * The radius of the point marker.
  36886. *
  36887. * @sample {highcharts} highcharts/plotoptions/series-marker-radius/
  36888. * Bigger markers
  36889. *
  36890. * @default {highstock} 2
  36891. * @default {highcharts} 4
  36892. *
  36893. */
  36894. radius: 4,
  36895. /**
  36896. * A predefined shape or symbol for the marker. When undefined, the
  36897. * symbol is pulled from options.symbols. Other possible values are
  36898. * `'circle'`, `'square'`,`'diamond'`, `'triangle'` and
  36899. * `'triangle-down'`.
  36900. *
  36901. * Additionally, the URL to a graphic can be given on this form:
  36902. * `'url(graphic.png)'`. Note that for the image to be applied to
  36903. * exported charts, its URL needs to be accessible by the export
  36904. * server.
  36905. *
  36906. * Custom callbacks for symbol path generation can also be added to
  36907. * `Highcharts.SVGRenderer.prototype.symbols`. The callback is then
  36908. * used by its method name, as shown in the demo.
  36909. *
  36910. * @sample {highcharts} highcharts/plotoptions/series-marker-symbol/
  36911. * Predefined, graphic and custom markers
  36912. * @sample {highstock} highcharts/plotoptions/series-marker-symbol/
  36913. * Predefined, graphic and custom markers
  36914. *
  36915. * @type {string}
  36916. * @apioption plotOptions.series.marker.symbol
  36917. */
  36918. /**
  36919. * Image markers only. Set the image width explicitly. When using
  36920. * this option, a `height` must also be set.
  36921. *
  36922. * @sample {highcharts} highcharts/plotoptions/series-marker-width-height/
  36923. * Fixed width and height
  36924. * @sample {highstock} highcharts/plotoptions/series-marker-width-height/
  36925. * Fixed width and height
  36926. *
  36927. * @type {number}
  36928. * @since 4.0.4
  36929. * @apioption plotOptions.series.marker.width
  36930. */
  36931. /**
  36932. * States for a single point marker.
  36933. *
  36934. * @declare Highcharts.PointStatesOptionsObject
  36935. */
  36936. states: {
  36937. /**
  36938. * The normal state of a single point marker. Currently only
  36939. * used for setting animation when returning to normal state
  36940. * from hover.
  36941. *
  36942. * @declare Highcharts.PointStatesNormalOptionsObject
  36943. */
  36944. normal: {
  36945. /**
  36946. * Animation when returning to normal state after hovering.
  36947. *
  36948. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  36949. */
  36950. animation: true
  36951. },
  36952. /**
  36953. * The hover state for a single point marker.
  36954. *
  36955. * @declare Highcharts.PointStatesHoverOptionsObject
  36956. */
  36957. hover: {
  36958. /**
  36959. * Animation when hovering over the marker.
  36960. *
  36961. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  36962. */
  36963. animation: {
  36964. /** @internal */
  36965. duration: 50
  36966. },
  36967. /**
  36968. * Enable or disable the point marker.
  36969. *
  36970. * @sample {highcharts} highcharts/plotoptions/series-marker-states-hover-enabled/
  36971. * Disabled hover state
  36972. */
  36973. enabled: true,
  36974. /**
  36975. * The fill color of the marker in hover state. When
  36976. * `undefined`, the series' or point's fillColor for normal
  36977. * state is used.
  36978. *
  36979. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  36980. * @apioption plotOptions.series.marker.states.hover.fillColor
  36981. */
  36982. /**
  36983. * The color of the point marker's outline. When
  36984. * `undefined`, the series' or point's lineColor for normal
  36985. * state is used.
  36986. *
  36987. * @sample {highcharts} highcharts/plotoptions/series-marker-states-hover-linecolor/
  36988. * White fill color, black line color
  36989. *
  36990. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  36991. * @apioption plotOptions.series.marker.states.hover.lineColor
  36992. */
  36993. /**
  36994. * The width of the point marker's outline. When
  36995. * `undefined`, the series' or point's lineWidth for normal
  36996. * state is used.
  36997. *
  36998. * @sample {highcharts} highcharts/plotoptions/series-marker-states-hover-linewidth/
  36999. * 3px line width
  37000. *
  37001. * @type {number}
  37002. * @apioption plotOptions.series.marker.states.hover.lineWidth
  37003. */
  37004. /**
  37005. * The radius of the point marker. In hover state, it
  37006. * defaults to the normal state's radius + 2 as per the
  37007. * [radiusPlus](#plotOptions.series.marker.states.hover.radiusPlus)
  37008. * option.
  37009. *
  37010. * @sample {highcharts} highcharts/plotoptions/series-marker-states-hover-radius/
  37011. * 10px radius
  37012. *
  37013. * @type {number}
  37014. * @apioption plotOptions.series.marker.states.hover.radius
  37015. */
  37016. /**
  37017. * The number of pixels to increase the radius of the
  37018. * hovered point.
  37019. *
  37020. * @sample {highcharts} highcharts/plotoptions/series-states-hover-linewidthplus/
  37021. * 5 pixels greater radius on hover
  37022. * @sample {highstock} highcharts/plotoptions/series-states-hover-linewidthplus/
  37023. * 5 pixels greater radius on hover
  37024. *
  37025. * @since 4.0.3
  37026. */
  37027. radiusPlus: 2,
  37028. /**
  37029. * The additional line width for a hovered point.
  37030. *
  37031. * @sample {highcharts} highcharts/plotoptions/series-states-hover-linewidthplus/
  37032. * 2 pixels wider on hover
  37033. * @sample {highstock} highcharts/plotoptions/series-states-hover-linewidthplus/
  37034. * 2 pixels wider on hover
  37035. *
  37036. * @since 4.0.3
  37037. */
  37038. lineWidthPlus: 1
  37039. },
  37040. /**
  37041. * The appearance of the point marker when selected. In order to
  37042. * allow a point to be selected, set the
  37043. * `series.allowPointSelect` option to true.
  37044. *
  37045. * @declare Highcharts.PointStatesSelectOptionsObject
  37046. */
  37047. select: {
  37048. /**
  37049. * Enable or disable visible feedback for selection.
  37050. *
  37051. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-enabled/
  37052. * Disabled select state
  37053. *
  37054. * @type {boolean}
  37055. * @default true
  37056. * @apioption plotOptions.series.marker.states.select.enabled
  37057. */
  37058. /**
  37059. * The radius of the point marker. In hover state, it
  37060. * defaults to the normal state's radius + 2.
  37061. *
  37062. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-radius/
  37063. * 10px radius for selected points
  37064. *
  37065. * @type {number}
  37066. * @apioption plotOptions.series.marker.states.select.radius
  37067. */
  37068. /**
  37069. * The fill color of the point marker.
  37070. *
  37071. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-fillcolor/
  37072. * Solid red discs for selected points
  37073. *
  37074. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  37075. */
  37076. fillColor: palette.neutralColor20,
  37077. /**
  37078. * The color of the point marker's outline. When
  37079. * `undefined`, the series' or point's color is used.
  37080. *
  37081. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-linecolor/
  37082. * Red line color for selected points
  37083. *
  37084. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  37085. */
  37086. lineColor: palette.neutralColor100,
  37087. /**
  37088. * The width of the point marker's outline.
  37089. *
  37090. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-linewidth/
  37091. * 3px line width for selected points
  37092. */
  37093. lineWidth: 2
  37094. }
  37095. }
  37096. },
  37097. /**
  37098. * Properties for each single point.
  37099. *
  37100. * @declare Highcharts.PlotSeriesPointOptions
  37101. *
  37102. * @private
  37103. */
  37104. point: {
  37105. /**
  37106. * Fires when a point is clicked. One parameter, `event`, is passed
  37107. * to the function, containing common event information.
  37108. *
  37109. * If the `series.allowPointSelect` option is true, the default
  37110. * action for the point's click event is to toggle the point's
  37111. * select state. Returning `false` cancels this action.
  37112. *
  37113. * @sample {highcharts} highcharts/plotoptions/series-point-events-click/
  37114. * Click marker to alert values
  37115. * @sample {highcharts} highcharts/plotoptions/series-point-events-click-column/
  37116. * Click column
  37117. * @sample {highcharts} highcharts/plotoptions/series-point-events-click-url/
  37118. * Go to URL
  37119. * @sample {highmaps} maps/plotoptions/series-point-events-click/
  37120. * Click marker to display values
  37121. * @sample {highmaps} maps/plotoptions/series-point-events-click-url/
  37122. * Go to URL
  37123. *
  37124. * @type {Highcharts.PointClickCallbackFunction}
  37125. * @context Highcharts.Point
  37126. * @apioption plotOptions.series.point.events.click
  37127. */
  37128. /**
  37129. * Fires when the mouse leaves the area close to the point. One
  37130. * parameter, `event`, is passed to the function, containing common
  37131. * event information.
  37132. *
  37133. * @sample {highcharts} highcharts/plotoptions/series-point-events-mouseover/
  37134. * Show values in the chart's corner on mouse over
  37135. *
  37136. * @type {Highcharts.PointMouseOutCallbackFunction}
  37137. * @context Highcharts.Point
  37138. * @apioption plotOptions.series.point.events.mouseOut
  37139. */
  37140. /**
  37141. * Fires when the mouse enters the area close to the point. One
  37142. * parameter, `event`, is passed to the function, containing common
  37143. * event information.
  37144. *
  37145. * @sample {highcharts} highcharts/plotoptions/series-point-events-mouseover/
  37146. * Show values in the chart's corner on mouse over
  37147. *
  37148. * @type {Highcharts.PointMouseOverCallbackFunction}
  37149. * @context Highcharts.Point
  37150. * @apioption plotOptions.series.point.events.mouseOver
  37151. */
  37152. /**
  37153. * Fires when the point is removed using the `.remove()` method. One
  37154. * parameter, `event`, is passed to the function. Returning `false`
  37155. * cancels the operation.
  37156. *
  37157. * @sample {highcharts} highcharts/plotoptions/series-point-events-remove/
  37158. * Remove point and confirm
  37159. *
  37160. * @type {Highcharts.PointRemoveCallbackFunction}
  37161. * @since 1.2.0
  37162. * @context Highcharts.Point
  37163. * @apioption plotOptions.series.point.events.remove
  37164. */
  37165. /**
  37166. * Fires when the point is selected either programmatically or
  37167. * following a click on the point. One parameter, `event`, is passed
  37168. * to the function. Returning `false` cancels the operation.
  37169. *
  37170. * @sample {highcharts} highcharts/plotoptions/series-point-events-select/
  37171. * Report the last selected point
  37172. * @sample {highmaps} maps/plotoptions/series-allowpointselect/
  37173. * Report select and unselect
  37174. *
  37175. * @type {Highcharts.PointSelectCallbackFunction}
  37176. * @since 1.2.0
  37177. * @context Highcharts.Point
  37178. * @apioption plotOptions.series.point.events.select
  37179. */
  37180. /**
  37181. * Fires when the point is unselected either programmatically or
  37182. * following a click on the point. One parameter, `event`, is passed
  37183. * to the function.
  37184. * Returning `false` cancels the operation.
  37185. *
  37186. * @sample {highcharts} highcharts/plotoptions/series-point-events-unselect/
  37187. * Report the last unselected point
  37188. * @sample {highmaps} maps/plotoptions/series-allowpointselect/
  37189. * Report select and unselect
  37190. *
  37191. * @type {Highcharts.PointUnselectCallbackFunction}
  37192. * @since 1.2.0
  37193. * @context Highcharts.Point
  37194. * @apioption plotOptions.series.point.events.unselect
  37195. */
  37196. /**
  37197. * Fires when the point is updated programmatically through the
  37198. * `.update()` method. One parameter, `event`, is passed to the
  37199. * function. The new point options can be accessed through
  37200. * `event.options`. Returning `false` cancels the operation.
  37201. *
  37202. * @sample {highcharts} highcharts/plotoptions/series-point-events-update/
  37203. * Confirm point updating
  37204. *
  37205. * @type {Highcharts.PointUpdateCallbackFunction}
  37206. * @since 1.2.0
  37207. * @context Highcharts.Point
  37208. * @apioption plotOptions.series.point.events.update
  37209. */
  37210. /**
  37211. * Events for each single point.
  37212. *
  37213. * @declare Highcharts.PointEventsOptionsObject
  37214. */
  37215. events: {}
  37216. },
  37217. /**
  37218. * Options for the series data labels, appearing next to each data
  37219. * point.
  37220. *
  37221. * Since v6.2.0, multiple data labels can be applied to each single
  37222. * point by defining them as an array of configs.
  37223. *
  37224. * In styled mode, the data labels can be styled with the
  37225. * `.highcharts-data-label-box` and `.highcharts-data-label` class names
  37226. * ([see example](https://www.highcharts.com/samples/highcharts/css/series-datalabels)).
  37227. *
  37228. * @sample {highcharts} highcharts/plotoptions/series-datalabels-enabled
  37229. * Data labels enabled
  37230. * @sample {highcharts} highcharts/plotoptions/series-datalabels-multiple
  37231. * Multiple data labels on a bar series
  37232. * @sample {highcharts} highcharts/css/series-datalabels
  37233. * Style mode example
  37234. *
  37235. * @type {*|Array<*>}
  37236. * @product highcharts highstock highmaps gantt
  37237. *
  37238. * @private
  37239. */
  37240. dataLabels: {
  37241. /**
  37242. * Enable or disable the initial animation when a series is
  37243. * displayed for the `dataLabels`. The animation can also be set as
  37244. * a configuration object. Please note that this option only
  37245. * applies to the initial animation.
  37246. * For other animations, see [chart.animation](#chart.animation)
  37247. * and the animation parameter under the API methods.
  37248. * The following properties are supported:
  37249. *
  37250. * - `defer`: The animation delay time in milliseconds.
  37251. *
  37252. * @sample {highcharts} highcharts/plotoptions/animation-defer/
  37253. * Animation defer settings
  37254. *
  37255. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  37256. * @since 8.2.0
  37257. * @apioption plotOptions.series.dataLabels.animation
  37258. */
  37259. animation: {},
  37260. /**
  37261. * The animation delay time in milliseconds.
  37262. * Set to `0` renders dataLabel immediately.
  37263. * As `undefined` inherits defer time from the [series.animation.defer](#plotOptions.series.animation.defer).
  37264. *
  37265. * @type {number}
  37266. * @since 8.2.0
  37267. * @apioption plotOptions.series.dataLabels.animation.defer
  37268. */
  37269. /**
  37270. * The alignment of the data label compared to the point. If
  37271. * `right`, the right side of the label should be touching the
  37272. * point. For points with an extent, like columns, the alignments
  37273. * also dictates how to align it inside the box, as given with the
  37274. * [inside](#plotOptions.column.dataLabels.inside)
  37275. * option. Can be one of `left`, `center` or `right`.
  37276. *
  37277. * @sample {highcharts} highcharts/plotoptions/series-datalabels-align-left/
  37278. * Left aligned
  37279. * @sample {highcharts} highcharts/plotoptions/bar-datalabels-align-inside-bar/
  37280. * Data labels inside the bar
  37281. *
  37282. * @type {Highcharts.AlignValue|null}
  37283. */
  37284. align: 'center',
  37285. /**
  37286. * Whether to allow data labels to overlap. To make the labels less
  37287. * sensitive for overlapping, the
  37288. * [dataLabels.padding](#plotOptions.series.dataLabels.padding)
  37289. * can be set to 0.
  37290. *
  37291. * @sample {highcharts} highcharts/plotoptions/series-datalabels-allowoverlap-false/
  37292. * Don't allow overlap
  37293. *
  37294. * @type {boolean}
  37295. * @default false
  37296. * @since 4.1.0
  37297. * @apioption plotOptions.series.dataLabels.allowOverlap
  37298. */
  37299. /**
  37300. * The background color or gradient for the data label.
  37301. *
  37302. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  37303. * Data labels box options
  37304. * @sample {highmaps} maps/plotoptions/series-datalabels-box/
  37305. * Data labels box options
  37306. *
  37307. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  37308. * @since 2.2.1
  37309. * @apioption plotOptions.series.dataLabels.backgroundColor
  37310. */
  37311. /**
  37312. * The border color for the data label. Defaults to `undefined`.
  37313. *
  37314. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  37315. * Data labels box options
  37316. *
  37317. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  37318. * @since 2.2.1
  37319. * @apioption plotOptions.series.dataLabels.borderColor
  37320. */
  37321. /**
  37322. * The border radius in pixels for the data label.
  37323. *
  37324. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  37325. * Data labels box options
  37326. * @sample {highmaps} maps/plotoptions/series-datalabels-box/
  37327. * Data labels box options
  37328. *
  37329. * @type {number}
  37330. * @default 0
  37331. * @since 2.2.1
  37332. * @apioption plotOptions.series.dataLabels.borderRadius
  37333. */
  37334. /**
  37335. * The border width in pixels for the data label.
  37336. *
  37337. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  37338. * Data labels box options
  37339. *
  37340. * @type {number}
  37341. * @default 0
  37342. * @since 2.2.1
  37343. * @apioption plotOptions.series.dataLabels.borderWidth
  37344. */
  37345. /**
  37346. * A class name for the data label. Particularly in styled mode,
  37347. * this can be used to give each series' or point's data label
  37348. * unique styling. In addition to this option, a default color class
  37349. * name is added so that we can give the labels a contrast text
  37350. * shadow.
  37351. *
  37352. * @sample {highcharts} highcharts/css/data-label-contrast/
  37353. * Contrast text shadow
  37354. * @sample {highcharts} highcharts/css/series-datalabels/
  37355. * Styling by CSS
  37356. *
  37357. * @type {string}
  37358. * @since 5.0.0
  37359. * @apioption plotOptions.series.dataLabels.className
  37360. */
  37361. /**
  37362. * The text color for the data labels. Defaults to `undefined`. For
  37363. * certain series types, like column or map, the data labels can be
  37364. * drawn inside the points. In this case the data label will be
  37365. * drawn with maximum contrast by default. Additionally, it will be
  37366. * given a `text-outline` style with the opposite color, to further
  37367. * increase the contrast. This can be overridden by setting the
  37368. * `text-outline` style to `none` in the `dataLabels.style` option.
  37369. *
  37370. * @sample {highcharts} highcharts/plotoptions/series-datalabels-color/
  37371. * Red data labels
  37372. * @sample {highmaps} maps/demo/color-axis/
  37373. * White data labels
  37374. *
  37375. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  37376. * @apioption plotOptions.series.dataLabels.color
  37377. */
  37378. /**
  37379. * Whether to hide data labels that are outside the plot area. By
  37380. * default, the data label is moved inside the plot area according
  37381. * to the
  37382. * [overflow](#plotOptions.series.dataLabels.overflow)
  37383. * option.
  37384. *
  37385. * @type {boolean}
  37386. * @default true
  37387. * @since 2.3.3
  37388. * @apioption plotOptions.series.dataLabels.crop
  37389. */
  37390. /**
  37391. * Whether to defer displaying the data labels until the initial
  37392. * series animation has finished. Setting to `false` renders the
  37393. * data label immediately. If set to `true` inherits the defer
  37394. * time set in [plotOptions.series.animation](#plotOptions.series.animation).
  37395. * If set to a number, a defer time is specified in milliseconds.
  37396. *
  37397. * @sample highcharts/plotoptions/animation-defer
  37398. * Set defer time
  37399. *
  37400. * @since 4.0.0
  37401. * @type {boolean|number}
  37402. * @product highcharts highstock gantt
  37403. */
  37404. defer: true,
  37405. /**
  37406. * Enable or disable the data labels.
  37407. *
  37408. * @sample {highcharts} highcharts/plotoptions/series-datalabels-enabled/
  37409. * Data labels enabled
  37410. * @sample {highmaps} maps/demo/color-axis/
  37411. * Data labels enabled
  37412. *
  37413. * @type {boolean}
  37414. * @default false
  37415. * @apioption plotOptions.series.dataLabels.enabled
  37416. */
  37417. /**
  37418. * A declarative filter to control of which data labels to display.
  37419. * The declarative filter is designed for use when callback
  37420. * functions are not available, like when the chart options require
  37421. * a pure JSON structure or for use with graphical editors. For
  37422. * programmatic control, use the `formatter` instead, and return
  37423. * `undefined` to disable a single data label.
  37424. *
  37425. * @example
  37426. * filter: {
  37427. * property: 'percentage',
  37428. * operator: '>',
  37429. * value: 4
  37430. * }
  37431. *
  37432. * @sample {highcharts} highcharts/demo/pie-monochrome
  37433. * Data labels filtered by percentage
  37434. *
  37435. * @declare Highcharts.DataLabelsFilterOptionsObject
  37436. * @since 6.0.3
  37437. * @apioption plotOptions.series.dataLabels.filter
  37438. */
  37439. /**
  37440. * The operator to compare by. Can be one of `>`, `<`, `>=`, `<=`,
  37441. * `==`, and `===`.
  37442. *
  37443. * @type {string}
  37444. * @validvalue [">", "<", ">=", "<=", "==", "==="]
  37445. * @apioption plotOptions.series.dataLabels.filter.operator
  37446. */
  37447. /**
  37448. * The point property to filter by. Point options are passed
  37449. * directly to properties, additionally there are `y` value,
  37450. * `percentage` and others listed under {@link Highcharts.Point}
  37451. * members.
  37452. *
  37453. * @type {string}
  37454. * @apioption plotOptions.series.dataLabels.filter.property
  37455. */
  37456. /**
  37457. * The value to compare against.
  37458. *
  37459. * @type {number}
  37460. * @apioption plotOptions.series.dataLabels.filter.value
  37461. */
  37462. /**
  37463. * A
  37464. * [format string](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting)
  37465. * for the data label. Available variables are the same as for
  37466. * `formatter`.
  37467. *
  37468. * @sample {highcharts} highcharts/plotoptions/series-datalabels-format/
  37469. * Add a unit
  37470. * @sample {highmaps} maps/plotoptions/series-datalabels-format/
  37471. * Formatted value in the data label
  37472. *
  37473. * @type {string}
  37474. * @default y
  37475. * @default point.value
  37476. * @since 3.0
  37477. * @apioption plotOptions.series.dataLabels.format
  37478. */
  37479. // eslint-disable-next-line valid-jsdoc
  37480. /**
  37481. * Callback JavaScript function to format the data label. Note that
  37482. * if a `format` is defined, the format takes precedence and the
  37483. * formatter is ignored.
  37484. *
  37485. * @sample {highmaps} maps/plotoptions/series-datalabels-format/
  37486. * Formatted value
  37487. *
  37488. * @type {Highcharts.DataLabelsFormatterCallbackFunction}
  37489. */
  37490. formatter: function () {
  37491. var numberFormatter = this.series.chart.numberFormatter;
  37492. return typeof this.y !== 'number' ? '' : numberFormatter(this.y, -1);
  37493. },
  37494. /**
  37495. * For points with an extent, like columns or map areas, whether to
  37496. * align the data label inside the box or to the actual value point.
  37497. * Defaults to `false` in most cases, `true` in stacked columns.
  37498. *
  37499. * @type {boolean}
  37500. * @since 3.0
  37501. * @apioption plotOptions.series.dataLabels.inside
  37502. */
  37503. /**
  37504. * Format for points with the value of null. Works analogously to
  37505. * [format](#plotOptions.series.dataLabels.format). `nullFormat` can
  37506. * be applied only to series which support displaying null points.
  37507. *
  37508. * @sample {highcharts} highcharts/plotoptions/series-datalabels-format/
  37509. * Format data label and tooltip for null point.
  37510. *
  37511. * @type {boolean|string}
  37512. * @since 7.1.0
  37513. * @apioption plotOptions.series.dataLabels.nullFormat
  37514. */
  37515. /**
  37516. * Callback JavaScript function that defines formatting for points
  37517. * with the value of null. Works analogously to
  37518. * [formatter](#plotOptions.series.dataLabels.formatter).
  37519. * `nullPointFormatter` can be applied only to series which support
  37520. * displaying null points.
  37521. *
  37522. * @sample {highcharts} highcharts/plotoptions/series-datalabels-format/
  37523. * Format data label and tooltip for null point.
  37524. *
  37525. * @type {Highcharts.DataLabelsFormatterCallbackFunction}
  37526. * @since 7.1.0
  37527. * @apioption plotOptions.series.dataLabels.nullFormatter
  37528. */
  37529. /**
  37530. * How to handle data labels that flow outside the plot area. The
  37531. * default is `"justify"`, which aligns them inside the plot area.
  37532. * For columns and bars, this means it will be moved inside the bar.
  37533. * To display data labels outside the plot area, set `crop` to
  37534. * `false` and `overflow` to `"allow"`.
  37535. *
  37536. * @type {Highcharts.DataLabelsOverflowValue}
  37537. * @default justify
  37538. * @since 3.0.6
  37539. * @apioption plotOptions.series.dataLabels.overflow
  37540. */
  37541. /**
  37542. * When either the `borderWidth` or the `backgroundColor` is set,
  37543. * this is the padding within the box.
  37544. *
  37545. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  37546. * Data labels box options
  37547. * @sample {highmaps} maps/plotoptions/series-datalabels-box/
  37548. * Data labels box options
  37549. *
  37550. * @since 2.2.1
  37551. */
  37552. padding: 5,
  37553. /**
  37554. * Aligns data labels relative to points. If `center` alignment is
  37555. * not possible, it defaults to `right`.
  37556. *
  37557. * @type {Highcharts.AlignValue}
  37558. * @default center
  37559. * @apioption plotOptions.series.dataLabels.position
  37560. */
  37561. /**
  37562. * Text rotation in degrees. Note that due to a more complex
  37563. * structure, backgrounds, borders and padding will be lost on a
  37564. * rotated data label.
  37565. *
  37566. * @sample {highcharts} highcharts/plotoptions/series-datalabels-rotation/
  37567. * Vertical labels
  37568. *
  37569. * @type {number}
  37570. * @default 0
  37571. * @apioption plotOptions.series.dataLabels.rotation
  37572. */
  37573. /**
  37574. * The shadow of the box. Works best with `borderWidth` or
  37575. * `backgroundColor`. Since 2.3 the shadow can be an object
  37576. * configuration containing `color`, `offsetX`, `offsetY`, `opacity`
  37577. * and `width`.
  37578. *
  37579. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  37580. * Data labels box options
  37581. *
  37582. * @type {boolean|Highcharts.ShadowOptionsObject}
  37583. * @default false
  37584. * @since 2.2.1
  37585. * @apioption plotOptions.series.dataLabels.shadow
  37586. */
  37587. /**
  37588. * The name of a symbol to use for the border around the label.
  37589. * Symbols are predefined functions on the Renderer object.
  37590. *
  37591. * @sample {highcharts} highcharts/plotoptions/series-datalabels-shape/
  37592. * A callout for annotations
  37593. *
  37594. * @type {string}
  37595. * @default square
  37596. * @since 4.1.2
  37597. * @apioption plotOptions.series.dataLabels.shape
  37598. */
  37599. /**
  37600. * Styles for the label. The default `color` setting is
  37601. * `"contrast"`, which is a pseudo color that Highcharts picks up
  37602. * and applies the maximum contrast to the underlying point item,
  37603. * for example the bar in a bar chart.
  37604. *
  37605. * The `textOutline` is a pseudo property that applies an outline of
  37606. * the given width with the given color, which by default is the
  37607. * maximum contrast to the text. So a bright text color will result
  37608. * in a black text outline for maximum readability on a mixed
  37609. * background. In some cases, especially with grayscale text, the
  37610. * text outline doesn't work well, in which cases it can be disabled
  37611. * by setting it to `"none"`. When `useHTML` is true, the
  37612. * `textOutline` will not be picked up. In this, case, the same
  37613. * effect can be acheived through the `text-shadow` CSS property.
  37614. *
  37615. * For some series types, where each point has an extent, like for
  37616. * example tree maps, the data label may overflow the point. There
  37617. * are two strategies for handling overflow. By default, the text
  37618. * will wrap to multiple lines. The other strategy is to set
  37619. * `style.textOverflow` to `ellipsis`, which will keep the text on
  37620. * one line plus it will break inside long words.
  37621. *
  37622. * @sample {highcharts} highcharts/plotoptions/series-datalabels-style/
  37623. * Bold labels
  37624. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-overflow/
  37625. * Long labels truncated with an ellipsis in a pie
  37626. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-overflow-wrap/
  37627. * Long labels are wrapped in a pie
  37628. * @sample {highmaps} maps/demo/color-axis/
  37629. * Bold labels
  37630. *
  37631. * @type {Highcharts.CSSObject}
  37632. * @since 4.1.0
  37633. * @apioption plotOptions.series.dataLabels.style
  37634. */
  37635. style: {
  37636. /** @internal */
  37637. fontSize: '11px',
  37638. /** @internal */
  37639. fontWeight: 'bold',
  37640. /** @internal */
  37641. color: 'contrast',
  37642. /** @internal */
  37643. textOutline: '1px contrast'
  37644. },
  37645. /**
  37646. * Options for a label text which should follow marker's shape.
  37647. * Border and background are disabled for a label that follows a
  37648. * path.
  37649. *
  37650. * **Note:** Only SVG-based renderer supports this option. Setting
  37651. * `useHTML` to true will disable this option.
  37652. *
  37653. * @declare Highcharts.DataLabelsTextPathOptionsObject
  37654. * @since 7.1.0
  37655. * @apioption plotOptions.series.dataLabels.textPath
  37656. */
  37657. /**
  37658. * Presentation attributes for the text path.
  37659. *
  37660. * @type {Highcharts.SVGAttributes}
  37661. * @since 7.1.0
  37662. * @apioption plotOptions.series.dataLabels.textPath.attributes
  37663. */
  37664. /**
  37665. * Enable or disable `textPath` option for link's or marker's data
  37666. * labels.
  37667. *
  37668. * @type {boolean}
  37669. * @since 7.1.0
  37670. * @apioption plotOptions.series.dataLabels.textPath.enabled
  37671. */
  37672. /**
  37673. * Whether to
  37674. * [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  37675. * to render the labels.
  37676. *
  37677. * @type {boolean}
  37678. * @default false
  37679. * @apioption plotOptions.series.dataLabels.useHTML
  37680. */
  37681. /**
  37682. * The vertical alignment of a data label. Can be one of `top`,
  37683. * `middle` or `bottom`. The default value depends on the data, for
  37684. * instance in a column chart, the label is above positive values
  37685. * and below negative values.
  37686. *
  37687. * @type {Highcharts.VerticalAlignValue|null}
  37688. * @since 2.3.3
  37689. */
  37690. verticalAlign: 'bottom',
  37691. /**
  37692. * The x position offset of the label relative to the point in
  37693. * pixels.
  37694. *
  37695. * @sample {highcharts} highcharts/plotoptions/series-datalabels-rotation/
  37696. * Vertical and positioned
  37697. * @sample {highcharts} highcharts/plotoptions/bar-datalabels-align-inside-bar/
  37698. * Data labels inside the bar
  37699. */
  37700. x: 0,
  37701. /**
  37702. * The Z index of the data labels. The default Z index puts it above
  37703. * the series. Use a Z index of 2 to display it behind the series.
  37704. *
  37705. * @type {number}
  37706. * @default 6
  37707. * @since 2.3.5
  37708. * @apioption plotOptions.series.dataLabels.z
  37709. */
  37710. /**
  37711. * The y position offset of the label relative to the point in
  37712. * pixels.
  37713. *
  37714. * @sample {highcharts} highcharts/plotoptions/series-datalabels-rotation/
  37715. * Vertical and positioned
  37716. */
  37717. y: 0
  37718. },
  37719. /**
  37720. * When the series contains less points than the crop threshold, all
  37721. * points are drawn, even if the points fall outside the visible plot
  37722. * area at the current zoom. The advantage of drawing all points
  37723. * (including markers and columns), is that animation is performed on
  37724. * updates. On the other hand, when the series contains more points than
  37725. * the crop threshold, the series data is cropped to only contain points
  37726. * that fall within the plot area. The advantage of cropping away
  37727. * invisible points is to increase performance on large series.
  37728. *
  37729. * @since 2.2
  37730. * @product highcharts highstock
  37731. *
  37732. * @private
  37733. */
  37734. cropThreshold: 300,
  37735. /**
  37736. * Opacity of a series parts: line, fill (e.g. area) and dataLabels.
  37737. *
  37738. * @see [states.inactive.opacity](#plotOptions.series.states.inactive.opacity)
  37739. *
  37740. * @since 7.1.0
  37741. *
  37742. * @private
  37743. */
  37744. opacity: 1,
  37745. /**
  37746. * The width of each point on the x axis. For example in a column chart
  37747. * with one value each day, the pointRange would be 1 day (= 24 * 3600
  37748. * * 1000 milliseconds). This is normally computed automatically, but
  37749. * this option can be used to override the automatic value.
  37750. *
  37751. * @product highstock
  37752. *
  37753. * @private
  37754. */
  37755. pointRange: 0,
  37756. /**
  37757. * When this is true, the series will not cause the Y axis to cross
  37758. * the zero plane (or [threshold](#plotOptions.series.threshold) option)
  37759. * unless the data actually crosses the plane.
  37760. *
  37761. * For example, if `softThreshold` is `false`, a series of 0, 1, 2,
  37762. * 3 will make the Y axis show negative values according to the
  37763. * `minPadding` option. If `softThreshold` is `true`, the Y axis starts
  37764. * at 0.
  37765. *
  37766. * @since 4.1.9
  37767. * @product highcharts highstock
  37768. *
  37769. * @private
  37770. */
  37771. softThreshold: true,
  37772. /**
  37773. * @declare Highcharts.SeriesStatesOptionsObject
  37774. *
  37775. * @private
  37776. */
  37777. states: {
  37778. /**
  37779. * The normal state of a series, or for point items in column, pie
  37780. * and similar series. Currently only used for setting animation
  37781. * when returning to normal state from hover.
  37782. *
  37783. * @declare Highcharts.SeriesStatesNormalOptionsObject
  37784. */
  37785. normal: {
  37786. /**
  37787. * Animation when returning to normal state after hovering.
  37788. *
  37789. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  37790. */
  37791. animation: true
  37792. },
  37793. /**
  37794. * Options for the hovered series. These settings override the
  37795. * normal state options when a series is moused over or touched.
  37796. *
  37797. * @declare Highcharts.SeriesStatesHoverOptionsObject
  37798. */
  37799. hover: {
  37800. /**
  37801. * Enable separate styles for the hovered series to visualize
  37802. * that the user hovers either the series itself or the legend.
  37803. *
  37804. * @sample {highcharts} highcharts/plotoptions/series-states-hover-enabled/
  37805. * Line
  37806. * @sample {highcharts} highcharts/plotoptions/series-states-hover-enabled-column/
  37807. * Column
  37808. * @sample {highcharts} highcharts/plotoptions/series-states-hover-enabled-pie/
  37809. * Pie
  37810. *
  37811. * @type {boolean}
  37812. * @default true
  37813. * @since 1.2
  37814. * @apioption plotOptions.series.states.hover.enabled
  37815. */
  37816. /**
  37817. * Animation setting for hovering the graph in line-type series.
  37818. *
  37819. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  37820. * @since 5.0.8
  37821. * @product highcharts highstock
  37822. */
  37823. animation: {
  37824. /**
  37825. * The duration of the hover animation in milliseconds. By
  37826. * default the hover state animates quickly in, and slowly
  37827. * back to normal.
  37828. *
  37829. * @internal
  37830. */
  37831. duration: 50
  37832. },
  37833. /**
  37834. * Pixel width of the graph line. By default this property is
  37835. * undefined, and the `lineWidthPlus` property dictates how much
  37836. * to increase the linewidth from normal state.
  37837. *
  37838. * @sample {highcharts} highcharts/plotoptions/series-states-hover-linewidth/
  37839. * 5px line on hover
  37840. *
  37841. * @type {number}
  37842. * @product highcharts highstock
  37843. * @apioption plotOptions.series.states.hover.lineWidth
  37844. */
  37845. /**
  37846. * The additional line width for the graph of a hovered series.
  37847. *
  37848. * @sample {highcharts} highcharts/plotoptions/series-states-hover-linewidthplus/
  37849. * 5 pixels wider
  37850. * @sample {highstock} highcharts/plotoptions/series-states-hover-linewidthplus/
  37851. * 5 pixels wider
  37852. *
  37853. * @since 4.0.3
  37854. * @product highcharts highstock
  37855. */
  37856. lineWidthPlus: 1,
  37857. /**
  37858. * In Highcharts 1.0, the appearance of all markers belonging
  37859. * to the hovered series. For settings on the hover state of the
  37860. * individual point, see
  37861. * [marker.states.hover](#plotOptions.series.marker.states.hover).
  37862. *
  37863. * @deprecated
  37864. *
  37865. * @extends plotOptions.series.marker
  37866. * @excluding states
  37867. * @product highcharts highstock
  37868. */
  37869. marker: {
  37870. // lineWidth: base + 1,
  37871. // radius: base + 1
  37872. },
  37873. /**
  37874. * Options for the halo appearing around the hovered point in
  37875. * line-type series as well as outside the hovered slice in pie
  37876. * charts. By default the halo is filled by the current point or
  37877. * series color with an opacity of 0.25\. The halo can be
  37878. * disabled by setting the `halo` option to `null`.
  37879. *
  37880. * In styled mode, the halo is styled with the
  37881. * `.highcharts-halo` class, with colors inherited from
  37882. * `.highcharts-color-{n}`.
  37883. *
  37884. * @sample {highcharts} highcharts/plotoptions/halo/
  37885. * Halo options
  37886. * @sample {highstock} highcharts/plotoptions/halo/
  37887. * Halo options
  37888. *
  37889. * @declare Highcharts.SeriesStatesHoverHaloOptionsObject
  37890. * @type {null|*}
  37891. * @since 4.0
  37892. * @product highcharts highstock
  37893. */
  37894. halo: {
  37895. /**
  37896. * A collection of SVG attributes to override the appearance
  37897. * of the halo, for example `fill`, `stroke` and
  37898. * `stroke-width`.
  37899. *
  37900. * @type {Highcharts.SVGAttributes}
  37901. * @since 4.0
  37902. * @product highcharts highstock
  37903. * @apioption plotOptions.series.states.hover.halo.attributes
  37904. */
  37905. /**
  37906. * The pixel size of the halo. For point markers this is the
  37907. * radius of the halo. For pie slices it is the width of the
  37908. * halo outside the slice. For bubbles it defaults to 5 and
  37909. * is the width of the halo outside the bubble.
  37910. *
  37911. * @since 4.0
  37912. * @product highcharts highstock
  37913. */
  37914. size: 10,
  37915. /**
  37916. * Opacity for the halo unless a specific fill is overridden
  37917. * using the `attributes` setting. Note that Highcharts is
  37918. * only able to apply opacity to colors of hex or rgb(a)
  37919. * formats.
  37920. *
  37921. * @since 4.0
  37922. * @product highcharts highstock
  37923. */
  37924. opacity: 0.25
  37925. }
  37926. },
  37927. /**
  37928. * Specific options for point in selected states, after being
  37929. * selected by
  37930. * [allowPointSelect](#plotOptions.series.allowPointSelect)
  37931. * or programmatically.
  37932. *
  37933. * @sample maps/plotoptions/series-allowpointselect/
  37934. * Allow point select demo
  37935. *
  37936. * @declare Highcharts.SeriesStatesSelectOptionsObject
  37937. * @extends plotOptions.series.states.hover
  37938. * @excluding brightness
  37939. */
  37940. select: {
  37941. animation: {
  37942. /** @internal */
  37943. duration: 0
  37944. }
  37945. },
  37946. /**
  37947. * The opposite state of a hover for series.
  37948. *
  37949. * @sample highcharts/plotoptions/series-states-inactive-disabled
  37950. * Disabled inactive state
  37951. *
  37952. * @declare Highcharts.SeriesStatesInactiveOptionsObject
  37953. */
  37954. inactive: {
  37955. /**
  37956. * Enable or disable the inactive state for a series
  37957. *
  37958. * @sample highcharts/plotoptions/series-states-inactive-disabled
  37959. * Disabled inactive state
  37960. *
  37961. * @type {boolean}
  37962. * @default true
  37963. * @apioption plotOptions.series.states.inactive.enabled
  37964. */
  37965. /**
  37966. * The animation for entering the inactive state.
  37967. *
  37968. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  37969. */
  37970. animation: {
  37971. /** @internal */
  37972. duration: 50
  37973. },
  37974. /**
  37975. * Opacity of series elements (dataLabels, line, area).
  37976. *
  37977. * @type {number}
  37978. */
  37979. opacity: 0.2
  37980. }
  37981. },
  37982. /**
  37983. * Sticky tracking of mouse events. When true, the `mouseOut` event on a
  37984. * series isn't triggered until the mouse moves over another series, or
  37985. * out of the plot area. When false, the `mouseOut` event on a series is
  37986. * triggered when the mouse leaves the area around the series' graph or
  37987. * markers. This also implies the tooltip when not shared. When
  37988. * `stickyTracking` is false and `tooltip.shared` is false, the tooltip
  37989. * will be hidden when moving the mouse between series. Defaults to true
  37990. * for line and area type series, but to false for columns, pies etc.
  37991. *
  37992. * **Note:** The boost module will force this option because of
  37993. * technical limitations.
  37994. *
  37995. * @sample {highcharts} highcharts/plotoptions/series-stickytracking-true/
  37996. * True by default
  37997. * @sample {highcharts} highcharts/plotoptions/series-stickytracking-false/
  37998. * False
  37999. *
  38000. * @default {highcharts} true
  38001. * @default {highstock} true
  38002. * @default {highmaps} false
  38003. * @since 2.0
  38004. *
  38005. * @private
  38006. */
  38007. stickyTracking: true,
  38008. /**
  38009. * A configuration object for the tooltip rendering of each single
  38010. * series. Properties are inherited from [tooltip](#tooltip), but only
  38011. * the following properties can be defined on a series level.
  38012. *
  38013. * @declare Highcharts.SeriesTooltipOptionsObject
  38014. * @since 2.3
  38015. * @extends tooltip
  38016. * @excluding animation, backgroundColor, borderColor, borderRadius,
  38017. * borderWidth, className, crosshairs, enabled, formatter,
  38018. * headerShape, hideDelay, outside, padding, positioner,
  38019. * shadow, shape, shared, snap, split, stickOnContact,
  38020. * style, useHTML
  38021. * @apioption plotOptions.series.tooltip
  38022. */
  38023. /**
  38024. * When a series contains a data array that is longer than this, only
  38025. * one dimensional arrays of numbers, or two dimensional arrays with
  38026. * x and y values are allowed. Also, only the first point is tested,
  38027. * and the rest are assumed to be the same format. This saves expensive
  38028. * data checking and indexing in long series. Set it to `0` disable.
  38029. *
  38030. * Note:
  38031. * In boost mode turbo threshold is forced. Only array of numbers or
  38032. * two dimensional arrays are allowed.
  38033. *
  38034. * @since 2.2
  38035. * @product highcharts highstock gantt
  38036. *
  38037. * @private
  38038. */
  38039. turboThreshold: 1000,
  38040. /**
  38041. * An array defining zones within a series. Zones can be applied to the
  38042. * X axis, Y axis or Z axis for bubbles, according to the `zoneAxis`
  38043. * option. The zone definitions have to be in ascending order regarding
  38044. * to the value.
  38045. *
  38046. * In styled mode, the color zones are styled with the
  38047. * `.highcharts-zone-{n}` class, or custom classed from the `className`
  38048. * option
  38049. * ([view live demo](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/css/color-zones/)).
  38050. *
  38051. * @see [zoneAxis](#plotOptions.series.zoneAxis)
  38052. *
  38053. * @sample {highcharts} highcharts/series/color-zones-simple/
  38054. * Color zones
  38055. * @sample {highstock} highcharts/series/color-zones-simple/
  38056. * Color zones
  38057. *
  38058. * @declare Highcharts.SeriesZonesOptionsObject
  38059. * @type {Array<*>}
  38060. * @since 4.1.0
  38061. * @product highcharts highstock
  38062. * @apioption plotOptions.series.zones
  38063. */
  38064. /**
  38065. * Styled mode only. A custom class name for the zone.
  38066. *
  38067. * @sample highcharts/css/color-zones/
  38068. * Zones styled by class name
  38069. *
  38070. * @type {string}
  38071. * @since 5.0.0
  38072. * @apioption plotOptions.series.zones.className
  38073. */
  38074. /**
  38075. * Defines the color of the series.
  38076. *
  38077. * @see [series color](#plotOptions.series.color)
  38078. *
  38079. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  38080. * @since 4.1.0
  38081. * @product highcharts highstock
  38082. * @apioption plotOptions.series.zones.color
  38083. */
  38084. /**
  38085. * A name for the dash style to use for the graph.
  38086. *
  38087. * @see [plotOptions.series.dashStyle](#plotOptions.series.dashStyle)
  38088. *
  38089. * @sample {highcharts|highstock} highcharts/series/color-zones-dashstyle-dot/
  38090. * Dashed line indicates prognosis
  38091. *
  38092. * @type {Highcharts.DashStyleValue}
  38093. * @since 4.1.0
  38094. * @product highcharts highstock
  38095. * @apioption plotOptions.series.zones.dashStyle
  38096. */
  38097. /**
  38098. * Defines the fill color for the series (in area type series)
  38099. *
  38100. * @see [fillColor](#plotOptions.area.fillColor)
  38101. *
  38102. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  38103. * @since 4.1.0
  38104. * @product highcharts highstock
  38105. * @apioption plotOptions.series.zones.fillColor
  38106. */
  38107. /**
  38108. * The value up to where the zone extends, if undefined the zones
  38109. * stretches to the last value in the series.
  38110. *
  38111. * @type {number}
  38112. * @since 4.1.0
  38113. * @product highcharts highstock
  38114. * @apioption plotOptions.series.zones.value
  38115. */
  38116. /**
  38117. * When using dual or multiple color axes, this number defines which
  38118. * colorAxis the particular series is connected to. It refers to
  38119. * either the
  38120. * {@link #colorAxis.id|axis id}
  38121. * or the index of the axis in the colorAxis array, with 0 being the
  38122. * first. Set this option to false to prevent a series from connecting
  38123. * to the default color axis.
  38124. *
  38125. * Since v7.2.0 the option can also be an axis id or an axis index
  38126. * instead of a boolean flag.
  38127. *
  38128. * @sample highcharts/coloraxis/coloraxis-with-pie/
  38129. * Color axis with pie series
  38130. * @sample highcharts/coloraxis/multiple-coloraxis/
  38131. * Multiple color axis
  38132. *
  38133. * @type {number|string|boolean}
  38134. * @default 0
  38135. * @product highcharts highstock highmaps
  38136. * @apioption plotOptions.series.colorAxis
  38137. */
  38138. /**
  38139. * Determines what data value should be used to calculate point color
  38140. * if `colorAxis` is used. Requires to set `min` and `max` if some
  38141. * custom point property is used or if approximation for data grouping
  38142. * is set to `'sum'`.
  38143. *
  38144. * @sample highcharts/coloraxis/custom-color-key/
  38145. * Custom color key
  38146. * @sample highcharts/coloraxis/changed-default-color-key/
  38147. * Changed default color key
  38148. *
  38149. * @type {string}
  38150. * @default y
  38151. * @since 7.2.0
  38152. * @product highcharts highstock highmaps
  38153. * @apioption plotOptions.series.colorKey
  38154. */
  38155. /**
  38156. * Determines whether the series should look for the nearest point
  38157. * in both dimensions or just the x-dimension when hovering the series.
  38158. * Defaults to `'xy'` for scatter series and `'x'` for most other
  38159. * series. If the data has duplicate x-values, it is recommended to
  38160. * set this to `'xy'` to allow hovering over all points.
  38161. *
  38162. * Applies only to series types using nearest neighbor search (not
  38163. * direct hover) for tooltip.
  38164. *
  38165. * @sample {highcharts} highcharts/series/findnearestpointby/
  38166. * Different hover behaviors
  38167. * @sample {highstock} highcharts/series/findnearestpointby/
  38168. * Different hover behaviors
  38169. * @sample {highmaps} highcharts/series/findnearestpointby/
  38170. * Different hover behaviors
  38171. *
  38172. * @since 5.0.10
  38173. * @validvalue ["x", "xy"]
  38174. *
  38175. * @private
  38176. */
  38177. findNearestPointBy: 'x'
  38178. };
  38179. return Series;
  38180. }());
  38181. extend(Series.prototype, {
  38182. axisTypes: ['xAxis', 'yAxis'],
  38183. coll: 'series',
  38184. colorCounter: 0,
  38185. cropShoulder: 1,
  38186. directTouch: false,
  38187. drawLegendSymbol: LegendSymbolMixin.drawLineMarker,
  38188. isCartesian: true,
  38189. kdAxisArray: ['clientX', 'plotY'],
  38190. // each point's x and y values are stored in this.xData and this.yData:
  38191. parallelArrays: ['x', 'y'],
  38192. pointClass: Point,
  38193. requireSorting: true,
  38194. // requires the data to be sorted:
  38195. sorted: true
  38196. });
  38197. /* *
  38198. *
  38199. * Registry
  38200. *
  38201. * */
  38202. SeriesRegistry.series = Series;
  38203. /* *
  38204. *
  38205. * Default Export
  38206. *
  38207. * */
  38208. /* *
  38209. *
  38210. * API Declarations
  38211. *
  38212. * */
  38213. /**
  38214. * This is a placeholder type of the possible series options for
  38215. * [Highcharts](../highcharts/series), [Highcharts Stock](../highstock/series),
  38216. * [Highmaps](../highmaps/series), and [Gantt](../gantt/series).
  38217. *
  38218. * In TypeScript is this dynamically generated to reference all possible types
  38219. * of series options.
  38220. *
  38221. * @ignore-declaration
  38222. * @typedef {Highcharts.SeriesOptions|Highcharts.Dictionary<*>} Highcharts.SeriesOptionsType
  38223. */
  38224. /**
  38225. * Options for `dataSorting`.
  38226. *
  38227. * @interface Highcharts.DataSortingOptionsObject
  38228. * @since 8.0.0
  38229. */ /**
  38230. * Enable or disable data sorting for the series.
  38231. * @name Highcharts.DataSortingOptionsObject#enabled
  38232. * @type {boolean|undefined}
  38233. */ /**
  38234. * Whether to allow matching points by name in an update.
  38235. * @name Highcharts.DataSortingOptionsObject#matchByName
  38236. * @type {boolean|undefined}
  38237. */ /**
  38238. * Determines what data value should be used to sort by.
  38239. * @name Highcharts.DataSortingOptionsObject#sortKey
  38240. * @type {string|undefined}
  38241. */
  38242. /**
  38243. * Function callback when a series has been animated.
  38244. *
  38245. * @callback Highcharts.SeriesAfterAnimateCallbackFunction
  38246. *
  38247. * @param {Highcharts.Series} this
  38248. * The series where the event occured.
  38249. *
  38250. * @param {Highcharts.SeriesAfterAnimateEventObject} event
  38251. * Event arguments.
  38252. */
  38253. /**
  38254. * Event information regarding completed animation of a series.
  38255. *
  38256. * @interface Highcharts.SeriesAfterAnimateEventObject
  38257. */ /**
  38258. * Animated series.
  38259. * @name Highcharts.SeriesAfterAnimateEventObject#target
  38260. * @type {Highcharts.Series}
  38261. */ /**
  38262. * Event type.
  38263. * @name Highcharts.SeriesAfterAnimateEventObject#type
  38264. * @type {"afterAnimate"}
  38265. */
  38266. /**
  38267. * Function callback when the checkbox next to the series' name in the legend is
  38268. * clicked.
  38269. *
  38270. * @callback Highcharts.SeriesCheckboxClickCallbackFunction
  38271. *
  38272. * @param {Highcharts.Series} this
  38273. * The series where the event occured.
  38274. *
  38275. * @param {Highcharts.SeriesCheckboxClickEventObject} event
  38276. * Event arguments.
  38277. */
  38278. /**
  38279. * Event information regarding check of a series box.
  38280. *
  38281. * @interface Highcharts.SeriesCheckboxClickEventObject
  38282. */ /**
  38283. * Whether the box has been checked.
  38284. * @name Highcharts.SeriesCheckboxClickEventObject#checked
  38285. * @type {boolean}
  38286. */ /**
  38287. * Related series.
  38288. * @name Highcharts.SeriesCheckboxClickEventObject#item
  38289. * @type {Highcharts.Series}
  38290. */ /**
  38291. * Related series.
  38292. * @name Highcharts.SeriesCheckboxClickEventObject#target
  38293. * @type {Highcharts.Series}
  38294. */ /**
  38295. * Event type.
  38296. * @name Highcharts.SeriesCheckboxClickEventObject#type
  38297. * @type {"checkboxClick"}
  38298. */
  38299. /**
  38300. * Function callback when a series is clicked. Return false to cancel toogle
  38301. * actions.
  38302. *
  38303. * @callback Highcharts.SeriesClickCallbackFunction
  38304. *
  38305. * @param {Highcharts.Series} this
  38306. * The series where the event occured.
  38307. *
  38308. * @param {Highcharts.SeriesClickEventObject} event
  38309. * Event arguments.
  38310. */
  38311. /**
  38312. * Common information for a click event on a series.
  38313. *
  38314. * @interface Highcharts.SeriesClickEventObject
  38315. * @extends global.Event
  38316. */ /**
  38317. * Nearest point on the graph.
  38318. * @name Highcharts.SeriesClickEventObject#point
  38319. * @type {Highcharts.Point}
  38320. */
  38321. /**
  38322. * Gets fired when the series is hidden after chart generation time, either by
  38323. * clicking the legend item or by calling `.hide()`.
  38324. *
  38325. * @callback Highcharts.SeriesHideCallbackFunction
  38326. *
  38327. * @param {Highcharts.Series} this
  38328. * The series where the event occured.
  38329. *
  38330. * @param {global.Event} event
  38331. * The event that occured.
  38332. */
  38333. /**
  38334. * The SVG value used for the `stroke-linecap` and `stroke-linejoin` of a line
  38335. * graph.
  38336. *
  38337. * @typedef {"butt"|"round"|"square"|string} Highcharts.SeriesLinecapValue
  38338. */
  38339. /**
  38340. * Gets fired when the legend item belonging to the series is clicked. The
  38341. * default action is to toggle the visibility of the series. This can be
  38342. * prevented by returning `false` or calling `event.preventDefault()`.
  38343. *
  38344. * @callback Highcharts.SeriesLegendItemClickCallbackFunction
  38345. *
  38346. * @param {Highcharts.Series} this
  38347. * The series where the event occured.
  38348. *
  38349. * @param {Highcharts.SeriesLegendItemClickEventObject} event
  38350. * The event that occured.
  38351. */
  38352. /**
  38353. * Information about the event.
  38354. *
  38355. * @interface Highcharts.SeriesLegendItemClickEventObject
  38356. */ /**
  38357. * Related browser event.
  38358. * @name Highcharts.SeriesLegendItemClickEventObject#browserEvent
  38359. * @type {global.PointerEvent}
  38360. */ /**
  38361. * Prevent the default action of toggle the visibility of the series.
  38362. * @name Highcharts.SeriesLegendItemClickEventObject#preventDefault
  38363. * @type {Function}
  38364. */ /**
  38365. * Related series.
  38366. * @name Highcharts.SeriesCheckboxClickEventObject#target
  38367. * @type {Highcharts.Series}
  38368. */ /**
  38369. * Event type.
  38370. * @name Highcharts.SeriesCheckboxClickEventObject#type
  38371. * @type {"checkboxClick"}
  38372. */
  38373. /**
  38374. * Gets fired when the mouse leaves the graph.
  38375. *
  38376. * @callback Highcharts.SeriesMouseOutCallbackFunction
  38377. *
  38378. * @param {Highcharts.Series} this
  38379. * Series where the event occured.
  38380. *
  38381. * @param {global.PointerEvent} event
  38382. * Event that occured.
  38383. */
  38384. /**
  38385. * Gets fired when the mouse enters the graph.
  38386. *
  38387. * @callback Highcharts.SeriesMouseOverCallbackFunction
  38388. *
  38389. * @param {Highcharts.Series} this
  38390. * Series where the event occured.
  38391. *
  38392. * @param {global.PointerEvent} event
  38393. * Event that occured.
  38394. */
  38395. /**
  38396. * Translation and scale for the plot area of a series.
  38397. *
  38398. * @interface Highcharts.SeriesPlotBoxObject
  38399. */ /**
  38400. * @name Highcharts.SeriesPlotBoxObject#scaleX
  38401. * @type {number}
  38402. */ /**
  38403. * @name Highcharts.SeriesPlotBoxObject#scaleY
  38404. * @type {number}
  38405. */ /**
  38406. * @name Highcharts.SeriesPlotBoxObject#translateX
  38407. * @type {number}
  38408. */ /**
  38409. * @name Highcharts.SeriesPlotBoxObject#translateY
  38410. * @type {number}
  38411. */
  38412. /**
  38413. * Gets fired when the series is shown after chart generation time, either by
  38414. * clicking the legend item or by calling `.show()`.
  38415. *
  38416. * @callback Highcharts.SeriesShowCallbackFunction
  38417. *
  38418. * @param {Highcharts.Series} this
  38419. * Series where the event occured.
  38420. *
  38421. * @param {global.Event} event
  38422. * Event that occured.
  38423. */
  38424. /**
  38425. * Possible key values for the series state options.
  38426. *
  38427. * @typedef {"hover"|"inactive"|"normal"|"select"} Highcharts.SeriesStateValue
  38428. */
  38429. ''; // detach doclets above
  38430. /* *
  38431. *
  38432. * API Options
  38433. *
  38434. * */
  38435. /**
  38436. * Series options for specific data and the data itself. In TypeScript you
  38437. * have to cast the series options to specific series types, to get all
  38438. * possible options for a series.
  38439. *
  38440. * @example
  38441. * // TypeScript example
  38442. * Highcharts.chart('container', {
  38443. * series: [{
  38444. * color: '#06C',
  38445. * data: [[0, 1], [2, 3]]
  38446. * } as Highcharts.SeriesLineOptions ]
  38447. * });
  38448. *
  38449. * @type {Array<*>}
  38450. * @apioption series
  38451. */
  38452. /**
  38453. * An id for the series. This can be used after render time to get a pointer
  38454. * to the series object through `chart.get()`.
  38455. *
  38456. * @sample {highcharts} highcharts/plotoptions/series-id/
  38457. * Get series by id
  38458. *
  38459. * @type {string}
  38460. * @since 1.2.0
  38461. * @apioption series.id
  38462. */
  38463. /**
  38464. * The index of the series in the chart, affecting the internal index in the
  38465. * `chart.series` array, the visible Z index as well as the order in the
  38466. * legend.
  38467. *
  38468. * @type {number}
  38469. * @since 2.3.0
  38470. * @apioption series.index
  38471. */
  38472. /**
  38473. * The sequential index of the series in the legend.
  38474. *
  38475. * @see [legend.reversed](#legend.reversed),
  38476. * [yAxis.reversedStacks](#yAxis.reversedStacks)
  38477. *
  38478. * @sample {highcharts|highstock} highcharts/series/legendindex/
  38479. * Legend in opposite order
  38480. *
  38481. * @type {number}
  38482. * @apioption series.legendIndex
  38483. */
  38484. /**
  38485. * The name of the series as shown in the legend, tooltip etc.
  38486. *
  38487. * @sample {highcharts} highcharts/series/name/
  38488. * Series name
  38489. * @sample {highmaps} maps/demo/category-map/
  38490. * Series name
  38491. *
  38492. * @type {string}
  38493. * @apioption series.name
  38494. */
  38495. /**
  38496. * This option allows grouping series in a stacked chart. The stack option
  38497. * can be a string or anything else, as long as the grouped series' stack
  38498. * options match each other after conversion into a string.
  38499. *
  38500. * @sample {highcharts} highcharts/series/stack/
  38501. * Stacked and grouped columns
  38502. *
  38503. * @type {number|string}
  38504. * @since 2.1
  38505. * @product highcharts highstock
  38506. * @apioption series.stack
  38507. */
  38508. /**
  38509. * The type of series, for example `line` or `column`. By default, the
  38510. * series type is inherited from [chart.type](#chart.type), so unless the
  38511. * chart is a combination of series types, there is no need to set it on the
  38512. * series level.
  38513. *
  38514. * @sample {highcharts} highcharts/series/type/
  38515. * Line and column in the same chart
  38516. * @sample highcharts/series/type-dynamic/
  38517. * Dynamic types with button selector
  38518. * @sample {highmaps} maps/demo/mapline-mappoint/
  38519. * Multiple types in the same map
  38520. *
  38521. * @type {string}
  38522. * @apioption series.type
  38523. */
  38524. /**
  38525. * When using dual or multiple x axes, this number defines which xAxis the
  38526. * particular series is connected to. It refers to either the
  38527. * {@link #xAxis.id|axis id}
  38528. * or the index of the axis in the xAxis array, with 0 being the first.
  38529. *
  38530. * @type {number|string}
  38531. * @default 0
  38532. * @product highcharts highstock
  38533. * @apioption series.xAxis
  38534. */
  38535. /**
  38536. * When using dual or multiple y axes, this number defines which yAxis the
  38537. * particular series is connected to. It refers to either the
  38538. * {@link #yAxis.id|axis id}
  38539. * or the index of the axis in the yAxis array, with 0 being the first.
  38540. *
  38541. * @sample {highcharts} highcharts/series/yaxis/
  38542. * Apply the column series to the secondary Y axis
  38543. *
  38544. * @type {number|string}
  38545. * @default 0
  38546. * @product highcharts highstock
  38547. * @apioption series.yAxis
  38548. */
  38549. /**
  38550. * Define the visual z index of the series.
  38551. *
  38552. * @sample {highcharts} highcharts/plotoptions/series-zindex-default/
  38553. * With no z index, the series defined last are on top
  38554. * @sample {highcharts} highcharts/plotoptions/series-zindex/
  38555. * With a z index, the series with the highest z index is on top
  38556. * @sample {highstock} highcharts/plotoptions/series-zindex-default/
  38557. * With no z index, the series defined last are on top
  38558. * @sample {highstock} highcharts/plotoptions/series-zindex/
  38559. * With a z index, the series with the highest z index is on top
  38560. *
  38561. * @type {number}
  38562. * @product highcharts highstock
  38563. * @apioption series.zIndex
  38564. */
  38565. ''; // include precedent doclets in transpilat
  38566. return Series;
  38567. });
  38568. _registerModule(_modules, 'Extensions/ScrollablePlotArea.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Axis/Axis.js'], _modules['Core/Chart/Chart.js'], _modules['Core/Series/Series.js'], _modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (A, Axis, Chart, Series, H, U) {
  38569. /* *
  38570. *
  38571. * (c) 2010-2021 Torstein Honsi
  38572. *
  38573. * License: www.highcharts.com/license
  38574. *
  38575. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  38576. *
  38577. * Highcharts feature to make the Y axis stay fixed when scrolling the chart
  38578. * horizontally on mobile devices. Supports left and right side axes.
  38579. */
  38580. /*
  38581. WIP on vertical scrollable plot area (#9378). To do:
  38582. - Bottom axis positioning
  38583. - Test with Gantt
  38584. - Look for size optimizing the code
  38585. - API and demos
  38586. */
  38587. var stop = A.stop;
  38588. var addEvent = U.addEvent,
  38589. createElement = U.createElement,
  38590. merge = U.merge,
  38591. pick = U.pick;
  38592. /**
  38593. * Options for a scrollable plot area. This feature provides a minimum size for
  38594. * the plot area of the chart. If the size gets smaller than this, typically
  38595. * on mobile devices, a native browser scrollbar is presented. This scrollbar
  38596. * provides smooth scrolling for the contents of the plot area, whereas the
  38597. * title, legend and unaffected axes are fixed.
  38598. *
  38599. * Since v7.1.2, a scrollable plot area can be defined for either horizontal or
  38600. * vertical scrolling, depending on whether the `minWidth` or `minHeight`
  38601. * option is set.
  38602. *
  38603. * @sample highcharts/chart/scrollable-plotarea
  38604. * Scrollable plot area
  38605. * @sample highcharts/chart/scrollable-plotarea-vertical
  38606. * Vertically scrollable plot area
  38607. * @sample {gantt} highcharts/chart/scrollable-plotarea-vertical
  38608. * Gantt chart with vertically scrollable plot area
  38609. *
  38610. * @since 6.1.0
  38611. * @product highcharts gantt
  38612. * @apioption chart.scrollablePlotArea
  38613. */
  38614. /**
  38615. * The minimum height for the plot area. If it gets smaller than this, the plot
  38616. * area will become scrollable.
  38617. *
  38618. * @type {number}
  38619. * @apioption chart.scrollablePlotArea.minHeight
  38620. */
  38621. /**
  38622. * The minimum width for the plot area. If it gets smaller than this, the plot
  38623. * area will become scrollable.
  38624. *
  38625. * @type {number}
  38626. * @apioption chart.scrollablePlotArea.minWidth
  38627. */
  38628. /**
  38629. * The initial scrolling position of the scrollable plot area. Ranges from 0 to
  38630. * 1, where 0 aligns the plot area to the left and 1 aligns it to the right.
  38631. * Typically we would use 1 if the chart has right aligned Y axes.
  38632. *
  38633. * @type {number}
  38634. * @apioption chart.scrollablePlotArea.scrollPositionX
  38635. */
  38636. /**
  38637. * The initial scrolling position of the scrollable plot area. Ranges from 0 to
  38638. * 1, where 0 aligns the plot area to the top and 1 aligns it to the bottom.
  38639. *
  38640. * @type {number}
  38641. * @apioption chart.scrollablePlotArea.scrollPositionY
  38642. */
  38643. /**
  38644. * The opacity of mask applied on one of the sides of the plot
  38645. * area.
  38646. *
  38647. * @sample {highcharts} highcharts/chart/scrollable-plotarea-opacity
  38648. * Disabled opacity for the mask
  38649. *
  38650. * @type {number}
  38651. * @default 0.85
  38652. * @since 7.1.1
  38653. * @apioption chart.scrollablePlotArea.opacity
  38654. */
  38655. ''; // detach API doclets
  38656. /* eslint-disable no-invalid-this, valid-jsdoc */
  38657. addEvent(Chart, 'afterSetChartSize', function (e) {
  38658. var scrollablePlotArea = this.options.chart.scrollablePlotArea,
  38659. scrollableMinWidth = scrollablePlotArea && scrollablePlotArea.minWidth,
  38660. scrollableMinHeight = scrollablePlotArea && scrollablePlotArea.minHeight,
  38661. scrollablePixelsX,
  38662. scrollablePixelsY,
  38663. corrections;
  38664. if (!this.renderer.forExport) {
  38665. // The amount of pixels to scroll, the difference between chart
  38666. // width and scrollable width
  38667. if (scrollableMinWidth) {
  38668. this.scrollablePixelsX = scrollablePixelsX = Math.max(0, scrollableMinWidth - this.chartWidth);
  38669. if (scrollablePixelsX) {
  38670. this.scrollablePlotBox = this.renderer.scrollablePlotBox = merge(this.plotBox);
  38671. this.plotBox.width = this.plotWidth += scrollablePixelsX;
  38672. if (this.inverted) {
  38673. this.clipBox.height += scrollablePixelsX;
  38674. }
  38675. else {
  38676. this.clipBox.width += scrollablePixelsX;
  38677. }
  38678. corrections = {
  38679. // Corrections for right side
  38680. 1: { name: 'right', value: scrollablePixelsX }
  38681. };
  38682. }
  38683. // Currently we can only do either X or Y
  38684. }
  38685. else if (scrollableMinHeight) {
  38686. this.scrollablePixelsY = scrollablePixelsY = Math.max(0, scrollableMinHeight - this.chartHeight);
  38687. if (scrollablePixelsY) {
  38688. this.scrollablePlotBox = this.renderer.scrollablePlotBox = merge(this.plotBox);
  38689. this.plotBox.height = this.plotHeight += scrollablePixelsY;
  38690. if (this.inverted) {
  38691. this.clipBox.width += scrollablePixelsY;
  38692. }
  38693. else {
  38694. this.clipBox.height += scrollablePixelsY;
  38695. }
  38696. corrections = {
  38697. 2: { name: 'bottom', value: scrollablePixelsY }
  38698. };
  38699. }
  38700. }
  38701. if (corrections && !e.skipAxes) {
  38702. this.axes.forEach(function (axis) {
  38703. // For right and bottom axes, only fix the plot line length
  38704. if (corrections[axis.side]) {
  38705. // Get the plot lines right in getPlotLinePath,
  38706. // temporarily set it to the adjusted plot width.
  38707. axis.getPlotLinePath = function () {
  38708. var marginName = corrections[axis.side].name,
  38709. correctionValue = corrections[axis.side].value,
  38710. // axis.right or axis.bottom
  38711. margin = this[marginName],
  38712. path;
  38713. // Temporarily adjust
  38714. this[marginName] = margin - correctionValue;
  38715. path = H.Axis.prototype.getPlotLinePath.apply(this, arguments);
  38716. // Reset
  38717. this[marginName] = margin;
  38718. return path;
  38719. };
  38720. }
  38721. else {
  38722. // Apply the corrected plotWidth
  38723. axis.setAxisSize();
  38724. axis.setAxisTranslation();
  38725. }
  38726. });
  38727. }
  38728. }
  38729. });
  38730. addEvent(Chart, 'render', function () {
  38731. if (this.scrollablePixelsX || this.scrollablePixelsY) {
  38732. if (this.setUpScrolling) {
  38733. this.setUpScrolling();
  38734. }
  38735. this.applyFixed();
  38736. }
  38737. else if (this.fixedDiv) { // Has been in scrollable mode
  38738. this.applyFixed();
  38739. }
  38740. });
  38741. /**
  38742. * @private
  38743. * @function Highcharts.Chart#setUpScrolling
  38744. * @return {void}
  38745. */
  38746. Chart.prototype.setUpScrolling = function () {
  38747. var _this = this;
  38748. var css = {
  38749. WebkitOverflowScrolling: 'touch',
  38750. overflowX: 'hidden',
  38751. overflowY: 'hidden'
  38752. };
  38753. if (this.scrollablePixelsX) {
  38754. css.overflowX = 'auto';
  38755. }
  38756. if (this.scrollablePixelsY) {
  38757. css.overflowY = 'auto';
  38758. }
  38759. // Insert a container with position relative
  38760. // that scrolling and fixed container renders to (#10555)
  38761. this.scrollingParent = createElement('div', {
  38762. className: 'highcharts-scrolling-parent'
  38763. }, {
  38764. position: 'relative'
  38765. }, this.renderTo);
  38766. // Add the necessary divs to provide scrolling
  38767. this.scrollingContainer = createElement('div', {
  38768. 'className': 'highcharts-scrolling'
  38769. }, css, this.scrollingParent);
  38770. // On scroll, reset the chart position because it applies to the scrolled
  38771. // container
  38772. addEvent(this.scrollingContainer, 'scroll', function () {
  38773. if (_this.pointer) {
  38774. delete _this.pointer.chartPosition;
  38775. }
  38776. });
  38777. this.innerContainer = createElement('div', {
  38778. 'className': 'highcharts-inner-container'
  38779. }, null, this.scrollingContainer);
  38780. // Now move the container inside
  38781. this.innerContainer.appendChild(this.container);
  38782. // Don't run again
  38783. this.setUpScrolling = null;
  38784. };
  38785. /**
  38786. * These elements are moved over to the fixed renderer and stay fixed when the
  38787. * user scrolls the chart
  38788. * @private
  38789. */
  38790. Chart.prototype.moveFixedElements = function () {
  38791. var container = this.container,
  38792. fixedRenderer = this.fixedRenderer,
  38793. fixedSelectors = [
  38794. '.highcharts-contextbutton',
  38795. '.highcharts-credits',
  38796. '.highcharts-legend',
  38797. '.highcharts-legend-checkbox',
  38798. '.highcharts-navigator-series',
  38799. '.highcharts-navigator-xaxis',
  38800. '.highcharts-navigator-yaxis',
  38801. '.highcharts-navigator',
  38802. '.highcharts-reset-zoom',
  38803. '.highcharts-drillup-button',
  38804. '.highcharts-scrollbar',
  38805. '.highcharts-subtitle',
  38806. '.highcharts-title'
  38807. ],
  38808. axisClass;
  38809. if (this.scrollablePixelsX && !this.inverted) {
  38810. axisClass = '.highcharts-yaxis';
  38811. }
  38812. else if (this.scrollablePixelsX && this.inverted) {
  38813. axisClass = '.highcharts-xaxis';
  38814. }
  38815. else if (this.scrollablePixelsY && !this.inverted) {
  38816. axisClass = '.highcharts-xaxis';
  38817. }
  38818. else if (this.scrollablePixelsY && this.inverted) {
  38819. axisClass = '.highcharts-yaxis';
  38820. }
  38821. if (axisClass) {
  38822. fixedSelectors.push(axisClass + ":not(.highcharts-radial-axis)", axisClass + "-labels:not(.highcharts-radial-axis-labels)");
  38823. }
  38824. fixedSelectors.forEach(function (className) {
  38825. [].forEach.call(container.querySelectorAll(className), function (elem) {
  38826. (elem.namespaceURI === fixedRenderer.SVG_NS ?
  38827. fixedRenderer.box :
  38828. fixedRenderer.box.parentNode).appendChild(elem);
  38829. elem.style.pointerEvents = 'auto';
  38830. });
  38831. });
  38832. };
  38833. /**
  38834. * @private
  38835. * @function Highcharts.Chart#applyFixed
  38836. * @return {void}
  38837. */
  38838. Chart.prototype.applyFixed = function () {
  38839. var fixedRenderer,
  38840. scrollableWidth,
  38841. scrollableHeight,
  38842. firstTime = !this.fixedDiv,
  38843. chartOptions = this.options.chart,
  38844. scrollableOptions = chartOptions.scrollablePlotArea;
  38845. // First render
  38846. if (firstTime) {
  38847. this.fixedDiv = createElement('div', {
  38848. className: 'highcharts-fixed'
  38849. }, {
  38850. position: 'absolute',
  38851. overflow: 'hidden',
  38852. pointerEvents: 'none',
  38853. zIndex: (chartOptions.style && chartOptions.style.zIndex || 0) + 2,
  38854. top: 0
  38855. }, null, true);
  38856. if (this.scrollingContainer) {
  38857. this.scrollingContainer.parentNode.insertBefore(this.fixedDiv, this.scrollingContainer);
  38858. }
  38859. this.renderTo.style.overflow = 'visible';
  38860. this.fixedRenderer = fixedRenderer = new H.Renderer(this.fixedDiv, this.chartWidth, this.chartHeight, this.options.chart.style);
  38861. // Mask
  38862. this.scrollableMask = fixedRenderer
  38863. .path()
  38864. .attr({
  38865. fill: this.options.chart.backgroundColor || '#fff',
  38866. 'fill-opacity': pick(scrollableOptions.opacity, 0.85),
  38867. zIndex: -1
  38868. })
  38869. .addClass('highcharts-scrollable-mask')
  38870. .add();
  38871. addEvent(this, 'afterShowResetZoom', this.moveFixedElements);
  38872. addEvent(this, 'afterDrilldown', this.moveFixedElements);
  38873. addEvent(this, 'afterLayOutTitles', this.moveFixedElements);
  38874. }
  38875. else {
  38876. // Set the size of the fixed renderer to the visible width
  38877. this.fixedRenderer.setSize(this.chartWidth, this.chartHeight);
  38878. }
  38879. if (this.scrollableDirty || firstTime) {
  38880. this.scrollableDirty = false;
  38881. this.moveFixedElements();
  38882. }
  38883. // Increase the size of the scrollable renderer and background
  38884. scrollableWidth = this.chartWidth + (this.scrollablePixelsX || 0);
  38885. scrollableHeight = this.chartHeight + (this.scrollablePixelsY || 0);
  38886. stop(this.container);
  38887. this.container.style.width = scrollableWidth + 'px';
  38888. this.container.style.height = scrollableHeight + 'px';
  38889. this.renderer.boxWrapper.attr({
  38890. width: scrollableWidth,
  38891. height: scrollableHeight,
  38892. viewBox: [0, 0, scrollableWidth, scrollableHeight].join(' ')
  38893. });
  38894. this.chartBackground.attr({
  38895. width: scrollableWidth,
  38896. height: scrollableHeight
  38897. });
  38898. this.scrollingContainer.style.height = this.chartHeight + 'px';
  38899. // Set scroll position
  38900. if (firstTime) {
  38901. if (scrollableOptions.scrollPositionX) {
  38902. this.scrollingContainer.scrollLeft =
  38903. this.scrollablePixelsX *
  38904. scrollableOptions.scrollPositionX;
  38905. }
  38906. if (scrollableOptions.scrollPositionY) {
  38907. this.scrollingContainer.scrollTop =
  38908. this.scrollablePixelsY *
  38909. scrollableOptions.scrollPositionY;
  38910. }
  38911. }
  38912. // Mask behind the left and right side
  38913. var axisOffset = this.axisOffset,
  38914. maskTop = this.plotTop - axisOffset[0] - 1,
  38915. maskLeft = this.plotLeft - axisOffset[3] - 1,
  38916. maskBottom = this.plotTop + this.plotHeight + axisOffset[2] + 1,
  38917. maskRight = this.plotLeft + this.plotWidth + axisOffset[1] + 1,
  38918. maskPlotRight = this.plotLeft + this.plotWidth -
  38919. (this.scrollablePixelsX || 0),
  38920. maskPlotBottom = this.plotTop + this.plotHeight -
  38921. (this.scrollablePixelsY || 0),
  38922. d;
  38923. if (this.scrollablePixelsX) {
  38924. d = [
  38925. // Left side
  38926. ['M', 0, maskTop],
  38927. ['L', this.plotLeft - 1, maskTop],
  38928. ['L', this.plotLeft - 1, maskBottom],
  38929. ['L', 0, maskBottom],
  38930. ['Z'],
  38931. // Right side
  38932. ['M', maskPlotRight, maskTop],
  38933. ['L', this.chartWidth, maskTop],
  38934. ['L', this.chartWidth, maskBottom],
  38935. ['L', maskPlotRight, maskBottom],
  38936. ['Z']
  38937. ];
  38938. }
  38939. else if (this.scrollablePixelsY) {
  38940. d = [
  38941. // Top side
  38942. ['M', maskLeft, 0],
  38943. ['L', maskLeft, this.plotTop - 1],
  38944. ['L', maskRight, this.plotTop - 1],
  38945. ['L', maskRight, 0],
  38946. ['Z'],
  38947. // Bottom side
  38948. ['M', maskLeft, maskPlotBottom],
  38949. ['L', maskLeft, this.chartHeight],
  38950. ['L', maskRight, this.chartHeight],
  38951. ['L', maskRight, maskPlotBottom],
  38952. ['Z']
  38953. ];
  38954. }
  38955. else {
  38956. d = [['M', 0, 0]];
  38957. }
  38958. if (this.redrawTrigger !== 'adjustHeight') {
  38959. this.scrollableMask.attr({ d: d });
  38960. }
  38961. };
  38962. addEvent(Axis, 'afterInit', function () {
  38963. this.chart.scrollableDirty = true;
  38964. });
  38965. addEvent(Series, 'show', function () {
  38966. this.chart.scrollableDirty = true;
  38967. });
  38968. });
  38969. _registerModule(_modules, 'Core/Axis/StackingAxis.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Utilities.js']], function (A, U) {
  38970. /* *
  38971. *
  38972. * (c) 2010-2021 Torstein Honsi
  38973. *
  38974. * License: www.highcharts.com/license
  38975. *
  38976. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  38977. *
  38978. * */
  38979. var getDeferredAnimation = A.getDeferredAnimation;
  38980. var addEvent = U.addEvent,
  38981. destroyObjectProperties = U.destroyObjectProperties,
  38982. fireEvent = U.fireEvent,
  38983. isNumber = U.isNumber,
  38984. objectEach = U.objectEach,
  38985. pick = U.pick;
  38986. /* eslint-disable valid-jsdoc */
  38987. /**
  38988. * Adds stacking support to axes.
  38989. * @private
  38990. * @class
  38991. */
  38992. var StackingAxisAdditions = /** @class */ (function () {
  38993. /* *
  38994. *
  38995. * Constructors
  38996. *
  38997. * */
  38998. function StackingAxisAdditions(axis) {
  38999. this.oldStacks = {};
  39000. this.stacks = {};
  39001. this.stacksTouched = 0;
  39002. this.axis = axis;
  39003. }
  39004. /* *
  39005. *
  39006. * Functions
  39007. *
  39008. * */
  39009. /**
  39010. * Build the stacks from top down
  39011. * @private
  39012. */
  39013. StackingAxisAdditions.prototype.buildStacks = function () {
  39014. var stacking = this;
  39015. var axis = stacking.axis;
  39016. var axisSeries = axis.series;
  39017. var reversedStacks = axis.options.reversedStacks;
  39018. var len = axisSeries.length;
  39019. var actualSeries,
  39020. i;
  39021. if (!axis.isXAxis) {
  39022. stacking.usePercentage = false;
  39023. i = len;
  39024. while (i--) {
  39025. actualSeries = axisSeries[reversedStacks ? i : len - i - 1];
  39026. actualSeries.setStackedPoints();
  39027. actualSeries.setGroupedPoints();
  39028. }
  39029. // Loop up again to compute percent and stream stack
  39030. for (i = 0; i < len; i++) {
  39031. axisSeries[i].modifyStacks();
  39032. }
  39033. fireEvent(axis, 'afterBuildStacks');
  39034. }
  39035. };
  39036. /**
  39037. * @private
  39038. */
  39039. StackingAxisAdditions.prototype.cleanStacks = function () {
  39040. var stacking = this;
  39041. var axis = stacking.axis;
  39042. var stacks;
  39043. if (!axis.isXAxis) {
  39044. if (stacking.oldStacks) {
  39045. stacks = stacking.stacks = stacking.oldStacks;
  39046. }
  39047. // reset stacks
  39048. objectEach(stacks, function (type) {
  39049. objectEach(type, function (stack) {
  39050. stack.cumulative = stack.total;
  39051. });
  39052. });
  39053. }
  39054. };
  39055. /**
  39056. * Set all the stacks to initial states and destroy unused ones.
  39057. * @private
  39058. */
  39059. StackingAxisAdditions.prototype.resetStacks = function () {
  39060. var _this = this;
  39061. var _a = this,
  39062. axis = _a.axis,
  39063. stacks = _a.stacks;
  39064. if (!axis.isXAxis) {
  39065. objectEach(stacks, function (type) {
  39066. objectEach(type, function (stack, x) {
  39067. // Clean up memory after point deletion (#1044, #4320)
  39068. if (isNumber(stack.touched) &&
  39069. stack.touched < _this.stacksTouched) {
  39070. stack.destroy();
  39071. delete type[x];
  39072. // Reset stacks
  39073. }
  39074. else {
  39075. stack.total = null;
  39076. stack.cumulative = null;
  39077. }
  39078. });
  39079. });
  39080. }
  39081. };
  39082. /**
  39083. * @private
  39084. */
  39085. StackingAxisAdditions.prototype.renderStackTotals = function () {
  39086. var stacking = this;
  39087. var axis = stacking.axis;
  39088. var chart = axis.chart;
  39089. var renderer = chart.renderer;
  39090. var stacks = stacking.stacks;
  39091. var stackLabelsAnim = axis.options.stackLabels && axis.options.stackLabels.animation;
  39092. var animationConfig = getDeferredAnimation(chart,
  39093. stackLabelsAnim || false);
  39094. var stackTotalGroup = stacking.stackTotalGroup = (stacking.stackTotalGroup ||
  39095. renderer
  39096. .g('stack-labels')
  39097. .attr({
  39098. visibility: 'visible',
  39099. zIndex: 6,
  39100. opacity: 0
  39101. })
  39102. .add());
  39103. // plotLeft/Top will change when y axis gets wider so we need to
  39104. // translate the stackTotalGroup at every render call. See bug #506
  39105. // and #516
  39106. stackTotalGroup.translate(chart.plotLeft, chart.plotTop);
  39107. // Render each stack total
  39108. objectEach(stacks, function (type) {
  39109. objectEach(type, function (stack) {
  39110. stack.render(stackTotalGroup);
  39111. });
  39112. });
  39113. stackTotalGroup.animate({
  39114. opacity: 1
  39115. }, animationConfig);
  39116. };
  39117. return StackingAxisAdditions;
  39118. }());
  39119. /**
  39120. * Axis with stacking support.
  39121. * @private
  39122. * @class
  39123. */
  39124. var StackingAxis = /** @class */ (function () {
  39125. function StackingAxis() {
  39126. }
  39127. /* *
  39128. *
  39129. * Static Functions
  39130. *
  39131. * */
  39132. /**
  39133. * Extends axis with stacking support.
  39134. * @private
  39135. */
  39136. StackingAxis.compose = function (AxisClass) {
  39137. var axisProto = AxisClass.prototype;
  39138. addEvent(AxisClass, 'init', StackingAxis.onInit);
  39139. addEvent(AxisClass, 'destroy', StackingAxis.onDestroy);
  39140. };
  39141. /**
  39142. * @private
  39143. */
  39144. StackingAxis.onDestroy = function () {
  39145. var stacking = this.stacking;
  39146. if (!stacking) {
  39147. return;
  39148. }
  39149. var stacks = stacking.stacks;
  39150. // Destroy each stack total
  39151. objectEach(stacks, function (stack, stackKey) {
  39152. destroyObjectProperties(stack);
  39153. stacks[stackKey] = null;
  39154. });
  39155. if (stacking &&
  39156. stacking.stackTotalGroup) {
  39157. stacking.stackTotalGroup.destroy();
  39158. }
  39159. };
  39160. /**
  39161. * @private
  39162. */
  39163. StackingAxis.onInit = function () {
  39164. var axis = this;
  39165. if (!axis.stacking) {
  39166. axis.stacking = new StackingAxisAdditions(axis);
  39167. }
  39168. };
  39169. return StackingAxis;
  39170. }());
  39171. return StackingAxis;
  39172. });
  39173. _registerModule(_modules, 'Extensions/Stacking.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Chart/Chart.js'], _modules['Core/FormatUtilities.js'], _modules['Core/Globals.js'], _modules['Core/Series/Series.js'], _modules['Core/Axis/StackingAxis.js'], _modules['Core/Utilities.js']], function (Axis, Chart, F, H, Series, StackingAxis, U) {
  39174. /* *
  39175. *
  39176. * (c) 2010-2021 Torstein Honsi
  39177. *
  39178. * License: www.highcharts.com/license
  39179. *
  39180. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  39181. *
  39182. * */
  39183. var format = F.format;
  39184. var correctFloat = U.correctFloat,
  39185. defined = U.defined,
  39186. destroyObjectProperties = U.destroyObjectProperties,
  39187. isArray = U.isArray,
  39188. isNumber = U.isNumber,
  39189. objectEach = U.objectEach,
  39190. pick = U.pick;
  39191. /**
  39192. * Stack of data points
  39193. *
  39194. * @product highcharts
  39195. *
  39196. * @interface Highcharts.StackItemObject
  39197. */ /**
  39198. * Alignment settings
  39199. * @name Highcharts.StackItemObject#alignOptions
  39200. * @type {Highcharts.AlignObject}
  39201. */ /**
  39202. * Related axis
  39203. * @name Highcharts.StackItemObject#axis
  39204. * @type {Highcharts.Axis}
  39205. */ /**
  39206. * Cumulative value of the stacked data points
  39207. * @name Highcharts.StackItemObject#cumulative
  39208. * @type {number}
  39209. */ /**
  39210. * True if on the negative side
  39211. * @name Highcharts.StackItemObject#isNegative
  39212. * @type {boolean}
  39213. */ /**
  39214. * Related SVG element
  39215. * @name Highcharts.StackItemObject#label
  39216. * @type {Highcharts.SVGElement}
  39217. */ /**
  39218. * Related stack options
  39219. * @name Highcharts.StackItemObject#options
  39220. * @type {Highcharts.YAxisStackLabelsOptions}
  39221. */ /**
  39222. * Total value of the stacked data points
  39223. * @name Highcharts.StackItemObject#total
  39224. * @type {number}
  39225. */ /**
  39226. * Shared x value of the stack
  39227. * @name Highcharts.StackItemObject#x
  39228. * @type {number}
  39229. */
  39230. ''; // detached doclets above
  39231. /* eslint-disable no-invalid-this, valid-jsdoc */
  39232. /**
  39233. * The class for stacks. Each stack, on a specific X value and either negative
  39234. * or positive, has its own stack item.
  39235. *
  39236. * @private
  39237. * @class
  39238. * @name Highcharts.StackItem
  39239. * @param {Highcharts.Axis} axis
  39240. * @param {Highcharts.YAxisStackLabelsOptions} options
  39241. * @param {boolean} isNegative
  39242. * @param {number} x
  39243. * @param {Highcharts.OptionsStackingValue} [stackOption]
  39244. */
  39245. var StackItem = /** @class */ (function () {
  39246. function StackItem(axis, options, isNegative, x, stackOption) {
  39247. var inverted = axis.chart.inverted;
  39248. this.axis = axis;
  39249. // Tells if the stack is negative
  39250. this.isNegative = isNegative;
  39251. // Save the options to be able to style the label
  39252. this.options = options = options || {};
  39253. // Save the x value to be able to position the label later
  39254. this.x = x;
  39255. // Initialize total value
  39256. this.total = null;
  39257. // This will keep each points' extremes stored by series.index and point
  39258. // index
  39259. this.points = {};
  39260. this.hasValidPoints = false;
  39261. // Save the stack option on the series configuration object,
  39262. // and whether to treat it as percent
  39263. this.stack = stackOption;
  39264. this.leftCliff = 0;
  39265. this.rightCliff = 0;
  39266. // The align options and text align varies on whether the stack is
  39267. // negative and if the chart is inverted or not.
  39268. // First test the user supplied value, then use the dynamic.
  39269. this.alignOptions = {
  39270. align: options.align ||
  39271. (inverted ? (isNegative ? 'left' : 'right') : 'center'),
  39272. verticalAlign: options.verticalAlign ||
  39273. (inverted ? 'middle' : (isNegative ? 'bottom' : 'top')),
  39274. y: options.y,
  39275. x: options.x
  39276. };
  39277. this.textAlign = options.textAlign ||
  39278. (inverted ? (isNegative ? 'right' : 'left') : 'center');
  39279. }
  39280. /**
  39281. * @private
  39282. * @function Highcharts.StackItem#destroy
  39283. */
  39284. StackItem.prototype.destroy = function () {
  39285. destroyObjectProperties(this, this.axis);
  39286. };
  39287. /**
  39288. * Renders the stack total label and adds it to the stack label group.
  39289. *
  39290. * @private
  39291. * @function Highcharts.StackItem#render
  39292. * @param {Highcharts.SVGElement} group
  39293. */
  39294. StackItem.prototype.render = function (group) {
  39295. var chart = this.axis.chart,
  39296. options = this.options,
  39297. formatOption = options.format,
  39298. attr = {},
  39299. str = formatOption ? // format the text in the label
  39300. format(formatOption,
  39301. this,
  39302. chart) :
  39303. options.formatter.call(this);
  39304. // Change the text to reflect the new total and set visibility to hidden
  39305. // in case the serie is hidden
  39306. if (this.label) {
  39307. this.label.attr({ text: str, visibility: 'hidden' });
  39308. }
  39309. else {
  39310. // Create new label
  39311. this.label = chart.renderer
  39312. .label(str, null, null, options.shape, null, null, options.useHTML, false, 'stack-labels');
  39313. attr = {
  39314. r: options.borderRadius || 0,
  39315. text: str,
  39316. rotation: options.rotation,
  39317. padding: pick(options.padding, 5),
  39318. visibility: 'hidden' // hidden until setOffset is called
  39319. };
  39320. if (!chart.styledMode) {
  39321. attr.fill = options.backgroundColor;
  39322. attr.stroke = options.borderColor;
  39323. attr['stroke-width'] = options.borderWidth;
  39324. this.label.css(options.style);
  39325. }
  39326. this.label.attr(attr);
  39327. if (!this.label.added) {
  39328. this.label.add(group); // add to the labels-group
  39329. }
  39330. }
  39331. // Rank it higher than data labels (#8742)
  39332. this.label.labelrank = chart.plotSizeY;
  39333. };
  39334. /**
  39335. * Sets the offset that the stack has from the x value and repositions the
  39336. * label.
  39337. *
  39338. * @private
  39339. * @function Highcarts.StackItem#setOffset
  39340. * @param {number} xOffset
  39341. * @param {number} xWidth
  39342. * @param {number} [boxBottom]
  39343. * @param {number} [boxTop]
  39344. * @param {number} [defaultX]
  39345. */
  39346. StackItem.prototype.setOffset = function (xOffset, xWidth, boxBottom, boxTop, defaultX) {
  39347. var stackItem = this,
  39348. axis = stackItem.axis,
  39349. chart = axis.chart,
  39350. // stack value translated mapped to chart coordinates
  39351. y = axis.translate(axis.stacking.usePercentage ?
  39352. 100 :
  39353. (boxTop ?
  39354. boxTop :
  39355. stackItem.total), 0, 0, 0, 1),
  39356. yZero = axis.translate(boxBottom ? boxBottom : 0), // stack origin
  39357. // stack height:
  39358. h = defined(y) && Math.abs(y - yZero),
  39359. // x position:
  39360. x = pick(defaultX,
  39361. chart.xAxis[0].translate(stackItem.x)) +
  39362. xOffset,
  39363. stackBox = defined(y) && stackItem.getStackBox(chart,
  39364. stackItem,
  39365. x,
  39366. y,
  39367. xWidth,
  39368. h,
  39369. axis),
  39370. label = stackItem.label,
  39371. isNegative = stackItem.isNegative,
  39372. isJustify = pick(stackItem.options.overflow, 'justify') === 'justify',
  39373. textAlign = stackItem.textAlign,
  39374. visible;
  39375. if (label && stackBox) {
  39376. var bBox = label.getBBox(),
  39377. padding = label.padding,
  39378. boxOffsetX = void 0,
  39379. boxOffsetY = void 0;
  39380. if (textAlign === 'left') {
  39381. boxOffsetX = chart.inverted ? -padding : padding;
  39382. }
  39383. else if (textAlign === 'right') {
  39384. boxOffsetX = bBox.width;
  39385. }
  39386. else {
  39387. if (chart.inverted && textAlign === 'center') {
  39388. boxOffsetX = bBox.width / 2;
  39389. }
  39390. else {
  39391. boxOffsetX = chart.inverted ?
  39392. (isNegative ? bBox.width + padding : -padding) : bBox.width / 2;
  39393. }
  39394. }
  39395. boxOffsetY = chart.inverted ?
  39396. bBox.height / 2 : (isNegative ? -padding : bBox.height);
  39397. // Reset alignOptions property after justify #12337
  39398. stackItem.alignOptions.x = pick(stackItem.options.x, 0);
  39399. stackItem.alignOptions.y = pick(stackItem.options.y, 0);
  39400. // Set the stackBox position
  39401. stackBox.x -= boxOffsetX;
  39402. stackBox.y -= boxOffsetY;
  39403. // Align the label to the box
  39404. label.align(stackItem.alignOptions, null, stackBox);
  39405. // Check if label is inside the plotArea #12294
  39406. if (chart.isInsidePlot(label.alignAttr.x + boxOffsetX - stackItem.alignOptions.x, label.alignAttr.y + boxOffsetY - stackItem.alignOptions.y)) {
  39407. label.show();
  39408. }
  39409. else {
  39410. // Move label away to avoid the overlapping issues
  39411. label.alignAttr.y = -9999;
  39412. isJustify = false;
  39413. }
  39414. if (isJustify) {
  39415. // Justify stackLabel into the stackBox
  39416. Series.prototype.justifyDataLabel.call(this.axis, label, stackItem.alignOptions, label.alignAttr, bBox, stackBox);
  39417. }
  39418. label.attr({
  39419. x: label.alignAttr.x,
  39420. y: label.alignAttr.y
  39421. });
  39422. if (pick(!isJustify && stackItem.options.crop, true)) {
  39423. visible =
  39424. isNumber(label.x) &&
  39425. isNumber(label.y) &&
  39426. chart.isInsidePlot(label.x - padding + label.width, label.y) &&
  39427. chart.isInsidePlot(label.x + padding, label.y);
  39428. if (!visible) {
  39429. label.hide();
  39430. }
  39431. }
  39432. }
  39433. };
  39434. /**
  39435. * @private
  39436. * @function Highcharts.StackItem#getStackBox
  39437. *
  39438. * @param {Highcharts.Chart} chart
  39439. *
  39440. * @param {Highcharts.StackItem} stackItem
  39441. *
  39442. * @param {number} x
  39443. *
  39444. * @param {number} y
  39445. *
  39446. * @param {number} xWidth
  39447. *
  39448. * @param {number} h
  39449. *
  39450. * @param {Highcharts.Axis} axis
  39451. *
  39452. * @return {Highcharts.BBoxObject}
  39453. */
  39454. StackItem.prototype.getStackBox = function (chart, stackItem, x, y, xWidth, h, axis) {
  39455. var reversed = stackItem.axis.reversed,
  39456. inverted = chart.inverted,
  39457. axisPos = axis.height + axis.pos -
  39458. (inverted ? chart.plotLeft : chart.plotTop),
  39459. neg = (stackItem.isNegative && !reversed) ||
  39460. (!stackItem.isNegative && reversed); // #4056
  39461. return {
  39462. x: inverted ? (neg ? y - axis.right : y - h + axis.pos - chart.plotLeft) :
  39463. x + chart.xAxis[0].transB - chart.plotLeft,
  39464. y: inverted ?
  39465. axis.height - x - xWidth :
  39466. (neg ?
  39467. (axisPos - y - h) :
  39468. axisPos - y),
  39469. width: inverted ? h : xWidth,
  39470. height: inverted ? xWidth : h
  39471. };
  39472. };
  39473. return StackItem;
  39474. }());
  39475. /**
  39476. * Generate stacks for each series and calculate stacks total values
  39477. *
  39478. * @private
  39479. * @function Highcharts.Chart#getStacks
  39480. */
  39481. Chart.prototype.getStacks = function () {
  39482. var chart = this,
  39483. inverted = chart.inverted;
  39484. // reset stacks for each yAxis
  39485. chart.yAxis.forEach(function (axis) {
  39486. if (axis.stacking && axis.stacking.stacks && axis.hasVisibleSeries) {
  39487. axis.stacking.oldStacks = axis.stacking.stacks;
  39488. }
  39489. });
  39490. chart.series.forEach(function (series) {
  39491. var xAxisOptions = series.xAxis && series.xAxis.options || {};
  39492. if (series.options.stacking &&
  39493. (series.visible === true ||
  39494. chart.options.chart.ignoreHiddenSeries === false)) {
  39495. series.stackKey = [
  39496. series.type,
  39497. pick(series.options.stack, ''),
  39498. inverted ? xAxisOptions.top : xAxisOptions.left,
  39499. inverted ? xAxisOptions.height : xAxisOptions.width
  39500. ].join(',');
  39501. }
  39502. });
  39503. };
  39504. // Stacking methods defined on the Axis prototype
  39505. StackingAxis.compose(Axis);
  39506. // Stacking methods defined for Series prototype
  39507. /**
  39508. * Set grouped points in a stack-like object. When `centerInCategory` is true,
  39509. * and `stacking` is not enabled, we need a pseudo (horizontal) stack in order
  39510. * to handle grouping of points within the same category.
  39511. *
  39512. * @private
  39513. * @function Highcharts.Series#setStackedPoints
  39514. * @return {void}
  39515. */
  39516. Series.prototype.setGroupedPoints = function () {
  39517. var stacking = this.yAxis.stacking;
  39518. if (this.options.centerInCategory &&
  39519. (this.is('column') || this.is('columnrange')) &&
  39520. // With stacking enabled, we already have stacks that we can compute
  39521. // from
  39522. !this.options.stacking &&
  39523. // With only one series, we don't need to consider centerInCategory
  39524. this.chart.series.length > 1) {
  39525. Series.prototype.setStackedPoints.call(this, 'group');
  39526. // After updating, if we now have proper stacks, we must delete the group
  39527. // pseudo stacks (#14986)
  39528. }
  39529. else if (stacking) {
  39530. objectEach(stacking.stacks, function (type, key) {
  39531. if (key.slice(-5) === 'group') {
  39532. objectEach(type, function (stack) { return stack.destroy(); });
  39533. delete stacking.stacks[key];
  39534. }
  39535. });
  39536. }
  39537. };
  39538. /**
  39539. * Adds series' points value to corresponding stack
  39540. *
  39541. * @private
  39542. * @function Highcharts.Series#setStackedPoints
  39543. */
  39544. Series.prototype.setStackedPoints = function (stackingParam) {
  39545. var stacking = stackingParam || this.options.stacking;
  39546. if (!stacking || (this.visible !== true &&
  39547. this.chart.options.chart.ignoreHiddenSeries !== false)) {
  39548. return;
  39549. }
  39550. var series = this, xData = series.processedXData, yData = series.processedYData, stackedYData = [], yDataLength = yData.length, seriesOptions = series.options, threshold = seriesOptions.threshold, stackThreshold = pick(seriesOptions.startFromThreshold && threshold, 0), stackOption = seriesOptions.stack, stackKey = stackingParam ? series.type + "," + stacking : series.stackKey, negKey = '-' + stackKey, negStacks = series.negStacks, yAxis = series.yAxis, stacks = yAxis.stacking.stacks, oldStacks = yAxis.stacking.oldStacks, stackIndicator, isNegative, stack, other, key, pointKey, i, x, y;
  39551. yAxis.stacking.stacksTouched += 1;
  39552. // loop over the non-null y values and read them into a local array
  39553. for (i = 0; i < yDataLength; i++) {
  39554. x = xData[i];
  39555. y = yData[i];
  39556. stackIndicator = series.getStackIndicator(stackIndicator, x, series.index);
  39557. pointKey = stackIndicator.key;
  39558. // Read stacked values into a stack based on the x value,
  39559. // the sign of y and the stack key. Stacking is also handled for null
  39560. // values (#739)
  39561. isNegative = negStacks && y < (stackThreshold ? 0 : threshold);
  39562. key = isNegative ? negKey : stackKey;
  39563. // Create empty object for this stack if it doesn't exist yet
  39564. if (!stacks[key]) {
  39565. stacks[key] =
  39566. {};
  39567. }
  39568. // Initialize StackItem for this x
  39569. if (!stacks[key][x]) {
  39570. if (oldStacks[key] &&
  39571. oldStacks[key][x]) {
  39572. stacks[key][x] = oldStacks[key][x];
  39573. stacks[key][x].total = null;
  39574. }
  39575. else {
  39576. stacks[key][x] = new StackItem(yAxis, yAxis.options.stackLabels, isNegative, x, stackOption);
  39577. }
  39578. }
  39579. // If the StackItem doesn't exist, create it first
  39580. stack = stacks[key][x];
  39581. if (y !== null) {
  39582. stack.points[pointKey] = stack.points[series.index] =
  39583. [pick(stack.cumulative, stackThreshold)];
  39584. // Record the base of the stack
  39585. if (!defined(stack.cumulative)) {
  39586. stack.base = pointKey;
  39587. }
  39588. stack.touched = yAxis.stacking.stacksTouched;
  39589. // In area charts, if there are multiple points on the same X value,
  39590. // let the area fill the full span of those points
  39591. if (stackIndicator.index > 0 && series.singleStacks === false) {
  39592. stack.points[pointKey][0] =
  39593. stack.points[series.index + ',' + x + ',0'][0];
  39594. }
  39595. // When updating to null, reset the point stack (#7493)
  39596. }
  39597. else {
  39598. stack.points[pointKey] = stack.points[series.index] =
  39599. null;
  39600. }
  39601. // Add value to the stack total
  39602. if (stacking === 'percent') {
  39603. // Percent stacked column, totals are the same for the positive and
  39604. // negative stacks
  39605. other = isNegative ? stackKey : negKey;
  39606. if (negStacks && stacks[other] && stacks[other][x]) {
  39607. other = stacks[other][x];
  39608. stack.total = other.total =
  39609. Math.max(other.total, stack.total) +
  39610. Math.abs(y) ||
  39611. 0;
  39612. // Percent stacked areas
  39613. }
  39614. else {
  39615. stack.total =
  39616. correctFloat(stack.total + (Math.abs(y) || 0));
  39617. }
  39618. }
  39619. else if (stacking === 'group') {
  39620. if (isArray(y)) {
  39621. y = y[0];
  39622. }
  39623. // In this stack, the total is the number of valid points
  39624. if (y !== null) {
  39625. stack.total = (stack.total || 0) + 1;
  39626. }
  39627. }
  39628. else {
  39629. stack.total = correctFloat(stack.total + (y || 0));
  39630. }
  39631. if (stacking === 'group') {
  39632. // This point's index within the stack, pushed to stack.points[1]
  39633. stack.cumulative = (stack.total || 1) - 1;
  39634. }
  39635. else {
  39636. stack.cumulative =
  39637. pick(stack.cumulative, stackThreshold) + (y || 0);
  39638. }
  39639. if (y !== null) {
  39640. stack.points[pointKey].push(stack.cumulative);
  39641. stackedYData[i] = stack.cumulative;
  39642. stack.hasValidPoints = true;
  39643. }
  39644. }
  39645. if (stacking === 'percent') {
  39646. yAxis.stacking.usePercentage = true;
  39647. }
  39648. if (stacking !== 'group') {
  39649. this.stackedYData = stackedYData; // To be used in getExtremes
  39650. }
  39651. // Reset old stacks
  39652. yAxis.stacking.oldStacks = {};
  39653. };
  39654. /**
  39655. * Iterate over all stacks and compute the absolute values to percent
  39656. *
  39657. * @private
  39658. * @function Highcharts.Series#modifyStacks
  39659. */
  39660. Series.prototype.modifyStacks = function () {
  39661. var series = this,
  39662. yAxis = series.yAxis,
  39663. stackKey = series.stackKey,
  39664. stacks = yAxis.stacking.stacks,
  39665. processedXData = series.processedXData,
  39666. stackIndicator,
  39667. stacking = series.options.stacking;
  39668. if (series[stacking + 'Stacker']) { // Modifier function exists
  39669. [stackKey, '-' + stackKey].forEach(function (key) {
  39670. var i = processedXData.length,
  39671. x,
  39672. stack,
  39673. pointExtremes;
  39674. while (i--) {
  39675. x = processedXData[i];
  39676. stackIndicator = series.getStackIndicator(stackIndicator, x, series.index, key);
  39677. stack = stacks[key] && stacks[key][x];
  39678. pointExtremes =
  39679. stack && stack.points[stackIndicator.key];
  39680. if (pointExtremes) {
  39681. series[stacking + 'Stacker'](pointExtremes, stack, i);
  39682. }
  39683. }
  39684. });
  39685. }
  39686. };
  39687. /**
  39688. * Modifier function for percent stacks. Blows up the stack to 100%.
  39689. *
  39690. * @private
  39691. * @function Highcharts.Series#percentStacker
  39692. */
  39693. Series.prototype.percentStacker = function (pointExtremes, stack, i) {
  39694. var totalFactor = stack.total ? 100 / stack.total : 0;
  39695. // Y bottom value
  39696. pointExtremes[0] = correctFloat(pointExtremes[0] * totalFactor);
  39697. // Y value
  39698. pointExtremes[1] = correctFloat(pointExtremes[1] * totalFactor);
  39699. this.stackedYData[i] = pointExtremes[1];
  39700. };
  39701. /**
  39702. * Get stack indicator, according to it's x-value, to determine points with the
  39703. * same x-value
  39704. *
  39705. * @private
  39706. * @function Highcharts.Series#getStackIndicator
  39707. * @param {Highcharts.StackItemIndicatorObject|undefined} stackIndicator
  39708. * @param {number} x
  39709. * @param {number} index
  39710. * @param {string} [key]
  39711. * @return {Highcharts.StackItemIndicatorObject}
  39712. */
  39713. Series.prototype.getStackIndicator = function (stackIndicator, x, index, key) {
  39714. // Update stack indicator, when:
  39715. // first point in a stack || x changed || stack type (negative vs positive)
  39716. // changed:
  39717. if (!defined(stackIndicator) ||
  39718. stackIndicator.x !== x ||
  39719. (key && stackIndicator.key !== key)) {
  39720. stackIndicator = {
  39721. x: x,
  39722. index: 0,
  39723. key: key
  39724. };
  39725. }
  39726. else {
  39727. (stackIndicator).index++;
  39728. }
  39729. stackIndicator.key =
  39730. [index, x, stackIndicator.index].join(',');
  39731. return stackIndicator;
  39732. };
  39733. H.StackItem = StackItem;
  39734. return H.StackItem;
  39735. });
  39736. _registerModule(_modules, 'Series/Line/LineSeries.js', [_modules['Core/Color/Palette.js'], _modules['Core/Series/Series.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (palette, Series, SeriesRegistry, U) {
  39737. /* *
  39738. *
  39739. * (c) 2010-2021 Torstein Honsi
  39740. *
  39741. * License: www.highcharts.com/license
  39742. *
  39743. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  39744. *
  39745. * */
  39746. var __extends = (this && this.__extends) || (function () {
  39747. var extendStatics = function (d,
  39748. b) {
  39749. extendStatics = Object.setPrototypeOf ||
  39750. ({ __proto__: [] } instanceof Array && function (d,
  39751. b) { d.__proto__ = b; }) ||
  39752. function (d,
  39753. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  39754. return extendStatics(d, b);
  39755. };
  39756. return function (d, b) {
  39757. extendStatics(d, b);
  39758. function __() { this.constructor = d; }
  39759. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  39760. };
  39761. })();
  39762. var defined = U.defined,
  39763. merge = U.merge;
  39764. /* *
  39765. *
  39766. * Class
  39767. *
  39768. * */
  39769. /**
  39770. * The line series is the base type and is therefor the series base prototype.
  39771. *
  39772. * @private
  39773. */
  39774. var LineSeries = /** @class */ (function (_super) {
  39775. __extends(LineSeries, _super);
  39776. function LineSeries() {
  39777. /* *
  39778. *
  39779. * Static Functions
  39780. *
  39781. * */
  39782. var _this = _super !== null && _super.apply(this,
  39783. arguments) || this;
  39784. /* *
  39785. *
  39786. * Properties
  39787. *
  39788. * */
  39789. _this.data = void 0;
  39790. _this.options = void 0;
  39791. _this.points = void 0;
  39792. return _this;
  39793. }
  39794. /* *
  39795. *
  39796. * Functions
  39797. *
  39798. * */
  39799. /**
  39800. * Draw the graph. Called internally when rendering line-like series
  39801. * types. The first time it generates the `series.graph` item and
  39802. * optionally other series-wide items like `series.area` for area
  39803. * charts. On subsequent calls these items are updated with new
  39804. * positions and attributes.
  39805. *
  39806. * @function Highcharts.Series#drawGraph
  39807. */
  39808. LineSeries.prototype.drawGraph = function () {
  39809. var series = this,
  39810. options = this.options,
  39811. graphPath = (this.gappedPath || this.getGraphPath).call(this),
  39812. styledMode = this.chart.styledMode,
  39813. props = [[
  39814. 'graph',
  39815. 'highcharts-graph'
  39816. ]];
  39817. // Presentational properties
  39818. if (!styledMode) {
  39819. props[0].push((options.lineColor ||
  39820. this.color ||
  39821. palette.neutralColor20 // when colorByPoint = true
  39822. ), options.dashStyle);
  39823. }
  39824. props = series.getZonesGraphs(props);
  39825. // Draw the graph
  39826. props.forEach(function (prop, i) {
  39827. var graphKey = prop[0],
  39828. graph = series[graphKey],
  39829. verb = graph ? 'animate' : 'attr',
  39830. attribs;
  39831. if (graph) {
  39832. graph.endX = series.preventGraphAnimation ?
  39833. null :
  39834. graphPath.xMap;
  39835. graph.animate({ d: graphPath });
  39836. }
  39837. else if (graphPath.length) { // #1487
  39838. /**
  39839. * SVG element of area-based charts. Can be used for styling
  39840. * purposes. If zones are configured, this element will be
  39841. * hidden and replaced by multiple zone areas, accessible
  39842. * via `series['zone-area-x']` (where x is a number,
  39843. * starting with 0).
  39844. *
  39845. * @name Highcharts.Series#area
  39846. * @type {Highcharts.SVGElement|undefined}
  39847. */
  39848. /**
  39849. * SVG element of line-based charts. Can be used for styling
  39850. * purposes. If zones are configured, this element will be
  39851. * hidden and replaced by multiple zone lines, accessible
  39852. * via `series['zone-graph-x']` (where x is a number,
  39853. * starting with 0).
  39854. *
  39855. * @name Highcharts.Series#graph
  39856. * @type {Highcharts.SVGElement|undefined}
  39857. */
  39858. series[graphKey] = graph = series.chart.renderer
  39859. .path(graphPath)
  39860. .addClass(prop[1])
  39861. .attr({ zIndex: 1 }) // #1069
  39862. .add(series.group);
  39863. }
  39864. if (graph && !styledMode) {
  39865. attribs = {
  39866. 'stroke': prop[2],
  39867. 'stroke-width': options.lineWidth,
  39868. // Polygon series use filled graph
  39869. 'fill': (series.fillGraph && series.color) || 'none'
  39870. };
  39871. if (prop[3]) {
  39872. attribs.dashstyle = prop[3];
  39873. }
  39874. else if (options.linecap !== 'square') {
  39875. attribs['stroke-linecap'] =
  39876. attribs['stroke-linejoin'] = 'round';
  39877. }
  39878. graph[verb](attribs)
  39879. // Add shadow to normal series (0) or to first
  39880. // zone (1) #3932
  39881. .shadow((i < 2) && options.shadow);
  39882. }
  39883. // Helpers for animation
  39884. if (graph) {
  39885. graph.startX = graphPath.xMap;
  39886. graph.isArea = graphPath.isArea; // For arearange animation
  39887. }
  39888. });
  39889. };
  39890. // eslint-disable-next-line valid-jsdoc
  39891. /**
  39892. * Get the graph path.
  39893. *
  39894. * @private
  39895. */
  39896. LineSeries.prototype.getGraphPath = function (points, nullsAsZeroes, connectCliffs) {
  39897. var series = this,
  39898. options = series.options,
  39899. step = options.step,
  39900. reversed,
  39901. graphPath = [],
  39902. xMap = [],
  39903. gap;
  39904. points = points || series.points;
  39905. // Bottom of a stack is reversed
  39906. reversed = points.reversed;
  39907. if (reversed) {
  39908. points.reverse();
  39909. }
  39910. // Reverse the steps (#5004)
  39911. step = {
  39912. right: 1,
  39913. center: 2
  39914. }[step] || (step && 3);
  39915. if (step && reversed) {
  39916. step = 4 - step;
  39917. }
  39918. // Remove invalid points, especially in spline (#5015)
  39919. points = this.getValidPoints(points, false, !(options.connectNulls && !nullsAsZeroes && !connectCliffs));
  39920. // Build the line
  39921. points.forEach(function (point, i) {
  39922. var plotX = point.plotX,
  39923. plotY = point.plotY,
  39924. lastPoint = points[i - 1],
  39925. // the path to this point from the previous
  39926. pathToPoint;
  39927. if ((point.leftCliff || (lastPoint && lastPoint.rightCliff)) &&
  39928. !connectCliffs) {
  39929. gap = true; // ... and continue
  39930. }
  39931. // Line series, nullsAsZeroes is not handled
  39932. if (point.isNull && !defined(nullsAsZeroes) && i > 0) {
  39933. gap = !options.connectNulls;
  39934. // Area series, nullsAsZeroes is set
  39935. }
  39936. else if (point.isNull && !nullsAsZeroes) {
  39937. gap = true;
  39938. }
  39939. else {
  39940. if (i === 0 || gap) {
  39941. pathToPoint = [[
  39942. 'M',
  39943. point.plotX,
  39944. point.plotY
  39945. ]];
  39946. // Generate the spline as defined in the SplineSeries object
  39947. }
  39948. else if (series.getPointSpline) {
  39949. pathToPoint = [series.getPointSpline(points, point, i)];
  39950. }
  39951. else if (step) {
  39952. if (step === 1) { // right
  39953. pathToPoint = [[
  39954. 'L',
  39955. lastPoint.plotX,
  39956. plotY
  39957. ]];
  39958. }
  39959. else if (step === 2) { // center
  39960. pathToPoint = [[
  39961. 'L',
  39962. (lastPoint.plotX + plotX) / 2,
  39963. lastPoint.plotY
  39964. ], [
  39965. 'L',
  39966. (lastPoint.plotX + plotX) / 2,
  39967. plotY
  39968. ]];
  39969. }
  39970. else {
  39971. pathToPoint = [[
  39972. 'L',
  39973. plotX,
  39974. lastPoint.plotY
  39975. ]];
  39976. }
  39977. pathToPoint.push([
  39978. 'L',
  39979. plotX,
  39980. plotY
  39981. ]);
  39982. }
  39983. else {
  39984. // normal line to next point
  39985. pathToPoint = [[
  39986. 'L',
  39987. plotX,
  39988. plotY
  39989. ]];
  39990. }
  39991. // Prepare for animation. When step is enabled, there are
  39992. // two path nodes for each x value.
  39993. xMap.push(point.x);
  39994. if (step) {
  39995. xMap.push(point.x);
  39996. if (step === 2) { // step = center (#8073)
  39997. xMap.push(point.x);
  39998. }
  39999. }
  40000. graphPath.push.apply(graphPath, pathToPoint);
  40001. gap = false;
  40002. }
  40003. });
  40004. graphPath.xMap = xMap;
  40005. series.graphPath = graphPath;
  40006. return graphPath;
  40007. };
  40008. // eslint-disable-next-line valid-jsdoc
  40009. /**
  40010. * Get zones properties for building graphs. Extendable by series with
  40011. * multiple lines within one series.
  40012. *
  40013. * @private
  40014. */
  40015. LineSeries.prototype.getZonesGraphs = function (props) {
  40016. // Add the zone properties if any
  40017. this.zones.forEach(function (zone, i) {
  40018. var propset = [
  40019. 'zone-graph-' + i,
  40020. 'highcharts-graph highcharts-zone-graph-' + i + ' ' +
  40021. (zone.className || '')
  40022. ];
  40023. if (!this.chart.styledMode) {
  40024. propset.push((zone.color || this.color), (zone.dashStyle || this.options.dashStyle));
  40025. }
  40026. props.push(propset);
  40027. }, this);
  40028. return props;
  40029. };
  40030. /**
  40031. * General options for all series types.
  40032. *
  40033. * @optionparent plotOptions.series
  40034. */
  40035. LineSeries.defaultOptions = merge(Series.defaultOptions, {
  40036. // nothing here yet
  40037. });
  40038. return LineSeries;
  40039. }(Series));
  40040. SeriesRegistry.registerSeriesType('line', LineSeries);
  40041. /* *
  40042. *
  40043. * Default Export
  40044. *
  40045. * */
  40046. /* *
  40047. *
  40048. * API Options
  40049. *
  40050. * */
  40051. /**
  40052. * A line series displays information as a series of data points connected by
  40053. * straight line segments.
  40054. *
  40055. * @sample {highcharts} highcharts/demo/line-basic/
  40056. * Line chart
  40057. * @sample {highstock} stock/demo/basic-line/
  40058. * Line chart
  40059. *
  40060. * @extends plotOptions.series
  40061. * @product highcharts highstock
  40062. * @apioption plotOptions.line
  40063. */
  40064. /**
  40065. * The SVG value used for the `stroke-linecap` and `stroke-linejoin`
  40066. * of a line graph. Round means that lines are rounded in the ends and
  40067. * bends.
  40068. *
  40069. * @type {Highcharts.SeriesLinecapValue}
  40070. * @default round
  40071. * @since 3.0.7
  40072. * @apioption plotOptions.line.linecap
  40073. */
  40074. /**
  40075. * A `line` series. If the [type](#series.line.type) option is not
  40076. * specified, it is inherited from [chart.type](#chart.type).
  40077. *
  40078. * @extends series,plotOptions.line
  40079. * @excluding dataParser,dataURL
  40080. * @product highcharts highstock
  40081. * @apioption series.line
  40082. */
  40083. /**
  40084. * An array of data points for the series. For the `line` series type,
  40085. * points can be given in the following ways:
  40086. *
  40087. * 1. An array of numerical values. In this case, the numerical values will be
  40088. * interpreted as `y` options. The `x` values will be automatically
  40089. * calculated, either starting at 0 and incremented by 1, or from
  40090. * `pointStart` and `pointInterval` given in the series options. If the axis
  40091. * has categories, these will be used. Example:
  40092. * ```js
  40093. * data: [0, 5, 3, 5]
  40094. * ```
  40095. *
  40096. * 2. An array of arrays with 2 values. In this case, the values correspond to
  40097. * `x,y`. If the first value is a string, it is applied as the name of the
  40098. * point, and the `x` value is inferred.
  40099. * ```js
  40100. * data: [
  40101. * [0, 1],
  40102. * [1, 2],
  40103. * [2, 8]
  40104. * ]
  40105. * ```
  40106. *
  40107. * 3. An array of objects with named values. The following snippet shows only a
  40108. * few settings, see the complete options set below. If the total number of
  40109. * data points exceeds the series'
  40110. * [turboThreshold](#series.line.turboThreshold),
  40111. * this option is not available.
  40112. * ```js
  40113. * data: [{
  40114. * x: 1,
  40115. * y: 9,
  40116. * name: "Point2",
  40117. * color: "#00FF00"
  40118. * }, {
  40119. * x: 1,
  40120. * y: 6,
  40121. * name: "Point1",
  40122. * color: "#FF00FF"
  40123. * }]
  40124. * ```
  40125. *
  40126. * **Note:** In TypeScript you have to extend `PointOptionsObject` with an
  40127. * additional declaration to allow custom data types:
  40128. * ```ts
  40129. * declare module `highcharts` {
  40130. * interface PointOptionsObject {
  40131. * custom: Record<string, (boolean|number|string)>;
  40132. * }
  40133. * }
  40134. * ```
  40135. *
  40136. * @sample {highcharts} highcharts/chart/reflow-true/
  40137. * Numerical values
  40138. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  40139. * Arrays of numeric x and y
  40140. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  40141. * Arrays of datetime x and y
  40142. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  40143. * Arrays of point.name and y
  40144. * @sample {highcharts} highcharts/series/data-array-of-objects/
  40145. * Config objects
  40146. *
  40147. * @declare Highcharts.PointOptionsObject
  40148. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  40149. * @apioption series.line.data
  40150. */
  40151. /**
  40152. * An additional, individual class name for the data point's graphic
  40153. * representation.
  40154. *
  40155. * @type {string}
  40156. * @since 5.0.0
  40157. * @product highcharts gantt
  40158. * @apioption series.line.data.className
  40159. */
  40160. /**
  40161. * Individual color for the point. By default the color is pulled from
  40162. * the global `colors` array.
  40163. *
  40164. * In styled mode, the `color` option doesn't take effect. Instead, use
  40165. * `colorIndex`.
  40166. *
  40167. * @sample {highcharts} highcharts/point/color/
  40168. * Mark the highest point
  40169. *
  40170. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  40171. * @product highcharts highstock gantt
  40172. * @apioption series.line.data.color
  40173. */
  40174. /**
  40175. * A specific color index to use for the point, so its graphic representations
  40176. * are given the class name `highcharts-color-{n}`. In styled mode this will
  40177. * change the color of the graphic. In non-styled mode, the color by is set by
  40178. * the `fill` attribute, so the change in class name won't have a visual effect
  40179. * by default.
  40180. *
  40181. * @type {number}
  40182. * @since 5.0.0
  40183. * @product highcharts gantt
  40184. * @apioption series.line.data.colorIndex
  40185. */
  40186. /**
  40187. * A reserved subspace to store options and values for customized functionality.
  40188. * Here you can add additional data for your own event callbacks and formatter
  40189. * callbacks.
  40190. *
  40191. * @sample {highcharts} highcharts/point/custom/
  40192. * Point and series with custom data
  40193. *
  40194. * @type {Highcharts.Dictionary<*>}
  40195. * @apioption series.line.data.custom
  40196. */
  40197. /**
  40198. * Individual data label for each point. The options are the same as
  40199. * the ones for [plotOptions.series.dataLabels](
  40200. * #plotOptions.series.dataLabels).
  40201. *
  40202. * @sample highcharts/point/datalabels/
  40203. * Show a label for the last value
  40204. *
  40205. * @declare Highcharts.DataLabelsOptions
  40206. * @extends plotOptions.line.dataLabels
  40207. * @product highcharts highstock gantt
  40208. * @apioption series.line.data.dataLabels
  40209. */
  40210. /**
  40211. * A description of the point to add to the screen reader information
  40212. * about the point.
  40213. *
  40214. * @type {string}
  40215. * @since 5.0.0
  40216. * @requires modules/accessibility
  40217. * @apioption series.line.data.description
  40218. */
  40219. /**
  40220. * An id for the point. This can be used after render time to get a
  40221. * pointer to the point object through `chart.get()`.
  40222. *
  40223. * @sample {highcharts} highcharts/point/id/
  40224. * Remove an id'd point
  40225. *
  40226. * @type {string}
  40227. * @since 1.2.0
  40228. * @product highcharts highstock gantt
  40229. * @apioption series.line.data.id
  40230. */
  40231. /**
  40232. * The rank for this point's data label in case of collision. If two
  40233. * data labels are about to overlap, only the one with the highest `labelrank`
  40234. * will be drawn.
  40235. *
  40236. * @type {number}
  40237. * @apioption series.line.data.labelrank
  40238. */
  40239. /**
  40240. * The name of the point as shown in the legend, tooltip, dataLabels, etc.
  40241. *
  40242. * @see [xAxis.uniqueNames](#xAxis.uniqueNames)
  40243. *
  40244. * @sample {highcharts} highcharts/series/data-array-of-objects/
  40245. * Point names
  40246. *
  40247. * @type {string}
  40248. * @apioption series.line.data.name
  40249. */
  40250. /**
  40251. * Whether the data point is selected initially.
  40252. *
  40253. * @type {boolean}
  40254. * @default false
  40255. * @product highcharts highstock gantt
  40256. * @apioption series.line.data.selected
  40257. */
  40258. /**
  40259. * The x value of the point. For datetime axes, the X value is the timestamp
  40260. * in milliseconds since 1970.
  40261. *
  40262. * @type {number}
  40263. * @product highcharts highstock
  40264. * @apioption series.line.data.x
  40265. */
  40266. /**
  40267. * The y value of the point.
  40268. *
  40269. * @type {number|null}
  40270. * @product highcharts highstock
  40271. * @apioption series.line.data.y
  40272. */
  40273. /**
  40274. * The individual point events.
  40275. *
  40276. * @extends plotOptions.series.point.events
  40277. * @product highcharts highstock gantt
  40278. * @apioption series.line.data.events
  40279. */
  40280. /**
  40281. * Options for the point markers of line-like series.
  40282. *
  40283. * @declare Highcharts.PointMarkerOptionsObject
  40284. * @extends plotOptions.series.marker
  40285. * @product highcharts highstock
  40286. * @apioption series.line.data.marker
  40287. */
  40288. ''; // include precedent doclets in transpilat
  40289. return LineSeries;
  40290. });
  40291. _registerModule(_modules, 'Series/Area/AreaSeries.js', [_modules['Core/Color/Color.js'], _modules['Mixins/LegendSymbol.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (Color, LegendSymbolMixin, SeriesRegistry, U) {
  40292. /* *
  40293. *
  40294. * (c) 2010-2021 Torstein Honsi
  40295. *
  40296. * License: www.highcharts.com/license
  40297. *
  40298. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  40299. *
  40300. * */
  40301. var __extends = (this && this.__extends) || (function () {
  40302. var extendStatics = function (d,
  40303. b) {
  40304. extendStatics = Object.setPrototypeOf ||
  40305. ({ __proto__: [] } instanceof Array && function (d,
  40306. b) { d.__proto__ = b; }) ||
  40307. function (d,
  40308. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40309. return extendStatics(d, b);
  40310. };
  40311. return function (d, b) {
  40312. extendStatics(d, b);
  40313. function __() { this.constructor = d; }
  40314. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40315. };
  40316. })();
  40317. var color = Color.parse;
  40318. var LineSeries = SeriesRegistry.seriesTypes.line;
  40319. var extend = U.extend,
  40320. merge = U.merge,
  40321. objectEach = U.objectEach,
  40322. pick = U.pick;
  40323. /* *
  40324. *
  40325. * Class
  40326. *
  40327. * */
  40328. /**
  40329. * Area series type.
  40330. *
  40331. * @private
  40332. * @class
  40333. * @name AreaSeries
  40334. *
  40335. * @augments LineSeries
  40336. */
  40337. var AreaSeries = /** @class */ (function (_super) {
  40338. __extends(AreaSeries, _super);
  40339. function AreaSeries() {
  40340. /* *
  40341. *
  40342. * Static Properties
  40343. *
  40344. * */
  40345. var _this = _super !== null && _super.apply(this,
  40346. arguments) || this;
  40347. _this.data = void 0;
  40348. _this.options = void 0;
  40349. _this.points = void 0;
  40350. return _this;
  40351. /* eslint-enable valid-jsdoc */
  40352. }
  40353. /* *
  40354. *
  40355. * Functions
  40356. *
  40357. * */
  40358. /* eslint-disable valid-jsdoc */
  40359. /**
  40360. * Draw the graph and the underlying area. This method calls the Series
  40361. * base function and adds the area. The areaPath is calculated in the
  40362. * getSegmentPath method called from Series.prototype.drawGraph.
  40363. * @private
  40364. */
  40365. AreaSeries.prototype.drawGraph = function () {
  40366. // Define or reset areaPath
  40367. this.areaPath = [];
  40368. // Call the base method
  40369. _super.prototype.drawGraph.apply(this);
  40370. // Define local variables
  40371. var series = this,
  40372. areaPath = this.areaPath,
  40373. options = this.options,
  40374. zones = this.zones,
  40375. props = [[
  40376. 'area',
  40377. 'highcharts-area',
  40378. this.color,
  40379. options.fillColor
  40380. ]]; // area name, main color, fill color
  40381. zones.forEach(function (zone,
  40382. i) {
  40383. props.push([
  40384. 'zone-area-' + i,
  40385. 'highcharts-area highcharts-zone-area-' + i + ' ' +
  40386. zone.className,
  40387. zone.color || series.color,
  40388. zone.fillColor || options.fillColor
  40389. ]);
  40390. });
  40391. props.forEach(function (prop) {
  40392. var areaKey = prop[0],
  40393. area = series[areaKey],
  40394. verb = area ? 'animate' : 'attr',
  40395. attribs = {};
  40396. // Create or update the area
  40397. if (area) { // update
  40398. area.endX = series.preventGraphAnimation ?
  40399. null :
  40400. areaPath.xMap;
  40401. area.animate({ d: areaPath });
  40402. }
  40403. else { // create
  40404. attribs.zIndex = 0; // #1069
  40405. area = series[areaKey] = series.chart.renderer
  40406. .path(areaPath)
  40407. .addClass(prop[1])
  40408. .add(series.group);
  40409. area.isArea = true;
  40410. }
  40411. if (!series.chart.styledMode) {
  40412. attribs.fill = pick(prop[3], color(prop[2])
  40413. .setOpacity(pick(options.fillOpacity, 0.75))
  40414. .get());
  40415. }
  40416. area[verb](attribs);
  40417. area.startX = areaPath.xMap;
  40418. area.shiftUnit = options.step ? 2 : 1;
  40419. });
  40420. };
  40421. /**
  40422. * @private
  40423. */
  40424. AreaSeries.prototype.getGraphPath = function (points) {
  40425. var getGraphPath = LineSeries.prototype.getGraphPath, graphPath, options = this.options, stacking = options.stacking, yAxis = this.yAxis, topPath, bottomPath, bottomPoints = [], graphPoints = [], seriesIndex = this.index, i, areaPath, plotX, stacks = yAxis.stacking.stacks[this.stackKey], threshold = options.threshold, translatedThreshold = Math.round(// #10909
  40426. yAxis.getThreshold(options.threshold)), isNull, yBottom, connectNulls = pick(// #10574
  40427. options.connectNulls, stacking === 'percent'),
  40428. // To display null points in underlying stacked series, this
  40429. // series graph must be broken, and the area also fall down to
  40430. // fill the gap left by the null point. #2069
  40431. addDummyPoints = function (i, otherI, side) {
  40432. var point = points[i], stackedValues = stacking &&
  40433. stacks[point.x].points[seriesIndex], nullVal = point[side + 'Null'] || 0, cliffVal = point[side + 'Cliff'] || 0, top, bottom, isNull = true;
  40434. if (cliffVal || nullVal) {
  40435. top = (nullVal ?
  40436. stackedValues[0] :
  40437. stackedValues[1]) + cliffVal;
  40438. bottom = stackedValues[0] + cliffVal;
  40439. isNull = !!nullVal;
  40440. }
  40441. else if (!stacking &&
  40442. points[otherI] &&
  40443. points[otherI].isNull) {
  40444. top = bottom = threshold;
  40445. }
  40446. // Add to the top and bottom line of the area
  40447. if (typeof top !== 'undefined') {
  40448. graphPoints.push({
  40449. plotX: plotX,
  40450. plotY: top === null ?
  40451. translatedThreshold :
  40452. yAxis.getThreshold(top),
  40453. isNull: isNull,
  40454. isCliff: true
  40455. });
  40456. bottomPoints.push({
  40457. plotX: plotX,
  40458. plotY: bottom === null ?
  40459. translatedThreshold :
  40460. yAxis.getThreshold(bottom),
  40461. doCurve: false // #1041, gaps in areaspline areas
  40462. });
  40463. }
  40464. };
  40465. // Find what points to use
  40466. points = points || this.points;
  40467. // Fill in missing points
  40468. if (stacking) {
  40469. points = this.getStackPoints(points);
  40470. }
  40471. for (i = 0; i < points.length; i++) {
  40472. // Reset after series.update of stacking property (#12033)
  40473. if (!stacking) {
  40474. points[i].leftCliff = points[i].rightCliff =
  40475. points[i].leftNull = points[i].rightNull = void 0;
  40476. }
  40477. isNull = points[i].isNull;
  40478. plotX = pick(points[i].rectPlotX, points[i].plotX);
  40479. yBottom = stacking ? pick(points[i].yBottom, translatedThreshold) : translatedThreshold;
  40480. if (!isNull || connectNulls) {
  40481. if (!connectNulls) {
  40482. addDummyPoints(i, i - 1, 'left');
  40483. }
  40484. // Skip null point when stacking is false and connectNulls
  40485. // true
  40486. if (!(isNull && !stacking && connectNulls)) {
  40487. graphPoints.push(points[i]);
  40488. bottomPoints.push({
  40489. x: i,
  40490. plotX: plotX,
  40491. plotY: yBottom
  40492. });
  40493. }
  40494. if (!connectNulls) {
  40495. addDummyPoints(i, i + 1, 'right');
  40496. }
  40497. }
  40498. }
  40499. topPath = getGraphPath.call(this, graphPoints, true, true);
  40500. bottomPoints.reversed = true;
  40501. bottomPath = getGraphPath.call(this, bottomPoints, true, true);
  40502. var firstBottomPoint = bottomPath[0];
  40503. if (firstBottomPoint && firstBottomPoint[0] === 'M') {
  40504. bottomPath[0] = ['L', firstBottomPoint[1], firstBottomPoint[2]];
  40505. }
  40506. areaPath = topPath.concat(bottomPath);
  40507. if (areaPath.length) {
  40508. areaPath.push(['Z']);
  40509. }
  40510. // TODO: don't set leftCliff and rightCliff when connectNulls?
  40511. graphPath = getGraphPath
  40512. .call(this, graphPoints, false, connectNulls);
  40513. areaPath.xMap = topPath.xMap;
  40514. this.areaPath = areaPath;
  40515. return graphPath;
  40516. };
  40517. /**
  40518. * Return an array of stacked points, where null and missing points are
  40519. * replaced by dummy points in order for gaps to be drawn correctly in
  40520. * stacks.
  40521. * @private
  40522. */
  40523. AreaSeries.prototype.getStackPoints = function (points) {
  40524. var series = this,
  40525. segment = [],
  40526. keys = [],
  40527. xAxis = this.xAxis,
  40528. yAxis = this.yAxis,
  40529. stack = yAxis.stacking.stacks[this.stackKey],
  40530. pointMap = {},
  40531. yAxisSeries = yAxis.series,
  40532. seriesLength = yAxisSeries.length,
  40533. upOrDown = yAxis.options.reversedStacks ? 1 : -1,
  40534. seriesIndex = yAxisSeries.indexOf(series);
  40535. points = points || this.points;
  40536. if (this.options.stacking) {
  40537. for (var i = 0; i < points.length; i++) {
  40538. // Reset after point update (#7326)
  40539. points[i].leftNull = points[i].rightNull = void 0;
  40540. // Create a map where we can quickly look up the points by
  40541. // their X values.
  40542. pointMap[points[i].x] = points[i];
  40543. }
  40544. // Sort the keys (#1651)
  40545. objectEach(stack, function (stackX, x) {
  40546. // nulled after switching between
  40547. // grouping and not (#1651, #2336)
  40548. if (stackX.total !== null) {
  40549. keys.push(x);
  40550. }
  40551. });
  40552. keys.sort(function (a, b) {
  40553. return a - b;
  40554. });
  40555. var visibleSeries_1 = yAxisSeries.map(function (s) { return s.visible; });
  40556. keys.forEach(function (x, idx) {
  40557. var y = 0,
  40558. stackPoint,
  40559. stackedValues;
  40560. if (pointMap[x] && !pointMap[x].isNull) {
  40561. segment.push(pointMap[x]);
  40562. // Find left and right cliff. -1 goes left, 1 goes
  40563. // right.
  40564. [-1, 1].forEach(function (direction) {
  40565. var nullName = direction === 1 ?
  40566. 'rightNull' :
  40567. 'leftNull',
  40568. cliffName = direction === 1 ?
  40569. 'rightCliff' :
  40570. 'leftCliff',
  40571. cliff = 0,
  40572. otherStack = stack[keys[idx + direction]];
  40573. // If there is a stack next to this one,
  40574. // to the left or to the right...
  40575. if (otherStack) {
  40576. var i = seriesIndex;
  40577. // Can go either up or down,
  40578. // depending on reversedStacks
  40579. while (i >= 0 && i < seriesLength) {
  40580. var si = yAxisSeries[i].index;
  40581. stackPoint = otherStack.points[si];
  40582. if (!stackPoint) {
  40583. // If the next point in this series
  40584. // is missing, mark the point
  40585. // with point.leftNull or
  40586. // point.rightNull = true.
  40587. if (si === series.index) {
  40588. pointMap[x][nullName] = true;
  40589. // If there are missing points in
  40590. // the next stack in any of the
  40591. // series below this one, we need
  40592. // to substract the missing values
  40593. // and add a hiatus to the left or
  40594. // right.
  40595. }
  40596. else if (visibleSeries_1[i]) {
  40597. stackedValues =
  40598. stack[x].points[si];
  40599. if (stackedValues) {
  40600. cliff -= stackedValues[1] - stackedValues[0];
  40601. }
  40602. }
  40603. }
  40604. // When reversedStacks is true, loop up,
  40605. // else loop down
  40606. i += upOrDown;
  40607. }
  40608. }
  40609. pointMap[x][cliffName] = cliff;
  40610. });
  40611. // There is no point for this X value in this series, so we
  40612. // insert a dummy point in order for the areas to be drawn
  40613. // correctly.
  40614. }
  40615. else {
  40616. // Loop down the stack to find the series below this
  40617. // one that has a value (#1991)
  40618. var i = seriesIndex;
  40619. while (i >= 0 && i < seriesLength) {
  40620. var si = yAxisSeries[i].index;
  40621. stackPoint = stack[x].points[si];
  40622. if (stackPoint) {
  40623. y = stackPoint[1];
  40624. break;
  40625. }
  40626. // When reversedStacks is true, loop up, else loop
  40627. // down
  40628. i += upOrDown;
  40629. }
  40630. y = pick(y, 0);
  40631. y = yAxis.translate(// #6272
  40632. y, 0, 1, 0, 1);
  40633. segment.push({
  40634. isNull: true,
  40635. plotX: xAxis.translate(// #6272
  40636. x, 0, 0, 0, 1),
  40637. x: x,
  40638. plotY: y,
  40639. yBottom: y
  40640. });
  40641. }
  40642. });
  40643. }
  40644. return segment;
  40645. };
  40646. /**
  40647. * The area series type.
  40648. *
  40649. * @sample {highcharts} highcharts/demo/area-basic/
  40650. * Area chart
  40651. * @sample {highstock} stock/demo/area/
  40652. * Area chart
  40653. *
  40654. * @extends plotOptions.line
  40655. * @excluding useOhlcData
  40656. * @product highcharts highstock
  40657. * @optionparent plotOptions.area
  40658. */
  40659. AreaSeries.defaultOptions = merge(LineSeries.defaultOptions, {
  40660. /**
  40661. * @see [fillColor](#plotOptions.area.fillColor)
  40662. * @see [fillOpacity](#plotOptions.area.fillOpacity)
  40663. *
  40664. * @apioption plotOptions.area.color
  40665. */
  40666. /**
  40667. * Fill color or gradient for the area. When `null`, the series' `color`
  40668. * is used with the series' `fillOpacity`.
  40669. *
  40670. * In styled mode, the fill color can be set with the `.highcharts-area`
  40671. * class name.
  40672. *
  40673. * @see [color](#plotOptions.area.color)
  40674. * @see [fillOpacity](#plotOptions.area.fillOpacity)
  40675. *
  40676. * @sample {highcharts} highcharts/plotoptions/area-fillcolor-default/
  40677. * Null by default
  40678. * @sample {highcharts} highcharts/plotoptions/area-fillcolor-gradient/
  40679. * Gradient
  40680. *
  40681. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  40682. * @product highcharts highstock
  40683. * @apioption plotOptions.area.fillColor
  40684. */
  40685. /**
  40686. * Fill opacity for the area. When you set an explicit `fillColor`,
  40687. * the `fillOpacity` is not applied. Instead, you should define the
  40688. * opacity in the `fillColor` with an rgba color definition. The
  40689. * `fillOpacity` setting, also the default setting, overrides the alpha
  40690. * component of the `color` setting.
  40691. *
  40692. * In styled mode, the fill opacity can be set with the
  40693. * `.highcharts-area` class name.
  40694. *
  40695. * @see [color](#plotOptions.area.color)
  40696. * @see [fillColor](#plotOptions.area.fillColor)
  40697. *
  40698. * @sample {highcharts} highcharts/plotoptions/area-fillopacity/
  40699. * Automatic fill color and fill opacity of 0.1
  40700. *
  40701. * @type {number}
  40702. * @default {highcharts} 0.75
  40703. * @default {highstock} 0.75
  40704. * @product highcharts highstock
  40705. * @apioption plotOptions.area.fillOpacity
  40706. */
  40707. /**
  40708. * A separate color for the graph line. By default the line takes the
  40709. * `color` of the series, but the lineColor setting allows setting a
  40710. * separate color for the line without altering the `fillColor`.
  40711. *
  40712. * In styled mode, the line stroke can be set with the
  40713. * `.highcharts-graph` class name.
  40714. *
  40715. * @sample {highcharts} highcharts/plotoptions/area-linecolor/
  40716. * Dark gray line
  40717. *
  40718. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  40719. * @product highcharts highstock
  40720. * @apioption plotOptions.area.lineColor
  40721. */
  40722. /**
  40723. * A separate color for the negative part of the area.
  40724. *
  40725. * In styled mode, a negative color is set with the
  40726. * `.highcharts-negative` class name.
  40727. *
  40728. * @see [negativeColor](#plotOptions.area.negativeColor)
  40729. *
  40730. * @sample {highcharts} highcharts/css/series-negative-color/
  40731. * Negative color in styled mode
  40732. *
  40733. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  40734. * @since 3.0
  40735. * @product highcharts
  40736. * @apioption plotOptions.area.negativeFillColor
  40737. */
  40738. /**
  40739. * Whether the whole area or just the line should respond to mouseover
  40740. * tooltips and other mouse or touch events.
  40741. *
  40742. * @sample {highcharts|highstock} highcharts/plotoptions/area-trackbyarea/
  40743. * Display the tooltip when the area is hovered
  40744. *
  40745. * @type {boolean}
  40746. * @default false
  40747. * @since 1.1.6
  40748. * @product highcharts highstock
  40749. * @apioption plotOptions.area.trackByArea
  40750. */
  40751. /**
  40752. * The Y axis value to serve as the base for the area, for
  40753. * distinguishing between values above and below a threshold. The area
  40754. * between the graph and the threshold is filled.
  40755. *
  40756. * * If a number is given, the Y axis will scale to the threshold.
  40757. * * If `null`, the scaling behaves like a line series with fill between
  40758. * the graph and the Y axis minimum.
  40759. * * If `Infinity` or `-Infinity`, the area between the graph and the
  40760. * corresponding Y axis extreme is filled (since v6.1.0).
  40761. *
  40762. * @sample {highcharts} highcharts/plotoptions/area-threshold/
  40763. * A threshold of 100
  40764. * @sample {highcharts} highcharts/plotoptions/area-threshold-infinity/
  40765. * A threshold of Infinity
  40766. *
  40767. * @type {number|null}
  40768. * @since 2.0
  40769. * @product highcharts highstock
  40770. */
  40771. threshold: 0
  40772. });
  40773. return AreaSeries;
  40774. }(LineSeries));
  40775. extend(AreaSeries.prototype, {
  40776. singleStacks: false,
  40777. drawLegendSymbol: LegendSymbolMixin.drawRectangle
  40778. });
  40779. SeriesRegistry.registerSeriesType('area', AreaSeries);
  40780. /* *
  40781. *
  40782. * Default Export
  40783. *
  40784. * */
  40785. /* *
  40786. *
  40787. * API Options
  40788. *
  40789. * */
  40790. /**
  40791. * A `area` series. If the [type](#series.area.type) option is not
  40792. * specified, it is inherited from [chart.type](#chart.type).
  40793. *
  40794. * @extends series,plotOptions.area
  40795. * @excluding dataParser, dataURL, useOhlcData
  40796. * @product highcharts highstock
  40797. * @apioption series.area
  40798. */
  40799. /**
  40800. * @see [fillColor](#series.area.fillColor)
  40801. * @see [fillOpacity](#series.area.fillOpacity)
  40802. *
  40803. * @apioption series.area.color
  40804. */
  40805. /**
  40806. * An array of data points for the series. For the `area` series type,
  40807. * points can be given in the following ways:
  40808. *
  40809. * 1. An array of numerical values. In this case, the numerical values will be
  40810. * interpreted as `y` options. The `x` values will be automatically
  40811. * calculated, either starting at 0 and incremented by 1, or from
  40812. * `pointStart` * and `pointInterval` given in the series options. If the
  40813. * axis has categories, these will be used. Example:
  40814. * ```js
  40815. * data: [0, 5, 3, 5]
  40816. * ```
  40817. *
  40818. * 2. An array of arrays with 2 values. In this case, the values correspond to
  40819. * `x,y`. If the first value is a string, it is applied as the name of the
  40820. * point, and the `x` value is inferred.
  40821. * ```js
  40822. * data: [
  40823. * [0, 9],
  40824. * [1, 7],
  40825. * [2, 6]
  40826. * ]
  40827. * ```
  40828. *
  40829. * 3. An array of objects with named values. The following snippet shows only a
  40830. * few settings, see the complete options set below. If the total number of
  40831. * data points exceeds the series'
  40832. * [turboThreshold](#series.area.turboThreshold), this option is not
  40833. * available.
  40834. * ```js
  40835. * data: [{
  40836. * x: 1,
  40837. * y: 9,
  40838. * name: "Point2",
  40839. * color: "#00FF00"
  40840. * }, {
  40841. * x: 1,
  40842. * y: 6,
  40843. * name: "Point1",
  40844. * color: "#FF00FF"
  40845. * }]
  40846. * ```
  40847. *
  40848. * @sample {highcharts} highcharts/chart/reflow-true/
  40849. * Numerical values
  40850. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  40851. * Arrays of numeric x and y
  40852. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  40853. * Arrays of datetime x and y
  40854. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  40855. * Arrays of point.name and y
  40856. * @sample {highcharts} highcharts/series/data-array-of-objects/
  40857. * Config objects
  40858. *
  40859. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  40860. * @extends series.line.data
  40861. * @product highcharts highstock
  40862. * @apioption series.area.data
  40863. */
  40864. /**
  40865. * @see [color](#series.area.color)
  40866. * @see [fillOpacity](#series.area.fillOpacity)
  40867. *
  40868. * @apioption series.area.fillColor
  40869. */
  40870. /**
  40871. * @see [color](#series.area.color)
  40872. * @see [fillColor](#series.area.fillColor)
  40873. *
  40874. * @default {highcharts} 0.75
  40875. * @default {highstock} 0.75
  40876. * @apioption series.area.fillOpacity
  40877. */
  40878. ''; // adds doclets above to transpilat
  40879. return AreaSeries;
  40880. });
  40881. _registerModule(_modules, 'Series/Spline/SplineSeries.js', [_modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (SeriesRegistry, U) {
  40882. /* *
  40883. *
  40884. * (c) 2010-2021 Torstein Honsi
  40885. *
  40886. * License: www.highcharts.com/license
  40887. *
  40888. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  40889. *
  40890. * */
  40891. var __extends = (this && this.__extends) || (function () {
  40892. var extendStatics = function (d,
  40893. b) {
  40894. extendStatics = Object.setPrototypeOf ||
  40895. ({ __proto__: [] } instanceof Array && function (d,
  40896. b) { d.__proto__ = b; }) ||
  40897. function (d,
  40898. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40899. return extendStatics(d, b);
  40900. };
  40901. return function (d, b) {
  40902. extendStatics(d, b);
  40903. function __() { this.constructor = d; }
  40904. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40905. };
  40906. })();
  40907. var LineSeries = SeriesRegistry.seriesTypes.line;
  40908. var merge = U.merge,
  40909. pick = U.pick;
  40910. /**
  40911. * Spline series type.
  40912. *
  40913. * @private
  40914. */
  40915. var SplineSeries = /** @class */ (function (_super) {
  40916. __extends(SplineSeries, _super);
  40917. function SplineSeries() {
  40918. /* *
  40919. *
  40920. * Static Properties
  40921. *
  40922. * */
  40923. var _this = _super !== null && _super.apply(this,
  40924. arguments) || this;
  40925. /* *
  40926. *
  40927. * Properties
  40928. *
  40929. * */
  40930. _this.data = void 0;
  40931. _this.options = void 0;
  40932. _this.points = void 0;
  40933. return _this;
  40934. /* eslint-enable valid-jsdoc */
  40935. }
  40936. /* *
  40937. *
  40938. * Functions
  40939. *
  40940. * */
  40941. /* eslint-disable valid-jsdoc */
  40942. /**
  40943. * Get the spline segment from a given point's previous neighbour to the
  40944. * given point.
  40945. *
  40946. * @private
  40947. * @function Highcharts.seriesTypes.spline#getPointSpline
  40948. *
  40949. * @param {Array<Highcharts.Point>}
  40950. *
  40951. * @param {Highcharts.Point} point
  40952. *
  40953. * @param {number} i
  40954. *
  40955. * @return {Highcharts.SVGPathArray}
  40956. */
  40957. SplineSeries.prototype.getPointSpline = function (points, point, i) {
  40958. var
  40959. // 1 means control points midway between points, 2 means 1/3
  40960. // from the point, 3 is 1/4 etc
  40961. smoothing = 1.5,
  40962. denom = smoothing + 1,
  40963. plotX = point.plotX || 0,
  40964. plotY = point.plotY || 0,
  40965. lastPoint = points[i - 1],
  40966. nextPoint = points[i + 1],
  40967. leftContX,
  40968. leftContY,
  40969. rightContX,
  40970. rightContY,
  40971. ret;
  40972. /**
  40973. * @private
  40974. */
  40975. function doCurve(otherPoint) {
  40976. return otherPoint &&
  40977. !otherPoint.isNull &&
  40978. otherPoint.doCurve !== false &&
  40979. // #6387, area splines next to null:
  40980. !point.isCliff;
  40981. }
  40982. // Find control points
  40983. if (doCurve(lastPoint) && doCurve(nextPoint)) {
  40984. var lastX = lastPoint.plotX || 0,
  40985. lastY = lastPoint.plotY || 0,
  40986. nextX = nextPoint.plotX || 0,
  40987. nextY = nextPoint.plotY || 0,
  40988. correction = 0;
  40989. leftContX = (smoothing * plotX + lastX) / denom;
  40990. leftContY = (smoothing * plotY + lastY) / denom;
  40991. rightContX = (smoothing * plotX + nextX) / denom;
  40992. rightContY = (smoothing * plotY + nextY) / denom;
  40993. // Have the two control points make a straight line through main
  40994. // point
  40995. if (rightContX !== leftContX) { // #5016, division by zero
  40996. correction = (((rightContY - leftContY) *
  40997. (rightContX - plotX)) /
  40998. (rightContX - leftContX) + plotY - rightContY);
  40999. }
  41000. leftContY += correction;
  41001. rightContY += correction;
  41002. // to prevent false extremes, check that control points are
  41003. // between neighbouring points' y values
  41004. if (leftContY > lastY && leftContY > plotY) {
  41005. leftContY = Math.max(lastY, plotY);
  41006. // mirror of left control point
  41007. rightContY = 2 * plotY - leftContY;
  41008. }
  41009. else if (leftContY < lastY && leftContY < plotY) {
  41010. leftContY = Math.min(lastY, plotY);
  41011. rightContY = 2 * plotY - leftContY;
  41012. }
  41013. if (rightContY > nextY && rightContY > plotY) {
  41014. rightContY = Math.max(nextY, plotY);
  41015. leftContY = 2 * plotY - rightContY;
  41016. }
  41017. else if (rightContY < nextY && rightContY < plotY) {
  41018. rightContY = Math.min(nextY, plotY);
  41019. leftContY = 2 * plotY - rightContY;
  41020. }
  41021. // record for drawing in next point
  41022. point.rightContX = rightContX;
  41023. point.rightContY = rightContY;
  41024. }
  41025. // Visualize control points for debugging
  41026. /*
  41027. if (leftContX) {
  41028. this.chart.renderer.circle(
  41029. leftContX + this.chart.plotLeft,
  41030. leftContY + this.chart.plotTop,
  41031. 2
  41032. )
  41033. .attr({
  41034. stroke: 'red',
  41035. 'stroke-width': 2,
  41036. fill: 'none',
  41037. zIndex: 9
  41038. })
  41039. .add();
  41040. this.chart.renderer.path(['M', leftContX + this.chart.plotLeft,
  41041. leftContY + this.chart.plotTop,
  41042. 'L', plotX + this.chart.plotLeft, plotY + this.chart.plotTop])
  41043. .attr({
  41044. stroke: 'red',
  41045. 'stroke-width': 2,
  41046. zIndex: 9
  41047. })
  41048. .add();
  41049. }
  41050. if (rightContX) {
  41051. this.chart.renderer.circle(
  41052. rightContX + this.chart.plotLeft,
  41053. rightContY + this.chart.plotTop,
  41054. 2
  41055. )
  41056. .attr({
  41057. stroke: 'green',
  41058. 'stroke-width': 2,
  41059. fill: 'none',
  41060. zIndex: 9
  41061. })
  41062. .add();
  41063. this.chart.renderer.path(['M', rightContX + this.chart.plotLeft,
  41064. rightContY + this.chart.plotTop,
  41065. 'L', plotX + this.chart.plotLeft, plotY + this.chart.plotTop])
  41066. .attr({
  41067. stroke: 'green',
  41068. 'stroke-width': 2,
  41069. zIndex: 9
  41070. })
  41071. .add();
  41072. }
  41073. // */
  41074. ret = [
  41075. 'C',
  41076. pick(lastPoint.rightContX, lastPoint.plotX, 0),
  41077. pick(lastPoint.rightContY, lastPoint.plotY, 0),
  41078. pick(leftContX, plotX, 0),
  41079. pick(leftContY, plotY, 0),
  41080. plotX,
  41081. plotY
  41082. ];
  41083. // reset for updating series later
  41084. lastPoint.rightContX = lastPoint.rightContY = void 0;
  41085. return ret;
  41086. };
  41087. /**
  41088. * A spline series is a special type of line series, where the segments
  41089. * between the data points are smoothed.
  41090. *
  41091. * @sample {highcharts} highcharts/demo/spline-irregular-time/
  41092. * Spline chart
  41093. * @sample {highstock} stock/demo/spline/
  41094. * Spline chart
  41095. *
  41096. * @extends plotOptions.series
  41097. * @excluding step, boostThreshold, boostBlending
  41098. * @product highcharts highstock
  41099. * @optionparent plotOptions.spline
  41100. */
  41101. SplineSeries.defaultOptions = merge(LineSeries.defaultOptions);
  41102. return SplineSeries;
  41103. }(LineSeries));
  41104. SeriesRegistry.registerSeriesType('spline', SplineSeries);
  41105. /* *
  41106. *
  41107. * Default Export
  41108. *
  41109. * */
  41110. /* *
  41111. *
  41112. * API Options
  41113. *
  41114. * */
  41115. /**
  41116. * A `spline` series. If the [type](#series.spline.type) option is
  41117. * not specified, it is inherited from [chart.type](#chart.type).
  41118. *
  41119. * @extends series,plotOptions.spline
  41120. * @excluding dataParser, dataURL, step, boostThreshold, boostBlending
  41121. * @product highcharts highstock
  41122. * @apioption series.spline
  41123. */
  41124. /**
  41125. * An array of data points for the series. For the `spline` series type,
  41126. * points can be given in the following ways:
  41127. *
  41128. * 1. An array of numerical values. In this case, the numerical values will be
  41129. * interpreted as `y` options. The `x` values will be automatically
  41130. * calculated, either starting at 0 and incremented by 1, or from
  41131. * `pointStart` and `pointInterval` given in the series options. If the axis
  41132. * has categories, these will be used. Example:
  41133. * ```js
  41134. * data: [0, 5, 3, 5]
  41135. * ```
  41136. *
  41137. * 2. An array of arrays with 2 values. In this case, the values correspond to
  41138. * `x,y`. If the first value is a string, it is applied as the name of the
  41139. * point, and the `x` value is inferred.
  41140. * ```js
  41141. * data: [
  41142. * [0, 9],
  41143. * [1, 2],
  41144. * [2, 8]
  41145. * ]
  41146. * ```
  41147. *
  41148. * 3. An array of objects with named values. The following snippet shows only a
  41149. * few settings, see the complete options set below. If the total number of
  41150. * data points exceeds the series'
  41151. * [turboThreshold](#series.spline.turboThreshold),
  41152. * this option is not available.
  41153. * ```js
  41154. * data: [{
  41155. * x: 1,
  41156. * y: 9,
  41157. * name: "Point2",
  41158. * color: "#00FF00"
  41159. * }, {
  41160. * x: 1,
  41161. * y: 0,
  41162. * name: "Point1",
  41163. * color: "#FF00FF"
  41164. * }]
  41165. * ```
  41166. *
  41167. * @sample {highcharts} highcharts/chart/reflow-true/
  41168. * Numerical values
  41169. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  41170. * Arrays of numeric x and y
  41171. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  41172. * Arrays of datetime x and y
  41173. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  41174. * Arrays of point.name and y
  41175. * @sample {highcharts} highcharts/series/data-array-of-objects/
  41176. * Config objects
  41177. *
  41178. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  41179. * @extends series.line.data
  41180. * @product highcharts highstock
  41181. * @apioption series.spline.data
  41182. */
  41183. ''; // adds doclets above intro transpilat
  41184. return SplineSeries;
  41185. });
  41186. _registerModule(_modules, 'Series/AreaSpline/AreaSplineSeries.js', [_modules['Series/Area/AreaSeries.js'], _modules['Series/Spline/SplineSeries.js'], _modules['Mixins/LegendSymbol.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (AreaSeries, SplineSeries, LegendSymbolMixin, SeriesRegistry, U) {
  41187. /* *
  41188. *
  41189. * (c) 2010-2021 Torstein Honsi
  41190. *
  41191. * License: www.highcharts.com/license
  41192. *
  41193. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  41194. *
  41195. * */
  41196. var __extends = (this && this.__extends) || (function () {
  41197. var extendStatics = function (d,
  41198. b) {
  41199. extendStatics = Object.setPrototypeOf ||
  41200. ({ __proto__: [] } instanceof Array && function (d,
  41201. b) { d.__proto__ = b; }) ||
  41202. function (d,
  41203. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  41204. return extendStatics(d, b);
  41205. };
  41206. return function (d, b) {
  41207. extendStatics(d, b);
  41208. function __() { this.constructor = d; }
  41209. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  41210. };
  41211. })();
  41212. var areaProto = AreaSeries.prototype;
  41213. var extend = U.extend,
  41214. merge = U.merge;
  41215. /* *
  41216. *
  41217. * Class
  41218. *
  41219. * */
  41220. /**
  41221. * AreaSpline series type.
  41222. *
  41223. * @private
  41224. * @class
  41225. * @name Highcharts.seriesTypes.areaspline
  41226. *
  41227. * @augments Highcharts.Series
  41228. */
  41229. var AreaSplineSeries = /** @class */ (function (_super) {
  41230. __extends(AreaSplineSeries, _super);
  41231. function AreaSplineSeries() {
  41232. /* *
  41233. *
  41234. * Static properties
  41235. *
  41236. * */
  41237. var _this = _super !== null && _super.apply(this,
  41238. arguments) || this;
  41239. /* *
  41240. *
  41241. * Properties
  41242. *
  41243. * */
  41244. _this.data = void 0;
  41245. _this.points = void 0;
  41246. _this.options = void 0;
  41247. return _this;
  41248. }
  41249. /**
  41250. * The area spline series is an area series where the graph between the
  41251. * points is smoothed into a spline.
  41252. *
  41253. * @sample {highcharts} highcharts/demo/areaspline/
  41254. * Area spline chart
  41255. * @sample {highstock} stock/demo/areaspline/
  41256. * Area spline chart
  41257. *
  41258. * @extends plotOptions.area
  41259. * @excluding step, boostThreshold, boostBlending
  41260. * @product highcharts highstock
  41261. * @apioption plotOptions.areaspline
  41262. */
  41263. /**
  41264. * @see [fillColor](#plotOptions.areaspline.fillColor)
  41265. * @see [fillOpacity](#plotOptions.areaspline.fillOpacity)
  41266. *
  41267. * @apioption plotOptions.areaspline.color
  41268. */
  41269. /**
  41270. * @see [color](#plotOptions.areaspline.color)
  41271. * @see [fillOpacity](#plotOptions.areaspline.fillOpacity)
  41272. *
  41273. * @apioption plotOptions.areaspline.fillColor
  41274. */
  41275. /**
  41276. * @see [color](#plotOptions.areaspline.color)
  41277. * @see [fillColor](#plotOptions.areaspline.fillColor)
  41278. *
  41279. * @default {highcharts} 0.75
  41280. * @default {highstock} 0.75
  41281. * @apioption plotOptions.areaspline.fillOpacity
  41282. */
  41283. AreaSplineSeries.defaultOptions = merge(SplineSeries.defaultOptions, AreaSeries.defaultOptions);
  41284. return AreaSplineSeries;
  41285. }(SplineSeries));
  41286. extend(AreaSplineSeries.prototype, {
  41287. getGraphPath: areaProto.getGraphPath,
  41288. getStackPoints: areaProto.getStackPoints,
  41289. drawGraph: areaProto.drawGraph,
  41290. drawLegendSymbol: LegendSymbolMixin.drawRectangle
  41291. });
  41292. SeriesRegistry.registerSeriesType('areaspline', AreaSplineSeries);
  41293. /* *
  41294. *
  41295. * Default export
  41296. *
  41297. * */
  41298. /**
  41299. * A `areaspline` series. If the [type](#series.areaspline.type) option
  41300. * is not specified, it is inherited from [chart.type](#chart.type).
  41301. *
  41302. *
  41303. * @extends series,plotOptions.areaspline
  41304. * @excluding dataParser, dataURL, step, boostThreshold, boostBlending
  41305. * @product highcharts highstock
  41306. * @apioption series.areaspline
  41307. */
  41308. /**
  41309. * @see [fillColor](#series.areaspline.fillColor)
  41310. * @see [fillOpacity](#series.areaspline.fillOpacity)
  41311. *
  41312. * @apioption series.areaspline.color
  41313. */
  41314. /**
  41315. * An array of data points for the series. For the `areaspline` series
  41316. * type, points can be given in the following ways:
  41317. *
  41318. * 1. An array of numerical values. In this case, the numerical values will be
  41319. * interpreted as `y` options. The `x` values will be automatically
  41320. * calculated, either starting at 0 and incremented by 1, or from
  41321. * `pointStart` and `pointInterval` given in the series options. If the axis
  41322. * has categories, these will be used. Example:
  41323. * ```js
  41324. * data: [0, 5, 3, 5]
  41325. * ```
  41326. *
  41327. * 2. An array of arrays with 2 values. In this case, the values correspond to
  41328. * `x,y`. If the first value is a string, it is applied as the name of the
  41329. * point, and the `x` value is inferred.
  41330. * ```js
  41331. * data: [
  41332. * [0, 10],
  41333. * [1, 9],
  41334. * [2, 3]
  41335. * ]
  41336. * ```
  41337. *
  41338. * 3. An array of objects with named values. The following snippet shows only a
  41339. * few settings, see the complete options set below. If the total number of
  41340. * data points exceeds the series'
  41341. * [turboThreshold](#series.areaspline.turboThreshold), this option is not
  41342. * available.
  41343. * ```js
  41344. * data: [{
  41345. * x: 1,
  41346. * y: 4,
  41347. * name: "Point2",
  41348. * color: "#00FF00"
  41349. * }, {
  41350. * x: 1,
  41351. * y: 4,
  41352. * name: "Point1",
  41353. * color: "#FF00FF"
  41354. * }]
  41355. * ```
  41356. *
  41357. * @sample {highcharts} highcharts/chart/reflow-true/
  41358. * Numerical values
  41359. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  41360. * Arrays of numeric x and y
  41361. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  41362. * Arrays of datetime x and y
  41363. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  41364. * Arrays of point.name and y
  41365. * @sample {highcharts} highcharts/series/data-array-of-objects/
  41366. * Config objects
  41367. *
  41368. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  41369. * @extends series.line.data
  41370. * @product highcharts highstock
  41371. * @apioption series.areaspline.data
  41372. */
  41373. /**
  41374. * @see [color](#series.areaspline.color)
  41375. * @see [fillOpacity](#series.areaspline.fillOpacity)
  41376. *
  41377. * @apioption series.areaspline.fillColor
  41378. */
  41379. /**
  41380. * @see [color](#series.areaspline.color)
  41381. * @see [fillColor](#series.areaspline.fillColor)
  41382. *
  41383. * @default {highcharts} 0.75
  41384. * @default {highstock} 0.75
  41385. * @apioption series.areaspline.fillOpacity
  41386. */
  41387. ''; // adds doclets above into transpilat
  41388. return AreaSplineSeries;
  41389. });
  41390. _registerModule(_modules, 'Series/Column/ColumnSeries.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Color/Color.js'], _modules['Core/Globals.js'], _modules['Mixins/LegendSymbol.js'], _modules['Core/Color/Palette.js'], _modules['Core/Series/Series.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (A, Color, H, LegendSymbolMixin, palette, Series, SeriesRegistry, U) {
  41391. /* *
  41392. *
  41393. * (c) 2010-2021 Torstein Honsi
  41394. *
  41395. * License: www.highcharts.com/license
  41396. *
  41397. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  41398. *
  41399. * */
  41400. var __extends = (this && this.__extends) || (function () {
  41401. var extendStatics = function (d,
  41402. b) {
  41403. extendStatics = Object.setPrototypeOf ||
  41404. ({ __proto__: [] } instanceof Array && function (d,
  41405. b) { d.__proto__ = b; }) ||
  41406. function (d,
  41407. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  41408. return extendStatics(d, b);
  41409. };
  41410. return function (d, b) {
  41411. extendStatics(d, b);
  41412. function __() { this.constructor = d; }
  41413. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  41414. };
  41415. })();
  41416. var animObject = A.animObject;
  41417. var color = Color.parse;
  41418. var hasTouch = H.hasTouch,
  41419. noop = H.noop;
  41420. var clamp = U.clamp,
  41421. css = U.css,
  41422. defined = U.defined,
  41423. extend = U.extend,
  41424. fireEvent = U.fireEvent,
  41425. isArray = U.isArray,
  41426. isNumber = U.isNumber,
  41427. merge = U.merge,
  41428. pick = U.pick,
  41429. objectEach = U.objectEach;
  41430. /**
  41431. * The column series type.
  41432. *
  41433. * @private
  41434. * @class
  41435. * @name Highcharts.seriesTypes.column
  41436. *
  41437. * @augments Highcharts.Series
  41438. */
  41439. var ColumnSeries = /** @class */ (function (_super) {
  41440. __extends(ColumnSeries, _super);
  41441. function ColumnSeries() {
  41442. /* *
  41443. *
  41444. * Static Properties
  41445. *
  41446. * */
  41447. var _this = _super !== null && _super.apply(this,
  41448. arguments) || this;
  41449. /* *
  41450. *
  41451. * Properties
  41452. *
  41453. * */
  41454. _this.borderWidth = void 0;
  41455. _this.data = void 0;
  41456. _this.group = void 0;
  41457. _this.options = void 0;
  41458. _this.points = void 0;
  41459. return _this;
  41460. /* eslint-enable valid-jsdoc */
  41461. }
  41462. /* *
  41463. *
  41464. * Functions
  41465. *
  41466. * */
  41467. /* eslint-disable valid-jsdoc */
  41468. /**
  41469. * Animate the column heights one by one from zero.
  41470. *
  41471. * @private
  41472. * @function Highcharts.seriesTypes.column#animate
  41473. *
  41474. * @param {boolean} init
  41475. * Whether to initialize the animation or run it
  41476. */
  41477. ColumnSeries.prototype.animate = function (init) {
  41478. var series = this,
  41479. yAxis = this.yAxis,
  41480. options = series.options,
  41481. inverted = this.chart.inverted,
  41482. attr = {},
  41483. translateProp = inverted ? 'translateX' : 'translateY',
  41484. translateStart,
  41485. translatedThreshold;
  41486. if (init) {
  41487. attr.scaleY = 0.001;
  41488. translatedThreshold = clamp(yAxis.toPixels(options.threshold), yAxis.pos, yAxis.pos + yAxis.len);
  41489. if (inverted) {
  41490. attr.translateX = translatedThreshold - yAxis.len;
  41491. }
  41492. else {
  41493. attr.translateY = translatedThreshold;
  41494. }
  41495. // apply finnal clipping (used in Highcharts Stock) (#7083)
  41496. // animation is done by scaleY, so cliping is for panes
  41497. if (series.clipBox) {
  41498. series.setClip();
  41499. }
  41500. series.group.attr(attr);
  41501. }
  41502. else { // run the animation
  41503. translateStart = Number(series.group.attr(translateProp));
  41504. series.group.animate({ scaleY: 1 }, extend(animObject(series.options.animation), {
  41505. // Do the scale synchronously to ensure smooth
  41506. // updating (#5030, #7228)
  41507. step: function (val, fx) {
  41508. if (series.group) {
  41509. attr[translateProp] = translateStart +
  41510. fx.pos * (yAxis.pos - translateStart);
  41511. series.group.attr(attr);
  41512. }
  41513. }
  41514. }));
  41515. }
  41516. };
  41517. /**
  41518. * Initialize the series. Extends the basic Series.init method by
  41519. * marking other series of the same type as dirty.
  41520. *
  41521. * @private
  41522. * @function Highcharts.seriesTypes.column#init
  41523. */
  41524. ColumnSeries.prototype.init = function (chart, options) {
  41525. _super.prototype.init.apply(this, arguments);
  41526. var series = this;
  41527. chart = series.chart;
  41528. // if the series is added dynamically, force redraw of other
  41529. // series affected by a new column
  41530. if (chart.hasRendered) {
  41531. chart.series.forEach(function (otherSeries) {
  41532. if (otherSeries.type === series.type) {
  41533. otherSeries.isDirty = true;
  41534. }
  41535. });
  41536. }
  41537. };
  41538. /**
  41539. * Return the width and x offset of the columns adjusted for grouping,
  41540. * groupPadding, pointPadding, pointWidth etc.
  41541. *
  41542. * @private
  41543. * @function Highcharts.seriesTypes.column#getColumnMetrics
  41544. * @return {Highcharts.ColumnMetricsObject}
  41545. */
  41546. ColumnSeries.prototype.getColumnMetrics = function () {
  41547. var series = this,
  41548. options = series.options,
  41549. xAxis = series.xAxis,
  41550. yAxis = series.yAxis,
  41551. reversedStacks = xAxis.options.reversedStacks,
  41552. // Keep backward compatibility: reversed xAxis had reversed
  41553. // stacks
  41554. reverseStacks = (xAxis.reversed && !reversedStacks) ||
  41555. (!xAxis.reversed && reversedStacks),
  41556. stackKey,
  41557. stackGroups = {},
  41558. columnCount = 0;
  41559. // Get the total number of column type series. This is called on
  41560. // every series. Consider moving this logic to a chart.orderStacks()
  41561. // function and call it on init, addSeries and removeSeries
  41562. if (options.grouping === false) {
  41563. columnCount = 1;
  41564. }
  41565. else {
  41566. series.chart.series.forEach(function (otherSeries) {
  41567. var otherYAxis = otherSeries.yAxis,
  41568. otherOptions = otherSeries.options,
  41569. columnIndex;
  41570. if (otherSeries.type === series.type &&
  41571. (otherSeries.visible ||
  41572. !series.chart.options.chart.ignoreHiddenSeries) &&
  41573. yAxis.len === otherYAxis.len &&
  41574. yAxis.pos === otherYAxis.pos) { // #642, #2086
  41575. if (otherOptions.stacking && otherOptions.stacking !== 'group') {
  41576. stackKey = otherSeries.stackKey;
  41577. if (typeof stackGroups[stackKey] ===
  41578. 'undefined') {
  41579. stackGroups[stackKey] = columnCount++;
  41580. }
  41581. columnIndex = stackGroups[stackKey];
  41582. }
  41583. else if (otherOptions.grouping !== false) { // #1162
  41584. columnIndex = columnCount++;
  41585. }
  41586. otherSeries.columnIndex = columnIndex;
  41587. }
  41588. });
  41589. }
  41590. var categoryWidth = Math.min(Math.abs(xAxis.transA) * ((xAxis.ordinal && xAxis.ordinal.slope) ||
  41591. options.pointRange ||
  41592. xAxis.closestPointRange ||
  41593. xAxis.tickInterval ||
  41594. 1), // #2610
  41595. xAxis.len // #1535
  41596. ),
  41597. groupPadding = categoryWidth * options.groupPadding,
  41598. groupWidth = categoryWidth - 2 * groupPadding,
  41599. pointOffsetWidth = groupWidth / (columnCount || 1),
  41600. pointWidth = Math.min(options.maxPointWidth || xAxis.len,
  41601. pick(options.pointWidth,
  41602. pointOffsetWidth * (1 - 2 * options.pointPadding))),
  41603. pointPadding = (pointOffsetWidth - pointWidth) / 2,
  41604. // #1251, #3737
  41605. colIndex = (series.columnIndex || 0) + (reverseStacks ? 1 : 0),
  41606. pointXOffset = pointPadding +
  41607. (groupPadding +
  41608. colIndex * pointOffsetWidth -
  41609. (categoryWidth / 2)) * (reverseStacks ? -1 : 1);
  41610. // Save it for reading in linked series (Error bars particularly)
  41611. series.columnMetrics = {
  41612. width: pointWidth,
  41613. offset: pointXOffset,
  41614. paddedWidth: pointOffsetWidth,
  41615. columnCount: columnCount
  41616. };
  41617. return series.columnMetrics;
  41618. };
  41619. /**
  41620. * Make the columns crisp. The edges are rounded to the nearest full
  41621. * pixel.
  41622. *
  41623. * @private
  41624. * @function Highcharts.seriesTypes.column#crispCol
  41625. */
  41626. ColumnSeries.prototype.crispCol = function (x, y, w, h) {
  41627. var chart = this.chart,
  41628. borderWidth = this.borderWidth,
  41629. xCrisp = -(borderWidth % 2 ? 0.5 : 0),
  41630. yCrisp = borderWidth % 2 ? 0.5 : 1,
  41631. right,
  41632. bottom,
  41633. fromTop;
  41634. if (chart.inverted && chart.renderer.isVML) {
  41635. yCrisp += 1;
  41636. }
  41637. // Horizontal. We need to first compute the exact right edge, then
  41638. // round it and compute the width from there.
  41639. if (this.options.crisp) {
  41640. right = Math.round(x + w) + xCrisp;
  41641. x = Math.round(x) + xCrisp;
  41642. w = right - x;
  41643. }
  41644. // Vertical
  41645. bottom = Math.round(y + h) + yCrisp;
  41646. fromTop = Math.abs(y) <= 0.5 && bottom > 0.5; // #4504, #4656
  41647. y = Math.round(y) + yCrisp;
  41648. h = bottom - y;
  41649. // Top edges are exceptions
  41650. if (fromTop && h) { // #5146
  41651. y -= 1;
  41652. h += 1;
  41653. }
  41654. return {
  41655. x: x,
  41656. y: y,
  41657. width: w,
  41658. height: h
  41659. };
  41660. };
  41661. /**
  41662. * Adjust for missing columns, according to the `centerInCategory`
  41663. * option. Missing columns are either single points or stacks where the
  41664. * point or points are either missing or null.
  41665. *
  41666. * @private
  41667. * @function Highcharts.seriesTypes.column#adjustForMissingColumns
  41668. * @param {number} x
  41669. * The x coordinate of the column, left side
  41670. *
  41671. * @param {number} pointWidth
  41672. * The pointWidth, already computed upstream
  41673. *
  41674. * @param {Highcharts.ColumnPoint} point
  41675. * The point instance
  41676. *
  41677. * @param {Highcharts.ColumnMetricsObject} metrics
  41678. * The series-wide column metrics
  41679. *
  41680. * @return {number}
  41681. * The adjusted x position, or the original if not adjusted
  41682. */
  41683. ColumnSeries.prototype.adjustForMissingColumns = function (x, pointWidth, point, metrics) {
  41684. var _this = this;
  41685. var stacking = this.options.stacking;
  41686. if (!point.isNull && metrics.columnCount > 1) {
  41687. var indexInCategory_1 = 0;
  41688. var totalInCategory_1 = 0;
  41689. // Loop over all the stacks on the Y axis. When stacking is
  41690. // enabled, these are real point stacks. When stacking is not
  41691. // enabled, but `centerInCategory` is true, there is one stack
  41692. // handling the grouping of points in each category. This is
  41693. // done in the `setGroupedPoints` function.
  41694. objectEach(this.yAxis.stacking && this.yAxis.stacking.stacks, function (stack) {
  41695. if (typeof point.x === 'number') {
  41696. var stackItem = stack[point.x.toString()];
  41697. if (stackItem) {
  41698. var pointValues = stackItem.points[_this.index],
  41699. total = stackItem.total;
  41700. // If true `stacking` is enabled, count the
  41701. // total number of non-null stacks in the
  41702. // category, and note which index this point is
  41703. // within those stacks.
  41704. if (stacking) {
  41705. if (pointValues) {
  41706. indexInCategory_1 = totalInCategory_1;
  41707. }
  41708. if (stackItem.hasValidPoints) {
  41709. totalInCategory_1++;
  41710. }
  41711. // If `stacking` is not enabled, look for the
  41712. // index and total of the `group` stack.
  41713. }
  41714. else if (isArray(pointValues)) {
  41715. indexInCategory_1 = pointValues[1];
  41716. totalInCategory_1 = total || 0;
  41717. }
  41718. }
  41719. }
  41720. });
  41721. // Compute the adjusted x position
  41722. var boxWidth = (totalInCategory_1 - 1) * metrics.paddedWidth +
  41723. pointWidth;
  41724. x = (point.plotX || 0) + boxWidth / 2 - pointWidth -
  41725. indexInCategory_1 * metrics.paddedWidth;
  41726. }
  41727. return x;
  41728. };
  41729. /**
  41730. * Translate each point to the plot area coordinate system and find
  41731. * shape positions
  41732. *
  41733. * @private
  41734. * @function Highcharts.seriesTypes.column#translate
  41735. */
  41736. ColumnSeries.prototype.translate = function () {
  41737. var series = this,
  41738. chart = series.chart,
  41739. options = series.options,
  41740. dense = series.dense =
  41741. series.closestPointRange * series.xAxis.transA < 2,
  41742. borderWidth = series.borderWidth = pick(options.borderWidth,
  41743. dense ? 0 : 1 // #3635
  41744. ),
  41745. xAxis = series.xAxis,
  41746. yAxis = series.yAxis,
  41747. threshold = options.threshold,
  41748. translatedThreshold = series.translatedThreshold =
  41749. yAxis.getThreshold(threshold),
  41750. minPointLength = pick(options.minPointLength, 5),
  41751. metrics = series.getColumnMetrics(),
  41752. seriesPointWidth = metrics.width,
  41753. // postprocessed for border width
  41754. seriesBarW = series.barW =
  41755. Math.max(seriesPointWidth, 1 + 2 * borderWidth),
  41756. seriesXOffset = series.pointXOffset = metrics.offset,
  41757. dataMin = series.dataMin,
  41758. dataMax = series.dataMax;
  41759. if (chart.inverted) {
  41760. translatedThreshold -= 0.5; // #3355
  41761. }
  41762. // When the pointPadding is 0, we want the columns to be packed
  41763. // tightly, so we allow individual columns to have individual sizes.
  41764. // When pointPadding is greater, we strive for equal-width columns
  41765. // (#2694).
  41766. if (options.pointPadding) {
  41767. seriesBarW = Math.ceil(seriesBarW);
  41768. }
  41769. Series.prototype.translate.apply(series);
  41770. // Record the new values
  41771. series.points.forEach(function (point) {
  41772. var yBottom = pick(point.yBottom,
  41773. translatedThreshold),
  41774. safeDistance = 999 + Math.abs(yBottom),
  41775. pointWidth = seriesPointWidth,
  41776. plotX = point.plotX || 0,
  41777. // Don't draw too far outside plot area (#1303, #2241,
  41778. // #4264)
  41779. plotY = clamp(point.plotY, -safeDistance,
  41780. yAxis.len + safeDistance),
  41781. barX = plotX + seriesXOffset,
  41782. barW = seriesBarW,
  41783. barY = Math.min(plotY,
  41784. yBottom),
  41785. up,
  41786. barH = Math.max(plotY,
  41787. yBottom) - barY;
  41788. // Handle options.minPointLength
  41789. if (minPointLength && Math.abs(barH) < minPointLength) {
  41790. barH = minPointLength;
  41791. up = (!yAxis.reversed && !point.negative) ||
  41792. (yAxis.reversed && point.negative);
  41793. // Reverse zeros if there's no positive value in the series
  41794. // in visible range (#7046)
  41795. if (isNumber(threshold) &&
  41796. isNumber(dataMax) &&
  41797. point.y === threshold &&
  41798. dataMax <= threshold &&
  41799. // and if there's room for it (#7311)
  41800. (yAxis.min || 0) < threshold &&
  41801. // if all points are the same value (i.e zero) not draw
  41802. // as negative points (#10646), but only if there's room
  41803. // for it (#14876)
  41804. (dataMin !== dataMax || (yAxis.max || 0) <= threshold)) {
  41805. up = !up;
  41806. }
  41807. // If stacked...
  41808. barY = (Math.abs(barY - translatedThreshold) > minPointLength ?
  41809. // ...keep position
  41810. yBottom - minPointLength :
  41811. // #1485, #4051
  41812. translatedThreshold -
  41813. (up ? minPointLength : 0));
  41814. }
  41815. // Handle point.options.pointWidth
  41816. // @todo Handle grouping/stacking too. Calculate offset properly
  41817. if (defined(point.options.pointWidth)) {
  41818. pointWidth = barW =
  41819. Math.ceil(point.options.pointWidth);
  41820. barX -= Math.round((pointWidth - seriesPointWidth) / 2);
  41821. }
  41822. // Adjust for null or missing points
  41823. if (options.centerInCategory) {
  41824. barX = series.adjustForMissingColumns(barX, pointWidth, point, metrics);
  41825. }
  41826. // Cache for access in polar
  41827. point.barX = barX;
  41828. point.pointWidth = pointWidth;
  41829. // Fix the tooltip on center of grouped columns (#1216, #424,
  41830. // #3648)
  41831. point.tooltipPos = chart.inverted ?
  41832. [
  41833. clamp(yAxis.len + yAxis.pos - chart.plotLeft - plotY, yAxis.pos - chart.plotLeft, yAxis.len + yAxis.pos - chart.plotLeft),
  41834. xAxis.len + xAxis.pos - chart.plotTop - barX - barW / 2,
  41835. barH
  41836. ] :
  41837. [
  41838. xAxis.left - chart.plotLeft + barX + barW / 2,
  41839. clamp(plotY + yAxis.pos -
  41840. chart.plotTop, yAxis.pos - chart.plotTop, yAxis.len + yAxis.pos - chart.plotTop),
  41841. barH
  41842. ];
  41843. // Register shape type and arguments to be used in drawPoints
  41844. // Allow shapeType defined on pointClass level
  41845. point.shapeType = series.pointClass.prototype.shapeType || 'rect';
  41846. point.shapeArgs = series.crispCol.apply(series, point.isNull ?
  41847. // #3169, drilldown from null must have a position to work
  41848. // from #6585, dataLabel should be placed on xAxis, not
  41849. // floating in the middle of the chart
  41850. [barX, translatedThreshold, barW, 0] :
  41851. [barX, barY, barW, barH]);
  41852. });
  41853. };
  41854. /**
  41855. * Columns have no graph
  41856. *
  41857. * @private
  41858. * @function Highcharts.seriesTypes.column#drawGraph
  41859. */
  41860. ColumnSeries.prototype.drawGraph = function () {
  41861. this.group[this.dense ? 'addClass' : 'removeClass']('highcharts-dense-data');
  41862. };
  41863. /**
  41864. * Get presentational attributes
  41865. *
  41866. * @private
  41867. * @function Highcharts.seriesTypes.column#pointAttribs
  41868. */
  41869. ColumnSeries.prototype.pointAttribs = function (point, state) {
  41870. var options = this.options, stateOptions, ret, p2o = this.pointAttrToOptions || {}, strokeOption = p2o.stroke || 'borderColor', strokeWidthOption = p2o['stroke-width'] || 'borderWidth', fill = (point && point.color) || this.color,
  41871. // set to fill when borderColor null:
  41872. stroke = ((point && point[strokeOption]) ||
  41873. options[strokeOption] ||
  41874. fill), strokeWidth = (point && point[strokeWidthOption]) ||
  41875. options[strokeWidthOption] ||
  41876. this[strokeWidthOption] || 0, dashstyle = (point && point.options.dashStyle) || options.dashStyle, opacity = pick(point && point.opacity, options.opacity, 1), zone, brightness;
  41877. // Handle zone colors
  41878. if (point && this.zones.length) {
  41879. zone = point.getZone();
  41880. // When zones are present, don't use point.color (#4267).
  41881. // Changed order (#6527), added support for colorAxis (#10670)
  41882. fill = (point.options.color ||
  41883. (zone && (zone.color || point.nonZonedColor)) ||
  41884. this.color);
  41885. if (zone) {
  41886. stroke = zone.borderColor || stroke;
  41887. dashstyle = zone.dashStyle || dashstyle;
  41888. strokeWidth = zone.borderWidth || strokeWidth;
  41889. }
  41890. }
  41891. // Select or hover states
  41892. if (state && point) {
  41893. stateOptions = merge(options.states[state],
  41894. // #6401
  41895. point.options.states &&
  41896. point.options.states[state] ||
  41897. {});
  41898. brightness = stateOptions.brightness;
  41899. fill =
  41900. stateOptions.color || (typeof brightness !== 'undefined' &&
  41901. color(fill)
  41902. .brighten(stateOptions.brightness)
  41903. .get()) || fill;
  41904. stroke = stateOptions[strokeOption] || stroke;
  41905. strokeWidth =
  41906. stateOptions[strokeWidthOption] || strokeWidth;
  41907. dashstyle = stateOptions.dashStyle || dashstyle;
  41908. opacity = pick(stateOptions.opacity, opacity);
  41909. }
  41910. ret = {
  41911. fill: fill,
  41912. stroke: stroke,
  41913. 'stroke-width': strokeWidth,
  41914. opacity: opacity
  41915. };
  41916. if (dashstyle) {
  41917. ret.dashstyle = dashstyle;
  41918. }
  41919. return ret;
  41920. };
  41921. /**
  41922. * Draw the columns. For bars, the series.group is rotated, so the same
  41923. * coordinates apply for columns and bars. This method is inherited by
  41924. * scatter series.
  41925. *
  41926. * @private
  41927. * @function Highcharts.seriesTypes.column#drawPoints
  41928. */
  41929. ColumnSeries.prototype.drawPoints = function () {
  41930. var series = this,
  41931. chart = this.chart,
  41932. options = series.options,
  41933. renderer = chart.renderer,
  41934. animationLimit = options.animationLimit || 250,
  41935. shapeArgs;
  41936. // draw the columns
  41937. series.points.forEach(function (point) {
  41938. var plotY = point.plotY,
  41939. graphic = point.graphic,
  41940. hasGraphic = !!graphic,
  41941. verb = graphic && chart.pointCount < animationLimit ?
  41942. 'animate' : 'attr';
  41943. if (isNumber(plotY) && point.y !== null) {
  41944. shapeArgs = point.shapeArgs;
  41945. // When updating a series between 2d and 3d or cartesian and
  41946. // polar, the shape type changes.
  41947. if (graphic && point.hasNewShapeType()) {
  41948. graphic = graphic.destroy();
  41949. }
  41950. // Set starting position for point sliding animation.
  41951. if (series.enabledDataSorting) {
  41952. point.startXPos = series.xAxis.reversed ?
  41953. -(shapeArgs ? (shapeArgs.width || 0) : 0) :
  41954. series.xAxis.width;
  41955. }
  41956. if (!graphic) {
  41957. point.graphic = graphic =
  41958. renderer[point.shapeType](shapeArgs)
  41959. .add(point.group || series.group);
  41960. if (graphic &&
  41961. series.enabledDataSorting &&
  41962. chart.hasRendered &&
  41963. chart.pointCount < animationLimit) {
  41964. graphic.attr({
  41965. x: point.startXPos
  41966. });
  41967. hasGraphic = true;
  41968. verb = 'animate';
  41969. }
  41970. }
  41971. if (graphic && hasGraphic) { // update
  41972. graphic[verb](merge(shapeArgs));
  41973. }
  41974. // Border radius is not stylable (#6900)
  41975. if (options.borderRadius) {
  41976. graphic[verb]({
  41977. r: options.borderRadius
  41978. });
  41979. }
  41980. // Presentational
  41981. if (!chart.styledMode) {
  41982. graphic[verb](series.pointAttribs(point, (point.selected && 'select')))
  41983. .shadow(point.allowShadow !== false && options.shadow, null, options.stacking && !options.borderRadius);
  41984. }
  41985. if (graphic) {
  41986. graphic.addClass(point.getClassName(), true);
  41987. graphic.attr({
  41988. visibility: point.visible ? 'inherit' : 'hidden'
  41989. });
  41990. }
  41991. }
  41992. else if (graphic) {
  41993. point.graphic = graphic.destroy(); // #1269
  41994. }
  41995. });
  41996. };
  41997. /**
  41998. * Draw the tracker for a point.
  41999. * @private
  42000. */
  42001. ColumnSeries.prototype.drawTracker = function () {
  42002. var series = this,
  42003. chart = series.chart,
  42004. pointer = chart.pointer,
  42005. onMouseOver = function (e) {
  42006. var point = pointer.getPointFromEvent(e);
  42007. // undefined on graph in scatterchart
  42008. if (typeof point !== 'undefined') {
  42009. pointer.isDirectTouch = true;
  42010. point.onMouseOver(e);
  42011. }
  42012. }, dataLabels;
  42013. // Add reference to the point
  42014. series.points.forEach(function (point) {
  42015. dataLabels = (isArray(point.dataLabels) ?
  42016. point.dataLabels :
  42017. (point.dataLabel ? [point.dataLabel] : []));
  42018. if (point.graphic) {
  42019. point.graphic.element.point = point;
  42020. }
  42021. dataLabels.forEach(function (dataLabel) {
  42022. if (dataLabel.div) {
  42023. dataLabel.div.point = point;
  42024. }
  42025. else {
  42026. dataLabel.element.point = point;
  42027. }
  42028. });
  42029. });
  42030. // Add the event listeners, we need to do this only once
  42031. if (!series._hasTracking) {
  42032. series.trackerGroups.forEach(function (key) {
  42033. if (series[key]) {
  42034. // we don't always have dataLabelsGroup
  42035. series[key]
  42036. .addClass('highcharts-tracker')
  42037. .on('mouseover', onMouseOver)
  42038. .on('mouseout', function (e) {
  42039. pointer.onTrackerMouseOut(e);
  42040. });
  42041. if (hasTouch) {
  42042. series[key].on('touchstart', onMouseOver);
  42043. }
  42044. if (!chart.styledMode && series.options.cursor) {
  42045. series[key]
  42046. .css(css)
  42047. .css({ cursor: series.options.cursor });
  42048. }
  42049. }
  42050. });
  42051. series._hasTracking = true;
  42052. }
  42053. fireEvent(this, 'afterDrawTracker');
  42054. };
  42055. /**
  42056. * Remove this series from the chart
  42057. *
  42058. * @private
  42059. * @function Highcharts.seriesTypes.column#remove
  42060. */
  42061. ColumnSeries.prototype.remove = function () {
  42062. var series = this,
  42063. chart = series.chart;
  42064. // column and bar series affects other series of the same type
  42065. // as they are either stacked or grouped
  42066. if (chart.hasRendered) {
  42067. chart.series.forEach(function (otherSeries) {
  42068. if (otherSeries.type === series.type) {
  42069. otherSeries.isDirty = true;
  42070. }
  42071. });
  42072. }
  42073. Series.prototype.remove.apply(series, arguments);
  42074. };
  42075. /**
  42076. * Column series display one column per value along an X axis.
  42077. *
  42078. * @sample {highcharts} highcharts/demo/column-basic/
  42079. * Column chart
  42080. * @sample {highstock} stock/demo/column/
  42081. * Column chart
  42082. *
  42083. * @extends plotOptions.line
  42084. * @excluding connectEnds, connectNulls, gapSize, gapUnit, linecap,
  42085. * lineWidth, marker, step, useOhlcData
  42086. * @product highcharts highstock
  42087. * @optionparent plotOptions.column
  42088. */
  42089. ColumnSeries.defaultOptions = merge(Series.defaultOptions, {
  42090. /**
  42091. * The corner radius of the border surrounding each column or bar.
  42092. *
  42093. * @sample {highcharts} highcharts/plotoptions/column-borderradius/
  42094. * Rounded columns
  42095. *
  42096. * @product highcharts highstock gantt
  42097. *
  42098. * @private
  42099. */
  42100. borderRadius: 0,
  42101. /**
  42102. * When using automatic point colors pulled from the global
  42103. * [colors](colors) or series-specific
  42104. * [plotOptions.column.colors](series.colors) collections, this option
  42105. * determines whether the chart should receive one color per series or
  42106. * one color per point.
  42107. *
  42108. * In styled mode, the `colors` or `series.colors` arrays are not
  42109. * supported, and instead this option gives the points individual color
  42110. * class names on the form `highcharts-color-{n}`.
  42111. *
  42112. * @see [series colors](#plotOptions.column.colors)
  42113. *
  42114. * @sample {highcharts} highcharts/plotoptions/column-colorbypoint-false/
  42115. * False by default
  42116. * @sample {highcharts} highcharts/plotoptions/column-colorbypoint-true/
  42117. * True
  42118. *
  42119. * @type {boolean}
  42120. * @default false
  42121. * @since 2.0
  42122. * @product highcharts highstock gantt
  42123. * @apioption plotOptions.column.colorByPoint
  42124. */
  42125. /**
  42126. * A series specific or series type specific color set to apply instead
  42127. * of the global [colors](#colors) when [colorByPoint](
  42128. * #plotOptions.column.colorByPoint) is true.
  42129. *
  42130. * @type {Array<Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject>}
  42131. * @since 3.0
  42132. * @product highcharts highstock gantt
  42133. * @apioption plotOptions.column.colors
  42134. */
  42135. /**
  42136. * When `true`, the columns will center in the category, ignoring null
  42137. * or missing points. When `false`, space will be reserved for null or
  42138. * missing points.
  42139. *
  42140. * @sample {highcharts} highcharts/series-column/centerincategory/
  42141. * Center in category
  42142. *
  42143. * @since 8.0.1
  42144. * @product highcharts highstock gantt
  42145. *
  42146. * @private
  42147. */
  42148. centerInCategory: false,
  42149. /**
  42150. * Padding between each value groups, in x axis units.
  42151. *
  42152. * @sample {highcharts} highcharts/plotoptions/column-grouppadding-default/
  42153. * 0.2 by default
  42154. * @sample {highcharts} highcharts/plotoptions/column-grouppadding-none/
  42155. * No group padding - all columns are evenly spaced
  42156. *
  42157. * @product highcharts highstock gantt
  42158. *
  42159. * @private
  42160. */
  42161. groupPadding: 0.2,
  42162. /**
  42163. * Whether to group non-stacked columns or to let them render
  42164. * independent of each other. Non-grouped columns will be laid out
  42165. * individually and overlap each other.
  42166. *
  42167. * @sample {highcharts} highcharts/plotoptions/column-grouping-false/
  42168. * Grouping disabled
  42169. * @sample {highstock} highcharts/plotoptions/column-grouping-false/
  42170. * Grouping disabled
  42171. *
  42172. * @type {boolean}
  42173. * @default true
  42174. * @since 2.3.0
  42175. * @product highcharts highstock gantt
  42176. * @apioption plotOptions.column.grouping
  42177. */
  42178. /**
  42179. * @ignore-option
  42180. * @private
  42181. */
  42182. marker: null,
  42183. /**
  42184. * The maximum allowed pixel width for a column, translated to the
  42185. * height of a bar in a bar chart. This prevents the columns from
  42186. * becoming too wide when there is a small number of points in the
  42187. * chart.
  42188. *
  42189. * @see [pointWidth](#plotOptions.column.pointWidth)
  42190. *
  42191. * @sample {highcharts} highcharts/plotoptions/column-maxpointwidth-20/
  42192. * Limited to 50
  42193. * @sample {highstock} highcharts/plotoptions/column-maxpointwidth-20/
  42194. * Limited to 50
  42195. *
  42196. * @type {number}
  42197. * @since 4.1.8
  42198. * @product highcharts highstock gantt
  42199. * @apioption plotOptions.column.maxPointWidth
  42200. */
  42201. /**
  42202. * Padding between each column or bar, in x axis units.
  42203. *
  42204. * @sample {highcharts} highcharts/plotoptions/column-pointpadding-default/
  42205. * 0.1 by default
  42206. * @sample {highcharts} highcharts/plotoptions/column-pointpadding-025/
  42207. * 0.25
  42208. * @sample {highcharts} highcharts/plotoptions/column-pointpadding-none/
  42209. * 0 for tightly packed columns
  42210. *
  42211. * @product highcharts highstock gantt
  42212. *
  42213. * @private
  42214. */
  42215. pointPadding: 0.1,
  42216. /**
  42217. * A pixel value specifying a fixed width for each column or bar point.
  42218. * When set to `undefined`, the width is calculated from the
  42219. * `pointPadding` and `groupPadding`. The width effects the dimension
  42220. * that is not based on the point value. For column series it is the
  42221. * hoizontal length and for bar series it is the vertical length.
  42222. *
  42223. * @see [maxPointWidth](#plotOptions.column.maxPointWidth)
  42224. *
  42225. * @sample {highcharts} highcharts/plotoptions/column-pointwidth-20/
  42226. * 20px wide columns regardless of chart width or the amount of
  42227. * data points
  42228. *
  42229. * @type {number}
  42230. * @since 1.2.5
  42231. * @product highcharts highstock gantt
  42232. * @apioption plotOptions.column.pointWidth
  42233. */
  42234. /**
  42235. * A pixel value specifying a fixed width for the column or bar.
  42236. * Overrides pointWidth on the series.
  42237. *
  42238. * @see [series.pointWidth](#plotOptions.column.pointWidth)
  42239. *
  42240. * @type {number}
  42241. * @default undefined
  42242. * @since 7.0.0
  42243. * @product highcharts highstock gantt
  42244. * @apioption series.column.data.pointWidth
  42245. */
  42246. /**
  42247. * The minimal height for a column or width for a bar. By default,
  42248. * 0 values are not shown. To visualize a 0 (or close to zero) point,
  42249. * set the minimal point length to a pixel value like 3\. In stacked
  42250. * column charts, minPointLength might not be respected for tightly
  42251. * packed values.
  42252. *
  42253. * @sample {highcharts} highcharts/plotoptions/column-minpointlength/
  42254. * Zero base value
  42255. * @sample {highcharts} highcharts/plotoptions/column-minpointlength-pos-and-neg/
  42256. * Positive and negative close to zero values
  42257. *
  42258. * @product highcharts highstock gantt
  42259. *
  42260. * @private
  42261. */
  42262. minPointLength: 0,
  42263. /**
  42264. * When the series contains less points than the crop threshold, all
  42265. * points are drawn, event if the points fall outside the visible plot
  42266. * area at the current zoom. The advantage of drawing all points
  42267. * (including markers and columns), is that animation is performed on
  42268. * updates. On the other hand, when the series contains more points than
  42269. * the crop threshold, the series data is cropped to only contain points
  42270. * that fall within the plot area. The advantage of cropping away
  42271. * invisible points is to increase performance on large series.
  42272. *
  42273. * @product highcharts highstock gantt
  42274. *
  42275. * @private
  42276. */
  42277. cropThreshold: 50,
  42278. /**
  42279. * The X axis range that each point is valid for. This determines the
  42280. * width of the column. On a categorized axis, the range will be 1
  42281. * by default (one category unit). On linear and datetime axes, the
  42282. * range will be computed as the distance between the two closest data
  42283. * points.
  42284. *
  42285. * The default `null` means it is computed automatically, but this
  42286. * option can be used to override the automatic value.
  42287. *
  42288. * This option is set by default to 1 if data sorting is enabled.
  42289. *
  42290. * @sample {highcharts} highcharts/plotoptions/column-pointrange/
  42291. * Set the point range to one day on a data set with one week
  42292. * between the points
  42293. *
  42294. * @type {number|null}
  42295. * @since 2.3
  42296. * @product highcharts highstock gantt
  42297. *
  42298. * @private
  42299. */
  42300. pointRange: null,
  42301. states: {
  42302. /**
  42303. * Options for the hovered point. These settings override the normal
  42304. * state options when a point is moused over or touched.
  42305. *
  42306. * @extends plotOptions.series.states.hover
  42307. * @excluding halo, lineWidth, lineWidthPlus, marker
  42308. * @product highcharts highstock gantt
  42309. */
  42310. hover: {
  42311. /** @ignore-option */
  42312. halo: false,
  42313. /**
  42314. * A specific border color for the hovered point. Defaults to
  42315. * inherit the normal state border color.
  42316. *
  42317. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  42318. * @product highcharts gantt
  42319. * @apioption plotOptions.column.states.hover.borderColor
  42320. */
  42321. /**
  42322. * A specific color for the hovered point.
  42323. *
  42324. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  42325. * @product highcharts gantt
  42326. * @apioption plotOptions.column.states.hover.color
  42327. */
  42328. /**
  42329. * How much to brighten the point on interaction. Requires the
  42330. * main color to be defined in hex or rgb(a) format.
  42331. *
  42332. * In styled mode, the hover brightening is by default replaced
  42333. * with a fill-opacity set in the `.highcharts-point:hover`
  42334. * rule.
  42335. *
  42336. * @sample {highcharts} highcharts/plotoptions/column-states-hover-brightness/
  42337. * Brighten by 0.5
  42338. *
  42339. * @product highcharts highstock gantt
  42340. */
  42341. brightness: 0.1
  42342. },
  42343. /**
  42344. * Options for the selected point. These settings override the
  42345. * normal state options when a point is selected.
  42346. *
  42347. * @extends plotOptions.series.states.select
  42348. * @excluding halo, lineWidth, lineWidthPlus, marker
  42349. * @product highcharts highstock gantt
  42350. */
  42351. select: {
  42352. /**
  42353. * A specific color for the selected point.
  42354. *
  42355. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  42356. * @default #cccccc
  42357. * @product highcharts highstock gantt
  42358. */
  42359. color: palette.neutralColor20,
  42360. /**
  42361. * A specific border color for the selected point.
  42362. *
  42363. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  42364. * @default #000000
  42365. * @product highcharts highstock gantt
  42366. */
  42367. borderColor: palette.neutralColor100
  42368. }
  42369. },
  42370. dataLabels: {
  42371. align: void 0,
  42372. verticalAlign: void 0,
  42373. /**
  42374. * The y position offset of the label relative to the point in
  42375. * pixels.
  42376. *
  42377. * @type {number}
  42378. */
  42379. y: void 0
  42380. },
  42381. // false doesn't work well: https://jsfiddle.net/highcharts/hz8fopan/14/
  42382. /**
  42383. * @ignore-option
  42384. * @private
  42385. */
  42386. startFromThreshold: true,
  42387. stickyTracking: false,
  42388. tooltip: {
  42389. distance: 6
  42390. },
  42391. /**
  42392. * The Y axis value to serve as the base for the columns, for
  42393. * distinguishing between values above and below a threshold. If `null`,
  42394. * the columns extend from the padding Y axis minimum.
  42395. *
  42396. * @type {number|null}
  42397. * @since 2.0
  42398. * @product highcharts
  42399. *
  42400. * @private
  42401. */
  42402. threshold: 0,
  42403. /**
  42404. * The width of the border surrounding each column or bar. Defaults to
  42405. * `1` when there is room for a border, but to `0` when the columns are
  42406. * so dense that a border would cover the next column.
  42407. *
  42408. * In styled mode, the stroke width can be set with the
  42409. * `.highcharts-point` rule.
  42410. *
  42411. * @sample {highcharts} highcharts/plotoptions/column-borderwidth/
  42412. * 2px black border
  42413. *
  42414. * @type {number}
  42415. * @default undefined
  42416. * @product highcharts highstock gantt
  42417. * @apioption plotOptions.column.borderWidth
  42418. */
  42419. /**
  42420. * The color of the border surrounding each column or bar.
  42421. *
  42422. * In styled mode, the border stroke can be set with the
  42423. * `.highcharts-point` rule.
  42424. *
  42425. * @sample {highcharts} highcharts/plotoptions/column-bordercolor/
  42426. * Dark gray border
  42427. *
  42428. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  42429. * @default #ffffff
  42430. * @product highcharts highstock gantt
  42431. *
  42432. * @private
  42433. */
  42434. borderColor: palette.backgroundColor
  42435. });
  42436. return ColumnSeries;
  42437. }(Series));
  42438. extend(ColumnSeries.prototype, {
  42439. cropShoulder: 0,
  42440. // When tooltip is not shared, this series (and derivatives) requires
  42441. // direct touch/hover. KD-tree does not apply.
  42442. directTouch: true,
  42443. /**
  42444. * Use a solid rectangle like the area series types
  42445. *
  42446. * @private
  42447. * @function Highcharts.seriesTypes.column#drawLegendSymbol
  42448. *
  42449. * @param {Highcharts.Legend} legend
  42450. * The legend object
  42451. *
  42452. * @param {Highcharts.Series|Highcharts.Point} item
  42453. * The series (this) or point
  42454. */
  42455. drawLegendSymbol: LegendSymbolMixin.drawRectangle,
  42456. getSymbol: noop,
  42457. // use separate negative stacks, unlike area stacks where a negative
  42458. // point is substracted from previous (#1910)
  42459. negStacks: true,
  42460. trackerGroups: ['group', 'dataLabelsGroup']
  42461. });
  42462. SeriesRegistry.registerSeriesType('column', ColumnSeries);
  42463. /* *
  42464. *
  42465. * Export
  42466. *
  42467. * */
  42468. /* *
  42469. *
  42470. * API Declarations
  42471. *
  42472. * */
  42473. /**
  42474. * Adjusted width and x offset of the columns for grouping.
  42475. *
  42476. * @private
  42477. * @interface Highcharts.ColumnMetricsObject
  42478. */ /**
  42479. * Width of the columns.
  42480. * @name Highcharts.ColumnMetricsObject#width
  42481. * @type {number}
  42482. */ /**
  42483. * Offset of the columns.
  42484. * @name Highcharts.ColumnMetricsObject#offset
  42485. * @type {number}
  42486. */
  42487. ''; // detach doclets above
  42488. /* *
  42489. *
  42490. * API Options
  42491. *
  42492. * */
  42493. /**
  42494. * A `column` series. If the [type](#series.column.type) option is
  42495. * not specified, it is inherited from [chart.type](#chart.type).
  42496. *
  42497. * @extends series,plotOptions.column
  42498. * @excluding connectNulls, dataParser, dataURL, gapSize, gapUnit, linecap,
  42499. * lineWidth, marker, connectEnds, step
  42500. * @product highcharts highstock
  42501. * @apioption series.column
  42502. */
  42503. /**
  42504. * An array of data points for the series. For the `column` series type,
  42505. * points can be given in the following ways:
  42506. *
  42507. * 1. An array of numerical values. In this case, the numerical values will be
  42508. * interpreted as `y` options. The `x` values will be automatically
  42509. * calculated, either starting at 0 and incremented by 1, or from
  42510. * `pointStart` and `pointInterval` given in the series options. If the axis
  42511. * has categories, these will be used. Example:
  42512. * ```js
  42513. * data: [0, 5, 3, 5]
  42514. * ```
  42515. *
  42516. * 2. An array of arrays with 2 values. In this case, the values correspond to
  42517. * `x,y`. If the first value is a string, it is applied as the name of the
  42518. * point, and the `x` value is inferred.
  42519. * ```js
  42520. * data: [
  42521. * [0, 6],
  42522. * [1, 2],
  42523. * [2, 6]
  42524. * ]
  42525. * ```
  42526. *
  42527. * 3. An array of objects with named values. The following snippet shows only a
  42528. * few settings, see the complete options set below. If the total number of
  42529. * data points exceeds the series'
  42530. * [turboThreshold](#series.column.turboThreshold), this option is not
  42531. * available.
  42532. * ```js
  42533. * data: [{
  42534. * x: 1,
  42535. * y: 9,
  42536. * name: "Point2",
  42537. * color: "#00FF00"
  42538. * }, {
  42539. * x: 1,
  42540. * y: 6,
  42541. * name: "Point1",
  42542. * color: "#FF00FF"
  42543. * }]
  42544. * ```
  42545. *
  42546. * @sample {highcharts} highcharts/chart/reflow-true/
  42547. * Numerical values
  42548. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  42549. * Arrays of numeric x and y
  42550. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  42551. * Arrays of datetime x and y
  42552. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  42553. * Arrays of point.name and y
  42554. * @sample {highcharts} highcharts/series/data-array-of-objects/
  42555. * Config objects
  42556. *
  42557. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  42558. * @extends series.line.data
  42559. * @excluding marker
  42560. * @product highcharts highstock
  42561. * @apioption series.column.data
  42562. */
  42563. /**
  42564. * The color of the border surrounding the column or bar.
  42565. *
  42566. * In styled mode, the border stroke can be set with the `.highcharts-point`
  42567. * rule.
  42568. *
  42569. * @sample {highcharts} highcharts/plotoptions/column-bordercolor/
  42570. * Dark gray border
  42571. *
  42572. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  42573. * @product highcharts highstock
  42574. * @apioption series.column.data.borderColor
  42575. */
  42576. /**
  42577. * The width of the border surrounding the column or bar.
  42578. *
  42579. * In styled mode, the stroke width can be set with the `.highcharts-point`
  42580. * rule.
  42581. *
  42582. * @sample {highcharts} highcharts/plotoptions/column-borderwidth/
  42583. * 2px black border
  42584. *
  42585. * @type {number}
  42586. * @product highcharts highstock
  42587. * @apioption series.column.data.borderWidth
  42588. */
  42589. /**
  42590. * A name for the dash style to use for the column or bar. Overrides
  42591. * dashStyle on the series.
  42592. *
  42593. * In styled mode, the stroke dash-array can be set with the same classes as
  42594. * listed under [data.color](#series.column.data.color).
  42595. *
  42596. * @see [series.pointWidth](#plotOptions.column.dashStyle)
  42597. *
  42598. * @type {Highcharts.DashStyleValue}
  42599. * @apioption series.column.data.dashStyle
  42600. */
  42601. /**
  42602. * A pixel value specifying a fixed width for the column or bar. Overrides
  42603. * pointWidth on the series. The width effects the dimension that is not based
  42604. * on the point value.
  42605. *
  42606. * @see [series.pointWidth](#plotOptions.column.pointWidth)
  42607. *
  42608. * @type {number}
  42609. * @apioption series.column.data.pointWidth
  42610. */
  42611. /**
  42612. * @excluding halo, lineWidth, lineWidthPlus, marker
  42613. * @product highcharts highstock
  42614. * @apioption series.column.states.hover
  42615. */
  42616. /**
  42617. * @excluding halo, lineWidth, lineWidthPlus, marker
  42618. * @product highcharts highstock
  42619. * @apioption series.column.states.select
  42620. */
  42621. ''; // includes above doclets in transpilat
  42622. return ColumnSeries;
  42623. });
  42624. _registerModule(_modules, 'Series/Bar/BarSeries.js', [_modules['Series/Column/ColumnSeries.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (ColumnSeries, SeriesRegistry, U) {
  42625. /* *
  42626. *
  42627. * (c) 2010-2021 Torstein Honsi
  42628. *
  42629. * License: www.highcharts.com/license
  42630. *
  42631. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  42632. *
  42633. * */
  42634. var __extends = (this && this.__extends) || (function () {
  42635. var extendStatics = function (d,
  42636. b) {
  42637. extendStatics = Object.setPrototypeOf ||
  42638. ({ __proto__: [] } instanceof Array && function (d,
  42639. b) { d.__proto__ = b; }) ||
  42640. function (d,
  42641. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  42642. return extendStatics(d, b);
  42643. };
  42644. return function (d, b) {
  42645. extendStatics(d, b);
  42646. function __() { this.constructor = d; }
  42647. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  42648. };
  42649. })();
  42650. var extend = U.extend,
  42651. merge = U.merge;
  42652. /* *
  42653. *
  42654. * Class
  42655. *
  42656. * */
  42657. /**
  42658. * Bar series type.
  42659. *
  42660. * @private
  42661. * @class
  42662. * @name Highcharts.seriesTypes.bar
  42663. *
  42664. * @augments Highcharts.Series
  42665. */
  42666. var BarSeries = /** @class */ (function (_super) {
  42667. __extends(BarSeries, _super);
  42668. function BarSeries() {
  42669. /* *
  42670. *
  42671. * Static Properties
  42672. *
  42673. * */
  42674. var _this = _super !== null && _super.apply(this,
  42675. arguments) || this;
  42676. /* *
  42677. *
  42678. * Properties
  42679. *
  42680. * */
  42681. _this.data = void 0;
  42682. _this.options = void 0;
  42683. _this.points = void 0;
  42684. return _this;
  42685. }
  42686. /**
  42687. * A bar series is a special type of column series where the columns are
  42688. * horizontal.
  42689. *
  42690. * @sample highcharts/demo/bar-basic/
  42691. * Bar chart
  42692. *
  42693. * @extends plotOptions.column
  42694. * @product highcharts
  42695. * @optionparent plotOptions.bar
  42696. */
  42697. BarSeries.defaultOptions = merge(ColumnSeries.defaultOptions, {
  42698. // nothing here yet
  42699. });
  42700. return BarSeries;
  42701. }(ColumnSeries));
  42702. extend(BarSeries.prototype, {
  42703. inverted: true
  42704. });
  42705. SeriesRegistry.registerSeriesType('bar', BarSeries);
  42706. /* *
  42707. *
  42708. * Default Export
  42709. *
  42710. * */
  42711. /* *
  42712. *
  42713. * API Options
  42714. *
  42715. * */
  42716. /**
  42717. * A `bar` series. If the [type](#series.bar.type) option is not specified,
  42718. * it is inherited from [chart.type](#chart.type).
  42719. *
  42720. * @extends series,plotOptions.bar
  42721. * @excluding connectNulls, dashStyle, dataParser, dataURL, gapSize, gapUnit,
  42722. * linecap, lineWidth, marker, connectEnds, step
  42723. * @product highcharts
  42724. * @apioption series.bar
  42725. */
  42726. /**
  42727. * An array of data points for the series. For the `bar` series type,
  42728. * points can be given in the following ways:
  42729. *
  42730. * 1. An array of numerical values. In this case, the numerical values will be
  42731. * interpreted as `y` options. The `x` values will be automatically
  42732. * calculated, either starting at 0 and incremented by 1, or from
  42733. * `pointStart` and `pointInterval` given in the series options. If the axis
  42734. * has categories, these will be used. Example:
  42735. * ```js
  42736. * data: [0, 5, 3, 5]
  42737. * ```
  42738. *
  42739. * 2. An array of arrays with 2 values. In this case, the values correspond to
  42740. * `x,y`. If the first value is a string, it is applied as the name of the
  42741. * point, and the `x` value is inferred.
  42742. * ```js
  42743. * data: [
  42744. * [0, 5],
  42745. * [1, 10],
  42746. * [2, 3]
  42747. * ]
  42748. * ```
  42749. *
  42750. * 3. An array of objects with named values. The following snippet shows only a
  42751. * few settings, see the complete options set below. If the total number of
  42752. * data points exceeds the series'
  42753. * [turboThreshold](#series.bar.turboThreshold), this option is not
  42754. * available.
  42755. * ```js
  42756. * data: [{
  42757. * x: 1,
  42758. * y: 1,
  42759. * name: "Point2",
  42760. * color: "#00FF00"
  42761. * }, {
  42762. * x: 1,
  42763. * y: 10,
  42764. * name: "Point1",
  42765. * color: "#FF00FF"
  42766. * }]
  42767. * ```
  42768. *
  42769. * @sample {highcharts} highcharts/chart/reflow-true/
  42770. * Numerical values
  42771. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  42772. * Arrays of numeric x and y
  42773. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  42774. * Arrays of datetime x and y
  42775. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  42776. * Arrays of point.name and y
  42777. * @sample {highcharts} highcharts/series/data-array-of-objects/
  42778. * Config objects
  42779. *
  42780. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  42781. * @extends series.column.data
  42782. * @product highcharts
  42783. * @apioption series.bar.data
  42784. */
  42785. /**
  42786. * @excluding halo,lineWidth,lineWidthPlus,marker
  42787. * @product highcharts highstock
  42788. * @apioption series.bar.states.hover
  42789. */
  42790. /**
  42791. * @excluding halo,lineWidth,lineWidthPlus,marker
  42792. * @product highcharts highstock
  42793. * @apioption series.bar.states.select
  42794. */
  42795. ''; // gets doclets above into transpilat
  42796. return BarSeries;
  42797. });
  42798. _registerModule(_modules, 'Series/Scatter/ScatterSeries.js', [_modules['Series/Column/ColumnSeries.js'], _modules['Series/Line/LineSeries.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (ColumnSeries, LineSeries, SeriesRegistry, U) {
  42799. /* *
  42800. *
  42801. * (c) 2010-2021 Torstein Honsi
  42802. *
  42803. * License: www.highcharts.com/license
  42804. *
  42805. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  42806. *
  42807. * */
  42808. var __extends = (this && this.__extends) || (function () {
  42809. var extendStatics = function (d,
  42810. b) {
  42811. extendStatics = Object.setPrototypeOf ||
  42812. ({ __proto__: [] } instanceof Array && function (d,
  42813. b) { d.__proto__ = b; }) ||
  42814. function (d,
  42815. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  42816. return extendStatics(d, b);
  42817. };
  42818. return function (d, b) {
  42819. extendStatics(d, b);
  42820. function __() { this.constructor = d; }
  42821. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  42822. };
  42823. })();
  42824. var addEvent = U.addEvent,
  42825. extend = U.extend,
  42826. merge = U.merge;
  42827. /* *
  42828. *
  42829. * Class
  42830. *
  42831. * */
  42832. /**
  42833. * Scatter series type.
  42834. *
  42835. * @private
  42836. */
  42837. var ScatterSeries = /** @class */ (function (_super) {
  42838. __extends(ScatterSeries, _super);
  42839. function ScatterSeries() {
  42840. var _this = _super !== null && _super.apply(this,
  42841. arguments) || this;
  42842. /* *
  42843. *
  42844. * Properties
  42845. *
  42846. * */
  42847. _this.data = void 0;
  42848. _this.options = void 0;
  42849. _this.points = void 0;
  42850. return _this;
  42851. /* eslint-enable valid-jsdoc */
  42852. }
  42853. /* *
  42854. *
  42855. * Functions
  42856. *
  42857. * */
  42858. /* eslint-disable valid-jsdoc */
  42859. /**
  42860. * Optionally add the jitter effect.
  42861. * @private
  42862. */
  42863. ScatterSeries.prototype.applyJitter = function () {
  42864. var series = this,
  42865. jitter = this.options.jitter,
  42866. len = this.points.length;
  42867. /**
  42868. * Return a repeatable, pseudo-random number based on an integer
  42869. * seed.
  42870. * @private
  42871. */
  42872. function unrandom(seed) {
  42873. var rand = Math.sin(seed) * 10000;
  42874. return rand - Math.floor(rand);
  42875. }
  42876. if (jitter) {
  42877. this.points.forEach(function (point, i) {
  42878. ['x', 'y'].forEach(function (dim, j) {
  42879. var axis,
  42880. plotProp = 'plot' + dim.toUpperCase(),
  42881. min,
  42882. max,
  42883. translatedJitter;
  42884. if (jitter[dim] && !point.isNull) {
  42885. axis = series[dim + 'Axis'];
  42886. translatedJitter =
  42887. jitter[dim] * axis.transA;
  42888. if (axis && !axis.isLog) {
  42889. // Identify the outer bounds of the jitter range
  42890. min = Math.max(0, point[plotProp] - translatedJitter);
  42891. max = Math.min(axis.len, point[plotProp] + translatedJitter);
  42892. // Find a random position within this range
  42893. point[plotProp] = min +
  42894. (max - min) * unrandom(i + j * len);
  42895. // Update clientX for the tooltip k-d-tree
  42896. if (dim === 'x') {
  42897. point.clientX = point.plotX;
  42898. }
  42899. }
  42900. }
  42901. });
  42902. });
  42903. }
  42904. };
  42905. /**
  42906. * @private
  42907. * @function Highcharts.seriesTypes.scatter#drawGraph
  42908. */
  42909. ScatterSeries.prototype.drawGraph = function () {
  42910. if (this.options.lineWidth ||
  42911. // In case we have a graph from before and we update the line
  42912. // width to 0 (#13816)
  42913. (this.options.lineWidth === 0 &&
  42914. this.graph &&
  42915. this.graph.strokeWidth())) {
  42916. _super.prototype.drawGraph.call(this);
  42917. }
  42918. };
  42919. /**
  42920. * A scatter plot uses cartesian coordinates to display values for two
  42921. * variables for a set of data.
  42922. *
  42923. * @sample {highcharts} highcharts/demo/scatter/
  42924. * Scatter plot
  42925. *
  42926. * @extends plotOptions.line
  42927. * @excluding cropThreshold, pointPlacement, shadow, useOhlcData
  42928. * @product highcharts highstock
  42929. * @optionparent plotOptions.scatter
  42930. */
  42931. ScatterSeries.defaultOptions = merge(LineSeries.defaultOptions, {
  42932. /**
  42933. * The width of the line connecting the data points.
  42934. *
  42935. * @sample {highcharts} highcharts/plotoptions/scatter-linewidth-none/
  42936. * 0 by default
  42937. * @sample {highcharts} highcharts/plotoptions/scatter-linewidth-1/
  42938. * 1px
  42939. *
  42940. * @product highcharts highstock
  42941. */
  42942. lineWidth: 0,
  42943. findNearestPointBy: 'xy',
  42944. /**
  42945. * Apply a jitter effect for the rendered markers. When plotting
  42946. * discrete values, a little random noise may help telling the points
  42947. * apart. The jitter setting applies a random displacement of up to `n`
  42948. * axis units in either direction. So for example on a horizontal X
  42949. * axis, setting the `jitter.x` to 0.24 will render the point in a
  42950. * random position between 0.24 units to the left and 0.24 units to the
  42951. * right of the true axis position. On a category axis, setting it to
  42952. * 0.5 will fill up the bin and make the data appear continuous.
  42953. *
  42954. * When rendered on top of a box plot or a column series, a jitter value
  42955. * of 0.24 will correspond to the underlying series' default
  42956. * [groupPadding](
  42957. * https://api.highcharts.com/highcharts/plotOptions.column.groupPadding)
  42958. * and [pointPadding](
  42959. * https://api.highcharts.com/highcharts/plotOptions.column.pointPadding)
  42960. * settings.
  42961. *
  42962. * @sample {highcharts} highcharts/series-scatter/jitter
  42963. * Jitter on a scatter plot
  42964. *
  42965. * @sample {highcharts} highcharts/series-scatter/jitter-boxplot
  42966. * Jittered scatter plot on top of a box plot
  42967. *
  42968. * @product highcharts highstock
  42969. * @since 7.0.2
  42970. */
  42971. jitter: {
  42972. /**
  42973. * The maximal X offset for the random jitter effect.
  42974. */
  42975. x: 0,
  42976. /**
  42977. * The maximal Y offset for the random jitter effect.
  42978. */
  42979. y: 0
  42980. },
  42981. marker: {
  42982. enabled: true // Overrides auto-enabling in line series (#3647)
  42983. },
  42984. /**
  42985. * Sticky tracking of mouse events. When true, the `mouseOut` event
  42986. * on a series isn't triggered until the mouse moves over another
  42987. * series, or out of the plot area. When false, the `mouseOut` event on
  42988. * a series is triggered when the mouse leaves the area around the
  42989. * series' graph or markers. This also implies the tooltip. When
  42990. * `stickyTracking` is false and `tooltip.shared` is false, the tooltip
  42991. * will be hidden when moving the mouse between series.
  42992. *
  42993. * @type {boolean}
  42994. * @default false
  42995. * @product highcharts highstock
  42996. * @apioption plotOptions.scatter.stickyTracking
  42997. */
  42998. /**
  42999. * A configuration object for the tooltip rendering of each single
  43000. * series. Properties are inherited from [tooltip](#tooltip).
  43001. * Overridable properties are `headerFormat`, `pointFormat`,
  43002. * `yDecimals`, `xDateFormat`, `yPrefix` and `ySuffix`. Unlike other
  43003. * series, in a scatter plot the series.name by default shows in the
  43004. * headerFormat and point.x and point.y in the pointFormat.
  43005. *
  43006. * @product highcharts highstock
  43007. */
  43008. tooltip: {
  43009. headerFormat: '<span style="color:{point.color}">\u25CF</span> ' +
  43010. '<span style="font-size: 10px"> {series.name}</span><br/>',
  43011. pointFormat: 'x: <b>{point.x}</b><br/>y: <b>{point.y}</b><br/>'
  43012. }
  43013. });
  43014. return ScatterSeries;
  43015. }(LineSeries));
  43016. extend(ScatterSeries.prototype, {
  43017. drawTracker: ColumnSeries.prototype.drawTracker,
  43018. sorted: false,
  43019. requireSorting: false,
  43020. noSharedTooltip: true,
  43021. trackerGroups: ['group', 'markerGroup', 'dataLabelsGroup'],
  43022. takeOrdinalPosition: false // #2342
  43023. });
  43024. /* *
  43025. *
  43026. * Events
  43027. *
  43028. * */
  43029. /* eslint-disable no-invalid-this */
  43030. addEvent(ScatterSeries, 'afterTranslate', function () {
  43031. this.applyJitter();
  43032. });
  43033. SeriesRegistry.registerSeriesType('scatter', ScatterSeries);
  43034. /* *
  43035. *
  43036. * Default Export
  43037. *
  43038. * */
  43039. /* *
  43040. *
  43041. * API Options
  43042. *
  43043. * */
  43044. /**
  43045. * A `scatter` series. If the [type](#series.scatter.type) option is
  43046. * not specified, it is inherited from [chart.type](#chart.type).
  43047. *
  43048. * @extends series,plotOptions.scatter
  43049. * @excluding cropThreshold, dataParser, dataURL, useOhlcData
  43050. * @product highcharts highstock
  43051. * @apioption series.scatter
  43052. */
  43053. /**
  43054. * An array of data points for the series. For the `scatter` series
  43055. * type, points can be given in the following ways:
  43056. *
  43057. * 1. An array of numerical values. In this case, the numerical values will be
  43058. * interpreted as `y` options. The `x` values will be automatically
  43059. * calculated, either starting at 0 and incremented by 1, or from
  43060. * `pointStart` and `pointInterval` given in the series options. If the axis
  43061. * has categories, these will be used. Example:
  43062. * ```js
  43063. * data: [0, 5, 3, 5]
  43064. * ```
  43065. *
  43066. * 2. An array of arrays with 2 values. In this case, the values correspond to
  43067. * `x,y`. If the first value is a string, it is applied as the name of the
  43068. * point, and the `x` value is inferred.
  43069. * ```js
  43070. * data: [
  43071. * [0, 0],
  43072. * [1, 8],
  43073. * [2, 9]
  43074. * ]
  43075. * ```
  43076. *
  43077. * 3. An array of objects with named values. The following snippet shows only a
  43078. * few settings, see the complete options set below. If the total number of
  43079. * data points exceeds the series'
  43080. * [turboThreshold](#series.scatter.turboThreshold), this option is not
  43081. * available.
  43082. * ```js
  43083. * data: [{
  43084. * x: 1,
  43085. * y: 2,
  43086. * name: "Point2",
  43087. * color: "#00FF00"
  43088. * }, {
  43089. * x: 1,
  43090. * y: 4,
  43091. * name: "Point1",
  43092. * color: "#FF00FF"
  43093. * }]
  43094. * ```
  43095. *
  43096. * @sample {highcharts} highcharts/chart/reflow-true/
  43097. * Numerical values
  43098. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  43099. * Arrays of numeric x and y
  43100. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  43101. * Arrays of datetime x and y
  43102. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  43103. * Arrays of point.name and y
  43104. * @sample {highcharts} highcharts/series/data-array-of-objects/
  43105. * Config objects
  43106. *
  43107. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  43108. * @extends series.line.data
  43109. * @product highcharts highstock
  43110. * @apioption series.scatter.data
  43111. */
  43112. ''; // adds doclets above to transpilat
  43113. return ScatterSeries;
  43114. });
  43115. _registerModule(_modules, 'Mixins/CenteredSeries.js', [_modules['Core/Globals.js'], _modules['Core/Series/Series.js'], _modules['Core/Utilities.js']], function (H, Series, U) {
  43116. /* *
  43117. *
  43118. * (c) 2010-2021 Torstein Honsi
  43119. *
  43120. * License: www.highcharts.com/license
  43121. *
  43122. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  43123. *
  43124. * */
  43125. /**
  43126. * @private
  43127. * @interface Highcharts.RadianAngles
  43128. */ /**
  43129. * @name Highcharts.RadianAngles#end
  43130. * @type {number}
  43131. */ /**
  43132. * @name Highcharts.RadianAngles#start
  43133. * @type {number}
  43134. */
  43135. var isNumber = U.isNumber,
  43136. pick = U.pick,
  43137. relativeLength = U.relativeLength;
  43138. var deg2rad = H.deg2rad;
  43139. /* eslint-disable valid-jsdoc */
  43140. /**
  43141. * @private
  43142. * @mixin Highcharts.CenteredSeriesMixin
  43143. */
  43144. var centeredSeriesMixin = H.CenteredSeriesMixin = {
  43145. /**
  43146. * Get the center of the pie based on the size and center options relative
  43147. * to the plot area. Borrowed by the polar and gauge series types.
  43148. *
  43149. * @private
  43150. * @function Highcharts.CenteredSeriesMixin.getCenter
  43151. *
  43152. * @return {Array<number>}
  43153. */
  43154. getCenter: function () {
  43155. var options = this.options,
  43156. chart = this.chart,
  43157. slicingRoom = 2 * (options.slicedOffset || 0),
  43158. handleSlicingRoom,
  43159. plotWidth = chart.plotWidth - 2 * slicingRoom,
  43160. plotHeight = chart.plotHeight - 2 * slicingRoom,
  43161. centerOption = options.center,
  43162. smallestSize = Math.min(plotWidth,
  43163. plotHeight),
  43164. size = options.size,
  43165. innerSize = options.innerSize || 0,
  43166. positions,
  43167. i,
  43168. value;
  43169. if (typeof size === 'string') {
  43170. size = parseFloat(size);
  43171. }
  43172. if (typeof innerSize === 'string') {
  43173. innerSize = parseFloat(innerSize);
  43174. }
  43175. positions = [
  43176. pick(centerOption[0], '50%'),
  43177. pick(centerOption[1], '50%'),
  43178. // Prevent from negative values
  43179. pick(size && size < 0 ? void 0 : options.size, '100%'),
  43180. pick(innerSize && innerSize < 0 ? void 0 : options.innerSize || 0, '0%')
  43181. ];
  43182. // No need for inner size in angular (gauges) series but still required
  43183. // for pie series
  43184. if (chart.angular && !(this instanceof Series)) {
  43185. positions[3] = 0;
  43186. }
  43187. for (i = 0; i < 4; ++i) {
  43188. value = positions[i];
  43189. handleSlicingRoom = i < 2 || (i === 2 && /%$/.test(value));
  43190. // i == 0: centerX, relative to width
  43191. // i == 1: centerY, relative to height
  43192. // i == 2: size, relative to smallestSize
  43193. // i == 3: innerSize, relative to size
  43194. positions[i] = relativeLength(value, [plotWidth, plotHeight, smallestSize, positions[2]][i]) + (handleSlicingRoom ? slicingRoom : 0);
  43195. }
  43196. // innerSize cannot be larger than size (#3632)
  43197. if (positions[3] > positions[2]) {
  43198. positions[3] = positions[2];
  43199. }
  43200. return positions;
  43201. },
  43202. /**
  43203. * getStartAndEndRadians - Calculates start and end angles in radians.
  43204. * Used in series types such as pie and sunburst.
  43205. *
  43206. * @private
  43207. * @function Highcharts.CenteredSeriesMixin.getStartAndEndRadians
  43208. *
  43209. * @param {number} [start]
  43210. * Start angle in degrees.
  43211. *
  43212. * @param {number} [end]
  43213. * Start angle in degrees.
  43214. *
  43215. * @return {Highcharts.RadianAngles}
  43216. * Returns an object containing start and end angles as radians.
  43217. */
  43218. getStartAndEndRadians: function (start, end) {
  43219. var startAngle = isNumber(start) ? start : 0, // must be a number
  43220. endAngle = ((isNumber(end) && // must be a number
  43221. end > startAngle && // must be larger than the start angle
  43222. // difference must be less than 360 degrees
  43223. (end - startAngle) < 360) ?
  43224. end :
  43225. startAngle + 360),
  43226. correction = -90;
  43227. return {
  43228. start: deg2rad * (startAngle + correction),
  43229. end: deg2rad * (endAngle + correction)
  43230. };
  43231. }
  43232. };
  43233. return centeredSeriesMixin;
  43234. });
  43235. _registerModule(_modules, 'Series/Pie/PiePoint.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Series/Point.js'], _modules['Core/Utilities.js']], function (A, Point, U) {
  43236. /* *
  43237. *
  43238. * (c) 2010-2021 Torstein Honsi
  43239. *
  43240. * License: www.highcharts.com/license
  43241. *
  43242. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  43243. *
  43244. * */
  43245. var __extends = (this && this.__extends) || (function () {
  43246. var extendStatics = function (d,
  43247. b) {
  43248. extendStatics = Object.setPrototypeOf ||
  43249. ({ __proto__: [] } instanceof Array && function (d,
  43250. b) { d.__proto__ = b; }) ||
  43251. function (d,
  43252. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  43253. return extendStatics(d, b);
  43254. };
  43255. return function (d, b) {
  43256. extendStatics(d, b);
  43257. function __() { this.constructor = d; }
  43258. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  43259. };
  43260. })();
  43261. var setAnimation = A.setAnimation;
  43262. var addEvent = U.addEvent,
  43263. defined = U.defined,
  43264. extend = U.extend,
  43265. isNumber = U.isNumber,
  43266. pick = U.pick,
  43267. relativeLength = U.relativeLength;
  43268. /* *
  43269. *
  43270. * Class
  43271. *
  43272. * */
  43273. var PiePoint = /** @class */ (function (_super) {
  43274. __extends(PiePoint, _super);
  43275. function PiePoint() {
  43276. /* *
  43277. *
  43278. * Properties
  43279. *
  43280. * */
  43281. var _this = _super !== null && _super.apply(this,
  43282. arguments) || this;
  43283. _this.labelDistance = void 0;
  43284. _this.options = void 0;
  43285. _this.series = void 0;
  43286. return _this;
  43287. }
  43288. /* *
  43289. *
  43290. * Functions
  43291. *
  43292. * */
  43293. /* eslint-disable valid-jsdoc */
  43294. /**
  43295. * Extendable method for getting the path of the connector between the
  43296. * data label and the pie slice.
  43297. * @private
  43298. */
  43299. PiePoint.prototype.getConnectorPath = function () {
  43300. var labelPosition = this.labelPosition,
  43301. options = this.series.options.dataLabels,
  43302. connectorShape = options.connectorShape,
  43303. predefinedShapes = this.connectorShapes;
  43304. // find out whether to use the predefined shape
  43305. if (predefinedShapes[connectorShape]) {
  43306. connectorShape = predefinedShapes[connectorShape];
  43307. }
  43308. return connectorShape.call(this, {
  43309. // pass simplified label position object for user's convenience
  43310. x: labelPosition.final.x,
  43311. y: labelPosition.final.y,
  43312. alignment: labelPosition.alignment
  43313. }, labelPosition.connectorPosition, options);
  43314. };
  43315. /**
  43316. * @private
  43317. */
  43318. PiePoint.prototype.getTranslate = function () {
  43319. return this.sliced ? this.slicedTranslation : {
  43320. translateX: 0,
  43321. translateY: 0
  43322. };
  43323. };
  43324. /**
  43325. * @private
  43326. */
  43327. PiePoint.prototype.haloPath = function (size) {
  43328. var shapeArgs = this.shapeArgs;
  43329. return this.sliced || !this.visible ?
  43330. [] :
  43331. this.series.chart.renderer.symbols.arc(shapeArgs.x, shapeArgs.y, shapeArgs.r + size, shapeArgs.r + size, {
  43332. // Substract 1px to ensure the background is not bleeding
  43333. // through between the halo and the slice (#7495).
  43334. innerR: shapeArgs.r - 1,
  43335. start: shapeArgs.start,
  43336. end: shapeArgs.end
  43337. });
  43338. };
  43339. /**
  43340. * Initialize the pie slice.
  43341. * @private
  43342. */
  43343. PiePoint.prototype.init = function () {
  43344. Point.prototype.init.apply(this, arguments);
  43345. var point = this,
  43346. toggleSlice;
  43347. point.name = pick(point.name, 'Slice');
  43348. // add event listener for select
  43349. toggleSlice = function (e) {
  43350. point.slice(e.type === 'select');
  43351. };
  43352. addEvent(point, 'select', toggleSlice);
  43353. addEvent(point, 'unselect', toggleSlice);
  43354. return point;
  43355. };
  43356. /**
  43357. * Negative points are not valid (#1530, #3623, #5322)
  43358. * @private
  43359. */
  43360. PiePoint.prototype.isValid = function () {
  43361. return isNumber(this.y) && this.y >= 0;
  43362. };
  43363. /**
  43364. * Toggle the visibility of the pie slice.
  43365. * @private
  43366. *
  43367. * @param {boolean} vis
  43368. * Whether to show the slice or not. If undefined, the visibility is
  43369. * toggled.
  43370. */
  43371. PiePoint.prototype.setVisible = function (vis, redraw) {
  43372. var point = this,
  43373. series = point.series,
  43374. chart = series.chart,
  43375. ignoreHiddenPoint = series.options.ignoreHiddenPoint;
  43376. redraw = pick(redraw, ignoreHiddenPoint);
  43377. if (vis !== point.visible) {
  43378. // If called without an argument, toggle visibility
  43379. point.visible = point.options.visible = vis =
  43380. typeof vis === 'undefined' ? !point.visible : vis;
  43381. // update userOptions.data
  43382. series.options.data[series.data.indexOf(point)] =
  43383. point.options;
  43384. // Show and hide associated elements. This is performed
  43385. // regardless of redraw or not, because chart.redraw only
  43386. // handles full series.
  43387. ['graphic', 'dataLabel', 'connector', 'shadowGroup'].forEach(function (key) {
  43388. if (point[key]) {
  43389. point[key][vis ? 'show' : 'hide'](vis);
  43390. }
  43391. });
  43392. if (point.legendItem) {
  43393. chart.legend.colorizeItem(point, vis);
  43394. }
  43395. // #4170, hide halo after hiding point
  43396. if (!vis && point.state === 'hover') {
  43397. point.setState('');
  43398. }
  43399. // Handle ignore hidden slices
  43400. if (ignoreHiddenPoint) {
  43401. series.isDirty = true;
  43402. }
  43403. if (redraw) {
  43404. chart.redraw();
  43405. }
  43406. }
  43407. };
  43408. /**
  43409. * Set or toggle whether the slice is cut out from the pie.
  43410. * @private
  43411. *
  43412. * @param {boolean} sliced
  43413. * When undefined, the slice state is toggled.
  43414. *
  43415. * @param {boolean} redraw
  43416. * Whether to redraw the chart. True by default.
  43417. *
  43418. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>}
  43419. * Animation options.
  43420. */
  43421. PiePoint.prototype.slice = function (sliced, redraw, animation) {
  43422. var point = this,
  43423. series = point.series,
  43424. chart = series.chart;
  43425. setAnimation(animation, chart);
  43426. // redraw is true by default
  43427. redraw = pick(redraw, true);
  43428. /**
  43429. * Pie series only. Whether to display a slice offset from the
  43430. * center.
  43431. * @name Highcharts.Point#sliced
  43432. * @type {boolean|undefined}
  43433. */
  43434. // if called without an argument, toggle
  43435. point.sliced = point.options.sliced = sliced =
  43436. defined(sliced) ? sliced : !point.sliced;
  43437. // update userOptions.data
  43438. series.options.data[series.data.indexOf(point)] =
  43439. point.options;
  43440. if (point.graphic) {
  43441. point.graphic.animate(this.getTranslate());
  43442. }
  43443. if (point.shadowGroup) {
  43444. point.shadowGroup.animate(this.getTranslate());
  43445. }
  43446. };
  43447. return PiePoint;
  43448. }(Point));
  43449. extend(PiePoint.prototype, {
  43450. connectorShapes: {
  43451. // only one available before v7.0.0
  43452. fixedOffset: function (labelPosition, connectorPosition, options) {
  43453. var breakAt = connectorPosition.breakAt,
  43454. touchingSliceAt = connectorPosition.touchingSliceAt,
  43455. lineSegment = options.softConnector ? [
  43456. 'C',
  43457. // 1st control point (of the curve)
  43458. labelPosition.x +
  43459. // 5 gives the connector a little horizontal bend
  43460. (labelPosition.alignment === 'left' ? -5 : 5),
  43461. labelPosition.y,
  43462. 2 * breakAt.x - touchingSliceAt.x,
  43463. 2 * breakAt.y - touchingSliceAt.y,
  43464. breakAt.x,
  43465. breakAt.y //
  43466. ] : [
  43467. 'L',
  43468. breakAt.x,
  43469. breakAt.y
  43470. ];
  43471. // assemble the path
  43472. return ([
  43473. ['M', labelPosition.x, labelPosition.y],
  43474. lineSegment,
  43475. ['L', touchingSliceAt.x, touchingSliceAt.y]
  43476. ]);
  43477. },
  43478. straight: function (labelPosition, connectorPosition) {
  43479. var touchingSliceAt = connectorPosition.touchingSliceAt;
  43480. // direct line to the slice
  43481. return [
  43482. ['M', labelPosition.x, labelPosition.y],
  43483. ['L', touchingSliceAt.x, touchingSliceAt.y]
  43484. ];
  43485. },
  43486. crookedLine: function (labelPosition, connectorPosition, options) {
  43487. var touchingSliceAt = connectorPosition.touchingSliceAt,
  43488. series = this.series,
  43489. pieCenterX = series.center[0],
  43490. plotWidth = series.chart.plotWidth,
  43491. plotLeft = series.chart.plotLeft,
  43492. alignment = labelPosition.alignment,
  43493. radius = this.shapeArgs.r,
  43494. crookDistance = relativeLength(// % to fraction
  43495. options.crookDistance, 1),
  43496. crookX = alignment === 'left' ?
  43497. pieCenterX + radius + (plotWidth + plotLeft -
  43498. pieCenterX - radius) * (1 - crookDistance) :
  43499. plotLeft + (pieCenterX - radius) * crookDistance,
  43500. segmentWithCrook = [
  43501. 'L',
  43502. crookX,
  43503. labelPosition.y
  43504. ],
  43505. useCrook = true;
  43506. // crookedLine formula doesn't make sense if the path overlaps
  43507. // the label - use straight line instead in that case
  43508. if (alignment === 'left' ?
  43509. (crookX > labelPosition.x || crookX < touchingSliceAt.x) :
  43510. (crookX < labelPosition.x || crookX > touchingSliceAt.x)) {
  43511. useCrook = false;
  43512. }
  43513. // assemble the path
  43514. var path = [
  43515. ['M',
  43516. labelPosition.x,
  43517. labelPosition.y]
  43518. ];
  43519. if (useCrook) {
  43520. path.push(segmentWithCrook);
  43521. }
  43522. path.push(['L', touchingSliceAt.x, touchingSliceAt.y]);
  43523. return path;
  43524. }
  43525. }
  43526. });
  43527. /* *
  43528. *
  43529. * Default Export
  43530. *
  43531. * */
  43532. return PiePoint;
  43533. });
  43534. _registerModule(_modules, 'Series/Pie/PieSeries.js', [_modules['Mixins/CenteredSeries.js'], _modules['Series/Column/ColumnSeries.js'], _modules['Core/Globals.js'], _modules['Mixins/LegendSymbol.js'], _modules['Core/Color/Palette.js'], _modules['Series/Pie/PiePoint.js'], _modules['Core/Series/Series.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Renderer/SVG/SVGRenderer.js'], _modules['Core/Utilities.js']], function (CenteredSeriesMixin, ColumnSeries, H, LegendSymbolMixin, palette, PiePoint, Series, SeriesRegistry, SVGRenderer, U) {
  43535. /* *
  43536. *
  43537. * (c) 2010-2021 Torstein Honsi
  43538. *
  43539. * License: www.highcharts.com/license
  43540. *
  43541. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  43542. *
  43543. * */
  43544. var __extends = (this && this.__extends) || (function () {
  43545. var extendStatics = function (d,
  43546. b) {
  43547. extendStatics = Object.setPrototypeOf ||
  43548. ({ __proto__: [] } instanceof Array && function (d,
  43549. b) { d.__proto__ = b; }) ||
  43550. function (d,
  43551. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  43552. return extendStatics(d, b);
  43553. };
  43554. return function (d, b) {
  43555. extendStatics(d, b);
  43556. function __() { this.constructor = d; }
  43557. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  43558. };
  43559. })();
  43560. var getStartAndEndRadians = CenteredSeriesMixin.getStartAndEndRadians;
  43561. var noop = H.noop;
  43562. var clamp = U.clamp,
  43563. extend = U.extend,
  43564. fireEvent = U.fireEvent,
  43565. merge = U.merge,
  43566. pick = U.pick,
  43567. relativeLength = U.relativeLength;
  43568. /* *
  43569. *
  43570. * Class
  43571. *
  43572. * */
  43573. /**
  43574. * Pie series type.
  43575. *
  43576. * @private
  43577. * @class
  43578. * @name Highcharts.seriesTypes.pie
  43579. *
  43580. * @augments Highcharts.Series
  43581. */
  43582. var PieSeries = /** @class */ (function (_super) {
  43583. __extends(PieSeries, _super);
  43584. function PieSeries() {
  43585. /* *
  43586. *
  43587. * Static Properties
  43588. *
  43589. * */
  43590. var _this = _super !== null && _super.apply(this,
  43591. arguments) || this;
  43592. /* *
  43593. *
  43594. * Properties
  43595. *
  43596. * */
  43597. _this.center = void 0;
  43598. _this.data = void 0;
  43599. _this.maxLabelDistance = void 0;
  43600. _this.options = void 0;
  43601. _this.points = void 0;
  43602. return _this;
  43603. /* eslint-enable valid-jsdoc */
  43604. }
  43605. /* *
  43606. *
  43607. * Functions
  43608. *
  43609. * */
  43610. /* eslint-disable valid-jsdoc */
  43611. /**
  43612. * Animates the pies in.
  43613. * @private
  43614. */
  43615. PieSeries.prototype.animate = function (init) {
  43616. var series = this,
  43617. points = series.points,
  43618. startAngleRad = series.startAngleRad;
  43619. if (!init) {
  43620. points.forEach(function (point) {
  43621. var graphic = point.graphic,
  43622. args = point.shapeArgs;
  43623. if (graphic && args) {
  43624. // start values
  43625. graphic.attr({
  43626. // animate from inner radius (#779)
  43627. r: pick(point.startR, (series.center && series.center[3] / 2)),
  43628. start: startAngleRad,
  43629. end: startAngleRad
  43630. });
  43631. // animate
  43632. graphic.animate({
  43633. r: args.r,
  43634. start: args.start,
  43635. end: args.end
  43636. }, series.options.animation);
  43637. }
  43638. });
  43639. }
  43640. };
  43641. /**
  43642. * Called internally to draw auxiliary graph in pie-like series in
  43643. * situtation when the default graph is not sufficient enough to present
  43644. * the data well. Auxiliary graph is saved in the same object as
  43645. * regular graph.
  43646. * @private
  43647. */
  43648. PieSeries.prototype.drawEmpty = function () {
  43649. var centerX,
  43650. centerY,
  43651. start = this.startAngleRad,
  43652. end = this.endAngleRad,
  43653. options = this.options;
  43654. // Draw auxiliary graph if there're no visible points.
  43655. if (this.total === 0 && this.center) {
  43656. centerX = this.center[0];
  43657. centerY = this.center[1];
  43658. if (!this.graph) {
  43659. this.graph = this.chart.renderer
  43660. .arc(centerX, centerY, this.center[1] / 2, 0, start, end)
  43661. .addClass('highcharts-empty-series')
  43662. .add(this.group);
  43663. }
  43664. this.graph.attr({
  43665. d: SVGRenderer.prototype.symbols.arc(centerX, centerY, this.center[2] / 2, 0, {
  43666. start: start,
  43667. end: end,
  43668. innerR: this.center[3] / 2
  43669. })
  43670. });
  43671. if (!this.chart.styledMode) {
  43672. this.graph.attr({
  43673. 'stroke-width': options.borderWidth,
  43674. fill: options.fillColor || 'none',
  43675. stroke: options.color || palette.neutralColor20
  43676. });
  43677. }
  43678. }
  43679. else if (this.graph) { // Destroy the graph object.
  43680. this.graph = this.graph.destroy();
  43681. }
  43682. };
  43683. /**
  43684. * Slices in pie chart are initialized in DOM, but it's shapes and
  43685. * animations are normally run in `drawPoints()`.
  43686. * @private
  43687. */
  43688. PieSeries.prototype.drawPoints = function () {
  43689. var renderer = this.chart.renderer;
  43690. this.points.forEach(function (point) {
  43691. // When updating a series between 2d and 3d or cartesian and
  43692. // polar, the shape type changes.
  43693. if (point.graphic && point.hasNewShapeType()) {
  43694. point.graphic = point.graphic.destroy();
  43695. }
  43696. if (!point.graphic) {
  43697. point.graphic = renderer[point.shapeType](point.shapeArgs)
  43698. .add(point.series.group);
  43699. point.delayedRendering = true;
  43700. }
  43701. });
  43702. };
  43703. /**
  43704. * Extend the generatePoints method by adding total and percentage
  43705. * properties to each point
  43706. * @private
  43707. */
  43708. PieSeries.prototype.generatePoints = function () {
  43709. _super.prototype.generatePoints.call(this);
  43710. this.updateTotals();
  43711. };
  43712. /**
  43713. * Utility for getting the x value from a given y, used for
  43714. * anticollision logic in data labels. Added point for using specific
  43715. * points' label distance.
  43716. * @private
  43717. */
  43718. PieSeries.prototype.getX = function (y, left, point) {
  43719. var center = this.center,
  43720. // Variable pie has individual radius
  43721. radius = this.radii ?
  43722. this.radii[point.index] || 0 :
  43723. center[2] / 2,
  43724. angle,
  43725. x;
  43726. angle = Math.asin(clamp((y - center[1]) / (radius + point.labelDistance), -1, 1));
  43727. x = center[0] +
  43728. (left ? -1 : 1) *
  43729. (Math.cos(angle) * (radius + point.labelDistance)) +
  43730. (point.labelDistance > 0 ?
  43731. (left ? -1 : 1) * this.options.dataLabels.padding :
  43732. 0);
  43733. return x;
  43734. };
  43735. /**
  43736. * Define hasData function for non-cartesian series. Returns true if the
  43737. * series has points at all.
  43738. * @private
  43739. */
  43740. PieSeries.prototype.hasData = function () {
  43741. return !!this.processedXData.length; // != 0
  43742. };
  43743. /**
  43744. * Draw the data points
  43745. * @private
  43746. */
  43747. PieSeries.prototype.redrawPoints = function () {
  43748. var series = this,
  43749. chart = series.chart,
  43750. renderer = chart.renderer,
  43751. groupTranslation,
  43752. graphic,
  43753. pointAttr,
  43754. shapeArgs,
  43755. shadow = series.options.shadow;
  43756. this.drawEmpty();
  43757. if (shadow && !series.shadowGroup && !chart.styledMode) {
  43758. series.shadowGroup = renderer
  43759. .g('shadow')
  43760. .attr({ zIndex: -1 })
  43761. .add(series.group);
  43762. }
  43763. // draw the slices
  43764. series.points.forEach(function (point) {
  43765. var animateTo = {};
  43766. graphic = point.graphic;
  43767. if (!point.isNull && graphic) {
  43768. var shadowGroup = void 0;
  43769. shapeArgs = point.shapeArgs;
  43770. // If the point is sliced, use special translation, else use
  43771. // plot area translation
  43772. groupTranslation = point.getTranslate();
  43773. if (!chart.styledMode) {
  43774. // Put the shadow behind all points
  43775. shadowGroup = point.shadowGroup;
  43776. if (shadow && !shadowGroup) {
  43777. shadowGroup = point.shadowGroup = renderer
  43778. .g('shadow')
  43779. .add(series.shadowGroup);
  43780. }
  43781. if (shadowGroup) {
  43782. shadowGroup.attr(groupTranslation);
  43783. }
  43784. pointAttr = series.pointAttribs(point, (point.selected && 'select'));
  43785. }
  43786. // Draw the slice
  43787. if (!point.delayedRendering) {
  43788. graphic
  43789. .setRadialReference(series.center);
  43790. if (!chart.styledMode) {
  43791. merge(true, animateTo, pointAttr);
  43792. }
  43793. merge(true, animateTo, shapeArgs, groupTranslation);
  43794. graphic.animate(animateTo);
  43795. }
  43796. else {
  43797. graphic
  43798. .setRadialReference(series.center)
  43799. .attr(shapeArgs)
  43800. .attr(groupTranslation);
  43801. if (!chart.styledMode) {
  43802. graphic
  43803. .attr(pointAttr)
  43804. .attr({ 'stroke-linejoin': 'round' })
  43805. .shadow(shadow, shadowGroup);
  43806. }
  43807. point.delayedRendering = false;
  43808. }
  43809. graphic.attr({
  43810. visibility: point.visible ? 'inherit' : 'hidden'
  43811. });
  43812. graphic.addClass(point.getClassName(), true);
  43813. }
  43814. else if (graphic) {
  43815. point.graphic = graphic.destroy();
  43816. }
  43817. });
  43818. };
  43819. /**
  43820. * Utility for sorting data labels.
  43821. * @private
  43822. */
  43823. PieSeries.prototype.sortByAngle = function (points, sign) {
  43824. points.sort(function (a, b) {
  43825. return ((typeof a.angle !== 'undefined') &&
  43826. (b.angle - a.angle) * sign);
  43827. });
  43828. };
  43829. /**
  43830. * Do translation for pie slices
  43831. * @private
  43832. */
  43833. PieSeries.prototype.translate = function (positions) {
  43834. this.generatePoints();
  43835. var series = this,
  43836. cumulative = 0,
  43837. precision = 1000, // issue #172
  43838. options = series.options,
  43839. slicedOffset = options.slicedOffset,
  43840. connectorOffset = slicedOffset + (options.borderWidth || 0),
  43841. finalConnectorOffset,
  43842. start,
  43843. end,
  43844. angle,
  43845. radians = getStartAndEndRadians(options.startAngle,
  43846. options.endAngle),
  43847. startAngleRad = series.startAngleRad = radians.start,
  43848. endAngleRad = series.endAngleRad = radians.end,
  43849. circ = endAngleRad - startAngleRad, // 2 * Math.PI,
  43850. points = series.points,
  43851. // the x component of the radius vector for a given point
  43852. radiusX,
  43853. radiusY,
  43854. labelDistance = options.dataLabels.distance,
  43855. ignoreHiddenPoint = options.ignoreHiddenPoint,
  43856. i,
  43857. len = points.length,
  43858. point;
  43859. // Get positions - either an integer or a percentage string must be
  43860. // given. If positions are passed as a parameter, we're in a
  43861. // recursive loop for adjusting space for data labels.
  43862. if (!positions) {
  43863. series.center = positions = series.getCenter();
  43864. }
  43865. // Calculate the geometry for each point
  43866. for (i = 0; i < len; i++) {
  43867. point = points[i];
  43868. // set start and end angle
  43869. start = startAngleRad + (cumulative * circ);
  43870. if (point.isValid() &&
  43871. (!ignoreHiddenPoint || point.visible)) {
  43872. cumulative += point.percentage / 100;
  43873. }
  43874. end = startAngleRad + (cumulative * circ);
  43875. // set the shape
  43876. var shapeArgs = {
  43877. x: positions[0],
  43878. y: positions[1],
  43879. r: positions[2] / 2,
  43880. innerR: positions[3] / 2,
  43881. start: Math.round(start * precision) / precision,
  43882. end: Math.round(end * precision) / precision
  43883. };
  43884. point.shapeType = 'arc';
  43885. point.shapeArgs = shapeArgs;
  43886. // Used for distance calculation for specific point.
  43887. point.labelDistance = pick((point.options.dataLabels &&
  43888. point.options.dataLabels.distance), labelDistance);
  43889. // Compute point.labelDistance if it's defined as percentage
  43890. // of slice radius (#8854)
  43891. point.labelDistance = relativeLength(point.labelDistance, shapeArgs.r);
  43892. // Saved for later dataLabels distance calculation.
  43893. series.maxLabelDistance = Math.max(series.maxLabelDistance || 0, point.labelDistance);
  43894. // The angle must stay within -90 and 270 (#2645)
  43895. angle = (end + start) / 2;
  43896. if (angle > 1.5 * Math.PI) {
  43897. angle -= 2 * Math.PI;
  43898. }
  43899. else if (angle < -Math.PI / 2) {
  43900. angle += 2 * Math.PI;
  43901. }
  43902. // Center for the sliced out slice
  43903. point.slicedTranslation = {
  43904. translateX: Math.round(Math.cos(angle) * slicedOffset),
  43905. translateY: Math.round(Math.sin(angle) * slicedOffset)
  43906. };
  43907. // set the anchor point for tooltips
  43908. radiusX = Math.cos(angle) * positions[2] / 2;
  43909. radiusY = Math.sin(angle) * positions[2] / 2;
  43910. point.tooltipPos = [
  43911. positions[0] + radiusX * 0.7,
  43912. positions[1] + radiusY * 0.7
  43913. ];
  43914. point.half = angle < -Math.PI / 2 || angle > Math.PI / 2 ?
  43915. 1 :
  43916. 0;
  43917. point.angle = angle;
  43918. // Set the anchor point for data labels. Use point.labelDistance
  43919. // instead of labelDistance // #1174
  43920. // finalConnectorOffset - not override connectorOffset value.
  43921. finalConnectorOffset = Math.min(connectorOffset, point.labelDistance / 5); // #1678
  43922. point.labelPosition = {
  43923. natural: {
  43924. // initial position of the data label - it's utilized for
  43925. // finding the final position for the label
  43926. x: positions[0] + radiusX + Math.cos(angle) *
  43927. point.labelDistance,
  43928. y: positions[1] + radiusY + Math.sin(angle) *
  43929. point.labelDistance
  43930. },
  43931. 'final': {
  43932. // used for generating connector path -
  43933. // initialized later in drawDataLabels function
  43934. // x: undefined,
  43935. // y: undefined
  43936. },
  43937. // left - pie on the left side of the data label
  43938. // right - pie on the right side of the data label
  43939. // center - data label overlaps the pie
  43940. alignment: point.labelDistance < 0 ?
  43941. 'center' : point.half ? 'right' : 'left',
  43942. connectorPosition: {
  43943. breakAt: {
  43944. x: positions[0] + radiusX + Math.cos(angle) *
  43945. finalConnectorOffset,
  43946. y: positions[1] + radiusY + Math.sin(angle) *
  43947. finalConnectorOffset
  43948. },
  43949. touchingSliceAt: {
  43950. x: positions[0] + radiusX,
  43951. y: positions[1] + radiusY
  43952. }
  43953. }
  43954. };
  43955. }
  43956. fireEvent(series, 'afterTranslate');
  43957. };
  43958. /**
  43959. * Recompute total chart sum and update percentages of points.
  43960. * @private
  43961. */
  43962. PieSeries.prototype.updateTotals = function () {
  43963. var i,
  43964. total = 0,
  43965. points = this.points,
  43966. len = points.length,
  43967. point,
  43968. ignoreHiddenPoint = this.options.ignoreHiddenPoint;
  43969. // Get the total sum
  43970. for (i = 0; i < len; i++) {
  43971. point = points[i];
  43972. if (point.isValid() &&
  43973. (!ignoreHiddenPoint || point.visible)) {
  43974. total += point.y;
  43975. }
  43976. }
  43977. this.total = total;
  43978. // Set each point's properties
  43979. for (i = 0; i < len; i++) {
  43980. point = points[i];
  43981. point.percentage =
  43982. (total > 0 && (point.visible || !ignoreHiddenPoint)) ?
  43983. point.y / total * 100 :
  43984. 0;
  43985. point.total = total;
  43986. }
  43987. };
  43988. /**
  43989. * A pie chart is a circular graphic which is divided into slices to
  43990. * illustrate numerical proportion.
  43991. *
  43992. * @sample highcharts/demo/pie-basic/
  43993. * Pie chart
  43994. *
  43995. * @extends plotOptions.line
  43996. * @excluding animationLimit, boostThreshold, connectEnds, connectNulls,
  43997. * cropThreshold, dashStyle, dataSorting, dragDrop,
  43998. * findNearestPointBy, getExtremesFromAll, label, lineWidth,
  43999. * marker, negativeColor, pointInterval, pointIntervalUnit,
  44000. * pointPlacement, pointStart, softThreshold, stacking, step,
  44001. * threshold, turboThreshold, zoneAxis, zones, dataSorting,
  44002. * boostBlending
  44003. * @product highcharts
  44004. * @optionparent plotOptions.pie
  44005. */
  44006. PieSeries.defaultOptions = merge(Series.defaultOptions, {
  44007. /**
  44008. * @excluding legendItemClick
  44009. * @apioption plotOptions.pie.events
  44010. */
  44011. /**
  44012. * Fires when the checkbox next to the point name in the legend is
  44013. * clicked. One parameter, event, is passed to the function. The state
  44014. * of the checkbox is found by event.checked. The checked item is found
  44015. * by event.item. Return false to prevent the default action which is to
  44016. * toggle the select state of the series.
  44017. *
  44018. * @sample {highcharts} highcharts/plotoptions/series-events-checkboxclick/
  44019. * Alert checkbox status
  44020. *
  44021. * @type {Function}
  44022. * @since 1.2.0
  44023. * @product highcharts
  44024. * @context Highcharts.Point
  44025. * @apioption plotOptions.pie.events.checkboxClick
  44026. */
  44027. /**
  44028. * Fires when the legend item belonging to the pie point (slice) is
  44029. * clicked. The `this` keyword refers to the point itself. One
  44030. * parameter, `event`, is passed to the function, containing common
  44031. * event information. The default action is to toggle the visibility of
  44032. * the point. This can be prevented by calling `event.preventDefault()`.
  44033. *
  44034. * @sample {highcharts} highcharts/plotoptions/pie-point-events-legenditemclick/
  44035. * Confirm toggle visibility
  44036. *
  44037. * @type {Highcharts.PointLegendItemClickCallbackFunction}
  44038. * @since 1.2.0
  44039. * @product highcharts
  44040. * @apioption plotOptions.pie.point.events.legendItemClick
  44041. */
  44042. /**
  44043. * The center of the pie chart relative to the plot area. Can be
  44044. * percentages or pixel values. The default behaviour (as of 3.0) is to
  44045. * center the pie so that all slices and data labels are within the plot
  44046. * area. As a consequence, the pie may actually jump around in a chart
  44047. * with dynamic values, as the data labels move. In that case, the
  44048. * center should be explicitly set, for example to `["50%", "50%"]`.
  44049. *
  44050. * @sample {highcharts} highcharts/plotoptions/pie-center/
  44051. * Centered at 100, 100
  44052. *
  44053. * @type {Array<(number|string|null),(number|string|null)>}
  44054. * @default [null, null]
  44055. * @product highcharts
  44056. *
  44057. * @private
  44058. */
  44059. center: [null, null],
  44060. /**
  44061. * The color of the pie series. A pie series is represented as an empty
  44062. * circle if the total sum of its values is 0. Use this property to
  44063. * define the color of its border.
  44064. *
  44065. * In styled mode, the color can be defined by the
  44066. * [colorIndex](#plotOptions.series.colorIndex) option. Also, the series
  44067. * color can be set with the `.highcharts-series`,
  44068. * `.highcharts-color-{n}`, `.highcharts-{type}-series` or
  44069. * `.highcharts-series-{n}` class, or individual classes given by the
  44070. * `className` option.
  44071. *
  44072. * @sample {highcharts} highcharts/plotoptions/pie-emptyseries/
  44073. * Empty pie series
  44074. *
  44075. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  44076. * @default ${palette.neutralColor20}
  44077. * @apioption plotOptions.pie.color
  44078. */
  44079. /**
  44080. * @product highcharts
  44081. *
  44082. * @private
  44083. */
  44084. clip: false,
  44085. /**
  44086. * @ignore-option
  44087. *
  44088. * @private
  44089. */
  44090. colorByPoint: true,
  44091. /**
  44092. * A series specific or series type specific color set to use instead
  44093. * of the global [colors](#colors).
  44094. *
  44095. * @sample {highcharts} highcharts/demo/pie-monochrome/
  44096. * Set default colors for all pies
  44097. *
  44098. * @type {Array<Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject>}
  44099. * @since 3.0
  44100. * @product highcharts
  44101. * @apioption plotOptions.pie.colors
  44102. */
  44103. /**
  44104. * @declare Highcharts.SeriesPieDataLabelsOptionsObject
  44105. * @extends plotOptions.series.dataLabels
  44106. * @excluding align, allowOverlap, inside, staggerLines, step
  44107. * @private
  44108. */
  44109. dataLabels: {
  44110. /**
  44111. * Alignment method for data labels. Possible values are:
  44112. *
  44113. * - `toPlotEdges`: Each label touches the nearest vertical edge of
  44114. * the plot area.
  44115. *
  44116. * - `connectors`: Connectors have the same x position and the
  44117. * widest label of each half (left & right) touches the nearest
  44118. * vertical edge of the plot area.
  44119. *
  44120. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-alignto-connectors/
  44121. * alignTo: connectors
  44122. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-alignto-plotedges/
  44123. * alignTo: plotEdges
  44124. *
  44125. * @type {string}
  44126. * @since 7.0.0
  44127. * @product highcharts
  44128. * @apioption plotOptions.pie.dataLabels.alignTo
  44129. */
  44130. allowOverlap: true,
  44131. /**
  44132. * The color of the line connecting the data label to the pie slice.
  44133. * The default color is the same as the point's color.
  44134. *
  44135. * In styled mode, the connector stroke is given in the
  44136. * `.highcharts-data-label-connector` class.
  44137. *
  44138. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorcolor/
  44139. * Blue connectors
  44140. * @sample {highcharts} highcharts/css/pie-point/
  44141. * Styled connectors
  44142. *
  44143. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  44144. * @since 2.1
  44145. * @product highcharts
  44146. * @apioption plotOptions.pie.dataLabels.connectorColor
  44147. */
  44148. /**
  44149. * The distance from the data label to the connector. Note that
  44150. * data labels also have a default `padding`, so in order for the
  44151. * connector to touch the text, the `padding` must also be 0.
  44152. *
  44153. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorpadding/
  44154. * No padding
  44155. *
  44156. * @since 2.1
  44157. * @product highcharts
  44158. */
  44159. connectorPadding: 5,
  44160. /**
  44161. * Specifies the method that is used to generate the connector path.
  44162. * Highcharts provides 3 built-in connector shapes: `'fixedOffset'`
  44163. * (default), `'straight'` and `'crookedLine'`. Using
  44164. * `'crookedLine'` has the most sense (in most of the cases) when
  44165. * `'alignTo'` is set.
  44166. *
  44167. * Users can provide their own method by passing a function instead
  44168. * of a String. 3 arguments are passed to the callback:
  44169. *
  44170. * - Object that holds the information about the coordinates of the
  44171. * label (`x` & `y` properties) and how the label is located in
  44172. * relation to the pie (`alignment` property). `alignment` can by
  44173. * one of the following:
  44174. * `'left'` (pie on the left side of the data label),
  44175. * `'right'` (pie on the right side of the data label) or
  44176. * `'center'` (data label overlaps the pie).
  44177. *
  44178. * - Object that holds the information about the position of the
  44179. * connector. Its `touchingSliceAt` porperty tells the position
  44180. * of the place where the connector touches the slice.
  44181. *
  44182. * - Data label options
  44183. *
  44184. * The function has to return an SVG path definition in array form
  44185. * (see the example).
  44186. *
  44187. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorshape-string/
  44188. * connectorShape is a String
  44189. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorshape-function/
  44190. * connectorShape is a function
  44191. *
  44192. * @type {string|Function}
  44193. * @since 7.0.0
  44194. * @product highcharts
  44195. */
  44196. connectorShape: 'fixedOffset',
  44197. /**
  44198. * The width of the line connecting the data label to the pie slice.
  44199. *
  44200. * In styled mode, the connector stroke width is given in the
  44201. * `.highcharts-data-label-connector` class.
  44202. *
  44203. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorwidth-disabled/
  44204. * Disable the connector
  44205. * @sample {highcharts} highcharts/css/pie-point/
  44206. * Styled connectors
  44207. *
  44208. * @type {number}
  44209. * @default 1
  44210. * @since 2.1
  44211. * @product highcharts
  44212. * @apioption plotOptions.pie.dataLabels.connectorWidth
  44213. */
  44214. /**
  44215. * Works only if `connectorShape` is `'crookedLine'`. It defines how
  44216. * far from the vertical plot edge the coonnector path should be
  44217. * crooked.
  44218. *
  44219. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-crookdistance/
  44220. * crookDistance set to 90%
  44221. *
  44222. * @since 7.0.0
  44223. * @product highcharts
  44224. */
  44225. crookDistance: '70%',
  44226. /**
  44227. * The distance of the data label from the pie's edge. Negative
  44228. * numbers put the data label on top of the pie slices. Can also be
  44229. * defined as a percentage of pie's radius. Connectors are only
  44230. * shown for data labels outside the pie.
  44231. *
  44232. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-distance/
  44233. * Data labels on top of the pie
  44234. *
  44235. * @type {number|string}
  44236. * @since 2.1
  44237. * @product highcharts
  44238. */
  44239. distance: 30,
  44240. enabled: true,
  44241. /**
  44242. * A
  44243. * [format string](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting)
  44244. * for the data label. Available variables are the same as for
  44245. * `formatter`.
  44246. *
  44247. * @sample {highcharts} highcharts/plotoptions/series-datalabels-format/
  44248. * Add a unit
  44249. *
  44250. * @type {string}
  44251. * @default undefined
  44252. * @since 3.0
  44253. * @apioption plotOptions.pie.dataLabels.format
  44254. */
  44255. // eslint-disable-next-line valid-jsdoc
  44256. /**
  44257. * Callback JavaScript function to format the data label. Note that
  44258. * if a `format` is defined, the format takes precedence and the
  44259. * formatter is ignored.
  44260. *
  44261. * @type {Highcharts.DataLabelsFormatterCallbackFunction}
  44262. * @default function () { return this.point.isNull ? void 0 : this.point.name; }
  44263. */
  44264. formatter: function () {
  44265. return this.point.isNull ? void 0 : this.point.name;
  44266. },
  44267. /**
  44268. * Whether to render the connector as a soft arc or a line with
  44269. * sharp break. Works only if `connectorShape` equals to
  44270. * `fixedOffset`.
  44271. *
  44272. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-softconnector-true/
  44273. * Soft
  44274. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-softconnector-false/
  44275. * Non soft
  44276. *
  44277. * @since 2.1.7
  44278. * @product highcharts
  44279. */
  44280. softConnector: true,
  44281. /**
  44282. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-overflow
  44283. * Long labels truncated with an ellipsis
  44284. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-overflow-wrap
  44285. * Long labels are wrapped
  44286. *
  44287. * @type {Highcharts.CSSObject}
  44288. * @apioption plotOptions.pie.dataLabels.style
  44289. */
  44290. x: 0
  44291. },
  44292. /**
  44293. * If the total sum of the pie's values is 0, the series is represented
  44294. * as an empty circle . The `fillColor` option defines the color of that
  44295. * circle. Use [pie.borderWidth](#plotOptions.pie.borderWidth) to set
  44296. * the border thickness.
  44297. *
  44298. * @sample {highcharts} highcharts/plotoptions/pie-emptyseries/
  44299. * Empty pie series
  44300. *
  44301. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  44302. * @private
  44303. */
  44304. fillColor: void 0,
  44305. /**
  44306. * The end angle of the pie in degrees where 0 is top and 90 is right.
  44307. * Defaults to `startAngle` plus 360.
  44308. *
  44309. * @sample {highcharts} highcharts/demo/pie-semi-circle/
  44310. * Semi-circle donut
  44311. *
  44312. * @type {number}
  44313. * @since 1.3.6
  44314. * @product highcharts
  44315. * @apioption plotOptions.pie.endAngle
  44316. */
  44317. /**
  44318. * Equivalent to [chart.ignoreHiddenSeries](#chart.ignoreHiddenSeries),
  44319. * this option tells whether the series shall be redrawn as if the
  44320. * hidden point were `null`.
  44321. *
  44322. * The default value changed from `false` to `true` with Highcharts
  44323. * 3.0.
  44324. *
  44325. * @sample {highcharts} highcharts/plotoptions/pie-ignorehiddenpoint/
  44326. * True, the hiddden point is ignored
  44327. *
  44328. * @since 2.3.0
  44329. * @product highcharts
  44330. *
  44331. * @private
  44332. */
  44333. ignoreHiddenPoint: true,
  44334. /**
  44335. * @ignore-option
  44336. *
  44337. * @private
  44338. */
  44339. inactiveOtherPoints: true,
  44340. /**
  44341. * The size of the inner diameter for the pie. A size greater than 0
  44342. * renders a donut chart. Can be a percentage or pixel value.
  44343. * Percentages are relative to the pie size. Pixel values are given as
  44344. * integers.
  44345. *
  44346. *
  44347. * Note: in Highcharts < 4.1.2, the percentage was relative to the plot
  44348. * area, not the pie size.
  44349. *
  44350. * @sample {highcharts} highcharts/plotoptions/pie-innersize-80px/
  44351. * 80px inner size
  44352. * @sample {highcharts} highcharts/plotoptions/pie-innersize-50percent/
  44353. * 50% of the plot area
  44354. * @sample {highcharts} highcharts/demo/3d-pie-donut/
  44355. * 3D donut
  44356. *
  44357. * @type {number|string}
  44358. * @default 0
  44359. * @since 2.0
  44360. * @product highcharts
  44361. * @apioption plotOptions.pie.innerSize
  44362. */
  44363. /**
  44364. * @ignore-option
  44365. *
  44366. * @private
  44367. */
  44368. legendType: 'point',
  44369. /**
  44370. * @ignore-option
  44371. *
  44372. * @private
  44373. */
  44374. marker: null,
  44375. /**
  44376. * The minimum size for a pie in response to auto margins. The pie will
  44377. * try to shrink to make room for data labels in side the plot area,
  44378. * but only to this size.
  44379. *
  44380. * @type {number|string}
  44381. * @default 80
  44382. * @since 3.0
  44383. * @product highcharts
  44384. * @apioption plotOptions.pie.minSize
  44385. */
  44386. /**
  44387. * The diameter of the pie relative to the plot area. Can be a
  44388. * percentage or pixel value. Pixel values are given as integers. The
  44389. * default behaviour (as of 3.0) is to scale to the plot area and give
  44390. * room for data labels within the plot area.
  44391. * [slicedOffset](#plotOptions.pie.slicedOffset) is also included in the
  44392. * default size calculation. As a consequence, the size of the pie may
  44393. * vary when points are updated and data labels more around. In that
  44394. * case it is best to set a fixed value, for example `"75%"`.
  44395. *
  44396. * @sample {highcharts} highcharts/plotoptions/pie-size/
  44397. * Smaller pie
  44398. *
  44399. * @type {number|string|null}
  44400. * @product highcharts
  44401. *
  44402. * @private
  44403. */
  44404. size: null,
  44405. /**
  44406. * Whether to display this particular series or series type in the
  44407. * legend. Since 2.1, pies are not shown in the legend by default.
  44408. *
  44409. * @sample {highcharts} highcharts/plotoptions/series-showinlegend/
  44410. * One series in the legend, one hidden
  44411. *
  44412. * @product highcharts
  44413. *
  44414. * @private
  44415. */
  44416. showInLegend: false,
  44417. /**
  44418. * If a point is sliced, moved out from the center, how many pixels
  44419. * should it be moved?.
  44420. *
  44421. * @sample {highcharts} highcharts/plotoptions/pie-slicedoffset-20/
  44422. * 20px offset
  44423. *
  44424. * @product highcharts
  44425. *
  44426. * @private
  44427. */
  44428. slicedOffset: 10,
  44429. /**
  44430. * The start angle of the pie slices in degrees where 0 is top and 90
  44431. * right.
  44432. *
  44433. * @sample {highcharts} highcharts/plotoptions/pie-startangle-90/
  44434. * Start from right
  44435. *
  44436. * @type {number}
  44437. * @default 0
  44438. * @since 2.3.4
  44439. * @product highcharts
  44440. * @apioption plotOptions.pie.startAngle
  44441. */
  44442. /**
  44443. * Sticky tracking of mouse events. When true, the `mouseOut` event
  44444. * on a series isn't triggered until the mouse moves over another
  44445. * series, or out of the plot area. When false, the `mouseOut` event on
  44446. * a series is triggered when the mouse leaves the area around the
  44447. * series' graph or markers. This also implies the tooltip. When
  44448. * `stickyTracking` is false and `tooltip.shared` is false, the tooltip
  44449. * will be hidden when moving the mouse between series.
  44450. *
  44451. * @product highcharts
  44452. *
  44453. * @private
  44454. */
  44455. stickyTracking: false,
  44456. tooltip: {
  44457. followPointer: true
  44458. },
  44459. /**
  44460. * The color of the border surrounding each slice. When `null`, the
  44461. * border takes the same color as the slice fill. This can be used
  44462. * together with a `borderWidth` to fill drawing gaps created by
  44463. * antialiazing artefacts in borderless pies.
  44464. *
  44465. * In styled mode, the border stroke is given in the `.highcharts-point`
  44466. * class.
  44467. *
  44468. * @sample {highcharts} highcharts/plotoptions/pie-bordercolor-black/
  44469. * Black border
  44470. *
  44471. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  44472. * @default #ffffff
  44473. * @product highcharts
  44474. *
  44475. * @private
  44476. */
  44477. borderColor: palette.backgroundColor,
  44478. /**
  44479. * The width of the border surrounding each slice.
  44480. *
  44481. * When setting the border width to 0, there may be small gaps between
  44482. * the slices due to SVG antialiasing artefacts. To work around this,
  44483. * keep the border width at 0.5 or 1, but set the `borderColor` to
  44484. * `null` instead.
  44485. *
  44486. * In styled mode, the border stroke width is given in the
  44487. * `.highcharts-point` class.
  44488. *
  44489. * @sample {highcharts} highcharts/plotoptions/pie-borderwidth/
  44490. * 3px border
  44491. *
  44492. * @product highcharts
  44493. *
  44494. * @private
  44495. */
  44496. borderWidth: 1,
  44497. /**
  44498. * @ignore-options
  44499. * @private
  44500. */
  44501. lineWidth: void 0,
  44502. states: {
  44503. /**
  44504. * @extends plotOptions.series.states.hover
  44505. * @excluding marker, lineWidth, lineWidthPlus
  44506. * @product highcharts
  44507. */
  44508. hover: {
  44509. /**
  44510. * How much to brighten the point on interaction. Requires the
  44511. * main color to be defined in hex or rgb(a) format.
  44512. *
  44513. * In styled mode, the hover brightness is by default replaced
  44514. * by a fill-opacity given in the `.highcharts-point-hover`
  44515. * class.
  44516. *
  44517. * @sample {highcharts} highcharts/plotoptions/pie-states-hover-brightness/
  44518. * Brightened by 0.5
  44519. *
  44520. * @product highcharts
  44521. */
  44522. brightness: 0.1
  44523. }
  44524. }
  44525. });
  44526. return PieSeries;
  44527. }(Series));
  44528. extend(PieSeries.prototype, {
  44529. axisTypes: [],
  44530. directTouch: true,
  44531. drawGraph: void 0,
  44532. drawLegendSymbol: LegendSymbolMixin.drawRectangle,
  44533. drawTracker: ColumnSeries.prototype.drawTracker,
  44534. getCenter: CenteredSeriesMixin.getCenter,
  44535. getSymbol: noop,
  44536. isCartesian: false,
  44537. noSharedTooltip: true,
  44538. pointAttribs: ColumnSeries.prototype.pointAttribs,
  44539. pointClass: PiePoint,
  44540. requireSorting: false,
  44541. searchPoint: noop,
  44542. trackerGroups: ['group', 'dataLabelsGroup']
  44543. });
  44544. SeriesRegistry.registerSeriesType('pie', PieSeries);
  44545. /* *
  44546. *
  44547. * Default Export
  44548. *
  44549. * */
  44550. /* *
  44551. *
  44552. * API Options
  44553. *
  44554. * */
  44555. /**
  44556. * A `pie` series. If the [type](#series.pie.type) option is not specified,
  44557. * it is inherited from [chart.type](#chart.type).
  44558. *
  44559. * @extends series,plotOptions.pie
  44560. * @excluding cropThreshold, dataParser, dataURL, stack, xAxis, yAxis,
  44561. * dataSorting, step, boostThreshold, boostBlending
  44562. * @product highcharts
  44563. * @apioption series.pie
  44564. */
  44565. /**
  44566. * An array of data points for the series. For the `pie` series type,
  44567. * points can be given in the following ways:
  44568. *
  44569. * 1. An array of numerical values. In this case, the numerical values will be
  44570. * interpreted as `y` options. Example:
  44571. * ```js
  44572. * data: [0, 5, 3, 5]
  44573. * ```
  44574. *
  44575. * 2. An array of objects with named values. The following snippet shows only a
  44576. * few settings, see the complete options set below. If the total number of
  44577. * data points exceeds the series'
  44578. * [turboThreshold](#series.pie.turboThreshold),
  44579. * this option is not available.
  44580. * ```js
  44581. * data: [{
  44582. * y: 1,
  44583. * name: "Point2",
  44584. * color: "#00FF00"
  44585. * }, {
  44586. * y: 7,
  44587. * name: "Point1",
  44588. * color: "#FF00FF"
  44589. * }]
  44590. * ```
  44591. *
  44592. * @sample {highcharts} highcharts/chart/reflow-true/
  44593. * Numerical values
  44594. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  44595. * Arrays of numeric x and y
  44596. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  44597. * Arrays of datetime x and y
  44598. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  44599. * Arrays of point.name and y
  44600. * @sample {highcharts} highcharts/series/data-array-of-objects/
  44601. * Config objects
  44602. *
  44603. * @type {Array<number|Array<string,(number|null)>|null|*>}
  44604. * @extends series.line.data
  44605. * @excluding marker, x
  44606. * @product highcharts
  44607. * @apioption series.pie.data
  44608. */
  44609. /**
  44610. * @type {Highcharts.SeriesPieDataLabelsOptionsObject}
  44611. * @product highcharts
  44612. * @apioption series.pie.data.dataLabels
  44613. */
  44614. /**
  44615. * The sequential index of the data point in the legend.
  44616. *
  44617. * @type {number}
  44618. * @product highcharts
  44619. * @apioption series.pie.data.legendIndex
  44620. */
  44621. /**
  44622. * Whether to display a slice offset from the center.
  44623. *
  44624. * @sample {highcharts} highcharts/point/sliced/
  44625. * One sliced point
  44626. *
  44627. * @type {boolean}
  44628. * @product highcharts
  44629. * @apioption series.pie.data.sliced
  44630. */
  44631. /**
  44632. * @extends plotOptions.pie.dataLabels
  44633. * @excluding align, allowOverlap, inside, staggerLines, step
  44634. * @product highcharts
  44635. * @apioption series.pie.dataLabels
  44636. */
  44637. /**
  44638. * @excluding legendItemClick
  44639. * @product highcharts
  44640. * @apioption series.pie.events
  44641. */
  44642. ''; // placeholder for transpiled doclets above
  44643. return PieSeries;
  44644. });
  44645. _registerModule(_modules, 'Core/Series/DataLabels.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/FormatUtilities.js'], _modules['Core/Globals.js'], _modules['Core/Color/Palette.js'], _modules['Core/Series/Series.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (A, F, H, palette, Series, SeriesRegistry, U) {
  44646. /* *
  44647. *
  44648. * (c) 2010-2021 Torstein Honsi
  44649. *
  44650. * License: www.highcharts.com/license
  44651. *
  44652. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  44653. *
  44654. * */
  44655. var getDeferredAnimation = A.getDeferredAnimation;
  44656. var format = F.format;
  44657. var noop = H.noop;
  44658. var seriesTypes = SeriesRegistry.seriesTypes;
  44659. var arrayMax = U.arrayMax,
  44660. clamp = U.clamp,
  44661. defined = U.defined,
  44662. extend = U.extend,
  44663. fireEvent = U.fireEvent,
  44664. isArray = U.isArray,
  44665. merge = U.merge,
  44666. objectEach = U.objectEach,
  44667. pick = U.pick,
  44668. relativeLength = U.relativeLength,
  44669. splat = U.splat,
  44670. stableSort = U.stableSort;
  44671. /**
  44672. * Callback JavaScript function to format the data label as a string. Note that
  44673. * if a `format` is defined, the format takes precedence and the formatter is
  44674. * ignored.
  44675. *
  44676. * @callback Highcharts.DataLabelsFormatterCallbackFunction
  44677. *
  44678. * @param {Highcharts.PointLabelObject} this
  44679. * Data label context to format
  44680. *
  44681. * @param {Highcharts.DataLabelsOptions} options
  44682. * [API options](/highcharts/plotOptions.series.dataLabels) of the data label
  44683. *
  44684. * @return {number|string|null|undefined}
  44685. * Formatted data label text
  44686. */
  44687. /**
  44688. * Values for handling data labels that flow outside the plot area.
  44689. *
  44690. * @typedef {"allow"|"justify"} Highcharts.DataLabelsOverflowValue
  44691. */
  44692. ''; // detach doclets above
  44693. /* eslint-disable valid-jsdoc */
  44694. /**
  44695. * General distribution algorithm for distributing labels of differing size
  44696. * along a confined length in two dimensions. The algorithm takes an array of
  44697. * objects containing a size, a target and a rank. It will place the labels as
  44698. * close as possible to their targets, skipping the lowest ranked labels if
  44699. * necessary.
  44700. *
  44701. * @private
  44702. * @function Highcharts.distribute
  44703. * @param {Highcharts.DataLabelsBoxArray} boxes
  44704. * @param {number} len
  44705. * @param {number} [maxDistance]
  44706. * @return {void}
  44707. */
  44708. H.distribute = function (boxes, len, maxDistance) {
  44709. var i,
  44710. overlapping = true,
  44711. origBoxes = boxes, // Original array will be altered with added .pos
  44712. restBoxes = [], // The outranked overshoot
  44713. box,
  44714. target,
  44715. total = 0,
  44716. reducedLen = origBoxes.reducedLen || len;
  44717. /**
  44718. * @private
  44719. */
  44720. function sortByTarget(a, b) {
  44721. return a.target - b.target;
  44722. }
  44723. // If the total size exceeds the len, remove those boxes with the lowest
  44724. // rank
  44725. i = boxes.length;
  44726. while (i--) {
  44727. total += boxes[i].size;
  44728. }
  44729. // Sort by rank, then slice away overshoot
  44730. if (total > reducedLen) {
  44731. stableSort(boxes, function (a, b) {
  44732. return (b.rank || 0) - (a.rank || 0);
  44733. });
  44734. i = 0;
  44735. total = 0;
  44736. while (total <= reducedLen) {
  44737. total += boxes[i].size;
  44738. i++;
  44739. }
  44740. restBoxes = boxes.splice(i - 1, boxes.length);
  44741. }
  44742. // Order by target
  44743. stableSort(boxes, sortByTarget);
  44744. // So far we have been mutating the original array. Now
  44745. // create a copy with target arrays
  44746. boxes = boxes.map(function (box) {
  44747. return {
  44748. size: box.size,
  44749. targets: [box.target],
  44750. align: pick(box.align, 0.5)
  44751. };
  44752. });
  44753. while (overlapping) {
  44754. // Initial positions: target centered in box
  44755. i = boxes.length;
  44756. while (i--) {
  44757. box = boxes[i];
  44758. // Composite box, average of targets
  44759. target = (Math.min.apply(0, box.targets) +
  44760. Math.max.apply(0, box.targets)) / 2;
  44761. box.pos = clamp(target - box.size * box.align, 0, len - box.size);
  44762. }
  44763. // Detect overlap and join boxes
  44764. i = boxes.length;
  44765. overlapping = false;
  44766. while (i--) {
  44767. // Overlap
  44768. if (i > 0 &&
  44769. boxes[i - 1].pos + boxes[i - 1].size >
  44770. boxes[i].pos) {
  44771. // Add this size to the previous box
  44772. boxes[i - 1].size += boxes[i].size;
  44773. boxes[i - 1].targets = boxes[i - 1]
  44774. .targets
  44775. .concat(boxes[i].targets);
  44776. boxes[i - 1].align = 0.5;
  44777. // Overlapping right, push left
  44778. if (boxes[i - 1].pos + boxes[i - 1].size > len) {
  44779. boxes[i - 1].pos = len - boxes[i - 1].size;
  44780. }
  44781. boxes.splice(i, 1); // Remove this item
  44782. overlapping = true;
  44783. }
  44784. }
  44785. }
  44786. // Add the rest (hidden boxes)
  44787. origBoxes.push.apply(origBoxes, restBoxes);
  44788. // Now the composite boxes are placed, we need to put the original boxes
  44789. // within them
  44790. i = 0;
  44791. boxes.some(function (box) {
  44792. var posInCompositeBox = 0;
  44793. if (box.targets.some(function () {
  44794. origBoxes[i].pos = box.pos + posInCompositeBox;
  44795. // If the distance between the position and the target exceeds
  44796. // maxDistance, abort the loop and decrease the length in increments
  44797. // of 10% to recursively reduce the number of visible boxes by
  44798. // rank. Once all boxes are within the maxDistance, we're good.
  44799. if (typeof maxDistance !== 'undefined' &&
  44800. Math.abs(origBoxes[i].pos - origBoxes[i].target) > maxDistance) {
  44801. // Reset the positions that are already set
  44802. origBoxes.slice(0, i + 1).forEach(function (box) {
  44803. delete box.pos;
  44804. });
  44805. // Try with a smaller length
  44806. origBoxes.reducedLen =
  44807. (origBoxes.reducedLen || len) - (len * 0.1);
  44808. // Recurse
  44809. if (origBoxes.reducedLen > len * 0.1) {
  44810. H.distribute(origBoxes, len, maxDistance);
  44811. }
  44812. // Exceeded maxDistance => abort
  44813. return true;
  44814. }
  44815. posInCompositeBox += origBoxes[i].size;
  44816. i++;
  44817. })) {
  44818. // Exceeded maxDistance => abort
  44819. return true;
  44820. }
  44821. });
  44822. // Add the rest (hidden) boxes and sort by target
  44823. stableSort(origBoxes, sortByTarget);
  44824. };
  44825. /**
  44826. * Draw the data labels
  44827. *
  44828. * @private
  44829. * @function Highcharts.Series#drawDataLabels
  44830. * @return {void}
  44831. * @fires Highcharts.Series#event:afterDrawDataLabels
  44832. */
  44833. Series.prototype.drawDataLabels = function () {
  44834. var series = this,
  44835. chart = series.chart,
  44836. seriesOptions = series.options,
  44837. seriesDlOptions = seriesOptions.dataLabels,
  44838. points = series.points,
  44839. pointOptions,
  44840. hasRendered = series.hasRendered || 0,
  44841. dataLabelsGroup,
  44842. dataLabelAnim = seriesDlOptions.animation,
  44843. animationConfig = seriesDlOptions.defer ?
  44844. getDeferredAnimation(chart,
  44845. dataLabelAnim,
  44846. series) :
  44847. { defer: 0,
  44848. duration: 0 },
  44849. renderer = chart.renderer;
  44850. /**
  44851. * Handle the dataLabels.filter option.
  44852. * @private
  44853. */
  44854. function applyFilter(point, options) {
  44855. var filter = options.filter,
  44856. op,
  44857. prop,
  44858. val;
  44859. if (filter) {
  44860. op = filter.operator;
  44861. prop = point[filter.property];
  44862. val = filter.value;
  44863. if ((op === '>' && prop > val) ||
  44864. (op === '<' && prop < val) ||
  44865. (op === '>=' && prop >= val) ||
  44866. (op === '<=' && prop <= val) ||
  44867. (op === '==' && prop == val) || // eslint-disable-line eqeqeq
  44868. (op === '===' && prop === val)) {
  44869. return true;
  44870. }
  44871. return false;
  44872. }
  44873. return true;
  44874. }
  44875. /**
  44876. * Merge two objects that can be arrays. If one of them is an array, the
  44877. * other is merged into each element. If both are arrays, each element is
  44878. * merged by index. If neither are arrays, we use normal merge.
  44879. * @private
  44880. */
  44881. function mergeArrays(one, two) {
  44882. var res = [],
  44883. i;
  44884. if (isArray(one) && !isArray(two)) {
  44885. res = one.map(function (el) {
  44886. return merge(el, two);
  44887. });
  44888. }
  44889. else if (isArray(two) && !isArray(one)) {
  44890. res = two.map(function (el) {
  44891. return merge(one, el);
  44892. });
  44893. }
  44894. else if (!isArray(one) && !isArray(two)) {
  44895. res = merge(one, two);
  44896. }
  44897. else {
  44898. i = Math.max(one.length, two.length);
  44899. while (i--) {
  44900. res[i] = merge(one[i], two[i]);
  44901. }
  44902. }
  44903. return res;
  44904. }
  44905. // Merge in plotOptions.dataLabels for series
  44906. seriesDlOptions = mergeArrays(mergeArrays(chart.options.plotOptions &&
  44907. chart.options.plotOptions.series &&
  44908. chart.options.plotOptions.series.dataLabels, chart.options.plotOptions &&
  44909. chart.options.plotOptions[series.type] &&
  44910. chart.options.plotOptions[series.type].dataLabels), seriesDlOptions);
  44911. fireEvent(this, 'drawDataLabels');
  44912. if (isArray(seriesDlOptions) ||
  44913. seriesDlOptions.enabled ||
  44914. series._hasPointLabels) {
  44915. // Create a separate group for the data labels to avoid rotation
  44916. dataLabelsGroup = series.plotGroup('dataLabelsGroup', 'data-labels', !hasRendered ? 'hidden' : 'inherit', // #5133, #10220
  44917. seriesDlOptions.zIndex || 6);
  44918. dataLabelsGroup.attr({ opacity: +hasRendered }); // #3300
  44919. if (!hasRendered) {
  44920. var group = series.dataLabelsGroup;
  44921. if (group) {
  44922. if (series.visible) { // #2597, #3023, #3024
  44923. dataLabelsGroup.show(true);
  44924. }
  44925. group[seriesOptions.animation ? 'animate' : 'attr']({ opacity: 1 }, animationConfig);
  44926. }
  44927. }
  44928. // Make the labels for each point
  44929. points.forEach(function (point) {
  44930. // Merge in series options for the point.
  44931. // @note dataLabelAttribs (like pointAttribs) would eradicate
  44932. // the need for dlOptions, and simplify the section below.
  44933. pointOptions = splat(mergeArrays(seriesDlOptions, point.dlOptions || // dlOptions is used in treemaps
  44934. (point.options && point.options.dataLabels)));
  44935. // Handle each individual data label for this point
  44936. pointOptions.forEach(function (labelOptions, i) {
  44937. // Options for one datalabel
  44938. var labelEnabled = (labelOptions.enabled &&
  44939. // #2282, #4641, #7112, #10049
  44940. (!point.isNull || point.dataLabelOnNull) &&
  44941. applyFilter(point,
  44942. labelOptions)),
  44943. labelConfig,
  44944. formatString,
  44945. labelText,
  44946. style,
  44947. rotation,
  44948. attr,
  44949. dataLabel = point.dataLabels ? point.dataLabels[i] :
  44950. point.dataLabel,
  44951. connector = point.connectors ? point.connectors[i] :
  44952. point.connector,
  44953. labelDistance = pick(labelOptions.distance,
  44954. point.labelDistance),
  44955. isNew = !dataLabel;
  44956. if (labelEnabled) {
  44957. // Create individual options structure that can be extended
  44958. // without affecting others
  44959. labelConfig = point.getLabelConfig();
  44960. formatString = pick(labelOptions[point.formatPrefix + 'Format'], labelOptions.format);
  44961. labelText = defined(formatString) ?
  44962. format(formatString, labelConfig, chart) :
  44963. (labelOptions[point.formatPrefix + 'Formatter'] ||
  44964. labelOptions.formatter).call(labelConfig, labelOptions);
  44965. style = labelOptions.style;
  44966. rotation = labelOptions.rotation;
  44967. if (!chart.styledMode) {
  44968. // Determine the color
  44969. style.color = pick(labelOptions.color, style.color, series.color, palette.neutralColor100);
  44970. // Get automated contrast color
  44971. if (style.color === 'contrast') {
  44972. point.contrastColor = renderer.getContrast((point.color || series.color));
  44973. style.color = (!defined(labelDistance) &&
  44974. labelOptions.inside) ||
  44975. labelDistance < 0 ||
  44976. !!seriesOptions.stacking ?
  44977. point.contrastColor :
  44978. palette.neutralColor100;
  44979. }
  44980. else {
  44981. delete point.contrastColor;
  44982. }
  44983. if (seriesOptions.cursor) {
  44984. style.cursor = seriesOptions.cursor;
  44985. }
  44986. }
  44987. attr = {
  44988. r: labelOptions.borderRadius || 0,
  44989. rotation: rotation,
  44990. padding: labelOptions.padding,
  44991. zIndex: 1
  44992. };
  44993. if (!chart.styledMode) {
  44994. attr.fill = labelOptions.backgroundColor;
  44995. attr.stroke = labelOptions.borderColor;
  44996. attr['stroke-width'] = labelOptions.borderWidth;
  44997. }
  44998. // Remove unused attributes (#947)
  44999. objectEach(attr, function (val, name) {
  45000. if (typeof val === 'undefined') {
  45001. delete attr[name];
  45002. }
  45003. });
  45004. }
  45005. // If the point is outside the plot area, destroy it. #678, #820
  45006. if (dataLabel && (!labelEnabled || !defined(labelText))) {
  45007. point.dataLabel =
  45008. point.dataLabel && point.dataLabel.destroy();
  45009. if (point.dataLabels) {
  45010. // Remove point.dataLabels if this was the last one
  45011. if (point.dataLabels.length === 1) {
  45012. delete point.dataLabels;
  45013. }
  45014. else {
  45015. delete point.dataLabels[i];
  45016. }
  45017. }
  45018. if (!i) {
  45019. delete point.dataLabel;
  45020. }
  45021. if (connector) {
  45022. point.connector = point.connector.destroy();
  45023. if (point.connectors) {
  45024. // Remove point.connectors if this was the last one
  45025. if (point.connectors.length === 1) {
  45026. delete point.connectors;
  45027. }
  45028. else {
  45029. delete point.connectors[i];
  45030. }
  45031. }
  45032. }
  45033. // Individual labels are disabled if the are explicitly disabled
  45034. // in the point options, or if they fall outside the plot area.
  45035. }
  45036. else if (labelEnabled && defined(labelText)) {
  45037. if (!dataLabel) {
  45038. // Create new label element
  45039. point.dataLabels = point.dataLabels || [];
  45040. dataLabel = point.dataLabels[i] = rotation ?
  45041. // Labels don't rotate, use text element
  45042. renderer.text(labelText, 0, -9999, labelOptions.useHTML)
  45043. .addClass('highcharts-data-label') :
  45044. // We can use label
  45045. renderer.label(labelText, 0, -9999, labelOptions.shape, null, null, labelOptions.useHTML, null, 'data-label');
  45046. // Store for backwards compatibility
  45047. if (!i) {
  45048. point.dataLabel = dataLabel;
  45049. }
  45050. dataLabel.addClass(' highcharts-data-label-color-' + point.colorIndex +
  45051. ' ' + (labelOptions.className || '') +
  45052. ( // #3398
  45053. labelOptions.useHTML ?
  45054. ' highcharts-tracker' :
  45055. ''));
  45056. }
  45057. else {
  45058. // Use old element and just update text
  45059. attr.text = labelText;
  45060. }
  45061. // Store data label options for later access
  45062. dataLabel.options = labelOptions;
  45063. dataLabel.attr(attr);
  45064. if (!chart.styledMode) {
  45065. // Styles must be applied before add in order to read
  45066. // text bounding box
  45067. dataLabel.css(style).shadow(labelOptions.shadow);
  45068. }
  45069. if (!dataLabel.added) {
  45070. dataLabel.add(dataLabelsGroup);
  45071. }
  45072. if (labelOptions.textPath && !labelOptions.useHTML) {
  45073. dataLabel.setTextPath((point.getDataLabelPath &&
  45074. point.getDataLabelPath(dataLabel)) || point.graphic, labelOptions.textPath);
  45075. if (point.dataLabelPath &&
  45076. !labelOptions.textPath.enabled) {
  45077. // clean the DOM
  45078. point.dataLabelPath = point.dataLabelPath.destroy();
  45079. }
  45080. }
  45081. // Now the data label is created and placed at 0,0, so we
  45082. // need to align it
  45083. series.alignDataLabel(point, dataLabel, labelOptions, null, isNew);
  45084. }
  45085. });
  45086. });
  45087. }
  45088. fireEvent(this, 'afterDrawDataLabels');
  45089. };
  45090. /**
  45091. * Align each individual data label.
  45092. *
  45093. * @private
  45094. * @function Highcharts.Series#alignDataLabel
  45095. * @param {Highcharts.Point} point
  45096. * @param {Highcharts.SVGElement} dataLabel
  45097. * @param {Highcharts.DataLabelsOptions} options
  45098. * @param {Highcharts.BBoxObject} alignTo
  45099. * @param {boolean} [isNew]
  45100. * @return {void}
  45101. */
  45102. Series.prototype.alignDataLabel = function (point, dataLabel, options, alignTo, isNew) {
  45103. var series = this,
  45104. chart = this.chart,
  45105. inverted = this.isCartesian && chart.inverted,
  45106. enabledDataSorting = this.enabledDataSorting,
  45107. plotX = pick(point.dlBox && point.dlBox.centerX,
  45108. point.plotX, -9999),
  45109. plotY = pick(point.plotY, -9999),
  45110. bBox = dataLabel.getBBox(),
  45111. baseline,
  45112. rotation = options.rotation,
  45113. normRotation,
  45114. negRotation,
  45115. align = options.align,
  45116. rotCorr, // rotation correction
  45117. isInsidePlot = chart.isInsidePlot(plotX,
  45118. Math.round(plotY), {
  45119. inverted: inverted,
  45120. paneCoordinates: true,
  45121. series: series
  45122. }),
  45123. // Math.round for rounding errors (#2683), alignTo to allow column
  45124. // labels (#2700)
  45125. alignAttr, // the final position;
  45126. justify = pick(options.overflow, (enabledDataSorting ? 'none' : 'justify')) === 'justify', visible = this.visible &&
  45127. point.visible !== false &&
  45128. (point.series.forceDL ||
  45129. (enabledDataSorting && !justify) ||
  45130. isInsidePlot ||
  45131. (
  45132. // If the data label is inside the align box, it is enough
  45133. // that parts of the align box is inside the plot area
  45134. // (#12370). When stacking, it is always inside regardless
  45135. // of the option (#15148).
  45136. pick(options.inside, !!this.options.stacking) &&
  45137. alignTo &&
  45138. chart.isInsidePlot(plotX, inverted ?
  45139. alignTo.x + 1 :
  45140. alignTo.y + alignTo.height - 1, {
  45141. inverted: inverted,
  45142. paneCoordinates: true,
  45143. series: series
  45144. }))), setStartPos = function (alignOptions) {
  45145. if (enabledDataSorting && series.xAxis && !justify) {
  45146. series.setDataLabelStartPos(point, dataLabel, isNew, isInsidePlot, alignOptions);
  45147. }
  45148. };
  45149. if (visible) {
  45150. baseline = chart.renderer.fontMetrics(chart.styledMode ? void 0 : options.style.fontSize, dataLabel).b;
  45151. // The alignment box is a singular point
  45152. alignTo = extend({
  45153. x: inverted ? this.yAxis.len - plotY : plotX,
  45154. y: Math.round(inverted ? this.xAxis.len - plotX : plotY),
  45155. width: 0,
  45156. height: 0
  45157. }, alignTo);
  45158. // Add the text size for alignment calculation
  45159. extend(options, {
  45160. width: bBox.width,
  45161. height: bBox.height
  45162. });
  45163. // Allow a hook for changing alignment in the last moment, then do the
  45164. // alignment
  45165. if (rotation) {
  45166. justify = false; // Not supported for rotated text
  45167. rotCorr = chart.renderer.rotCorr(baseline, rotation); // #3723
  45168. alignAttr = {
  45169. x: (alignTo.x +
  45170. (options.x || 0) +
  45171. alignTo.width / 2 +
  45172. rotCorr.x),
  45173. y: (alignTo.y +
  45174. (options.y || 0) +
  45175. { top: 0, middle: 0.5, bottom: 1 }[options.verticalAlign] *
  45176. alignTo.height)
  45177. };
  45178. setStartPos(alignAttr); // data sorting
  45179. dataLabel[isNew ? 'attr' : 'animate'](alignAttr)
  45180. .attr({
  45181. align: align
  45182. });
  45183. // Compensate for the rotated label sticking out on the sides
  45184. normRotation = (rotation + 720) % 360;
  45185. negRotation = normRotation > 180 && normRotation < 360;
  45186. if (align === 'left') {
  45187. alignAttr.y -= negRotation ? bBox.height : 0;
  45188. }
  45189. else if (align === 'center') {
  45190. alignAttr.x -= bBox.width / 2;
  45191. alignAttr.y -= bBox.height / 2;
  45192. }
  45193. else if (align === 'right') {
  45194. alignAttr.x -= bBox.width;
  45195. alignAttr.y -= negRotation ? 0 : bBox.height;
  45196. }
  45197. dataLabel.placed = true;
  45198. dataLabel.alignAttr = alignAttr;
  45199. }
  45200. else {
  45201. setStartPos(alignTo); // data sorting
  45202. dataLabel.align(options, void 0, alignTo);
  45203. alignAttr = dataLabel.alignAttr;
  45204. }
  45205. // Handle justify or crop
  45206. if (justify && alignTo.height >= 0) { // #8830
  45207. this.justifyDataLabel(dataLabel, options, alignAttr, bBox, alignTo, isNew);
  45208. // Now check that the data label is within the plot area
  45209. }
  45210. else if (pick(options.crop, true)) {
  45211. visible =
  45212. chart.isInsidePlot(alignAttr.x, alignAttr.y, {
  45213. paneCoordinates: true,
  45214. series: series
  45215. }) &&
  45216. chart.isInsidePlot(alignAttr.x + bBox.width, alignAttr.y + bBox.height, {
  45217. paneCoordinates: true,
  45218. series: series
  45219. });
  45220. }
  45221. // When we're using a shape, make it possible with a connector or an
  45222. // arrow pointing to thie point
  45223. if (options.shape && !rotation) {
  45224. dataLabel[isNew ? 'attr' : 'animate']({
  45225. anchorX: inverted ?
  45226. chart.plotWidth - point.plotY :
  45227. point.plotX,
  45228. anchorY: inverted ?
  45229. chart.plotHeight - point.plotX :
  45230. point.plotY
  45231. });
  45232. }
  45233. }
  45234. // To use alignAttr property in hideOverlappingLabels
  45235. if (isNew && enabledDataSorting) {
  45236. dataLabel.placed = false;
  45237. }
  45238. // Show or hide based on the final aligned position
  45239. if (!visible && (!enabledDataSorting || justify)) {
  45240. dataLabel.hide(true);
  45241. dataLabel.placed = false; // don't animate back in
  45242. }
  45243. };
  45244. /**
  45245. * Set starting position for data label sorting animation.
  45246. *
  45247. * @private
  45248. * @function Highcharts.Series#setDataLabelStartPos
  45249. * @param {Highcharts.SVGElement} dataLabel
  45250. * @param {Highcharts.ColumnPoint} point
  45251. * @param {boolean | undefined} [isNew]
  45252. * @param {boolean} [isInside]
  45253. * @param {Highcharts.AlignObject} [alignOptions]
  45254. *
  45255. * @return {void}
  45256. */
  45257. Series.prototype.setDataLabelStartPos = function (point, dataLabel, isNew, isInside, alignOptions) {
  45258. var chart = this.chart,
  45259. inverted = chart.inverted,
  45260. xAxis = this.xAxis,
  45261. reversed = xAxis.reversed,
  45262. labelCenter = inverted ? dataLabel.height / 2 : dataLabel.width / 2,
  45263. pointWidth = point.pointWidth,
  45264. halfWidth = pointWidth ? pointWidth / 2 : 0,
  45265. startXPos,
  45266. startYPos;
  45267. startXPos = inverted ?
  45268. alignOptions.x :
  45269. (reversed ?
  45270. -labelCenter - halfWidth :
  45271. xAxis.width - labelCenter + halfWidth);
  45272. startYPos = inverted ?
  45273. (reversed ?
  45274. this.yAxis.height - labelCenter + halfWidth :
  45275. -labelCenter - halfWidth) : alignOptions.y;
  45276. dataLabel.startXPos = startXPos;
  45277. dataLabel.startYPos = startYPos;
  45278. // We need to handle visibility in case of sorting point outside plot area
  45279. if (!isInside) {
  45280. dataLabel
  45281. .attr({ opacity: 1 })
  45282. .animate({ opacity: 0 }, void 0, dataLabel.hide);
  45283. }
  45284. else if (dataLabel.visibility === 'hidden') {
  45285. dataLabel.show();
  45286. dataLabel
  45287. .attr({ opacity: 0 })
  45288. .animate({ opacity: 1 });
  45289. }
  45290. // Save start position on first render, but do not change position
  45291. if (!chart.hasRendered) {
  45292. return;
  45293. }
  45294. // Set start position
  45295. if (isNew) {
  45296. dataLabel.attr({ x: dataLabel.startXPos, y: dataLabel.startYPos });
  45297. }
  45298. dataLabel.placed = true;
  45299. };
  45300. /**
  45301. * If data labels fall partly outside the plot area, align them back in, in a
  45302. * way that doesn't hide the point.
  45303. *
  45304. * @private
  45305. * @function Highcharts.Series#justifyDataLabel
  45306. * @param {Highcharts.SVGElement} dataLabel
  45307. * @param {Highcharts.DataLabelsOptions} options
  45308. * @param {Highcharts.SVGAttributes} alignAttr
  45309. * @param {Highcharts.BBoxObject} bBox
  45310. * @param {Highcharts.BBoxObject} [alignTo]
  45311. * @param {boolean} [isNew]
  45312. * @return {boolean|undefined}
  45313. */
  45314. Series.prototype.justifyDataLabel = function (dataLabel, options, alignAttr, bBox, alignTo, isNew) {
  45315. var chart = this.chart,
  45316. align = options.align,
  45317. verticalAlign = options.verticalAlign,
  45318. off,
  45319. justified,
  45320. padding = dataLabel.box ? 0 : (dataLabel.padding || 0);
  45321. var _a = options.x,
  45322. x = _a === void 0 ? 0 : _a,
  45323. _b = options.y,
  45324. y = _b === void 0 ? 0 : _b;
  45325. // Off left
  45326. off = (alignAttr.x || 0) + padding;
  45327. if (off < 0) {
  45328. if (align === 'right' && x >= 0) {
  45329. options.align = 'left';
  45330. options.inside = true;
  45331. }
  45332. else {
  45333. x -= off;
  45334. }
  45335. justified = true;
  45336. }
  45337. // Off right
  45338. off = (alignAttr.x || 0) + bBox.width - padding;
  45339. if (off > chart.plotWidth) {
  45340. if (align === 'left' && x <= 0) {
  45341. options.align = 'right';
  45342. options.inside = true;
  45343. }
  45344. else {
  45345. x += chart.plotWidth - off;
  45346. }
  45347. justified = true;
  45348. }
  45349. // Off top
  45350. off = alignAttr.y + padding;
  45351. if (off < 0) {
  45352. if (verticalAlign === 'bottom' && y >= 0) {
  45353. options.verticalAlign = 'top';
  45354. options.inside = true;
  45355. }
  45356. else {
  45357. y -= off;
  45358. }
  45359. justified = true;
  45360. }
  45361. // Off bottom
  45362. off = (alignAttr.y || 0) + bBox.height - padding;
  45363. if (off > chart.plotHeight) {
  45364. if (verticalAlign === 'top' && y <= 0) {
  45365. options.verticalAlign = 'bottom';
  45366. options.inside = true;
  45367. }
  45368. else {
  45369. y += chart.plotHeight - off;
  45370. }
  45371. justified = true;
  45372. }
  45373. if (justified) {
  45374. options.x = x;
  45375. options.y = y;
  45376. dataLabel.placed = !isNew;
  45377. dataLabel.align(options, void 0, alignTo);
  45378. }
  45379. return justified;
  45380. };
  45381. if (seriesTypes.pie) {
  45382. seriesTypes.pie.prototype.dataLabelPositioners = {
  45383. // Based on the value computed in Highcharts' distribute algorithm.
  45384. radialDistributionY: function (point) {
  45385. return point.top + point.distributeBox.pos;
  45386. },
  45387. // get the x - use the natural x position for labels near the
  45388. // top and bottom, to prevent the top and botton slice
  45389. // connectors from touching each other on either side
  45390. // Based on the value computed in Highcharts' distribute algorithm.
  45391. radialDistributionX: function (series, point, y, naturalY) {
  45392. return series.getX(y < point.top + 2 || y > point.bottom - 2 ?
  45393. naturalY :
  45394. y, point.half, point);
  45395. },
  45396. // dataLabels.distance determines the x position of the label
  45397. justify: function (point, radius, seriesCenter) {
  45398. return seriesCenter[0] + (point.half ? -1 : 1) *
  45399. (radius + point.labelDistance);
  45400. },
  45401. // Left edges of the left-half labels touch the left edge of the plot
  45402. // area. Right edges of the right-half labels touch the right edge of
  45403. // the plot area.
  45404. alignToPlotEdges: function (dataLabel, half, plotWidth, plotLeft) {
  45405. var dataLabelWidth = dataLabel.getBBox().width;
  45406. return half ? dataLabelWidth + plotLeft :
  45407. plotWidth - dataLabelWidth - plotLeft;
  45408. },
  45409. // Connectors of each side end in the same x position. Labels are
  45410. // aligned to them. Left edge of the widest left-half label touches the
  45411. // left edge of the plot area. Right edge of the widest right-half label
  45412. // touches the right edge of the plot area.
  45413. alignToConnectors: function (points, half, plotWidth, plotLeft) {
  45414. var maxDataLabelWidth = 0,
  45415. dataLabelWidth;
  45416. // find widest data label
  45417. points.forEach(function (point) {
  45418. dataLabelWidth = point.dataLabel.getBBox().width;
  45419. if (dataLabelWidth > maxDataLabelWidth) {
  45420. maxDataLabelWidth = dataLabelWidth;
  45421. }
  45422. });
  45423. return half ? maxDataLabelWidth + plotLeft :
  45424. plotWidth - maxDataLabelWidth - plotLeft;
  45425. }
  45426. };
  45427. /**
  45428. * Override the base drawDataLabels method by pie specific functionality
  45429. *
  45430. * @private
  45431. * @function Highcharts.seriesTypes.pie#drawDataLabels
  45432. * @return {void}
  45433. */
  45434. seriesTypes.pie.prototype.drawDataLabels = function () {
  45435. var series = this,
  45436. data = series.data,
  45437. point,
  45438. chart = series.chart,
  45439. options = series.options.dataLabels || {},
  45440. connectorPadding = options.connectorPadding,
  45441. connectorWidth,
  45442. plotWidth = chart.plotWidth,
  45443. plotHeight = chart.plotHeight,
  45444. plotLeft = chart.plotLeft,
  45445. maxWidth = Math.round(chart.chartWidth / 3),
  45446. connector,
  45447. seriesCenter = series.center,
  45448. radius = seriesCenter[2] / 2,
  45449. centerY = seriesCenter[1],
  45450. dataLabel,
  45451. dataLabelWidth,
  45452. // labelPos,
  45453. labelPosition,
  45454. labelHeight,
  45455. // divide the points into right and left halves for anti collision
  45456. halves = [
  45457. [],
  45458. [] // left
  45459. ],
  45460. x,
  45461. y,
  45462. visibility,
  45463. j,
  45464. overflow = [0, 0, 0, 0], // top, right, bottom, left
  45465. dataLabelPositioners = series.dataLabelPositioners,
  45466. pointDataLabelsOptions;
  45467. // get out if not enabled
  45468. if (!series.visible ||
  45469. (!options.enabled &&
  45470. !series._hasPointLabels)) {
  45471. return;
  45472. }
  45473. // Reset all labels that have been shortened
  45474. data.forEach(function (point) {
  45475. if (point.dataLabel && point.visible && point.dataLabel.shortened) {
  45476. point.dataLabel
  45477. .attr({
  45478. width: 'auto'
  45479. }).css({
  45480. width: 'auto',
  45481. textOverflow: 'clip'
  45482. });
  45483. point.dataLabel.shortened = false;
  45484. }
  45485. });
  45486. // run parent method
  45487. Series.prototype.drawDataLabels.apply(series);
  45488. data.forEach(function (point) {
  45489. if (point.dataLabel) {
  45490. if (point.visible) { // #407, #2510
  45491. // Arrange points for detection collision
  45492. halves[point.half].push(point);
  45493. // Reset positions (#4905)
  45494. point.dataLabel._pos = null;
  45495. // Avoid long labels squeezing the pie size too far down
  45496. if (!defined(options.style.width) &&
  45497. !defined(point.options.dataLabels &&
  45498. point.options.dataLabels.style &&
  45499. point.options.dataLabels.style.width)) {
  45500. if (point.dataLabel.getBBox().width > maxWidth) {
  45501. point.dataLabel.css({
  45502. // Use a fraction of the maxWidth to avoid
  45503. // wrapping close to the end of the string.
  45504. width: Math.round(maxWidth * 0.7) + 'px'
  45505. });
  45506. point.dataLabel.shortened = true;
  45507. }
  45508. }
  45509. }
  45510. else {
  45511. point.dataLabel = point.dataLabel.destroy();
  45512. // Workaround to make pies destroy multiple datalabels
  45513. // correctly. This logic needs rewriting to support multiple
  45514. // datalabels fully.
  45515. if (point.dataLabels && point.dataLabels.length === 1) {
  45516. delete point.dataLabels;
  45517. }
  45518. }
  45519. }
  45520. });
  45521. /* Loop over the points in each half, starting from the top and bottom
  45522. * of the pie to detect overlapping labels.
  45523. */
  45524. halves.forEach(function (points, i) {
  45525. var top,
  45526. bottom,
  45527. length = points.length,
  45528. positions = [],
  45529. naturalY,
  45530. sideOverflow,
  45531. size,
  45532. distributionLength;
  45533. if (!length) {
  45534. return;
  45535. }
  45536. // Sort by angle
  45537. series.sortByAngle(points, i - 0.5);
  45538. // Only do anti-collision when we have dataLabels outside the pie
  45539. // and have connectors. (#856)
  45540. if (series.maxLabelDistance > 0) {
  45541. top = Math.max(0, centerY - radius - series.maxLabelDistance);
  45542. bottom = Math.min(centerY + radius + series.maxLabelDistance, chart.plotHeight);
  45543. points.forEach(function (point) {
  45544. // check if specific points' label is outside the pie
  45545. if (point.labelDistance > 0 && point.dataLabel) {
  45546. // point.top depends on point.labelDistance value
  45547. // Used for calculation of y value in getX method
  45548. point.top = Math.max(0, centerY - radius - point.labelDistance);
  45549. point.bottom = Math.min(centerY + radius + point.labelDistance, chart.plotHeight);
  45550. size = point.dataLabel.getBBox().height || 21;
  45551. // point.positionsIndex is needed for getting index of
  45552. // parameter related to specific point inside positions
  45553. // array - not every point is in positions array.
  45554. point.distributeBox = {
  45555. target: point.labelPosition.natural.y -
  45556. point.top + size / 2,
  45557. size: size,
  45558. rank: point.y
  45559. };
  45560. positions.push(point.distributeBox);
  45561. }
  45562. });
  45563. distributionLength = bottom + size - top;
  45564. H.distribute(positions, distributionLength, distributionLength / 5);
  45565. }
  45566. // Now the used slots are sorted, fill them up sequentially
  45567. for (j = 0; j < length; j++) {
  45568. point = points[j];
  45569. // labelPos = point.labelPos;
  45570. labelPosition = point.labelPosition;
  45571. dataLabel = point.dataLabel;
  45572. visibility = point.visible === false ? 'hidden' : 'inherit';
  45573. naturalY = labelPosition.natural.y;
  45574. y = naturalY;
  45575. if (positions && defined(point.distributeBox)) {
  45576. if (typeof point.distributeBox.pos === 'undefined') {
  45577. visibility = 'hidden';
  45578. }
  45579. else {
  45580. labelHeight = point.distributeBox.size;
  45581. // Find label's y position
  45582. y = dataLabelPositioners
  45583. .radialDistributionY(point);
  45584. }
  45585. }
  45586. // It is needed to delete point.positionIndex for
  45587. // dynamically added points etc.
  45588. delete point.positionIndex; // @todo unused
  45589. // Find label's x position
  45590. // justify is undocumented in the API - preserve support for it
  45591. if (options.justify) {
  45592. x = dataLabelPositioners.justify(point, radius, seriesCenter);
  45593. }
  45594. else {
  45595. switch (options.alignTo) {
  45596. case 'connectors':
  45597. x = dataLabelPositioners.alignToConnectors(points, i, plotWidth, plotLeft);
  45598. break;
  45599. case 'plotEdges':
  45600. x = dataLabelPositioners.alignToPlotEdges(dataLabel, i, plotWidth, plotLeft);
  45601. break;
  45602. default:
  45603. x = dataLabelPositioners.radialDistributionX(series, point, y, naturalY);
  45604. }
  45605. }
  45606. // Record the placement and visibility
  45607. dataLabel._attr = {
  45608. visibility: visibility,
  45609. align: labelPosition.alignment
  45610. };
  45611. pointDataLabelsOptions = point.options.dataLabels || {};
  45612. dataLabel._pos = {
  45613. x: (x +
  45614. pick(pointDataLabelsOptions.x, options.x) + // (#12985)
  45615. ({
  45616. left: connectorPadding,
  45617. right: -connectorPadding
  45618. }[labelPosition.alignment] || 0)),
  45619. // 10 is for the baseline (label vs text)
  45620. y: (y +
  45621. pick(pointDataLabelsOptions.y, options.y) - // (#12985)
  45622. 10)
  45623. };
  45624. // labelPos.x = x;
  45625. // labelPos.y = y;
  45626. labelPosition.final.x = x;
  45627. labelPosition.final.y = y;
  45628. // Detect overflowing data labels
  45629. if (pick(options.crop, true)) {
  45630. dataLabelWidth = dataLabel.getBBox().width;
  45631. sideOverflow = null;
  45632. // Overflow left
  45633. if (x - dataLabelWidth < connectorPadding &&
  45634. i === 1 // left half
  45635. ) {
  45636. sideOverflow = Math.round(dataLabelWidth - x + connectorPadding);
  45637. overflow[3] = Math.max(sideOverflow, overflow[3]);
  45638. // Overflow right
  45639. }
  45640. else if (x + dataLabelWidth > plotWidth - connectorPadding &&
  45641. i === 0 // right half
  45642. ) {
  45643. sideOverflow = Math.round(x + dataLabelWidth - plotWidth + connectorPadding);
  45644. overflow[1] = Math.max(sideOverflow, overflow[1]);
  45645. }
  45646. // Overflow top
  45647. if (y - labelHeight / 2 < 0) {
  45648. overflow[0] = Math.max(Math.round(-y + labelHeight / 2), overflow[0]);
  45649. // Overflow left
  45650. }
  45651. else if (y + labelHeight / 2 > plotHeight) {
  45652. overflow[2] = Math.max(Math.round(y + labelHeight / 2 - plotHeight), overflow[2]);
  45653. }
  45654. dataLabel.sideOverflow = sideOverflow;
  45655. }
  45656. } // for each point
  45657. }); // for each half
  45658. // Do not apply the final placement and draw the connectors until we
  45659. // have verified that labels are not spilling over.
  45660. if (arrayMax(overflow) === 0 ||
  45661. this.verifyDataLabelOverflow(overflow)) {
  45662. // Place the labels in the final position
  45663. this.placeDataLabels();
  45664. this.points.forEach(function (point) {
  45665. // #8864: every connector can have individual options
  45666. pointDataLabelsOptions =
  45667. merge(options, point.options.dataLabels);
  45668. connectorWidth =
  45669. pick(pointDataLabelsOptions.connectorWidth, 1);
  45670. // Draw the connector
  45671. if (connectorWidth) {
  45672. var isNew = void 0;
  45673. connector = point.connector;
  45674. dataLabel = point.dataLabel;
  45675. if (dataLabel &&
  45676. dataLabel._pos &&
  45677. point.visible &&
  45678. point.labelDistance > 0) {
  45679. visibility = dataLabel._attr.visibility;
  45680. isNew = !connector;
  45681. if (isNew) {
  45682. point.connector = connector = chart.renderer
  45683. .path()
  45684. .addClass('highcharts-data-label-connector ' +
  45685. ' highcharts-color-' + point.colorIndex +
  45686. (point.className ?
  45687. ' ' + point.className :
  45688. ''))
  45689. .add(series.dataLabelsGroup);
  45690. if (!chart.styledMode) {
  45691. connector.attr({
  45692. 'stroke-width': connectorWidth,
  45693. 'stroke': (pointDataLabelsOptions.connectorColor ||
  45694. point.color ||
  45695. palette.neutralColor60)
  45696. });
  45697. }
  45698. }
  45699. connector[isNew ? 'attr' : 'animate']({
  45700. d: point.getConnectorPath()
  45701. });
  45702. connector.attr('visibility', visibility);
  45703. }
  45704. else if (connector) {
  45705. point.connector = connector.destroy();
  45706. }
  45707. }
  45708. });
  45709. }
  45710. };
  45711. /**
  45712. * Extendable method for getting the path of the connector between the data
  45713. * label and the pie slice.
  45714. *
  45715. * @private
  45716. * @function Highcharts.seriesTypes.pie#connectorPath
  45717. *
  45718. * @param {*} labelPos
  45719. *
  45720. * @return {Highcharts.SVGPathArray}
  45721. */
  45722. // TODO: depracated - remove it
  45723. /*
  45724. seriesTypes.pie.prototype.connectorPath = function (labelPos) {
  45725. let x = labelPos.x,
  45726. y = labelPos.y;
  45727. return pick(this.options.dataLabels.softConnector, true) ? [
  45728. 'M',
  45729. // end of the string at the label
  45730. x + (labelPos[6] === 'left' ? 5 : -5), y,
  45731. 'C',
  45732. x, y, // first break, next to the label
  45733. 2 * labelPos[2] - labelPos[4], 2 * labelPos[3] - labelPos[5],
  45734. labelPos[2], labelPos[3], // second break
  45735. 'L',
  45736. labelPos[4], labelPos[5] // base
  45737. ] : [
  45738. 'M',
  45739. // end of the string at the label
  45740. x + (labelPos[6] === 'left' ? 5 : -5), y,
  45741. 'L',
  45742. labelPos[2], labelPos[3], // second break
  45743. 'L',
  45744. labelPos[4], labelPos[5] // base
  45745. ];
  45746. };
  45747. */
  45748. /**
  45749. * Perform the final placement of the data labels after we have verified
  45750. * that they fall within the plot area.
  45751. *
  45752. * @private
  45753. * @function Highcharts.seriesTypes.pie#placeDataLabels
  45754. * @return {void}
  45755. */
  45756. seriesTypes.pie.prototype.placeDataLabels = function () {
  45757. this.points.forEach(function (point) {
  45758. var dataLabel = point.dataLabel,
  45759. _pos;
  45760. if (dataLabel && point.visible) {
  45761. _pos = dataLabel._pos;
  45762. if (_pos) {
  45763. // Shorten data labels with ellipsis if they still overflow
  45764. // after the pie has reached minSize (#223).
  45765. if (dataLabel.sideOverflow) {
  45766. dataLabel._attr.width =
  45767. Math.max(dataLabel.getBBox().width -
  45768. dataLabel.sideOverflow, 0);
  45769. dataLabel.css({
  45770. width: dataLabel._attr.width + 'px',
  45771. textOverflow: ((this.options.dataLabels.style || {})
  45772. .textOverflow ||
  45773. 'ellipsis')
  45774. });
  45775. dataLabel.shortened = true;
  45776. }
  45777. dataLabel.attr(dataLabel._attr);
  45778. dataLabel[dataLabel.moved ? 'animate' : 'attr'](_pos);
  45779. dataLabel.moved = true;
  45780. }
  45781. else if (dataLabel) {
  45782. dataLabel.attr({ y: -9999 });
  45783. }
  45784. }
  45785. // Clear for update
  45786. delete point.distributeBox;
  45787. }, this);
  45788. };
  45789. seriesTypes.pie.prototype.alignDataLabel = noop;
  45790. /**
  45791. * Verify whether the data labels are allowed to draw, or we should run more
  45792. * translation and data label positioning to keep them inside the plot area.
  45793. * Returns true when data labels are ready to draw.
  45794. *
  45795. * @private
  45796. * @function Highcharts.seriesTypes.pie#verifyDataLabelOverflow
  45797. * @param {Array<number>} overflow
  45798. * @return {boolean}
  45799. */
  45800. seriesTypes.pie.prototype.verifyDataLabelOverflow = function (overflow) {
  45801. var center = this.center,
  45802. options = this.options,
  45803. centerOption = options.center,
  45804. minSize = options.minSize || 80,
  45805. newSize = minSize,
  45806. // If a size is set, return true and don't try to shrink the pie
  45807. // to fit the labels.
  45808. ret = options.size !== null;
  45809. if (!ret) {
  45810. // Handle horizontal size and center
  45811. if (centerOption[0] !== null) { // Fixed center
  45812. newSize = Math.max(center[2] -
  45813. Math.max(overflow[1], overflow[3]), minSize);
  45814. }
  45815. else { // Auto center
  45816. newSize = Math.max(
  45817. // horizontal overflow
  45818. center[2] - overflow[1] - overflow[3], minSize);
  45819. // horizontal center
  45820. center[0] += (overflow[3] - overflow[1]) / 2;
  45821. }
  45822. // Handle vertical size and center
  45823. if (centerOption[1] !== null) { // Fixed center
  45824. newSize = clamp(newSize, minSize, center[2] - Math.max(overflow[0], overflow[2]));
  45825. }
  45826. else { // Auto center
  45827. newSize = clamp(newSize, minSize,
  45828. // vertical overflow
  45829. center[2] - overflow[0] - overflow[2]);
  45830. // vertical center
  45831. center[1] += (overflow[0] - overflow[2]) / 2;
  45832. }
  45833. // If the size must be decreased, we need to run translate and
  45834. // drawDataLabels again
  45835. if (newSize < center[2]) {
  45836. center[2] = newSize;
  45837. center[3] = Math.min(// #3632
  45838. relativeLength(options.innerSize || 0, newSize), newSize);
  45839. this.translate(center);
  45840. if (this.drawDataLabels) {
  45841. this.drawDataLabels();
  45842. }
  45843. // Else, return true to indicate that the pie and its labels is
  45844. // within the plot area
  45845. }
  45846. else {
  45847. ret = true;
  45848. }
  45849. }
  45850. return ret;
  45851. };
  45852. }
  45853. if (seriesTypes.column) {
  45854. /**
  45855. * Override the basic data label alignment by adjusting for the position of
  45856. * the column.
  45857. *
  45858. * @private
  45859. * @function Highcharts.seriesTypes.column#alignDataLabel
  45860. * @param {Highcharts.Point} point
  45861. * @param {Highcharts.SVGElement} dataLabel
  45862. * @param {Highcharts.DataLabelsOptions} options
  45863. * @param {Highcharts.BBoxObject} alignTo
  45864. * @param {boolean} [isNew]
  45865. * @return {void}
  45866. */
  45867. seriesTypes.column.prototype.alignDataLabel = function (point, dataLabel, options, alignTo, isNew) {
  45868. var inverted = this.chart.inverted,
  45869. series = point.series,
  45870. // data label box for alignment
  45871. dlBox = point.dlBox || point.shapeArgs,
  45872. below = pick(point.below, // range series
  45873. point.plotY >
  45874. pick(this.translatedThreshold,
  45875. series.yAxis.len)),
  45876. // draw it inside the box?
  45877. inside = pick(options.inside, !!this.options.stacking),
  45878. overshoot;
  45879. // Align to the column itself, or the top of it
  45880. if (dlBox) { // Area range uses this method but not alignTo
  45881. alignTo = merge(dlBox);
  45882. if (alignTo.y < 0) {
  45883. alignTo.height += alignTo.y;
  45884. alignTo.y = 0;
  45885. }
  45886. // If parts of the box overshoots outside the plot area, modify the
  45887. // box to center the label inside
  45888. overshoot = alignTo.y + alignTo.height - series.yAxis.len;
  45889. if (overshoot > 0 && overshoot < alignTo.height) {
  45890. alignTo.height -= overshoot;
  45891. }
  45892. if (inverted) {
  45893. alignTo = {
  45894. x: series.yAxis.len - alignTo.y - alignTo.height,
  45895. y: series.xAxis.len - alignTo.x - alignTo.width,
  45896. width: alignTo.height,
  45897. height: alignTo.width
  45898. };
  45899. }
  45900. // Compute the alignment box
  45901. if (!inside) {
  45902. if (inverted) {
  45903. alignTo.x += below ? 0 : alignTo.width;
  45904. alignTo.width = 0;
  45905. }
  45906. else {
  45907. alignTo.y += below ? alignTo.height : 0;
  45908. alignTo.height = 0;
  45909. }
  45910. }
  45911. }
  45912. // When alignment is undefined (typically columns and bars), display the
  45913. // individual point below or above the point depending on the threshold
  45914. options.align = pick(options.align, !inverted || inside ? 'center' : below ? 'right' : 'left');
  45915. options.verticalAlign = pick(options.verticalAlign, inverted || inside ? 'middle' : below ? 'top' : 'bottom');
  45916. // Call the parent method
  45917. Series.prototype.alignDataLabel.call(this, point, dataLabel, options, alignTo, isNew);
  45918. // If label was justified and we have contrast, set it:
  45919. if (options.inside && point.contrastColor) {
  45920. dataLabel.css({
  45921. color: point.contrastColor
  45922. });
  45923. }
  45924. };
  45925. }
  45926. });
  45927. _registerModule(_modules, 'Extensions/OverlappingDataLabels.js', [_modules['Core/Chart/Chart.js'], _modules['Core/Utilities.js']], function (Chart, U) {
  45928. /* *
  45929. *
  45930. * Highcharts module to hide overlapping data labels.
  45931. * This module is included in Highcharts.
  45932. *
  45933. * (c) 2009-2021 Torstein Honsi
  45934. *
  45935. * License: www.highcharts.com/license
  45936. *
  45937. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  45938. *
  45939. * */
  45940. var addEvent = U.addEvent,
  45941. fireEvent = U.fireEvent,
  45942. isArray = U.isArray,
  45943. isNumber = U.isNumber,
  45944. objectEach = U.objectEach,
  45945. pick = U.pick;
  45946. /**
  45947. * Internal type
  45948. * @private
  45949. */
  45950. /* eslint-disable no-invalid-this */
  45951. // Collect potensial overlapping data labels. Stack labels probably don't need
  45952. // to be considered because they are usually accompanied by data labels that lie
  45953. // inside the columns.
  45954. addEvent(Chart, 'render', function collectAndHide() {
  45955. var chart = this,
  45956. labels = [];
  45957. // Consider external label collectors
  45958. (this.labelCollectors || []).forEach(function (collector) {
  45959. labels = labels.concat(collector());
  45960. });
  45961. (this.yAxis || []).forEach(function (yAxis) {
  45962. if (yAxis.stacking &&
  45963. yAxis.options.stackLabels &&
  45964. !yAxis.options.stackLabels.allowOverlap) {
  45965. objectEach(yAxis.stacking.stacks, function (stack) {
  45966. objectEach(stack, function (stackItem) {
  45967. labels.push(stackItem.label);
  45968. });
  45969. });
  45970. }
  45971. });
  45972. (this.series || []).forEach(function (series) {
  45973. var dlOptions = series.options.dataLabels;
  45974. if (series.visible &&
  45975. !(dlOptions.enabled === false && !series._hasPointLabels)) { // #3866
  45976. var push = function (points) {
  45977. return points.forEach(function (point) {
  45978. if (point.visible) {
  45979. var dataLabels = (isArray(point.dataLabels) ?
  45980. point.dataLabels :
  45981. (point.dataLabel ? [point.dataLabel] : []));
  45982. dataLabels.forEach(function (label) {
  45983. var options = label.options;
  45984. label.labelrank = pick(options.labelrank, point.labelrank, point.shapeArgs && point.shapeArgs.height); // #4118
  45985. if (!options.allowOverlap) {
  45986. labels.push(label);
  45987. }
  45988. else { // #13449
  45989. label.oldOpacity = label.opacity;
  45990. label.newOpacity = 1;
  45991. hideOrShow(label, chart);
  45992. }
  45993. });
  45994. }
  45995. });
  45996. };
  45997. push(series.nodes || []);
  45998. push(series.points);
  45999. }
  46000. });
  46001. this.hideOverlappingLabels(labels);
  46002. });
  46003. /**
  46004. * Hide overlapping labels. Labels are moved and faded in and out on zoom to
  46005. * provide a smooth visual imression.
  46006. *
  46007. * @private
  46008. * @function Highcharts.Chart#hideOverlappingLabels
  46009. * @param {Array<Highcharts.SVGElement>} labels
  46010. * Rendered data labels
  46011. * @requires modules/overlapping-datalabels
  46012. */
  46013. Chart.prototype.hideOverlappingLabels = function (labels) {
  46014. var chart = this,
  46015. len = labels.length,
  46016. ren = chart.renderer,
  46017. label,
  46018. i,
  46019. j,
  46020. label1,
  46021. label2,
  46022. box1,
  46023. box2,
  46024. isLabelAffected = false,
  46025. isIntersectRect = function (box1,
  46026. box2) {
  46027. return !(box2.x >= box1.x + box1.width ||
  46028. box2.x + box2.width <= box1.x ||
  46029. box2.y >= box1.y + box1.height ||
  46030. box2.y + box2.height <= box1.y);
  46031. },
  46032. // Get the box with its position inside the chart, as opposed to getBBox
  46033. // that only reports the position relative to the parent.
  46034. getAbsoluteBox = function (label) {
  46035. var pos,
  46036. parent,
  46037. bBox,
  46038. // Substract the padding if no background or border (#4333)
  46039. padding = label.box ? 0 : (label.padding || 0),
  46040. lineHeightCorrection = 0,
  46041. xOffset = 0,
  46042. boxWidth,
  46043. alignValue;
  46044. if (label &&
  46045. (!label.alignAttr || label.placed)) {
  46046. pos = label.alignAttr || {
  46047. x: label.attr('x'),
  46048. y: label.attr('y')
  46049. };
  46050. parent = label.parentGroup;
  46051. // Get width and height if pure text nodes (stack labels)
  46052. if (!label.width) {
  46053. bBox = label.getBBox();
  46054. label.width = bBox.width;
  46055. label.height = bBox.height;
  46056. // Labels positions are computed from top left corner, so
  46057. // we need to substract the text height from text nodes too.
  46058. lineHeightCorrection = ren
  46059. .fontMetrics(null, label.element).h;
  46060. }
  46061. boxWidth = label.width - 2 * padding;
  46062. alignValue = {
  46063. left: '0',
  46064. center: '0.5',
  46065. right: '1'
  46066. }[label.alignValue];
  46067. if (alignValue) {
  46068. xOffset = +alignValue * boxWidth;
  46069. }
  46070. else if (isNumber(label.x) && Math.round(label.x) !== label.translateX) {
  46071. xOffset = label.x - label.translateX;
  46072. }
  46073. return {
  46074. x: pos.x + (parent.translateX || 0) + padding -
  46075. (xOffset || 0),
  46076. y: pos.y + (parent.translateY || 0) + padding -
  46077. lineHeightCorrection,
  46078. width: label.width - 2 * padding,
  46079. height: label.height - 2 * padding
  46080. };
  46081. }
  46082. };
  46083. for (i = 0; i < len; i++) {
  46084. label = labels[i];
  46085. if (label) {
  46086. // Mark with initial opacity
  46087. label.oldOpacity = label.opacity;
  46088. label.newOpacity = 1;
  46089. label.absoluteBox = getAbsoluteBox(label);
  46090. }
  46091. }
  46092. // Prevent a situation in a gradually rising slope, that each label will
  46093. // hide the previous one because the previous one always has lower rank.
  46094. labels.sort(function (a, b) {
  46095. return (b.labelrank || 0) - (a.labelrank || 0);
  46096. });
  46097. // Detect overlapping labels
  46098. for (i = 0; i < len; i++) {
  46099. label1 = labels[i];
  46100. box1 = label1 && label1.absoluteBox;
  46101. for (j = i + 1; j < len; ++j) {
  46102. label2 = labels[j];
  46103. box2 = label2 && label2.absoluteBox;
  46104. if (box1 &&
  46105. box2 &&
  46106. label1 !== label2 && // #6465, polar chart with connectEnds
  46107. label1.newOpacity !== 0 &&
  46108. label2.newOpacity !== 0) {
  46109. if (isIntersectRect(box1, box2)) {
  46110. (label1.labelrank < label2.labelrank ? label1 : label2)
  46111. .newOpacity = 0;
  46112. }
  46113. }
  46114. }
  46115. }
  46116. // Hide or show
  46117. labels.forEach(function (label) {
  46118. if (hideOrShow(label, chart)) {
  46119. isLabelAffected = true;
  46120. }
  46121. });
  46122. if (isLabelAffected) {
  46123. fireEvent(chart, 'afterHideAllOverlappingLabels');
  46124. }
  46125. };
  46126. /**
  46127. * Hide or show labels based on opacity.
  46128. *
  46129. * @private
  46130. * @function hideOrShow
  46131. * @param {Highcharts.SVGElement} label
  46132. * The label.
  46133. * @param {Highcharts.Chart} chart
  46134. * The chart that contains the label.
  46135. * @return {boolean}
  46136. */
  46137. function hideOrShow(label, chart) {
  46138. var complete,
  46139. newOpacity,
  46140. isLabelAffected = false;
  46141. if (label) {
  46142. newOpacity = label.newOpacity;
  46143. if (label.oldOpacity !== newOpacity) {
  46144. // Make sure the label is completely hidden to avoid catching
  46145. // clicks (#4362)
  46146. if (label.alignAttr && label.placed) { // data labels
  46147. label[newOpacity ? 'removeClass' : 'addClass']('highcharts-data-label-hidden');
  46148. complete = function () {
  46149. if (!chart.styledMode) {
  46150. label.css({ pointerEvents: newOpacity ? 'auto' : 'none' });
  46151. }
  46152. label.visibility = newOpacity ? 'inherit' : 'hidden';
  46153. };
  46154. isLabelAffected = true;
  46155. // Animate or set the opacity
  46156. label.alignAttr.opacity = newOpacity;
  46157. label[label.isOld ? 'animate' : 'attr'](label.alignAttr, null, complete);
  46158. fireEvent(chart, 'afterHideOverlappingLabel');
  46159. }
  46160. else { // other labels, tick labels
  46161. label.attr({
  46162. opacity: newOpacity
  46163. });
  46164. }
  46165. }
  46166. label.isOld = true;
  46167. }
  46168. return isLabelAffected;
  46169. }
  46170. });
  46171. _registerModule(_modules, 'Core/Responsive.js', [_modules['Core/Chart/Chart.js'], _modules['Core/Utilities.js']], function (Chart, U) {
  46172. /* *
  46173. *
  46174. * (c) 2010-2021 Torstein Honsi
  46175. *
  46176. * License: www.highcharts.com/license
  46177. *
  46178. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  46179. *
  46180. * */
  46181. var find = U.find,
  46182. isArray = U.isArray,
  46183. isObject = U.isObject,
  46184. merge = U.merge,
  46185. objectEach = U.objectEach,
  46186. pick = U.pick,
  46187. splat = U.splat,
  46188. uniqueKey = U.uniqueKey;
  46189. /**
  46190. * A callback function to gain complete control on when the responsive rule
  46191. * applies.
  46192. *
  46193. * @callback Highcharts.ResponsiveCallbackFunction
  46194. *
  46195. * @param {Highcharts.Chart} this
  46196. * Chart context.
  46197. *
  46198. * @return {boolean}
  46199. * Return `true` if it applies.
  46200. */
  46201. /**
  46202. * Allows setting a set of rules to apply for different screen or chart
  46203. * sizes. Each rule specifies additional chart options.
  46204. *
  46205. * @sample {highstock} stock/demo/responsive/
  46206. * Stock chart
  46207. * @sample highcharts/responsive/axis/
  46208. * Axis
  46209. * @sample highcharts/responsive/legend/
  46210. * Legend
  46211. * @sample highcharts/responsive/classname/
  46212. * Class name
  46213. *
  46214. * @since 5.0.0
  46215. * @apioption responsive
  46216. */
  46217. /**
  46218. * A set of rules for responsive settings. The rules are executed from
  46219. * the top down.
  46220. *
  46221. * @sample {highcharts} highcharts/responsive/axis/
  46222. * Axis changes
  46223. * @sample {highstock} highcharts/responsive/axis/
  46224. * Axis changes
  46225. * @sample {highmaps} highcharts/responsive/axis/
  46226. * Axis changes
  46227. *
  46228. * @type {Array<*>}
  46229. * @since 5.0.0
  46230. * @apioption responsive.rules
  46231. */
  46232. /**
  46233. * A full set of chart options to apply as overrides to the general
  46234. * chart options. The chart options are applied when the given rule
  46235. * is active.
  46236. *
  46237. * A special case is configuration objects that take arrays, for example
  46238. * [xAxis](#xAxis), [yAxis](#yAxis) or [series](#series). For these
  46239. * collections, an `id` option is used to map the new option set to
  46240. * an existing object. If an existing object of the same id is not found,
  46241. * the item of the same indexupdated. So for example, setting `chartOptions`
  46242. * with two series items without an `id`, will cause the existing chart's
  46243. * two series to be updated with respective options.
  46244. *
  46245. * @sample {highstock} stock/demo/responsive/
  46246. * Stock chart
  46247. * @sample highcharts/responsive/axis/
  46248. * Axis
  46249. * @sample highcharts/responsive/legend/
  46250. * Legend
  46251. * @sample highcharts/responsive/classname/
  46252. * Class name
  46253. *
  46254. * @type {Highcharts.Options}
  46255. * @since 5.0.0
  46256. * @apioption responsive.rules.chartOptions
  46257. */
  46258. /**
  46259. * Under which conditions the rule applies.
  46260. *
  46261. * @since 5.0.0
  46262. * @apioption responsive.rules.condition
  46263. */
  46264. /**
  46265. * A callback function to gain complete control on when the responsive
  46266. * rule applies. Return `true` if it applies. This opens for checking
  46267. * against other metrics than the chart size, for example the document
  46268. * size or other elements.
  46269. *
  46270. * @type {Highcharts.ResponsiveCallbackFunction}
  46271. * @since 5.0.0
  46272. * @context Highcharts.Chart
  46273. * @apioption responsive.rules.condition.callback
  46274. */
  46275. /**
  46276. * The responsive rule applies if the chart height is less than this.
  46277. *
  46278. * @type {number}
  46279. * @since 5.0.0
  46280. * @apioption responsive.rules.condition.maxHeight
  46281. */
  46282. /**
  46283. * The responsive rule applies if the chart width is less than this.
  46284. *
  46285. * @sample highcharts/responsive/axis/
  46286. * Max width is 500
  46287. *
  46288. * @type {number}
  46289. * @since 5.0.0
  46290. * @apioption responsive.rules.condition.maxWidth
  46291. */
  46292. /**
  46293. * The responsive rule applies if the chart height is greater than this.
  46294. *
  46295. * @type {number}
  46296. * @default 0
  46297. * @since 5.0.0
  46298. * @apioption responsive.rules.condition.minHeight
  46299. */
  46300. /**
  46301. * The responsive rule applies if the chart width is greater than this.
  46302. *
  46303. * @type {number}
  46304. * @default 0
  46305. * @since 5.0.0
  46306. * @apioption responsive.rules.condition.minWidth
  46307. */
  46308. /* eslint-disable no-invalid-this, valid-jsdoc */
  46309. /**
  46310. * Update the chart based on the current chart/document size and options for
  46311. * responsiveness.
  46312. *
  46313. * @private
  46314. * @function Highcharts.Chart#setResponsive
  46315. * @param {boolean} [redraw=true]
  46316. * @param {boolean} [reset=false]
  46317. * Reset by un-applying all rules. Chart.update resets all rules before applying
  46318. * updated options.
  46319. */
  46320. Chart.prototype.setResponsive = function (redraw, reset) {
  46321. var options = this.options.responsive,
  46322. ruleIds = [],
  46323. currentResponsive = this.currentResponsive,
  46324. currentRuleIds,
  46325. undoOptions;
  46326. if (!reset && options && options.rules) {
  46327. options.rules.forEach(function (rule) {
  46328. if (typeof rule._id === 'undefined') {
  46329. rule._id = uniqueKey();
  46330. }
  46331. this.matchResponsiveRule(rule, ruleIds /* , redraw */);
  46332. }, this);
  46333. }
  46334. // Merge matching rules
  46335. var mergedOptions = merge.apply(0,
  46336. ruleIds.map(function (ruleId) {
  46337. return find(options.rules,
  46338. function (rule) {
  46339. return rule._id === ruleId;
  46340. }).chartOptions;
  46341. }));
  46342. mergedOptions.isResponsiveOptions = true;
  46343. // Stringified key for the rules that currently apply.
  46344. ruleIds = (ruleIds.toString() || void 0);
  46345. currentRuleIds = currentResponsive && currentResponsive.ruleIds;
  46346. // Changes in what rules apply
  46347. if (ruleIds !== currentRuleIds) {
  46348. // Undo previous rules. Before we apply a new set of rules, we need to
  46349. // roll back completely to base options (#6291).
  46350. if (currentResponsive) {
  46351. this.update(currentResponsive.undoOptions, redraw, true);
  46352. }
  46353. if (ruleIds) {
  46354. // Get undo-options for matching rules
  46355. undoOptions = this.currentOptions(mergedOptions);
  46356. undoOptions.isResponsiveOptions = true;
  46357. this.currentResponsive = {
  46358. ruleIds: ruleIds,
  46359. mergedOptions: mergedOptions,
  46360. undoOptions: undoOptions
  46361. };
  46362. this.update(mergedOptions, redraw, true);
  46363. }
  46364. else {
  46365. this.currentResponsive = void 0;
  46366. }
  46367. }
  46368. };
  46369. /**
  46370. * Handle a single responsiveness rule.
  46371. *
  46372. * @private
  46373. * @function Highcharts.Chart#matchResponsiveRule
  46374. * @param {Highcharts.ResponsiveRulesOptions} rule
  46375. * @param {Array<string>} matches
  46376. */
  46377. Chart.prototype.matchResponsiveRule = function (rule, matches) {
  46378. var condition = rule.condition,
  46379. fn = condition.callback || function () {
  46380. return (this.chartWidth <= pick(condition.maxWidth,
  46381. Number.MAX_VALUE) &&
  46382. this.chartHeight <=
  46383. pick(condition.maxHeight,
  46384. Number.MAX_VALUE) &&
  46385. this.chartWidth >= pick(condition.minWidth, 0) &&
  46386. this.chartHeight >= pick(condition.minHeight, 0));
  46387. };
  46388. if (fn.call(this)) {
  46389. matches.push(rule._id);
  46390. }
  46391. };
  46392. /**
  46393. * Get the current values for a given set of options. Used before we update
  46394. * the chart with a new responsiveness rule.
  46395. *
  46396. * @todo Restore axis options (by id?). The matching of items in collections
  46397. * bears resemblance to the oneToOne matching in Chart.update. Probably we can
  46398. * refactor out that matching and reuse it in both functions.
  46399. *
  46400. * @private
  46401. * @function Highcharts.Chart#currentOptions
  46402. * @param {Highcharts.Options} options
  46403. * @return {Highcharts.Options}
  46404. */
  46405. Chart.prototype.currentOptions = function (options) {
  46406. var chart = this,
  46407. ret = {};
  46408. /**
  46409. * Recurse over a set of options and its current values,
  46410. * and store the current values in the ret object.
  46411. */
  46412. function getCurrent(options, curr, ret, depth) {
  46413. var i;
  46414. objectEach(options, function (val, key) {
  46415. if (!depth &&
  46416. chart.collectionsWithUpdate.indexOf(key) > -1 &&
  46417. curr[key]) {
  46418. val = splat(val);
  46419. ret[key] = [];
  46420. // Iterate over collections like series, xAxis or yAxis and map
  46421. // the items by index.
  46422. for (i = 0; i < Math.max(val.length, curr[key].length); i++) {
  46423. // Item exists in current data (#6347)
  46424. if (curr[key][i]) {
  46425. // If the item is missing from the new data, we need to
  46426. // save the whole config structure. Like when
  46427. // responsively updating from a dual axis layout to a
  46428. // single axis and back (#13544).
  46429. if (val[i] === void 0) {
  46430. ret[key][i] = curr[key][i];
  46431. // Otherwise, proceed
  46432. }
  46433. else {
  46434. ret[key][i] = {};
  46435. getCurrent(val[i], curr[key][i], ret[key][i], depth + 1);
  46436. }
  46437. }
  46438. }
  46439. }
  46440. else if (isObject(val)) {
  46441. ret[key] = isArray(val) ? [] : {};
  46442. getCurrent(val, curr[key] || {}, ret[key], depth + 1);
  46443. }
  46444. else if (typeof curr[key] === 'undefined') { // #10286
  46445. ret[key] = null;
  46446. }
  46447. else {
  46448. ret[key] = curr[key];
  46449. }
  46450. });
  46451. }
  46452. getCurrent(options, this.options, ret, 0);
  46453. return ret;
  46454. };
  46455. });
  46456. _registerModule(_modules, 'masters/highcharts.src.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js'], _modules['Core/Options.js'], _modules['Core/Animation/Fx.js'], _modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Renderer/HTML/AST.js'], _modules['Core/FormatUtilities.js'], _modules['Core/Renderer/SVG/SVGElement.js'], _modules['Core/Series/Series.js']], function (Highcharts, Utilities, Options, Fx, Animation, AST, FormatUtilities, SVGElement, Series) {
  46457. var G = Highcharts;
  46458. // Animation
  46459. G.animate = Animation.animate;
  46460. G.animObject = Animation.animObject;
  46461. G.getDeferredAnimation = Animation.getDeferredAnimation;
  46462. G.setAnimation = Animation.setAnimation;
  46463. G.stop = Animation.stop;
  46464. G.timers = Fx.timers;
  46465. // Classes
  46466. G.AST = AST;
  46467. G.Fx = Fx;
  46468. G.Series = Series;
  46469. G.SVGElement = SVGElement;
  46470. // Format Utilities
  46471. G.dateFormat = FormatUtilities.dateFormat;
  46472. G.format = FormatUtilities.format;
  46473. G.numberFormat = FormatUtilities.numberFormat;
  46474. // Options
  46475. G.defaultOptions = Options.defaultOptions;
  46476. G.getOptions = Options.getOptions;
  46477. G.time = Options.defaultTime;
  46478. G.setOptions = Options.setOptions;
  46479. // Utilities
  46480. G.addEvent = Utilities.addEvent;
  46481. G.arrayMax = Utilities.arrayMax;
  46482. G.arrayMin = Utilities.arrayMin;
  46483. G.attr = Utilities.attr;
  46484. G.clearTimeout = Utilities.clearTimeout;
  46485. G.correctFloat = Utilities.correctFloat;
  46486. G.createElement = Utilities.createElement;
  46487. G.css = Utilities.css;
  46488. G.defined = Utilities.defined;
  46489. G.destroyObjectProperties = Utilities.destroyObjectProperties;
  46490. G.discardElement = Utilities.discardElement;
  46491. G.erase = Utilities.erase;
  46492. G.error = Utilities.error;
  46493. G.extend = Utilities.extend;
  46494. G.extendClass = Utilities.extendClass;
  46495. G.find = Utilities.find;
  46496. G.fireEvent = Utilities.fireEvent;
  46497. G.getMagnitude = Utilities.getMagnitude;
  46498. G.getStyle = Utilities.getStyle;
  46499. G.inArray = Utilities.inArray;
  46500. G.isArray = Utilities.isArray;
  46501. G.isClass = Utilities.isClass;
  46502. G.isDOMElement = Utilities.isDOMElement;
  46503. G.isFunction = Utilities.isFunction;
  46504. G.isNumber = Utilities.isNumber;
  46505. G.isObject = Utilities.isObject;
  46506. G.isString = Utilities.isString;
  46507. G.keys = Utilities.keys;
  46508. G.merge = Utilities.merge;
  46509. G.normalizeTickInterval = Utilities.normalizeTickInterval;
  46510. G.objectEach = Utilities.objectEach;
  46511. G.offset = Utilities.offset;
  46512. G.pad = Utilities.pad;
  46513. G.pick = Utilities.pick;
  46514. G.pInt = Utilities.pInt;
  46515. G.relativeLength = Utilities.relativeLength;
  46516. G.removeEvent = Utilities.removeEvent;
  46517. G.splat = Utilities.splat;
  46518. G.stableSort = Utilities.stableSort;
  46519. G.syncTimeout = Utilities.syncTimeout;
  46520. G.timeUnits = Utilities.timeUnits;
  46521. G.uniqueKey = Utilities.uniqueKey;
  46522. G.useSerialIds = Utilities.useSerialIds;
  46523. G.wrap = Utilities.wrap;
  46524. return G;
  46525. });
  46526. _registerModule(_modules, 'Series/XRange/XRangePoint.js', [_modules['Core/Series/Point.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (Point, SeriesRegistry, U) {
  46527. /* *
  46528. *
  46529. * X-range series module
  46530. *
  46531. * (c) 2010-2021 Torstein Honsi, Lars A. V. Cabrera
  46532. *
  46533. * License: www.highcharts.com/license
  46534. *
  46535. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  46536. *
  46537. * */
  46538. var __extends = (this && this.__extends) || (function () {
  46539. var extendStatics = function (d,
  46540. b) {
  46541. extendStatics = Object.setPrototypeOf ||
  46542. ({ __proto__: [] } instanceof Array && function (d,
  46543. b) { d.__proto__ = b; }) ||
  46544. function (d,
  46545. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  46546. return extendStatics(d, b);
  46547. };
  46548. return function (d, b) {
  46549. extendStatics(d, b);
  46550. function __() { this.constructor = d; }
  46551. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  46552. };
  46553. })();
  46554. var ColumnSeries = SeriesRegistry.seriesTypes.column;
  46555. var extend = U.extend;
  46556. /* *
  46557. *
  46558. * Class
  46559. *
  46560. * */
  46561. var XRangePoint = /** @class */ (function (_super) {
  46562. __extends(XRangePoint, _super);
  46563. function XRangePoint() {
  46564. var _this = _super !== null && _super.apply(this,
  46565. arguments) || this;
  46566. /* *
  46567. *
  46568. * Properties
  46569. *
  46570. * */
  46571. _this.options = void 0;
  46572. _this.series = void 0;
  46573. return _this;
  46574. /* eslint-enable valid-jsdoc */
  46575. }
  46576. /* *
  46577. *
  46578. * Static properties
  46579. *
  46580. * */
  46581. /**
  46582. * Return color of a point based on its category.
  46583. *
  46584. * @private
  46585. * @function getColorByCategory
  46586. *
  46587. * @param {object} series
  46588. * The series which the point belongs to.
  46589. *
  46590. * @param {object} point
  46591. * The point to calculate its color for.
  46592. *
  46593. * @return {object}
  46594. * Returns an object containing the properties color and colorIndex.
  46595. */
  46596. XRangePoint.getColorByCategory = function (series, point) {
  46597. var colors = series.options.colors || series.chart.options.colors,
  46598. colorCount = colors ?
  46599. colors.length :
  46600. series.chart.options.chart.colorCount,
  46601. colorIndex = point.y % colorCount,
  46602. color = colors && colors[colorIndex];
  46603. return {
  46604. colorIndex: colorIndex,
  46605. color: color
  46606. };
  46607. };
  46608. /* *
  46609. *
  46610. * Functions
  46611. *
  46612. * */
  46613. /**
  46614. * The ending X value of the range point.
  46615. * @name Highcharts.Point#x2
  46616. * @type {number|undefined}
  46617. * @requires modules/xrange
  46618. */
  46619. /**
  46620. * Extend applyOptions so that `colorByPoint` for x-range means that one
  46621. * color is applied per Y axis category.
  46622. *
  46623. * @private
  46624. * @function Highcharts.Point#applyOptions
  46625. *
  46626. * @return {Highcharts.Series}
  46627. */
  46628. /* eslint-disable valid-jsdoc */
  46629. /**
  46630. * @private
  46631. */
  46632. XRangePoint.prototype.resolveColor = function () {
  46633. var series = this.series,
  46634. colorByPoint;
  46635. if (series.options.colorByPoint && !this.options.color) {
  46636. colorByPoint = XRangePoint.getColorByCategory(series, this);
  46637. if (!series.chart.styledMode) {
  46638. this.color = colorByPoint.color;
  46639. }
  46640. if (!this.options.colorIndex) {
  46641. this.colorIndex = colorByPoint.colorIndex;
  46642. }
  46643. }
  46644. else if (!this.color) {
  46645. this.color = series.color;
  46646. }
  46647. };
  46648. /**
  46649. * Extend init to have y default to 0.
  46650. *
  46651. * @private
  46652. * @function Highcharts.Point#init
  46653. *
  46654. * @return {Highcharts.Point}
  46655. */
  46656. XRangePoint.prototype.init = function () {
  46657. Point.prototype.init.apply(this, arguments);
  46658. if (!this.y) {
  46659. this.y = 0;
  46660. }
  46661. return this;
  46662. };
  46663. /**
  46664. * @private
  46665. * @function Highcharts.Point#setState
  46666. */
  46667. XRangePoint.prototype.setState = function () {
  46668. Point.prototype.setState.apply(this, arguments);
  46669. this.series.drawPoint(this, this.series.getAnimationVerb());
  46670. };
  46671. /**
  46672. * @private
  46673. * @function Highcharts.Point#getLabelConfig
  46674. *
  46675. * @return {Highcharts.PointLabelObject}
  46676. */
  46677. // Add x2 and yCategory to the available properties for tooltip formats
  46678. XRangePoint.prototype.getLabelConfig = function () {
  46679. var point = this,
  46680. cfg = Point.prototype.getLabelConfig.call(point),
  46681. yCats = point.series.yAxis.categories;
  46682. cfg.x2 = point.x2;
  46683. cfg.yCategory = point.yCategory = yCats && yCats[point.y];
  46684. return cfg;
  46685. };
  46686. /**
  46687. * @private
  46688. * @function Highcharts.Point#isValid
  46689. *
  46690. * @return {boolean}
  46691. */
  46692. XRangePoint.prototype.isValid = function () {
  46693. return typeof this.x === 'number' &&
  46694. typeof this.x2 === 'number';
  46695. };
  46696. return XRangePoint;
  46697. }(ColumnSeries.prototype.pointClass));
  46698. extend(XRangePoint.prototype, {
  46699. tooltipDateKeys: ['x', 'x2']
  46700. });
  46701. /* *
  46702. *
  46703. * Default Export
  46704. *
  46705. * */
  46706. return XRangePoint;
  46707. });
  46708. _registerModule(_modules, 'Series/XRange/XRangeComposition.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Utilities.js']], function (Axis, U) {
  46709. /* *
  46710. *
  46711. * X-range series module
  46712. *
  46713. * (c) 2010-2021 Torstein Honsi, Lars A. V. Cabrera
  46714. *
  46715. * License: www.highcharts.com/license
  46716. *
  46717. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  46718. *
  46719. * */
  46720. /* *
  46721. *
  46722. * Imports
  46723. *
  46724. * */
  46725. /* *
  46726. *
  46727. * Imports
  46728. *
  46729. * */
  46730. var addEvent = U.addEvent,
  46731. pick = U.pick;
  46732. /**
  46733. * Max x2 should be considered in xAxis extremes
  46734. */
  46735. addEvent(Axis, 'afterGetSeriesExtremes', function () {
  46736. var axis = this, // eslint-disable-line no-invalid-this
  46737. axisSeries = axis.series,
  46738. dataMax,
  46739. modMax;
  46740. if (axis.isXAxis) {
  46741. dataMax = pick(axis.dataMax, -Number.MAX_VALUE);
  46742. axisSeries.forEach(function (series) {
  46743. if (series.x2Data) {
  46744. series.x2Data
  46745. .forEach(function (val) {
  46746. if (val > dataMax) {
  46747. dataMax = val;
  46748. modMax = true;
  46749. }
  46750. });
  46751. }
  46752. });
  46753. if (modMax) {
  46754. axis.dataMax = dataMax;
  46755. }
  46756. }
  46757. });
  46758. });
  46759. _registerModule(_modules, 'Series/XRange/XRangeSeries.js', [_modules['Core/Globals.js'], _modules['Core/Color/Color.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js'], _modules['Series/XRange/XRangePoint.js']], function (H, Color, SeriesRegistry, U, XRangePoint) {
  46760. /* *
  46761. *
  46762. * X-range series module
  46763. *
  46764. * (c) 2010-2021 Torstein Honsi, Lars A. V. Cabrera
  46765. *
  46766. * License: www.highcharts.com/license
  46767. *
  46768. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  46769. *
  46770. * */
  46771. var __extends = (this && this.__extends) || (function () {
  46772. var extendStatics = function (d,
  46773. b) {
  46774. extendStatics = Object.setPrototypeOf ||
  46775. ({ __proto__: [] } instanceof Array && function (d,
  46776. b) { d.__proto__ = b; }) ||
  46777. function (d,
  46778. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  46779. return extendStatics(d, b);
  46780. };
  46781. return function (d, b) {
  46782. extendStatics(d, b);
  46783. function __() { this.constructor = d; }
  46784. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  46785. };
  46786. })();
  46787. var color = Color.parse;
  46788. var Series = SeriesRegistry.series,
  46789. ColumnSeries = SeriesRegistry.seriesTypes.column;
  46790. var columnProto = ColumnSeries.prototype;
  46791. var clamp = U.clamp,
  46792. correctFloat = U.correctFloat,
  46793. defined = U.defined,
  46794. extend = U.extend,
  46795. find = U.find,
  46796. isNumber = U.isNumber,
  46797. isObject = U.isObject,
  46798. merge = U.merge,
  46799. pick = U.pick;
  46800. /* *
  46801. * @interface Highcharts.PointOptionsObject in parts/Point.ts
  46802. */ /**
  46803. * The ending X value of the range point.
  46804. * @name Highcharts.PointOptionsObject#x2
  46805. * @type {number|undefined}
  46806. * @requires modules/xrange
  46807. */
  46808. /**
  46809. * @private
  46810. * @class
  46811. * @name Highcharts.seriesTypes.xrange
  46812. *
  46813. * @augments Highcharts.Series
  46814. */
  46815. var XRangeSeries = /** @class */ (function (_super) {
  46816. __extends(XRangeSeries, _super);
  46817. function XRangeSeries() {
  46818. var _this = _super !== null && _super.apply(this,
  46819. arguments) || this;
  46820. /* *
  46821. *
  46822. * Properties
  46823. *
  46824. * */
  46825. _this.data = void 0;
  46826. _this.options = void 0;
  46827. _this.points = void 0;
  46828. return _this;
  46829. /*
  46830. // Override to remove stroke from points. For partial fill.
  46831. pointAttribs: function () {
  46832. let series = this,
  46833. retVal = columnType.prototype.pointAttribs
  46834. .apply(series, arguments);
  46835. //retVal['stroke-width'] = 0;
  46836. return retVal;
  46837. }
  46838. //*/
  46839. /* eslint-enable valid-jsdoc */
  46840. }
  46841. /* *
  46842. *
  46843. * Functions
  46844. *
  46845. * */
  46846. /* eslint-disable valid-jsdoc */
  46847. /**
  46848. * @private
  46849. * @function Highcarts.seriesTypes.xrange#init
  46850. * @return {void}
  46851. */
  46852. XRangeSeries.prototype.init = function () {
  46853. ColumnSeries.prototype.init.apply(this, arguments);
  46854. this.options.stacking = void 0; // #13161
  46855. };
  46856. /**
  46857. * Borrow the column series metrics, but with swapped axes. This gives
  46858. * free access to features like groupPadding, grouping, pointWidth etc.
  46859. *
  46860. * @private
  46861. * @function Highcharts.Series#getColumnMetrics
  46862. *
  46863. * @return {Highcharts.ColumnMetricsObject}
  46864. */
  46865. XRangeSeries.prototype.getColumnMetrics = function () {
  46866. var metrics,
  46867. chart = this.chart;
  46868. /**
  46869. * @private
  46870. */
  46871. function swapAxes() {
  46872. chart.series.forEach(function (s) {
  46873. var xAxis = s.xAxis;
  46874. s.xAxis = s.yAxis;
  46875. s.yAxis = xAxis;
  46876. });
  46877. }
  46878. swapAxes();
  46879. metrics = columnProto.getColumnMetrics.call(this);
  46880. swapAxes();
  46881. return metrics;
  46882. };
  46883. /**
  46884. * Override cropData to show a point where x or x2 is outside visible
  46885. * range, but one of them is inside.
  46886. *
  46887. * @private
  46888. * @function Highcharts.Series#cropData
  46889. *
  46890. * @param {Array<number>} xData
  46891. *
  46892. * @param {Array<number>} yData
  46893. *
  46894. * @param {number} min
  46895. *
  46896. * @param {number} max
  46897. *
  46898. * @param {number} [cropShoulder]
  46899. *
  46900. * @return {*}
  46901. */
  46902. XRangeSeries.prototype.cropData = function (xData, yData, min, max) {
  46903. // Replace xData with x2Data to find the appropriate cropStart
  46904. var cropData = Series.prototype.cropData,
  46905. crop = cropData.call(this,
  46906. this.x2Data,
  46907. yData,
  46908. min,
  46909. max);
  46910. // Re-insert the cropped xData
  46911. crop.xData = xData.slice(crop.start, crop.end);
  46912. return crop;
  46913. };
  46914. /**
  46915. * Finds the index of an existing point that matches the given point
  46916. * options.
  46917. *
  46918. * @private
  46919. * @function Highcharts.Series#findPointIndex
  46920. * @param {object} options The options of the point.
  46921. * @returns {number|undefined} Returns index of a matching point,
  46922. * returns undefined if no match is found.
  46923. */
  46924. XRangeSeries.prototype.findPointIndex = function (options) {
  46925. var _a = this,
  46926. cropped = _a.cropped,
  46927. cropStart = _a.cropStart,
  46928. points = _a.points;
  46929. var id = options.id;
  46930. var pointIndex;
  46931. if (id) {
  46932. var point = find(points,
  46933. function (point) {
  46934. return point.id === id;
  46935. });
  46936. pointIndex = point ? point.index : void 0;
  46937. }
  46938. if (typeof pointIndex === 'undefined') {
  46939. var point = find(points,
  46940. function (point) {
  46941. return (point.x === options.x &&
  46942. point.x2 === options.x2 &&
  46943. !point.touched);
  46944. });
  46945. pointIndex = point ? point.index : void 0;
  46946. }
  46947. // Reduce pointIndex if data is cropped
  46948. if (cropped &&
  46949. isNumber(pointIndex) &&
  46950. isNumber(cropStart) &&
  46951. pointIndex >= cropStart) {
  46952. pointIndex -= cropStart;
  46953. }
  46954. return pointIndex;
  46955. };
  46956. /**
  46957. * @private
  46958. * @function Highcharts.Series#translatePoint
  46959. *
  46960. * @param {Highcharts.Point} point
  46961. */
  46962. XRangeSeries.prototype.translatePoint = function (point) {
  46963. var series = this,
  46964. xAxis = series.xAxis,
  46965. yAxis = series.yAxis,
  46966. metrics = series.columnMetrics,
  46967. options = series.options,
  46968. minPointLength = options.minPointLength || 0,
  46969. oldColWidth = (point.shapeArgs && point.shapeArgs.width || 0) / 2,
  46970. seriesXOffset = series.pointXOffset = metrics.offset,
  46971. plotX = point.plotX,
  46972. posX = pick(point.x2,
  46973. point.x + (point.len || 0)),
  46974. plotX2 = xAxis.translate(posX, 0, 0, 0, 1),
  46975. length = Math.abs(plotX2 - plotX),
  46976. widthDifference,
  46977. partialFill,
  46978. inverted = this.chart.inverted,
  46979. borderWidth = pick(options.borderWidth, 1),
  46980. crisper = borderWidth % 2 / 2,
  46981. yOffset = metrics.offset,
  46982. pointHeight = Math.round(metrics.width),
  46983. dlLeft,
  46984. dlRight,
  46985. dlWidth,
  46986. clipRectWidth,
  46987. tooltipYOffset;
  46988. if (minPointLength) {
  46989. widthDifference = minPointLength - length;
  46990. if (widthDifference < 0) {
  46991. widthDifference = 0;
  46992. }
  46993. plotX -= widthDifference / 2;
  46994. plotX2 += widthDifference / 2;
  46995. }
  46996. plotX = Math.max(plotX, -10);
  46997. plotX2 = clamp(plotX2, -10, xAxis.len + 10);
  46998. // Handle individual pointWidth
  46999. if (defined(point.options.pointWidth)) {
  47000. yOffset -= ((Math.ceil(point.options.pointWidth) - pointHeight) / 2);
  47001. pointHeight = Math.ceil(point.options.pointWidth);
  47002. }
  47003. // Apply pointPlacement to the Y axis
  47004. if (options.pointPlacement &&
  47005. isNumber(point.plotY) &&
  47006. yAxis.categories) {
  47007. point.plotY = yAxis.translate(point.y, 0, 1, 0, 1, options.pointPlacement);
  47008. }
  47009. var shapeArgs = {
  47010. x: Math.floor(Math.min(plotX,
  47011. plotX2)) + crisper,
  47012. y: Math.floor(point.plotY + yOffset) + crisper,
  47013. width: Math.round(Math.abs(plotX2 - plotX)),
  47014. height: pointHeight,
  47015. r: series.options.borderRadius
  47016. };
  47017. point.shapeArgs = shapeArgs;
  47018. // Move tooltip to default position
  47019. if (!inverted) {
  47020. point.tooltipPos[0] -= oldColWidth +
  47021. seriesXOffset -
  47022. shapeArgs.width / 2;
  47023. }
  47024. else {
  47025. point.tooltipPos[1] += seriesXOffset +
  47026. oldColWidth;
  47027. }
  47028. // Align data labels inside the shape and inside the plot area
  47029. dlLeft = shapeArgs.x;
  47030. dlRight = dlLeft + shapeArgs.width;
  47031. if (dlLeft < 0 || dlRight > xAxis.len) {
  47032. dlLeft = clamp(dlLeft, 0, xAxis.len);
  47033. dlRight = clamp(dlRight, 0, xAxis.len);
  47034. dlWidth = dlRight - dlLeft;
  47035. point.dlBox = merge(shapeArgs, {
  47036. x: dlLeft,
  47037. width: dlRight - dlLeft,
  47038. centerX: dlWidth ? dlWidth / 2 : null
  47039. });
  47040. }
  47041. else {
  47042. point.dlBox = null;
  47043. }
  47044. // Tooltip position
  47045. var tooltipPos = point.tooltipPos;
  47046. var xIndex = !inverted ? 0 : 1;
  47047. var yIndex = !inverted ? 1 : 0;
  47048. tooltipYOffset = series.columnMetrics ?
  47049. series.columnMetrics.offset : -metrics.width / 2;
  47050. // Centering tooltip position (#14147)
  47051. if (!inverted) {
  47052. tooltipPos[xIndex] += (xAxis.reversed ? -1 : 0) * shapeArgs.width;
  47053. }
  47054. else {
  47055. tooltipPos[xIndex] += shapeArgs.width / 2;
  47056. }
  47057. tooltipPos[yIndex] = clamp(tooltipPos[yIndex] + ((inverted ? -1 : 1) * tooltipYOffset), 0, yAxis.len - 1);
  47058. // Add a partShapeArgs to the point, based on the shapeArgs property
  47059. partialFill = point.partialFill;
  47060. if (partialFill) {
  47061. // Get the partial fill amount
  47062. if (isObject(partialFill)) {
  47063. partialFill = partialFill.amount;
  47064. }
  47065. // If it was not a number, assume 0
  47066. if (!isNumber(partialFill)) {
  47067. partialFill = 0;
  47068. }
  47069. point.partShapeArgs = merge(shapeArgs, {
  47070. r: series.options.borderRadius
  47071. });
  47072. clipRectWidth = Math.max(Math.round(length * partialFill + point.plotX -
  47073. plotX), 0);
  47074. point.clipRectArgs = {
  47075. x: xAxis.reversed ? // #10717
  47076. shapeArgs.x + length - clipRectWidth :
  47077. shapeArgs.x,
  47078. y: shapeArgs.y,
  47079. width: clipRectWidth,
  47080. height: shapeArgs.height
  47081. };
  47082. }
  47083. };
  47084. /**
  47085. * @private
  47086. * @function Highcharts.Series#translate
  47087. */
  47088. XRangeSeries.prototype.translate = function () {
  47089. columnProto.translate.apply(this, arguments);
  47090. this.points.forEach(function (point) {
  47091. this.translatePoint(point);
  47092. }, this);
  47093. };
  47094. /**
  47095. * Draws a single point in the series. Needed for partial fill.
  47096. *
  47097. * This override turns point.graphic into a group containing the
  47098. * original graphic and an overlay displaying the partial fill.
  47099. *
  47100. * @private
  47101. * @function Highcharts.Series#drawPoint
  47102. *
  47103. * @param {Highcharts.Point} point
  47104. * An instance of Point in the series.
  47105. *
  47106. * @param {"animate"|"attr"} verb
  47107. * 'animate' (animates changes) or 'attr' (sets options)
  47108. */
  47109. XRangeSeries.prototype.drawPoint = function (point, verb) {
  47110. var series = this,
  47111. seriesOpts = series.options,
  47112. renderer = series.chart.renderer,
  47113. graphic = point.graphic,
  47114. type = point.shapeType,
  47115. shapeArgs = point.shapeArgs,
  47116. partShapeArgs = point.partShapeArgs,
  47117. clipRectArgs = point.clipRectArgs,
  47118. pfOptions = point.partialFill,
  47119. cutOff = seriesOpts.stacking && !seriesOpts.borderRadius,
  47120. pointState = point.state,
  47121. stateOpts = (seriesOpts.states[pointState || 'normal'] ||
  47122. {}),
  47123. pointStateVerb = typeof pointState === 'undefined' ?
  47124. 'attr' : verb,
  47125. pointAttr = series.pointAttribs(point,
  47126. pointState),
  47127. animation = pick(series.chart.options.chart.animation,
  47128. stateOpts.animation),
  47129. fill;
  47130. if (!point.isNull && point.visible !== false) {
  47131. // Original graphic
  47132. if (graphic) { // update
  47133. graphic.rect[verb](shapeArgs);
  47134. }
  47135. else {
  47136. point.graphic = graphic = renderer.g('point')
  47137. .addClass(point.getClassName())
  47138. .add(point.group || series.group);
  47139. graphic.rect = renderer[type](merge(shapeArgs))
  47140. .addClass(point.getClassName())
  47141. .addClass('highcharts-partfill-original')
  47142. .add(graphic);
  47143. }
  47144. // Partial fill graphic
  47145. if (partShapeArgs) {
  47146. if (graphic.partRect) {
  47147. graphic.partRect[verb](merge(partShapeArgs));
  47148. graphic.partialClipRect[verb](merge(clipRectArgs));
  47149. }
  47150. else {
  47151. graphic.partialClipRect = renderer.clipRect(clipRectArgs.x, clipRectArgs.y, clipRectArgs.width, clipRectArgs.height);
  47152. graphic.partRect =
  47153. renderer[type](partShapeArgs)
  47154. .addClass('highcharts-partfill-overlay')
  47155. .add(graphic)
  47156. .clip(graphic.partialClipRect);
  47157. }
  47158. }
  47159. // Presentational
  47160. if (!series.chart.styledMode) {
  47161. graphic
  47162. .rect[verb](pointAttr, animation)
  47163. .shadow(seriesOpts.shadow, null, cutOff);
  47164. if (partShapeArgs) {
  47165. // Ensure pfOptions is an object
  47166. if (!isObject(pfOptions)) {
  47167. pfOptions = {};
  47168. }
  47169. if (isObject(seriesOpts.partialFill)) {
  47170. pfOptions = merge(seriesOpts.partialFill, pfOptions);
  47171. }
  47172. fill = (pfOptions.fill ||
  47173. color(pointAttr.fill).brighten(-0.3).get() ||
  47174. color(point.color || series.color)
  47175. .brighten(-0.3).get());
  47176. pointAttr.fill = fill;
  47177. graphic
  47178. .partRect[pointStateVerb](pointAttr, animation)
  47179. .shadow(seriesOpts.shadow, null, cutOff);
  47180. }
  47181. }
  47182. }
  47183. else if (graphic) {
  47184. point.graphic = graphic.destroy(); // #1269
  47185. }
  47186. };
  47187. /**
  47188. * @private
  47189. * @function Highcharts.Series#drawPoints
  47190. */
  47191. XRangeSeries.prototype.drawPoints = function () {
  47192. var series = this,
  47193. verb = series.getAnimationVerb();
  47194. // Draw the columns
  47195. series.points.forEach(function (point) {
  47196. series.drawPoint(point, verb);
  47197. });
  47198. };
  47199. /**
  47200. * Returns "animate", or "attr" if the number of points is above the
  47201. * animation limit.
  47202. *
  47203. * @private
  47204. * @function Highcharts.Series#getAnimationVerb
  47205. *
  47206. * @return {string}
  47207. */
  47208. XRangeSeries.prototype.getAnimationVerb = function () {
  47209. return (this.chart.pointCount < (this.options.animationLimit || 250) ?
  47210. 'animate' :
  47211. 'attr');
  47212. };
  47213. /**
  47214. * @private
  47215. * @function Highcharts.XRangeSeries#isPointInside
  47216. */
  47217. XRangeSeries.prototype.isPointInside = function (point) {
  47218. var shapeArgs = point.shapeArgs,
  47219. plotX = point.plotX,
  47220. plotY = point.plotY;
  47221. if (!shapeArgs) {
  47222. return _super.prototype.isPointInside.apply(this, arguments);
  47223. }
  47224. var isInside = typeof plotX !== 'undefined' &&
  47225. typeof plotY !== 'undefined' &&
  47226. plotY >= 0 &&
  47227. plotY <= this.yAxis.len &&
  47228. (shapeArgs.x || 0) + (shapeArgs.width || 0) >= 0 &&
  47229. plotX <= this.xAxis.len;
  47230. return isInside;
  47231. };
  47232. /* *
  47233. *
  47234. * Static properties
  47235. *
  47236. * */
  47237. /**
  47238. * The X-range series displays ranges on the X axis, typically time
  47239. * intervals with a start and end date.
  47240. *
  47241. * @sample {highcharts} highcharts/demo/x-range/
  47242. * X-range
  47243. * @sample {highcharts} highcharts/css/x-range/
  47244. * Styled mode X-range
  47245. * @sample {highcharts} highcharts/chart/inverted-xrange/
  47246. * Inverted X-range
  47247. *
  47248. * @extends plotOptions.column
  47249. * @since 6.0.0
  47250. * @product highcharts highstock gantt
  47251. * @excluding boostThreshold, crisp, cropThreshold, depth, edgeColor,
  47252. * edgeWidth, findNearestPointBy, getExtremesFromAll,
  47253. * negativeColor, pointInterval, pointIntervalUnit,
  47254. * pointPlacement, pointRange, pointStart, softThreshold,
  47255. * stacking, threshold, data, dataSorting, boostBlending
  47256. * @requires modules/xrange
  47257. * @optionparent plotOptions.xrange
  47258. */
  47259. XRangeSeries.defaultOptions = merge(ColumnSeries.defaultOptions, {
  47260. /**
  47261. * A partial fill for each point, typically used to visualize how much
  47262. * of a task is performed. The partial fill object can be set either on
  47263. * series or point level.
  47264. *
  47265. * @sample {highcharts} highcharts/demo/x-range
  47266. * X-range with partial fill
  47267. *
  47268. * @product highcharts highstock gantt
  47269. * @apioption plotOptions.xrange.partialFill
  47270. */
  47271. /**
  47272. * The fill color to be used for partial fills. Defaults to a darker
  47273. * shade of the point color.
  47274. *
  47275. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  47276. * @product highcharts highstock gantt
  47277. * @apioption plotOptions.xrange.partialFill.fill
  47278. */
  47279. /**
  47280. * A partial fill for each point, typically used to visualize how much
  47281. * of a task is performed. See [completed](series.gantt.data.completed).
  47282. *
  47283. * @sample gantt/demo/progress-indicator
  47284. * Gantt with progress indicator
  47285. *
  47286. * @product gantt
  47287. * @apioption plotOptions.gantt.partialFill
  47288. */
  47289. /**
  47290. * In an X-range series, this option makes all points of the same Y-axis
  47291. * category the same color.
  47292. */
  47293. colorByPoint: true,
  47294. dataLabels: {
  47295. formatter: function () {
  47296. var point = this.point,
  47297. amount = point.partialFill;
  47298. if (isObject(amount)) {
  47299. amount = amount.amount;
  47300. }
  47301. if (isNumber(amount) && amount > 0) {
  47302. return correctFloat(amount * 100) + '%';
  47303. }
  47304. },
  47305. inside: true,
  47306. verticalAlign: 'middle'
  47307. },
  47308. tooltip: {
  47309. headerFormat: '<span style="font-size: 10px">{point.x} - {point.x2}</span><br/>',
  47310. pointFormat: '<span style="color:{point.color}">\u25CF</span> {series.name}: <b>{point.yCategory}</b><br/>'
  47311. },
  47312. borderRadius: 3,
  47313. pointRange: 0
  47314. });
  47315. return XRangeSeries;
  47316. }(ColumnSeries));
  47317. extend(XRangeSeries.prototype, {
  47318. type: 'xrange',
  47319. parallelArrays: ['x', 'x2', 'y'],
  47320. requireSorting: false,
  47321. animate: Series.prototype.animate,
  47322. cropShoulder: 1,
  47323. getExtremesFromAll: true,
  47324. autoIncrement: H.noop,
  47325. buildKDTree: H.noop,
  47326. pointClass: XRangePoint
  47327. });
  47328. SeriesRegistry.registerSeriesType('xrange', XRangeSeries);
  47329. /* *
  47330. *
  47331. * Default Export
  47332. *
  47333. * */
  47334. /* *
  47335. *
  47336. * API Options
  47337. *
  47338. * */
  47339. /**
  47340. * An `xrange` series. If the [type](#series.xrange.type) option is not
  47341. * specified, it is inherited from [chart.type](#chart.type).
  47342. *
  47343. * @extends series,plotOptions.xrange
  47344. * @excluding boostThreshold, crisp, cropThreshold, depth, edgeColor, edgeWidth,
  47345. * findNearestPointBy, getExtremesFromAll, negativeColor,
  47346. * pointInterval, pointIntervalUnit, pointPlacement, pointRange,
  47347. * pointStart, softThreshold, stacking, threshold, dataSorting,
  47348. * boostBlending
  47349. * @product highcharts highstock gantt
  47350. * @requires modules/xrange
  47351. * @apioption series.xrange
  47352. */
  47353. /**
  47354. * An array of data points for the series. For the `xrange` series type,
  47355. * points can be given in the following ways:
  47356. *
  47357. * 1. An array of objects with named values. The objects are point configuration
  47358. * objects as seen below.
  47359. * ```js
  47360. * data: [{
  47361. * x: Date.UTC(2017, 0, 1),
  47362. * x2: Date.UTC(2017, 0, 3),
  47363. * name: "Test",
  47364. * y: 0,
  47365. * color: "#00FF00"
  47366. * }, {
  47367. * x: Date.UTC(2017, 0, 4),
  47368. * x2: Date.UTC(2017, 0, 5),
  47369. * name: "Deploy",
  47370. * y: 1,
  47371. * color: "#FF0000"
  47372. * }]
  47373. * ```
  47374. *
  47375. * @sample {highcharts} highcharts/series/data-array-of-objects/
  47376. * Config objects
  47377. *
  47378. * @declare Highcharts.XrangePointOptionsObject
  47379. * @type {Array<*>}
  47380. * @extends series.line.data
  47381. * @product highcharts highstock gantt
  47382. * @apioption series.xrange.data
  47383. */
  47384. /**
  47385. * The starting X value of the range point.
  47386. *
  47387. * @sample {highcharts} highcharts/demo/x-range
  47388. * X-range
  47389. *
  47390. * @type {number}
  47391. * @product highcharts highstock gantt
  47392. * @apioption series.xrange.data.x
  47393. */
  47394. /**
  47395. * The ending X value of the range point.
  47396. *
  47397. * @sample {highcharts} highcharts/demo/x-range
  47398. * X-range
  47399. *
  47400. * @type {number}
  47401. * @product highcharts highstock gantt
  47402. * @apioption series.xrange.data.x2
  47403. */
  47404. /**
  47405. * The Y value of the range point.
  47406. *
  47407. * @sample {highcharts} highcharts/demo/x-range
  47408. * X-range
  47409. *
  47410. * @type {number}
  47411. * @product highcharts highstock gantt
  47412. * @apioption series.xrange.data.y
  47413. */
  47414. /**
  47415. * A partial fill for each point, typically used to visualize how much of
  47416. * a task is performed. The partial fill object can be set either on series
  47417. * or point level.
  47418. *
  47419. * @sample {highcharts} highcharts/demo/x-range
  47420. * X-range with partial fill
  47421. *
  47422. * @declare Highcharts.XrangePointPartialFillOptionsObject
  47423. * @product highcharts highstock gantt
  47424. * @apioption series.xrange.data.partialFill
  47425. */
  47426. /**
  47427. * The amount of the X-range point to be filled. Values can be 0-1 and are
  47428. * converted to percentages in the default data label formatter.
  47429. *
  47430. * @type {number}
  47431. * @product highcharts highstock gantt
  47432. * @apioption series.xrange.data.partialFill.amount
  47433. */
  47434. /**
  47435. * The fill color to be used for partial fills. Defaults to a darker shade
  47436. * of the point color.
  47437. *
  47438. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  47439. * @product highcharts highstock gantt
  47440. * @apioption series.xrange.data.partialFill.fill
  47441. */
  47442. ''; // adds doclets above to transpiled file
  47443. return XRangeSeries;
  47444. });
  47445. _registerModule(_modules, 'Series/Gantt/GanttPoint.js', [_modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (SeriesRegistry, U) {
  47446. /* *
  47447. *
  47448. * (c) 2016-2021 Highsoft AS
  47449. *
  47450. * Author: Lars A. V. Cabrera
  47451. *
  47452. * License: www.highcharts.com/license
  47453. *
  47454. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  47455. *
  47456. * */
  47457. var __extends = (this && this.__extends) || (function () {
  47458. var extendStatics = function (d,
  47459. b) {
  47460. extendStatics = Object.setPrototypeOf ||
  47461. ({ __proto__: [] } instanceof Array && function (d,
  47462. b) { d.__proto__ = b; }) ||
  47463. function (d,
  47464. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  47465. return extendStatics(d, b);
  47466. };
  47467. return function (d, b) {
  47468. extendStatics(d, b);
  47469. function __() { this.constructor = d; }
  47470. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  47471. };
  47472. })();
  47473. var XRangePoint = SeriesRegistry.seriesTypes.xrange.prototype.pointClass;
  47474. var pick = U.pick;
  47475. /* *
  47476. *
  47477. * Class
  47478. *
  47479. * */
  47480. var GanttPoint = /** @class */ (function (_super) {
  47481. __extends(GanttPoint, _super);
  47482. function GanttPoint() {
  47483. /* *
  47484. *
  47485. * Static Functions
  47486. *
  47487. * */
  47488. var _this = _super !== null && _super.apply(this,
  47489. arguments) || this;
  47490. _this.options = void 0;
  47491. _this.series = void 0;
  47492. return _this;
  47493. /* eslint-enable valid-jsdoc */
  47494. }
  47495. /* eslint-disable valid-jsdoc */
  47496. /**
  47497. * @private
  47498. */
  47499. GanttPoint.setGanttPointAliases = function (options) {
  47500. /**
  47501. * Add a value to options if the value exists.
  47502. * @private
  47503. */
  47504. function addIfExists(prop, val) {
  47505. if (typeof val !== 'undefined') {
  47506. options[prop] = val;
  47507. }
  47508. }
  47509. addIfExists('x', pick(options.start, options.x));
  47510. addIfExists('x2', pick(options.end, options.x2));
  47511. addIfExists('partialFill', pick(options.completed, options.partialFill));
  47512. };
  47513. /* *
  47514. *
  47515. * Functions
  47516. *
  47517. * */
  47518. /* eslint-disable valid-jsdoc */
  47519. /**
  47520. * Applies the options containing the x and y data and possible some
  47521. * extra properties. This is called on point init or from point.update.
  47522. *
  47523. * @private
  47524. * @function Highcharts.Point#applyOptions
  47525. *
  47526. * @param {object} options
  47527. * The point options
  47528. *
  47529. * @param {number} x
  47530. * The x value
  47531. *
  47532. * @return {Highcharts.Point}
  47533. * The Point instance
  47534. */
  47535. GanttPoint.prototype.applyOptions = function (options, x) {
  47536. var point = this,
  47537. ganttPoint;
  47538. ganttPoint = _super.prototype.applyOptions.call(point, options, x);
  47539. GanttPoint.setGanttPointAliases(ganttPoint);
  47540. return ganttPoint;
  47541. };
  47542. GanttPoint.prototype.isValid = function () {
  47543. return ((typeof this.start === 'number' ||
  47544. typeof this.x === 'number') &&
  47545. (typeof this.end === 'number' ||
  47546. typeof this.x2 === 'number' ||
  47547. this.milestone));
  47548. };
  47549. return GanttPoint;
  47550. }(XRangePoint));
  47551. /* *
  47552. *
  47553. * Default Export
  47554. *
  47555. * */
  47556. return GanttPoint;
  47557. });
  47558. _registerModule(_modules, 'Gantt/Tree.js', [_modules['Core/Utilities.js']], function (U) {
  47559. /* *
  47560. *
  47561. * (c) 2016-2021 Highsoft AS
  47562. *
  47563. * Authors: Jon Arild Nygard
  47564. *
  47565. * License: www.highcharts.com/license
  47566. *
  47567. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  47568. *
  47569. * */
  47570. /* eslint no-console: 0 */
  47571. var extend = U.extend,
  47572. isNumber = U.isNumber,
  47573. pick = U.pick;
  47574. /**
  47575. * Creates an object map from parent id to childrens index.
  47576. *
  47577. * @private
  47578. * @function Highcharts.Tree#getListOfParents
  47579. *
  47580. * @param {Array<*>} data
  47581. * List of points set in options. `Array.parent` is parent id of point.
  47582. *
  47583. * @param {Array<string>} ids
  47584. * List of all point ids.
  47585. *
  47586. * @return {Highcharts.Dictionary<Array<*>>}
  47587. * Map from parent id to children index in data
  47588. */
  47589. var getListOfParents = function (data,
  47590. ids) {
  47591. var listOfParents = data.reduce(function (prev,
  47592. curr) {
  47593. var parent = pick(curr.parent, '');
  47594. if (typeof prev[parent] === 'undefined') {
  47595. prev[parent] = [];
  47596. }
  47597. prev[parent].push(curr);
  47598. return prev;
  47599. }, {}), parents = Object.keys(listOfParents);
  47600. // If parent does not exist, hoist parent to root of tree.
  47601. parents.forEach(function (parent, list) {
  47602. var children = listOfParents[parent];
  47603. if ((parent !== '') && (ids.indexOf(parent) === -1)) {
  47604. children.forEach(function (child) {
  47605. list[''].push(child);
  47606. });
  47607. delete list[parent];
  47608. }
  47609. });
  47610. return listOfParents;
  47611. };
  47612. var getNode = function (id,
  47613. parent,
  47614. level,
  47615. data,
  47616. mapOfIdToChildren,
  47617. options) {
  47618. var descendants = 0,
  47619. height = 0,
  47620. after = options && options.after,
  47621. before = options && options.before,
  47622. node = {
  47623. data: data,
  47624. depth: level - 1,
  47625. id: id,
  47626. level: level,
  47627. parent: parent
  47628. },
  47629. start,
  47630. end,
  47631. children;
  47632. // Allow custom logic before the children has been created.
  47633. if (typeof before === 'function') {
  47634. before(node, options);
  47635. }
  47636. // Call getNode recursively on the children. Calulate the height of the
  47637. // node, and the number of descendants.
  47638. children = ((mapOfIdToChildren[id] || [])).map(function (child) {
  47639. var node = getNode(child.id,
  47640. id, (level + 1),
  47641. child,
  47642. mapOfIdToChildren,
  47643. options),
  47644. childStart = child.start,
  47645. childEnd = (child.milestone === true ?
  47646. childStart :
  47647. child.end);
  47648. // Start should be the lowest child.start.
  47649. start = ((!isNumber(start) || childStart < start) ?
  47650. childStart :
  47651. start);
  47652. // End should be the largest child.end.
  47653. // If child is milestone, then use start as end.
  47654. end = ((!isNumber(end) || childEnd > end) ?
  47655. childEnd :
  47656. end);
  47657. descendants = descendants + 1 + node.descendants;
  47658. height = Math.max(node.height + 1, height);
  47659. return node;
  47660. });
  47661. // Calculate start and end for point if it is not already explicitly set.
  47662. if (data) {
  47663. data.start = pick(data.start, start);
  47664. data.end = pick(data.end, end);
  47665. }
  47666. extend(node, {
  47667. children: children,
  47668. descendants: descendants,
  47669. height: height
  47670. });
  47671. // Allow custom logic after the children has been created.
  47672. if (typeof after === 'function') {
  47673. after(node, options);
  47674. }
  47675. return node;
  47676. };
  47677. var getTree = function (data,
  47678. options) {
  47679. var ids = data.map(function (d) {
  47680. return d.id;
  47681. }), mapOfIdToChildren = getListOfParents(data, ids);
  47682. return getNode('', null, 1, null, mapOfIdToChildren, options);
  47683. };
  47684. var Tree = {
  47685. getListOfParents: getListOfParents,
  47686. getNode: getNode,
  47687. getTree: getTree
  47688. };
  47689. return Tree;
  47690. });
  47691. _registerModule(_modules, 'Core/Axis/TreeGridTick.js', [_modules['Core/Color/Palette.js'], _modules['Core/Utilities.js']], function (palette, U) {
  47692. /* *
  47693. *
  47694. * (c) 2016 Highsoft AS
  47695. * Authors: Jon Arild Nygard
  47696. *
  47697. * License: www.highcharts.com/license
  47698. *
  47699. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  47700. *
  47701. * */
  47702. var addEvent = U.addEvent,
  47703. defined = U.defined,
  47704. isObject = U.isObject,
  47705. isNumber = U.isNumber,
  47706. pick = U.pick,
  47707. wrap = U.wrap;
  47708. /**
  47709. * @private
  47710. */
  47711. var TreeGridTick;
  47712. (function (TreeGridTick) {
  47713. /* *
  47714. *
  47715. * Interfaces
  47716. *
  47717. * */
  47718. /* *
  47719. *
  47720. * Variables
  47721. *
  47722. * */
  47723. var applied = false;
  47724. /* *
  47725. *
  47726. * Functions
  47727. *
  47728. * */
  47729. /**
  47730. * @private
  47731. */
  47732. function compose(TickClass) {
  47733. if (!applied) {
  47734. addEvent(TickClass, 'init', onInit);
  47735. wrap(TickClass.prototype, 'getLabelPosition', wrapGetLabelPosition);
  47736. wrap(TickClass.prototype, 'renderLabel', wrapRenderLabel);
  47737. // backwards compatibility
  47738. TickClass.prototype.collapse = function (redraw) {
  47739. this.treeGrid.collapse(redraw);
  47740. };
  47741. TickClass.prototype.expand = function (redraw) {
  47742. this.treeGrid.expand(redraw);
  47743. };
  47744. TickClass.prototype.toggleCollapse = function (redraw) {
  47745. this.treeGrid.toggleCollapse(redraw);
  47746. };
  47747. applied = true;
  47748. }
  47749. }
  47750. TreeGridTick.compose = compose;
  47751. /**
  47752. * @private
  47753. */
  47754. function onInit() {
  47755. var tick = this;
  47756. if (!tick.treeGrid) {
  47757. tick.treeGrid = new Additions(tick);
  47758. }
  47759. }
  47760. /**
  47761. * @private
  47762. */
  47763. function onTickHover(label) {
  47764. label.addClass('highcharts-treegrid-node-active');
  47765. if (!label.renderer.styledMode) {
  47766. label.css({
  47767. textDecoration: 'underline'
  47768. });
  47769. }
  47770. }
  47771. /**
  47772. * @private
  47773. */
  47774. function onTickHoverExit(label, options) {
  47775. var css = isObject(options.style) ? options.style : {};
  47776. label.removeClass('highcharts-treegrid-node-active');
  47777. if (!label.renderer.styledMode) {
  47778. label.css({ textDecoration: css.textDecoration });
  47779. }
  47780. }
  47781. /**
  47782. * @private
  47783. */
  47784. function renderLabelIcon(tick, params) {
  47785. var treeGrid = tick.treeGrid,
  47786. isNew = !treeGrid.labelIcon,
  47787. renderer = params.renderer,
  47788. labelBox = params.xy,
  47789. options = params.options,
  47790. width = options.width || 0,
  47791. height = options.height || 0,
  47792. iconCenter = {
  47793. x: labelBox.x - (width / 2) - (options.padding || 0),
  47794. y: labelBox.y - (height / 2)
  47795. },
  47796. rotation = params.collapsed ? 90 : 180,
  47797. shouldRender = params.show && isNumber(iconCenter.y);
  47798. var icon = treeGrid.labelIcon;
  47799. if (!icon) {
  47800. treeGrid.labelIcon = icon = renderer
  47801. .path(renderer.symbols[options.type](options.x || 0, options.y || 0, width, height))
  47802. .addClass('highcharts-label-icon')
  47803. .add(params.group);
  47804. }
  47805. // Set the new position, and show or hide
  47806. icon.attr({ y: shouldRender ? 0 : -9999 }); // #14904, #1338
  47807. // Presentational attributes
  47808. if (!renderer.styledMode) {
  47809. icon
  47810. .attr({
  47811. cursor: 'pointer',
  47812. 'fill': pick(params.color, palette.neutralColor60),
  47813. 'stroke-width': 1,
  47814. stroke: options.lineColor,
  47815. strokeWidth: options.lineWidth || 0
  47816. });
  47817. }
  47818. // Update the icon positions
  47819. icon[isNew ? 'attr' : 'animate']({
  47820. translateX: iconCenter.x,
  47821. translateY: iconCenter.y,
  47822. rotation: rotation
  47823. });
  47824. }
  47825. /**
  47826. * @private
  47827. */
  47828. function wrapGetLabelPosition(proceed, x, y, label, horiz, labelOptions, tickmarkOffset, index, step) {
  47829. var tick = this,
  47830. lbOptions = pick(tick.options && tick.options.labels,
  47831. labelOptions),
  47832. pos = tick.pos,
  47833. axis = tick.axis,
  47834. options = axis.options,
  47835. isTreeGrid = options.type === 'treegrid',
  47836. result = proceed.apply(tick,
  47837. [x,
  47838. y,
  47839. label,
  47840. horiz,
  47841. lbOptions,
  47842. tickmarkOffset,
  47843. index,
  47844. step]);
  47845. var symbolOptions,
  47846. indentation,
  47847. mapOfPosToGridNode,
  47848. node,
  47849. level;
  47850. if (isTreeGrid) {
  47851. symbolOptions = (lbOptions && isObject(lbOptions.symbol, true) ?
  47852. lbOptions.symbol :
  47853. {});
  47854. indentation = (lbOptions && isNumber(lbOptions.indentation) ?
  47855. lbOptions.indentation :
  47856. 0);
  47857. mapOfPosToGridNode = axis.treeGrid.mapOfPosToGridNode;
  47858. node = mapOfPosToGridNode && mapOfPosToGridNode[pos];
  47859. level = (node && node.depth) || 1;
  47860. result.x += (
  47861. // Add space for symbols
  47862. ((symbolOptions.width || 0) +
  47863. ((symbolOptions.padding || 0) * 2)) +
  47864. // Apply indentation
  47865. ((level - 1) * indentation));
  47866. }
  47867. return result;
  47868. }
  47869. /**
  47870. * @private
  47871. */
  47872. function wrapRenderLabel(proceed) {
  47873. var tick = this, pos = tick.pos, axis = tick.axis, label = tick.label, mapOfPosToGridNode = axis.treeGrid.mapOfPosToGridNode, options = axis.options, labelOptions = pick(tick.options && tick.options.labels, options && options.labels), symbolOptions = (labelOptions && isObject(labelOptions.symbol, true) ?
  47874. labelOptions.symbol :
  47875. {}), node = mapOfPosToGridNode && mapOfPosToGridNode[pos], level = node && node.depth, isTreeGrid = options.type === 'treegrid', shouldRender = axis.tickPositions.indexOf(pos) > -1, prefixClassName = 'highcharts-treegrid-node-', styledMode = axis.chart.styledMode;
  47876. var collapsed,
  47877. addClassName,
  47878. removeClassName;
  47879. if (isTreeGrid && node) {
  47880. // Add class name for hierarchical styling.
  47881. if (label &&
  47882. label.element) {
  47883. label.addClass(prefixClassName + 'level-' + level);
  47884. }
  47885. }
  47886. proceed.apply(tick, Array.prototype.slice.call(arguments, 1));
  47887. if (isTreeGrid &&
  47888. label &&
  47889. label.element &&
  47890. node &&
  47891. node.descendants &&
  47892. node.descendants > 0) {
  47893. collapsed = axis.treeGrid.isCollapsed(node);
  47894. renderLabelIcon(tick, {
  47895. color: !styledMode && label.styles && label.styles.color || '',
  47896. collapsed: collapsed,
  47897. group: label.parentGroup,
  47898. options: symbolOptions,
  47899. renderer: label.renderer,
  47900. show: shouldRender,
  47901. xy: label.xy
  47902. });
  47903. // Add class name for the node.
  47904. addClassName = prefixClassName +
  47905. (collapsed ? 'collapsed' : 'expanded');
  47906. removeClassName = prefixClassName +
  47907. (collapsed ? 'expanded' : 'collapsed');
  47908. label
  47909. .addClass(addClassName)
  47910. .removeClass(removeClassName);
  47911. if (!styledMode) {
  47912. label.css({
  47913. cursor: 'pointer'
  47914. });
  47915. }
  47916. // Add events to both label text and icon
  47917. [label, tick.treeGrid.labelIcon].forEach(function (object) {
  47918. if (object && !object.attachedTreeGridEvents) {
  47919. // On hover
  47920. addEvent(object.element, 'mouseover', function () {
  47921. onTickHover(label);
  47922. });
  47923. // On hover out
  47924. addEvent(object.element, 'mouseout', function () {
  47925. onTickHoverExit(label, labelOptions);
  47926. });
  47927. addEvent(object.element, 'click', function () {
  47928. tick.treeGrid.toggleCollapse();
  47929. });
  47930. object.attachedTreeGridEvents = true;
  47931. }
  47932. });
  47933. }
  47934. }
  47935. /* *
  47936. *
  47937. * Classes
  47938. *
  47939. * */
  47940. /**
  47941. * @private
  47942. * @class
  47943. */
  47944. var Additions = /** @class */ (function () {
  47945. /* *
  47946. *
  47947. * Constructors
  47948. *
  47949. * */
  47950. /**
  47951. * @private
  47952. */
  47953. function Additions(tick) {
  47954. this.tick = tick;
  47955. }
  47956. /* *
  47957. *
  47958. * Functions
  47959. *
  47960. * */
  47961. /**
  47962. * Collapse the grid cell. Used when axis is of type treegrid.
  47963. *
  47964. * @see gantt/treegrid-axis/collapsed-dynamically/demo.js
  47965. *
  47966. * @private
  47967. * @function Highcharts.Tick#collapse
  47968. *
  47969. * @param {boolean} [redraw=true]
  47970. * Whether to redraw the chart or wait for an explicit call to
  47971. * {@link Highcharts.Chart#redraw}
  47972. */
  47973. Additions.prototype.collapse = function (redraw) {
  47974. var tick = this.tick,
  47975. axis = tick.axis,
  47976. brokenAxis = axis.brokenAxis;
  47977. if (brokenAxis &&
  47978. axis.treeGrid.mapOfPosToGridNode) {
  47979. var pos = tick.pos,
  47980. node = axis.treeGrid.mapOfPosToGridNode[pos],
  47981. breaks = axis.treeGrid.collapse(node);
  47982. brokenAxis.setBreaks(breaks, pick(redraw, true));
  47983. }
  47984. };
  47985. /**
  47986. * Expand the grid cell. Used when axis is of type treegrid.
  47987. *
  47988. * @see gantt/treegrid-axis/collapsed-dynamically/demo.js
  47989. *
  47990. * @private
  47991. * @function Highcharts.Tick#expand
  47992. *
  47993. * @param {boolean} [redraw=true]
  47994. * Whether to redraw the chart or wait for an explicit call to
  47995. * {@link Highcharts.Chart#redraw}
  47996. */
  47997. Additions.prototype.expand = function (redraw) {
  47998. var tick = this.tick,
  47999. axis = tick.axis,
  48000. brokenAxis = axis.brokenAxis;
  48001. if (brokenAxis &&
  48002. axis.treeGrid.mapOfPosToGridNode) {
  48003. var pos = tick.pos,
  48004. node = axis.treeGrid.mapOfPosToGridNode[pos],
  48005. breaks = axis.treeGrid.expand(node);
  48006. brokenAxis.setBreaks(breaks, pick(redraw, true));
  48007. }
  48008. };
  48009. /**
  48010. * Toggle the collapse/expand state of the grid cell. Used when axis is
  48011. * of type treegrid.
  48012. *
  48013. * @see gantt/treegrid-axis/collapsed-dynamically/demo.js
  48014. *
  48015. * @private
  48016. * @function Highcharts.Tick#toggleCollapse
  48017. *
  48018. * @param {boolean} [redraw=true]
  48019. * Whether to redraw the chart or wait for an explicit call to
  48020. * {@link Highcharts.Chart#redraw}
  48021. */
  48022. Additions.prototype.toggleCollapse = function (redraw) {
  48023. var tick = this.tick,
  48024. axis = tick.axis,
  48025. brokenAxis = axis.brokenAxis;
  48026. if (brokenAxis &&
  48027. axis.treeGrid.mapOfPosToGridNode) {
  48028. var pos = tick.pos,
  48029. node = axis.treeGrid.mapOfPosToGridNode[pos],
  48030. breaks = axis.treeGrid.toggleCollapse(node);
  48031. brokenAxis.setBreaks(breaks, pick(redraw, true));
  48032. }
  48033. };
  48034. return Additions;
  48035. }());
  48036. TreeGridTick.Additions = Additions;
  48037. })(TreeGridTick || (TreeGridTick = {}));
  48038. return TreeGridTick;
  48039. });
  48040. _registerModule(_modules, 'Mixins/TreeSeries.js', [_modules['Core/Color/Color.js'], _modules['Core/Utilities.js']], function (Color, U) {
  48041. /* *
  48042. *
  48043. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  48044. *
  48045. * */
  48046. var extend = U.extend,
  48047. isArray = U.isArray,
  48048. isNumber = U.isNumber,
  48049. isObject = U.isObject,
  48050. merge = U.merge,
  48051. pick = U.pick;
  48052. var isBoolean = function (x) {
  48053. return typeof x === 'boolean';
  48054. }, isFn = function (x) {
  48055. return typeof x === 'function';
  48056. };
  48057. /* eslint-disable valid-jsdoc */
  48058. /**
  48059. * @todo Combine buildTree and buildNode with setTreeValues
  48060. * @todo Remove logic from Treemap and make it utilize this mixin.
  48061. * @private
  48062. */
  48063. var setTreeValues = function setTreeValues(tree,
  48064. options) {
  48065. var before = options.before,
  48066. idRoot = options.idRoot,
  48067. mapIdToNode = options.mapIdToNode,
  48068. nodeRoot = mapIdToNode[idRoot],
  48069. levelIsConstant = (isBoolean(options.levelIsConstant) ?
  48070. options.levelIsConstant :
  48071. true),
  48072. points = options.points,
  48073. point = points[tree.i],
  48074. optionsPoint = point && point.options || {},
  48075. childrenTotal = 0,
  48076. children = [],
  48077. value;
  48078. tree.levelDynamic = tree.level - (levelIsConstant ? 0 : nodeRoot.level);
  48079. tree.name = pick(point && point.name, '');
  48080. tree.visible = (idRoot === tree.id ||
  48081. (isBoolean(options.visible) ? options.visible : false));
  48082. if (isFn(before)) {
  48083. tree = before(tree, options);
  48084. }
  48085. // First give the children some values
  48086. tree.children.forEach(function (child, i) {
  48087. var newOptions = extend({},
  48088. options);
  48089. extend(newOptions, {
  48090. index: i,
  48091. siblings: tree.children.length,
  48092. visible: tree.visible
  48093. });
  48094. child = setTreeValues(child, newOptions);
  48095. children.push(child);
  48096. if (child.visible) {
  48097. childrenTotal += child.val;
  48098. }
  48099. });
  48100. tree.visible = childrenTotal > 0 || tree.visible;
  48101. // Set the values
  48102. value = pick(optionsPoint.value, childrenTotal);
  48103. tree.children = children;
  48104. tree.childrenTotal = childrenTotal;
  48105. tree.isLeaf = tree.visible && !childrenTotal;
  48106. tree.val = value;
  48107. return tree;
  48108. };
  48109. /**
  48110. * @private
  48111. */
  48112. var getColor = function getColor(node,
  48113. options) {
  48114. var index = options.index,
  48115. mapOptionsToLevel = options.mapOptionsToLevel,
  48116. parentColor = options.parentColor,
  48117. parentColorIndex = options.parentColorIndex,
  48118. series = options.series,
  48119. colors = options.colors,
  48120. siblings = options.siblings,
  48121. points = series.points,
  48122. getColorByPoint,
  48123. chartOptionsChart = series.chart.options.chart,
  48124. point,
  48125. level,
  48126. colorByPoint,
  48127. colorIndexByPoint,
  48128. color,
  48129. colorIndex;
  48130. /**
  48131. * @private
  48132. */
  48133. function variation(color) {
  48134. var colorVariation = level && level.colorVariation;
  48135. if (colorVariation) {
  48136. if (colorVariation.key === 'brightness') {
  48137. return Color.parse(color).brighten(colorVariation.to * (index / siblings)).get();
  48138. }
  48139. }
  48140. return color;
  48141. }
  48142. if (node) {
  48143. point = points[node.i];
  48144. level = mapOptionsToLevel[node.level] || {};
  48145. getColorByPoint = point && level.colorByPoint;
  48146. if (getColorByPoint) {
  48147. colorIndexByPoint = point.index % (colors ?
  48148. colors.length :
  48149. chartOptionsChart.colorCount);
  48150. colorByPoint = colors && colors[colorIndexByPoint];
  48151. }
  48152. // Select either point color, level color or inherited color.
  48153. if (!series.chart.styledMode) {
  48154. color = pick(point && point.options.color, level && level.color, colorByPoint, parentColor && variation(parentColor), series.color);
  48155. }
  48156. colorIndex = pick(point && point.options.colorIndex, level && level.colorIndex, colorIndexByPoint, parentColorIndex, options.colorIndex);
  48157. }
  48158. return {
  48159. color: color,
  48160. colorIndex: colorIndex
  48161. };
  48162. };
  48163. /**
  48164. * Creates a map from level number to its given options.
  48165. *
  48166. * @private
  48167. * @function getLevelOptions
  48168. * @param {object} params
  48169. * Object containing parameters.
  48170. * - `defaults` Object containing default options. The default options
  48171. * are merged with the userOptions to get the final options for a
  48172. * specific level.
  48173. * - `from` The lowest level number.
  48174. * - `levels` User options from series.levels.
  48175. * - `to` The highest level number.
  48176. * @return {Highcharts.Dictionary<object>|null}
  48177. * Returns a map from level number to its given options.
  48178. */
  48179. var getLevelOptions = function getLevelOptions(params) {
  48180. var result = null,
  48181. defaults,
  48182. converted,
  48183. i,
  48184. from,
  48185. to,
  48186. levels;
  48187. if (isObject(params)) {
  48188. result = {};
  48189. from = isNumber(params.from) ? params.from : 1;
  48190. levels = params.levels;
  48191. converted = {};
  48192. defaults = isObject(params.defaults) ? params.defaults : {};
  48193. if (isArray(levels)) {
  48194. converted = levels.reduce(function (obj, item) {
  48195. var level,
  48196. levelIsConstant,
  48197. options;
  48198. if (isObject(item) && isNumber(item.level)) {
  48199. options = merge({}, item);
  48200. levelIsConstant = (isBoolean(options.levelIsConstant) ?
  48201. options.levelIsConstant :
  48202. defaults.levelIsConstant);
  48203. // Delete redundant properties.
  48204. delete options.levelIsConstant;
  48205. delete options.level;
  48206. // Calculate which level these options apply to.
  48207. level = item.level + (levelIsConstant ? 0 : from - 1);
  48208. if (isObject(obj[level])) {
  48209. extend(obj[level], options);
  48210. }
  48211. else {
  48212. obj[level] = options;
  48213. }
  48214. }
  48215. return obj;
  48216. }, {});
  48217. }
  48218. to = isNumber(params.to) ? params.to : 1;
  48219. for (i = 0; i <= to; i++) {
  48220. result[i] = merge({}, defaults, isObject(converted[i]) ? converted[i] : {});
  48221. }
  48222. }
  48223. return result;
  48224. };
  48225. /**
  48226. * Update the rootId property on the series. Also makes sure that it is
  48227. * accessible to exporting.
  48228. *
  48229. * @private
  48230. * @function updateRootId
  48231. *
  48232. * @param {object} series
  48233. * The series to operate on.
  48234. *
  48235. * @return {string}
  48236. * Returns the resulting rootId after update.
  48237. */
  48238. var updateRootId = function (series) {
  48239. var rootId,
  48240. options;
  48241. if (isObject(series)) {
  48242. // Get the series options.
  48243. options = isObject(series.options) ? series.options : {};
  48244. // Calculate the rootId.
  48245. rootId = pick(series.rootNode, options.rootId, '');
  48246. // Set rootId on series.userOptions to pick it up in exporting.
  48247. if (isObject(series.userOptions)) {
  48248. series.userOptions.rootId = rootId;
  48249. }
  48250. // Set rootId on series to pick it up on next update.
  48251. series.rootNode = rootId;
  48252. }
  48253. return rootId;
  48254. };
  48255. var result = {
  48256. getColor: getColor,
  48257. getLevelOptions: getLevelOptions,
  48258. setTreeValues: setTreeValues,
  48259. updateRootId: updateRootId
  48260. };
  48261. return result;
  48262. });
  48263. _registerModule(_modules, 'Core/Axis/GridAxis.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Globals.js'], _modules['Core/Axis/Tick.js'], _modules['Core/Utilities.js']], function (Axis, H, Tick, U) {
  48264. /* *
  48265. *
  48266. * (c) 2016 Highsoft AS
  48267. * Authors: Lars A. V. Cabrera
  48268. *
  48269. * License: www.highcharts.com/license
  48270. *
  48271. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  48272. *
  48273. * */
  48274. var addEvent = U.addEvent,
  48275. defined = U.defined,
  48276. erase = U.erase,
  48277. find = U.find,
  48278. isArray = U.isArray,
  48279. isNumber = U.isNumber,
  48280. merge = U.merge,
  48281. pick = U.pick,
  48282. timeUnits = U.timeUnits,
  48283. wrap = U.wrap;
  48284. var argsToArray = function (args) {
  48285. return Array.prototype.slice.call(args, 1);
  48286. }, isObject = function (x) {
  48287. // Always use strict mode
  48288. return U.isObject(x, true);
  48289. }, Chart = H.Chart;
  48290. var applyGridOptions = function applyGridOptions(axis) {
  48291. var options = axis.options;
  48292. // Center-align by default
  48293. /*
  48294. if (!options.labels) {
  48295. options.labels = {};
  48296. }
  48297. */
  48298. options.labels.align = pick(options.labels.align, 'center');
  48299. // @todo: Check against tickLabelPlacement between/on etc
  48300. /* Prevents adding the last tick label if the axis is not a category
  48301. axis.
  48302. Since numeric labels are normally placed at starts and ends of a
  48303. range of value, and this module makes the label point at the value,
  48304. an "extra" label would appear. */
  48305. if (!axis.categories) {
  48306. options.showLastLabel = false;
  48307. }
  48308. // Prevents rotation of labels when squished, as rotating them would not
  48309. // help.
  48310. axis.labelRotation = 0;
  48311. options.labels.rotation = 0;
  48312. };
  48313. /**
  48314. * @productdesc {gantt}
  48315. * For grid axes (like in Gantt charts),
  48316. * it is possible to declare as a list to provide different
  48317. * formats depending on available space.
  48318. *
  48319. * Defaults to:
  48320. * ```js
  48321. * {
  48322. * hour: { list: ['%H:%M', '%H'] },
  48323. * day: { list: ['%A, %e. %B', '%a, %e. %b', '%E'] },
  48324. * week: { list: ['Week %W', 'W%W'] },
  48325. * month: { list: ['%B', '%b', '%o'] }
  48326. * }
  48327. * ```
  48328. *
  48329. * @sample {gantt} gantt/grid-axis/date-time-label-formats
  48330. * Gantt chart with custom axis date format.
  48331. *
  48332. * @apioption xAxis.dateTimeLabelFormats
  48333. */
  48334. /**
  48335. * Set grid options for the axis labels. Requires Highcharts Gantt.
  48336. *
  48337. * @since 6.2.0
  48338. * @product gantt
  48339. * @apioption xAxis.grid
  48340. */
  48341. /**
  48342. * Enable grid on the axis labels. Defaults to true for Gantt charts.
  48343. *
  48344. * @type {boolean}
  48345. * @default true
  48346. * @since 6.2.0
  48347. * @product gantt
  48348. * @apioption xAxis.grid.enabled
  48349. */
  48350. /**
  48351. * Set specific options for each column (or row for horizontal axes) in the
  48352. * grid. Each extra column/row is its own axis, and the axis options can be set
  48353. * here.
  48354. *
  48355. * @sample gantt/demo/left-axis-table
  48356. * Left axis as a table
  48357. *
  48358. * @type {Array<Highcharts.XAxisOptions>}
  48359. * @apioption xAxis.grid.columns
  48360. */
  48361. /**
  48362. * Set border color for the label grid lines.
  48363. *
  48364. * @type {Highcharts.ColorString}
  48365. * @apioption xAxis.grid.borderColor
  48366. */
  48367. /**
  48368. * Set border width of the label grid lines.
  48369. *
  48370. * @type {number}
  48371. * @default 1
  48372. * @apioption xAxis.grid.borderWidth
  48373. */
  48374. /**
  48375. * Set cell height for grid axis labels. By default this is calculated from font
  48376. * size. This option only applies to horizontal axes.
  48377. *
  48378. * @sample gantt/grid-axis/cellheight
  48379. * Gant chart with custom cell height
  48380. * @type {number}
  48381. * @apioption xAxis.grid.cellHeight
  48382. */
  48383. ''; // detach doclets above
  48384. /**
  48385. * Get the largest label width and height.
  48386. *
  48387. * @private
  48388. * @function Highcharts.Axis#getMaxLabelDimensions
  48389. *
  48390. * @param {Highcharts.Dictionary<Highcharts.Tick>} ticks
  48391. * All the ticks on one axis.
  48392. *
  48393. * @param {Array<number|string>} tickPositions
  48394. * All the tick positions on one axis.
  48395. *
  48396. * @return {Highcharts.SizeObject}
  48397. * Object containing the properties height and width.
  48398. *
  48399. * @todo Move this to the generic axis implementation, as it is used there.
  48400. */
  48401. Axis.prototype.getMaxLabelDimensions = function (ticks, tickPositions) {
  48402. var dimensions = {
  48403. width: 0,
  48404. height: 0
  48405. };
  48406. tickPositions.forEach(function (pos) {
  48407. var tick = ticks[pos],
  48408. labelHeight = 0,
  48409. labelWidth = 0,
  48410. label;
  48411. if (isObject(tick)) {
  48412. label = isObject(tick.label) ? tick.label : {};
  48413. // Find width and height of label
  48414. labelHeight = label.getBBox ? label.getBBox().height : 0;
  48415. if (label.textStr && !isNumber(label.textPxLength)) {
  48416. label.textPxLength = label.getBBox().width;
  48417. }
  48418. labelWidth = isNumber(label.textPxLength) ?
  48419. // Math.round ensures crisp lines
  48420. Math.round(label.textPxLength) :
  48421. 0;
  48422. if (label.textStr) {
  48423. // Set the tickWidth same as the label width after ellipsis
  48424. // applied #10281
  48425. labelWidth = Math.round(label.getBBox().width);
  48426. }
  48427. // Update the result if width and/or height are larger
  48428. dimensions.height = Math.max(labelHeight, dimensions.height);
  48429. dimensions.width = Math.max(labelWidth, dimensions.width);
  48430. }
  48431. });
  48432. return dimensions;
  48433. };
  48434. // Adds week date format
  48435. H.dateFormats.W = function (timestamp) {
  48436. var d = new this.Date(timestamp);
  48437. var firstDay = (this.get('Day',
  48438. d) + 6) % 7;
  48439. var thursday = new this.Date(d.valueOf());
  48440. this.set('Date', thursday, this.get('Date', d) - firstDay + 3);
  48441. var firstThursday = new this.Date(this.get('FullYear',
  48442. thursday), 0, 1);
  48443. if (this.get('Day', firstThursday) !== 4) {
  48444. this.set('Month', d, 0);
  48445. this.set('Date', d, 1 + (11 - this.get('Day', firstThursday)) % 7);
  48446. }
  48447. return (1 +
  48448. Math.floor((thursday.valueOf() - firstThursday.valueOf()) / 604800000)).toString();
  48449. };
  48450. // First letter of the day of the week, e.g. 'M' for 'Monday'.
  48451. H.dateFormats.E = function (timestamp) {
  48452. return this.dateFormat('%a', timestamp, true).charAt(0);
  48453. };
  48454. /* eslint-disable no-invalid-this */
  48455. addEvent(Chart, 'afterSetChartSize', function () {
  48456. this.axes.forEach(function (axis) {
  48457. (axis.grid && axis.grid.columns || []).forEach(function (column) {
  48458. column.setAxisSize();
  48459. column.setAxisTranslation();
  48460. });
  48461. });
  48462. });
  48463. // Center tick labels in cells.
  48464. addEvent(Tick, 'afterGetLabelPosition', function (e) {
  48465. var tick = this,
  48466. label = tick.label,
  48467. axis = tick.axis,
  48468. reversed = axis.reversed,
  48469. chart = axis.chart,
  48470. options = axis.options,
  48471. gridOptions = options.grid || {},
  48472. labelOpts = axis.options.labels,
  48473. align = labelOpts.align,
  48474. // verticalAlign is currently not supported for axis.labels.
  48475. verticalAlign = 'middle', // labelOpts.verticalAlign,
  48476. side = GridAxis.Side[axis.side],
  48477. tickmarkOffset = e.tickmarkOffset,
  48478. tickPositions = axis.tickPositions,
  48479. tickPos = tick.pos - tickmarkOffset,
  48480. nextTickPos = (isNumber(tickPositions[e.index + 1]) ?
  48481. tickPositions[e.index + 1] - tickmarkOffset :
  48482. axis.max + tickmarkOffset),
  48483. tickSize = axis.tickSize('tick'),
  48484. tickWidth = tickSize ? tickSize[0] : 0,
  48485. crispCorr = tickSize ? tickSize[1] / 2 : 0,
  48486. labelHeight,
  48487. lblMetrics,
  48488. lines,
  48489. bottom,
  48490. top,
  48491. left,
  48492. right;
  48493. // Only center tick labels in grid axes
  48494. if (gridOptions.enabled === true) {
  48495. // Calculate top and bottom positions of the cell.
  48496. if (side === 'top') {
  48497. bottom = axis.top + axis.offset;
  48498. top = bottom - tickWidth;
  48499. }
  48500. else if (side === 'bottom') {
  48501. top = chart.chartHeight - axis.bottom + axis.offset;
  48502. bottom = top + tickWidth;
  48503. }
  48504. else {
  48505. bottom = axis.top + axis.len - axis.translate(reversed ? nextTickPos : tickPos);
  48506. top = axis.top + axis.len - axis.translate(reversed ? tickPos : nextTickPos);
  48507. }
  48508. // Calculate left and right positions of the cell.
  48509. if (side === 'right') {
  48510. left = chart.chartWidth - axis.right + axis.offset;
  48511. right = left + tickWidth;
  48512. }
  48513. else if (side === 'left') {
  48514. right = axis.left + axis.offset;
  48515. left = right - tickWidth;
  48516. }
  48517. else {
  48518. left = Math.round(axis.left + axis.translate(reversed ? nextTickPos : tickPos)) - crispCorr;
  48519. right = Math.round(axis.left + axis.translate(reversed ? tickPos : nextTickPos)) - crispCorr;
  48520. }
  48521. tick.slotWidth = right - left;
  48522. // Calculate the positioning of the label based on
  48523. // alignment.
  48524. e.pos.x = (align === 'left' ?
  48525. left :
  48526. align === 'right' ?
  48527. right :
  48528. left + ((right - left) / 2) // default to center
  48529. );
  48530. e.pos.y = (verticalAlign === 'top' ?
  48531. top :
  48532. verticalAlign === 'bottom' ?
  48533. bottom :
  48534. top + ((bottom - top) / 2) // default to middle
  48535. );
  48536. lblMetrics = chart.renderer.fontMetrics(labelOpts.style.fontSize, label.element);
  48537. labelHeight = label.getBBox().height;
  48538. // Adjustment to y position to align the label correctly.
  48539. // Would be better to have a setter or similar for this.
  48540. if (!labelOpts.useHTML) {
  48541. lines = Math.round(labelHeight / lblMetrics.h);
  48542. e.pos.y += (
  48543. // Center the label
  48544. // TODO: why does this actually center the label?
  48545. ((lblMetrics.b - (lblMetrics.h - lblMetrics.f)) / 2) +
  48546. // Adjust for height of additional lines.
  48547. -(((lines - 1) * lblMetrics.h) / 2));
  48548. }
  48549. else {
  48550. e.pos.y += (
  48551. // Readjust yCorr in htmlUpdateTransform
  48552. lblMetrics.b +
  48553. // Adjust for height of html label
  48554. -(labelHeight / 2));
  48555. }
  48556. e.pos.x += (axis.horiz && labelOpts.x || 0);
  48557. }
  48558. });
  48559. addEvent(Tick, 'labelFormat', function (ctx) {
  48560. var axis = ctx.axis,
  48561. value = ctx.value;
  48562. if (axis.options.grid &&
  48563. axis.options.grid.enabled) {
  48564. var tickPos = axis.tickPositions;
  48565. var series = (axis.linkedParent || axis).series[0];
  48566. var isFirst = value === tickPos[0];
  48567. var isLast = value === tickPos[tickPos.length - 1];
  48568. var point = series && find(series.options.data,
  48569. function (p) {
  48570. return p[axis.isXAxis ? 'x' : 'y'] === value;
  48571. });
  48572. var pointCopy = void 0;
  48573. if (point && series.is('gantt')) {
  48574. // For the Gantt set point aliases to the pointCopy
  48575. // to do not change the original point
  48576. pointCopy = merge(point);
  48577. H.seriesTypes.gantt.prototype.pointClass
  48578. .setGanttPointAliases(pointCopy);
  48579. }
  48580. // Make additional properties available for the
  48581. // formatter
  48582. ctx.isFirst = isFirst;
  48583. ctx.isLast = isLast;
  48584. ctx.point = pointCopy;
  48585. }
  48586. });
  48587. /* eslint-enable no-invalid-this */
  48588. /**
  48589. * Additions for grid axes.
  48590. * @private
  48591. * @class
  48592. */
  48593. var GridAxisAdditions = /** @class */ (function () {
  48594. /* *
  48595. *
  48596. * Constructors
  48597. *
  48598. * */
  48599. function GridAxisAdditions(axis) {
  48600. this.axis = axis;
  48601. }
  48602. /* *
  48603. *
  48604. * Functions
  48605. *
  48606. * */
  48607. /**
  48608. * Checks if an axis is the outer axis in its dimension. Since
  48609. * axes are placed outwards in order, the axis with the highest
  48610. * index is the outermost axis.
  48611. *
  48612. * Example: If there are multiple x-axes at the top of the chart,
  48613. * this function returns true if the axis supplied is the last
  48614. * of the x-axes.
  48615. *
  48616. * @private
  48617. *
  48618. * @return {boolean}
  48619. * True if the axis is the outermost axis in its dimension; false if
  48620. * not.
  48621. */
  48622. GridAxisAdditions.prototype.isOuterAxis = function () {
  48623. var axis = this.axis;
  48624. var chart = axis.chart;
  48625. var columnIndex = axis.grid.columnIndex;
  48626. var columns = (axis.linkedParent && axis.linkedParent.grid.columns ||
  48627. axis.grid.columns);
  48628. var parentAxis = columnIndex ? axis.linkedParent : axis;
  48629. var thisIndex = -1,
  48630. lastIndex = 0;
  48631. chart[axis.coll].forEach(function (otherAxis, index) {
  48632. if (otherAxis.side === axis.side && !otherAxis.options.isInternal) {
  48633. lastIndex = index;
  48634. if (otherAxis === parentAxis) {
  48635. // Get the index of the axis in question
  48636. thisIndex = index;
  48637. }
  48638. }
  48639. });
  48640. return (lastIndex === thisIndex &&
  48641. (isNumber(columnIndex) ? columns.length === columnIndex : true));
  48642. };
  48643. /**
  48644. * Add extra border based on the provided path.
  48645. * *
  48646. * @private
  48647. *
  48648. * @param {SVGPath} path
  48649. * The path of the border.
  48650. *
  48651. * @return {Highcharts.SVGElement}
  48652. */
  48653. GridAxisAdditions.prototype.renderBorder = function (path) {
  48654. var axis = this.axis,
  48655. renderer = axis.chart.renderer,
  48656. options = axis.options,
  48657. extraBorderLine = renderer.path(path)
  48658. .addClass('highcharts-axis-line')
  48659. .add(axis.axisBorder);
  48660. if (!renderer.styledMode) {
  48661. extraBorderLine.attr({
  48662. stroke: options.lineColor,
  48663. 'stroke-width': options.lineWidth,
  48664. zIndex: 7
  48665. });
  48666. }
  48667. return extraBorderLine;
  48668. };
  48669. return GridAxisAdditions;
  48670. }());
  48671. /**
  48672. * Axis with grid support.
  48673. * @private
  48674. * @class
  48675. */
  48676. var GridAxis = /** @class */ (function () {
  48677. function GridAxis() {
  48678. }
  48679. /* *
  48680. *
  48681. * Static Functions
  48682. *
  48683. * */
  48684. /* eslint-disable valid-jsdoc */
  48685. /**
  48686. * Extends axis class with grid support.
  48687. * @private
  48688. */
  48689. GridAxis.compose = function (AxisClass) {
  48690. Axis.keepProps.push('grid');
  48691. wrap(AxisClass.prototype, 'unsquish', GridAxis.wrapUnsquish);
  48692. // Add event handlers
  48693. addEvent(AxisClass, 'init', GridAxis.onInit);
  48694. addEvent(AxisClass, 'afterGetOffset', GridAxis.onAfterGetOffset);
  48695. addEvent(AxisClass, 'afterGetTitlePosition', GridAxis.onAfterGetTitlePosition);
  48696. addEvent(AxisClass, 'afterInit', GridAxis.onAfterInit);
  48697. addEvent(AxisClass, 'afterRender', GridAxis.onAfterRender);
  48698. addEvent(AxisClass, 'afterSetAxisTranslation', GridAxis.onAfterSetAxisTranslation);
  48699. addEvent(AxisClass, 'afterSetOptions', GridAxis.onAfterSetOptions);
  48700. addEvent(AxisClass, 'afterSetOptions', GridAxis.onAfterSetOptions2);
  48701. addEvent(AxisClass, 'afterSetScale', GridAxis.onAfterSetScale);
  48702. addEvent(AxisClass, 'afterTickSize', GridAxis.onAfterTickSize);
  48703. addEvent(AxisClass, 'trimTicks', GridAxis.onTrimTicks);
  48704. addEvent(AxisClass, 'destroy', GridAxis.onDestroy);
  48705. };
  48706. /**
  48707. * Handle columns and getOffset.
  48708. * @private
  48709. */
  48710. GridAxis.onAfterGetOffset = function () {
  48711. var grid = this.grid;
  48712. (grid && grid.columns || []).forEach(function (column) {
  48713. column.getOffset();
  48714. });
  48715. };
  48716. /**
  48717. * @private
  48718. */
  48719. GridAxis.onAfterGetTitlePosition = function (e) {
  48720. var axis = this;
  48721. var options = axis.options;
  48722. var gridOptions = options.grid || {};
  48723. if (gridOptions.enabled === true) {
  48724. // compute anchor points for each of the title align options
  48725. var axisTitle = axis.axisTitle,
  48726. axisHeight = axis.height,
  48727. horiz = axis.horiz,
  48728. axisLeft = axis.left,
  48729. offset = axis.offset,
  48730. opposite = axis.opposite,
  48731. options_1 = axis.options,
  48732. axisTop = axis.top,
  48733. axisWidth = axis.width;
  48734. var tickSize = axis.tickSize();
  48735. var titleWidth = axisTitle && axisTitle.getBBox().width;
  48736. var xOption = options_1.title.x;
  48737. var yOption = options_1.title.y;
  48738. var titleMargin = pick(options_1.title.margin,
  48739. horiz ? 5 : 10);
  48740. var titleFontSize = axis.chart.renderer.fontMetrics(options_1.title.style.fontSize,
  48741. axisTitle).f;
  48742. var crispCorr = tickSize ? tickSize[0] / 2 : 0;
  48743. // TODO account for alignment
  48744. // the position in the perpendicular direction of the axis
  48745. var offAxis = ((horiz ? axisTop + axisHeight : axisLeft) +
  48746. (horiz ? 1 : -1) * // horizontal axis reverses the margin
  48747. (opposite ? -1 : 1) * // so does opposite axes
  48748. crispCorr +
  48749. (axis.side === GridAxis.Side.bottom ? titleFontSize : 0));
  48750. e.titlePosition.x = horiz ?
  48751. axisLeft - (titleWidth || 0) / 2 - titleMargin + xOption :
  48752. offAxis + (opposite ? axisWidth : 0) + offset + xOption;
  48753. e.titlePosition.y = horiz ?
  48754. (offAxis -
  48755. (opposite ? axisHeight : 0) +
  48756. (opposite ? titleFontSize : -titleFontSize) / 2 +
  48757. offset +
  48758. yOption) :
  48759. axisTop - titleMargin + yOption;
  48760. }
  48761. };
  48762. /**
  48763. * @private
  48764. */
  48765. GridAxis.onAfterInit = function () {
  48766. var axis = this;
  48767. var chart = axis.chart,
  48768. _a = axis.options.grid,
  48769. gridOptions = _a === void 0 ? {} : _a,
  48770. userOptions = axis.userOptions;
  48771. if (gridOptions.enabled) {
  48772. applyGridOptions(axis);
  48773. }
  48774. if (gridOptions.columns) {
  48775. var columns = axis.grid.columns = [],
  48776. columnIndex = axis.grid.columnIndex = 0;
  48777. // Handle columns, each column is a grid axis
  48778. while (++columnIndex < gridOptions.columns.length) {
  48779. var columnOptions = merge(userOptions,
  48780. gridOptions.columns[gridOptions.columns.length - columnIndex - 1], {
  48781. linkedTo: 0,
  48782. // Force to behave like category axis
  48783. type: 'category',
  48784. // Disable by default the scrollbar on the grid axis
  48785. scrollbar: {
  48786. enabled: false
  48787. }
  48788. });
  48789. delete columnOptions.grid.columns; // Prevent recursion
  48790. var column = new Axis(axis.chart,
  48791. columnOptions);
  48792. column.grid.isColumn = true;
  48793. column.grid.columnIndex = columnIndex;
  48794. // Remove column axis from chart axes array, and place it
  48795. // in the columns array.
  48796. erase(chart.axes, column);
  48797. erase(chart[axis.coll], column);
  48798. columns.push(column);
  48799. }
  48800. }
  48801. };
  48802. /**
  48803. * Draw an extra line on the far side of the outermost axis,
  48804. * creating floor/roof/wall of a grid. And some padding.
  48805. * ```
  48806. * Make this:
  48807. * (axis.min) __________________________ (axis.max)
  48808. * | | | | |
  48809. * Into this:
  48810. * (axis.min) __________________________ (axis.max)
  48811. * ___|____|____|____|____|__
  48812. * ```
  48813. * @private
  48814. */
  48815. GridAxis.onAfterRender = function () {
  48816. var axis = this,
  48817. grid = axis.grid,
  48818. options = axis.options,
  48819. gridOptions = options.grid || {};
  48820. if (gridOptions.enabled === true) {
  48821. // @todo acutual label padding (top, bottom, left, right)
  48822. axis.maxLabelDimensions = axis.getMaxLabelDimensions(axis.ticks, axis.tickPositions);
  48823. // Remove right wall before rendering if updating
  48824. if (axis.rightWall) {
  48825. axis.rightWall.destroy();
  48826. }
  48827. /*
  48828. Draw an extra axis line on outer axes
  48829. >
  48830. Make this: |______|______|______|___
  48831. > _________________________
  48832. Into this: |______|______|______|__|
  48833. */
  48834. if (axis.grid && axis.grid.isOuterAxis() && axis.axisLine) {
  48835. var lineWidth = options.lineWidth;
  48836. if (lineWidth) {
  48837. var linePath = axis.getLinePath(lineWidth),
  48838. startPoint = linePath[0],
  48839. endPoint = linePath[1],
  48840. // Negate distance if top or left axis
  48841. // Subtract 1px to draw the line at the end of the tick
  48842. tickLength = (axis.tickSize('tick') || [1])[0],
  48843. distance = (tickLength - 1) * ((axis.side === GridAxis.Side.top ||
  48844. axis.side === GridAxis.Side.left) ? -1 : 1);
  48845. // If axis is horizontal, reposition line path vertically
  48846. if (startPoint[0] === 'M' && endPoint[0] === 'L') {
  48847. if (axis.horiz) {
  48848. startPoint[2] += distance;
  48849. endPoint[2] += distance;
  48850. }
  48851. else {
  48852. startPoint[1] += distance;
  48853. endPoint[1] += distance;
  48854. }
  48855. }
  48856. // If it doesn't exist, add an upper and lower border
  48857. // for the vertical grid axis.
  48858. if (!axis.horiz && axis.chart.marginRight) {
  48859. var upperBorderStartPoint = startPoint, upperBorderEndPoint = ['L', axis.left, startPoint[2]], upperBorderPath = [upperBorderStartPoint, upperBorderEndPoint], lowerBorderEndPoint = ['L', axis.chart.chartWidth - axis.chart.marginRight, axis.toPixels(axis.max + axis.tickmarkOffset)], lowerBorderStartPoint = ['M', endPoint[1], axis.toPixels(axis.max + axis.tickmarkOffset)], lowerBorderPath = [lowerBorderStartPoint, lowerBorderEndPoint];
  48860. if (!axis.grid.upperBorder && axis.min % 1 !== 0) {
  48861. axis.grid.upperBorder = axis.grid.renderBorder(upperBorderPath);
  48862. }
  48863. if (axis.grid.upperBorder) {
  48864. axis.grid.upperBorder.animate({
  48865. d: upperBorderPath
  48866. });
  48867. }
  48868. if (!axis.grid.lowerBorder && axis.max % 1 !== 0) {
  48869. axis.grid.lowerBorder = axis.grid.renderBorder(lowerBorderPath);
  48870. }
  48871. if (axis.grid.lowerBorder) {
  48872. axis.grid.lowerBorder.animate({
  48873. d: lowerBorderPath
  48874. });
  48875. }
  48876. }
  48877. // Render an extra line parallel to the existing axes,
  48878. // to close the grid.
  48879. if (!axis.grid.axisLineExtra) {
  48880. axis.grid.axisLineExtra = axis.grid.renderBorder(linePath);
  48881. }
  48882. else {
  48883. axis.grid.axisLineExtra.animate({
  48884. d: linePath
  48885. });
  48886. }
  48887. // show or hide the line depending on
  48888. // options.showEmpty
  48889. axis.axisLine[axis.showAxis ? 'show' : 'hide'](true);
  48890. }
  48891. }
  48892. (grid && grid.columns || []).forEach(function (column) {
  48893. column.render();
  48894. });
  48895. // Manipulate the tick mark visibility
  48896. // based on the axis.max- allows smooth scrolling.
  48897. if (!axis.horiz &&
  48898. axis.chart.hasRendered &&
  48899. (axis.scrollbar ||
  48900. (axis.linkedParent && axis.linkedParent.scrollbar))) {
  48901. var max = axis.max,
  48902. min = axis.min,
  48903. tickmarkOffset = axis.tickmarkOffset,
  48904. lastTick = axis.tickPositions[axis.tickPositions.length - 1],
  48905. firstTick = axis.tickPositions[0];
  48906. // Hide/show firts tick label.
  48907. if (min - firstTick > tickmarkOffset) {
  48908. axis.ticks[firstTick].label.hide();
  48909. }
  48910. else {
  48911. axis.ticks[firstTick].label.show();
  48912. }
  48913. // Hide/show last tick mark/label.
  48914. if (lastTick - max > tickmarkOffset) {
  48915. axis.ticks[lastTick].label.hide();
  48916. }
  48917. else {
  48918. axis.ticks[lastTick].label.show();
  48919. }
  48920. if (lastTick - max < tickmarkOffset && lastTick - max > 0 && axis.ticks[lastTick].isLast) {
  48921. axis.ticks[lastTick].mark.hide();
  48922. }
  48923. else if (axis.ticks[lastTick - 1]) {
  48924. axis.ticks[lastTick - 1].mark.show();
  48925. }
  48926. }
  48927. }
  48928. };
  48929. /**
  48930. * @private
  48931. */
  48932. GridAxis.onAfterSetAxisTranslation = function () {
  48933. var axis = this;
  48934. var tickInfo = axis.tickPositions && axis.tickPositions.info;
  48935. var options = axis.options;
  48936. var gridOptions = options.grid || {};
  48937. var userLabels = axis.userOptions.labels || {};
  48938. // Fire this only for the Gantt type chart, #14868.
  48939. if (gridOptions.enabled) {
  48940. if (axis.horiz) {
  48941. axis.series.forEach(function (series) {
  48942. series.options.pointRange = 0;
  48943. });
  48944. // Lower level time ticks, like hours or minutes, represent
  48945. // points in time and not ranges. These should be aligned
  48946. // left in the grid cell by default. The same applies to
  48947. // years of higher order.
  48948. if (tickInfo &&
  48949. options.dateTimeLabelFormats &&
  48950. options.labels &&
  48951. !defined(userLabels.align) &&
  48952. (options.dateTimeLabelFormats[tickInfo.unitName].range === false ||
  48953. tickInfo.count > 1 // years
  48954. )) {
  48955. options.labels.align = 'left';
  48956. if (!defined(userLabels.x)) {
  48957. options.labels.x = 3;
  48958. }
  48959. }
  48960. }
  48961. else {
  48962. // Don't trim ticks which not in min/max range but
  48963. // they are still in the min/max plus tickInterval.
  48964. if (this.options.type !== 'treegrid' &&
  48965. axis.grid &&
  48966. axis.grid.columns) {
  48967. this.minPointOffset = this.tickInterval;
  48968. }
  48969. }
  48970. }
  48971. };
  48972. /**
  48973. * Creates a left and right wall on horizontal axes:
  48974. * - Places leftmost tick at the start of the axis, to create a left
  48975. * wall
  48976. * - Ensures that the rightmost tick is at the end of the axis, to
  48977. * create a right wall.
  48978. * @private
  48979. */
  48980. GridAxis.onAfterSetOptions = function (e) {
  48981. var options = this.options,
  48982. userOptions = e.userOptions,
  48983. gridAxisOptions,
  48984. gridOptions = ((options && isObject(options.grid)) ? options.grid : {});
  48985. if (gridOptions.enabled === true) {
  48986. // Merge the user options into default grid axis options so
  48987. // that when a user option is set, it takes presedence.
  48988. gridAxisOptions = merge(true, {
  48989. className: ('highcharts-grid-axis ' + (userOptions.className || '')),
  48990. dateTimeLabelFormats: {
  48991. hour: {
  48992. list: ['%H:%M', '%H']
  48993. },
  48994. day: {
  48995. list: ['%A, %e. %B', '%a, %e. %b', '%E']
  48996. },
  48997. week: {
  48998. list: ['Week %W', 'W%W']
  48999. },
  49000. month: {
  49001. list: ['%B', '%b', '%o']
  49002. }
  49003. },
  49004. grid: {
  49005. borderWidth: 1
  49006. },
  49007. labels: {
  49008. padding: 2,
  49009. style: {
  49010. fontSize: '13px'
  49011. }
  49012. },
  49013. margin: 0,
  49014. title: {
  49015. text: null,
  49016. reserveSpace: false,
  49017. rotation: 0
  49018. },
  49019. // In a grid axis, only allow one unit of certain types,
  49020. // for example we shouln't have one grid cell spanning
  49021. // two days.
  49022. units: [[
  49023. 'millisecond',
  49024. [1, 10, 100]
  49025. ], [
  49026. 'second',
  49027. [1, 10]
  49028. ], [
  49029. 'minute',
  49030. [1, 5, 15]
  49031. ], [
  49032. 'hour',
  49033. [1, 6]
  49034. ], [
  49035. 'day',
  49036. [1]
  49037. ], [
  49038. 'week',
  49039. [1]
  49040. ], [
  49041. 'month',
  49042. [1]
  49043. ], [
  49044. 'year',
  49045. null
  49046. ]]
  49047. }, userOptions);
  49048. // X-axis specific options
  49049. if (this.coll === 'xAxis') {
  49050. // For linked axes, tickPixelInterval is used only if
  49051. // the tickPositioner below doesn't run or returns
  49052. // undefined (like multiple years)
  49053. if (defined(userOptions.linkedTo) &&
  49054. !defined(userOptions.tickPixelInterval)) {
  49055. gridAxisOptions.tickPixelInterval = 350;
  49056. }
  49057. // For the secondary grid axis, use the primary axis'
  49058. // tick intervals and return ticks one level higher.
  49059. if (
  49060. // Check for tick pixel interval in options
  49061. !defined(userOptions.tickPixelInterval) &&
  49062. // Only for linked axes
  49063. defined(userOptions.linkedTo) &&
  49064. !defined(userOptions.tickPositioner) &&
  49065. !defined(userOptions.tickInterval)) {
  49066. gridAxisOptions.tickPositioner = function (min, max) {
  49067. var parentInfo = (this.linkedParent &&
  49068. this.linkedParent.tickPositions &&
  49069. this.linkedParent.tickPositions.info);
  49070. if (parentInfo) {
  49071. var unitIdx = void 0,
  49072. count = void 0,
  49073. unitName = void 0,
  49074. i = void 0,
  49075. units = gridAxisOptions.units,
  49076. unitRange = void 0;
  49077. for (i = 0; i < units.length; i++) {
  49078. if (units[i][0] ===
  49079. parentInfo.unitName) {
  49080. unitIdx = i;
  49081. break;
  49082. }
  49083. }
  49084. // Get the first allowed count on the next
  49085. // unit.
  49086. if (units[unitIdx + 1]) {
  49087. unitName = units[unitIdx + 1][0];
  49088. count =
  49089. (units[unitIdx + 1][1] || [1])[0];
  49090. // In case the base X axis shows years, make
  49091. // the secondary axis show ten times the
  49092. // years (#11427)
  49093. }
  49094. else if (parentInfo.unitName === 'year') {
  49095. unitName = 'year';
  49096. count = parentInfo.count * 10;
  49097. }
  49098. unitRange = timeUnits[unitName];
  49099. this.tickInterval = unitRange * count;
  49100. return this.getTimeTicks({
  49101. unitRange: unitRange,
  49102. count: count,
  49103. unitName: unitName
  49104. }, min, max, this.options.startOfWeek);
  49105. }
  49106. };
  49107. }
  49108. }
  49109. // Now merge the combined options into the axis options
  49110. merge(true, this.options, gridAxisOptions);
  49111. if (this.horiz) {
  49112. /* _________________________
  49113. Make this: ___|_____|_____|_____|__|
  49114. ^ ^
  49115. _________________________
  49116. Into this: |_____|_____|_____|_____|
  49117. ^ ^ */
  49118. options.minPadding = pick(userOptions.minPadding, 0);
  49119. options.maxPadding = pick(userOptions.maxPadding, 0);
  49120. }
  49121. // If borderWidth is set, then use its value for tick and
  49122. // line width.
  49123. if (isNumber(options.grid.borderWidth)) {
  49124. options.tickWidth = options.lineWidth =
  49125. gridOptions.borderWidth;
  49126. }
  49127. }
  49128. };
  49129. /**
  49130. * @private
  49131. */
  49132. GridAxis.onAfterSetOptions2 = function (e) {
  49133. var axis = this;
  49134. var userOptions = e.userOptions;
  49135. var gridOptions = userOptions && userOptions.grid || {};
  49136. var columns = gridOptions.columns;
  49137. // Add column options to the parent axis. Children has their column
  49138. // options set on init in onGridAxisAfterInit.
  49139. if (gridOptions.enabled && columns) {
  49140. merge(true, axis.options, columns[columns.length - 1]);
  49141. }
  49142. };
  49143. /**
  49144. * Handle columns and setScale.
  49145. * @private
  49146. */
  49147. GridAxis.onAfterSetScale = function () {
  49148. var axis = this;
  49149. (axis.grid.columns || []).forEach(function (column) {
  49150. column.setScale();
  49151. });
  49152. };
  49153. /**
  49154. * Draw vertical axis ticks extra long to create cell floors and roofs.
  49155. * Overrides the tickLength for vertical axes.
  49156. * @private
  49157. */
  49158. GridAxis.onAfterTickSize = function (e) {
  49159. var defaultLeftAxisOptions = Axis.defaultLeftAxisOptions;
  49160. var _a = this,
  49161. horiz = _a.horiz,
  49162. maxLabelDimensions = _a.maxLabelDimensions,
  49163. _b = _a.options.grid,
  49164. gridOptions = _b === void 0 ? {} : _b;
  49165. if (gridOptions.enabled && maxLabelDimensions) {
  49166. var labelPadding = (Math.abs(defaultLeftAxisOptions.labels.x) * 2);
  49167. var distance = horiz ?
  49168. gridOptions.cellHeight || labelPadding + maxLabelDimensions.height :
  49169. labelPadding + maxLabelDimensions.width;
  49170. if (isArray(e.tickSize)) {
  49171. e.tickSize[0] = distance;
  49172. }
  49173. else {
  49174. e.tickSize = [distance, 0];
  49175. }
  49176. }
  49177. };
  49178. /**
  49179. * @private
  49180. */
  49181. GridAxis.onDestroy = function (e) {
  49182. var grid = this.grid;
  49183. (grid.columns || []).forEach(function (column) {
  49184. column.destroy(e.keepEvents);
  49185. });
  49186. grid.columns = void 0;
  49187. };
  49188. /**
  49189. * Wraps axis init to draw cell walls on vertical axes.
  49190. * @private
  49191. */
  49192. GridAxis.onInit = function (e) {
  49193. var axis = this;
  49194. var userOptions = e.userOptions || {};
  49195. var gridOptions = userOptions.grid || {};
  49196. if (gridOptions.enabled && defined(gridOptions.borderColor)) {
  49197. userOptions.tickColor = userOptions.lineColor = gridOptions.borderColor;
  49198. }
  49199. if (!axis.grid) {
  49200. axis.grid = new GridAxisAdditions(axis);
  49201. }
  49202. };
  49203. /**
  49204. * Makes tick labels which are usually ignored in a linked axis
  49205. * displayed if they are within range of linkedParent.min.
  49206. * ```
  49207. * _____________________________
  49208. * | | | | |
  49209. * Make this: | | 2 | 3 | 4 |
  49210. * |___|_______|_______|_______|
  49211. * ^
  49212. * _____________________________
  49213. * | | | | |
  49214. * Into this: | 1 | 2 | 3 | 4 |
  49215. * |___|_______|_______|_______|
  49216. * ^
  49217. * ```
  49218. * @private
  49219. * @todo Does this function do what the drawing says? Seems to affect
  49220. * ticks and not the labels directly?
  49221. */
  49222. GridAxis.onTrimTicks = function () {
  49223. var axis = this;
  49224. var options = axis.options;
  49225. var gridOptions = options.grid || {};
  49226. var categoryAxis = axis.categories;
  49227. var tickPositions = axis.tickPositions;
  49228. var firstPos = tickPositions[0];
  49229. var lastPos = tickPositions[tickPositions.length - 1];
  49230. var linkedMin = axis.linkedParent && axis.linkedParent.min;
  49231. var linkedMax = axis.linkedParent && axis.linkedParent.max;
  49232. var min = linkedMin || axis.min;
  49233. var max = linkedMax || axis.max;
  49234. var tickInterval = axis.tickInterval;
  49235. var endMoreThanMin = (firstPos < min &&
  49236. firstPos + tickInterval > min);
  49237. var startLessThanMax = (lastPos > max &&
  49238. lastPos - tickInterval < max);
  49239. if (gridOptions.enabled === true &&
  49240. !categoryAxis &&
  49241. (axis.horiz || axis.isLinked)) {
  49242. if (endMoreThanMin && !options.startOnTick) {
  49243. tickPositions[0] = min;
  49244. }
  49245. if (startLessThanMax && !options.endOnTick) {
  49246. tickPositions[tickPositions.length - 1] = max;
  49247. }
  49248. }
  49249. };
  49250. /**
  49251. * Avoid altering tickInterval when reserving space.
  49252. * @private
  49253. */
  49254. GridAxis.wrapUnsquish = function (proceed) {
  49255. var axis = this;
  49256. var _a = axis.options.grid,
  49257. gridOptions = _a === void 0 ? {} : _a;
  49258. if (gridOptions.enabled === true && axis.categories) {
  49259. return axis.tickInterval;
  49260. }
  49261. return proceed.apply(axis, argsToArray(arguments));
  49262. };
  49263. return GridAxis;
  49264. }());
  49265. (function (GridAxis) {
  49266. /**
  49267. * Enum for which side the axis is on. Maps to axis.side.
  49268. * @private
  49269. */
  49270. var Side;
  49271. (function (Side) {
  49272. Side[Side["top"] = 0] = "top";
  49273. Side[Side["right"] = 1] = "right";
  49274. Side[Side["bottom"] = 2] = "bottom";
  49275. Side[Side["left"] = 3] = "left";
  49276. })(Side = GridAxis.Side || (GridAxis.Side = {}));
  49277. })(GridAxis || (GridAxis = {}));
  49278. GridAxis.compose(Axis);
  49279. return GridAxis;
  49280. });
  49281. _registerModule(_modules, 'Core/Axis/BrokenAxis.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Series/Series.js'], _modules['Extensions/Stacking.js'], _modules['Core/Utilities.js']], function (Axis, Series, StackItem, U) {
  49282. /* *
  49283. *
  49284. * (c) 2009-2021 Torstein Honsi
  49285. *
  49286. * License: www.highcharts.com/license
  49287. *
  49288. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  49289. *
  49290. * */
  49291. var addEvent = U.addEvent,
  49292. find = U.find,
  49293. fireEvent = U.fireEvent,
  49294. isArray = U.isArray,
  49295. isNumber = U.isNumber,
  49296. pick = U.pick;
  49297. /* eslint-disable valid-jsdoc */
  49298. /**
  49299. * Provides support for broken axes.
  49300. * @private
  49301. * @class
  49302. */
  49303. var BrokenAxisAdditions = /** @class */ (function () {
  49304. /* *
  49305. *
  49306. * Constructors
  49307. *
  49308. * */
  49309. function BrokenAxisAdditions(axis) {
  49310. this.hasBreaks = false;
  49311. this.axis = axis;
  49312. }
  49313. /* *
  49314. *
  49315. * Static Functions
  49316. *
  49317. * */
  49318. /**
  49319. * @private
  49320. */
  49321. BrokenAxisAdditions.isInBreak = function (brk, val) {
  49322. var ret,
  49323. repeat = brk.repeat || Infinity,
  49324. from = brk.from,
  49325. length = brk.to - brk.from,
  49326. test = (val >= from ?
  49327. (val - from) % repeat :
  49328. repeat - ((from - val) % repeat));
  49329. if (!brk.inclusive) {
  49330. ret = test < length && test !== 0;
  49331. }
  49332. else {
  49333. ret = test <= length;
  49334. }
  49335. return ret;
  49336. };
  49337. /**
  49338. * @private
  49339. */
  49340. BrokenAxisAdditions.lin2Val = function (val) {
  49341. var axis = this;
  49342. var brokenAxis = axis.brokenAxis;
  49343. var breakArray = brokenAxis && brokenAxis.breakArray;
  49344. if (!breakArray || !isNumber(val)) {
  49345. return val;
  49346. }
  49347. var nval = val,
  49348. brk,
  49349. i;
  49350. for (i = 0; i < breakArray.length; i++) {
  49351. brk = breakArray[i];
  49352. if (brk.from >= nval) {
  49353. break;
  49354. }
  49355. else if (brk.to < nval) {
  49356. nval += brk.len;
  49357. }
  49358. else if (BrokenAxisAdditions.isInBreak(brk, nval)) {
  49359. nval += brk.len;
  49360. }
  49361. }
  49362. return nval;
  49363. };
  49364. /**
  49365. * @private
  49366. */
  49367. BrokenAxisAdditions.val2Lin = function (val) {
  49368. var axis = this;
  49369. var brokenAxis = axis.brokenAxis;
  49370. var breakArray = brokenAxis && brokenAxis.breakArray;
  49371. if (!breakArray || !isNumber(val)) {
  49372. return val;
  49373. }
  49374. var nval = val,
  49375. brk,
  49376. i;
  49377. for (i = 0; i < breakArray.length; i++) {
  49378. brk = breakArray[i];
  49379. if (brk.to <= val) {
  49380. nval -= brk.len;
  49381. }
  49382. else if (brk.from >= val) {
  49383. break;
  49384. }
  49385. else if (BrokenAxisAdditions.isInBreak(brk, val)) {
  49386. nval -= (val - brk.from);
  49387. break;
  49388. }
  49389. }
  49390. return nval;
  49391. };
  49392. /* *
  49393. *
  49394. * Functions
  49395. *
  49396. * */
  49397. /**
  49398. * Returns the first break found where the x is larger then break.from and
  49399. * smaller then break.to.
  49400. *
  49401. * @param {number} x
  49402. * The number which should be within a break.
  49403. *
  49404. * @param {Array<Highcharts.XAxisBreaksOptions>} breaks
  49405. * The array of breaks to search within.
  49406. *
  49407. * @return {Highcharts.XAxisBreaksOptions|undefined}
  49408. * Returns the first break found that matches, returns false if no break is
  49409. * found.
  49410. */
  49411. BrokenAxisAdditions.prototype.findBreakAt = function (x, breaks) {
  49412. return find(breaks, function (b) {
  49413. return b.from < x && x < b.to;
  49414. });
  49415. };
  49416. /**
  49417. * @private
  49418. */
  49419. BrokenAxisAdditions.prototype.isInAnyBreak = function (val, testKeep) {
  49420. var brokenAxis = this;
  49421. var axis = brokenAxis.axis;
  49422. var breaks = axis.options.breaks || [],
  49423. i = breaks.length,
  49424. inbrk,
  49425. keep,
  49426. ret;
  49427. if (i && isNumber(val)) {
  49428. while (i--) {
  49429. if (BrokenAxisAdditions.isInBreak(breaks[i], val)) {
  49430. inbrk = true;
  49431. if (!keep) {
  49432. keep = pick(breaks[i].showPoints, !axis.isXAxis);
  49433. }
  49434. }
  49435. }
  49436. if (inbrk && testKeep) {
  49437. ret = inbrk && !keep;
  49438. }
  49439. else {
  49440. ret = inbrk;
  49441. }
  49442. }
  49443. return ret;
  49444. };
  49445. /**
  49446. * Dynamically set or unset breaks in an axis. This function in lighter than
  49447. * usin Axis.update, and it also preserves animation.
  49448. *
  49449. * @private
  49450. * @function Highcharts.Axis#setBreaks
  49451. *
  49452. * @param {Array<Highcharts.XAxisBreaksOptions>} [breaks]
  49453. * The breaks to add. When `undefined` it removes existing breaks.
  49454. *
  49455. * @param {boolean} [redraw=true]
  49456. * Whether to redraw the chart immediately.
  49457. *
  49458. * @return {void}
  49459. */
  49460. BrokenAxisAdditions.prototype.setBreaks = function (breaks, redraw) {
  49461. var brokenAxis = this;
  49462. var axis = brokenAxis.axis;
  49463. var hasBreaks = (isArray(breaks) && !!breaks.length);
  49464. axis.isDirty = brokenAxis.hasBreaks !== hasBreaks;
  49465. brokenAxis.hasBreaks = hasBreaks;
  49466. axis.options.breaks = axis.userOptions.breaks = breaks;
  49467. axis.forceRedraw = true; // Force recalculation in setScale
  49468. // Recalculate series related to the axis.
  49469. axis.series.forEach(function (series) {
  49470. series.isDirty = true;
  49471. });
  49472. if (!hasBreaks && axis.val2lin === BrokenAxisAdditions.val2Lin) {
  49473. // Revert to prototype functions
  49474. delete axis.val2lin;
  49475. delete axis.lin2val;
  49476. }
  49477. if (hasBreaks) {
  49478. axis.userOptions.ordinal = false;
  49479. axis.lin2val = BrokenAxisAdditions.lin2Val;
  49480. axis.val2lin = BrokenAxisAdditions.val2Lin;
  49481. axis.setExtremes = function (newMin, newMax, redraw, animation, eventArguments) {
  49482. // If trying to set extremes inside a break, extend min to
  49483. // after, and max to before the break ( #3857 )
  49484. if (brokenAxis.hasBreaks) {
  49485. var axisBreak = void 0,
  49486. breaks_1 = this.options.breaks;
  49487. while ((axisBreak = brokenAxis.findBreakAt(newMin, breaks_1))) {
  49488. newMin = axisBreak.to;
  49489. }
  49490. while ((axisBreak = brokenAxis.findBreakAt(newMax, breaks_1))) {
  49491. newMax = axisBreak.from;
  49492. }
  49493. // If both min and max is within the same break.
  49494. if (newMax < newMin) {
  49495. newMax = newMin;
  49496. }
  49497. }
  49498. Axis.prototype.setExtremes.call(this, newMin, newMax, redraw, animation, eventArguments);
  49499. };
  49500. axis.setAxisTranslation = function () {
  49501. Axis.prototype.setAxisTranslation.call(this);
  49502. brokenAxis.unitLength = void 0;
  49503. if (brokenAxis.hasBreaks) {
  49504. var breaks_2 = axis.options.breaks || [],
  49505. // Temporary one:
  49506. breakArrayT_1 = [],
  49507. breakArray_1 = [],
  49508. length_1 = 0,
  49509. inBrk_1,
  49510. repeat_1,
  49511. min_1 = axis.userMin || axis.min,
  49512. max_1 = axis.userMax || axis.max,
  49513. pointRangePadding = pick(axis.pointRangePadding, 0),
  49514. start_1,
  49515. i_1;
  49516. // Min & max check (#4247)
  49517. breaks_2.forEach(function (brk) {
  49518. repeat_1 = brk.repeat || Infinity;
  49519. if (isNumber(min_1) && isNumber(max_1)) {
  49520. if (BrokenAxisAdditions.isInBreak(brk, min_1)) {
  49521. min_1 += (brk.to % repeat_1) - (min_1 % repeat_1);
  49522. }
  49523. if (BrokenAxisAdditions.isInBreak(brk, max_1)) {
  49524. max_1 -= (max_1 % repeat_1) - (brk.from % repeat_1);
  49525. }
  49526. }
  49527. });
  49528. // Construct an array holding all breaks in the axis
  49529. breaks_2.forEach(function (brk) {
  49530. start_1 = brk.from;
  49531. repeat_1 = brk.repeat || Infinity;
  49532. if (isNumber(min_1) && isNumber(max_1)) {
  49533. while (start_1 - repeat_1 > min_1) {
  49534. start_1 -= repeat_1;
  49535. }
  49536. while (start_1 < min_1) {
  49537. start_1 += repeat_1;
  49538. }
  49539. for (i_1 = start_1; i_1 < max_1; i_1 += repeat_1) {
  49540. breakArrayT_1.push({
  49541. value: i_1,
  49542. move: 'in'
  49543. });
  49544. breakArrayT_1.push({
  49545. value: i_1 + brk.to - brk.from,
  49546. move: 'out',
  49547. size: brk.breakSize
  49548. });
  49549. }
  49550. }
  49551. });
  49552. breakArrayT_1.sort(function (a, b) {
  49553. return ((a.value === b.value) ?
  49554. ((a.move === 'in' ? 0 : 1) -
  49555. (b.move === 'in' ? 0 : 1)) :
  49556. a.value - b.value);
  49557. });
  49558. // Simplify the breaks
  49559. inBrk_1 = 0;
  49560. start_1 = min_1;
  49561. breakArrayT_1.forEach(function (brk) {
  49562. inBrk_1 += (brk.move === 'in' ? 1 : -1);
  49563. if (inBrk_1 === 1 && brk.move === 'in') {
  49564. start_1 = brk.value;
  49565. }
  49566. if (inBrk_1 === 0 && isNumber(start_1)) {
  49567. breakArray_1.push({
  49568. from: start_1,
  49569. to: brk.value,
  49570. len: brk.value - start_1 - (brk.size || 0)
  49571. });
  49572. length_1 += brk.value - start_1 - (brk.size || 0);
  49573. }
  49574. });
  49575. brokenAxis.breakArray = breakArray_1;
  49576. // Used with staticScale, and below the actual axis length,
  49577. // when breaks are substracted.
  49578. if (isNumber(min_1) && isNumber(max_1) && isNumber(axis.min)) {
  49579. brokenAxis.unitLength = max_1 - min_1 - length_1 +
  49580. pointRangePadding;
  49581. fireEvent(axis, 'afterBreaks');
  49582. if (axis.staticScale) {
  49583. axis.transA = axis.staticScale;
  49584. }
  49585. else if (brokenAxis.unitLength) {
  49586. axis.transA *=
  49587. (max_1 - axis.min + pointRangePadding) /
  49588. brokenAxis.unitLength;
  49589. }
  49590. if (pointRangePadding) {
  49591. axis.minPixelPadding =
  49592. axis.transA * (axis.minPointOffset || 0);
  49593. }
  49594. axis.min = min_1;
  49595. axis.max = max_1;
  49596. }
  49597. }
  49598. };
  49599. }
  49600. if (pick(redraw, true)) {
  49601. axis.chart.redraw();
  49602. }
  49603. };
  49604. return BrokenAxisAdditions;
  49605. }());
  49606. /**
  49607. * Axis with support of broken data rows.
  49608. * @private
  49609. * @class
  49610. */
  49611. var BrokenAxis = /** @class */ (function () {
  49612. function BrokenAxis() {
  49613. }
  49614. /**
  49615. * Adds support for broken axes.
  49616. * @private
  49617. */
  49618. BrokenAxis.compose = function (AxisClass, SeriesClass) {
  49619. AxisClass.keepProps.push('brokenAxis');
  49620. var seriesProto = Series.prototype;
  49621. /**
  49622. * @private
  49623. */
  49624. seriesProto.drawBreaks = function (axis, keys) {
  49625. var series = this,
  49626. points = series.points,
  49627. breaks,
  49628. threshold,
  49629. eventName,
  49630. y;
  49631. if (axis && // #5950
  49632. axis.brokenAxis &&
  49633. axis.brokenAxis.hasBreaks) {
  49634. var brokenAxis_1 = axis.brokenAxis;
  49635. keys.forEach(function (key) {
  49636. breaks = brokenAxis_1 && brokenAxis_1.breakArray || [];
  49637. threshold = axis.isXAxis ?
  49638. axis.min :
  49639. pick(series.options.threshold, axis.min);
  49640. points.forEach(function (point) {
  49641. y = pick(point['stack' + key.toUpperCase()], point[key]);
  49642. breaks.forEach(function (brk) {
  49643. if (isNumber(threshold) && isNumber(y)) {
  49644. eventName = false;
  49645. if ((threshold < brk.from && y > brk.to) ||
  49646. (threshold > brk.from && y < brk.from)) {
  49647. eventName = 'pointBreak';
  49648. }
  49649. else if ((threshold < brk.from && y > brk.from && y < brk.to) ||
  49650. (threshold > brk.from && y > brk.to && y < brk.from)) {
  49651. eventName = 'pointInBreak';
  49652. }
  49653. if (eventName) {
  49654. fireEvent(axis, eventName, { point: point, brk: brk });
  49655. }
  49656. }
  49657. });
  49658. });
  49659. });
  49660. }
  49661. };
  49662. /**
  49663. * Extend getGraphPath by identifying gaps in the data so that we can
  49664. * draw a gap in the line or area. This was moved from ordinal axis
  49665. * module to broken axis module as of #5045.
  49666. *
  49667. * @private
  49668. * @function Highcharts.Series#gappedPath
  49669. *
  49670. * @return {Highcharts.SVGPathArray}
  49671. * Gapped path
  49672. */
  49673. seriesProto.gappedPath = function () {
  49674. var currentDataGrouping = this.currentDataGrouping,
  49675. groupingSize = currentDataGrouping && currentDataGrouping.gapSize,
  49676. gapSize = this.options.gapSize,
  49677. points = this.points.slice(),
  49678. i = points.length - 1,
  49679. yAxis = this.yAxis,
  49680. stack;
  49681. /**
  49682. * Defines when to display a gap in the graph, together with the
  49683. * [gapUnit](plotOptions.series.gapUnit) option.
  49684. *
  49685. * In case when `dataGrouping` is enabled, points can be grouped
  49686. * into a larger time span. This can make the grouped points to have
  49687. * a greater distance than the absolute value of `gapSize` property,
  49688. * which will result in disappearing graph completely. To prevent
  49689. * this situation the mentioned distance between grouped points is
  49690. * used instead of previously defined `gapSize`.
  49691. *
  49692. * In practice, this option is most often used to visualize gaps in
  49693. * time series. In a stock chart, intraday data is available for
  49694. * daytime hours, while gaps will appear in nights and weekends.
  49695. *
  49696. * @see [gapUnit](plotOptions.series.gapUnit)
  49697. * @see [xAxis.breaks](#xAxis.breaks)
  49698. *
  49699. * @sample {highstock} stock/plotoptions/series-gapsize/
  49700. * Setting the gap size to 2 introduces gaps for weekends
  49701. * in daily datasets.
  49702. *
  49703. * @type {number}
  49704. * @default 0
  49705. * @product highstock
  49706. * @requires modules/broken-axis
  49707. * @apioption plotOptions.series.gapSize
  49708. */
  49709. /**
  49710. * Together with [gapSize](plotOptions.series.gapSize), this option
  49711. * defines where to draw gaps in the graph.
  49712. *
  49713. * When the `gapUnit` is `"relative"` (default), a gap size of 5
  49714. * means that if the distance between two points is greater than
  49715. * 5 times that of the two closest points, the graph will be broken.
  49716. *
  49717. * When the `gapUnit` is `"value"`, the gap is based on absolute
  49718. * axis values, which on a datetime axis is milliseconds. This also
  49719. * applies to the navigator series that inherits gap options from
  49720. * the base series.
  49721. *
  49722. * @see [gapSize](plotOptions.series.gapSize)
  49723. *
  49724. * @type {string}
  49725. * @default relative
  49726. * @since 5.0.13
  49727. * @product highstock
  49728. * @validvalue ["relative", "value"]
  49729. * @requires modules/broken-axis
  49730. * @apioption plotOptions.series.gapUnit
  49731. */
  49732. if (gapSize && i > 0) { // #5008
  49733. // Gap unit is relative
  49734. if (this.options.gapUnit !== 'value') {
  49735. gapSize *= this.basePointRange;
  49736. }
  49737. // Setting a new gapSize in case dataGrouping is enabled (#7686)
  49738. if (groupingSize &&
  49739. groupingSize > gapSize &&
  49740. // Except when DG is forced (e.g. from other series)
  49741. // and has lower granularity than actual points (#11351)
  49742. groupingSize >= this.basePointRange) {
  49743. gapSize = groupingSize;
  49744. }
  49745. // extension for ordinal breaks
  49746. var current = void 0,
  49747. next = void 0;
  49748. while (i--) {
  49749. // Reassign next if it is not visible
  49750. if (!(next && next.visible !== false)) {
  49751. next = points[i + 1];
  49752. }
  49753. current = points[i];
  49754. // Skip iteration if one of the points is not visible
  49755. if (next.visible === false || current.visible === false) {
  49756. continue;
  49757. }
  49758. if (next.x - current.x > gapSize) {
  49759. var xRange = (current.x + next.x) / 2;
  49760. points.splice(// insert after this one
  49761. i + 1, 0, {
  49762. isNull: true,
  49763. x: xRange
  49764. });
  49765. // For stacked chart generate empty stack items, #6546
  49766. if (yAxis.stacking && this.options.stacking) {
  49767. stack = yAxis.stacking.stacks[this.stackKey][xRange] =
  49768. new StackItem(yAxis, yAxis.options
  49769. .stackLabels, false, xRange, this.stack);
  49770. stack.total = 0;
  49771. }
  49772. }
  49773. // Assign current to next for the upcoming iteration
  49774. next = current;
  49775. }
  49776. }
  49777. // Call base method
  49778. return this.getGraphPath(points);
  49779. };
  49780. /* eslint-disable no-invalid-this */
  49781. addEvent(AxisClass, 'init', function () {
  49782. var axis = this;
  49783. if (!axis.brokenAxis) {
  49784. axis.brokenAxis = new BrokenAxisAdditions(axis);
  49785. }
  49786. });
  49787. addEvent(AxisClass, 'afterInit', function () {
  49788. if (typeof this.brokenAxis !== 'undefined') {
  49789. this.brokenAxis.setBreaks(this.options.breaks, false);
  49790. }
  49791. });
  49792. addEvent(AxisClass, 'afterSetTickPositions', function () {
  49793. var axis = this;
  49794. var brokenAxis = axis.brokenAxis;
  49795. if (brokenAxis &&
  49796. brokenAxis.hasBreaks) {
  49797. var tickPositions = this.tickPositions,
  49798. info = this.tickPositions.info,
  49799. newPositions = [],
  49800. i = void 0;
  49801. for (i = 0; i < tickPositions.length; i++) {
  49802. if (!brokenAxis.isInAnyBreak(tickPositions[i])) {
  49803. newPositions.push(tickPositions[i]);
  49804. }
  49805. }
  49806. this.tickPositions = newPositions;
  49807. this.tickPositions.info = info;
  49808. }
  49809. });
  49810. // Force Axis to be not-ordinal when breaks are defined
  49811. addEvent(AxisClass, 'afterSetOptions', function () {
  49812. if (this.brokenAxis && this.brokenAxis.hasBreaks) {
  49813. this.options.ordinal = false;
  49814. }
  49815. });
  49816. addEvent(SeriesClass, 'afterGeneratePoints', function () {
  49817. var _a = this,
  49818. isDirty = _a.isDirty,
  49819. connectNulls = _a.options.connectNulls,
  49820. points = _a.points,
  49821. xAxis = _a.xAxis,
  49822. yAxis = _a.yAxis;
  49823. // Set, or reset visibility of the points. Axis.setBreaks marks the
  49824. // series as isDirty
  49825. if (isDirty) {
  49826. var i = points.length;
  49827. while (i--) {
  49828. var point = points[i];
  49829. // Respect nulls inside the break (#4275)
  49830. var nullGap = point.y === null && connectNulls === false;
  49831. var isPointInBreak = (!nullGap && ((xAxis &&
  49832. xAxis.brokenAxis &&
  49833. xAxis.brokenAxis.isInAnyBreak(point.x,
  49834. true)) || (yAxis &&
  49835. yAxis.brokenAxis &&
  49836. yAxis.brokenAxis.isInAnyBreak(point.y,
  49837. true))));
  49838. // Set point.visible if in any break.
  49839. // If not in break, reset visible to original value.
  49840. point.visible = isPointInBreak ?
  49841. false :
  49842. point.options.visible !== false;
  49843. }
  49844. }
  49845. });
  49846. addEvent(SeriesClass, 'afterRender', function drawPointsWrapped() {
  49847. this.drawBreaks(this.xAxis, ['x']);
  49848. this.drawBreaks(this.yAxis, pick(this.pointArrayMap, ['y']));
  49849. });
  49850. };
  49851. return BrokenAxis;
  49852. }());
  49853. BrokenAxis.compose(Axis, Series); // @todo remove automatism
  49854. return BrokenAxis;
  49855. });
  49856. _registerModule(_modules, 'Core/Axis/TreeGridAxis.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Axis/Tick.js'], _modules['Gantt/Tree.js'], _modules['Core/Axis/TreeGridTick.js'], _modules['Mixins/TreeSeries.js'], _modules['Core/Utilities.js']], function (Axis, Tick, Tree, TreeGridTick, mixinTreeSeries, U) {
  49857. /* *
  49858. *
  49859. * (c) 2016 Highsoft AS
  49860. * Authors: Jon Arild Nygard
  49861. *
  49862. * License: www.highcharts.com/license
  49863. *
  49864. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  49865. *
  49866. * */
  49867. var getLevelOptions = mixinTreeSeries.getLevelOptions;
  49868. var addEvent = U.addEvent,
  49869. find = U.find,
  49870. fireEvent = U.fireEvent,
  49871. isArray = U.isArray,
  49872. isNumber = U.isNumber,
  49873. isObject = U.isObject,
  49874. isString = U.isString,
  49875. merge = U.merge,
  49876. pick = U.pick,
  49877. wrap = U.wrap;
  49878. /**
  49879. * @private
  49880. */
  49881. var TreeGridAxis;
  49882. (function (TreeGridAxis) {
  49883. /* *
  49884. *
  49885. * Interfaces
  49886. *
  49887. * */
  49888. /* *
  49889. *
  49890. * Variables
  49891. *
  49892. * */
  49893. var applied = false;
  49894. /* *
  49895. *
  49896. * Functions
  49897. *
  49898. * */
  49899. /**
  49900. * @private
  49901. */
  49902. function compose(AxisClass) {
  49903. if (!applied) {
  49904. wrap(AxisClass.prototype, 'generateTick', wrapGenerateTick);
  49905. wrap(AxisClass.prototype, 'getMaxLabelDimensions', wrapGetMaxLabelDimensions);
  49906. wrap(AxisClass.prototype, 'init', wrapInit);
  49907. wrap(AxisClass.prototype, 'setTickInterval', wrapSetTickInterval);
  49908. TreeGridTick.compose(Tick);
  49909. applied = true;
  49910. }
  49911. }
  49912. TreeGridAxis.compose = compose;
  49913. /**
  49914. * @private
  49915. */
  49916. function getBreakFromNode(node, max) {
  49917. var from = node.collapseStart || 0,
  49918. to = node.collapseEnd || 0;
  49919. // In broken-axis, the axis.max is minimized until it is not within a
  49920. // break. Therefore, if break.to is larger than axis.max, the axis.to
  49921. // should not add the 0.5 axis.tickMarkOffset, to avoid adding a break
  49922. // larger than axis.max.
  49923. // TODO consider simplifying broken-axis and this might solve itself
  49924. if (to >= max) {
  49925. from -= 0.5;
  49926. }
  49927. return {
  49928. from: from,
  49929. to: to,
  49930. showPoints: false
  49931. };
  49932. }
  49933. /**
  49934. * Creates a tree structure of the data, and the treegrid. Calculates
  49935. * categories, and y-values of points based on the tree.
  49936. *
  49937. * @private
  49938. * @function getTreeGridFromData
  49939. *
  49940. * @param {Array<Highcharts.GanttPointOptions>} data
  49941. * All the data points to display in the axis.
  49942. *
  49943. * @param {boolean} uniqueNames
  49944. * Wether or not the data node with the same name should share grid cell. If
  49945. * true they do share cell. False by default.
  49946. *
  49947. * @param {number} numberOfSeries
  49948. *
  49949. * @return {object}
  49950. * Returns an object containing categories, mapOfIdToNode,
  49951. * mapOfPosToGridNode, and tree.
  49952. *
  49953. * @todo There should be only one point per line.
  49954. * @todo It should be optional to have one category per point, or merge
  49955. * cells
  49956. * @todo Add unit-tests.
  49957. */
  49958. function getTreeGridFromData(data, uniqueNames, numberOfSeries) {
  49959. var categories = [],
  49960. collapsedNodes = [],
  49961. mapOfIdToNode = {},
  49962. mapOfPosToGridNode = {},
  49963. posIterator = -1,
  49964. uniqueNamesEnabled = typeof uniqueNames === 'boolean' ? uniqueNames : false,
  49965. tree;
  49966. // Build the tree from the series data.
  49967. var treeParams = {
  49968. // After the children has been created.
  49969. after: function (node) {
  49970. var gridNode = mapOfPosToGridNode[node.pos],
  49971. height = 0,
  49972. descendants = 0;
  49973. gridNode.children.forEach(function (child) {
  49974. descendants += (child.descendants || 0) + 1;
  49975. height = Math.max((child.height || 0) + 1, height);
  49976. });
  49977. gridNode.descendants = descendants;
  49978. gridNode.height = height;
  49979. if (gridNode.collapsed) {
  49980. collapsedNodes.push(gridNode);
  49981. }
  49982. },
  49983. // Before the children has been created.
  49984. before: function (node) {
  49985. var data = isObject(node.data,
  49986. true) ? node.data : {},
  49987. name = isString(data.name) ? data.name : '',
  49988. parentNode = mapOfIdToNode[node.parent],
  49989. parentGridNode = (isObject(parentNode,
  49990. true) ?
  49991. mapOfPosToGridNode[parentNode.pos] :
  49992. null),
  49993. hasSameName = function (x) {
  49994. return x.name === name;
  49995. }, gridNode, pos;
  49996. // If not unique names, look for sibling node with the same name
  49997. if (uniqueNamesEnabled &&
  49998. isObject(parentGridNode, true) &&
  49999. !!(gridNode = find(parentGridNode.children, hasSameName))) {
  50000. // If there is a gridNode with the same name, reuse position
  50001. pos = gridNode.pos;
  50002. // Add data node to list of nodes in the grid node.
  50003. gridNode.nodes.push(node);
  50004. }
  50005. else {
  50006. // If it is a new grid node, increment position.
  50007. pos = posIterator++;
  50008. }
  50009. // Add new grid node to map.
  50010. if (!mapOfPosToGridNode[pos]) {
  50011. mapOfPosToGridNode[pos] = gridNode = {
  50012. depth: parentGridNode ? parentGridNode.depth + 1 : 0,
  50013. name: name,
  50014. id: data.id,
  50015. nodes: [node],
  50016. children: [],
  50017. pos: pos
  50018. };
  50019. // If not root, then add name to categories.
  50020. if (pos !== -1) {
  50021. categories.push(name);
  50022. }
  50023. // Add name to list of children.
  50024. if (isObject(parentGridNode, true)) {
  50025. parentGridNode.children.push(gridNode);
  50026. }
  50027. }
  50028. // Add data node to map
  50029. if (isString(node.id)) {
  50030. mapOfIdToNode[node.id] = node;
  50031. }
  50032. // If one of the points are collapsed, then start the grid node
  50033. // in collapsed state.
  50034. if (gridNode &&
  50035. data.collapsed === true) {
  50036. gridNode.collapsed = true;
  50037. }
  50038. // Assign pos to data node
  50039. node.pos = pos;
  50040. }
  50041. };
  50042. var updateYValuesAndTickPos = function (map,
  50043. numberOfSeries) {
  50044. var setValues = function (gridNode,
  50045. start,
  50046. result) {
  50047. var nodes = gridNode.nodes,
  50048. end = start + (start === -1 ? 0 : numberOfSeries - 1),
  50049. diff = (end - start) / 2,
  50050. padding = 0.5,
  50051. pos = start + diff;
  50052. nodes.forEach(function (node) {
  50053. var data = node.data;
  50054. if (isObject(data, true)) {
  50055. // Update point
  50056. data.y = start + (data.seriesIndex || 0);
  50057. // Remove the property once used
  50058. delete data.seriesIndex;
  50059. }
  50060. node.pos = pos;
  50061. });
  50062. result[pos] = gridNode;
  50063. gridNode.pos = pos;
  50064. gridNode.tickmarkOffset = diff + padding;
  50065. gridNode.collapseStart = end + padding;
  50066. gridNode.children.forEach(function (child) {
  50067. setValues(child, end + 1, result);
  50068. end = (child.collapseEnd || 0) - padding;
  50069. });
  50070. // Set collapseEnd to the end of the last child node.
  50071. gridNode.collapseEnd = end + padding;
  50072. return result;
  50073. };
  50074. return setValues(map['-1'], -1, {});
  50075. };
  50076. // Create tree from data
  50077. tree = Tree.getTree(data, treeParams);
  50078. // Update y values of data, and set calculate tick positions.
  50079. mapOfPosToGridNode = updateYValuesAndTickPos(mapOfPosToGridNode, numberOfSeries);
  50080. // Return the resulting data.
  50081. return {
  50082. categories: categories,
  50083. mapOfIdToNode: mapOfIdToNode,
  50084. mapOfPosToGridNode: mapOfPosToGridNode,
  50085. collapsedNodes: collapsedNodes,
  50086. tree: tree
  50087. };
  50088. }
  50089. /**
  50090. * Builds the tree of categories and calculates its positions.
  50091. * @private
  50092. * @param {object} e Event object
  50093. * @param {object} e.target The chart instance which the event was fired on.
  50094. * @param {object[]} e.target.axes The axes of the chart.
  50095. */
  50096. function onBeforeRender(e) {
  50097. var chart = e.target,
  50098. axes = chart.axes;
  50099. axes.filter(function (axis) {
  50100. return axis.options.type === 'treegrid';
  50101. }).forEach(function (axis) {
  50102. var options = axis.options || {},
  50103. labelOptions = options.labels,
  50104. uniqueNames = options.uniqueNames,
  50105. numberOfSeries = 0,
  50106. isDirty,
  50107. data,
  50108. treeGrid,
  50109. max = options.max;
  50110. // Check whether any of series is rendering for the first time,
  50111. // visibility has changed, or its data is dirty,
  50112. // and only then update. #10570, #10580
  50113. // Also check if mapOfPosToGridNode exists. #10887
  50114. isDirty = (!axis.treeGrid.mapOfPosToGridNode ||
  50115. axis.series.some(function (series) {
  50116. return !series.hasRendered ||
  50117. series.isDirtyData ||
  50118. series.isDirty;
  50119. }));
  50120. if (isDirty) {
  50121. // Concatenate data from all series assigned to this axis.
  50122. data = axis.series.reduce(function (arr, s) {
  50123. if (s.visible) {
  50124. // Push all data to array
  50125. (s.options.data || []).forEach(function (data) {
  50126. // For using keys - rebuild the data structure
  50127. if (s.options.keys && s.options.keys.length) {
  50128. data = s.pointClass.prototype.optionsToObject.call({ series: s }, data);
  50129. s.pointClass.setGanttPointAliases(data);
  50130. }
  50131. if (isObject(data, true)) {
  50132. // Set series index on data. Removed again
  50133. // after use.
  50134. data.seriesIndex = numberOfSeries;
  50135. arr.push(data);
  50136. }
  50137. });
  50138. // Increment series index
  50139. if (uniqueNames === true) {
  50140. numberOfSeries++;
  50141. }
  50142. }
  50143. return arr;
  50144. }, []);
  50145. // If max is higher than set data - add a
  50146. // dummy data to render categories #10779
  50147. if (max && data.length < max) {
  50148. for (var i = data.length; i <= max; i++) {
  50149. data.push({
  50150. // Use the zero-width character
  50151. // to avoid conflict with uniqueNames
  50152. name: i + '\u200B'
  50153. });
  50154. }
  50155. }
  50156. // setScale is fired after all the series is initialized,
  50157. // which is an ideal time to update the axis.categories.
  50158. treeGrid = getTreeGridFromData(data, uniqueNames || false, (uniqueNames === true) ? numberOfSeries : 1);
  50159. // Assign values to the axis.
  50160. axis.categories = treeGrid.categories;
  50161. axis.treeGrid.mapOfPosToGridNode = treeGrid.mapOfPosToGridNode;
  50162. axis.hasNames = true;
  50163. axis.treeGrid.tree = treeGrid.tree;
  50164. // Update yData now that we have calculated the y values
  50165. axis.series.forEach(function (series) {
  50166. var axisData = (series.options.data || []).map(function (d) {
  50167. if (isArray(d) && series.options.keys && series.options.keys.length) {
  50168. // Get the axisData from the data array used to
  50169. // build the treeGrid where has been modified
  50170. data.forEach(function (point) {
  50171. if (d.indexOf(point.x) >= 0 && d.indexOf(point.x2) >= 0) {
  50172. d = point;
  50173. }
  50174. });
  50175. }
  50176. return isObject(d, true) ? merge(d) : d;
  50177. });
  50178. // Avoid destroying points when series is not visible
  50179. if (series.visible) {
  50180. series.setData(axisData, false);
  50181. }
  50182. });
  50183. // Calculate the label options for each level in the tree.
  50184. axis.treeGrid.mapOptionsToLevel =
  50185. getLevelOptions({
  50186. defaults: labelOptions,
  50187. from: 1,
  50188. levels: labelOptions && labelOptions.levels,
  50189. to: axis.treeGrid.tree && axis.treeGrid.tree.height
  50190. });
  50191. // Setting initial collapsed nodes
  50192. if (e.type === 'beforeRender') {
  50193. axis.treeGrid.collapsedNodes = treeGrid.collapsedNodes;
  50194. }
  50195. }
  50196. });
  50197. }
  50198. /**
  50199. * Generates a tick for initial positioning.
  50200. *
  50201. * @private
  50202. * @function Highcharts.GridAxis#generateTick
  50203. *
  50204. * @param {Function} proceed
  50205. * The original generateTick function.
  50206. *
  50207. * @param {number} pos
  50208. * The tick position in axis values.
  50209. */
  50210. function wrapGenerateTick(proceed, pos) {
  50211. var axis = this,
  50212. mapOptionsToLevel = axis.treeGrid.mapOptionsToLevel || {},
  50213. isTreeGrid = axis.options.type === 'treegrid',
  50214. ticks = axis.ticks;
  50215. var tick = ticks[pos],
  50216. levelOptions,
  50217. options,
  50218. gridNode;
  50219. if (isTreeGrid &&
  50220. axis.treeGrid.mapOfPosToGridNode) {
  50221. gridNode = axis.treeGrid.mapOfPosToGridNode[pos];
  50222. levelOptions = mapOptionsToLevel[gridNode.depth];
  50223. if (levelOptions) {
  50224. options = {
  50225. labels: levelOptions
  50226. };
  50227. }
  50228. if (!tick) {
  50229. ticks[pos] = tick =
  50230. new Tick(axis, pos, void 0, void 0, {
  50231. category: gridNode.name,
  50232. tickmarkOffset: gridNode.tickmarkOffset,
  50233. options: options
  50234. });
  50235. }
  50236. else {
  50237. // update labels depending on tick interval
  50238. tick.parameters.category = gridNode.name;
  50239. tick.options = options;
  50240. tick.addLabel();
  50241. }
  50242. }
  50243. else {
  50244. proceed.apply(axis, Array.prototype.slice.call(arguments, 1));
  50245. }
  50246. }
  50247. /**
  50248. * Override to add indentation to axis.maxLabelDimensions.
  50249. *
  50250. * @private
  50251. * @function Highcharts.GridAxis#getMaxLabelDimensions
  50252. *
  50253. * @param {Function} proceed
  50254. * The original function
  50255. */
  50256. function wrapGetMaxLabelDimensions(proceed) {
  50257. var axis = this,
  50258. options = axis.options,
  50259. retVal = proceed.apply(axis,
  50260. Array.prototype.slice.call(arguments, 1)),
  50261. isTreeGrid = options.type === 'treegrid';
  50262. var treeDepth;
  50263. if (isTreeGrid && axis.treeGrid.mapOfPosToGridNode) {
  50264. treeDepth = axis.treeGrid.mapOfPosToGridNode[-1].height || 0;
  50265. retVal.width += options.labels.indentation * (treeDepth - 1);
  50266. }
  50267. return retVal;
  50268. }
  50269. /**
  50270. * @private
  50271. */
  50272. function wrapInit(proceed, chart, userOptions) {
  50273. var axis = this,
  50274. isTreeGrid = userOptions.type === 'treegrid';
  50275. if (!axis.treeGrid) {
  50276. axis.treeGrid = new Additions(axis);
  50277. }
  50278. // Set default and forced options for TreeGrid
  50279. if (isTreeGrid) {
  50280. // Add event for updating the categories of a treegrid.
  50281. // NOTE Preferably these events should be set on the axis.
  50282. addEvent(chart, 'beforeRender', onBeforeRender);
  50283. addEvent(chart, 'beforeRedraw', onBeforeRender);
  50284. // Add new collapsed nodes on addseries
  50285. addEvent(chart, 'addSeries', function (e) {
  50286. if (e.options.data) {
  50287. var treeGrid = getTreeGridFromData(e.options.data,
  50288. userOptions.uniqueNames || false, 1);
  50289. axis.treeGrid.collapsedNodes = (axis.treeGrid.collapsedNodes || []).concat(treeGrid.collapsedNodes);
  50290. }
  50291. });
  50292. // Collapse all nodes in axis.treegrid.collapsednodes
  50293. // where collapsed equals true.
  50294. addEvent(axis, 'foundExtremes', function () {
  50295. if (axis.treeGrid.collapsedNodes) {
  50296. axis.treeGrid.collapsedNodes.forEach(function (node) {
  50297. var breaks = axis.treeGrid.collapse(node);
  50298. if (axis.brokenAxis) {
  50299. axis.brokenAxis.setBreaks(breaks, false);
  50300. // remove the node from the axis collapsedNodes
  50301. if (axis.treeGrid.collapsedNodes) {
  50302. axis.treeGrid.collapsedNodes = axis.treeGrid.collapsedNodes.filter(function (n) {
  50303. return node.collapseStart !== n.collapseStart ||
  50304. node.collapseEnd !== n.collapseEnd;
  50305. });
  50306. }
  50307. }
  50308. });
  50309. }
  50310. });
  50311. // If staticScale is not defined on the yAxis
  50312. // and chart height is set, set axis.isDirty
  50313. // to ensure collapsing works (#12012)
  50314. addEvent(axis, 'afterBreaks', function () {
  50315. if (axis.coll === 'yAxis' &&
  50316. !axis.staticScale &&
  50317. axis.chart.options.chart.height) {
  50318. axis.isDirty = true;
  50319. }
  50320. });
  50321. userOptions = merge({
  50322. // Default options
  50323. grid: {
  50324. enabled: true
  50325. },
  50326. // TODO: add support for align in treegrid.
  50327. labels: {
  50328. align: 'left',
  50329. /**
  50330. * Set options on specific levels in a tree grid axis. Takes
  50331. * precedence over labels options.
  50332. *
  50333. * @sample {gantt} gantt/treegrid-axis/labels-levels
  50334. * Levels on TreeGrid Labels
  50335. *
  50336. * @type {Array<*>}
  50337. * @product gantt
  50338. * @apioption yAxis.labels.levels
  50339. *
  50340. * @private
  50341. */
  50342. levels: [{
  50343. /**
  50344. * Specify the level which the options within this object
  50345. * applies to.
  50346. *
  50347. * @type {number}
  50348. * @product gantt
  50349. * @apioption yAxis.labels.levels.level
  50350. *
  50351. * @private
  50352. */
  50353. level: void 0
  50354. }, {
  50355. level: 1,
  50356. /**
  50357. * @type {Highcharts.CSSObject}
  50358. * @product gantt
  50359. * @apioption yAxis.labels.levels.style
  50360. *
  50361. * @private
  50362. */
  50363. style: {
  50364. /** @ignore-option */
  50365. fontWeight: 'bold'
  50366. }
  50367. }],
  50368. /**
  50369. * The symbol for the collapse and expand icon in a
  50370. * treegrid.
  50371. *
  50372. * @product gantt
  50373. * @optionparent yAxis.labels.symbol
  50374. *
  50375. * @private
  50376. */
  50377. symbol: {
  50378. /**
  50379. * The symbol type. Points to a definition function in
  50380. * the `Highcharts.Renderer.symbols` collection.
  50381. *
  50382. * @type {Highcharts.SymbolKeyValue}
  50383. *
  50384. * @private
  50385. */
  50386. type: 'triangle',
  50387. x: -5,
  50388. y: -5,
  50389. height: 10,
  50390. width: 10,
  50391. padding: 5
  50392. }
  50393. },
  50394. uniqueNames: false
  50395. }, userOptions, {
  50396. // Forced options
  50397. reversed: true,
  50398. // grid.columns is not supported in treegrid
  50399. grid: {
  50400. columns: void 0
  50401. }
  50402. });
  50403. }
  50404. // Now apply the original function with the original arguments,
  50405. // which are sliced off this function's arguments
  50406. proceed.apply(axis, [chart, userOptions]);
  50407. if (isTreeGrid) {
  50408. axis.hasNames = true;
  50409. axis.options.showLastLabel = true;
  50410. }
  50411. }
  50412. /**
  50413. * Set the tick positions, tickInterval, axis min and max.
  50414. *
  50415. * @private
  50416. * @function Highcharts.GridAxis#setTickInterval
  50417. *
  50418. * @param {Function} proceed
  50419. * The original setTickInterval function.
  50420. */
  50421. function wrapSetTickInterval(proceed) {
  50422. var axis = this,
  50423. options = axis.options,
  50424. isTreeGrid = options.type === 'treegrid';
  50425. if (isTreeGrid) {
  50426. axis.min = pick(axis.userMin, options.min, axis.dataMin);
  50427. axis.max = pick(axis.userMax, options.max, axis.dataMax);
  50428. fireEvent(axis, 'foundExtremes');
  50429. // setAxisTranslation modifies the min and max according to
  50430. // axis breaks.
  50431. axis.setAxisTranslation();
  50432. axis.tickmarkOffset = 0.5;
  50433. axis.tickInterval = 1;
  50434. axis.tickPositions = axis.treeGrid.mapOfPosToGridNode ?
  50435. axis.treeGrid.getTickPositions() :
  50436. [];
  50437. }
  50438. else {
  50439. proceed.apply(axis, Array.prototype.slice.call(arguments, 1));
  50440. }
  50441. }
  50442. /* *
  50443. *
  50444. * Classes
  50445. *
  50446. * */
  50447. /**
  50448. * @private
  50449. * @class
  50450. */
  50451. var Additions = /** @class */ (function () {
  50452. /* *
  50453. *
  50454. * Constructors
  50455. *
  50456. * */
  50457. /**
  50458. * @private
  50459. */
  50460. function Additions(axis) {
  50461. this.axis = axis;
  50462. }
  50463. /* *
  50464. *
  50465. * Functions
  50466. *
  50467. * */
  50468. /**
  50469. * Set the collapse status.
  50470. *
  50471. * @private
  50472. *
  50473. * @param {Highcharts.Axis} axis
  50474. * The axis to check against.
  50475. *
  50476. * @param {Highcharts.GridNode} node
  50477. * The node to collapse.
  50478. */
  50479. Additions.prototype.setCollapsedStatus = function (node) {
  50480. var axis = this.axis,
  50481. chart = axis.chart;
  50482. axis.series.forEach(function (series) {
  50483. var data = series.options.data;
  50484. if (node.id && data) {
  50485. var point = chart.get(node.id),
  50486. dataPoint = data[series.data.indexOf(point)];
  50487. if (point && dataPoint) {
  50488. point.collapsed = node.collapsed;
  50489. dataPoint.collapsed = node.collapsed;
  50490. }
  50491. }
  50492. });
  50493. };
  50494. /**
  50495. * Calculates the new axis breaks to collapse a node.
  50496. *
  50497. * @private
  50498. *
  50499. * @param {Highcharts.Axis} axis
  50500. * The axis to check against.
  50501. *
  50502. * @param {Highcharts.GridNode} node
  50503. * The node to collapse.
  50504. *
  50505. * @param {number} pos
  50506. * The tick position to collapse.
  50507. *
  50508. * @return {Array<object>}
  50509. * Returns an array of the new breaks for the axis.
  50510. */
  50511. Additions.prototype.collapse = function (node) {
  50512. var axis = this.axis,
  50513. breaks = (axis.options.breaks || []),
  50514. obj = getBreakFromNode(node,
  50515. axis.max);
  50516. breaks.push(obj);
  50517. // Change the collapsed flag #13838
  50518. node.collapsed = true;
  50519. axis.treeGrid.setCollapsedStatus(node);
  50520. return breaks;
  50521. };
  50522. /**
  50523. * Calculates the new axis breaks to expand a node.
  50524. *
  50525. * @private
  50526. *
  50527. * @param {Highcharts.Axis} axis
  50528. * The axis to check against.
  50529. *
  50530. * @param {Highcharts.GridNode} node
  50531. * The node to expand.
  50532. *
  50533. * @param {number} pos
  50534. * The tick position to expand.
  50535. *
  50536. * @return {Array<object>}
  50537. * Returns an array of the new breaks for the axis.
  50538. */
  50539. Additions.prototype.expand = function (node) {
  50540. var axis = this.axis,
  50541. breaks = (axis.options.breaks || []),
  50542. obj = getBreakFromNode(node,
  50543. axis.max);
  50544. // Change the collapsed flag #13838
  50545. node.collapsed = false;
  50546. axis.treeGrid.setCollapsedStatus(node);
  50547. // Remove the break from the axis breaks array.
  50548. return breaks.reduce(function (arr, b) {
  50549. if (b.to !== obj.to || b.from !== obj.from) {
  50550. arr.push(b);
  50551. }
  50552. return arr;
  50553. }, []);
  50554. };
  50555. /**
  50556. * Creates a list of positions for the ticks on the axis. Filters out
  50557. * positions that are outside min and max, or is inside an axis break.
  50558. *
  50559. * @private
  50560. *
  50561. * @return {Array<number>}
  50562. * List of positions.
  50563. */
  50564. Additions.prototype.getTickPositions = function () {
  50565. var axis = this.axis,
  50566. roundedMin = Math.floor(axis.min / axis.tickInterval) * axis.tickInterval,
  50567. roundedMax = Math.ceil(axis.max / axis.tickInterval) * axis.tickInterval;
  50568. return Object.keys(axis.treeGrid.mapOfPosToGridNode || {}).reduce(function (arr, key) {
  50569. var pos = +key;
  50570. if (pos >= roundedMin &&
  50571. pos <= roundedMax &&
  50572. !(axis.brokenAxis && axis.brokenAxis.isInAnyBreak(pos))) {
  50573. arr.push(pos);
  50574. }
  50575. return arr;
  50576. }, []);
  50577. };
  50578. /**
  50579. * Check if a node is collapsed.
  50580. *
  50581. * @private
  50582. *
  50583. * @param {Highcharts.Axis} axis
  50584. * The axis to check against.
  50585. *
  50586. * @param {object} node
  50587. * The node to check if is collapsed.
  50588. *
  50589. * @param {number} pos
  50590. * The tick position to collapse.
  50591. *
  50592. * @return {boolean}
  50593. * Returns true if collapsed, false if expanded.
  50594. */
  50595. Additions.prototype.isCollapsed = function (node) {
  50596. var axis = this.axis,
  50597. breaks = (axis.options.breaks || []),
  50598. obj = getBreakFromNode(node,
  50599. axis.max);
  50600. return breaks.some(function (b) {
  50601. return b.from === obj.from && b.to === obj.to;
  50602. });
  50603. };
  50604. /**
  50605. * Calculates the new axis breaks after toggling the collapse/expand
  50606. * state of a node. If it is collapsed it will be expanded, and if it is
  50607. * exapended it will be collapsed.
  50608. *
  50609. * @private
  50610. *
  50611. * @param {Highcharts.Axis} axis
  50612. * The axis to check against.
  50613. *
  50614. * @param {Highcharts.GridNode} node
  50615. * The node to toggle.
  50616. *
  50617. * @return {Array<object>}
  50618. * Returns an array of the new breaks for the axis.
  50619. */
  50620. Additions.prototype.toggleCollapse = function (node) {
  50621. return (this.isCollapsed(node) ?
  50622. this.expand(node) :
  50623. this.collapse(node));
  50624. };
  50625. return Additions;
  50626. }());
  50627. TreeGridAxis.Additions = Additions;
  50628. })(TreeGridAxis || (TreeGridAxis = {}));
  50629. // Make utility functions available for testing.
  50630. Axis.prototype.utils = {
  50631. getNode: Tree.getNode
  50632. };
  50633. TreeGridAxis.compose(Axis);
  50634. return TreeGridAxis;
  50635. });
  50636. _registerModule(_modules, 'Extensions/CurrentDateIndication.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Color/Palette.js'], _modules['Core/Utilities.js'], _modules['Core/Axis/PlotLineOrBand.js']], function (Axis, palette, U, PlotLineOrBand) {
  50637. /* *
  50638. *
  50639. * (c) 2016-2021 Highsoft AS
  50640. *
  50641. * Author: Lars A. V. Cabrera
  50642. *
  50643. * License: www.highcharts.com/license
  50644. *
  50645. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  50646. *
  50647. * */
  50648. var addEvent = U.addEvent,
  50649. merge = U.merge,
  50650. wrap = U.wrap;
  50651. /**
  50652. * Show an indicator on the axis for the current date and time. Can be a
  50653. * boolean or a configuration object similar to
  50654. * [xAxis.plotLines](#xAxis.plotLines).
  50655. *
  50656. * @sample gantt/current-date-indicator/demo
  50657. * Current date indicator enabled
  50658. * @sample gantt/current-date-indicator/object-config
  50659. * Current date indicator with custom options
  50660. *
  50661. * @declare Highcharts.CurrentDateIndicatorOptions
  50662. * @type {boolean|CurrentDateIndicatorOptions}
  50663. * @default true
  50664. * @extends xAxis.plotLines
  50665. * @excluding value
  50666. * @product gantt
  50667. * @apioption xAxis.currentDateIndicator
  50668. */
  50669. var defaultOptions = {
  50670. color: palette.highlightColor20,
  50671. width: 2,
  50672. /**
  50673. * @declare Highcharts.AxisCurrentDateIndicatorLabelOptions
  50674. */
  50675. label: {
  50676. /**
  50677. * Format of the label. This options is passed as the fist argument to
  50678. * [dateFormat](/class-reference/Highcharts#.dateFormat) function.
  50679. *
  50680. * @type {string}
  50681. * @default %a, %b %d %Y, %H:%M
  50682. * @product gantt
  50683. * @apioption xAxis.currentDateIndicator.label.format
  50684. */
  50685. format: '%a, %b %d %Y, %H:%M',
  50686. formatter: function (value, format) {
  50687. return this.axis.chart.time.dateFormat(format || '', value);
  50688. },
  50689. rotation: 0,
  50690. /**
  50691. * @type {Highcharts.CSSObject}
  50692. */
  50693. style: {
  50694. /** @internal */
  50695. fontSize: '10px'
  50696. }
  50697. }
  50698. };
  50699. /* eslint-disable no-invalid-this */
  50700. addEvent(Axis, 'afterSetOptions', function () {
  50701. var options = this.options,
  50702. cdiOptions = options.currentDateIndicator;
  50703. if (cdiOptions) {
  50704. var plotLineOptions = typeof cdiOptions === 'object' ?
  50705. merge(defaultOptions,
  50706. cdiOptions) :
  50707. merge(defaultOptions);
  50708. plotLineOptions.value = Date.now();
  50709. plotLineOptions.className = 'highcharts-current-date-indicator';
  50710. if (!options.plotLines) {
  50711. options.plotLines = [];
  50712. }
  50713. options.plotLines.push(plotLineOptions);
  50714. }
  50715. });
  50716. addEvent(PlotLineOrBand, 'render', function () {
  50717. // If the label already exists, update its text
  50718. if (this.label) {
  50719. this.label.attr({
  50720. text: this.getLabelText(this.options.label)
  50721. });
  50722. }
  50723. });
  50724. wrap(PlotLineOrBand.prototype, 'getLabelText', function (defaultMethod, defaultLabelOptions) {
  50725. var options = this.options;
  50726. if (options &&
  50727. options.className &&
  50728. options.className.indexOf('highcharts-current-date-indicator') !== -1 &&
  50729. options.label &&
  50730. typeof options.label.formatter === 'function') {
  50731. options.value = Date.now();
  50732. return options.label.formatter
  50733. .call(this, options.value, options.label.format);
  50734. }
  50735. return defaultMethod.call(this, defaultLabelOptions);
  50736. });
  50737. });
  50738. _registerModule(_modules, 'Extensions/StaticScale.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Chart/Chart.js'], _modules['Core/Utilities.js']], function (Axis, Chart, U) {
  50739. /* *
  50740. *
  50741. * (c) 2016-2021 Torstein Honsi, Lars Cabrera
  50742. *
  50743. * License: www.highcharts.com/license
  50744. *
  50745. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  50746. *
  50747. * */
  50748. var addEvent = U.addEvent,
  50749. defined = U.defined,
  50750. isNumber = U.isNumber,
  50751. pick = U.pick;
  50752. /* eslint-disable no-invalid-this */
  50753. /**
  50754. * For vertical axes only. Setting the static scale ensures that each tick unit
  50755. * is translated into a fixed pixel height. For example, setting the static
  50756. * scale to 24 results in each Y axis category taking up 24 pixels, and the
  50757. * height of the chart adjusts. Adding or removing items will make the chart
  50758. * resize.
  50759. *
  50760. * @sample gantt/xrange-series/demo/
  50761. * X-range series with static scale
  50762. *
  50763. * @type {number}
  50764. * @default 50
  50765. * @since 6.2.0
  50766. * @product gantt
  50767. * @apioption yAxis.staticScale
  50768. */
  50769. addEvent(Axis, 'afterSetOptions', function () {
  50770. var chartOptions = this.chart.options.chart;
  50771. if (!this.horiz &&
  50772. isNumber(this.options.staticScale) &&
  50773. (!chartOptions.height ||
  50774. (chartOptions.scrollablePlotArea &&
  50775. chartOptions.scrollablePlotArea.minHeight))) {
  50776. this.staticScale = this.options.staticScale;
  50777. }
  50778. });
  50779. Chart.prototype.adjustHeight = function () {
  50780. if (this.redrawTrigger !== 'adjustHeight') {
  50781. (this.axes || []).forEach(function (axis) {
  50782. var chart = axis.chart,
  50783. animate = !!chart.initiatedScale &&
  50784. chart.options.animation,
  50785. staticScale = axis.options.staticScale,
  50786. height,
  50787. diff;
  50788. if (axis.staticScale && defined(axis.min)) {
  50789. height = pick(axis.brokenAxis && axis.brokenAxis.unitLength, axis.max + axis.tickInterval - axis.min) * staticScale;
  50790. // Minimum height is 1 x staticScale.
  50791. height = Math.max(height, staticScale);
  50792. diff = height - chart.plotHeight;
  50793. if (!chart.scrollablePixelsY && Math.abs(diff) >= 1) {
  50794. chart.plotHeight = height;
  50795. chart.redrawTrigger = 'adjustHeight';
  50796. chart.setSize(void 0, chart.chartHeight + diff, animate);
  50797. }
  50798. // Make sure clip rects have the right height before initial
  50799. // animation.
  50800. axis.series.forEach(function (series) {
  50801. var clipRect = series.sharedClipKey &&
  50802. chart.sharedClips[series.sharedClipKey];
  50803. if (clipRect) {
  50804. clipRect.attr(chart.inverted ? {
  50805. width: chart.plotHeight
  50806. } : {
  50807. height: chart.plotHeight
  50808. });
  50809. }
  50810. });
  50811. }
  50812. });
  50813. this.initiatedScale = true;
  50814. }
  50815. this.redrawTrigger = null;
  50816. };
  50817. addEvent(Chart, 'render', Chart.prototype.adjustHeight);
  50818. });
  50819. _registerModule(_modules, 'Extensions/ArrowSymbols.js', [_modules['Core/Renderer/SVG/SVGRenderer.js']], function (SVGRenderer) {
  50820. /* *
  50821. *
  50822. * (c) 2017 Highsoft AS
  50823. * Authors: Lars A. V. Cabrera
  50824. *
  50825. * License: www.highcharts.com/license
  50826. *
  50827. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  50828. *
  50829. * */
  50830. /**
  50831. * Creates an arrow symbol. Like a triangle, except not filled.
  50832. * ```
  50833. * o
  50834. * o
  50835. * o
  50836. * o
  50837. * o
  50838. * o
  50839. * o
  50840. * ```
  50841. *
  50842. * @private
  50843. * @function
  50844. *
  50845. * @param {number} x
  50846. * x position of the arrow
  50847. *
  50848. * @param {number} y
  50849. * y position of the arrow
  50850. *
  50851. * @param {number} w
  50852. * width of the arrow
  50853. *
  50854. * @param {number} h
  50855. * height of the arrow
  50856. *
  50857. * @return {Highcharts.SVGPathArray}
  50858. * Path array
  50859. */
  50860. SVGRenderer.prototype.symbols.arrow = function (x, y, w, h) {
  50861. return [
  50862. ['M', x, y + h / 2],
  50863. ['L', x + w, y],
  50864. ['L', x, y + h / 2],
  50865. ['L', x + w, y + h]
  50866. ];
  50867. };
  50868. /**
  50869. * Creates a half-width arrow symbol. Like a triangle, except not filled.
  50870. * ```
  50871. * o
  50872. * o
  50873. * o
  50874. * o
  50875. * o
  50876. * ```
  50877. *
  50878. * @private
  50879. * @function
  50880. *
  50881. * @param {number} x
  50882. * x position of the arrow
  50883. *
  50884. * @param {number} y
  50885. * y position of the arrow
  50886. *
  50887. * @param {number} w
  50888. * width of the arrow
  50889. *
  50890. * @param {number} h
  50891. * height of the arrow
  50892. *
  50893. * @return {Highcharts.SVGPathArray}
  50894. * Path array
  50895. */
  50896. SVGRenderer.prototype.symbols['arrow-half'] = function (x, y, w, h) {
  50897. return SVGRenderer.prototype.symbols.arrow(x, y, w / 2, h);
  50898. };
  50899. /**
  50900. * Creates a left-oriented triangle.
  50901. * ```
  50902. * o
  50903. * ooooooo
  50904. * ooooooooooooo
  50905. * ooooooo
  50906. * o
  50907. * ```
  50908. *
  50909. * @private
  50910. * @function
  50911. *
  50912. * @param {number} x
  50913. * x position of the triangle
  50914. *
  50915. * @param {number} y
  50916. * y position of the triangle
  50917. *
  50918. * @param {number} w
  50919. * width of the triangle
  50920. *
  50921. * @param {number} h
  50922. * height of the triangle
  50923. *
  50924. * @return {Highcharts.SVGPathArray}
  50925. * Path array
  50926. */
  50927. SVGRenderer.prototype.symbols['triangle-left'] = function (x, y, w, h) {
  50928. return [
  50929. ['M', x + w, y],
  50930. ['L', x, y + h / 2],
  50931. ['L', x + w, y + h],
  50932. ['Z']
  50933. ];
  50934. };
  50935. /**
  50936. * Alias function for triangle-left.
  50937. *
  50938. * @private
  50939. * @function
  50940. *
  50941. * @param {number} x
  50942. * x position of the arrow
  50943. *
  50944. * @param {number} y
  50945. * y position of the arrow
  50946. *
  50947. * @param {number} w
  50948. * width of the arrow
  50949. *
  50950. * @param {number} h
  50951. * height of the arrow
  50952. *
  50953. * @return {Highcharts.SVGPathArray}
  50954. * Path array
  50955. */
  50956. SVGRenderer.prototype.symbols['arrow-filled'] = SVGRenderer.prototype.symbols['triangle-left'];
  50957. /**
  50958. * Creates a half-width, left-oriented triangle.
  50959. * ```
  50960. * o
  50961. * oooo
  50962. * ooooooo
  50963. * oooo
  50964. * o
  50965. * ```
  50966. *
  50967. * @private
  50968. * @function
  50969. *
  50970. * @param {number} x
  50971. * x position of the triangle
  50972. *
  50973. * @param {number} y
  50974. * y position of the triangle
  50975. *
  50976. * @param {number} w
  50977. * width of the triangle
  50978. *
  50979. * @param {number} h
  50980. * height of the triangle
  50981. *
  50982. * @return {Highcharts.SVGPathArray}
  50983. * Path array
  50984. */
  50985. SVGRenderer.prototype.symbols['triangle-left-half'] = function (x, y, w, h) {
  50986. return SVGRenderer.prototype.symbols['triangle-left'](x, y, w / 2, h);
  50987. };
  50988. /**
  50989. * Alias function for triangle-left-half.
  50990. *
  50991. * @private
  50992. * @function
  50993. *
  50994. * @param {number} x
  50995. * x position of the arrow
  50996. *
  50997. * @param {number} y
  50998. * y position of the arrow
  50999. *
  51000. * @param {number} w
  51001. * width of the arrow
  51002. *
  51003. * @param {number} h
  51004. * height of the arrow
  51005. *
  51006. * @return {Highcharts.SVGPathArray}
  51007. * Path array
  51008. */
  51009. SVGRenderer.prototype.symbols['arrow-filled-half'] = SVGRenderer.prototype.symbols['triangle-left-half'];
  51010. });
  51011. _registerModule(_modules, 'Gantt/Connection.js', [_modules['Core/Globals.js'], _modules['Core/Options.js'], _modules['Core/Series/Point.js'], _modules['Core/Utilities.js']], function (H, O, Point, U) {
  51012. /* *
  51013. *
  51014. * (c) 2016 Highsoft AS
  51015. * Authors: Øystein Moseng, Lars A. V. Cabrera
  51016. *
  51017. * License: www.highcharts.com/license
  51018. *
  51019. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  51020. *
  51021. * */
  51022. /**
  51023. * The default pathfinder algorithm to use for a chart. It is possible to define
  51024. * your own algorithms by adding them to the
  51025. * `Highcharts.Pathfinder.prototype.algorithms`
  51026. * object before the chart has been created.
  51027. *
  51028. * The default algorithms are as follows:
  51029. *
  51030. * `straight`: Draws a straight line between the connecting
  51031. * points. Does not avoid other points when drawing.
  51032. *
  51033. * `simpleConnect`: Finds a path between the points using right angles
  51034. * only. Takes only starting/ending points into
  51035. * account, and will not avoid other points.
  51036. *
  51037. * `fastAvoid`: Finds a path between the points using right angles
  51038. * only. Will attempt to avoid other points, but its
  51039. * focus is performance over accuracy. Works well with
  51040. * less dense datasets.
  51041. *
  51042. * @typedef {"fastAvoid"|"simpleConnect"|"straight"|string} Highcharts.PathfinderTypeValue
  51043. */
  51044. ''; // detach doclets above
  51045. var defaultOptions = O.defaultOptions;
  51046. var addEvent = U.addEvent,
  51047. defined = U.defined,
  51048. error = U.error,
  51049. extend = U.extend,
  51050. merge = U.merge,
  51051. objectEach = U.objectEach,
  51052. pick = U.pick,
  51053. splat = U.splat;
  51054. var deg2rad = H.deg2rad,
  51055. max = Math.max,
  51056. min = Math.min;
  51057. /*
  51058. @todo:
  51059. - Document how to write your own algorithms
  51060. - Consider adding a Point.pathTo method that wraps creating a connection
  51061. and rendering it
  51062. */
  51063. // Set default Pathfinder options
  51064. extend(defaultOptions, {
  51065. /**
  51066. * The Pathfinder module allows you to define connections between any two
  51067. * points, represented as lines - optionally with markers for the start
  51068. * and/or end points. Multiple algorithms are available for calculating how
  51069. * the connecting lines are drawn.
  51070. *
  51071. * Connector functionality requires Highcharts Gantt to be loaded. In Gantt
  51072. * charts, the connectors are used to draw dependencies between tasks.
  51073. *
  51074. * @see [dependency](series.gantt.data.dependency)
  51075. *
  51076. * @sample gantt/pathfinder/demo
  51077. * Pathfinder connections
  51078. *
  51079. * @declare Highcharts.ConnectorsOptions
  51080. * @product gantt
  51081. * @optionparent connectors
  51082. */
  51083. connectors: {
  51084. /**
  51085. * Enable connectors for this chart. Requires Highcharts Gantt.
  51086. *
  51087. * @type {boolean}
  51088. * @default true
  51089. * @since 6.2.0
  51090. * @apioption connectors.enabled
  51091. */
  51092. /**
  51093. * Set the default dash style for this chart's connecting lines.
  51094. *
  51095. * @type {string}
  51096. * @default solid
  51097. * @since 6.2.0
  51098. * @apioption connectors.dashStyle
  51099. */
  51100. /**
  51101. * Set the default color for this chart's Pathfinder connecting lines.
  51102. * Defaults to the color of the point being connected.
  51103. *
  51104. * @type {Highcharts.ColorString}
  51105. * @since 6.2.0
  51106. * @apioption connectors.lineColor
  51107. */
  51108. /**
  51109. * Set the default pathfinder margin to use, in pixels. Some Pathfinder
  51110. * algorithms attempt to avoid obstacles, such as other points in the
  51111. * chart. These algorithms use this margin to determine how close lines
  51112. * can be to an obstacle. The default is to compute this automatically
  51113. * from the size of the obstacles in the chart.
  51114. *
  51115. * To draw connecting lines close to existing points, set this to a low
  51116. * number. For more space around existing points, set this number
  51117. * higher.
  51118. *
  51119. * @sample gantt/pathfinder/algorithm-margin
  51120. * Small algorithmMargin
  51121. *
  51122. * @type {number}
  51123. * @since 6.2.0
  51124. * @apioption connectors.algorithmMargin
  51125. */
  51126. /**
  51127. * Set the default pathfinder algorithm to use for this chart. It is
  51128. * possible to define your own algorithms by adding them to the
  51129. * Highcharts.Pathfinder.prototype.algorithms object before the chart
  51130. * has been created.
  51131. *
  51132. * The default algorithms are as follows:
  51133. *
  51134. * `straight`: Draws a straight line between the connecting
  51135. * points. Does not avoid other points when drawing.
  51136. *
  51137. * `simpleConnect`: Finds a path between the points using right angles
  51138. * only. Takes only starting/ending points into
  51139. * account, and will not avoid other points.
  51140. *
  51141. * `fastAvoid`: Finds a path between the points using right angles
  51142. * only. Will attempt to avoid other points, but its
  51143. * focus is performance over accuracy. Works well with
  51144. * less dense datasets.
  51145. *
  51146. * Default value: `straight` is used as default for most series types,
  51147. * while `simpleConnect` is used as default for Gantt series, to show
  51148. * dependencies between points.
  51149. *
  51150. * @sample gantt/pathfinder/demo
  51151. * Different types used
  51152. *
  51153. * @type {Highcharts.PathfinderTypeValue}
  51154. * @default undefined
  51155. * @since 6.2.0
  51156. */
  51157. type: 'straight',
  51158. /**
  51159. * Set the default pixel width for this chart's Pathfinder connecting
  51160. * lines.
  51161. *
  51162. * @since 6.2.0
  51163. */
  51164. lineWidth: 1,
  51165. /**
  51166. * Marker options for this chart's Pathfinder connectors. Note that
  51167. * this option is overridden by the `startMarker` and `endMarker`
  51168. * options.
  51169. *
  51170. * @declare Highcharts.ConnectorsMarkerOptions
  51171. * @since 6.2.0
  51172. */
  51173. marker: {
  51174. /**
  51175. * Set the radius of the connector markers. The default is
  51176. * automatically computed based on the algorithmMargin setting.
  51177. *
  51178. * Setting marker.width and marker.height will override this
  51179. * setting.
  51180. *
  51181. * @type {number}
  51182. * @since 6.2.0
  51183. * @apioption connectors.marker.radius
  51184. */
  51185. /**
  51186. * Set the width of the connector markers. If not supplied, this
  51187. * is inferred from the marker radius.
  51188. *
  51189. * @type {number}
  51190. * @since 6.2.0
  51191. * @apioption connectors.marker.width
  51192. */
  51193. /**
  51194. * Set the height of the connector markers. If not supplied, this
  51195. * is inferred from the marker radius.
  51196. *
  51197. * @type {number}
  51198. * @since 6.2.0
  51199. * @apioption connectors.marker.height
  51200. */
  51201. /**
  51202. * Set the color of the connector markers. By default this is the
  51203. * same as the connector color.
  51204. *
  51205. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  51206. * @since 6.2.0
  51207. * @apioption connectors.marker.color
  51208. */
  51209. /**
  51210. * Set the line/border color of the connector markers. By default
  51211. * this is the same as the marker color.
  51212. *
  51213. * @type {Highcharts.ColorString}
  51214. * @since 6.2.0
  51215. * @apioption connectors.marker.lineColor
  51216. */
  51217. /**
  51218. * Enable markers for the connectors.
  51219. */
  51220. enabled: false,
  51221. /**
  51222. * Horizontal alignment of the markers relative to the points.
  51223. *
  51224. * @type {Highcharts.AlignValue}
  51225. */
  51226. align: 'center',
  51227. /**
  51228. * Vertical alignment of the markers relative to the points.
  51229. *
  51230. * @type {Highcharts.VerticalAlignValue}
  51231. */
  51232. verticalAlign: 'middle',
  51233. /**
  51234. * Whether or not to draw the markers inside the points.
  51235. */
  51236. inside: false,
  51237. /**
  51238. * Set the line/border width of the pathfinder markers.
  51239. */
  51240. lineWidth: 1
  51241. },
  51242. /**
  51243. * Marker options specific to the start markers for this chart's
  51244. * Pathfinder connectors. Overrides the generic marker options.
  51245. *
  51246. * @declare Highcharts.ConnectorsStartMarkerOptions
  51247. * @extends connectors.marker
  51248. * @since 6.2.0
  51249. */
  51250. startMarker: {
  51251. /**
  51252. * Set the symbol of the connector start markers.
  51253. */
  51254. symbol: 'diamond'
  51255. },
  51256. /**
  51257. * Marker options specific to the end markers for this chart's
  51258. * Pathfinder connectors. Overrides the generic marker options.
  51259. *
  51260. * @declare Highcharts.ConnectorsEndMarkerOptions
  51261. * @extends connectors.marker
  51262. * @since 6.2.0
  51263. */
  51264. endMarker: {
  51265. /**
  51266. * Set the symbol of the connector end markers.
  51267. */
  51268. symbol: 'arrow-filled'
  51269. }
  51270. }
  51271. });
  51272. /**
  51273. * Override Pathfinder connector options for a series. Requires Highcharts Gantt
  51274. * to be loaded.
  51275. *
  51276. * @declare Highcharts.SeriesConnectorsOptionsObject
  51277. * @extends connectors
  51278. * @since 6.2.0
  51279. * @excluding enabled, algorithmMargin
  51280. * @product gantt
  51281. * @apioption plotOptions.series.connectors
  51282. */
  51283. /**
  51284. * Connect to a point. This option can be either a string, referring to the ID
  51285. * of another point, or an object, or an array of either. If the option is an
  51286. * array, each element defines a connection.
  51287. *
  51288. * @sample gantt/pathfinder/demo
  51289. * Different connection types
  51290. *
  51291. * @declare Highcharts.XrangePointConnectorsOptionsObject
  51292. * @type {string|Array<string|*>|*}
  51293. * @extends plotOptions.series.connectors
  51294. * @since 6.2.0
  51295. * @excluding enabled
  51296. * @product gantt
  51297. * @requires highcharts-gantt
  51298. * @apioption series.xrange.data.connect
  51299. */
  51300. /**
  51301. * The ID of the point to connect to.
  51302. *
  51303. * @type {string}
  51304. * @since 6.2.0
  51305. * @product gantt
  51306. * @apioption series.xrange.data.connect.to
  51307. */
  51308. /**
  51309. * Get point bounding box using plotX/plotY and shapeArgs. If using
  51310. * graphic.getBBox() directly, the bbox will be affected by animation.
  51311. *
  51312. * @private
  51313. * @function
  51314. *
  51315. * @param {Highcharts.Point} point
  51316. * The point to get BB of.
  51317. *
  51318. * @return {Highcharts.Dictionary<number>|null}
  51319. * Result xMax, xMin, yMax, yMin.
  51320. */
  51321. function getPointBB(point) {
  51322. var shapeArgs = point.shapeArgs,
  51323. bb;
  51324. // Prefer using shapeArgs (columns)
  51325. if (shapeArgs) {
  51326. return {
  51327. xMin: shapeArgs.x || 0,
  51328. xMax: (shapeArgs.x || 0) + (shapeArgs.width || 0),
  51329. yMin: shapeArgs.y || 0,
  51330. yMax: (shapeArgs.y || 0) + (shapeArgs.height || 0)
  51331. };
  51332. }
  51333. // Otherwise use plotX/plotY and bb
  51334. bb = point.graphic && point.graphic.getBBox();
  51335. return bb ? {
  51336. xMin: point.plotX - bb.width / 2,
  51337. xMax: point.plotX + bb.width / 2,
  51338. yMin: point.plotY - bb.height / 2,
  51339. yMax: point.plotY + bb.height / 2
  51340. } : null;
  51341. }
  51342. /**
  51343. * Calculate margin to place around obstacles for the pathfinder in pixels.
  51344. * Returns a minimum of 1 pixel margin.
  51345. *
  51346. * @private
  51347. * @function
  51348. *
  51349. * @param {Array<object>} obstacles
  51350. * Obstacles to calculate margin from.
  51351. *
  51352. * @return {number}
  51353. * The calculated margin in pixels. At least 1.
  51354. */
  51355. function calculateObstacleMargin(obstacles) {
  51356. var len = obstacles.length,
  51357. i = 0,
  51358. j,
  51359. obstacleDistance,
  51360. distances = [],
  51361. // Compute smallest distance between two rectangles
  51362. distance = function (a,
  51363. b,
  51364. bbMargin) {
  51365. // Count the distance even if we are slightly off
  51366. var margin = pick(bbMargin, 10),
  51367. yOverlap = a.yMax + margin > b.yMin - margin &&
  51368. a.yMin - margin < b.yMax + margin,
  51369. xOverlap = a.xMax + margin > b.xMin - margin &&
  51370. a.xMin - margin < b.xMax + margin,
  51371. xDistance = yOverlap ? (a.xMin > b.xMax ? a.xMin - b.xMax : b.xMin - a.xMax) : Infinity,
  51372. yDistance = xOverlap ? (a.yMin > b.yMax ? a.yMin - b.yMax : b.yMin - a.yMax) : Infinity;
  51373. // If the rectangles collide, try recomputing with smaller margin.
  51374. // If they collide anyway, discard the obstacle.
  51375. if (xOverlap && yOverlap) {
  51376. return (margin ?
  51377. distance(a, b, Math.floor(margin / 2)) :
  51378. Infinity);
  51379. }
  51380. return min(xDistance, yDistance);
  51381. };
  51382. // Go over all obstacles and compare them to the others.
  51383. for (; i < len; ++i) {
  51384. // Compare to all obstacles ahead. We will already have compared this
  51385. // obstacle to the ones before.
  51386. for (j = i + 1; j < len; ++j) {
  51387. obstacleDistance = distance(obstacles[i], obstacles[j]);
  51388. // TODO: Magic number 80
  51389. if (obstacleDistance < 80) { // Ignore large distances
  51390. distances.push(obstacleDistance);
  51391. }
  51392. }
  51393. }
  51394. // Ensure we always have at least one value, even in very spaceous charts
  51395. distances.push(80);
  51396. return max(Math.floor(distances.sort(function (a, b) {
  51397. return (a - b);
  51398. })[
  51399. // Discard first 10% of the relevant distances, and then grab
  51400. // the smallest one.
  51401. Math.floor(distances.length / 10)] / 2 - 1 // Divide the distance by 2 and subtract 1.
  51402. ), 1 // 1 is the minimum margin
  51403. );
  51404. }
  51405. /* eslint-disable no-invalid-this, valid-jsdoc */
  51406. /**
  51407. * The Connection class. Used internally to represent a connection between two
  51408. * points.
  51409. *
  51410. * @private
  51411. * @class
  51412. * @name Highcharts.Connection
  51413. *
  51414. * @param {Highcharts.Point} from
  51415. * Connection runs from this Point.
  51416. *
  51417. * @param {Highcharts.Point} to
  51418. * Connection runs to this Point.
  51419. *
  51420. * @param {Highcharts.ConnectorsOptions} [options]
  51421. * Connection options.
  51422. */
  51423. var Connection = /** @class */ (function () {
  51424. function Connection(from, to, options) {
  51425. /* *
  51426. *
  51427. * Properties
  51428. *
  51429. * */
  51430. this.chart = void 0;
  51431. this.fromPoint = void 0;
  51432. this.graphics = void 0;
  51433. this.pathfinder = void 0;
  51434. this.toPoint = void 0;
  51435. this.init(from, to, options);
  51436. }
  51437. /**
  51438. * Initialize the Connection object. Used as constructor only.
  51439. *
  51440. * @function Highcharts.Connection#init
  51441. *
  51442. * @param {Highcharts.Point} from
  51443. * Connection runs from this Point.
  51444. *
  51445. * @param {Highcharts.Point} to
  51446. * Connection runs to this Point.
  51447. *
  51448. * @param {Highcharts.ConnectorsOptions} [options]
  51449. * Connection options.
  51450. */
  51451. Connection.prototype.init = function (from, to, options) {
  51452. this.fromPoint = from;
  51453. this.toPoint = to;
  51454. this.options = options;
  51455. this.chart = from.series.chart;
  51456. this.pathfinder = this.chart.pathfinder;
  51457. };
  51458. /**
  51459. * Add (or update) this connection's path on chart. Stores reference to the
  51460. * created element on this.graphics.path.
  51461. *
  51462. * @function Highcharts.Connection#renderPath
  51463. *
  51464. * @param {Highcharts.SVGPathArray} path
  51465. * Path to render, in array format. E.g. ['M', 0, 0, 'L', 10, 10]
  51466. *
  51467. * @param {Highcharts.SVGAttributes} [attribs]
  51468. * SVG attributes for the path.
  51469. *
  51470. * @param {Partial<Highcharts.AnimationOptionsObject>} [animation]
  51471. * Animation options for the rendering.
  51472. */
  51473. Connection.prototype.renderPath = function (path, attribs, animation) {
  51474. var connection = this,
  51475. chart = this.chart,
  51476. styledMode = chart.styledMode,
  51477. pathfinder = chart.pathfinder,
  51478. animate = !chart.options.chart.forExport && animation !== false,
  51479. pathGraphic = connection.graphics && connection.graphics.path,
  51480. anim;
  51481. // Add the SVG element of the pathfinder group if it doesn't exist
  51482. if (!pathfinder.group) {
  51483. pathfinder.group = chart.renderer.g()
  51484. .addClass('highcharts-pathfinder-group')
  51485. .attr({ zIndex: -1 })
  51486. .add(chart.seriesGroup);
  51487. }
  51488. // Shift the group to compensate for plot area.
  51489. // Note: Do this always (even when redrawing a path) to avoid issues
  51490. // when updating chart in a way that changes plot metrics.
  51491. pathfinder.group.translate(chart.plotLeft, chart.plotTop);
  51492. // Create path if does not exist
  51493. if (!(pathGraphic && pathGraphic.renderer)) {
  51494. pathGraphic = chart.renderer.path()
  51495. .add(pathfinder.group);
  51496. if (!styledMode) {
  51497. pathGraphic.attr({
  51498. opacity: 0
  51499. });
  51500. }
  51501. }
  51502. // Set path attribs and animate to the new path
  51503. pathGraphic.attr(attribs);
  51504. anim = { d: path };
  51505. if (!styledMode) {
  51506. anim.opacity = 1;
  51507. }
  51508. pathGraphic[animate ? 'animate' : 'attr'](anim, animation);
  51509. // Store reference on connection
  51510. this.graphics = this.graphics || {};
  51511. this.graphics.path = pathGraphic;
  51512. };
  51513. /**
  51514. * Calculate and add marker graphics for connection to the chart. The
  51515. * created/updated elements are stored on this.graphics.start and
  51516. * this.graphics.end.
  51517. *
  51518. * @function Highcharts.Connection#addMarker
  51519. *
  51520. * @param {string} type
  51521. * Marker type, either 'start' or 'end'.
  51522. *
  51523. * @param {Highcharts.ConnectorsMarkerOptions} options
  51524. * All options for this marker. Not calculated or merged with other
  51525. * options.
  51526. *
  51527. * @param {Highcharts.SVGPathArray} path
  51528. * Connection path in array format. This is used to calculate the
  51529. * rotation angle of the markers.
  51530. */
  51531. Connection.prototype.addMarker = function (type, options, path) {
  51532. var connection = this,
  51533. chart = connection.fromPoint.series.chart,
  51534. pathfinder = chart.pathfinder,
  51535. renderer = chart.renderer,
  51536. point = (type === 'start' ?
  51537. connection.fromPoint :
  51538. connection.toPoint),
  51539. anchor = point.getPathfinderAnchorPoint(options),
  51540. markerVector,
  51541. radians,
  51542. rotation,
  51543. box,
  51544. width,
  51545. height,
  51546. pathVector,
  51547. segment;
  51548. if (!options.enabled) {
  51549. return;
  51550. }
  51551. // Last vector before start/end of path, used to get angle
  51552. if (type === 'start') {
  51553. segment = path[1];
  51554. }
  51555. else { // 'end'
  51556. segment = path[path.length - 2];
  51557. }
  51558. if (segment && segment[0] === 'M' || segment[0] === 'L') {
  51559. pathVector = {
  51560. x: segment[1],
  51561. y: segment[2]
  51562. };
  51563. // Get angle between pathVector and anchor point and use it to
  51564. // create marker position.
  51565. radians = point.getRadiansToVector(pathVector, anchor);
  51566. markerVector = point.getMarkerVector(radians, options.radius, anchor);
  51567. // Rotation of marker is calculated from angle between pathVector
  51568. // and markerVector.
  51569. // (Note:
  51570. // Used to recalculate radians between markerVector and pathVector,
  51571. // but this should be the same as between pathVector and anchor.)
  51572. rotation = -radians / deg2rad;
  51573. if (options.width && options.height) {
  51574. width = options.width;
  51575. height = options.height;
  51576. }
  51577. else {
  51578. width = height = options.radius * 2;
  51579. }
  51580. // Add graphics object if it does not exist
  51581. connection.graphics = connection.graphics || {};
  51582. box = {
  51583. x: markerVector.x - (width / 2),
  51584. y: markerVector.y - (height / 2),
  51585. width: width,
  51586. height: height,
  51587. rotation: rotation,
  51588. rotationOriginX: markerVector.x,
  51589. rotationOriginY: markerVector.y
  51590. };
  51591. if (!connection.graphics[type]) {
  51592. // Create new marker element
  51593. connection.graphics[type] = renderer
  51594. .symbol(options.symbol)
  51595. .addClass('highcharts-point-connecting-path-' + type + '-marker')
  51596. .attr(box)
  51597. .add(pathfinder.group);
  51598. if (!renderer.styledMode) {
  51599. connection.graphics[type].attr({
  51600. fill: options.color || connection.fromPoint.color,
  51601. stroke: options.lineColor,
  51602. 'stroke-width': options.lineWidth,
  51603. opacity: 0
  51604. })
  51605. .animate({
  51606. opacity: 1
  51607. }, point.series.options.animation);
  51608. }
  51609. }
  51610. else {
  51611. connection.graphics[type].animate(box);
  51612. }
  51613. }
  51614. };
  51615. /**
  51616. * Calculate and return connection path.
  51617. * Note: Recalculates chart obstacles on demand if they aren't calculated.
  51618. *
  51619. * @function Highcharts.Connection#getPath
  51620. *
  51621. * @param {Highcharts.ConnectorsOptions} options
  51622. * Connector options. Not calculated or merged with other options.
  51623. *
  51624. * @return {object|undefined}
  51625. * Calculated SVG path data in array format.
  51626. */
  51627. Connection.prototype.getPath = function (options) {
  51628. var pathfinder = this.pathfinder,
  51629. chart = this.chart,
  51630. algorithm = pathfinder.algorithms[options.type],
  51631. chartObstacles = pathfinder.chartObstacles;
  51632. if (typeof algorithm !== 'function') {
  51633. error('"' + options.type + '" is not a Pathfinder algorithm.');
  51634. return {
  51635. path: [],
  51636. obstacles: []
  51637. };
  51638. }
  51639. // This function calculates obstacles on demand if they don't exist
  51640. if (algorithm.requiresObstacles && !chartObstacles) {
  51641. chartObstacles =
  51642. pathfinder.chartObstacles =
  51643. pathfinder.getChartObstacles(options);
  51644. // If the algorithmMargin was computed, store the result in default
  51645. // options.
  51646. chart.options.connectors.algorithmMargin =
  51647. options.algorithmMargin;
  51648. // Cache some metrics too
  51649. pathfinder.chartObstacleMetrics =
  51650. pathfinder.getObstacleMetrics(chartObstacles);
  51651. }
  51652. // Get the SVG path
  51653. return algorithm(
  51654. // From
  51655. this.fromPoint.getPathfinderAnchorPoint(options.startMarker),
  51656. // To
  51657. this.toPoint.getPathfinderAnchorPoint(options.endMarker), merge({
  51658. chartObstacles: chartObstacles,
  51659. lineObstacles: pathfinder.lineObstacles || [],
  51660. obstacleMetrics: pathfinder.chartObstacleMetrics,
  51661. hardBounds: {
  51662. xMin: 0,
  51663. xMax: chart.plotWidth,
  51664. yMin: 0,
  51665. yMax: chart.plotHeight
  51666. },
  51667. obstacleOptions: {
  51668. margin: options.algorithmMargin
  51669. },
  51670. startDirectionX: pathfinder.getAlgorithmStartDirection(options.startMarker)
  51671. }, options));
  51672. };
  51673. /**
  51674. * (re)Calculate and (re)draw the connection.
  51675. *
  51676. * @function Highcharts.Connection#render
  51677. */
  51678. Connection.prototype.render = function () {
  51679. var connection = this,
  51680. fromPoint = connection.fromPoint,
  51681. series = fromPoint.series,
  51682. chart = series.chart,
  51683. pathfinder = chart.pathfinder,
  51684. pathResult,
  51685. path,
  51686. options = merge(chart.options.connectors,
  51687. series.options.connectors,
  51688. fromPoint.options.connectors,
  51689. connection.options),
  51690. attribs = {};
  51691. // Set path attribs
  51692. if (!chart.styledMode) {
  51693. attribs.stroke = options.lineColor || fromPoint.color;
  51694. attribs['stroke-width'] = options.lineWidth;
  51695. if (options.dashStyle) {
  51696. attribs.dashstyle = options.dashStyle;
  51697. }
  51698. }
  51699. attribs['class'] = // eslint-disable-line dot-notation
  51700. 'highcharts-point-connecting-path ' +
  51701. 'highcharts-color-' + fromPoint.colorIndex;
  51702. options = merge(attribs, options);
  51703. // Set common marker options
  51704. if (!defined(options.marker.radius)) {
  51705. options.marker.radius = min(max(Math.ceil((options.algorithmMargin || 8) / 2) - 1, 1), 5);
  51706. }
  51707. // Get the path
  51708. pathResult = connection.getPath(options);
  51709. path = pathResult.path;
  51710. // Always update obstacle storage with obstacles from this path.
  51711. // We don't know if future calls will need this for their algorithm.
  51712. if (pathResult.obstacles) {
  51713. pathfinder.lineObstacles =
  51714. pathfinder.lineObstacles || [];
  51715. pathfinder.lineObstacles =
  51716. pathfinder.lineObstacles.concat(pathResult.obstacles);
  51717. }
  51718. // Add the calculated path to the pathfinder group
  51719. connection.renderPath(path, attribs, series.options.animation);
  51720. // Render the markers
  51721. connection.addMarker('start', merge(options.marker, options.startMarker), path);
  51722. connection.addMarker('end', merge(options.marker, options.endMarker), path);
  51723. };
  51724. /**
  51725. * Destroy connection by destroying the added graphics elements.
  51726. *
  51727. * @function Highcharts.Connection#destroy
  51728. */
  51729. Connection.prototype.destroy = function () {
  51730. if (this.graphics) {
  51731. objectEach(this.graphics, function (val) {
  51732. val.destroy();
  51733. });
  51734. delete this.graphics;
  51735. }
  51736. };
  51737. return Connection;
  51738. }());
  51739. // Add to Highcharts namespace
  51740. H.Connection = Connection;
  51741. // Add pathfinding capabilities to Points
  51742. extend(Point.prototype, /** @lends Point.prototype */ {
  51743. /**
  51744. * Get coordinates of anchor point for pathfinder connection.
  51745. *
  51746. * @private
  51747. * @function Highcharts.Point#getPathfinderAnchorPoint
  51748. *
  51749. * @param {Highcharts.ConnectorsMarkerOptions} markerOptions
  51750. * Connection options for position on point.
  51751. *
  51752. * @return {Highcharts.PositionObject}
  51753. * An object with x/y properties for the position. Coordinates are
  51754. * in plot values, not relative to point.
  51755. */
  51756. getPathfinderAnchorPoint: function (markerOptions) {
  51757. var bb = getPointBB(this),
  51758. x,
  51759. y;
  51760. switch (markerOptions.align) { // eslint-disable-line default-case
  51761. case 'right':
  51762. x = 'xMax';
  51763. break;
  51764. case 'left':
  51765. x = 'xMin';
  51766. }
  51767. switch (markerOptions.verticalAlign) { // eslint-disable-line default-case
  51768. case 'top':
  51769. y = 'yMin';
  51770. break;
  51771. case 'bottom':
  51772. y = 'yMax';
  51773. }
  51774. return {
  51775. x: x ? bb[x] : (bb.xMin + bb.xMax) / 2,
  51776. y: y ? bb[y] : (bb.yMin + bb.yMax) / 2
  51777. };
  51778. },
  51779. /**
  51780. * Utility to get the angle from one point to another.
  51781. *
  51782. * @private
  51783. * @function Highcharts.Point#getRadiansToVector
  51784. *
  51785. * @param {Highcharts.PositionObject} v1
  51786. * The first vector, as an object with x/y properties.
  51787. *
  51788. * @param {Highcharts.PositionObject} v2
  51789. * The second vector, as an object with x/y properties.
  51790. *
  51791. * @return {number}
  51792. * The angle in degrees
  51793. */
  51794. getRadiansToVector: function (v1, v2) {
  51795. var box;
  51796. if (!defined(v2)) {
  51797. box = getPointBB(this);
  51798. if (box) {
  51799. v2 = {
  51800. x: (box.xMin + box.xMax) / 2,
  51801. y: (box.yMin + box.yMax) / 2
  51802. };
  51803. }
  51804. }
  51805. return Math.atan2(v2.y - v1.y, v1.x - v2.x);
  51806. },
  51807. /**
  51808. * Utility to get the position of the marker, based on the path angle and
  51809. * the marker's radius.
  51810. *
  51811. * @private
  51812. * @function Highcharts.Point#getMarkerVector
  51813. *
  51814. * @param {number} radians
  51815. * The angle in radians from the point center to another vector.
  51816. *
  51817. * @param {number} markerRadius
  51818. * The radius of the marker, to calculate the additional distance to
  51819. * the center of the marker.
  51820. *
  51821. * @param {object} anchor
  51822. * The anchor point of the path and marker as an object with x/y
  51823. * properties.
  51824. *
  51825. * @return {object}
  51826. * The marker vector as an object with x/y properties.
  51827. */
  51828. getMarkerVector: function (radians, markerRadius, anchor) {
  51829. var twoPI = Math.PI * 2.0,
  51830. theta = radians,
  51831. bb = getPointBB(this),
  51832. rectWidth = bb.xMax - bb.xMin,
  51833. rectHeight = bb.yMax - bb.yMin,
  51834. rAtan = Math.atan2(rectHeight,
  51835. rectWidth),
  51836. tanTheta = 1,
  51837. leftOrRightRegion = false,
  51838. rectHalfWidth = rectWidth / 2.0,
  51839. rectHalfHeight = rectHeight / 2.0,
  51840. rectHorizontalCenter = bb.xMin + rectHalfWidth,
  51841. rectVerticalCenter = bb.yMin + rectHalfHeight,
  51842. edgePoint = {
  51843. x: rectHorizontalCenter,
  51844. y: rectVerticalCenter
  51845. },
  51846. xFactor = 1,
  51847. yFactor = 1;
  51848. while (theta < -Math.PI) {
  51849. theta += twoPI;
  51850. }
  51851. while (theta > Math.PI) {
  51852. theta -= twoPI;
  51853. }
  51854. tanTheta = Math.tan(theta);
  51855. if ((theta > -rAtan) && (theta <= rAtan)) {
  51856. // Right side
  51857. yFactor = -1;
  51858. leftOrRightRegion = true;
  51859. }
  51860. else if (theta > rAtan && theta <= (Math.PI - rAtan)) {
  51861. // Top side
  51862. yFactor = -1;
  51863. }
  51864. else if (theta > (Math.PI - rAtan) || theta <= -(Math.PI - rAtan)) {
  51865. // Left side
  51866. xFactor = -1;
  51867. leftOrRightRegion = true;
  51868. }
  51869. else {
  51870. // Bottom side
  51871. xFactor = -1;
  51872. }
  51873. // Correct the edgePoint according to the placement of the marker
  51874. if (leftOrRightRegion) {
  51875. edgePoint.x += xFactor * (rectHalfWidth);
  51876. edgePoint.y += yFactor * (rectHalfWidth) * tanTheta;
  51877. }
  51878. else {
  51879. edgePoint.x += xFactor * (rectHeight / (2.0 * tanTheta));
  51880. edgePoint.y += yFactor * (rectHalfHeight);
  51881. }
  51882. if (anchor.x !== rectHorizontalCenter) {
  51883. edgePoint.x = anchor.x;
  51884. }
  51885. if (anchor.y !== rectVerticalCenter) {
  51886. edgePoint.y = anchor.y;
  51887. }
  51888. return {
  51889. x: edgePoint.x + (markerRadius * Math.cos(theta)),
  51890. y: edgePoint.y - (markerRadius * Math.sin(theta))
  51891. };
  51892. }
  51893. });
  51894. /**
  51895. * Warn if using legacy options. Copy the options over. Note that this will
  51896. * still break if using the legacy options in chart.update, addSeries etc.
  51897. * @private
  51898. */
  51899. function warnLegacy(chart) {
  51900. if (chart.options.pathfinder ||
  51901. chart.series.reduce(function (acc, series) {
  51902. if (series.options) {
  51903. merge(true, (series.options.connectors = series.options.connectors ||
  51904. {}), series.options.pathfinder);
  51905. }
  51906. return acc || series.options && series.options.pathfinder;
  51907. }, false)) {
  51908. merge(true, (chart.options.connectors = chart.options.connectors || {}), chart.options.pathfinder);
  51909. error('WARNING: Pathfinder options have been renamed. ' +
  51910. 'Use "chart.connectors" or "series.connectors" instead.');
  51911. }
  51912. }
  51913. return Connection;
  51914. });
  51915. _registerModule(_modules, 'Gantt/PathfinderAlgorithms.js', [_modules['Core/Utilities.js']], function (U) {
  51916. /* *
  51917. *
  51918. * (c) 2016 Highsoft AS
  51919. * Author: Øystein Moseng
  51920. *
  51921. * License: www.highcharts.com/license
  51922. *
  51923. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  51924. *
  51925. * */
  51926. var extend = U.extend,
  51927. pick = U.pick;
  51928. var min = Math.min,
  51929. max = Math.max,
  51930. abs = Math.abs;
  51931. /**
  51932. * Get index of last obstacle before xMin. Employs a type of binary search, and
  51933. * thus requires that obstacles are sorted by xMin value.
  51934. *
  51935. * @private
  51936. * @function findLastObstacleBefore
  51937. *
  51938. * @param {Array<object>} obstacles
  51939. * Array of obstacles to search in.
  51940. *
  51941. * @param {number} xMin
  51942. * The xMin threshold.
  51943. *
  51944. * @param {number} [startIx]
  51945. * Starting index to search from. Must be within array range.
  51946. *
  51947. * @return {number}
  51948. * The index of the last obstacle element before xMin.
  51949. */
  51950. function findLastObstacleBefore(obstacles, xMin, startIx) {
  51951. var left = startIx || 0, // left limit
  51952. right = obstacles.length - 1, // right limit
  51953. min = xMin - 0.0000001, // Make sure we include all obstacles at xMin
  51954. cursor,
  51955. cmp;
  51956. while (left <= right) {
  51957. cursor = (right + left) >> 1;
  51958. cmp = min - obstacles[cursor].xMin;
  51959. if (cmp > 0) {
  51960. left = cursor + 1;
  51961. }
  51962. else if (cmp < 0) {
  51963. right = cursor - 1;
  51964. }
  51965. else {
  51966. return cursor;
  51967. }
  51968. }
  51969. return left > 0 ? left - 1 : 0;
  51970. }
  51971. /**
  51972. * Test if a point lays within an obstacle.
  51973. *
  51974. * @private
  51975. * @function pointWithinObstacle
  51976. *
  51977. * @param {object} obstacle
  51978. * Obstacle to test.
  51979. *
  51980. * @param {Highcharts.Point} point
  51981. * Point with x/y props.
  51982. *
  51983. * @return {boolean}
  51984. * Whether point is within the obstacle or not.
  51985. */
  51986. function pointWithinObstacle(obstacle, point) {
  51987. return (point.x <= obstacle.xMax &&
  51988. point.x >= obstacle.xMin &&
  51989. point.y <= obstacle.yMax &&
  51990. point.y >= obstacle.yMin);
  51991. }
  51992. /**
  51993. * Find the index of an obstacle that wraps around a point.
  51994. * Returns -1 if not found.
  51995. *
  51996. * @private
  51997. * @function findObstacleFromPoint
  51998. *
  51999. * @param {Array<object>} obstacles
  52000. * Obstacles to test.
  52001. *
  52002. * @param {Highcharts.Point} point
  52003. * Point with x/y props.
  52004. *
  52005. * @return {number}
  52006. * Ix of the obstacle in the array, or -1 if not found.
  52007. */
  52008. function findObstacleFromPoint(obstacles, point) {
  52009. var i = findLastObstacleBefore(obstacles,
  52010. point.x + 1) + 1;
  52011. while (i--) {
  52012. if (obstacles[i].xMax >= point.x &&
  52013. // optimization using lazy evaluation
  52014. pointWithinObstacle(obstacles[i], point)) {
  52015. return i;
  52016. }
  52017. }
  52018. return -1;
  52019. }
  52020. /**
  52021. * Get SVG path array from array of line segments.
  52022. *
  52023. * @private
  52024. * @function pathFromSegments
  52025. *
  52026. * @param {Array<object>} segments
  52027. * The segments to build the path from.
  52028. *
  52029. * @return {Highcharts.SVGPathArray}
  52030. * SVG path array as accepted by the SVG Renderer.
  52031. */
  52032. function pathFromSegments(segments) {
  52033. var path = [];
  52034. if (segments.length) {
  52035. path.push(['M', segments[0].start.x, segments[0].start.y]);
  52036. for (var i = 0; i < segments.length; ++i) {
  52037. path.push(['L', segments[i].end.x, segments[i].end.y]);
  52038. }
  52039. }
  52040. return path;
  52041. }
  52042. /**
  52043. * Limits obstacle max/mins in all directions to bounds. Modifies input
  52044. * obstacle.
  52045. *
  52046. * @private
  52047. * @function limitObstacleToBounds
  52048. *
  52049. * @param {object} obstacle
  52050. * Obstacle to limit.
  52051. *
  52052. * @param {object} bounds
  52053. * Bounds to use as limit.
  52054. *
  52055. * @return {void}
  52056. */
  52057. function limitObstacleToBounds(obstacle, bounds) {
  52058. obstacle.yMin = max(obstacle.yMin, bounds.yMin);
  52059. obstacle.yMax = min(obstacle.yMax, bounds.yMax);
  52060. obstacle.xMin = max(obstacle.xMin, bounds.xMin);
  52061. obstacle.xMax = min(obstacle.xMax, bounds.xMax);
  52062. }
  52063. /**
  52064. * Get an SVG path from a starting coordinate to an ending coordinate.
  52065. * Draws a straight line.
  52066. *
  52067. * @function Highcharts.Pathfinder.algorithms.straight
  52068. *
  52069. * @param {Highcharts.PositionObject} start
  52070. * Starting coordinate, object with x/y props.
  52071. *
  52072. * @param {Highcharts.PositionObject} end
  52073. * Ending coordinate, object with x/y props.
  52074. *
  52075. * @return {object}
  52076. * An object with the SVG path in Array form as accepted by the SVG
  52077. * renderer, as well as an array of new obstacles making up this
  52078. * path.
  52079. */
  52080. function straight(start, end) {
  52081. return {
  52082. path: [
  52083. ['M', start.x, start.y],
  52084. ['L', end.x, end.y]
  52085. ],
  52086. obstacles: [{ start: start, end: end }]
  52087. };
  52088. }
  52089. /**
  52090. * Find a path from a starting coordinate to an ending coordinate, using
  52091. * right angles only, and taking only starting/ending obstacle into
  52092. * consideration.
  52093. *
  52094. * @function Highcharts.Pathfinder.algorithms.simpleConnect
  52095. *
  52096. * @param {Highcharts.PositionObject} start
  52097. * Starting coordinate, object with x/y props.
  52098. *
  52099. * @param {Highcharts.PositionObject} end
  52100. * Ending coordinate, object with x/y props.
  52101. *
  52102. * @param {object} options
  52103. * Options for the algorithm:
  52104. * - chartObstacles: Array of chart obstacles to avoid
  52105. * - startDirectionX: Optional. True if starting in the X direction.
  52106. * If not provided, the algorithm starts in the direction that is
  52107. * the furthest between start/end.
  52108. *
  52109. * @return {object}
  52110. * An object with the SVG path in Array form as accepted by the SVG
  52111. * renderer, as well as an array of new obstacles making up this
  52112. * path.
  52113. */
  52114. var simpleConnect = function (start,
  52115. end,
  52116. options) {
  52117. var segments = [],
  52118. endSegment,
  52119. dir = pick(options.startDirectionX,
  52120. abs(end.x - start.x) > abs(end.y - start.y)) ? 'x' : 'y',
  52121. chartObstacles = options.chartObstacles,
  52122. startObstacleIx = findObstacleFromPoint(chartObstacles,
  52123. start),
  52124. endObstacleIx = findObstacleFromPoint(chartObstacles,
  52125. end),
  52126. startObstacle,
  52127. endObstacle,
  52128. prevWaypoint,
  52129. waypoint,
  52130. waypoint2,
  52131. useMax,
  52132. endPoint;
  52133. // eslint-disable-next-line valid-jsdoc
  52134. /**
  52135. * Return a clone of a point with a property set from a target object,
  52136. * optionally with an offset
  52137. * @private
  52138. */
  52139. function copyFromPoint(from, fromKey, to, toKey, offset) {
  52140. var point = {
  52141. x: from.x,
  52142. y: from.y
  52143. };
  52144. point[fromKey] = to[toKey || fromKey] + (offset || 0);
  52145. return point;
  52146. }
  52147. // eslint-disable-next-line valid-jsdoc
  52148. /**
  52149. * Return waypoint outside obstacle.
  52150. * @private
  52151. */
  52152. function getMeOut(obstacle, point, direction) {
  52153. var useMax = abs(point[direction] - obstacle[direction + 'Min']) >
  52154. abs(point[direction] - obstacle[direction + 'Max']);
  52155. return copyFromPoint(point, direction, obstacle, direction + (useMax ? 'Max' : 'Min'), useMax ? 1 : -1);
  52156. }
  52157. // Pull out end point
  52158. if (endObstacleIx > -1) {
  52159. endObstacle = chartObstacles[endObstacleIx];
  52160. waypoint = getMeOut(endObstacle, end, dir);
  52161. endSegment = {
  52162. start: waypoint,
  52163. end: end
  52164. };
  52165. endPoint = waypoint;
  52166. }
  52167. else {
  52168. endPoint = end;
  52169. }
  52170. // If an obstacle envelops the start point, add a segment to get out,
  52171. // and around it.
  52172. if (startObstacleIx > -1) {
  52173. startObstacle = chartObstacles[startObstacleIx];
  52174. waypoint = getMeOut(startObstacle, start, dir);
  52175. segments.push({
  52176. start: start,
  52177. end: waypoint
  52178. });
  52179. // If we are going back again, switch direction to get around start
  52180. // obstacle.
  52181. if (
  52182. // Going towards max from start:
  52183. waypoint[dir] >= start[dir] ===
  52184. // Going towards min to end:
  52185. waypoint[dir] >= endPoint[dir]) {
  52186. dir = dir === 'y' ? 'x' : 'y';
  52187. useMax = start[dir] < end[dir];
  52188. segments.push({
  52189. start: waypoint,
  52190. end: copyFromPoint(waypoint, dir, startObstacle, dir + (useMax ? 'Max' : 'Min'), useMax ? 1 : -1)
  52191. });
  52192. // Switch direction again
  52193. dir = dir === 'y' ? 'x' : 'y';
  52194. }
  52195. }
  52196. // We are around the start obstacle. Go towards the end in one
  52197. // direction.
  52198. prevWaypoint = segments.length ?
  52199. segments[segments.length - 1].end :
  52200. start;
  52201. waypoint = copyFromPoint(prevWaypoint, dir, endPoint);
  52202. segments.push({
  52203. start: prevWaypoint,
  52204. end: waypoint
  52205. });
  52206. // Final run to end point in the other direction
  52207. dir = dir === 'y' ? 'x' : 'y';
  52208. waypoint2 = copyFromPoint(waypoint, dir, endPoint);
  52209. segments.push({
  52210. start: waypoint,
  52211. end: waypoint2
  52212. });
  52213. // Finally add the endSegment
  52214. segments.push(endSegment);
  52215. return {
  52216. path: pathFromSegments(segments),
  52217. obstacles: segments
  52218. };
  52219. };
  52220. simpleConnect.requiresObstacles = true;
  52221. /**
  52222. * Find a path from a starting coordinate to an ending coordinate, taking
  52223. * obstacles into consideration. Might not always find the optimal path,
  52224. * but is fast, and usually good enough.
  52225. *
  52226. * @function Highcharts.Pathfinder.algorithms.fastAvoid
  52227. *
  52228. * @param {Highcharts.PositionObject} start
  52229. * Starting coordinate, object with x/y props.
  52230. *
  52231. * @param {Highcharts.PositionObject} end
  52232. * Ending coordinate, object with x/y props.
  52233. *
  52234. * @param {object} options
  52235. * Options for the algorithm.
  52236. * - chartObstacles: Array of chart obstacles to avoid
  52237. * - lineObstacles: Array of line obstacles to jump over
  52238. * - obstacleMetrics: Object with metrics of chartObstacles cached
  52239. * - hardBounds: Hard boundaries to not cross
  52240. * - obstacleOptions: Options for the obstacles, including margin
  52241. * - startDirectionX: Optional. True if starting in the X direction.
  52242. * If not provided, the algorithm starts in the
  52243. * direction that is the furthest between
  52244. * start/end.
  52245. *
  52246. * @return {object}
  52247. * An object with the SVG path in Array form as accepted by the SVG
  52248. * renderer, as well as an array of new obstacles making up this
  52249. * path.
  52250. */
  52251. var fastAvoid = function (start,
  52252. end,
  52253. options) {
  52254. /*
  52255. Algorithm rules/description
  52256. - Find initial direction
  52257. - Determine soft/hard max for each direction.
  52258. - Move along initial direction until obstacle.
  52259. - Change direction.
  52260. - If hitting obstacle,
  52261. first try to change length of previous line
  52262. before changing direction again.
  52263. Soft min/max x = start/destination x +/- widest obstacle + margin
  52264. Soft min/max y = start/destination y +/- tallest obstacle + margin
  52265. @todo:
  52266. - Make retrospective,
  52267. try changing prev segment to reduce
  52268. corners
  52269. - Fix logic for breaking out of end-points - not always picking
  52270. the best direction currently
  52271. - When going around the end obstacle we should not always go the
  52272. shortest route,
  52273. rather pick the one closer to the end point
  52274. */
  52275. var dirIsX = pick(options.startDirectionX,
  52276. abs(end.x - start.x) > abs(end.y - start.y)),
  52277. dir = dirIsX ? 'x' : 'y',
  52278. segments,
  52279. useMax,
  52280. extractedEndPoint,
  52281. endSegments = [],
  52282. forceObstacleBreak = false, // Used in clearPathTo to keep track of
  52283. // when to force break through an obstacle.
  52284. // Boundaries to stay within. If beyond soft boundary, prefer to
  52285. // change direction ASAP. If at hard max, always change immediately.
  52286. metrics = options.obstacleMetrics,
  52287. softMinX = min(start.x,
  52288. end.x) - metrics.maxWidth - 10,
  52289. softMaxX = max(start.x,
  52290. end.x) + metrics.maxWidth + 10,
  52291. softMinY = min(start.y,
  52292. end.y) - metrics.maxHeight - 10,
  52293. softMaxY = max(start.y,
  52294. end.y) + metrics.maxHeight + 10,
  52295. // Obstacles
  52296. chartObstacles = options.chartObstacles,
  52297. startObstacleIx = findLastObstacleBefore(chartObstacles,
  52298. softMinX),
  52299. endObstacleIx = findLastObstacleBefore(chartObstacles,
  52300. softMaxX);
  52301. // eslint-disable-next-line valid-jsdoc
  52302. /**
  52303. * How far can you go between two points before hitting an obstacle?
  52304. * Does not work for diagonal lines (because it doesn't have to).
  52305. * @private
  52306. */
  52307. function pivotPoint(fromPoint, toPoint, directionIsX) {
  52308. var firstPoint,
  52309. lastPoint,
  52310. highestPoint,
  52311. lowestPoint,
  52312. i,
  52313. searchDirection = fromPoint.x < toPoint.x ? 1 : -1;
  52314. if (fromPoint.x < toPoint.x) {
  52315. firstPoint = fromPoint;
  52316. lastPoint = toPoint;
  52317. }
  52318. else {
  52319. firstPoint = toPoint;
  52320. lastPoint = fromPoint;
  52321. }
  52322. if (fromPoint.y < toPoint.y) {
  52323. lowestPoint = fromPoint;
  52324. highestPoint = toPoint;
  52325. }
  52326. else {
  52327. lowestPoint = toPoint;
  52328. highestPoint = fromPoint;
  52329. }
  52330. // Go through obstacle range in reverse if toPoint is before
  52331. // fromPoint in the X-dimension.
  52332. i = searchDirection < 0 ?
  52333. // Searching backwards, start at last obstacle before last point
  52334. min(findLastObstacleBefore(chartObstacles, lastPoint.x), chartObstacles.length - 1) :
  52335. // Forwards. Since we're not sorted by xMax, we have to look
  52336. // at all obstacles.
  52337. 0;
  52338. // Go through obstacles in this X range
  52339. while (chartObstacles[i] && (searchDirection > 0 && chartObstacles[i].xMin <= lastPoint.x ||
  52340. searchDirection < 0 && chartObstacles[i].xMax >= firstPoint.x)) {
  52341. // If this obstacle is between from and to points in a straight
  52342. // line, pivot at the intersection.
  52343. if (chartObstacles[i].xMin <= lastPoint.x &&
  52344. chartObstacles[i].xMax >= firstPoint.x &&
  52345. chartObstacles[i].yMin <= highestPoint.y &&
  52346. chartObstacles[i].yMax >= lowestPoint.y) {
  52347. if (directionIsX) {
  52348. return {
  52349. y: fromPoint.y,
  52350. x: fromPoint.x < toPoint.x ?
  52351. chartObstacles[i].xMin - 1 :
  52352. chartObstacles[i].xMax + 1,
  52353. obstacle: chartObstacles[i]
  52354. };
  52355. }
  52356. // else ...
  52357. return {
  52358. x: fromPoint.x,
  52359. y: fromPoint.y < toPoint.y ?
  52360. chartObstacles[i].yMin - 1 :
  52361. chartObstacles[i].yMax + 1,
  52362. obstacle: chartObstacles[i]
  52363. };
  52364. }
  52365. i += searchDirection;
  52366. }
  52367. return toPoint;
  52368. }
  52369. /**
  52370. * Decide in which direction to dodge or get out of an obstacle.
  52371. * Considers desired direction, which way is shortest, soft and hard
  52372. * bounds.
  52373. *
  52374. * (? Returns a string, either xMin, xMax, yMin or yMax.)
  52375. *
  52376. * @private
  52377. * @function
  52378. *
  52379. * @param {object} obstacle
  52380. * Obstacle to dodge/escape.
  52381. *
  52382. * @param {object} fromPoint
  52383. * Point with x/y props that's dodging/escaping.
  52384. *
  52385. * @param {object} toPoint
  52386. * Goal point.
  52387. *
  52388. * @param {boolean} dirIsX
  52389. * Dodge in X dimension.
  52390. *
  52391. * @param {object} bounds
  52392. * Hard and soft boundaries.
  52393. *
  52394. * @return {boolean}
  52395. * Use max or not.
  52396. */
  52397. function getDodgeDirection(obstacle, fromPoint, toPoint, dirIsX, bounds) {
  52398. var softBounds = bounds.soft, hardBounds = bounds.hard, dir = dirIsX ? 'x' : 'y', toPointMax = { x: fromPoint.x, y: fromPoint.y }, toPointMin = { x: fromPoint.x, y: fromPoint.y }, minPivot, maxPivot, maxOutOfSoftBounds = obstacle[dir + 'Max'] >=
  52399. softBounds[dir + 'Max'], minOutOfSoftBounds = obstacle[dir + 'Min'] <=
  52400. softBounds[dir + 'Min'], maxOutOfHardBounds = obstacle[dir + 'Max'] >=
  52401. hardBounds[dir + 'Max'], minOutOfHardBounds = obstacle[dir + 'Min'] <=
  52402. hardBounds[dir + 'Min'],
  52403. // Find out if we should prefer one direction over the other if
  52404. // we can choose freely
  52405. minDistance = abs(obstacle[dir + 'Min'] - fromPoint[dir]), maxDistance = abs(obstacle[dir + 'Max'] - fromPoint[dir]),
  52406. // If it's a small difference, pick the one leading towards dest
  52407. // point. Otherwise pick the shortest distance
  52408. useMax = abs(minDistance - maxDistance) < 10 ?
  52409. fromPoint[dir] < toPoint[dir] :
  52410. maxDistance < minDistance;
  52411. // Check if we hit any obstacles trying to go around in either
  52412. // direction.
  52413. toPointMin[dir] = obstacle[dir + 'Min'];
  52414. toPointMax[dir] = obstacle[dir + 'Max'];
  52415. minPivot = pivotPoint(fromPoint, toPointMin, dirIsX)[dir] !==
  52416. toPointMin[dir];
  52417. maxPivot = pivotPoint(fromPoint, toPointMax, dirIsX)[dir] !==
  52418. toPointMax[dir];
  52419. useMax = minPivot ?
  52420. (maxPivot ? useMax : true) :
  52421. (maxPivot ? false : useMax);
  52422. // useMax now contains our preferred choice, bounds not taken into
  52423. // account. If both or neither direction is out of bounds we want to
  52424. // use this.
  52425. // Deal with soft bounds
  52426. useMax = minOutOfSoftBounds ?
  52427. (maxOutOfSoftBounds ? useMax : true) : // Out on min
  52428. (maxOutOfSoftBounds ? false : useMax); // Not out on min
  52429. // Deal with hard bounds
  52430. useMax = minOutOfHardBounds ?
  52431. (maxOutOfHardBounds ? useMax : true) : // Out on min
  52432. (maxOutOfHardBounds ? false : useMax); // Not out on min
  52433. return useMax;
  52434. }
  52435. // eslint-disable-next-line valid-jsdoc
  52436. /**
  52437. * Find a clear path between point.
  52438. * @private
  52439. */
  52440. function clearPathTo(fromPoint, toPoint, dirIsX) {
  52441. // Don't waste time if we've hit goal
  52442. if (fromPoint.x === toPoint.x && fromPoint.y === toPoint.y) {
  52443. return [];
  52444. }
  52445. var dir = dirIsX ? 'x' : 'y',
  52446. pivot,
  52447. segments,
  52448. waypoint,
  52449. waypointUseMax,
  52450. envelopingObstacle,
  52451. secondEnvelopingObstacle,
  52452. envelopWaypoint,
  52453. obstacleMargin = options.obstacleOptions.margin,
  52454. bounds = {
  52455. soft: {
  52456. xMin: softMinX,
  52457. xMax: softMaxX,
  52458. yMin: softMinY,
  52459. yMax: softMaxY
  52460. },
  52461. hard: options.hardBounds
  52462. };
  52463. // If fromPoint is inside an obstacle we have a problem. Break out
  52464. // by just going to the outside of this obstacle. We prefer to go to
  52465. // the nearest edge in the chosen direction.
  52466. envelopingObstacle =
  52467. findObstacleFromPoint(chartObstacles, fromPoint);
  52468. if (envelopingObstacle > -1) {
  52469. envelopingObstacle = chartObstacles[envelopingObstacle];
  52470. waypointUseMax = getDodgeDirection(envelopingObstacle, fromPoint, toPoint, dirIsX, bounds);
  52471. // Cut obstacle to hard bounds to make sure we stay within
  52472. limitObstacleToBounds(envelopingObstacle, options.hardBounds);
  52473. envelopWaypoint = dirIsX ? {
  52474. y: fromPoint.y,
  52475. x: envelopingObstacle[waypointUseMax ? 'xMax' : 'xMin'] +
  52476. (waypointUseMax ? 1 : -1)
  52477. } : {
  52478. x: fromPoint.x,
  52479. y: envelopingObstacle[waypointUseMax ? 'yMax' : 'yMin'] +
  52480. (waypointUseMax ? 1 : -1)
  52481. };
  52482. // If we crashed into another obstacle doing this, we put the
  52483. // waypoint between them instead
  52484. secondEnvelopingObstacle = findObstacleFromPoint(chartObstacles, envelopWaypoint);
  52485. if (secondEnvelopingObstacle > -1) {
  52486. secondEnvelopingObstacle = chartObstacles[secondEnvelopingObstacle];
  52487. // Cut obstacle to hard bounds
  52488. limitObstacleToBounds(secondEnvelopingObstacle, options.hardBounds);
  52489. // Modify waypoint to lay between obstacles
  52490. envelopWaypoint[dir] = waypointUseMax ? max(envelopingObstacle[dir + 'Max'] - obstacleMargin + 1, (secondEnvelopingObstacle[dir + 'Min'] +
  52491. envelopingObstacle[dir + 'Max']) / 2) :
  52492. min((envelopingObstacle[dir + 'Min'] + obstacleMargin - 1), ((secondEnvelopingObstacle[dir + 'Max'] +
  52493. envelopingObstacle[dir + 'Min']) / 2));
  52494. // We are not going anywhere. If this happens for the first
  52495. // time, do nothing. Otherwise, try to go to the extreme of
  52496. // the obstacle pair in the current direction.
  52497. if (fromPoint.x === envelopWaypoint.x &&
  52498. fromPoint.y === envelopWaypoint.y) {
  52499. if (forceObstacleBreak) {
  52500. envelopWaypoint[dir] = waypointUseMax ?
  52501. max(envelopingObstacle[dir + 'Max'], secondEnvelopingObstacle[dir + 'Max']) + 1 :
  52502. min(envelopingObstacle[dir + 'Min'], secondEnvelopingObstacle[dir + 'Min']) - 1;
  52503. }
  52504. // Toggle on if off, and the opposite
  52505. forceObstacleBreak = !forceObstacleBreak;
  52506. }
  52507. else {
  52508. // This point is not identical to previous.
  52509. // Clear break trigger.
  52510. forceObstacleBreak = false;
  52511. }
  52512. }
  52513. segments = [{
  52514. start: fromPoint,
  52515. end: envelopWaypoint
  52516. }];
  52517. }
  52518. else { // If not enveloping, use standard pivot calculation
  52519. pivot = pivotPoint(fromPoint, {
  52520. x: dirIsX ? toPoint.x : fromPoint.x,
  52521. y: dirIsX ? fromPoint.y : toPoint.y
  52522. }, dirIsX);
  52523. segments = [{
  52524. start: fromPoint,
  52525. end: {
  52526. x: pivot.x,
  52527. y: pivot.y
  52528. }
  52529. }];
  52530. // Pivot before goal, use a waypoint to dodge obstacle
  52531. if (pivot[dirIsX ? 'x' : 'y'] !== toPoint[dirIsX ? 'x' : 'y']) {
  52532. // Find direction of waypoint
  52533. waypointUseMax = getDodgeDirection(pivot.obstacle, pivot, toPoint, !dirIsX, bounds);
  52534. // Cut waypoint to hard bounds
  52535. limitObstacleToBounds(pivot.obstacle, options.hardBounds);
  52536. waypoint = {
  52537. x: dirIsX ?
  52538. pivot.x :
  52539. pivot.obstacle[waypointUseMax ? 'xMax' : 'xMin'] +
  52540. (waypointUseMax ? 1 : -1),
  52541. y: dirIsX ?
  52542. pivot.obstacle[waypointUseMax ? 'yMax' : 'yMin'] +
  52543. (waypointUseMax ? 1 : -1) :
  52544. pivot.y
  52545. };
  52546. // We're changing direction here, store that to make sure we
  52547. // also change direction when adding the last segment array
  52548. // after handling waypoint.
  52549. dirIsX = !dirIsX;
  52550. segments = segments.concat(clearPathTo({
  52551. x: pivot.x,
  52552. y: pivot.y
  52553. }, waypoint, dirIsX));
  52554. }
  52555. }
  52556. // Get segments for the other direction too
  52557. // Recursion is our friend
  52558. segments = segments.concat(clearPathTo(segments[segments.length - 1].end, toPoint, !dirIsX));
  52559. return segments;
  52560. }
  52561. // eslint-disable-next-line valid-jsdoc
  52562. /**
  52563. * Extract point to outside of obstacle in whichever direction is
  52564. * closest. Returns new point outside obstacle.
  52565. * @private
  52566. */
  52567. function extractFromObstacle(obstacle, point, goalPoint) {
  52568. var dirIsX = min(obstacle.xMax - point.x,
  52569. point.x - obstacle.xMin) <
  52570. min(obstacle.yMax - point.y,
  52571. point.y - obstacle.yMin),
  52572. bounds = {
  52573. soft: options.hardBounds,
  52574. hard: options.hardBounds
  52575. },
  52576. useMax = getDodgeDirection(obstacle,
  52577. point,
  52578. goalPoint,
  52579. dirIsX,
  52580. bounds);
  52581. return dirIsX ? {
  52582. y: point.y,
  52583. x: obstacle[useMax ? 'xMax' : 'xMin'] + (useMax ? 1 : -1)
  52584. } : {
  52585. x: point.x,
  52586. y: obstacle[useMax ? 'yMax' : 'yMin'] + (useMax ? 1 : -1)
  52587. };
  52588. }
  52589. // Cut the obstacle array to soft bounds for optimization in large
  52590. // datasets.
  52591. chartObstacles =
  52592. chartObstacles.slice(startObstacleIx, endObstacleIx + 1);
  52593. // If an obstacle envelops the end point, move it out of there and add
  52594. // a little segment to where it was.
  52595. if ((endObstacleIx = findObstacleFromPoint(chartObstacles, end)) > -1) {
  52596. extractedEndPoint = extractFromObstacle(chartObstacles[endObstacleIx], end, start);
  52597. endSegments.push({
  52598. end: end,
  52599. start: extractedEndPoint
  52600. });
  52601. end = extractedEndPoint;
  52602. }
  52603. // If it's still inside one or more obstacles, get out of there by
  52604. // force-moving towards the start point.
  52605. while ((endObstacleIx = findObstacleFromPoint(chartObstacles, end)) > -1) {
  52606. useMax = end[dir] - start[dir] < 0;
  52607. extractedEndPoint = {
  52608. x: end.x,
  52609. y: end.y
  52610. };
  52611. extractedEndPoint[dir] = chartObstacles[endObstacleIx][useMax ? dir + 'Max' : dir + 'Min'] + (useMax ? 1 : -1);
  52612. endSegments.push({
  52613. end: end,
  52614. start: extractedEndPoint
  52615. });
  52616. end = extractedEndPoint;
  52617. }
  52618. // Find the path
  52619. segments = clearPathTo(start, end, dirIsX);
  52620. // Add the end-point segments
  52621. segments = segments.concat(endSegments.reverse());
  52622. return {
  52623. path: pathFromSegments(segments),
  52624. obstacles: segments
  52625. };
  52626. };
  52627. fastAvoid.requiresObstacles = true;
  52628. // Define the available pathfinding algorithms.
  52629. // Algorithms take up to 3 arguments: starting point, ending point, and an
  52630. // options object.
  52631. var algorithms = {
  52632. fastAvoid: fastAvoid,
  52633. straight: straight,
  52634. simpleConnect: simpleConnect
  52635. };
  52636. return algorithms;
  52637. });
  52638. _registerModule(_modules, 'Gantt/Pathfinder.js', [_modules['Gantt/Connection.js'], _modules['Core/Chart/Chart.js'], _modules['Core/Globals.js'], _modules['Core/Options.js'], _modules['Core/Series/Point.js'], _modules['Core/Utilities.js'], _modules['Gantt/PathfinderAlgorithms.js']], function (Connection, Chart, H, O, Point, U, pathfinderAlgorithms) {
  52639. /* *
  52640. *
  52641. * (c) 2016 Highsoft AS
  52642. * Authors: Øystein Moseng, Lars A. V. Cabrera
  52643. *
  52644. * License: www.highcharts.com/license
  52645. *
  52646. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  52647. *
  52648. * */
  52649. /**
  52650. * The default pathfinder algorithm to use for a chart. It is possible to define
  52651. * your own algorithms by adding them to the
  52652. * `Highcharts.Pathfinder.prototype.algorithms`
  52653. * object before the chart has been created.
  52654. *
  52655. * The default algorithms are as follows:
  52656. *
  52657. * `straight`: Draws a straight line between the connecting
  52658. * points. Does not avoid other points when drawing.
  52659. *
  52660. * `simpleConnect`: Finds a path between the points using right angles
  52661. * only. Takes only starting/ending points into
  52662. * account, and will not avoid other points.
  52663. *
  52664. * `fastAvoid`: Finds a path between the points using right angles
  52665. * only. Will attempt to avoid other points, but its
  52666. * focus is performance over accuracy. Works well with
  52667. * less dense datasets.
  52668. *
  52669. * @typedef {"fastAvoid"|"simpleConnect"|"straight"|string} Highcharts.PathfinderTypeValue
  52670. */
  52671. ''; // detach doclets above
  52672. var defaultOptions = O.defaultOptions;
  52673. var addEvent = U.addEvent,
  52674. defined = U.defined,
  52675. error = U.error,
  52676. extend = U.extend,
  52677. merge = U.merge,
  52678. objectEach = U.objectEach,
  52679. pick = U.pick,
  52680. splat = U.splat;
  52681. var deg2rad = H.deg2rad,
  52682. max = Math.max,
  52683. min = Math.min;
  52684. /*
  52685. @todo:
  52686. - Document how to write your own algorithms
  52687. - Consider adding a Point.pathTo method that wraps creating a connection
  52688. and rendering it
  52689. */
  52690. // Set default Pathfinder options
  52691. extend(defaultOptions, {
  52692. /**
  52693. * The Pathfinder module allows you to define connections between any two
  52694. * points, represented as lines - optionally with markers for the start
  52695. * and/or end points. Multiple algorithms are available for calculating how
  52696. * the connecting lines are drawn.
  52697. *
  52698. * Connector functionality requires Highcharts Gantt to be loaded. In Gantt
  52699. * charts, the connectors are used to draw dependencies between tasks.
  52700. *
  52701. * @see [dependency](series.gantt.data.dependency)
  52702. *
  52703. * @sample gantt/pathfinder/demo
  52704. * Pathfinder connections
  52705. *
  52706. * @declare Highcharts.ConnectorsOptions
  52707. * @product gantt
  52708. * @optionparent connectors
  52709. */
  52710. connectors: {
  52711. /**
  52712. * Enable connectors for this chart. Requires Highcharts Gantt.
  52713. *
  52714. * @type {boolean}
  52715. * @default true
  52716. * @since 6.2.0
  52717. * @apioption connectors.enabled
  52718. */
  52719. /**
  52720. * Set the default dash style for this chart's connecting lines.
  52721. *
  52722. * @type {string}
  52723. * @default solid
  52724. * @since 6.2.0
  52725. * @apioption connectors.dashStyle
  52726. */
  52727. /**
  52728. * Set the default color for this chart's Pathfinder connecting lines.
  52729. * Defaults to the color of the point being connected.
  52730. *
  52731. * @type {Highcharts.ColorString}
  52732. * @since 6.2.0
  52733. * @apioption connectors.lineColor
  52734. */
  52735. /**
  52736. * Set the default pathfinder margin to use, in pixels. Some Pathfinder
  52737. * algorithms attempt to avoid obstacles, such as other points in the
  52738. * chart. These algorithms use this margin to determine how close lines
  52739. * can be to an obstacle. The default is to compute this automatically
  52740. * from the size of the obstacles in the chart.
  52741. *
  52742. * To draw connecting lines close to existing points, set this to a low
  52743. * number. For more space around existing points, set this number
  52744. * higher.
  52745. *
  52746. * @sample gantt/pathfinder/algorithm-margin
  52747. * Small algorithmMargin
  52748. *
  52749. * @type {number}
  52750. * @since 6.2.0
  52751. * @apioption connectors.algorithmMargin
  52752. */
  52753. /**
  52754. * Set the default pathfinder algorithm to use for this chart. It is
  52755. * possible to define your own algorithms by adding them to the
  52756. * Highcharts.Pathfinder.prototype.algorithms object before the chart
  52757. * has been created.
  52758. *
  52759. * The default algorithms are as follows:
  52760. *
  52761. * `straight`: Draws a straight line between the connecting
  52762. * points. Does not avoid other points when drawing.
  52763. *
  52764. * `simpleConnect`: Finds a path between the points using right angles
  52765. * only. Takes only starting/ending points into
  52766. * account, and will not avoid other points.
  52767. *
  52768. * `fastAvoid`: Finds a path between the points using right angles
  52769. * only. Will attempt to avoid other points, but its
  52770. * focus is performance over accuracy. Works well with
  52771. * less dense datasets.
  52772. *
  52773. * Default value: `straight` is used as default for most series types,
  52774. * while `simpleConnect` is used as default for Gantt series, to show
  52775. * dependencies between points.
  52776. *
  52777. * @sample gantt/pathfinder/demo
  52778. * Different types used
  52779. *
  52780. * @type {Highcharts.PathfinderTypeValue}
  52781. * @default undefined
  52782. * @since 6.2.0
  52783. */
  52784. type: 'straight',
  52785. /**
  52786. * Set the default pixel width for this chart's Pathfinder connecting
  52787. * lines.
  52788. *
  52789. * @since 6.2.0
  52790. */
  52791. lineWidth: 1,
  52792. /**
  52793. * Marker options for this chart's Pathfinder connectors. Note that
  52794. * this option is overridden by the `startMarker` and `endMarker`
  52795. * options.
  52796. *
  52797. * @declare Highcharts.ConnectorsMarkerOptions
  52798. * @since 6.2.0
  52799. */
  52800. marker: {
  52801. /**
  52802. * Set the radius of the connector markers. The default is
  52803. * automatically computed based on the algorithmMargin setting.
  52804. *
  52805. * Setting marker.width and marker.height will override this
  52806. * setting.
  52807. *
  52808. * @type {number}
  52809. * @since 6.2.0
  52810. * @apioption connectors.marker.radius
  52811. */
  52812. /**
  52813. * Set the width of the connector markers. If not supplied, this
  52814. * is inferred from the marker radius.
  52815. *
  52816. * @type {number}
  52817. * @since 6.2.0
  52818. * @apioption connectors.marker.width
  52819. */
  52820. /**
  52821. * Set the height of the connector markers. If not supplied, this
  52822. * is inferred from the marker radius.
  52823. *
  52824. * @type {number}
  52825. * @since 6.2.0
  52826. * @apioption connectors.marker.height
  52827. */
  52828. /**
  52829. * Set the color of the connector markers. By default this is the
  52830. * same as the connector color.
  52831. *
  52832. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  52833. * @since 6.2.0
  52834. * @apioption connectors.marker.color
  52835. */
  52836. /**
  52837. * Set the line/border color of the connector markers. By default
  52838. * this is the same as the marker color.
  52839. *
  52840. * @type {Highcharts.ColorString}
  52841. * @since 6.2.0
  52842. * @apioption connectors.marker.lineColor
  52843. */
  52844. /**
  52845. * Enable markers for the connectors.
  52846. */
  52847. enabled: false,
  52848. /**
  52849. * Horizontal alignment of the markers relative to the points.
  52850. *
  52851. * @type {Highcharts.AlignValue}
  52852. */
  52853. align: 'center',
  52854. /**
  52855. * Vertical alignment of the markers relative to the points.
  52856. *
  52857. * @type {Highcharts.VerticalAlignValue}
  52858. */
  52859. verticalAlign: 'middle',
  52860. /**
  52861. * Whether or not to draw the markers inside the points.
  52862. */
  52863. inside: false,
  52864. /**
  52865. * Set the line/border width of the pathfinder markers.
  52866. */
  52867. lineWidth: 1
  52868. },
  52869. /**
  52870. * Marker options specific to the start markers for this chart's
  52871. * Pathfinder connectors. Overrides the generic marker options.
  52872. *
  52873. * @declare Highcharts.ConnectorsStartMarkerOptions
  52874. * @extends connectors.marker
  52875. * @since 6.2.0
  52876. */
  52877. startMarker: {
  52878. /**
  52879. * Set the symbol of the connector start markers.
  52880. */
  52881. symbol: 'diamond'
  52882. },
  52883. /**
  52884. * Marker options specific to the end markers for this chart's
  52885. * Pathfinder connectors. Overrides the generic marker options.
  52886. *
  52887. * @declare Highcharts.ConnectorsEndMarkerOptions
  52888. * @extends connectors.marker
  52889. * @since 6.2.0
  52890. */
  52891. endMarker: {
  52892. /**
  52893. * Set the symbol of the connector end markers.
  52894. */
  52895. symbol: 'arrow-filled'
  52896. }
  52897. }
  52898. });
  52899. /**
  52900. * Override Pathfinder connector options for a series. Requires Highcharts Gantt
  52901. * to be loaded.
  52902. *
  52903. * @declare Highcharts.SeriesConnectorsOptionsObject
  52904. * @extends connectors
  52905. * @since 6.2.0
  52906. * @excluding enabled, algorithmMargin
  52907. * @product gantt
  52908. * @apioption plotOptions.series.connectors
  52909. */
  52910. /**
  52911. * Connect to a point. This option can be either a string, referring to the ID
  52912. * of another point, or an object, or an array of either. If the option is an
  52913. * array, each element defines a connection.
  52914. *
  52915. * @sample gantt/pathfinder/demo
  52916. * Different connection types
  52917. *
  52918. * @declare Highcharts.XrangePointConnectorsOptionsObject
  52919. * @type {string|Array<string|*>|*}
  52920. * @extends plotOptions.series.connectors
  52921. * @since 6.2.0
  52922. * @excluding enabled
  52923. * @product gantt
  52924. * @requires highcharts-gantt
  52925. * @apioption series.xrange.data.connect
  52926. */
  52927. /**
  52928. * The ID of the point to connect to.
  52929. *
  52930. * @type {string}
  52931. * @since 6.2.0
  52932. * @product gantt
  52933. * @apioption series.xrange.data.connect.to
  52934. */
  52935. /**
  52936. * Get point bounding box using plotX/plotY and shapeArgs. If using
  52937. * graphic.getBBox() directly, the bbox will be affected by animation.
  52938. *
  52939. * @private
  52940. * @function
  52941. *
  52942. * @param {Highcharts.Point} point
  52943. * The point to get BB of.
  52944. *
  52945. * @return {Highcharts.Dictionary<number>|null}
  52946. * Result xMax, xMin, yMax, yMin.
  52947. */
  52948. function getPointBB(point) {
  52949. var shapeArgs = point.shapeArgs,
  52950. bb;
  52951. // Prefer using shapeArgs (columns)
  52952. if (shapeArgs) {
  52953. return {
  52954. xMin: shapeArgs.x || 0,
  52955. xMax: (shapeArgs.x || 0) + (shapeArgs.width || 0),
  52956. yMin: shapeArgs.y || 0,
  52957. yMax: (shapeArgs.y || 0) + (shapeArgs.height || 0)
  52958. };
  52959. }
  52960. // Otherwise use plotX/plotY and bb
  52961. bb = point.graphic && point.graphic.getBBox();
  52962. return bb ? {
  52963. xMin: point.plotX - bb.width / 2,
  52964. xMax: point.plotX + bb.width / 2,
  52965. yMin: point.plotY - bb.height / 2,
  52966. yMax: point.plotY + bb.height / 2
  52967. } : null;
  52968. }
  52969. /**
  52970. * Calculate margin to place around obstacles for the pathfinder in pixels.
  52971. * Returns a minimum of 1 pixel margin.
  52972. *
  52973. * @private
  52974. * @function
  52975. *
  52976. * @param {Array<object>} obstacles
  52977. * Obstacles to calculate margin from.
  52978. *
  52979. * @return {number}
  52980. * The calculated margin in pixels. At least 1.
  52981. */
  52982. function calculateObstacleMargin(obstacles) {
  52983. var len = obstacles.length,
  52984. i = 0,
  52985. j,
  52986. obstacleDistance,
  52987. distances = [],
  52988. // Compute smallest distance between two rectangles
  52989. distance = function (a,
  52990. b,
  52991. bbMargin) {
  52992. // Count the distance even if we are slightly off
  52993. var margin = pick(bbMargin, 10),
  52994. yOverlap = a.yMax + margin > b.yMin - margin &&
  52995. a.yMin - margin < b.yMax + margin,
  52996. xOverlap = a.xMax + margin > b.xMin - margin &&
  52997. a.xMin - margin < b.xMax + margin,
  52998. xDistance = yOverlap ? (a.xMin > b.xMax ? a.xMin - b.xMax : b.xMin - a.xMax) : Infinity,
  52999. yDistance = xOverlap ? (a.yMin > b.yMax ? a.yMin - b.yMax : b.yMin - a.yMax) : Infinity;
  53000. // If the rectangles collide, try recomputing with smaller margin.
  53001. // If they collide anyway, discard the obstacle.
  53002. if (xOverlap && yOverlap) {
  53003. return (margin ?
  53004. distance(a, b, Math.floor(margin / 2)) :
  53005. Infinity);
  53006. }
  53007. return min(xDistance, yDistance);
  53008. };
  53009. // Go over all obstacles and compare them to the others.
  53010. for (; i < len; ++i) {
  53011. // Compare to all obstacles ahead. We will already have compared this
  53012. // obstacle to the ones before.
  53013. for (j = i + 1; j < len; ++j) {
  53014. obstacleDistance = distance(obstacles[i], obstacles[j]);
  53015. // TODO: Magic number 80
  53016. if (obstacleDistance < 80) { // Ignore large distances
  53017. distances.push(obstacleDistance);
  53018. }
  53019. }
  53020. }
  53021. // Ensure we always have at least one value, even in very spaceous charts
  53022. distances.push(80);
  53023. return max(Math.floor(distances.sort(function (a, b) {
  53024. return (a - b);
  53025. })[
  53026. // Discard first 10% of the relevant distances, and then grab
  53027. // the smallest one.
  53028. Math.floor(distances.length / 10)] / 2 - 1 // Divide the distance by 2 and subtract 1.
  53029. ), 1 // 1 is the minimum margin
  53030. );
  53031. }
  53032. /* eslint-disable no-invalid-this, valid-jsdoc */
  53033. /**
  53034. * The Pathfinder class.
  53035. *
  53036. * @private
  53037. * @class
  53038. * @name Highcharts.Pathfinder
  53039. *
  53040. * @param {Highcharts.Chart} chart
  53041. * The chart to operate on.
  53042. */
  53043. var Pathfinder = /** @class */ (function () {
  53044. function Pathfinder(chart) {
  53045. /* *
  53046. *
  53047. * Properties
  53048. *
  53049. * */
  53050. this.chart = void 0;
  53051. this.chartObstacles = void 0;
  53052. this.chartObstacleMetrics = void 0;
  53053. this.connections = void 0;
  53054. this.group = void 0;
  53055. this.lineObstacles = void 0;
  53056. this.init(chart);
  53057. }
  53058. /**
  53059. * @name Highcharts.Pathfinder#algorithms
  53060. * @type {Highcharts.Dictionary<Function>}
  53061. */
  53062. /**
  53063. * Initialize the Pathfinder object.
  53064. *
  53065. * @function Highcharts.Pathfinder#init
  53066. *
  53067. * @param {Highcharts.Chart} chart
  53068. * The chart context.
  53069. */
  53070. Pathfinder.prototype.init = function (chart) {
  53071. // Initialize pathfinder with chart context
  53072. this.chart = chart;
  53073. // Init connection reference list
  53074. this.connections = [];
  53075. // Recalculate paths/obstacles on chart redraw
  53076. addEvent(chart, 'redraw', function () {
  53077. this.pathfinder.update();
  53078. });
  53079. };
  53080. /**
  53081. * Update Pathfinder connections from scratch.
  53082. *
  53083. * @function Highcharts.Pathfinder#update
  53084. *
  53085. * @param {boolean} [deferRender]
  53086. * Whether or not to defer rendering of connections until
  53087. * series.afterAnimate event has fired. Used on first render.
  53088. */
  53089. Pathfinder.prototype.update = function (deferRender) {
  53090. var chart = this.chart,
  53091. pathfinder = this,
  53092. oldConnections = pathfinder.connections;
  53093. // Rebuild pathfinder connections from options
  53094. pathfinder.connections = [];
  53095. chart.series.forEach(function (series) {
  53096. if (series.visible && !series.options.isInternal) {
  53097. series.points.forEach(function (point) {
  53098. var ganttPointOptions = point.options;
  53099. // For Gantt series the connect could be
  53100. // defined as a dependency
  53101. if (ganttPointOptions && ganttPointOptions.dependency) {
  53102. ganttPointOptions.connect = ganttPointOptions.dependency;
  53103. }
  53104. var to,
  53105. connects = (point.options &&
  53106. point.options.connect &&
  53107. splat(point.options.connect));
  53108. if (point.visible && point.isInside !== false && connects) {
  53109. connects.forEach(function (connect) {
  53110. to = chart.get(typeof connect === 'string' ?
  53111. connect : connect.to);
  53112. if (to instanceof Point &&
  53113. to.series.visible &&
  53114. to.visible &&
  53115. to.isInside !== false) {
  53116. // Add new connection
  53117. pathfinder.connections.push(new Connection(point, // from
  53118. to, typeof connect === 'string' ?
  53119. {} :
  53120. connect));
  53121. }
  53122. });
  53123. }
  53124. });
  53125. }
  53126. });
  53127. // Clear connections that should not be updated, and move old info over
  53128. // to new connections.
  53129. for (var j = 0, k = void 0, found = void 0, lenOld = oldConnections.length, lenNew = pathfinder.connections.length; j < lenOld; ++j) {
  53130. found = false;
  53131. for (k = 0; k < lenNew; ++k) {
  53132. if (oldConnections[j].fromPoint ===
  53133. pathfinder.connections[k].fromPoint &&
  53134. oldConnections[j].toPoint ===
  53135. pathfinder.connections[k].toPoint) {
  53136. pathfinder.connections[k].graphics =
  53137. oldConnections[j].graphics;
  53138. found = true;
  53139. break;
  53140. }
  53141. }
  53142. if (!found) {
  53143. oldConnections[j].destroy();
  53144. }
  53145. }
  53146. // Clear obstacles to force recalculation. This must be done on every
  53147. // redraw in case positions have changed. Recalculation is handled in
  53148. // Connection.getPath on demand.
  53149. delete this.chartObstacles;
  53150. delete this.lineObstacles;
  53151. // Draw the pending connections
  53152. pathfinder.renderConnections(deferRender);
  53153. };
  53154. /**
  53155. * Draw the chart's connecting paths.
  53156. *
  53157. * @function Highcharts.Pathfinder#renderConnections
  53158. *
  53159. * @param {boolean} [deferRender]
  53160. * Whether or not to defer render until series animation is finished.
  53161. * Used on first render.
  53162. */
  53163. Pathfinder.prototype.renderConnections = function (deferRender) {
  53164. if (deferRender) {
  53165. // Render after series are done animating
  53166. this.chart.series.forEach(function (series) {
  53167. var render = function () {
  53168. // Find pathfinder connections belonging to this series
  53169. // that haven't rendered, and render them now.
  53170. var pathfinder = series.chart.pathfinder,
  53171. conns = pathfinder && pathfinder.connections || [];
  53172. conns.forEach(function (connection) {
  53173. if (connection.fromPoint &&
  53174. connection.fromPoint.series === series) {
  53175. connection.render();
  53176. }
  53177. });
  53178. if (series.pathfinderRemoveRenderEvent) {
  53179. series.pathfinderRemoveRenderEvent();
  53180. delete series.pathfinderRemoveRenderEvent;
  53181. }
  53182. };
  53183. if (series.options.animation === false) {
  53184. render();
  53185. }
  53186. else {
  53187. series.pathfinderRemoveRenderEvent = addEvent(series, 'afterAnimate', render);
  53188. }
  53189. });
  53190. }
  53191. else {
  53192. // Go through connections and render them
  53193. this.connections.forEach(function (connection) {
  53194. connection.render();
  53195. });
  53196. }
  53197. };
  53198. /**
  53199. * Get obstacles for the points in the chart. Does not include connecting
  53200. * lines from Pathfinder. Applies algorithmMargin to the obstacles.
  53201. *
  53202. * @function Highcharts.Pathfinder#getChartObstacles
  53203. *
  53204. * @param {object} options
  53205. * Options for the calculation. Currenlty only
  53206. * options.algorithmMargin.
  53207. *
  53208. * @return {Array<object>}
  53209. * An array of calculated obstacles. Each obstacle is defined as an
  53210. * object with xMin, xMax, yMin and yMax properties.
  53211. */
  53212. Pathfinder.prototype.getChartObstacles = function (options) {
  53213. var obstacles = [],
  53214. series = this.chart.series,
  53215. margin = pick(options.algorithmMargin, 0),
  53216. calculatedMargin;
  53217. for (var i = 0, sLen = series.length; i < sLen; ++i) {
  53218. if (series[i].visible && !series[i].options.isInternal) {
  53219. for (var j = 0, pLen = series[i].points.length, bb = void 0, point = void 0; j < pLen; ++j) {
  53220. point = series[i].points[j];
  53221. if (point.visible) {
  53222. bb = getPointBB(point);
  53223. if (bb) {
  53224. obstacles.push({
  53225. xMin: bb.xMin - margin,
  53226. xMax: bb.xMax + margin,
  53227. yMin: bb.yMin - margin,
  53228. yMax: bb.yMax + margin
  53229. });
  53230. }
  53231. }
  53232. }
  53233. }
  53234. }
  53235. // Sort obstacles by xMin for optimization
  53236. obstacles = obstacles.sort(function (a, b) {
  53237. return a.xMin - b.xMin;
  53238. });
  53239. // Add auto-calculated margin if the option is not defined
  53240. if (!defined(options.algorithmMargin)) {
  53241. calculatedMargin =
  53242. options.algorithmMargin =
  53243. calculateObstacleMargin(obstacles);
  53244. obstacles.forEach(function (obstacle) {
  53245. obstacle.xMin -= calculatedMargin;
  53246. obstacle.xMax += calculatedMargin;
  53247. obstacle.yMin -= calculatedMargin;
  53248. obstacle.yMax += calculatedMargin;
  53249. });
  53250. }
  53251. return obstacles;
  53252. };
  53253. /**
  53254. * Utility function to get metrics for obstacles:
  53255. * - Widest obstacle width
  53256. * - Tallest obstacle height
  53257. *
  53258. * @function Highcharts.Pathfinder#getObstacleMetrics
  53259. *
  53260. * @param {Array<object>} obstacles
  53261. * An array of obstacles to inspect.
  53262. *
  53263. * @return {object}
  53264. * The calculated metrics, as an object with maxHeight and maxWidth
  53265. * properties.
  53266. */
  53267. Pathfinder.prototype.getObstacleMetrics = function (obstacles) {
  53268. var maxWidth = 0,
  53269. maxHeight = 0,
  53270. width,
  53271. height,
  53272. i = obstacles.length;
  53273. while (i--) {
  53274. width = obstacles[i].xMax - obstacles[i].xMin;
  53275. height = obstacles[i].yMax - obstacles[i].yMin;
  53276. if (maxWidth < width) {
  53277. maxWidth = width;
  53278. }
  53279. if (maxHeight < height) {
  53280. maxHeight = height;
  53281. }
  53282. }
  53283. return {
  53284. maxHeight: maxHeight,
  53285. maxWidth: maxWidth
  53286. };
  53287. };
  53288. /**
  53289. * Utility to get which direction to start the pathfinding algorithm
  53290. * (X vs Y), calculated from a set of marker options.
  53291. *
  53292. * @function Highcharts.Pathfinder#getAlgorithmStartDirection
  53293. *
  53294. * @param {Highcharts.ConnectorsMarkerOptions} markerOptions
  53295. * Marker options to calculate from.
  53296. *
  53297. * @return {boolean}
  53298. * Returns true for X, false for Y, and undefined for autocalculate.
  53299. */
  53300. Pathfinder.prototype.getAlgorithmStartDirection = function (markerOptions) {
  53301. var xCenter = markerOptions.align !== 'left' &&
  53302. markerOptions.align !== 'right', yCenter = markerOptions.verticalAlign !== 'top' &&
  53303. markerOptions.verticalAlign !== 'bottom', undef;
  53304. return xCenter ?
  53305. (yCenter ? undef : false) : // x is centered
  53306. (yCenter ? true : undef); // x is off-center
  53307. };
  53308. return Pathfinder;
  53309. }());
  53310. Pathfinder.prototype.algorithms = pathfinderAlgorithms;
  53311. // Add to Highcharts namespace
  53312. H.Pathfinder = Pathfinder;
  53313. // Add pathfinding capabilities to Points
  53314. extend(Point.prototype, /** @lends Point.prototype */ {
  53315. /**
  53316. * Get coordinates of anchor point for pathfinder connection.
  53317. *
  53318. * @private
  53319. * @function Highcharts.Point#getPathfinderAnchorPoint
  53320. *
  53321. * @param {Highcharts.ConnectorsMarkerOptions} markerOptions
  53322. * Connection options for position on point.
  53323. *
  53324. * @return {Highcharts.PositionObject}
  53325. * An object with x/y properties for the position. Coordinates are
  53326. * in plot values, not relative to point.
  53327. */
  53328. getPathfinderAnchorPoint: function (markerOptions) {
  53329. var bb = getPointBB(this),
  53330. x,
  53331. y;
  53332. switch (markerOptions.align) { // eslint-disable-line default-case
  53333. case 'right':
  53334. x = 'xMax';
  53335. break;
  53336. case 'left':
  53337. x = 'xMin';
  53338. }
  53339. switch (markerOptions.verticalAlign) { // eslint-disable-line default-case
  53340. case 'top':
  53341. y = 'yMin';
  53342. break;
  53343. case 'bottom':
  53344. y = 'yMax';
  53345. }
  53346. return {
  53347. x: x ? bb[x] : (bb.xMin + bb.xMax) / 2,
  53348. y: y ? bb[y] : (bb.yMin + bb.yMax) / 2
  53349. };
  53350. },
  53351. /**
  53352. * Utility to get the angle from one point to another.
  53353. *
  53354. * @private
  53355. * @function Highcharts.Point#getRadiansToVector
  53356. *
  53357. * @param {Highcharts.PositionObject} v1
  53358. * The first vector, as an object with x/y properties.
  53359. *
  53360. * @param {Highcharts.PositionObject} v2
  53361. * The second vector, as an object with x/y properties.
  53362. *
  53363. * @return {number}
  53364. * The angle in degrees
  53365. */
  53366. getRadiansToVector: function (v1, v2) {
  53367. var box;
  53368. if (!defined(v2)) {
  53369. box = getPointBB(this);
  53370. if (box) {
  53371. v2 = {
  53372. x: (box.xMin + box.xMax) / 2,
  53373. y: (box.yMin + box.yMax) / 2
  53374. };
  53375. }
  53376. }
  53377. return Math.atan2(v2.y - v1.y, v1.x - v2.x);
  53378. },
  53379. /**
  53380. * Utility to get the position of the marker, based on the path angle and
  53381. * the marker's radius.
  53382. *
  53383. * @private
  53384. * @function Highcharts.Point#getMarkerVector
  53385. *
  53386. * @param {number} radians
  53387. * The angle in radians from the point center to another vector.
  53388. *
  53389. * @param {number} markerRadius
  53390. * The radius of the marker, to calculate the additional distance to
  53391. * the center of the marker.
  53392. *
  53393. * @param {object} anchor
  53394. * The anchor point of the path and marker as an object with x/y
  53395. * properties.
  53396. *
  53397. * @return {object}
  53398. * The marker vector as an object with x/y properties.
  53399. */
  53400. getMarkerVector: function (radians, markerRadius, anchor) {
  53401. var twoPI = Math.PI * 2.0,
  53402. theta = radians,
  53403. bb = getPointBB(this),
  53404. rectWidth = bb.xMax - bb.xMin,
  53405. rectHeight = bb.yMax - bb.yMin,
  53406. rAtan = Math.atan2(rectHeight,
  53407. rectWidth),
  53408. tanTheta = 1,
  53409. leftOrRightRegion = false,
  53410. rectHalfWidth = rectWidth / 2.0,
  53411. rectHalfHeight = rectHeight / 2.0,
  53412. rectHorizontalCenter = bb.xMin + rectHalfWidth,
  53413. rectVerticalCenter = bb.yMin + rectHalfHeight,
  53414. edgePoint = {
  53415. x: rectHorizontalCenter,
  53416. y: rectVerticalCenter
  53417. },
  53418. xFactor = 1,
  53419. yFactor = 1;
  53420. while (theta < -Math.PI) {
  53421. theta += twoPI;
  53422. }
  53423. while (theta > Math.PI) {
  53424. theta -= twoPI;
  53425. }
  53426. tanTheta = Math.tan(theta);
  53427. if ((theta > -rAtan) && (theta <= rAtan)) {
  53428. // Right side
  53429. yFactor = -1;
  53430. leftOrRightRegion = true;
  53431. }
  53432. else if (theta > rAtan && theta <= (Math.PI - rAtan)) {
  53433. // Top side
  53434. yFactor = -1;
  53435. }
  53436. else if (theta > (Math.PI - rAtan) || theta <= -(Math.PI - rAtan)) {
  53437. // Left side
  53438. xFactor = -1;
  53439. leftOrRightRegion = true;
  53440. }
  53441. else {
  53442. // Bottom side
  53443. xFactor = -1;
  53444. }
  53445. // Correct the edgePoint according to the placement of the marker
  53446. if (leftOrRightRegion) {
  53447. edgePoint.x += xFactor * (rectHalfWidth);
  53448. edgePoint.y += yFactor * (rectHalfWidth) * tanTheta;
  53449. }
  53450. else {
  53451. edgePoint.x += xFactor * (rectHeight / (2.0 * tanTheta));
  53452. edgePoint.y += yFactor * (rectHalfHeight);
  53453. }
  53454. if (anchor.x !== rectHorizontalCenter) {
  53455. edgePoint.x = anchor.x;
  53456. }
  53457. if (anchor.y !== rectVerticalCenter) {
  53458. edgePoint.y = anchor.y;
  53459. }
  53460. return {
  53461. x: edgePoint.x + (markerRadius * Math.cos(theta)),
  53462. y: edgePoint.y - (markerRadius * Math.sin(theta))
  53463. };
  53464. }
  53465. });
  53466. /**
  53467. * Warn if using legacy options. Copy the options over. Note that this will
  53468. * still break if using the legacy options in chart.update, addSeries etc.
  53469. * @private
  53470. */
  53471. function warnLegacy(chart) {
  53472. if (chart.options.pathfinder ||
  53473. chart.series.reduce(function (acc, series) {
  53474. if (series.options) {
  53475. merge(true, (series.options.connectors = series.options.connectors ||
  53476. {}), series.options.pathfinder);
  53477. }
  53478. return acc || series.options && series.options.pathfinder;
  53479. }, false)) {
  53480. merge(true, (chart.options.connectors = chart.options.connectors || {}), chart.options.pathfinder);
  53481. error('WARNING: Pathfinder options have been renamed. ' +
  53482. 'Use "chart.connectors" or "series.connectors" instead.');
  53483. }
  53484. }
  53485. // Initialize Pathfinder for charts
  53486. Chart.prototype.callbacks.push(function (chart) {
  53487. var options = chart.options;
  53488. if (options.connectors.enabled !== false) {
  53489. warnLegacy(chart);
  53490. this.pathfinder = new Pathfinder(this);
  53491. this.pathfinder.update(true); // First draw, defer render
  53492. }
  53493. });
  53494. return Pathfinder;
  53495. });
  53496. _registerModule(_modules, 'Series/Gantt/GanttSeries.js', [_modules['Series/Gantt/GanttPoint.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (GanttPoint, SeriesRegistry, U) {
  53497. /* *
  53498. *
  53499. * (c) 2016-2021 Highsoft AS
  53500. *
  53501. * Author: Lars A. V. Cabrera
  53502. *
  53503. * License: www.highcharts.com/license
  53504. *
  53505. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  53506. *
  53507. * */
  53508. var __extends = (this && this.__extends) || (function () {
  53509. var extendStatics = function (d,
  53510. b) {
  53511. extendStatics = Object.setPrototypeOf ||
  53512. ({ __proto__: [] } instanceof Array && function (d,
  53513. b) { d.__proto__ = b; }) ||
  53514. function (d,
  53515. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  53516. return extendStatics(d, b);
  53517. };
  53518. return function (d, b) {
  53519. extendStatics(d, b);
  53520. function __() { this.constructor = d; }
  53521. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  53522. };
  53523. })();
  53524. var Series = SeriesRegistry.series,
  53525. XRangeSeries = SeriesRegistry.seriesTypes.xrange;
  53526. var extend = U.extend,
  53527. isNumber = U.isNumber,
  53528. merge = U.merge,
  53529. splat = U.splat;
  53530. /* *
  53531. *
  53532. * Class
  53533. *
  53534. * */
  53535. /**
  53536. * @private
  53537. * @class
  53538. * @name Highcharts.seriesTypes.gantt
  53539. *
  53540. * @augments Highcharts.Series
  53541. */
  53542. var GanttSeries = /** @class */ (function (_super) {
  53543. __extends(GanttSeries, _super);
  53544. function GanttSeries() {
  53545. var _this = _super !== null && _super.apply(this,
  53546. arguments) || this;
  53547. /* *
  53548. *
  53549. * Properties
  53550. *
  53551. * */
  53552. _this.data = void 0;
  53553. _this.options = void 0;
  53554. _this.points = void 0;
  53555. return _this;
  53556. /* eslint-enable valid-jsdoc */
  53557. }
  53558. /* *
  53559. *
  53560. * Functions
  53561. *
  53562. * */
  53563. /* eslint-disable valid-jsdoc */
  53564. /**
  53565. * Draws a single point in the series.
  53566. *
  53567. * This override draws the point as a diamond if point.options.milestone
  53568. * is true, and uses the original drawPoint() if it is false or not set.
  53569. *
  53570. * @requires highcharts-gantt
  53571. *
  53572. * @private
  53573. * @function Highcharts.seriesTypes.gantt#drawPoint
  53574. *
  53575. * @param {Highcharts.Point} point
  53576. * An instance of Point in the series
  53577. *
  53578. * @param {"animate"|"attr"} verb
  53579. * 'animate' (animates changes) or 'attr' (sets options)
  53580. */
  53581. GanttSeries.prototype.drawPoint = function (point, verb) {
  53582. var series = this,
  53583. seriesOpts = series.options,
  53584. renderer = series.chart.renderer,
  53585. shapeArgs = point.shapeArgs,
  53586. plotY = point.plotY,
  53587. graphic = point.graphic,
  53588. state = point.selected && 'select',
  53589. cutOff = seriesOpts.stacking && !seriesOpts.borderRadius,
  53590. diamondShape;
  53591. if (point.options.milestone) {
  53592. if (isNumber(plotY) && point.y !== null && point.visible !== false) {
  53593. diamondShape = renderer.symbols.diamond(shapeArgs.x || 0, shapeArgs.y || 0, shapeArgs.width || 0, shapeArgs.height || 0);
  53594. if (graphic) {
  53595. graphic[verb]({
  53596. d: diamondShape
  53597. });
  53598. }
  53599. else {
  53600. point.graphic = graphic = renderer.path(diamondShape)
  53601. .addClass(point.getClassName(), true)
  53602. .add(point.group || series.group);
  53603. }
  53604. // Presentational
  53605. if (!series.chart.styledMode) {
  53606. point.graphic
  53607. .attr(series.pointAttribs(point, state))
  53608. .shadow(seriesOpts.shadow, null, cutOff);
  53609. }
  53610. }
  53611. else if (graphic) {
  53612. point.graphic = graphic.destroy(); // #1269
  53613. }
  53614. }
  53615. else {
  53616. XRangeSeries.prototype.drawPoint.call(series, point, verb);
  53617. }
  53618. };
  53619. /**
  53620. * Handle milestones, as they have no x2.
  53621. * @private
  53622. */
  53623. GanttSeries.prototype.translatePoint = function (point) {
  53624. var series = this,
  53625. shapeArgs,
  53626. size;
  53627. XRangeSeries.prototype.translatePoint.call(series, point);
  53628. if (point.options.milestone) {
  53629. shapeArgs = point.shapeArgs;
  53630. size = shapeArgs.height || 0;
  53631. point.shapeArgs = {
  53632. x: (shapeArgs.x || 0) - (size / 2),
  53633. y: shapeArgs.y,
  53634. width: size,
  53635. height: size
  53636. };
  53637. }
  53638. };
  53639. /**
  53640. * A `gantt` series. If the [type](#series.gantt.type) option is not specified,
  53641. * it is inherited from [chart.type](#chart.type).
  53642. *
  53643. * @extends plotOptions.xrange
  53644. * @product gantt
  53645. * @requires highcharts-gantt
  53646. * @optionparent plotOptions.gantt
  53647. */
  53648. GanttSeries.defaultOptions = merge(XRangeSeries.defaultOptions, {
  53649. // options - default options merged with parent
  53650. grouping: false,
  53651. dataLabels: {
  53652. enabled: true
  53653. },
  53654. tooltip: {
  53655. headerFormat: '<span style="font-size: 10px">{series.name}</span><br/>',
  53656. pointFormat: null,
  53657. pointFormatter: function () {
  53658. var point = this,
  53659. series = point.series,
  53660. tooltip = series.chart.tooltip,
  53661. xAxis = series.xAxis,
  53662. formats = series.tooltipOptions.dateTimeLabelFormats,
  53663. startOfWeek = xAxis.options.startOfWeek,
  53664. ttOptions = series.tooltipOptions,
  53665. format = ttOptions.xDateFormat,
  53666. start,
  53667. end,
  53668. milestone = point.options.milestone,
  53669. retVal = '<b>' + (point.name || point.yCategory) + '</b>';
  53670. if (ttOptions.pointFormat) {
  53671. return point.tooltipFormatter(ttOptions.pointFormat);
  53672. }
  53673. if (!format) {
  53674. format = splat(tooltip.getDateFormat(xAxis.closestPointRange, point.start, startOfWeek, formats))[0];
  53675. }
  53676. start = series.chart.time.dateFormat(format, point.start);
  53677. end = series.chart.time.dateFormat(format, point.end);
  53678. retVal += '<br/>';
  53679. if (!milestone) {
  53680. retVal += 'Start: ' + start + '<br/>';
  53681. retVal += 'End: ' + end + '<br/>';
  53682. }
  53683. else {
  53684. retVal += start + '<br/>';
  53685. }
  53686. return retVal;
  53687. }
  53688. },
  53689. connectors: {
  53690. type: 'simpleConnect',
  53691. /**
  53692. * @declare Highcharts.ConnectorsAnimationOptionsObject
  53693. */
  53694. animation: {
  53695. reversed: true // Dependencies go from child to parent
  53696. },
  53697. startMarker: {
  53698. enabled: true,
  53699. symbol: 'arrow-filled',
  53700. radius: 4,
  53701. fill: '#fa0',
  53702. align: 'left'
  53703. },
  53704. endMarker: {
  53705. enabled: false,
  53706. align: 'right'
  53707. }
  53708. }
  53709. });
  53710. return GanttSeries;
  53711. }(XRangeSeries));
  53712. extend(GanttSeries.prototype, {
  53713. // Keyboard navigation, don't use nearest vertical mode
  53714. keyboardMoveVertical: false,
  53715. pointArrayMap: ['start', 'end', 'y'],
  53716. pointClass: GanttPoint,
  53717. setData: Series.prototype.setData
  53718. });
  53719. SeriesRegistry.registerSeriesType('gantt', GanttSeries);
  53720. /* *
  53721. *
  53722. * Default Export
  53723. *
  53724. * */
  53725. /* *
  53726. *
  53727. * API Options
  53728. *
  53729. * */
  53730. /**
  53731. * A `gantt` series.
  53732. *
  53733. * @extends series,plotOptions.gantt
  53734. * @excluding boostThreshold, connectors, dashStyle, findNearestPointBy,
  53735. * getExtremesFromAll, marker, negativeColor, pointInterval,
  53736. * pointIntervalUnit, pointPlacement, pointStart
  53737. * @product gantt
  53738. * @requires highcharts-gantt
  53739. * @apioption series.gantt
  53740. */
  53741. /**
  53742. * Data for a Gantt series.
  53743. *
  53744. * @declare Highcharts.GanttPointOptionsObject
  53745. * @type {Array<*>}
  53746. * @extends series.xrange.data
  53747. * @excluding className, connect, dataLabels, events,
  53748. * partialFill, selected, x, x2
  53749. * @product gantt
  53750. * @apioption series.gantt.data
  53751. */
  53752. /**
  53753. * Whether the grid node belonging to this point should start as collapsed. Used
  53754. * in axes of type treegrid.
  53755. *
  53756. * @sample {gantt} gantt/treegrid-axis/collapsed/
  53757. * Start as collapsed
  53758. *
  53759. * @type {boolean}
  53760. * @default false
  53761. * @product gantt
  53762. * @apioption series.gantt.data.collapsed
  53763. */
  53764. /**
  53765. * The start time of a task.
  53766. *
  53767. * @type {number}
  53768. * @product gantt
  53769. * @apioption series.gantt.data.start
  53770. */
  53771. /**
  53772. * The end time of a task.
  53773. *
  53774. * @type {number}
  53775. * @product gantt
  53776. * @apioption series.gantt.data.end
  53777. */
  53778. /**
  53779. * The Y value of a task.
  53780. *
  53781. * @type {number}
  53782. * @product gantt
  53783. * @apioption series.gantt.data.y
  53784. */
  53785. /**
  53786. * The name of a task. If a `treegrid` y-axis is used (default in Gantt charts),
  53787. * this will be picked up automatically, and used to calculate the y-value.
  53788. *
  53789. * @type {string}
  53790. * @product gantt
  53791. * @apioption series.gantt.data.name
  53792. */
  53793. /**
  53794. * Progress indicator, how much of the task completed. If it is a number, the
  53795. * `fill` will be applied automatically.
  53796. *
  53797. * @sample {gantt} gantt/demo/progress-indicator
  53798. * Progress indicator
  53799. *
  53800. * @type {number|*}
  53801. * @extends series.xrange.data.partialFill
  53802. * @product gantt
  53803. * @apioption series.gantt.data.completed
  53804. */
  53805. /**
  53806. * The amount of the progress indicator, ranging from 0 (not started) to 1
  53807. * (finished).
  53808. *
  53809. * @type {number}
  53810. * @default 0
  53811. * @apioption series.gantt.data.completed.amount
  53812. */
  53813. /**
  53814. * The fill of the progress indicator. Defaults to a darkened variety of the
  53815. * main color.
  53816. *
  53817. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  53818. * @apioption series.gantt.data.completed.fill
  53819. */
  53820. /**
  53821. * The ID of the point (task) that this point depends on in Gantt charts.
  53822. * Aliases [connect](series.xrange.data.connect). Can also be an object,
  53823. * specifying further connecting [options](series.gantt.connectors) between the
  53824. * points. Multiple connections can be specified by providing an array.
  53825. *
  53826. * @sample gantt/demo/project-management
  53827. * Dependencies
  53828. * @sample gantt/pathfinder/demo
  53829. * Different connection types
  53830. *
  53831. * @type {string|Array<string|*>|*}
  53832. * @extends series.xrange.data.connect
  53833. * @since 6.2.0
  53834. * @product gantt
  53835. * @apioption series.gantt.data.dependency
  53836. */
  53837. /**
  53838. * Whether this point is a milestone. If so, only the `start` option is handled,
  53839. * while `end` is ignored.
  53840. *
  53841. * @sample gantt/gantt/milestones
  53842. * Milestones
  53843. *
  53844. * @type {boolean}
  53845. * @since 6.2.0
  53846. * @product gantt
  53847. * @apioption series.gantt.data.milestone
  53848. */
  53849. /**
  53850. * The ID of the parent point (task) of this point in Gantt charts.
  53851. *
  53852. * @sample gantt/demo/subtasks
  53853. * Gantt chart with subtasks
  53854. *
  53855. * @type {string}
  53856. * @since 6.2.0
  53857. * @product gantt
  53858. * @apioption series.gantt.data.parent
  53859. */
  53860. /**
  53861. * @excluding afterAnimate
  53862. * @apioption series.gantt.events
  53863. */
  53864. ''; // adds doclets above to the transpiled file
  53865. return GanttSeries;
  53866. });
  53867. _registerModule(_modules, 'Core/Chart/GanttChart.js', [_modules['Core/Chart/Chart.js'], _modules['Core/Options.js'], _modules['Core/Utilities.js']], function (Chart, O, U) {
  53868. /* *
  53869. *
  53870. * (c) 2016-2021 Highsoft AS
  53871. *
  53872. * Author: Lars A. V. Cabrera
  53873. *
  53874. * License: www.highcharts.com/license
  53875. *
  53876. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  53877. *
  53878. * */
  53879. var __extends = (this && this.__extends) || (function () {
  53880. var extendStatics = function (d,
  53881. b) {
  53882. extendStatics = Object.setPrototypeOf ||
  53883. ({ __proto__: [] } instanceof Array && function (d,
  53884. b) { d.__proto__ = b; }) ||
  53885. function (d,
  53886. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  53887. return extendStatics(d, b);
  53888. };
  53889. return function (d, b) {
  53890. extendStatics(d, b);
  53891. function __() { this.constructor = d; }
  53892. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  53893. };
  53894. })();
  53895. var getOptions = O.getOptions;
  53896. var isArray = U.isArray,
  53897. merge = U.merge,
  53898. splat = U.splat;
  53899. /**
  53900. * Gantt-optimized chart. Use {@link Highcharts.Chart|Chart} for common charts.
  53901. *
  53902. * @requires modules/gantt
  53903. *
  53904. * @class
  53905. * @name Highcharts.GanttChart
  53906. * @extends Highcharts.Chart
  53907. */
  53908. var GanttChart = /** @class */ (function (_super) {
  53909. __extends(GanttChart, _super);
  53910. function GanttChart() {
  53911. return _super !== null && _super.apply(this, arguments) || this;
  53912. }
  53913. /**
  53914. * Initializes the chart. The constructor's arguments are passed on
  53915. * directly.
  53916. *
  53917. * @function Highcharts.GanttChart#init
  53918. *
  53919. * @param {Highcharts.Options} userOptions
  53920. * Custom options.
  53921. *
  53922. * @param {Function} [callback]
  53923. * Function to run when the chart has loaded and and all external
  53924. * images are loaded.
  53925. *
  53926. * @return {void}
  53927. *
  53928. * @fires Highcharts.GanttChart#event:init
  53929. * @fires Highcharts.GanttChart#event:afterInit
  53930. */
  53931. GanttChart.prototype.init = function (userOptions, callback) {
  53932. var seriesOptions = userOptions.series,
  53933. defaultOptions = getOptions(),
  53934. defaultLinkedTo;
  53935. // If user hasn't defined axes as array, make it into an array and add a
  53936. // second axis by default.
  53937. if (!isArray(userOptions.xAxis)) {
  53938. userOptions.xAxis = [userOptions.xAxis || {}, {}];
  53939. }
  53940. // apply X axis options to both single and multi x axes
  53941. userOptions.xAxis = userOptions.xAxis.map(function (xAxisOptions, i) {
  53942. if (i === 1) { // Second xAxis
  53943. defaultLinkedTo = 0;
  53944. }
  53945. return merge(defaultOptions.xAxis, {
  53946. grid: {
  53947. enabled: true
  53948. },
  53949. opposite: true,
  53950. linkedTo: defaultLinkedTo
  53951. }, xAxisOptions, // user options
  53952. {
  53953. type: 'datetime'
  53954. });
  53955. });
  53956. // apply Y axis options to both single and multi y axes
  53957. userOptions.yAxis = (splat(userOptions.yAxis || {})).map(function (yAxisOptions) {
  53958. return merge(defaultOptions.yAxis, // #3802
  53959. {
  53960. grid: {
  53961. enabled: true
  53962. },
  53963. staticScale: 50,
  53964. reversed: true,
  53965. // Set default type treegrid, but only if 'categories' is
  53966. // undefined
  53967. type: yAxisOptions.categories ? yAxisOptions.type : 'treegrid'
  53968. }, yAxisOptions // user options
  53969. );
  53970. });
  53971. delete userOptions.series;
  53972. userOptions = merge(true, {
  53973. chart: {
  53974. type: 'gantt'
  53975. },
  53976. title: {
  53977. text: null
  53978. },
  53979. legend: {
  53980. enabled: false
  53981. },
  53982. navigator: {
  53983. series: { type: 'gantt' },
  53984. // Bars were clipped, #14060.
  53985. yAxis: {
  53986. type: 'category'
  53987. }
  53988. }
  53989. }, userOptions, // user's options
  53990. // forced options
  53991. {
  53992. isGantt: true
  53993. });
  53994. userOptions.series = seriesOptions;
  53995. _super.prototype.init.call(this, userOptions, callback);
  53996. };
  53997. return GanttChart;
  53998. }(Chart));
  53999. /* eslint-disable valid-jsdoc */
  54000. (function (GanttChart) {
  54001. /**
  54002. * The factory function for creating new gantt charts. Creates a new {@link
  54003. * Highcharts.GanttChart|GanttChart} object with different default options
  54004. * than the basic Chart.
  54005. *
  54006. * @example
  54007. * // Render a chart in to div#container
  54008. * let chart = Highcharts.ganttChart('container', {
  54009. * title: {
  54010. * text: 'My chart'
  54011. * },
  54012. * series: [{
  54013. * data: ...
  54014. * }]
  54015. * });
  54016. *
  54017. * @function Highcharts.ganttChart
  54018. *
  54019. * @param {string|Highcharts.HTMLDOMElement} renderTo
  54020. * The DOM element to render to, or its id.
  54021. *
  54022. * @param {Highcharts.Options} options
  54023. * The chart options structure.
  54024. *
  54025. * @param {Highcharts.ChartCallbackFunction} [callback]
  54026. * Function to run when the chart has loaded and and all external
  54027. * images are loaded. Defining a
  54028. * [chart.events.load](https://api.highcharts.com/highcharts/chart.events.load)
  54029. * handler is equivalent.
  54030. *
  54031. * @return {Highcharts.GanttChart}
  54032. * Returns the Chart object.
  54033. */
  54034. function ganttChart(a, b, c) {
  54035. return new GanttChart(a, b, c);
  54036. }
  54037. GanttChart.ganttChart = ganttChart;
  54038. })(GanttChart || (GanttChart = {}));
  54039. return GanttChart;
  54040. });
  54041. _registerModule(_modules, 'Core/Axis/ScrollbarAxis.js', [_modules['Core/Utilities.js']], function (U) {
  54042. /* *
  54043. *
  54044. * (c) 2010-2021 Torstein Honsi
  54045. *
  54046. * License: www.highcharts.com/license
  54047. *
  54048. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  54049. *
  54050. * */
  54051. var addEvent = U.addEvent,
  54052. defined = U.defined,
  54053. pick = U.pick;
  54054. /* eslint-disable no-invalid-this, valid-jsdoc */
  54055. /**
  54056. * Creates scrollbars if enabled.
  54057. *
  54058. * @private
  54059. */
  54060. var ScrollbarAxis = /** @class */ (function () {
  54061. function ScrollbarAxis() {
  54062. }
  54063. /**
  54064. * Attaches to axis events to create scrollbars if enabled.
  54065. *
  54066. * @private
  54067. *
  54068. * @param AxisClass
  54069. * Axis class to extend.
  54070. *
  54071. * @param ScrollbarClass
  54072. * Scrollbar class to use.
  54073. */
  54074. ScrollbarAxis.compose = function (AxisClass, ScrollbarClass) {
  54075. var getExtremes = function (axis) {
  54076. var axisMin = pick(axis.options && axis.options.min, axis.min);
  54077. var axisMax = pick(axis.options && axis.options.max,
  54078. axis.max);
  54079. return {
  54080. axisMin: axisMin,
  54081. axisMax: axisMax,
  54082. scrollMin: defined(axis.dataMin) ?
  54083. Math.min(axisMin, axis.min, axis.dataMin, pick(axis.threshold, Infinity)) : axisMin,
  54084. scrollMax: defined(axis.dataMax) ?
  54085. Math.max(axisMax, axis.max, axis.dataMax, pick(axis.threshold, -Infinity)) : axisMax
  54086. };
  54087. };
  54088. // Wrap axis initialization and create scrollbar if enabled:
  54089. addEvent(AxisClass, 'afterInit', function () {
  54090. var axis = this;
  54091. if (axis.options &&
  54092. axis.options.scrollbar &&
  54093. axis.options.scrollbar.enabled) {
  54094. // Predefined options:
  54095. axis.options.scrollbar.vertical = !axis.horiz;
  54096. axis.options.startOnTick = axis.options.endOnTick = false;
  54097. axis.scrollbar = new ScrollbarClass(axis.chart.renderer, axis.options.scrollbar, axis.chart);
  54098. addEvent(axis.scrollbar, 'changed', function (e) {
  54099. var _a = getExtremes(axis),
  54100. axisMin = _a.axisMin,
  54101. axisMax = _a.axisMax,
  54102. unitedMin = _a.scrollMin,
  54103. unitedMax = _a.scrollMax,
  54104. range = unitedMax - unitedMin,
  54105. to,
  54106. from;
  54107. // #12834, scroll when show/hide series, wrong extremes
  54108. if (!defined(axisMin) || !defined(axisMax)) {
  54109. return;
  54110. }
  54111. if ((axis.horiz && !axis.reversed) ||
  54112. (!axis.horiz && axis.reversed)) {
  54113. to = unitedMin + range * this.to;
  54114. from = unitedMin + range * this.from;
  54115. }
  54116. else {
  54117. // y-values in browser are reversed, but this also
  54118. // applies for reversed horizontal axis:
  54119. to = unitedMin + range * (1 - this.from);
  54120. from = unitedMin + range * (1 - this.to);
  54121. }
  54122. if (this.shouldUpdateExtremes(e.DOMType)) {
  54123. axis.setExtremes(from, to, true, e.DOMType !== 'mousemove' && e.DOMType !== 'touchmove', e);
  54124. }
  54125. else {
  54126. // When live redraw is disabled, don't change extremes
  54127. // Only change the position of the scollbar thumb
  54128. this.setRange(this.from, this.to);
  54129. }
  54130. });
  54131. }
  54132. });
  54133. // Wrap rendering axis, and update scrollbar if one is created:
  54134. addEvent(AxisClass, 'afterRender', function () {
  54135. var axis = this,
  54136. _a = getExtremes(axis),
  54137. scrollMin = _a.scrollMin,
  54138. scrollMax = _a.scrollMax,
  54139. scrollbar = axis.scrollbar,
  54140. offset = axis.axisTitleMargin + (axis.titleOffset || 0),
  54141. scrollbarsOffsets = axis.chart.scrollbarsOffsets,
  54142. axisMargin = axis.options.margin || 0,
  54143. offsetsIndex,
  54144. from,
  54145. to;
  54146. if (scrollbar) {
  54147. if (axis.horiz) {
  54148. // Reserve space for labels/title
  54149. if (!axis.opposite) {
  54150. scrollbarsOffsets[1] += offset;
  54151. }
  54152. scrollbar.position(axis.left, axis.top + axis.height + 2 + scrollbarsOffsets[1] -
  54153. (axis.opposite ? axisMargin : 0), axis.width, axis.height);
  54154. // Next scrollbar should reserve space for margin (if set)
  54155. if (!axis.opposite) {
  54156. scrollbarsOffsets[1] += axisMargin;
  54157. }
  54158. offsetsIndex = 1;
  54159. }
  54160. else {
  54161. // Reserve space for labels/title
  54162. if (axis.opposite) {
  54163. scrollbarsOffsets[0] += offset;
  54164. }
  54165. scrollbar.position(axis.left + axis.width + 2 + scrollbarsOffsets[0] -
  54166. (axis.opposite ? 0 : axisMargin), axis.top, axis.width, axis.height);
  54167. // Next scrollbar should reserve space for margin (if set)
  54168. if (axis.opposite) {
  54169. scrollbarsOffsets[0] += axisMargin;
  54170. }
  54171. offsetsIndex = 0;
  54172. }
  54173. scrollbarsOffsets[offsetsIndex] += scrollbar.size +
  54174. scrollbar.options.margin;
  54175. if (isNaN(scrollMin) ||
  54176. isNaN(scrollMax) ||
  54177. !defined(axis.min) ||
  54178. !defined(axis.max) ||
  54179. axis.min === axis.max // #10733
  54180. ) {
  54181. // default action: when extremes are the same or there is
  54182. // not extremes on the axis, but scrollbar exists, make it
  54183. // full size
  54184. scrollbar.setRange(0, 1);
  54185. }
  54186. else {
  54187. from =
  54188. (axis.min - scrollMin) / (scrollMax - scrollMin);
  54189. to =
  54190. (axis.max - scrollMin) / (scrollMax - scrollMin);
  54191. if ((axis.horiz && !axis.reversed) ||
  54192. (!axis.horiz && axis.reversed)) {
  54193. scrollbar.setRange(from, to);
  54194. }
  54195. else {
  54196. // inverse vertical axis
  54197. scrollbar.setRange(1 - to, 1 - from);
  54198. }
  54199. }
  54200. }
  54201. });
  54202. // Make space for a scrollbar:
  54203. addEvent(AxisClass, 'afterGetOffset', function () {
  54204. var axis = this,
  54205. index = axis.horiz ? 2 : 1,
  54206. scrollbar = axis.scrollbar;
  54207. if (scrollbar) {
  54208. axis.chart.scrollbarsOffsets = [0, 0]; // reset scrollbars offsets
  54209. axis.chart.axisOffset[index] +=
  54210. scrollbar.size + scrollbar.options.margin;
  54211. }
  54212. });
  54213. };
  54214. return ScrollbarAxis;
  54215. }());
  54216. return ScrollbarAxis;
  54217. });
  54218. _registerModule(_modules, 'Core/Scrollbar.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Globals.js'], _modules['Core/Color/Palette.js'], _modules['Core/Axis/ScrollbarAxis.js'], _modules['Core/Utilities.js'], _modules['Core/Options.js']], function (Axis, H, palette, ScrollbarAxis, U, O) {
  54219. /* *
  54220. *
  54221. * (c) 2010-2021 Torstein Honsi
  54222. *
  54223. * License: www.highcharts.com/license
  54224. *
  54225. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  54226. *
  54227. * */
  54228. var addEvent = U.addEvent,
  54229. correctFloat = U.correctFloat,
  54230. defined = U.defined,
  54231. destroyObjectProperties = U.destroyObjectProperties,
  54232. fireEvent = U.fireEvent,
  54233. merge = U.merge,
  54234. pick = U.pick,
  54235. removeEvent = U.removeEvent;
  54236. var defaultOptions = O.defaultOptions;
  54237. var isTouchDevice = H.isTouchDevice;
  54238. /**
  54239. * When we have vertical scrollbar, rifles and arrow in buttons should be
  54240. * rotated. The same method is used in Navigator's handles, to rotate them.
  54241. *
  54242. * @function Highcharts.swapXY
  54243. *
  54244. * @param {Highcharts.SVGPathArray} path
  54245. * Path to be rotated.
  54246. *
  54247. * @param {boolean} [vertical]
  54248. * If vertical scrollbar, swap x-y values.
  54249. *
  54250. * @return {Highcharts.SVGPathArray}
  54251. * Rotated path.
  54252. *
  54253. * @requires modules/stock
  54254. */
  54255. var swapXY = H.swapXY = function (path,
  54256. vertical) {
  54257. if (vertical) {
  54258. path.forEach(function (seg) {
  54259. var len = seg.length;
  54260. var temp;
  54261. for (var i = 0; i < len; i += 2) {
  54262. temp = seg[i + 1];
  54263. if (typeof temp === 'number') {
  54264. seg[i + 1] = seg[i + 2];
  54265. seg[i + 2] = temp;
  54266. }
  54267. }
  54268. });
  54269. }
  54270. return path;
  54271. };
  54272. /* eslint-disable no-invalid-this, valid-jsdoc */
  54273. /**
  54274. * A reusable scrollbar, internally used in Highcharts Stock's
  54275. * navigator and optionally on individual axes.
  54276. *
  54277. * @private
  54278. * @class
  54279. * @name Highcharts.Scrollbar
  54280. * @param {Highcharts.SVGRenderer} renderer
  54281. * @param {Highcharts.ScrollbarOptions} options
  54282. * @param {Highcharts.Chart} chart
  54283. */
  54284. var Scrollbar = /** @class */ (function () {
  54285. /* *
  54286. *
  54287. * Constructors
  54288. *
  54289. * */
  54290. function Scrollbar(renderer, options, chart) {
  54291. /* *
  54292. *
  54293. * Properties
  54294. *
  54295. * */
  54296. this._events = [];
  54297. this.chartX = 0;
  54298. this.chartY = 0;
  54299. this.from = 0;
  54300. this.group = void 0;
  54301. this.scrollbar = void 0;
  54302. this.scrollbarButtons = [];
  54303. this.scrollbarGroup = void 0;
  54304. this.scrollbarLeft = 0;
  54305. this.scrollbarRifles = void 0;
  54306. this.scrollbarStrokeWidth = 1;
  54307. this.scrollbarTop = 0;
  54308. this.size = 0;
  54309. this.to = 0;
  54310. this.track = void 0;
  54311. this.trackBorderWidth = 1;
  54312. this.userOptions = {};
  54313. this.x = 0;
  54314. this.y = 0;
  54315. this.chart = chart;
  54316. this.options = options;
  54317. this.renderer = chart.renderer;
  54318. this.init(renderer, options, chart);
  54319. }
  54320. /* *
  54321. *
  54322. * Functions
  54323. *
  54324. * */
  54325. /**
  54326. * Set up the mouse and touch events for the Scrollbar
  54327. *
  54328. * @private
  54329. * @function Highcharts.Scrollbar#addEvents
  54330. * @return {void}
  54331. */
  54332. Scrollbar.prototype.addEvents = function () {
  54333. var buttonsOrder = this.options.inverted ? [1, 0] : [0, 1],
  54334. buttons = this.scrollbarButtons,
  54335. bar = this.scrollbarGroup.element,
  54336. track = this.track.element,
  54337. mouseDownHandler = this.mouseDownHandler.bind(this),
  54338. mouseMoveHandler = this.mouseMoveHandler.bind(this),
  54339. mouseUpHandler = this.mouseUpHandler.bind(this),
  54340. _events;
  54341. // Mouse events
  54342. _events = [
  54343. [buttons[buttonsOrder[0]].element, 'click', this.buttonToMinClick.bind(this)],
  54344. [buttons[buttonsOrder[1]].element, 'click', this.buttonToMaxClick.bind(this)],
  54345. [track, 'click', this.trackClick.bind(this)],
  54346. [bar, 'mousedown', mouseDownHandler],
  54347. [bar.ownerDocument, 'mousemove', mouseMoveHandler],
  54348. [bar.ownerDocument, 'mouseup', mouseUpHandler]
  54349. ];
  54350. // Touch events
  54351. if (H.hasTouch) {
  54352. _events.push([bar, 'touchstart', mouseDownHandler], [bar.ownerDocument, 'touchmove', mouseMoveHandler], [bar.ownerDocument, 'touchend', mouseUpHandler]);
  54353. }
  54354. // Add them all
  54355. _events.forEach(function (args) {
  54356. addEvent.apply(null, args);
  54357. });
  54358. this._events = _events;
  54359. };
  54360. Scrollbar.prototype.buttonToMaxClick = function (e) {
  54361. var scroller = this;
  54362. var range = (scroller.to - scroller.from) * pick(scroller.options.step, 0.2);
  54363. scroller.updatePosition(scroller.from + range, scroller.to + range);
  54364. fireEvent(scroller, 'changed', {
  54365. from: scroller.from,
  54366. to: scroller.to,
  54367. trigger: 'scrollbar',
  54368. DOMEvent: e
  54369. });
  54370. };
  54371. Scrollbar.prototype.buttonToMinClick = function (e) {
  54372. var scroller = this;
  54373. var range = correctFloat(scroller.to - scroller.from) *
  54374. pick(scroller.options.step, 0.2);
  54375. scroller.updatePosition(correctFloat(scroller.from - range), correctFloat(scroller.to - range));
  54376. fireEvent(scroller, 'changed', {
  54377. from: scroller.from,
  54378. to: scroller.to,
  54379. trigger: 'scrollbar',
  54380. DOMEvent: e
  54381. });
  54382. };
  54383. /**
  54384. * Get normalized (0-1) cursor position over the scrollbar
  54385. *
  54386. * @private
  54387. * @function Highcharts.Scrollbar#cursorToScrollbarPosition
  54388. *
  54389. * @param {*} normalizedEvent
  54390. * normalized event, with chartX and chartY values
  54391. *
  54392. * @return {Highcharts.Dictionary<number>}
  54393. * Local position {chartX, chartY}
  54394. */
  54395. Scrollbar.prototype.cursorToScrollbarPosition = function (normalizedEvent) {
  54396. var scroller = this,
  54397. options = scroller.options,
  54398. minWidthDifference = options.minWidth > scroller.calculatedWidth ?
  54399. options.minWidth :
  54400. 0; // minWidth distorts translation
  54401. return {
  54402. chartX: (normalizedEvent.chartX - scroller.x -
  54403. scroller.xOffset) /
  54404. (scroller.barWidth - minWidthDifference),
  54405. chartY: (normalizedEvent.chartY - scroller.y -
  54406. scroller.yOffset) /
  54407. (scroller.barWidth - minWidthDifference)
  54408. };
  54409. };
  54410. /**
  54411. * Destroys allocated elements.
  54412. *
  54413. * @private
  54414. * @function Highcharts.Scrollbar#destroy
  54415. * @return {void}
  54416. */
  54417. Scrollbar.prototype.destroy = function () {
  54418. var scroller = this.chart.scroller;
  54419. // Disconnect events added in addEvents
  54420. this.removeEvents();
  54421. // Destroy properties
  54422. [
  54423. 'track',
  54424. 'scrollbarRifles',
  54425. 'scrollbar',
  54426. 'scrollbarGroup',
  54427. 'group'
  54428. ].forEach(function (prop) {
  54429. if (this[prop] && this[prop].destroy) {
  54430. this[prop] = this[prop].destroy();
  54431. }
  54432. }, this);
  54433. // #6421, chart may have more scrollbars
  54434. if (scroller && this === scroller.scrollbar) {
  54435. scroller.scrollbar = null;
  54436. // Destroy elements in collection
  54437. destroyObjectProperties(scroller.scrollbarButtons);
  54438. }
  54439. };
  54440. /**
  54441. * Draw the scrollbar buttons with arrows
  54442. *
  54443. * @private
  54444. * @function Highcharts.Scrollbar#drawScrollbarButton
  54445. * @param {number} index
  54446. * 0 is left, 1 is right
  54447. * @return {void}
  54448. */
  54449. Scrollbar.prototype.drawScrollbarButton = function (index) {
  54450. var scroller = this,
  54451. renderer = scroller.renderer,
  54452. scrollbarButtons = scroller.scrollbarButtons,
  54453. options = scroller.options,
  54454. size = scroller.size,
  54455. group,
  54456. tempElem;
  54457. group = renderer.g().add(scroller.group);
  54458. scrollbarButtons.push(group);
  54459. // Create a rectangle for the scrollbar button
  54460. tempElem = renderer.rect()
  54461. .addClass('highcharts-scrollbar-button')
  54462. .add(group);
  54463. // Presentational attributes
  54464. if (!this.chart.styledMode) {
  54465. tempElem.attr({
  54466. stroke: options.buttonBorderColor,
  54467. 'stroke-width': options.buttonBorderWidth,
  54468. fill: options.buttonBackgroundColor
  54469. });
  54470. }
  54471. // Place the rectangle based on the rendered stroke width
  54472. tempElem.attr(tempElem.crisp({
  54473. x: -0.5,
  54474. y: -0.5,
  54475. width: size + 1,
  54476. height: size + 1,
  54477. r: options.buttonBorderRadius
  54478. }, tempElem.strokeWidth()));
  54479. // Button arrow
  54480. tempElem = renderer
  54481. .path(swapXY([[
  54482. 'M',
  54483. size / 2 + (index ? -1 : 1),
  54484. size / 2 - 3
  54485. ], [
  54486. 'L',
  54487. size / 2 + (index ? -1 : 1),
  54488. size / 2 + 3
  54489. ], [
  54490. 'L',
  54491. size / 2 + (index ? 2 : -2),
  54492. size / 2
  54493. ]], options.vertical))
  54494. .addClass('highcharts-scrollbar-arrow')
  54495. .add(scrollbarButtons[index]);
  54496. if (!this.chart.styledMode) {
  54497. tempElem.attr({
  54498. fill: options.buttonArrowColor
  54499. });
  54500. }
  54501. };
  54502. /**
  54503. * @private
  54504. * @function Highcharts.Scrollbar#init
  54505. * @param {Highcharts.SVGRenderer} renderer
  54506. * @param {Highcharts.ScrollbarOptions} options
  54507. * @param {Highcharts.Chart} chart
  54508. */
  54509. Scrollbar.prototype.init = function (renderer, options, chart) {
  54510. this.scrollbarButtons = [];
  54511. this.renderer = renderer;
  54512. this.userOptions = options;
  54513. this.options = merge(Scrollbar.defaultOptions, options);
  54514. this.chart = chart;
  54515. // backward compatibility
  54516. this.size = pick(this.options.size, this.options.height);
  54517. // Init
  54518. if (options.enabled) {
  54519. this.render();
  54520. this.addEvents();
  54521. }
  54522. };
  54523. Scrollbar.prototype.mouseDownHandler = function (e) {
  54524. var scroller = this;
  54525. var normalizedEvent = scroller.chart.pointer.normalize(e),
  54526. mousePosition = scroller.cursorToScrollbarPosition(normalizedEvent);
  54527. scroller.chartX = mousePosition.chartX;
  54528. scroller.chartY = mousePosition.chartY;
  54529. scroller.initPositions = [scroller.from, scroller.to];
  54530. scroller.grabbedCenter = true;
  54531. };
  54532. /**
  54533. * Event handler for the mouse move event.
  54534. * @private
  54535. */
  54536. Scrollbar.prototype.mouseMoveHandler = function (e) {
  54537. var scroller = this;
  54538. var normalizedEvent = scroller.chart.pointer.normalize(e),
  54539. options = scroller.options,
  54540. direction = options.vertical ? 'chartY' : 'chartX',
  54541. initPositions = scroller.initPositions || [],
  54542. scrollPosition,
  54543. chartPosition,
  54544. change;
  54545. // In iOS, a mousemove event with e.pageX === 0 is fired when
  54546. // holding the finger down in the center of the scrollbar. This
  54547. // should be ignored.
  54548. if (scroller.grabbedCenter &&
  54549. // #4696, scrollbar failed on Android
  54550. (!e.touches || e.touches[0][direction] !== 0)) {
  54551. chartPosition = scroller.cursorToScrollbarPosition(normalizedEvent)[direction];
  54552. scrollPosition = scroller[direction];
  54553. change = chartPosition - scrollPosition;
  54554. scroller.hasDragged = true;
  54555. scroller.updatePosition(initPositions[0] + change, initPositions[1] + change);
  54556. if (scroller.hasDragged) {
  54557. fireEvent(scroller, 'changed', {
  54558. from: scroller.from,
  54559. to: scroller.to,
  54560. trigger: 'scrollbar',
  54561. DOMType: e.type,
  54562. DOMEvent: e
  54563. });
  54564. }
  54565. }
  54566. };
  54567. /**
  54568. * Event handler for the mouse up event.
  54569. * @private
  54570. */
  54571. Scrollbar.prototype.mouseUpHandler = function (e) {
  54572. var scroller = this;
  54573. if (scroller.hasDragged) {
  54574. fireEvent(scroller, 'changed', {
  54575. from: scroller.from,
  54576. to: scroller.to,
  54577. trigger: 'scrollbar',
  54578. DOMType: e.type,
  54579. DOMEvent: e
  54580. });
  54581. }
  54582. scroller.grabbedCenter =
  54583. scroller.hasDragged =
  54584. scroller.chartX =
  54585. scroller.chartY = null;
  54586. };
  54587. /**
  54588. * Position the scrollbar, method called from a parent with defined
  54589. * dimensions.
  54590. *
  54591. * @private
  54592. * @function Highcharts.Scrollbar#position
  54593. * @param {number} x
  54594. * x-position on the chart
  54595. * @param {number} y
  54596. * y-position on the chart
  54597. * @param {number} width
  54598. * width of the scrollbar
  54599. * @param {number} height
  54600. * height of the scorllbar
  54601. * @return {void}
  54602. */
  54603. Scrollbar.prototype.position = function (x, y, width, height) {
  54604. var scroller = this,
  54605. options = scroller.options,
  54606. vertical = options.vertical,
  54607. xOffset = height,
  54608. yOffset = 0,
  54609. method = scroller.rendered ? 'animate' : 'attr';
  54610. scroller.x = x;
  54611. scroller.y = y + this.trackBorderWidth;
  54612. scroller.width = width; // width with buttons
  54613. scroller.height = height;
  54614. scroller.xOffset = xOffset;
  54615. scroller.yOffset = yOffset;
  54616. // If Scrollbar is a vertical type, swap options:
  54617. if (vertical) {
  54618. scroller.width = scroller.yOffset = width = yOffset = scroller.size;
  54619. scroller.xOffset = xOffset = 0;
  54620. scroller.barWidth = height - width * 2; // width without buttons
  54621. scroller.x = x = x + scroller.options.margin;
  54622. }
  54623. else {
  54624. scroller.height = scroller.xOffset = height = xOffset =
  54625. scroller.size;
  54626. scroller.barWidth = width - height * 2; // width without buttons
  54627. scroller.y = scroller.y + scroller.options.margin;
  54628. }
  54629. // Set general position for a group:
  54630. scroller.group[method]({
  54631. translateX: x,
  54632. translateY: scroller.y
  54633. });
  54634. // Resize background/track:
  54635. scroller.track[method]({
  54636. width: width,
  54637. height: height
  54638. });
  54639. // Move right/bottom button ot it's place:
  54640. scroller.scrollbarButtons[1][method]({
  54641. translateX: vertical ? 0 : width - xOffset,
  54642. translateY: vertical ? height - yOffset : 0
  54643. });
  54644. };
  54645. /**
  54646. * Removes the event handlers attached previously with addEvents.
  54647. *
  54648. * @private
  54649. * @function Highcharts.Scrollbar#removeEvents
  54650. * @return {void}
  54651. */
  54652. Scrollbar.prototype.removeEvents = function () {
  54653. this._events.forEach(function (args) {
  54654. removeEvent.apply(null, args);
  54655. });
  54656. this._events.length = 0;
  54657. };
  54658. /**
  54659. * Render scrollbar with all required items.
  54660. *
  54661. * @private
  54662. * @function Highcharts.Scrollbar#render
  54663. */
  54664. Scrollbar.prototype.render = function () {
  54665. var scroller = this,
  54666. renderer = scroller.renderer,
  54667. options = scroller.options,
  54668. size = scroller.size,
  54669. styledMode = this.chart.styledMode,
  54670. group;
  54671. // Draw the scrollbar group
  54672. scroller.group = group = renderer.g('scrollbar').attr({
  54673. zIndex: options.zIndex,
  54674. translateY: -99999
  54675. }).add();
  54676. // Draw the scrollbar track:
  54677. scroller.track = renderer.rect()
  54678. .addClass('highcharts-scrollbar-track')
  54679. .attr({
  54680. x: 0,
  54681. r: options.trackBorderRadius || 0,
  54682. height: size,
  54683. width: size
  54684. }).add(group);
  54685. if (!styledMode) {
  54686. scroller.track.attr({
  54687. fill: options.trackBackgroundColor,
  54688. stroke: options.trackBorderColor,
  54689. 'stroke-width': options.trackBorderWidth
  54690. });
  54691. }
  54692. this.trackBorderWidth = scroller.track.strokeWidth();
  54693. scroller.track.attr({
  54694. y: -this.trackBorderWidth % 2 / 2
  54695. });
  54696. // Draw the scrollbar itself
  54697. scroller.scrollbarGroup = renderer.g().add(group);
  54698. scroller.scrollbar = renderer.rect()
  54699. .addClass('highcharts-scrollbar-thumb')
  54700. .attr({
  54701. height: size,
  54702. width: size,
  54703. r: options.barBorderRadius || 0
  54704. }).add(scroller.scrollbarGroup);
  54705. scroller.scrollbarRifles = renderer
  54706. .path(swapXY([
  54707. ['M', -3, size / 4],
  54708. ['L', -3, 2 * size / 3],
  54709. ['M', 0, size / 4],
  54710. ['L', 0, 2 * size / 3],
  54711. ['M', 3, size / 4],
  54712. ['L', 3, 2 * size / 3]
  54713. ], options.vertical))
  54714. .addClass('highcharts-scrollbar-rifles')
  54715. .add(scroller.scrollbarGroup);
  54716. if (!styledMode) {
  54717. scroller.scrollbar.attr({
  54718. fill: options.barBackgroundColor,
  54719. stroke: options.barBorderColor,
  54720. 'stroke-width': options.barBorderWidth
  54721. });
  54722. scroller.scrollbarRifles.attr({
  54723. stroke: options.rifleColor,
  54724. 'stroke-width': 1
  54725. });
  54726. }
  54727. scroller.scrollbarStrokeWidth = scroller.scrollbar.strokeWidth();
  54728. scroller.scrollbarGroup.translate(-scroller.scrollbarStrokeWidth % 2 / 2, -scroller.scrollbarStrokeWidth % 2 / 2);
  54729. // Draw the buttons:
  54730. scroller.drawScrollbarButton(0);
  54731. scroller.drawScrollbarButton(1);
  54732. };
  54733. /**
  54734. * Set scrollbar size, with a given scale.
  54735. *
  54736. * @private
  54737. * @function Highcharts.Scrollbar#setRange
  54738. * @param {number} from
  54739. * scale (0-1) where bar should start
  54740. * @param {number} to
  54741. * scale (0-1) where bar should end
  54742. * @return {void}
  54743. */
  54744. Scrollbar.prototype.setRange = function (from, to) {
  54745. var scroller = this,
  54746. options = scroller.options,
  54747. vertical = options.vertical,
  54748. minWidth = options.minWidth,
  54749. fullWidth = scroller.barWidth,
  54750. fromPX,
  54751. toPX,
  54752. newPos,
  54753. newSize,
  54754. newRiflesPos,
  54755. method = (this.rendered &&
  54756. !this.hasDragged &&
  54757. !(this.chart.navigator && this.chart.navigator.hasDragged)) ? 'animate' : 'attr';
  54758. if (!defined(fullWidth)) {
  54759. return;
  54760. }
  54761. from = Math.max(from, 0);
  54762. fromPX = Math.ceil(fullWidth * from);
  54763. toPX = fullWidth * Math.min(to, 1);
  54764. scroller.calculatedWidth = newSize = correctFloat(toPX - fromPX);
  54765. // We need to recalculate position, if minWidth is used
  54766. if (newSize < minWidth) {
  54767. fromPX = (fullWidth - minWidth + newSize) * from;
  54768. newSize = minWidth;
  54769. }
  54770. newPos = Math.floor(fromPX + scroller.xOffset + scroller.yOffset);
  54771. newRiflesPos = newSize / 2 - 0.5; // -0.5 -> rifle line width / 2
  54772. // Store current position:
  54773. scroller.from = from;
  54774. scroller.to = to;
  54775. if (!vertical) {
  54776. scroller.scrollbarGroup[method]({
  54777. translateX: newPos
  54778. });
  54779. scroller.scrollbar[method]({
  54780. width: newSize
  54781. });
  54782. scroller.scrollbarRifles[method]({
  54783. translateX: newRiflesPos
  54784. });
  54785. scroller.scrollbarLeft = newPos;
  54786. scroller.scrollbarTop = 0;
  54787. }
  54788. else {
  54789. scroller.scrollbarGroup[method]({
  54790. translateY: newPos
  54791. });
  54792. scroller.scrollbar[method]({
  54793. height: newSize
  54794. });
  54795. scroller.scrollbarRifles[method]({
  54796. translateY: newRiflesPos
  54797. });
  54798. scroller.scrollbarTop = newPos;
  54799. scroller.scrollbarLeft = 0;
  54800. }
  54801. if (newSize <= 12) {
  54802. scroller.scrollbarRifles.hide();
  54803. }
  54804. else {
  54805. scroller.scrollbarRifles.show(true);
  54806. }
  54807. // Show or hide the scrollbar based on the showFull setting
  54808. if (options.showFull === false) {
  54809. if (from <= 0 && to >= 1) {
  54810. scroller.group.hide();
  54811. }
  54812. else {
  54813. scroller.group.show();
  54814. }
  54815. }
  54816. scroller.rendered = true;
  54817. };
  54818. /**
  54819. * Checks if the extremes should be updated in response to a scrollbar
  54820. * change event.
  54821. *
  54822. * @private
  54823. * @function Highcharts.Scrollbar#shouldUpdateExtremes
  54824. * @param {string} eventType
  54825. * @return {boolean}
  54826. */
  54827. Scrollbar.prototype.shouldUpdateExtremes = function (eventType) {
  54828. return (pick(this.options.liveRedraw, H.svg && !H.isTouchDevice && !this.chart.isBoosting) ||
  54829. // Mouseup always should change extremes
  54830. eventType === 'mouseup' ||
  54831. eventType === 'touchend' ||
  54832. // Internal events
  54833. !defined(eventType));
  54834. };
  54835. Scrollbar.prototype.trackClick = function (e) {
  54836. var scroller = this;
  54837. var normalizedEvent = scroller.chart.pointer.normalize(e),
  54838. range = scroller.to - scroller.from,
  54839. top = scroller.y + scroller.scrollbarTop,
  54840. left = scroller.x + scroller.scrollbarLeft;
  54841. if ((scroller.options.vertical && normalizedEvent.chartY > top) ||
  54842. (!scroller.options.vertical && normalizedEvent.chartX > left)) {
  54843. // On the top or on the left side of the track:
  54844. scroller.updatePosition(scroller.from + range, scroller.to + range);
  54845. }
  54846. else {
  54847. // On the bottom or the right side of the track:
  54848. scroller.updatePosition(scroller.from - range, scroller.to - range);
  54849. }
  54850. fireEvent(scroller, 'changed', {
  54851. from: scroller.from,
  54852. to: scroller.to,
  54853. trigger: 'scrollbar',
  54854. DOMEvent: e
  54855. });
  54856. };
  54857. /**
  54858. * Update the scrollbar with new options
  54859. *
  54860. * @private
  54861. * @function Highcharts.Scrollbar#update
  54862. * @param {Highcharts.ScrollbarOptions} options
  54863. * @return {void}
  54864. */
  54865. Scrollbar.prototype.update = function (options) {
  54866. this.destroy();
  54867. this.init(this.chart.renderer, merge(true, this.options, options), this.chart);
  54868. };
  54869. /**
  54870. * Update position option in the Scrollbar, with normalized 0-1 scale
  54871. *
  54872. * @private
  54873. * @function Highcharts.Scrollbar#updatePosition
  54874. * @param {number} from
  54875. * @param {number} to
  54876. * @return {void}
  54877. */
  54878. Scrollbar.prototype.updatePosition = function (from, to) {
  54879. if (to > 1) {
  54880. from = correctFloat(1 - correctFloat(to - from));
  54881. to = 1;
  54882. }
  54883. if (from < 0) {
  54884. to = correctFloat(to - from);
  54885. from = 0;
  54886. }
  54887. this.from = from;
  54888. this.to = to;
  54889. };
  54890. /* *
  54891. *
  54892. * Static Properties
  54893. *
  54894. * */
  54895. /**
  54896. *
  54897. * The scrollbar is a means of panning over the X axis of a stock chart.
  54898. * Scrollbars can also be applied to other types of axes.
  54899. *
  54900. * Another approach to scrollable charts is the [chart.scrollablePlotArea](
  54901. * https://api.highcharts.com/highcharts/chart.scrollablePlotArea) option that
  54902. * is especially suitable for simpler cartesian charts on mobile.
  54903. *
  54904. * In styled mode, all the presentational options for the
  54905. * scrollbar are replaced by the classes `.highcharts-scrollbar-thumb`,
  54906. * `.highcharts-scrollbar-arrow`, `.highcharts-scrollbar-button`,
  54907. * `.highcharts-scrollbar-rifles` and `.highcharts-scrollbar-track`.
  54908. *
  54909. * @sample stock/yaxis/inverted-bar-scrollbar/
  54910. * A scrollbar on a simple bar chart
  54911. *
  54912. * @product highstock gantt
  54913. * @optionparent scrollbar
  54914. *
  54915. * @private
  54916. */
  54917. Scrollbar.defaultOptions = {
  54918. /**
  54919. * The height of the scrollbar. The height also applies to the width
  54920. * of the scroll arrows so that they are always squares. Defaults to
  54921. * 20 for touch devices and 14 for mouse devices.
  54922. *
  54923. * @sample stock/scrollbar/height/
  54924. * A 30px scrollbar
  54925. *
  54926. * @type {number}
  54927. * @default 20/14
  54928. */
  54929. height: isTouchDevice ? 20 : 14,
  54930. /**
  54931. * The border rounding radius of the bar.
  54932. *
  54933. * @sample stock/scrollbar/style/
  54934. * Scrollbar styling
  54935. */
  54936. barBorderRadius: 0,
  54937. /**
  54938. * The corner radius of the scrollbar buttons.
  54939. *
  54940. * @sample stock/scrollbar/style/
  54941. * Scrollbar styling
  54942. */
  54943. buttonBorderRadius: 0,
  54944. /**
  54945. * Enable or disable the scrollbar.
  54946. *
  54947. * @sample stock/scrollbar/enabled/
  54948. * Disable the scrollbar, only use navigator
  54949. *
  54950. * @type {boolean}
  54951. * @default true
  54952. * @apioption scrollbar.enabled
  54953. */
  54954. /**
  54955. * Whether to redraw the main chart as the scrollbar or the navigator
  54956. * zoomed window is moved. Defaults to `true` for modern browsers and
  54957. * `false` for legacy IE browsers as well as mobile devices.
  54958. *
  54959. * @sample stock/scrollbar/liveredraw
  54960. * Setting live redraw to false
  54961. *
  54962. * @type {boolean}
  54963. * @since 1.3
  54964. */
  54965. liveRedraw: void 0,
  54966. /**
  54967. * The margin between the scrollbar and its axis when the scrollbar is
  54968. * applied directly to an axis.
  54969. */
  54970. margin: 10,
  54971. /**
  54972. * The minimum width of the scrollbar.
  54973. *
  54974. * @since 1.2.5
  54975. */
  54976. minWidth: 6,
  54977. /**
  54978. * Whether to show or hide the scrollbar when the scrolled content is
  54979. * zoomed out to it full extent.
  54980. *
  54981. * @type {boolean}
  54982. * @default true
  54983. * @apioption scrollbar.showFull
  54984. */
  54985. step: 0.2,
  54986. /**
  54987. * The z index of the scrollbar group.
  54988. */
  54989. zIndex: 3,
  54990. /**
  54991. * The background color of the scrollbar itself.
  54992. *
  54993. * @sample stock/scrollbar/style/
  54994. * Scrollbar styling
  54995. *
  54996. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  54997. */
  54998. barBackgroundColor: palette.neutralColor20,
  54999. /**
  55000. * The width of the bar's border.
  55001. *
  55002. * @sample stock/scrollbar/style/
  55003. * Scrollbar styling
  55004. */
  55005. barBorderWidth: 1,
  55006. /**
  55007. * The color of the scrollbar's border.
  55008. *
  55009. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  55010. */
  55011. barBorderColor: palette.neutralColor20,
  55012. /**
  55013. * The color of the small arrow inside the scrollbar buttons.
  55014. *
  55015. * @sample stock/scrollbar/style/
  55016. * Scrollbar styling
  55017. *
  55018. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  55019. */
  55020. buttonArrowColor: palette.neutralColor80,
  55021. /**
  55022. * The color of scrollbar buttons.
  55023. *
  55024. * @sample stock/scrollbar/style/
  55025. * Scrollbar styling
  55026. *
  55027. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  55028. */
  55029. buttonBackgroundColor: palette.neutralColor10,
  55030. /**
  55031. * The color of the border of the scrollbar buttons.
  55032. *
  55033. * @sample stock/scrollbar/style/
  55034. * Scrollbar styling
  55035. *
  55036. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  55037. */
  55038. buttonBorderColor: palette.neutralColor20,
  55039. /**
  55040. * The border width of the scrollbar buttons.
  55041. *
  55042. * @sample stock/scrollbar/style/
  55043. * Scrollbar styling
  55044. */
  55045. buttonBorderWidth: 1,
  55046. /**
  55047. * The color of the small rifles in the middle of the scrollbar.
  55048. *
  55049. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  55050. */
  55051. rifleColor: palette.neutralColor80,
  55052. /**
  55053. * The color of the track background.
  55054. *
  55055. * @sample stock/scrollbar/style/
  55056. * Scrollbar styling
  55057. *
  55058. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  55059. */
  55060. trackBackgroundColor: palette.neutralColor5,
  55061. /**
  55062. * The color of the border of the scrollbar track.
  55063. *
  55064. * @sample stock/scrollbar/style/
  55065. * Scrollbar styling
  55066. *
  55067. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  55068. */
  55069. trackBorderColor: palette.neutralColor5,
  55070. /**
  55071. * The corner radius of the border of the scrollbar track.
  55072. *
  55073. * @sample stock/scrollbar/style/
  55074. * Scrollbar styling
  55075. *
  55076. * @type {number}
  55077. * @default 0
  55078. * @apioption scrollbar.trackBorderRadius
  55079. */
  55080. /**
  55081. * The width of the border of the scrollbar track.
  55082. *
  55083. * @sample stock/scrollbar/style/
  55084. * Scrollbar styling
  55085. */
  55086. trackBorderWidth: 1
  55087. };
  55088. return Scrollbar;
  55089. }());
  55090. if (!H.Scrollbar) {
  55091. defaultOptions.scrollbar = merge(true, Scrollbar.defaultOptions, defaultOptions.scrollbar);
  55092. H.Scrollbar = Scrollbar;
  55093. ScrollbarAxis.compose(Axis, Scrollbar);
  55094. }
  55095. return H.Scrollbar;
  55096. });
  55097. _registerModule(_modules, 'Extensions/RangeSelector.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Chart/Chart.js'], _modules['Core/Globals.js'], _modules['Core/Options.js'], _modules['Core/Color/Palette.js'], _modules['Core/Renderer/SVG/SVGElement.js'], _modules['Core/Utilities.js']], function (Axis, Chart, H, O, palette, SVGElement, U) {
  55098. /* *
  55099. *
  55100. * (c) 2010-2021 Torstein Honsi
  55101. *
  55102. * License: www.highcharts.com/license
  55103. *
  55104. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  55105. *
  55106. * */
  55107. var defaultOptions = O.defaultOptions;
  55108. var addEvent = U.addEvent,
  55109. createElement = U.createElement,
  55110. css = U.css,
  55111. defined = U.defined,
  55112. destroyObjectProperties = U.destroyObjectProperties,
  55113. discardElement = U.discardElement,
  55114. extend = U.extend,
  55115. find = U.find,
  55116. fireEvent = U.fireEvent,
  55117. isNumber = U.isNumber,
  55118. merge = U.merge,
  55119. objectEach = U.objectEach,
  55120. pad = U.pad,
  55121. pick = U.pick,
  55122. pInt = U.pInt,
  55123. splat = U.splat;
  55124. /**
  55125. * Define the time span for the button
  55126. *
  55127. * @typedef {"all"|"day"|"hour"|"millisecond"|"minute"|"month"|"second"|"week"|"year"|"ytd"} Highcharts.RangeSelectorButtonTypeValue
  55128. */
  55129. /**
  55130. * Callback function to react on button clicks.
  55131. *
  55132. * @callback Highcharts.RangeSelectorClickCallbackFunction
  55133. *
  55134. * @param {global.Event} e
  55135. * Event arguments.
  55136. *
  55137. * @param {boolean|undefined}
  55138. * Return false to cancel the default button event.
  55139. */
  55140. /**
  55141. * Callback function to parse values entered in the input boxes and return a
  55142. * valid JavaScript time as milliseconds since 1970.
  55143. *
  55144. * @callback Highcharts.RangeSelectorParseCallbackFunction
  55145. *
  55146. * @param {string} value
  55147. * Input value to parse.
  55148. *
  55149. * @return {number}
  55150. * Parsed JavaScript time value.
  55151. */
  55152. /* ************************************************************************** *
  55153. * Start Range Selector code *
  55154. * ************************************************************************** */
  55155. extend(defaultOptions, {
  55156. /**
  55157. * The range selector is a tool for selecting ranges to display within
  55158. * the chart. It provides buttons to select preconfigured ranges in
  55159. * the chart, like 1 day, 1 week, 1 month etc. It also provides input
  55160. * boxes where min and max dates can be manually input.
  55161. *
  55162. * @product highstock gantt
  55163. * @optionparent rangeSelector
  55164. */
  55165. rangeSelector: {
  55166. /**
  55167. * Whether to enable all buttons from the start. By default buttons are
  55168. * only enabled if the corresponding time range exists on the X axis,
  55169. * but enabling all buttons allows for dynamically loading different
  55170. * time ranges.
  55171. *
  55172. * @sample {highstock} stock/rangeselector/allbuttonsenabled-true/
  55173. * All buttons enabled
  55174. *
  55175. * @since 2.0.3
  55176. */
  55177. allButtonsEnabled: false,
  55178. /**
  55179. * An array of configuration objects for the buttons.
  55180. *
  55181. * Defaults to:
  55182. * ```js
  55183. * buttons: [{
  55184. * type: 'month',
  55185. * count: 1,
  55186. * text: '1m',
  55187. * title: 'View 1 month'
  55188. * }, {
  55189. * type: 'month',
  55190. * count: 3,
  55191. * text: '3m',
  55192. * title: 'View 3 months'
  55193. * }, {
  55194. * type: 'month',
  55195. * count: 6,
  55196. * text: '6m',
  55197. * title: 'View 6 months'
  55198. * }, {
  55199. * type: 'ytd',
  55200. * text: 'YTD',
  55201. * title: 'View year to date'
  55202. * }, {
  55203. * type: 'year',
  55204. * count: 1,
  55205. * text: '1y',
  55206. * title: 'View 1 year'
  55207. * }, {
  55208. * type: 'all',
  55209. * text: 'All',
  55210. * title: 'View all'
  55211. * }]
  55212. * ```
  55213. *
  55214. * @sample {highstock} stock/rangeselector/datagrouping/
  55215. * Data grouping by buttons
  55216. *
  55217. * @type {Array<*>}
  55218. */
  55219. buttons: void 0,
  55220. /**
  55221. * How many units of the defined type the button should span. If `type`
  55222. * is "month" and `count` is 3, the button spans three months.
  55223. *
  55224. * @type {number}
  55225. * @default 1
  55226. * @apioption rangeSelector.buttons.count
  55227. */
  55228. /**
  55229. * Fires when clicking on the rangeSelector button. One parameter,
  55230. * event, is passed to the function, containing common event
  55231. * information.
  55232. *
  55233. * ```js
  55234. * click: function(e) {
  55235. * console.log(this);
  55236. * }
  55237. * ```
  55238. *
  55239. * Return false to stop default button's click action.
  55240. *
  55241. * @sample {highstock} stock/rangeselector/button-click/
  55242. * Click event on the button
  55243. *
  55244. * @type {Highcharts.RangeSelectorClickCallbackFunction}
  55245. * @apioption rangeSelector.buttons.events.click
  55246. */
  55247. /**
  55248. * Additional range (in milliseconds) added to the end of the calculated
  55249. * time span.
  55250. *
  55251. * @sample {highstock} stock/rangeselector/min-max-offsets/
  55252. * Button offsets
  55253. *
  55254. * @type {number}
  55255. * @default 0
  55256. * @since 6.0.0
  55257. * @apioption rangeSelector.buttons.offsetMax
  55258. */
  55259. /**
  55260. * Additional range (in milliseconds) added to the start of the
  55261. * calculated time span.
  55262. *
  55263. * @sample {highstock} stock/rangeselector/min-max-offsets/
  55264. * Button offsets
  55265. *
  55266. * @type {number}
  55267. * @default 0
  55268. * @since 6.0.0
  55269. * @apioption rangeSelector.buttons.offsetMin
  55270. */
  55271. /**
  55272. * When buttons apply dataGrouping on a series, by default zooming
  55273. * in/out will deselect buttons and unset dataGrouping. Enable this
  55274. * option to keep buttons selected when extremes change.
  55275. *
  55276. * @sample {highstock} stock/rangeselector/preserve-datagrouping/
  55277. * Different preserveDataGrouping settings
  55278. *
  55279. * @type {boolean}
  55280. * @default false
  55281. * @since 6.1.2
  55282. * @apioption rangeSelector.buttons.preserveDataGrouping
  55283. */
  55284. /**
  55285. * A custom data grouping object for each button.
  55286. *
  55287. * @see [series.dataGrouping](#plotOptions.series.dataGrouping)
  55288. *
  55289. * @sample {highstock} stock/rangeselector/datagrouping/
  55290. * Data grouping by range selector buttons
  55291. *
  55292. * @type {*}
  55293. * @extends plotOptions.series.dataGrouping
  55294. * @apioption rangeSelector.buttons.dataGrouping
  55295. */
  55296. /**
  55297. * The text for the button itself.
  55298. *
  55299. * @type {string}
  55300. * @apioption rangeSelector.buttons.text
  55301. */
  55302. /**
  55303. * Explanation for the button, shown as a tooltip on hover, and used by
  55304. * assistive technology.
  55305. *
  55306. * @type {string}
  55307. * @apioption rangeSelector.buttons.title
  55308. */
  55309. /**
  55310. * Defined the time span for the button. Can be one of `millisecond`,
  55311. * `second`, `minute`, `hour`, `day`, `week`, `month`, `year`, `ytd`,
  55312. * and `all`.
  55313. *
  55314. * @type {Highcharts.RangeSelectorButtonTypeValue}
  55315. * @apioption rangeSelector.buttons.type
  55316. */
  55317. /**
  55318. * The space in pixels between the buttons in the range selector.
  55319. */
  55320. buttonSpacing: 5,
  55321. /**
  55322. * Whether to collapse the range selector buttons into a dropdown when
  55323. * there is not enough room to show everything in a single row, instead
  55324. * of dividing the range selector into multiple rows.
  55325. * Can be one of the following:
  55326. * - `always`: Always collapse
  55327. * - `responsive`: Only collapse when there is not enough room
  55328. * - `never`: Never collapse
  55329. *
  55330. * @sample {highstock} stock/rangeselector/dropdown/
  55331. * Dropdown option
  55332. *
  55333. * @validvalue ["always", "responsive", "never"]
  55334. * @since 9.0.0
  55335. */
  55336. dropdown: 'responsive',
  55337. /**
  55338. * Enable or disable the range selector. Default to `true` for stock
  55339. * charts, using the `stockChart` factory.
  55340. *
  55341. * @sample {highstock} stock/rangeselector/enabled/
  55342. * Disable the range selector
  55343. *
  55344. * @type {boolean|undefined}
  55345. * @default {highstock} true
  55346. */
  55347. enabled: void 0,
  55348. /**
  55349. * The vertical alignment of the rangeselector box. Allowed properties
  55350. * are `top`, `middle`, `bottom`.
  55351. *
  55352. * @sample {highstock} stock/rangeselector/vertical-align-middle/
  55353. * Middle
  55354. * @sample {highstock} stock/rangeselector/vertical-align-bottom/
  55355. * Bottom
  55356. *
  55357. * @type {Highcharts.VerticalAlignValue}
  55358. * @since 6.0.0
  55359. */
  55360. verticalAlign: 'top',
  55361. /**
  55362. * A collection of attributes for the buttons. The object takes SVG
  55363. * attributes like `fill`, `stroke`, `stroke-width`, as well as `style`,
  55364. * a collection of CSS properties for the text.
  55365. *
  55366. * The object can also be extended with states, so you can set
  55367. * presentational options for `hover`, `select` or `disabled` button
  55368. * states.
  55369. *
  55370. * CSS styles for the text label.
  55371. *
  55372. * In styled mode, the buttons are styled by the
  55373. * `.highcharts-range-selector-buttons .highcharts-button` rule with its
  55374. * different states.
  55375. *
  55376. * @sample {highstock} stock/rangeselector/styling/
  55377. * Styling the buttons and inputs
  55378. *
  55379. * @type {Highcharts.SVGAttributes}
  55380. */
  55381. buttonTheme: {
  55382. /** @ignore */
  55383. width: 28,
  55384. /** @ignore */
  55385. height: 18,
  55386. /** @ignore */
  55387. padding: 2,
  55388. /** @ignore */
  55389. zIndex: 7 // #484, #852
  55390. },
  55391. /**
  55392. * When the rangeselector is floating, the plot area does not reserve
  55393. * space for it. This opens for positioning anywhere on the chart.
  55394. *
  55395. * @sample {highstock} stock/rangeselector/floating/
  55396. * Placing the range selector between the plot area and the
  55397. * navigator
  55398. *
  55399. * @since 6.0.0
  55400. */
  55401. floating: false,
  55402. /**
  55403. * The x offset of the range selector relative to its horizontal
  55404. * alignment within `chart.spacingLeft` and `chart.spacingRight`.
  55405. *
  55406. * @since 6.0.0
  55407. */
  55408. x: 0,
  55409. /**
  55410. * The y offset of the range selector relative to its horizontal
  55411. * alignment within `chart.spacingLeft` and `chart.spacingRight`.
  55412. *
  55413. * @since 6.0.0
  55414. */
  55415. y: 0,
  55416. /**
  55417. * Deprecated. The height of the range selector. Currently it is
  55418. * calculated dynamically.
  55419. *
  55420. * @deprecated
  55421. * @type {number|undefined}
  55422. * @since 2.1.9
  55423. */
  55424. height: void 0,
  55425. /**
  55426. * The border color of the date input boxes.
  55427. *
  55428. * @sample {highstock} stock/rangeselector/styling/
  55429. * Styling the buttons and inputs
  55430. *
  55431. * @type {Highcharts.ColorString}
  55432. * @since 1.3.7
  55433. */
  55434. inputBoxBorderColor: 'none',
  55435. /**
  55436. * The pixel height of the date input boxes.
  55437. *
  55438. * @sample {highstock} stock/rangeselector/styling/
  55439. * Styling the buttons and inputs
  55440. *
  55441. * @since 1.3.7
  55442. */
  55443. inputBoxHeight: 17,
  55444. /**
  55445. * The pixel width of the date input boxes. When `undefined`, the width
  55446. * is fitted to the rendered content.
  55447. *
  55448. * @sample {highstock} stock/rangeselector/styling/
  55449. * Styling the buttons and inputs
  55450. *
  55451. * @type {number|undefined}
  55452. * @since 1.3.7
  55453. */
  55454. inputBoxWidth: void 0,
  55455. /**
  55456. * The date format in the input boxes when not selected for editing.
  55457. * Defaults to `%b %e, %Y`.
  55458. *
  55459. * This is used to determine which type of input to show,
  55460. * `datetime-local`, `date` or `time` and falling back to `text` when
  55461. * the browser does not support the input type or the format contains
  55462. * milliseconds.
  55463. *
  55464. * @sample {highstock} stock/rangeselector/input-type/
  55465. * Input types
  55466. * @sample {highstock} stock/rangeselector/input-format/
  55467. * Milliseconds in the range selector
  55468. *
  55469. */
  55470. inputDateFormat: '%b %e, %Y',
  55471. /**
  55472. * A custom callback function to parse values entered in the input boxes
  55473. * and return a valid JavaScript time as milliseconds since 1970.
  55474. * The first argument passed is a value to parse,
  55475. * second is a boolean indicating use of the UTC time.
  55476. *
  55477. * This will only get called for inputs of type `text`. Since v8.2.3,
  55478. * the input type is dynamically determined based on the granularity
  55479. * of the `inputDateFormat` and the browser support.
  55480. *
  55481. * @sample {highstock} stock/rangeselector/input-format/
  55482. * Milliseconds in the range selector
  55483. *
  55484. * @type {Highcharts.RangeSelectorParseCallbackFunction}
  55485. * @since 1.3.3
  55486. */
  55487. inputDateParser: void 0,
  55488. /**
  55489. * The date format in the input boxes when they are selected for
  55490. * editing. This must be a format that is recognized by JavaScript
  55491. * Date.parse.
  55492. *
  55493. * This will only be used for inputs of type `text`. Since v8.2.3,
  55494. * the input type is dynamically determined based on the granularity
  55495. * of the `inputDateFormat` and the browser support.
  55496. *
  55497. * @sample {highstock} stock/rangeselector/input-format/
  55498. * Milliseconds in the range selector
  55499. *
  55500. */
  55501. inputEditDateFormat: '%Y-%m-%d',
  55502. /**
  55503. * Enable or disable the date input boxes.
  55504. */
  55505. inputEnabled: true,
  55506. /**
  55507. * Positioning for the input boxes. Allowed properties are `align`,
  55508. * `x` and `y`.
  55509. *
  55510. * @since 1.2.4
  55511. */
  55512. inputPosition: {
  55513. /**
  55514. * The alignment of the input box. Allowed properties are `left`,
  55515. * `center`, `right`.
  55516. *
  55517. * @sample {highstock} stock/rangeselector/input-button-position/
  55518. * Alignment
  55519. *
  55520. * @type {Highcharts.AlignValue}
  55521. * @since 6.0.0
  55522. */
  55523. align: 'right',
  55524. /**
  55525. * X offset of the input row.
  55526. */
  55527. x: 0,
  55528. /**
  55529. * Y offset of the input row.
  55530. */
  55531. y: 0
  55532. },
  55533. /**
  55534. * The space in pixels between the labels and the date input boxes in
  55535. * the range selector.
  55536. *
  55537. * @since 9.0.0
  55538. */
  55539. inputSpacing: 5,
  55540. /**
  55541. * The index of the button to appear pre-selected.
  55542. *
  55543. * @type {number}
  55544. */
  55545. selected: void 0,
  55546. /**
  55547. * Positioning for the button row.
  55548. *
  55549. * @since 1.2.4
  55550. */
  55551. buttonPosition: {
  55552. /**
  55553. * The alignment of the input box. Allowed properties are `left`,
  55554. * `center`, `right`.
  55555. *
  55556. * @sample {highstock} stock/rangeselector/input-button-position/
  55557. * Alignment
  55558. *
  55559. * @type {Highcharts.AlignValue}
  55560. * @since 6.0.0
  55561. */
  55562. align: 'left',
  55563. /**
  55564. * X offset of the button row.
  55565. */
  55566. x: 0,
  55567. /**
  55568. * Y offset of the button row.
  55569. */
  55570. y: 0
  55571. },
  55572. /**
  55573. * CSS for the HTML inputs in the range selector.
  55574. *
  55575. * In styled mode, the inputs are styled by the
  55576. * `.highcharts-range-input text` rule in SVG mode, and
  55577. * `input.highcharts-range-selector` when active.
  55578. *
  55579. * @sample {highstock} stock/rangeselector/styling/
  55580. * Styling the buttons and inputs
  55581. *
  55582. * @type {Highcharts.CSSObject}
  55583. * @apioption rangeSelector.inputStyle
  55584. */
  55585. inputStyle: {
  55586. /** @ignore */
  55587. color: palette.highlightColor80,
  55588. /** @ignore */
  55589. cursor: 'pointer'
  55590. },
  55591. /**
  55592. * CSS styles for the labels - the Zoom, From and To texts.
  55593. *
  55594. * In styled mode, the labels are styled by the
  55595. * `.highcharts-range-label` class.
  55596. *
  55597. * @sample {highstock} stock/rangeselector/styling/
  55598. * Styling the buttons and inputs
  55599. *
  55600. * @type {Highcharts.CSSObject}
  55601. */
  55602. labelStyle: {
  55603. /** @ignore */
  55604. color: palette.neutralColor60
  55605. }
  55606. }
  55607. });
  55608. extend(defaultOptions.lang,
  55609. /**
  55610. * Language object. The language object is global and it can't be set
  55611. * on each chart initialization. Instead, use `Highcharts.setOptions` to
  55612. * set it before any chart is initialized.
  55613. *
  55614. * ```js
  55615. * Highcharts.setOptions({
  55616. * lang: {
  55617. * months: [
  55618. * 'Janvier', 'Février', 'Mars', 'Avril',
  55619. * 'Mai', 'Juin', 'Juillet', 'Août',
  55620. * 'Septembre', 'Octobre', 'Novembre', 'Décembre'
  55621. * ],
  55622. * weekdays: [
  55623. * 'Dimanche', 'Lundi', 'Mardi', 'Mercredi',
  55624. * 'Jeudi', 'Vendredi', 'Samedi'
  55625. * ]
  55626. * }
  55627. * });
  55628. * ```
  55629. *
  55630. * @optionparent lang
  55631. */
  55632. {
  55633. /**
  55634. * The text for the label for the range selector buttons.
  55635. *
  55636. * @product highstock gantt
  55637. */
  55638. rangeSelectorZoom: 'Zoom',
  55639. /**
  55640. * The text for the label for the "from" input box in the range
  55641. * selector. Since v9.0, this string is empty as the label is not
  55642. * rendered by default.
  55643. *
  55644. * @product highstock gantt
  55645. */
  55646. rangeSelectorFrom: '',
  55647. /**
  55648. * The text for the label for the "to" input box in the range selector.
  55649. *
  55650. * @product highstock gantt
  55651. */
  55652. rangeSelectorTo: '→'
  55653. });
  55654. /* eslint-disable no-invalid-this, valid-jsdoc */
  55655. /**
  55656. * The range selector.
  55657. *
  55658. * @private
  55659. * @class
  55660. * @name Highcharts.RangeSelector
  55661. * @param {Highcharts.Chart} chart
  55662. */
  55663. var RangeSelector = /** @class */ (function () {
  55664. function RangeSelector(chart) {
  55665. /* *
  55666. *
  55667. * Properties
  55668. *
  55669. * */
  55670. this.buttons = void 0;
  55671. this.buttonOptions = RangeSelector.prototype.defaultButtons;
  55672. this.initialButtonGroupWidth = 0;
  55673. this.options = void 0;
  55674. this.chart = chart;
  55675. // Run RangeSelector
  55676. this.init(chart);
  55677. }
  55678. /**
  55679. * The method to run when one of the buttons in the range selectors is
  55680. * clicked
  55681. *
  55682. * @private
  55683. * @function Highcharts.RangeSelector#clickButton
  55684. * @param {number} i
  55685. * The index of the button
  55686. * @param {boolean} [redraw]
  55687. * @return {void}
  55688. */
  55689. RangeSelector.prototype.clickButton = function (i, redraw) {
  55690. var rangeSelector = this,
  55691. chart = rangeSelector.chart,
  55692. rangeOptions = rangeSelector.buttonOptions[i],
  55693. baseAxis = chart.xAxis[0],
  55694. unionExtremes = (chart.scroller && chart.scroller.getUnionExtremes()) || baseAxis || {},
  55695. dataMin = unionExtremes.dataMin,
  55696. dataMax = unionExtremes.dataMax,
  55697. newMin,
  55698. newMax = baseAxis && Math.round(Math.min(baseAxis.max,
  55699. pick(dataMax,
  55700. baseAxis.max))), // #1568
  55701. type = rangeOptions.type,
  55702. baseXAxisOptions,
  55703. range = rangeOptions._range,
  55704. rangeMin,
  55705. minSetting,
  55706. rangeSetting,
  55707. ctx,
  55708. ytdExtremes,
  55709. dataGrouping = rangeOptions.dataGrouping;
  55710. // chart has no data, base series is removed
  55711. if (dataMin === null || dataMax === null) {
  55712. return;
  55713. }
  55714. // Set the fixed range before range is altered
  55715. chart.fixedRange = range;
  55716. rangeSelector.setSelected(i);
  55717. // Apply dataGrouping associated to button
  55718. if (dataGrouping) {
  55719. this.forcedDataGrouping = true;
  55720. Axis.prototype.setDataGrouping.call(baseAxis || { chart: this.chart }, dataGrouping, false);
  55721. this.frozenStates = rangeOptions.preserveDataGrouping;
  55722. }
  55723. // Apply range
  55724. if (type === 'month' || type === 'year') {
  55725. if (!baseAxis) {
  55726. // This is set to the user options and picked up later when the
  55727. // axis is instantiated so that we know the min and max.
  55728. range = rangeOptions;
  55729. }
  55730. else {
  55731. ctx = {
  55732. range: rangeOptions,
  55733. max: newMax,
  55734. chart: chart,
  55735. dataMin: dataMin,
  55736. dataMax: dataMax
  55737. };
  55738. newMin = baseAxis.minFromRange.call(ctx);
  55739. if (isNumber(ctx.newMax)) {
  55740. newMax = ctx.newMax;
  55741. }
  55742. }
  55743. // Fixed times like minutes, hours, days
  55744. }
  55745. else if (range) {
  55746. newMin = Math.max(newMax - range, dataMin);
  55747. newMax = Math.min(newMin + range, dataMax);
  55748. }
  55749. else if (type === 'ytd') {
  55750. // On user clicks on the buttons, or a delayed action running from
  55751. // the beforeRender event (below), the baseAxis is defined.
  55752. if (baseAxis) {
  55753. // When "ytd" is the pre-selected button for the initial view,
  55754. // its calculation is delayed and rerun in the beforeRender
  55755. // event (below). When the series are initialized, but before
  55756. // the chart is rendered, we have access to the xData array
  55757. // (#942).
  55758. if (typeof dataMax === 'undefined') {
  55759. dataMin = Number.MAX_VALUE;
  55760. dataMax = Number.MIN_VALUE;
  55761. chart.series.forEach(function (series) {
  55762. // reassign it to the last item
  55763. var xData = series.xData;
  55764. dataMin = Math.min(xData[0], dataMin);
  55765. dataMax = Math.max(xData[xData.length - 1], dataMax);
  55766. });
  55767. redraw = false;
  55768. }
  55769. ytdExtremes = rangeSelector.getYTDExtremes(dataMax, dataMin, chart.time.useUTC);
  55770. newMin = rangeMin = ytdExtremes.min;
  55771. newMax = ytdExtremes.max;
  55772. // "ytd" is pre-selected. We don't yet have access to processed
  55773. // point and extremes data (things like pointStart and pointInterval
  55774. // are missing), so we delay the process (#942)
  55775. }
  55776. else {
  55777. rangeSelector.deferredYTDClick = i;
  55778. return;
  55779. }
  55780. }
  55781. else if (type === 'all' && baseAxis) {
  55782. newMin = dataMin;
  55783. newMax = dataMax;
  55784. }
  55785. if (defined(newMin)) {
  55786. newMin += rangeOptions._offsetMin;
  55787. }
  55788. if (defined(newMax)) {
  55789. newMax += rangeOptions._offsetMax;
  55790. }
  55791. if (this.dropdown) {
  55792. this.dropdown.selectedIndex = i + 1;
  55793. }
  55794. // Update the chart
  55795. if (!baseAxis) {
  55796. // Axis not yet instanciated. Temporarily set min and range
  55797. // options and remove them on chart load (#4317).
  55798. baseXAxisOptions = splat(chart.options.xAxis)[0];
  55799. rangeSetting = baseXAxisOptions.range;
  55800. baseXAxisOptions.range = range;
  55801. minSetting = baseXAxisOptions.min;
  55802. baseXAxisOptions.min = rangeMin;
  55803. addEvent(chart, 'load', function resetMinAndRange() {
  55804. baseXAxisOptions.range = rangeSetting;
  55805. baseXAxisOptions.min = minSetting;
  55806. });
  55807. }
  55808. else {
  55809. // Existing axis object. Set extremes after render time.
  55810. baseAxis.setExtremes(newMin, newMax, pick(redraw, true), void 0, // auto animation
  55811. {
  55812. trigger: 'rangeSelectorButton',
  55813. rangeSelectorButton: rangeOptions
  55814. });
  55815. }
  55816. fireEvent(this, 'afterBtnClick');
  55817. };
  55818. /**
  55819. * Set the selected option. This method only sets the internal flag, it
  55820. * doesn't update the buttons or the actual zoomed range.
  55821. *
  55822. * @private
  55823. * @function Highcharts.RangeSelector#setSelected
  55824. * @param {number} [selected]
  55825. * @return {void}
  55826. */
  55827. RangeSelector.prototype.setSelected = function (selected) {
  55828. this.selected = this.options.selected = selected;
  55829. };
  55830. /**
  55831. * Initialize the range selector
  55832. *
  55833. * @private
  55834. * @function Highcharts.RangeSelector#init
  55835. * @param {Highcharts.Chart} chart
  55836. * @return {void}
  55837. */
  55838. RangeSelector.prototype.init = function (chart) {
  55839. var rangeSelector = this,
  55840. options = chart.options.rangeSelector,
  55841. buttonOptions = options.buttons || rangeSelector.defaultButtons.slice(),
  55842. selectedOption = options.selected,
  55843. blurInputs = function () {
  55844. var minInput = rangeSelector.minInput,
  55845. maxInput = rangeSelector.maxInput;
  55846. // #3274 in some case blur is not defined
  55847. if (minInput && minInput.blur) {
  55848. fireEvent(minInput, 'blur');
  55849. }
  55850. if (maxInput && maxInput.blur) {
  55851. fireEvent(maxInput, 'blur');
  55852. }
  55853. };
  55854. rangeSelector.chart = chart;
  55855. rangeSelector.options = options;
  55856. rangeSelector.buttons = [];
  55857. rangeSelector.buttonOptions = buttonOptions;
  55858. this.eventsToUnbind = [];
  55859. this.eventsToUnbind.push(addEvent(chart.container, 'mousedown', blurInputs));
  55860. this.eventsToUnbind.push(addEvent(chart, 'resize', blurInputs));
  55861. // Extend the buttonOptions with actual range
  55862. buttonOptions.forEach(rangeSelector.computeButtonRange);
  55863. // zoomed range based on a pre-selected button index
  55864. if (typeof selectedOption !== 'undefined' &&
  55865. buttonOptions[selectedOption]) {
  55866. this.clickButton(selectedOption, false);
  55867. }
  55868. this.eventsToUnbind.push(addEvent(chart, 'load', function () {
  55869. // If a data grouping is applied to the current button, release it
  55870. // when extremes change
  55871. if (chart.xAxis && chart.xAxis[0]) {
  55872. addEvent(chart.xAxis[0], 'setExtremes', function (e) {
  55873. if (this.max - this.min !==
  55874. chart.fixedRange &&
  55875. e.trigger !== 'rangeSelectorButton' &&
  55876. e.trigger !== 'updatedData' &&
  55877. rangeSelector.forcedDataGrouping &&
  55878. !rangeSelector.frozenStates) {
  55879. this.setDataGrouping(false, false);
  55880. }
  55881. });
  55882. }
  55883. }));
  55884. };
  55885. /**
  55886. * Dynamically update the range selector buttons after a new range has been
  55887. * set
  55888. *
  55889. * @private
  55890. * @function Highcharts.RangeSelector#updateButtonStates
  55891. * @return {void}
  55892. */
  55893. RangeSelector.prototype.updateButtonStates = function () {
  55894. var rangeSelector = this,
  55895. chart = this.chart,
  55896. dropdown = this.dropdown,
  55897. baseAxis = chart.xAxis[0],
  55898. actualRange = Math.round(baseAxis.max - baseAxis.min),
  55899. hasNoData = !baseAxis.hasVisibleSeries,
  55900. day = 24 * 36e5, // A single day in milliseconds
  55901. unionExtremes = (chart.scroller &&
  55902. chart.scroller.getUnionExtremes()) || baseAxis,
  55903. dataMin = unionExtremes.dataMin,
  55904. dataMax = unionExtremes.dataMax,
  55905. ytdExtremes = rangeSelector.getYTDExtremes(dataMax,
  55906. dataMin,
  55907. chart.time.useUTC),
  55908. ytdMin = ytdExtremes.min,
  55909. ytdMax = ytdExtremes.max,
  55910. selected = rangeSelector.selected,
  55911. selectedExists = isNumber(selected),
  55912. allButtonsEnabled = rangeSelector.options.allButtonsEnabled,
  55913. buttons = rangeSelector.buttons;
  55914. rangeSelector.buttonOptions.forEach(function (rangeOptions, i) {
  55915. var range = rangeOptions._range,
  55916. type = rangeOptions.type,
  55917. count = rangeOptions.count || 1,
  55918. button = buttons[i],
  55919. state = 0,
  55920. disable,
  55921. select,
  55922. offsetRange = rangeOptions._offsetMax -
  55923. rangeOptions._offsetMin,
  55924. isSelected = i === selected,
  55925. // Disable buttons where the range exceeds what is allowed in
  55926. // the current view
  55927. isTooGreatRange = range >
  55928. dataMax - dataMin,
  55929. // Disable buttons where the range is smaller than the minimum
  55930. // range
  55931. isTooSmallRange = range < baseAxis.minRange,
  55932. // Do not select the YTD button if not explicitly told so
  55933. isYTDButNotSelected = false,
  55934. // Disable the All button if we're already showing all
  55935. isAllButAlreadyShowingAll = false,
  55936. isSameRange = range === actualRange;
  55937. // Months and years have a variable range so we check the extremes
  55938. if ((type === 'month' || type === 'year') &&
  55939. (actualRange + 36e5 >=
  55940. { month: 28, year: 365 }[type] * day * count - offsetRange) &&
  55941. (actualRange - 36e5 <=
  55942. { month: 31, year: 366 }[type] * day * count + offsetRange)) {
  55943. isSameRange = true;
  55944. }
  55945. else if (type === 'ytd') {
  55946. isSameRange = (ytdMax - ytdMin + offsetRange) === actualRange;
  55947. isYTDButNotSelected = !isSelected;
  55948. }
  55949. else if (type === 'all') {
  55950. isSameRange = (baseAxis.max - baseAxis.min >=
  55951. dataMax - dataMin);
  55952. isAllButAlreadyShowingAll = (!isSelected &&
  55953. selectedExists &&
  55954. isSameRange);
  55955. }
  55956. // The new zoom area happens to match the range for a button - mark
  55957. // it selected. This happens when scrolling across an ordinal gap.
  55958. // It can be seen in the intraday demos when selecting 1h and scroll
  55959. // across the night gap.
  55960. disable = (!allButtonsEnabled &&
  55961. (isTooGreatRange ||
  55962. isTooSmallRange ||
  55963. isAllButAlreadyShowingAll ||
  55964. hasNoData));
  55965. select = ((isSelected && isSameRange) ||
  55966. (isSameRange && !selectedExists && !isYTDButNotSelected) ||
  55967. (isSelected && rangeSelector.frozenStates));
  55968. if (disable) {
  55969. state = 3;
  55970. }
  55971. else if (select) {
  55972. selectedExists = true; // Only one button can be selected
  55973. state = 2;
  55974. }
  55975. // If state has changed, update the button
  55976. if (button.state !== state) {
  55977. button.setState(state);
  55978. if (dropdown) {
  55979. dropdown.options[i + 1].disabled = disable;
  55980. if (state === 2) {
  55981. dropdown.selectedIndex = i + 1;
  55982. }
  55983. }
  55984. // Reset (#9209)
  55985. if (state === 0 && selected === i) {
  55986. rangeSelector.setSelected();
  55987. }
  55988. }
  55989. });
  55990. };
  55991. /**
  55992. * Compute and cache the range for an individual button
  55993. *
  55994. * @private
  55995. * @function Highcharts.RangeSelector#computeButtonRange
  55996. * @param {Highcharts.RangeSelectorButtonsOptions} rangeOptions
  55997. * @return {void}
  55998. */
  55999. RangeSelector.prototype.computeButtonRange = function (rangeOptions) {
  56000. var type = rangeOptions.type,
  56001. count = rangeOptions.count || 1,
  56002. // these time intervals have a fixed number of milliseconds, as
  56003. // opposed to month, ytd and year
  56004. fixedTimes = {
  56005. millisecond: 1,
  56006. second: 1000,
  56007. minute: 60 * 1000,
  56008. hour: 3600 * 1000,
  56009. day: 24 * 3600 * 1000,
  56010. week: 7 * 24 * 3600 * 1000
  56011. };
  56012. // Store the range on the button object
  56013. if (fixedTimes[type]) {
  56014. rangeOptions._range = fixedTimes[type] * count;
  56015. }
  56016. else if (type === 'month' || type === 'year') {
  56017. rangeOptions._range = {
  56018. month: 30,
  56019. year: 365
  56020. }[type] * 24 * 36e5 * count;
  56021. }
  56022. rangeOptions._offsetMin = pick(rangeOptions.offsetMin, 0);
  56023. rangeOptions._offsetMax = pick(rangeOptions.offsetMax, 0);
  56024. rangeOptions._range +=
  56025. rangeOptions._offsetMax - rangeOptions._offsetMin;
  56026. };
  56027. /**
  56028. * Get the unix timestamp of a HTML input for the dates
  56029. *
  56030. * @private
  56031. * @function Highcharts.RangeSelector#getInputValue
  56032. * @param {string} name
  56033. * @return {number}
  56034. */
  56035. RangeSelector.prototype.getInputValue = function (name) {
  56036. var input = name === 'min' ? this.minInput : this.maxInput;
  56037. var options = this.chart.options.rangeSelector;
  56038. var time = this.chart.time;
  56039. if (input) {
  56040. return ((input.type === 'text' && options.inputDateParser) ||
  56041. this.defaultInputDateParser)(input.value, time.useUTC, time);
  56042. }
  56043. return 0;
  56044. };
  56045. /**
  56046. * Set the internal and displayed value of a HTML input for the dates
  56047. *
  56048. * @private
  56049. * @function Highcharts.RangeSelector#setInputValue
  56050. * @param {string} name
  56051. * @param {number} [inputTime]
  56052. * @return {void}
  56053. */
  56054. RangeSelector.prototype.setInputValue = function (name, inputTime) {
  56055. var options = this.options, time = this.chart.time, input = name === 'min' ? this.minInput : this.maxInput, dateBox = name === 'min' ? this.minDateBox : this.maxDateBox;
  56056. if (input) {
  56057. var hcTimeAttr = input.getAttribute('data-hc-time');
  56058. var updatedTime = defined(hcTimeAttr) ? Number(hcTimeAttr) : void 0;
  56059. if (defined(inputTime)) {
  56060. var previousTime = updatedTime;
  56061. if (defined(previousTime)) {
  56062. input.setAttribute('data-hc-time-previous', previousTime);
  56063. }
  56064. input.setAttribute('data-hc-time', inputTime);
  56065. updatedTime = inputTime;
  56066. }
  56067. input.value = time.dateFormat(this.inputTypeFormats[input.type] || options.inputEditDateFormat, updatedTime);
  56068. if (dateBox) {
  56069. dateBox.attr({
  56070. text: time.dateFormat(options.inputDateFormat, updatedTime)
  56071. });
  56072. }
  56073. }
  56074. };
  56075. /**
  56076. * Set the min and max value of a HTML input for the dates
  56077. *
  56078. * @private
  56079. * @function Highcharts.RangeSelector#setInputExtremes
  56080. * @param {string} name
  56081. * @param {number} min
  56082. * @param {number} max
  56083. * @return {void}
  56084. */
  56085. RangeSelector.prototype.setInputExtremes = function (name, min, max) {
  56086. var input = name === 'min' ? this.minInput : this.maxInput;
  56087. if (input) {
  56088. var format = this.inputTypeFormats[input.type];
  56089. var time = this.chart.time;
  56090. if (format) {
  56091. var newMin = time.dateFormat(format,
  56092. min);
  56093. if (input.min !== newMin) {
  56094. input.min = newMin;
  56095. }
  56096. var newMax = time.dateFormat(format,
  56097. max);
  56098. if (input.max !== newMax) {
  56099. input.max = newMax;
  56100. }
  56101. }
  56102. }
  56103. };
  56104. /**
  56105. * @private
  56106. * @function Highcharts.RangeSelector#showInput
  56107. * @param {string} name
  56108. * @return {void}
  56109. */
  56110. RangeSelector.prototype.showInput = function (name) {
  56111. var dateBox = name === 'min' ? this.minDateBox : this.maxDateBox;
  56112. var input = name === 'min' ? this.minInput : this.maxInput;
  56113. if (input && dateBox && this.inputGroup) {
  56114. var isTextInput = input.type === 'text';
  56115. var _a = this.inputGroup,
  56116. translateX = _a.translateX,
  56117. translateY = _a.translateY;
  56118. var inputBoxWidth = this.options.inputBoxWidth;
  56119. css(input, {
  56120. width: isTextInput ? ((dateBox.width + (inputBoxWidth ? -2 : 20)) + 'px') : 'auto',
  56121. height: isTextInput ? ((dateBox.height - 2) + 'px') : 'auto',
  56122. border: '2px solid silver'
  56123. });
  56124. if (isTextInput && inputBoxWidth) {
  56125. css(input, {
  56126. left: (translateX + dateBox.x) + 'px',
  56127. top: translateY + 'px'
  56128. });
  56129. // Inputs of types date, time or datetime-local should be centered
  56130. // on top of the dateBox
  56131. }
  56132. else {
  56133. css(input, {
  56134. left: Math.min(Math.round(dateBox.x +
  56135. translateX -
  56136. (input.offsetWidth - dateBox.width) / 2), this.chart.chartWidth - input.offsetWidth) + 'px',
  56137. top: (translateY - 1 - (input.offsetHeight - dateBox.height) / 2) + 'px'
  56138. });
  56139. }
  56140. }
  56141. };
  56142. /**
  56143. * @private
  56144. * @function Highcharts.RangeSelector#hideInput
  56145. * @param {string} name
  56146. * @return {void}
  56147. */
  56148. RangeSelector.prototype.hideInput = function (name) {
  56149. var input = name === 'min' ? this.minInput : this.maxInput;
  56150. if (input) {
  56151. css(input, {
  56152. top: '-9999em',
  56153. border: 0,
  56154. width: '1px',
  56155. height: '1px'
  56156. });
  56157. }
  56158. };
  56159. /**
  56160. * @private
  56161. * @function Highcharts.RangeSelector#defaultInputDateParser
  56162. */
  56163. RangeSelector.prototype.defaultInputDateParser = function (inputDate, useUTC, time) {
  56164. var hasTimezone = function (str) {
  56165. return str.length > 6 &&
  56166. (str.lastIndexOf('-') === str.length - 6 ||
  56167. str.lastIndexOf('+') === str.length - 6);
  56168. };
  56169. var input = inputDate.split('/').join('-').split(' ').join('T');
  56170. if (input.indexOf('T') === -1) {
  56171. input += 'T00:00';
  56172. }
  56173. if (useUTC) {
  56174. input += 'Z';
  56175. }
  56176. else if (H.isSafari && !hasTimezone(input)) {
  56177. var offset = new Date(input).getTimezoneOffset() / 60;
  56178. input += offset <= 0 ? "+" + pad(-offset) + ":00" : "-" + pad(offset) + ":00";
  56179. }
  56180. var date = Date.parse(input);
  56181. // If the value isn't parsed directly to a value by the
  56182. // browser's Date.parse method, like YYYY-MM-DD in IE8, try
  56183. // parsing it a different way
  56184. if (!isNumber(date)) {
  56185. var parts = inputDate.split('-');
  56186. date = Date.UTC(pInt(parts[0]), pInt(parts[1]) - 1, pInt(parts[2]));
  56187. }
  56188. if (time && useUTC && isNumber(date)) {
  56189. date += time.getTimezoneOffset(date);
  56190. }
  56191. return date;
  56192. };
  56193. /**
  56194. * Draw either the 'from' or the 'to' HTML input box of the range selector
  56195. *
  56196. * @private
  56197. * @function Highcharts.RangeSelector#drawInput
  56198. * @param {string} name
  56199. * @return {RangeSelectorInputElements}
  56200. */
  56201. RangeSelector.prototype.drawInput = function (name) {
  56202. var _a = this,
  56203. chart = _a.chart,
  56204. div = _a.div,
  56205. inputGroup = _a.inputGroup;
  56206. var rangeSelector = this,
  56207. chartStyle = chart.renderer.style || {},
  56208. renderer = chart.renderer,
  56209. options = chart.options.rangeSelector,
  56210. lang = defaultOptions.lang,
  56211. isMin = name === 'min';
  56212. /**
  56213. * @private
  56214. */
  56215. function updateExtremes() {
  56216. var value = rangeSelector.getInputValue(name),
  56217. chartAxis = chart.xAxis[0],
  56218. dataAxis = chart.scroller && chart.scroller.xAxis ?
  56219. chart.scroller.xAxis :
  56220. chartAxis,
  56221. dataMin = dataAxis.dataMin,
  56222. dataMax = dataAxis.dataMax;
  56223. var maxInput = rangeSelector.maxInput,
  56224. minInput = rangeSelector.minInput;
  56225. if (value !== Number(input.getAttribute('data-hc-time-previous')) &&
  56226. isNumber(value)) {
  56227. input.setAttribute('data-hc-time-previous', value);
  56228. // Validate the extremes. If it goes beyound the data min or
  56229. // max, use the actual data extreme (#2438).
  56230. if (isMin && maxInput && isNumber(dataMin)) {
  56231. if (value > Number(maxInput.getAttribute('data-hc-time'))) {
  56232. value = void 0;
  56233. }
  56234. else if (value < dataMin) {
  56235. value = dataMin;
  56236. }
  56237. }
  56238. else if (minInput && isNumber(dataMax)) {
  56239. if (value < Number(minInput.getAttribute('data-hc-time'))) {
  56240. value = void 0;
  56241. }
  56242. else if (value > dataMax) {
  56243. value = dataMax;
  56244. }
  56245. }
  56246. // Set the extremes
  56247. if (typeof value !== 'undefined') { // @todo typof undefined
  56248. chartAxis.setExtremes(isMin ? value : chartAxis.min, isMin ? chartAxis.max : value, void 0, void 0, { trigger: 'rangeSelectorInput' });
  56249. }
  56250. }
  56251. }
  56252. // Create the text label
  56253. var text = lang[isMin ? 'rangeSelectorFrom' : 'rangeSelectorTo'];
  56254. var label = renderer
  56255. .label(text, 0)
  56256. .addClass('highcharts-range-label')
  56257. .attr({
  56258. padding: text ? 2 : 0
  56259. })
  56260. .add(inputGroup);
  56261. // Create an SVG label that shows updated date ranges and and records
  56262. // click events that bring in the HTML input.
  56263. var dateBox = renderer
  56264. .label('', 0)
  56265. .addClass('highcharts-range-input')
  56266. .attr({
  56267. padding: 2,
  56268. width: options.inputBoxWidth,
  56269. height: options.inputBoxHeight,
  56270. 'text-align': 'center'
  56271. })
  56272. .on('click',
  56273. function () {
  56274. // If it is already focused, the onfocus event doesn't fire
  56275. // (#3713)
  56276. rangeSelector.showInput(name);
  56277. rangeSelector[name + 'Input'].focus();
  56278. });
  56279. if (!chart.styledMode) {
  56280. dateBox.attr({
  56281. stroke: options.inputBoxBorderColor,
  56282. 'stroke-width': 1
  56283. });
  56284. }
  56285. dateBox.add(inputGroup);
  56286. // Create the HTML input element. This is rendered as 1x1 pixel then set
  56287. // to the right size when focused.
  56288. var input = createElement('input', {
  56289. name: name,
  56290. className: 'highcharts-range-selector'
  56291. },
  56292. void 0,
  56293. div);
  56294. // #14788: Setting input.type to an unsupported type throws in IE, so
  56295. // we need to use setAttribute instead
  56296. input.setAttribute('type', preferredInputType(options.inputDateFormat || '%b %e, %Y'));
  56297. if (!chart.styledMode) {
  56298. // Styles
  56299. label.css(merge(chartStyle, options.labelStyle));
  56300. dateBox.css(merge({
  56301. color: palette.neutralColor80
  56302. }, chartStyle, options.inputStyle));
  56303. css(input, extend({
  56304. position: 'absolute',
  56305. border: 0,
  56306. boxShadow: '0 0 15px rgba(0,0,0,0.3)',
  56307. width: '1px',
  56308. height: '1px',
  56309. padding: 0,
  56310. textAlign: 'center',
  56311. fontSize: chartStyle.fontSize,
  56312. fontFamily: chartStyle.fontFamily,
  56313. top: '-9999em' // #4798
  56314. }, options.inputStyle));
  56315. }
  56316. // Blow up the input box
  56317. input.onfocus = function () {
  56318. rangeSelector.showInput(name);
  56319. };
  56320. // Hide away the input box
  56321. input.onblur = function () {
  56322. // update extermes only when inputs are active
  56323. if (input === H.doc.activeElement) { // Only when focused
  56324. // Update also when no `change` event is triggered, like when
  56325. // clicking inside the SVG (#4710)
  56326. updateExtremes();
  56327. }
  56328. // #10404 - move hide and blur outside focus
  56329. rangeSelector.hideInput(name);
  56330. rangeSelector.setInputValue(name);
  56331. input.blur(); // #4606
  56332. };
  56333. var keyDown = false;
  56334. // handle changes in the input boxes
  56335. input.onchange = function () {
  56336. // Update extremes and blur input when clicking date input calendar
  56337. if (!keyDown) {
  56338. updateExtremes();
  56339. rangeSelector.hideInput(name);
  56340. input.blur();
  56341. }
  56342. };
  56343. input.onkeypress = function (event) {
  56344. // IE does not fire onchange on enter
  56345. if (event.keyCode === 13) {
  56346. updateExtremes();
  56347. }
  56348. };
  56349. input.onkeydown = function (event) {
  56350. keyDown = true;
  56351. // Arrow keys
  56352. if (event.keyCode === 38 || event.keyCode === 40) {
  56353. updateExtremes();
  56354. }
  56355. };
  56356. input.onkeyup = function () {
  56357. keyDown = false;
  56358. };
  56359. return { dateBox: dateBox, input: input, label: label };
  56360. };
  56361. /**
  56362. * Get the position of the range selector buttons and inputs. This can be
  56363. * overridden from outside for custom positioning.
  56364. *
  56365. * @private
  56366. * @function Highcharts.RangeSelector#getPosition
  56367. *
  56368. * @return {Highcharts.Dictionary<number>}
  56369. */
  56370. RangeSelector.prototype.getPosition = function () {
  56371. var chart = this.chart,
  56372. options = chart.options.rangeSelector,
  56373. top = options.verticalAlign === 'top' ?
  56374. chart.plotTop - chart.axisOffset[0] :
  56375. 0; // set offset only for varticalAlign top
  56376. return {
  56377. buttonTop: top + options.buttonPosition.y,
  56378. inputTop: top + options.inputPosition.y - 10
  56379. };
  56380. };
  56381. /**
  56382. * Get the extremes of YTD. Will choose dataMax if its value is lower than
  56383. * the current timestamp. Will choose dataMin if its value is higher than
  56384. * the timestamp for the start of current year.
  56385. *
  56386. * @private
  56387. * @function Highcharts.RangeSelector#getYTDExtremes
  56388. *
  56389. * @param {number} dataMax
  56390. *
  56391. * @param {number} dataMin
  56392. *
  56393. * @return {*}
  56394. * Returns min and max for the YTD
  56395. */
  56396. RangeSelector.prototype.getYTDExtremes = function (dataMax, dataMin, useUTC) {
  56397. var time = this.chart.time,
  56398. min,
  56399. now = new time.Date(dataMax),
  56400. year = time.get('FullYear',
  56401. now),
  56402. startOfYear = useUTC ?
  56403. time.Date.UTC(year, 0, 1) : // eslint-disable-line new-cap
  56404. +new time.Date(year, 0, 1);
  56405. min = Math.max(dataMin, startOfYear);
  56406. var ts = now.getTime();
  56407. return {
  56408. max: Math.min(dataMax || ts, ts),
  56409. min: min
  56410. };
  56411. };
  56412. /**
  56413. * Render the range selector including the buttons and the inputs. The first
  56414. * time render is called, the elements are created and positioned. On
  56415. * subsequent calls, they are moved and updated.
  56416. *
  56417. * @private
  56418. * @function Highcharts.RangeSelector#render
  56419. * @param {number} [min]
  56420. * X axis minimum
  56421. * @param {number} [max]
  56422. * X axis maximum
  56423. * @return {void}
  56424. */
  56425. RangeSelector.prototype.render = function (min, max) {
  56426. var chart = this.chart,
  56427. renderer = chart.renderer,
  56428. container = chart.container,
  56429. chartOptions = chart.options,
  56430. options = chartOptions.rangeSelector,
  56431. // Place inputs above the container
  56432. inputsZIndex = pick(chartOptions.chart.style &&
  56433. chartOptions.chart.style.zIndex, 0) + 1,
  56434. inputEnabled = options.inputEnabled,
  56435. rendered = this.rendered;
  56436. if (options.enabled === false) {
  56437. return;
  56438. }
  56439. // create the elements
  56440. if (!rendered) {
  56441. this.group = renderer.g('range-selector-group')
  56442. .attr({
  56443. zIndex: 7
  56444. })
  56445. .add();
  56446. this.div = createElement('div', void 0, {
  56447. position: 'relative',
  56448. height: 0,
  56449. zIndex: inputsZIndex
  56450. });
  56451. if (this.buttonOptions.length) {
  56452. this.renderButtons();
  56453. }
  56454. // First create a wrapper outside the container in order to make
  56455. // the inputs work and make export correct
  56456. if (container.parentNode) {
  56457. container.parentNode.insertBefore(this.div, container);
  56458. }
  56459. if (inputEnabled) {
  56460. // Create the group to keep the inputs
  56461. this.inputGroup = renderer.g('input-group').add(this.group);
  56462. var minElems = this.drawInput('min');
  56463. this.minDateBox = minElems.dateBox;
  56464. this.minLabel = minElems.label;
  56465. this.minInput = minElems.input;
  56466. var maxElems = this.drawInput('max');
  56467. this.maxDateBox = maxElems.dateBox;
  56468. this.maxLabel = maxElems.label;
  56469. this.maxInput = maxElems.input;
  56470. }
  56471. }
  56472. if (inputEnabled) {
  56473. // Set or reset the input values
  56474. this.setInputValue('min', min);
  56475. this.setInputValue('max', max);
  56476. var unionExtremes = (chart.scroller && chart.scroller.getUnionExtremes()) || chart.xAxis[0] || {};
  56477. if (defined(unionExtremes.dataMin) && defined(unionExtremes.dataMax)) {
  56478. var minRange = chart.xAxis[0].minRange || 0;
  56479. this.setInputExtremes('min', unionExtremes.dataMin, Math.min(unionExtremes.dataMax, this.getInputValue('max')) - minRange);
  56480. this.setInputExtremes('max', Math.max(unionExtremes.dataMin, this.getInputValue('min')) + minRange, unionExtremes.dataMax);
  56481. }
  56482. // Reflow
  56483. if (this.inputGroup) {
  56484. var x_1 = 0;
  56485. [
  56486. this.minLabel,
  56487. this.minDateBox,
  56488. this.maxLabel,
  56489. this.maxDateBox
  56490. ].forEach(function (label) {
  56491. if (label) {
  56492. var width = label.getBBox().width;
  56493. if (width) {
  56494. label.attr({ x: x_1 });
  56495. x_1 += width + options.inputSpacing;
  56496. }
  56497. }
  56498. });
  56499. }
  56500. }
  56501. this.alignElements();
  56502. this.rendered = true;
  56503. };
  56504. /**
  56505. * Render the range buttons. This only runs the first time, later the
  56506. * positioning is laid out in alignElements.
  56507. *
  56508. * @private
  56509. * @function Highcharts.RangeSelector#renderButtons
  56510. * @return {void}
  56511. */
  56512. RangeSelector.prototype.renderButtons = function () {
  56513. var _this = this;
  56514. var _a = this,
  56515. buttons = _a.buttons,
  56516. chart = _a.chart,
  56517. options = _a.options;
  56518. var lang = defaultOptions.lang;
  56519. var renderer = chart.renderer;
  56520. var buttonTheme = merge(options.buttonTheme);
  56521. var states = buttonTheme && buttonTheme.states;
  56522. // Prevent the button from resetting the width when the button state
  56523. // changes since we need more control over the width when collapsing
  56524. // the buttons
  56525. var width = buttonTheme.width || 28;
  56526. delete buttonTheme.width;
  56527. delete buttonTheme.states;
  56528. this.buttonGroup = renderer.g('range-selector-buttons').add(this.group);
  56529. var dropdown = this.dropdown = createElement('select',
  56530. void 0, {
  56531. position: 'absolute',
  56532. width: '1px',
  56533. height: '1px',
  56534. padding: 0,
  56535. border: 0,
  56536. top: '-9999em',
  56537. cursor: 'pointer',
  56538. opacity: 0.0001
  56539. },
  56540. this.div);
  56541. // Prevent page zoom on iPhone
  56542. addEvent(dropdown, 'touchstart', function () {
  56543. dropdown.style.fontSize = '16px';
  56544. });
  56545. // Forward events from select to button
  56546. [
  56547. [H.isMS ? 'mouseover' : 'mouseenter'],
  56548. [H.isMS ? 'mouseout' : 'mouseleave'],
  56549. ['change', 'click']
  56550. ].forEach(function (_a) {
  56551. var from = _a[0],
  56552. to = _a[1];
  56553. addEvent(dropdown, from, function () {
  56554. var button = buttons[_this.currentButtonIndex()];
  56555. if (button) {
  56556. fireEvent(button.element, to || from);
  56557. }
  56558. });
  56559. });
  56560. this.zoomText = renderer
  56561. .text(lang.rangeSelectorZoom, 0, 15)
  56562. .add(this.buttonGroup);
  56563. if (!this.chart.styledMode) {
  56564. this.zoomText.css(options.labelStyle);
  56565. buttonTheme['stroke-width'] = pick(buttonTheme['stroke-width'], 0);
  56566. }
  56567. createElement('option', {
  56568. textContent: this.zoomText.textStr,
  56569. disabled: true
  56570. }, void 0, dropdown);
  56571. this.buttonOptions.forEach(function (rangeOptions, i) {
  56572. createElement('option', {
  56573. textContent: rangeOptions.title || rangeOptions.text
  56574. }, void 0, dropdown);
  56575. buttons[i] = renderer
  56576. .button(rangeOptions.text, 0, 0, function (e) {
  56577. // extract events from button object and call
  56578. var buttonEvents = (rangeOptions.events &&
  56579. rangeOptions.events.click),
  56580. callDefaultEvent;
  56581. if (buttonEvents) {
  56582. callDefaultEvent =
  56583. buttonEvents.call(rangeOptions, e);
  56584. }
  56585. if (callDefaultEvent !== false) {
  56586. _this.clickButton(i);
  56587. }
  56588. _this.isActive = true;
  56589. }, buttonTheme, states && states.hover, states && states.select, states && states.disabled)
  56590. .attr({
  56591. 'text-align': 'center',
  56592. width: width
  56593. })
  56594. .add(_this.buttonGroup);
  56595. if (rangeOptions.title) {
  56596. buttons[i].attr('title', rangeOptions.title);
  56597. }
  56598. });
  56599. };
  56600. /**
  56601. * Align the elements horizontally and vertically.
  56602. *
  56603. * @private
  56604. * @function Highcharts.RangeSelector#alignElements
  56605. * @return {void}
  56606. */
  56607. RangeSelector.prototype.alignElements = function () {
  56608. var _this = this;
  56609. var _a = this,
  56610. buttonGroup = _a.buttonGroup,
  56611. buttons = _a.buttons,
  56612. chart = _a.chart,
  56613. group = _a.group,
  56614. inputGroup = _a.inputGroup,
  56615. options = _a.options,
  56616. zoomText = _a.zoomText;
  56617. var chartOptions = chart.options;
  56618. var navButtonOptions = (chartOptions.exporting &&
  56619. chartOptions.exporting.enabled !== false &&
  56620. chartOptions.navigation &&
  56621. chartOptions.navigation.buttonOptions);
  56622. var buttonPosition = options.buttonPosition,
  56623. inputPosition = options.inputPosition,
  56624. verticalAlign = options.verticalAlign;
  56625. // Get the X offset required to avoid overlapping with the exporting
  56626. // button. This is is used both by the buttonGroup and the inputGroup.
  56627. var getXOffsetForExportButton = function (group,
  56628. position) {
  56629. if (navButtonOptions &&
  56630. _this.titleCollision(chart) &&
  56631. verticalAlign === 'top' &&
  56632. position.align === 'right' && ((position.y -
  56633. group.getBBox().height - 12) <
  56634. ((navButtonOptions.y || 0) +
  56635. (navButtonOptions.height || 0) +
  56636. chart.spacing[0]))) {
  56637. return -40;
  56638. }
  56639. return 0;
  56640. };
  56641. var plotLeft = chart.plotLeft;
  56642. if (group && buttonPosition && inputPosition) {
  56643. var translateX = buttonPosition.x - chart.spacing[3];
  56644. if (buttonGroup) {
  56645. this.positionButtons();
  56646. if (!this.initialButtonGroupWidth) {
  56647. var width_1 = 0;
  56648. if (zoomText) {
  56649. width_1 += zoomText.getBBox().width + 5;
  56650. }
  56651. buttons.forEach(function (button, i) {
  56652. width_1 += button.width;
  56653. if (i !== buttons.length - 1) {
  56654. width_1 += options.buttonSpacing;
  56655. }
  56656. });
  56657. this.initialButtonGroupWidth = width_1;
  56658. }
  56659. plotLeft -= chart.spacing[3];
  56660. this.updateButtonStates();
  56661. // Detect collision between button group and exporting
  56662. var xOffsetForExportButton_1 = getXOffsetForExportButton(buttonGroup,
  56663. buttonPosition);
  56664. this.alignButtonGroup(xOffsetForExportButton_1);
  56665. // Skip animation
  56666. group.placed = buttonGroup.placed = chart.hasLoaded;
  56667. }
  56668. var xOffsetForExportButton = 0;
  56669. if (inputGroup) {
  56670. // Detect collision between the input group and exporting button
  56671. xOffsetForExportButton = getXOffsetForExportButton(inputGroup, inputPosition);
  56672. if (inputPosition.align === 'left') {
  56673. translateX = plotLeft;
  56674. }
  56675. else if (inputPosition.align === 'right') {
  56676. translateX = -Math.max(chart.axisOffset[1], -xOffsetForExportButton);
  56677. }
  56678. // Update the alignment to the updated spacing box
  56679. inputGroup.align({
  56680. y: inputPosition.y,
  56681. width: inputGroup.getBBox().width,
  56682. align: inputPosition.align,
  56683. // fix wrong getBBox() value on right align
  56684. x: inputPosition.x + translateX - 2
  56685. }, true, chart.spacingBox);
  56686. // Skip animation
  56687. inputGroup.placed = chart.hasLoaded;
  56688. }
  56689. this.handleCollision(xOffsetForExportButton);
  56690. // Vertical align
  56691. group.align({
  56692. verticalAlign: verticalAlign
  56693. }, true, chart.spacingBox);
  56694. var alignTranslateY = group.alignAttr.translateY;
  56695. // Set position
  56696. var groupHeight = group.getBBox().height + 20; // # 20 padding
  56697. var translateY = 0;
  56698. // Calculate bottom position
  56699. if (verticalAlign === 'bottom') {
  56700. var legendOptions = chart.legend && chart.legend.options;
  56701. var legendHeight = (legendOptions &&
  56702. legendOptions.verticalAlign === 'bottom' &&
  56703. legendOptions.enabled &&
  56704. !legendOptions.floating ?
  56705. (chart.legend.legendHeight +
  56706. pick(legendOptions.margin, 10)) :
  56707. 0);
  56708. groupHeight = groupHeight + legendHeight - 20;
  56709. translateY = (alignTranslateY -
  56710. groupHeight -
  56711. (options.floating ? 0 : options.y) -
  56712. (chart.titleOffset ? chart.titleOffset[2] : 0) -
  56713. 10 // 10 spacing
  56714. );
  56715. }
  56716. if (verticalAlign === 'top') {
  56717. if (options.floating) {
  56718. translateY = 0;
  56719. }
  56720. if (chart.titleOffset && chart.titleOffset[0]) {
  56721. translateY = chart.titleOffset[0];
  56722. }
  56723. translateY += ((chart.margin[0] - chart.spacing[0]) || 0);
  56724. }
  56725. else if (verticalAlign === 'middle') {
  56726. if (inputPosition.y === buttonPosition.y) {
  56727. translateY = alignTranslateY;
  56728. }
  56729. else if (inputPosition.y || buttonPosition.y) {
  56730. if (inputPosition.y < 0 ||
  56731. buttonPosition.y < 0) {
  56732. translateY -= Math.min(inputPosition.y, buttonPosition.y);
  56733. }
  56734. else {
  56735. translateY = alignTranslateY - groupHeight;
  56736. }
  56737. }
  56738. }
  56739. group.translate(options.x, options.y + Math.floor(translateY));
  56740. // Translate HTML inputs
  56741. var _b = this,
  56742. minInput = _b.minInput,
  56743. maxInput = _b.maxInput,
  56744. dropdown = _b.dropdown;
  56745. if (options.inputEnabled && minInput && maxInput) {
  56746. minInput.style.marginTop = group.translateY + 'px';
  56747. maxInput.style.marginTop = group.translateY + 'px';
  56748. }
  56749. if (dropdown) {
  56750. dropdown.style.marginTop = group.translateY + 'px';
  56751. }
  56752. }
  56753. };
  56754. /**
  56755. * Align the button group horizontally and vertically.
  56756. *
  56757. * @private
  56758. * @function Highcharts.RangeSelector#alignButtonGroup
  56759. * @param {number} xOffsetForExportButton
  56760. * @param {number} [width]
  56761. * @return {void}
  56762. */
  56763. RangeSelector.prototype.alignButtonGroup = function (xOffsetForExportButton, width) {
  56764. var _a = this,
  56765. chart = _a.chart,
  56766. options = _a.options,
  56767. buttonGroup = _a.buttonGroup,
  56768. buttons = _a.buttons;
  56769. var buttonPosition = options.buttonPosition;
  56770. var plotLeft = chart.plotLeft - chart.spacing[3];
  56771. var translateX = buttonPosition.x - chart.spacing[3];
  56772. if (buttonPosition.align === 'right') {
  56773. translateX += xOffsetForExportButton - plotLeft; // #13014
  56774. }
  56775. else if (buttonPosition.align === 'center') {
  56776. translateX -= plotLeft / 2;
  56777. }
  56778. if (buttonGroup) {
  56779. // Align button group
  56780. buttonGroup.align({
  56781. y: buttonPosition.y,
  56782. width: pick(width, this.initialButtonGroupWidth),
  56783. align: buttonPosition.align,
  56784. x: translateX
  56785. }, true, chart.spacingBox);
  56786. }
  56787. };
  56788. /**
  56789. * @private
  56790. * @function Highcharts.RangeSelector#positionButtons
  56791. * @return {void}
  56792. */
  56793. RangeSelector.prototype.positionButtons = function () {
  56794. var _a = this,
  56795. buttons = _a.buttons,
  56796. chart = _a.chart,
  56797. options = _a.options,
  56798. zoomText = _a.zoomText;
  56799. var verb = chart.hasLoaded ? 'animate' : 'attr';
  56800. var buttonPosition = options.buttonPosition;
  56801. var plotLeft = chart.plotLeft;
  56802. var buttonLeft = plotLeft;
  56803. if (zoomText && zoomText.visibility !== 'hidden') {
  56804. // #8769, allow dynamically updating margins
  56805. zoomText[verb]({
  56806. x: pick(plotLeft + buttonPosition.x, plotLeft)
  56807. });
  56808. // Button start position
  56809. buttonLeft += buttonPosition.x +
  56810. zoomText.getBBox().width + 5;
  56811. }
  56812. this.buttonOptions.forEach(function (rangeOptions, i) {
  56813. if (buttons[i].visibility !== 'hidden') {
  56814. buttons[i][verb]({ x: buttonLeft });
  56815. // increase button position for the next button
  56816. buttonLeft += buttons[i].width + options.buttonSpacing;
  56817. }
  56818. else {
  56819. buttons[i][verb]({ x: plotLeft });
  56820. }
  56821. });
  56822. };
  56823. /**
  56824. * Handle collision between the button group and the input group
  56825. *
  56826. * @private
  56827. * @function Highcharts.RangeSelector#handleCollision
  56828. *
  56829. * @param {number} xOffsetForExportButton
  56830. * The X offset of the group required to make room for the
  56831. * exporting button
  56832. * @return {void}
  56833. */
  56834. RangeSelector.prototype.handleCollision = function (xOffsetForExportButton) {
  56835. var _this = this;
  56836. var _a = this,
  56837. chart = _a.chart,
  56838. buttonGroup = _a.buttonGroup,
  56839. inputGroup = _a.inputGroup;
  56840. var _b = this.options,
  56841. buttonPosition = _b.buttonPosition,
  56842. dropdown = _b.dropdown,
  56843. inputPosition = _b.inputPosition;
  56844. var maxButtonWidth = function () {
  56845. var buttonWidth = 0;
  56846. _this.buttons.forEach(function (button) {
  56847. var bBox = button.getBBox();
  56848. if (bBox.width > buttonWidth) {
  56849. buttonWidth = bBox.width;
  56850. }
  56851. });
  56852. return buttonWidth;
  56853. };
  56854. var groupsOverlap = function (buttonGroupWidth) {
  56855. if (inputGroup && buttonGroup) {
  56856. var inputGroupX = (inputGroup.alignAttr.translateX +
  56857. inputGroup.alignOptions.x -
  56858. xOffsetForExportButton +
  56859. // getBBox for detecing left margin
  56860. inputGroup.getBBox().x +
  56861. // 2px padding to not overlap input and label
  56862. 2);
  56863. var inputGroupWidth = inputGroup.alignOptions.width;
  56864. var buttonGroupX = buttonGroup.alignAttr.translateX +
  56865. buttonGroup.getBBox().x;
  56866. return (buttonGroupX + buttonGroupWidth > inputGroupX) &&
  56867. (inputGroupX + inputGroupWidth > buttonGroupX) &&
  56868. (buttonPosition.y <
  56869. (inputPosition.y +
  56870. inputGroup.getBBox().height));
  56871. }
  56872. return false;
  56873. };
  56874. var moveInputsDown = function () {
  56875. if (inputGroup && buttonGroup) {
  56876. inputGroup.attr({
  56877. translateX: inputGroup.alignAttr.translateX + (chart.axisOffset[1] >= -xOffsetForExportButton ?
  56878. 0 :
  56879. -xOffsetForExportButton),
  56880. translateY: inputGroup.alignAttr.translateY +
  56881. buttonGroup.getBBox().height + 10
  56882. });
  56883. }
  56884. };
  56885. if (buttonGroup) {
  56886. if (dropdown === 'always') {
  56887. this.collapseButtons(xOffsetForExportButton);
  56888. if (groupsOverlap(maxButtonWidth())) {
  56889. // Move the inputs down if there is still a collision
  56890. // after collapsing the buttons
  56891. moveInputsDown();
  56892. }
  56893. return;
  56894. }
  56895. if (dropdown === 'never') {
  56896. this.expandButtons();
  56897. }
  56898. }
  56899. // Detect collision
  56900. if (inputGroup && buttonGroup) {
  56901. if ((inputPosition.align === buttonPosition.align) ||
  56902. // 20 is minimal spacing between elements
  56903. groupsOverlap(this.initialButtonGroupWidth + 20)) {
  56904. if (dropdown === 'responsive') {
  56905. this.collapseButtons(xOffsetForExportButton);
  56906. if (groupsOverlap(maxButtonWidth())) {
  56907. moveInputsDown();
  56908. }
  56909. }
  56910. else {
  56911. moveInputsDown();
  56912. }
  56913. }
  56914. else if (dropdown === 'responsive') {
  56915. this.expandButtons();
  56916. }
  56917. }
  56918. else if (buttonGroup && dropdown === 'responsive') {
  56919. if (this.initialButtonGroupWidth > chart.plotWidth) {
  56920. this.collapseButtons(xOffsetForExportButton);
  56921. }
  56922. else {
  56923. this.expandButtons();
  56924. }
  56925. }
  56926. };
  56927. /**
  56928. * Collapse the buttons and put the select element on top.
  56929. *
  56930. * @private
  56931. * @function Highcharts.RangeSelector#collapseButtons
  56932. * @param {number} xOffsetForExportButton
  56933. * @return {void}
  56934. */
  56935. RangeSelector.prototype.collapseButtons = function (xOffsetForExportButton) {
  56936. var _a = this,
  56937. buttons = _a.buttons,
  56938. buttonOptions = _a.buttonOptions,
  56939. dropdown = _a.dropdown,
  56940. options = _a.options,
  56941. zoomText = _a.zoomText;
  56942. var getAttribs = function (text) { return ({
  56943. text: text ? text + " \u25BE" : '▾',
  56944. width: 'auto',
  56945. paddingLeft: 8,
  56946. paddingRight: 8
  56947. }); };
  56948. if (zoomText) {
  56949. zoomText.hide();
  56950. }
  56951. var hasActiveButton = false;
  56952. buttonOptions.forEach(function (rangeOptions, i) {
  56953. var button = buttons[i];
  56954. if (button.state !== 2) {
  56955. button.hide();
  56956. }
  56957. else {
  56958. button.show();
  56959. button.attr(getAttribs(rangeOptions.text));
  56960. hasActiveButton = true;
  56961. }
  56962. });
  56963. if (!hasActiveButton) {
  56964. if (dropdown) {
  56965. dropdown.selectedIndex = 0;
  56966. }
  56967. buttons[0].show();
  56968. buttons[0].attr(getAttribs(this.zoomText && this.zoomText.textStr));
  56969. }
  56970. var align = options.buttonPosition.align;
  56971. this.positionButtons();
  56972. if (align === 'right' || align === 'center') {
  56973. this.alignButtonGroup(xOffsetForExportButton, buttons[this.currentButtonIndex()].getBBox().width);
  56974. }
  56975. this.showDropdown();
  56976. };
  56977. /**
  56978. * Show all the buttons and hide the select element.
  56979. *
  56980. * @private
  56981. * @function Highcharts.RangeSelector#expandButtons
  56982. * @return {void}
  56983. */
  56984. RangeSelector.prototype.expandButtons = function () {
  56985. var _a = this,
  56986. buttons = _a.buttons,
  56987. buttonOptions = _a.buttonOptions,
  56988. options = _a.options,
  56989. zoomText = _a.zoomText;
  56990. this.hideDropdown();
  56991. if (zoomText) {
  56992. zoomText.show();
  56993. }
  56994. buttonOptions.forEach(function (rangeOptions, i) {
  56995. var button = buttons[i];
  56996. button.show();
  56997. button.attr({
  56998. text: rangeOptions.text,
  56999. width: options.buttonTheme.width || 28,
  57000. paddingLeft: 'unset',
  57001. paddingRight: 'unset'
  57002. });
  57003. if (button.state < 2) {
  57004. button.setState(0);
  57005. }
  57006. });
  57007. this.positionButtons();
  57008. };
  57009. /**
  57010. * Get the index of the visible button when the buttons are collapsed.
  57011. *
  57012. * @private
  57013. * @function Highcharts.RangeSelector#currentButtonIndex
  57014. * @return {number}
  57015. */
  57016. RangeSelector.prototype.currentButtonIndex = function () {
  57017. var dropdown = this.dropdown;
  57018. if (dropdown && dropdown.selectedIndex > 0) {
  57019. return dropdown.selectedIndex - 1;
  57020. }
  57021. return 0;
  57022. };
  57023. /**
  57024. * Position the select element on top of the button.
  57025. *
  57026. * @private
  57027. * @function Highcharts.RangeSelector#showDropdown
  57028. * @return {void}
  57029. */
  57030. RangeSelector.prototype.showDropdown = function () {
  57031. var _a = this,
  57032. buttonGroup = _a.buttonGroup,
  57033. buttons = _a.buttons,
  57034. chart = _a.chart,
  57035. dropdown = _a.dropdown;
  57036. if (buttonGroup && dropdown) {
  57037. var translateX = buttonGroup.translateX,
  57038. translateY = buttonGroup.translateY;
  57039. var bBox = buttons[this.currentButtonIndex()].getBBox();
  57040. css(dropdown, {
  57041. left: (chart.plotLeft + translateX) + 'px',
  57042. top: (translateY + 0.5) + 'px',
  57043. width: bBox.width + 'px',
  57044. height: bBox.height + 'px'
  57045. });
  57046. this.hasVisibleDropdown = true;
  57047. }
  57048. };
  57049. /**
  57050. * @private
  57051. * @function Highcharts.RangeSelector#hideDropdown
  57052. * @return {void}
  57053. */
  57054. RangeSelector.prototype.hideDropdown = function () {
  57055. var dropdown = this.dropdown;
  57056. if (dropdown) {
  57057. css(dropdown, {
  57058. top: '-9999em',
  57059. width: '1px',
  57060. height: '1px'
  57061. });
  57062. this.hasVisibleDropdown = false;
  57063. }
  57064. };
  57065. /**
  57066. * Extracts height of range selector
  57067. *
  57068. * @private
  57069. * @function Highcharts.RangeSelector#getHeight
  57070. * @return {number}
  57071. * Returns rangeSelector height
  57072. */
  57073. RangeSelector.prototype.getHeight = function () {
  57074. var rangeSelector = this,
  57075. options = rangeSelector.options,
  57076. rangeSelectorGroup = rangeSelector.group,
  57077. inputPosition = options.inputPosition,
  57078. buttonPosition = options.buttonPosition,
  57079. yPosition = options.y,
  57080. buttonPositionY = buttonPosition.y,
  57081. inputPositionY = inputPosition.y,
  57082. rangeSelectorHeight = 0,
  57083. minPosition;
  57084. if (options.height) {
  57085. return options.height;
  57086. }
  57087. // Align the elements before we read the height in case we're switching
  57088. // between wrapped and non-wrapped layout
  57089. this.alignElements();
  57090. rangeSelectorHeight = rangeSelectorGroup ?
  57091. // 13px to keep back compatibility
  57092. (rangeSelectorGroup.getBBox(true).height) + 13 +
  57093. yPosition :
  57094. 0;
  57095. minPosition = Math.min(inputPositionY, buttonPositionY);
  57096. if ((inputPositionY < 0 && buttonPositionY < 0) ||
  57097. (inputPositionY > 0 && buttonPositionY > 0)) {
  57098. rangeSelectorHeight += Math.abs(minPosition);
  57099. }
  57100. return rangeSelectorHeight;
  57101. };
  57102. /**
  57103. * Detect collision with title or subtitle
  57104. *
  57105. * @private
  57106. * @function Highcharts.RangeSelector#titleCollision
  57107. *
  57108. * @param {Highcharts.Chart} chart
  57109. *
  57110. * @return {boolean}
  57111. * Returns collision status
  57112. */
  57113. RangeSelector.prototype.titleCollision = function (chart) {
  57114. return !(chart.options.title.text ||
  57115. chart.options.subtitle.text);
  57116. };
  57117. /**
  57118. * Update the range selector with new options
  57119. *
  57120. * @private
  57121. * @function Highcharts.RangeSelector#update
  57122. * @param {Highcharts.RangeSelectorOptions} options
  57123. * @return {void}
  57124. */
  57125. RangeSelector.prototype.update = function (options) {
  57126. var chart = this.chart;
  57127. merge(true, chart.options.rangeSelector, options);
  57128. this.destroy();
  57129. this.init(chart);
  57130. this.render();
  57131. };
  57132. /**
  57133. * Destroys allocated elements.
  57134. *
  57135. * @private
  57136. * @function Highcharts.RangeSelector#destroy
  57137. */
  57138. RangeSelector.prototype.destroy = function () {
  57139. var rSelector = this,
  57140. minInput = rSelector.minInput,
  57141. maxInput = rSelector.maxInput;
  57142. if (rSelector.eventsToUnbind) {
  57143. rSelector.eventsToUnbind.forEach(function (unbind) { return unbind(); });
  57144. rSelector.eventsToUnbind = void 0;
  57145. }
  57146. // Destroy elements in collections
  57147. destroyObjectProperties(rSelector.buttons);
  57148. // Clear input element events
  57149. if (minInput) {
  57150. minInput.onfocus = minInput.onblur = minInput.onchange = null;
  57151. }
  57152. if (maxInput) {
  57153. maxInput.onfocus = maxInput.onblur = maxInput.onchange = null;
  57154. }
  57155. // Destroy HTML and SVG elements
  57156. objectEach(rSelector, function (val, key) {
  57157. if (val && key !== 'chart') {
  57158. if (val instanceof SVGElement) {
  57159. // SVGElement
  57160. val.destroy();
  57161. }
  57162. else if (val instanceof window.HTMLElement) {
  57163. // HTML element
  57164. discardElement(val);
  57165. }
  57166. }
  57167. if (val !== RangeSelector.prototype[key]) {
  57168. rSelector[key] = null;
  57169. }
  57170. }, this);
  57171. };
  57172. return RangeSelector;
  57173. }());
  57174. /**
  57175. * The default buttons for pre-selecting time frames
  57176. */
  57177. RangeSelector.prototype.defaultButtons = [{
  57178. type: 'month',
  57179. count: 1,
  57180. text: '1m',
  57181. title: 'View 1 month'
  57182. }, {
  57183. type: 'month',
  57184. count: 3,
  57185. text: '3m',
  57186. title: 'View 3 months'
  57187. }, {
  57188. type: 'month',
  57189. count: 6,
  57190. text: '6m',
  57191. title: 'View 6 months'
  57192. }, {
  57193. type: 'ytd',
  57194. text: 'YTD',
  57195. title: 'View year to date'
  57196. }, {
  57197. type: 'year',
  57198. count: 1,
  57199. text: '1y',
  57200. title: 'View 1 year'
  57201. }, {
  57202. type: 'all',
  57203. text: 'All',
  57204. title: 'View all'
  57205. }];
  57206. /**
  57207. * The date formats to use when setting min, max and value on date inputs
  57208. */
  57209. RangeSelector.prototype.inputTypeFormats = {
  57210. 'datetime-local': '%Y-%m-%dT%H:%M:%S',
  57211. 'date': '%Y-%m-%d',
  57212. 'time': '%H:%M:%S'
  57213. };
  57214. /**
  57215. * Get the preferred input type based on a date format string.
  57216. *
  57217. * @private
  57218. * @function preferredInputType
  57219. * @param {string} format
  57220. * @return {string}
  57221. */
  57222. function preferredInputType(format) {
  57223. var ms = format.indexOf('%L') !== -1;
  57224. if (ms) {
  57225. return 'text';
  57226. }
  57227. var date = ['a', 'A', 'd', 'e', 'w', 'b', 'B', 'm', 'o', 'y', 'Y'].some(function (char) {
  57228. return format.indexOf('%' + char) !== -1;
  57229. });
  57230. var time = ['H', 'k', 'I', 'l', 'M', 'S'].some(function (char) {
  57231. return format.indexOf('%' + char) !== -1;
  57232. });
  57233. if (date && time) {
  57234. return 'datetime-local';
  57235. }
  57236. if (date) {
  57237. return 'date';
  57238. }
  57239. if (time) {
  57240. return 'time';
  57241. }
  57242. return 'text';
  57243. }
  57244. /**
  57245. * Get the axis min value based on the range option and the current max. For
  57246. * stock charts this is extended via the {@link RangeSelector} so that if the
  57247. * selected range is a multiple of months or years, it is compensated for
  57248. * various month lengths.
  57249. *
  57250. * @private
  57251. * @function Highcharts.Axis#minFromRange
  57252. * @return {number|undefined}
  57253. * The new minimum value.
  57254. */
  57255. Axis.prototype.minFromRange = function () {
  57256. var rangeOptions = this.range,
  57257. type = rangeOptions.type,
  57258. min,
  57259. max = this.max,
  57260. dataMin,
  57261. range,
  57262. time = this.chart.time,
  57263. // Get the true range from a start date
  57264. getTrueRange = function (base,
  57265. count) {
  57266. var timeName = type === 'year' ? 'FullYear' : 'Month';
  57267. var date = new time.Date(base);
  57268. var basePeriod = time.get(timeName,
  57269. date);
  57270. time.set(timeName, date, basePeriod + count);
  57271. if (basePeriod === time.get(timeName, date)) {
  57272. time.set('Date', date, 0); // #6537
  57273. }
  57274. return date.getTime() - base;
  57275. };
  57276. if (isNumber(rangeOptions)) {
  57277. min = max - rangeOptions;
  57278. range = rangeOptions;
  57279. }
  57280. else {
  57281. min = max + getTrueRange(max, -rangeOptions.count);
  57282. // Let the fixedRange reflect initial settings (#5930)
  57283. if (this.chart) {
  57284. this.chart.fixedRange = max - min;
  57285. }
  57286. }
  57287. dataMin = pick(this.dataMin, Number.MIN_VALUE);
  57288. if (!isNumber(min)) {
  57289. min = dataMin;
  57290. }
  57291. if (min <= dataMin) {
  57292. min = dataMin;
  57293. if (typeof range === 'undefined') { // #4501
  57294. range = getTrueRange(min, rangeOptions.count);
  57295. }
  57296. this.newMax = Math.min(min + range, this.dataMax);
  57297. }
  57298. if (!isNumber(max)) {
  57299. min = void 0;
  57300. }
  57301. return min;
  57302. };
  57303. if (!H.RangeSelector) {
  57304. var chartDestroyEvents_1 = [];
  57305. var initRangeSelector_1 = function (chart) {
  57306. var extremes,
  57307. rangeSelector = chart.rangeSelector,
  57308. legend,
  57309. alignTo,
  57310. verticalAlign;
  57311. /**
  57312. * @private
  57313. */
  57314. function render() {
  57315. if (rangeSelector) {
  57316. extremes = chart.xAxis[0].getExtremes();
  57317. legend = chart.legend;
  57318. verticalAlign = (rangeSelector &&
  57319. rangeSelector.options.verticalAlign);
  57320. if (isNumber(extremes.min)) {
  57321. rangeSelector.render(extremes.min, extremes.max);
  57322. }
  57323. // Re-align the legend so that it's below the rangeselector
  57324. if (legend.display &&
  57325. verticalAlign === 'top' &&
  57326. verticalAlign === legend.options.verticalAlign) {
  57327. // Create a new alignment box for the legend.
  57328. alignTo = merge(chart.spacingBox);
  57329. if (legend.options.layout === 'vertical') {
  57330. alignTo.y = chart.plotTop;
  57331. }
  57332. else {
  57333. alignTo.y += rangeSelector.getHeight();
  57334. }
  57335. legend.group.placed = false; // Don't animate the alignment.
  57336. legend.align(alignTo);
  57337. }
  57338. }
  57339. }
  57340. if (rangeSelector) {
  57341. var events = find(chartDestroyEvents_1,
  57342. function (e) { return e[0] === chart; });
  57343. if (!events) {
  57344. chartDestroyEvents_1.push([chart, [
  57345. // redraw the scroller on setExtremes
  57346. addEvent(chart.xAxis[0], 'afterSetExtremes', function (e) {
  57347. if (rangeSelector) {
  57348. rangeSelector.render(e.min, e.max);
  57349. }
  57350. }),
  57351. // redraw the scroller chart resize
  57352. addEvent(chart, 'redraw', render)
  57353. ]]);
  57354. }
  57355. // do it now
  57356. render();
  57357. }
  57358. };
  57359. // Initialize rangeselector for stock charts
  57360. addEvent(Chart, 'afterGetContainer', function () {
  57361. if (this.options.rangeSelector &&
  57362. this.options.rangeSelector.enabled) {
  57363. this.rangeSelector = new RangeSelector(this);
  57364. }
  57365. });
  57366. addEvent(Chart, 'beforeRender', function () {
  57367. var chart = this,
  57368. axes = chart.axes,
  57369. rangeSelector = chart.rangeSelector,
  57370. verticalAlign;
  57371. if (rangeSelector) {
  57372. if (isNumber(rangeSelector.deferredYTDClick)) {
  57373. rangeSelector.clickButton(rangeSelector.deferredYTDClick);
  57374. delete rangeSelector.deferredYTDClick;
  57375. }
  57376. axes.forEach(function (axis) {
  57377. axis.updateNames();
  57378. axis.setScale();
  57379. });
  57380. chart.getAxisMargins();
  57381. rangeSelector.render();
  57382. verticalAlign = rangeSelector.options.verticalAlign;
  57383. if (!rangeSelector.options.floating) {
  57384. if (verticalAlign === 'bottom') {
  57385. this.extraBottomMargin = true;
  57386. }
  57387. else if (verticalAlign !== 'middle') {
  57388. this.extraTopMargin = true;
  57389. }
  57390. }
  57391. }
  57392. });
  57393. addEvent(Chart, 'update', function (e) {
  57394. var chart = this,
  57395. options = e.options,
  57396. optionsRangeSelector = options.rangeSelector,
  57397. rangeSelector = chart.rangeSelector,
  57398. verticalAlign,
  57399. extraBottomMarginWas = this.extraBottomMargin,
  57400. extraTopMarginWas = this.extraTopMargin;
  57401. if (optionsRangeSelector &&
  57402. optionsRangeSelector.enabled &&
  57403. !defined(rangeSelector) &&
  57404. this.options.rangeSelector) {
  57405. this.options.rangeSelector.enabled = true;
  57406. this.rangeSelector = rangeSelector = new RangeSelector(this);
  57407. }
  57408. this.extraBottomMargin = false;
  57409. this.extraTopMargin = false;
  57410. if (rangeSelector) {
  57411. initRangeSelector_1(this);
  57412. verticalAlign = (optionsRangeSelector &&
  57413. optionsRangeSelector.verticalAlign) || (rangeSelector.options && rangeSelector.options.verticalAlign);
  57414. if (!rangeSelector.options.floating) {
  57415. if (verticalAlign === 'bottom') {
  57416. this.extraBottomMargin = true;
  57417. }
  57418. else if (verticalAlign !== 'middle') {
  57419. this.extraTopMargin = true;
  57420. }
  57421. }
  57422. if (this.extraBottomMargin !== extraBottomMarginWas ||
  57423. this.extraTopMargin !== extraTopMarginWas) {
  57424. this.isDirtyBox = true;
  57425. }
  57426. }
  57427. });
  57428. addEvent(Chart, 'render', function () {
  57429. var chart = this,
  57430. rangeSelector = chart.rangeSelector,
  57431. verticalAlign;
  57432. if (rangeSelector && !rangeSelector.options.floating) {
  57433. rangeSelector.render();
  57434. verticalAlign = rangeSelector.options.verticalAlign;
  57435. if (verticalAlign === 'bottom') {
  57436. this.extraBottomMargin = true;
  57437. }
  57438. else if (verticalAlign !== 'middle') {
  57439. this.extraTopMargin = true;
  57440. }
  57441. }
  57442. });
  57443. addEvent(Chart, 'getMargins', function () {
  57444. var rangeSelector = this.rangeSelector,
  57445. rangeSelectorHeight;
  57446. if (rangeSelector) {
  57447. rangeSelectorHeight = rangeSelector.getHeight();
  57448. if (this.extraTopMargin) {
  57449. this.plotTop += rangeSelectorHeight;
  57450. }
  57451. if (this.extraBottomMargin) {
  57452. this.marginBottom += rangeSelectorHeight;
  57453. }
  57454. }
  57455. });
  57456. Chart.prototype.callbacks.push(initRangeSelector_1);
  57457. // Remove resize/afterSetExtremes at chart destroy
  57458. addEvent(Chart, 'destroy', function destroyEvents() {
  57459. for (var i = 0; i < chartDestroyEvents_1.length; i++) {
  57460. var events = chartDestroyEvents_1[i];
  57461. if (events[0] === this) {
  57462. events[1].forEach(function (unbind) { return unbind(); });
  57463. chartDestroyEvents_1.splice(i, 1);
  57464. return;
  57465. }
  57466. }
  57467. });
  57468. H.RangeSelector = RangeSelector;
  57469. }
  57470. return H.RangeSelector;
  57471. });
  57472. _registerModule(_modules, 'Core/Axis/NavigatorAxis.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  57473. /* *
  57474. *
  57475. * (c) 2010-2021 Torstein Honsi
  57476. *
  57477. * License: www.highcharts.com/license
  57478. *
  57479. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  57480. *
  57481. * */
  57482. var isTouchDevice = H.isTouchDevice;
  57483. var addEvent = U.addEvent,
  57484. correctFloat = U.correctFloat,
  57485. defined = U.defined,
  57486. isNumber = U.isNumber,
  57487. pick = U.pick;
  57488. /* eslint-disable valid-jsdoc */
  57489. /**
  57490. * @private
  57491. * @class
  57492. */
  57493. var NavigatorAxisAdditions = /** @class */ (function () {
  57494. /* *
  57495. *
  57496. * Constructors
  57497. *
  57498. * */
  57499. function NavigatorAxisAdditions(axis) {
  57500. this.axis = axis;
  57501. }
  57502. /* *
  57503. *
  57504. * Functions
  57505. *
  57506. * */
  57507. /**
  57508. * @private
  57509. */
  57510. NavigatorAxisAdditions.prototype.destroy = function () {
  57511. this.axis = void 0;
  57512. };
  57513. /**
  57514. * Add logic to normalize the zoomed range in order to preserve the pressed
  57515. * state of range selector buttons
  57516. *
  57517. * @private
  57518. * @function Highcharts.Axis#toFixedRange
  57519. * @param {number} [pxMin]
  57520. * @param {number} [pxMax]
  57521. * @param {number} [fixedMin]
  57522. * @param {number} [fixedMax]
  57523. * @return {*}
  57524. */
  57525. NavigatorAxisAdditions.prototype.toFixedRange = function (pxMin, pxMax, fixedMin, fixedMax) {
  57526. var navigator = this;
  57527. var axis = navigator.axis;
  57528. var chart = axis.chart;
  57529. var fixedRange = chart && chart.fixedRange,
  57530. halfPointRange = (axis.pointRange || 0) / 2,
  57531. newMin = pick(fixedMin,
  57532. axis.translate(pxMin,
  57533. true, !axis.horiz)),
  57534. newMax = pick(fixedMax,
  57535. axis.translate(pxMax,
  57536. true, !axis.horiz)),
  57537. changeRatio = fixedRange && (newMax - newMin) / fixedRange;
  57538. // Add/remove half point range to/from the extremes (#1172)
  57539. if (!defined(fixedMin)) {
  57540. newMin = correctFloat(newMin + halfPointRange);
  57541. }
  57542. if (!defined(fixedMax)) {
  57543. newMax = correctFloat(newMax - halfPointRange);
  57544. }
  57545. // If the difference between the fixed range and the actual requested
  57546. // range is too great, the user is dragging across an ordinal gap, and
  57547. // we need to release the range selector button.
  57548. if (changeRatio > 0.7 && changeRatio < 1.3) {
  57549. if (fixedMax) {
  57550. newMin = newMax - fixedRange;
  57551. }
  57552. else {
  57553. newMax = newMin + fixedRange;
  57554. }
  57555. }
  57556. if (!isNumber(newMin) || !isNumber(newMax)) { // #1195, #7411
  57557. newMin = newMax = void 0;
  57558. }
  57559. return {
  57560. min: newMin,
  57561. max: newMax
  57562. };
  57563. };
  57564. return NavigatorAxisAdditions;
  57565. }());
  57566. /**
  57567. * @private
  57568. * @class
  57569. */
  57570. var NavigatorAxis = /** @class */ (function () {
  57571. function NavigatorAxis() {
  57572. }
  57573. /* *
  57574. *
  57575. * Static Functions
  57576. *
  57577. * */
  57578. /**
  57579. * @private
  57580. */
  57581. NavigatorAxis.compose = function (AxisClass) {
  57582. AxisClass.keepProps.push('navigatorAxis');
  57583. /* eslint-disable no-invalid-this */
  57584. addEvent(AxisClass, 'init', function () {
  57585. var axis = this;
  57586. if (!axis.navigatorAxis) {
  57587. axis.navigatorAxis = new NavigatorAxisAdditions(axis);
  57588. }
  57589. });
  57590. // For Stock charts, override selection zooming with some special
  57591. // features because X axis zooming is already allowed by the Navigator
  57592. // and Range selector.
  57593. addEvent(AxisClass, 'zoom', function (e) {
  57594. var axis = this;
  57595. var chart = axis.chart;
  57596. var chartOptions = chart.options;
  57597. var navigator = chartOptions.navigator;
  57598. var navigatorAxis = axis.navigatorAxis;
  57599. var pinchType = chartOptions.chart.pinchType;
  57600. var rangeSelector = chartOptions.rangeSelector;
  57601. var zoomType = chartOptions.chart.zoomType;
  57602. var previousZoom;
  57603. if (axis.isXAxis && ((navigator && navigator.enabled) ||
  57604. (rangeSelector && rangeSelector.enabled))) {
  57605. // For y only zooming, ignore the X axis completely
  57606. if (zoomType === 'y') {
  57607. e.zoomed = false;
  57608. // For xy zooming, record the state of the zoom before zoom
  57609. // selection, then when the reset button is pressed, revert to
  57610. // this state. This should apply only if the chart is
  57611. // initialized with a range (#6612), otherwise zoom all the way
  57612. // out.
  57613. }
  57614. else if (((!isTouchDevice && zoomType === 'xy') ||
  57615. (isTouchDevice && pinchType === 'xy')) &&
  57616. axis.options.range) {
  57617. previousZoom = navigatorAxis.previousZoom;
  57618. if (defined(e.newMin)) {
  57619. navigatorAxis.previousZoom = [axis.min, axis.max];
  57620. }
  57621. else if (previousZoom) {
  57622. e.newMin = previousZoom[0];
  57623. e.newMax = previousZoom[1];
  57624. navigatorAxis.previousZoom = void 0;
  57625. }
  57626. }
  57627. }
  57628. if (typeof e.zoomed !== 'undefined') {
  57629. e.preventDefault();
  57630. }
  57631. });
  57632. /* eslint-enable no-invalid-this */
  57633. };
  57634. /* *
  57635. *
  57636. * Static Properties
  57637. *
  57638. * */
  57639. /**
  57640. * @private
  57641. */
  57642. NavigatorAxis.AdditionsClass = NavigatorAxisAdditions;
  57643. return NavigatorAxis;
  57644. }());
  57645. return NavigatorAxis;
  57646. });
  57647. _registerModule(_modules, 'Core/Navigator.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Chart/Chart.js'], _modules['Core/Color/Color.js'], _modules['Core/Globals.js'], _modules['Core/Axis/NavigatorAxis.js'], _modules['Core/Options.js'], _modules['Core/Color/Palette.js'], _modules['Core/Scrollbar.js'], _modules['Core/Series/Series.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (Axis, Chart, Color, H, NavigatorAxis, O, palette, Scrollbar, Series, SeriesRegistry, U) {
  57648. /* *
  57649. *
  57650. * (c) 2010-2021 Torstein Honsi
  57651. *
  57652. * License: www.highcharts.com/license
  57653. *
  57654. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  57655. *
  57656. * */
  57657. var color = Color.parse;
  57658. var hasTouch = H.hasTouch,
  57659. isTouchDevice = H.isTouchDevice;
  57660. var defaultOptions = O.defaultOptions;
  57661. var seriesTypes = SeriesRegistry.seriesTypes;
  57662. var addEvent = U.addEvent,
  57663. clamp = U.clamp,
  57664. correctFloat = U.correctFloat,
  57665. defined = U.defined,
  57666. destroyObjectProperties = U.destroyObjectProperties,
  57667. erase = U.erase,
  57668. extend = U.extend,
  57669. find = U.find,
  57670. isArray = U.isArray,
  57671. isNumber = U.isNumber,
  57672. merge = U.merge,
  57673. pick = U.pick,
  57674. removeEvent = U.removeEvent,
  57675. splat = U.splat;
  57676. var defaultSeriesType,
  57677. // Finding the min or max of a set of variables where we don't know if they
  57678. // are defined, is a pattern that is repeated several places in Highcharts.
  57679. // Consider making this a global utility method.
  57680. numExt = function (extreme) {
  57681. var args = [];
  57682. for (var _i = 1; _i < arguments.length; _i++) {
  57683. args[_i - 1] = arguments[_i];
  57684. }
  57685. var numbers = [].filter.call(args,
  57686. isNumber);
  57687. if (numbers.length) {
  57688. return Math[extreme].apply(0, numbers);
  57689. }
  57690. };
  57691. defaultSeriesType = typeof seriesTypes.areaspline === 'undefined' ?
  57692. 'line' :
  57693. 'areaspline';
  57694. extend(defaultOptions, {
  57695. /**
  57696. * Maximum range which can be set using the navigator's handles.
  57697. * Opposite of [xAxis.minRange](#xAxis.minRange).
  57698. *
  57699. * @sample {highstock} stock/navigator/maxrange/
  57700. * Defined max and min range
  57701. *
  57702. * @type {number}
  57703. * @since 6.0.0
  57704. * @product highstock gantt
  57705. * @apioption xAxis.maxRange
  57706. */
  57707. /**
  57708. * The navigator is a small series below the main series, displaying
  57709. * a view of the entire data set. It provides tools to zoom in and
  57710. * out on parts of the data as well as panning across the dataset.
  57711. *
  57712. * @product highstock gantt
  57713. * @optionparent navigator
  57714. */
  57715. navigator: {
  57716. /**
  57717. * Whether the navigator and scrollbar should adapt to updated data
  57718. * in the base X axis. When loading data async, as in the demo below,
  57719. * this should be `false`. Otherwise new data will trigger navigator
  57720. * redraw, which will cause unwanted looping. In the demo below, the
  57721. * data in the navigator is set only once. On navigating, only the main
  57722. * chart content is updated.
  57723. *
  57724. * @sample {highstock} stock/demo/lazy-loading/
  57725. * Set to false with async data loading
  57726. *
  57727. * @type {boolean}
  57728. * @default true
  57729. * @apioption navigator.adaptToUpdatedData
  57730. */
  57731. /**
  57732. * An integer identifying the index to use for the base series, or a
  57733. * string representing the id of the series.
  57734. *
  57735. * **Note**: As of Highcharts 5.0, this is now a deprecated option.
  57736. * Prefer [series.showInNavigator](#plotOptions.series.showInNavigator).
  57737. *
  57738. * @see [series.showInNavigator](#plotOptions.series.showInNavigator)
  57739. *
  57740. * @deprecated
  57741. * @type {number|string}
  57742. * @default 0
  57743. * @apioption navigator.baseSeries
  57744. */
  57745. /**
  57746. * Enable or disable the navigator.
  57747. *
  57748. * @sample {highstock} stock/navigator/enabled/
  57749. * Disable the navigator
  57750. *
  57751. * @type {boolean}
  57752. * @default true
  57753. * @apioption navigator.enabled
  57754. */
  57755. /**
  57756. * When the chart is inverted, whether to draw the navigator on the
  57757. * opposite side.
  57758. *
  57759. * @type {boolean}
  57760. * @default false
  57761. * @since 5.0.8
  57762. * @apioption navigator.opposite
  57763. */
  57764. /**
  57765. * The height of the navigator.
  57766. *
  57767. * @sample {highstock} stock/navigator/height/
  57768. * A higher navigator
  57769. */
  57770. height: 40,
  57771. /**
  57772. * The distance from the nearest element, the X axis or X axis labels.
  57773. *
  57774. * @sample {highstock} stock/navigator/margin/
  57775. * A margin of 2 draws the navigator closer to the X axis labels
  57776. */
  57777. margin: 25,
  57778. /**
  57779. * Whether the mask should be inside the range marking the zoomed
  57780. * range, or outside. In Highcharts Stock 1.x it was always `false`.
  57781. *
  57782. * @sample {highstock} stock/navigator/maskinside-false/
  57783. * False, mask outside
  57784. *
  57785. * @since 2.0
  57786. */
  57787. maskInside: true,
  57788. /**
  57789. * Options for the handles for dragging the zoomed area.
  57790. *
  57791. * @sample {highstock} stock/navigator/handles/
  57792. * Colored handles
  57793. */
  57794. handles: {
  57795. /**
  57796. * Width for handles.
  57797. *
  57798. * @sample {highstock} stock/navigator/styled-handles/
  57799. * Styled handles
  57800. *
  57801. * @since 6.0.0
  57802. */
  57803. width: 7,
  57804. /**
  57805. * Height for handles.
  57806. *
  57807. * @sample {highstock} stock/navigator/styled-handles/
  57808. * Styled handles
  57809. *
  57810. * @since 6.0.0
  57811. */
  57812. height: 15,
  57813. /**
  57814. * Array to define shapes of handles. 0-index for left, 1-index for
  57815. * right.
  57816. *
  57817. * Additionally, the URL to a graphic can be given on this form:
  57818. * `url(graphic.png)`. Note that for the image to be applied to
  57819. * exported charts, its URL needs to be accessible by the export
  57820. * server.
  57821. *
  57822. * Custom callbacks for symbol path generation can also be added to
  57823. * `Highcharts.SVGRenderer.prototype.symbols`. The callback is then
  57824. * used by its method name, as shown in the demo.
  57825. *
  57826. * @sample {highstock} stock/navigator/styled-handles/
  57827. * Styled handles
  57828. *
  57829. * @type {Array<string>}
  57830. * @default ["navigator-handle", "navigator-handle"]
  57831. * @since 6.0.0
  57832. */
  57833. symbols: ['navigator-handle', 'navigator-handle'],
  57834. /**
  57835. * Allows to enable/disable handles.
  57836. *
  57837. * @since 6.0.0
  57838. */
  57839. enabled: true,
  57840. /**
  57841. * The width for the handle border and the stripes inside.
  57842. *
  57843. * @sample {highstock} stock/navigator/styled-handles/
  57844. * Styled handles
  57845. *
  57846. * @since 6.0.0
  57847. * @apioption navigator.handles.lineWidth
  57848. */
  57849. lineWidth: 1,
  57850. /**
  57851. * The fill for the handle.
  57852. *
  57853. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  57854. */
  57855. backgroundColor: palette.neutralColor5,
  57856. /**
  57857. * The stroke for the handle border and the stripes inside.
  57858. *
  57859. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  57860. */
  57861. borderColor: palette.neutralColor40
  57862. },
  57863. /**
  57864. * The color of the mask covering the areas of the navigator series
  57865. * that are currently not visible in the main series. The default
  57866. * color is bluish with an opacity of 0.3 to see the series below.
  57867. *
  57868. * @see In styled mode, the mask is styled with the
  57869. * `.highcharts-navigator-mask` and
  57870. * `.highcharts-navigator-mask-inside` classes.
  57871. *
  57872. * @sample {highstock} stock/navigator/maskfill/
  57873. * Blue, semi transparent mask
  57874. *
  57875. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  57876. * @default rgba(102,133,194,0.3)
  57877. */
  57878. maskFill: color(palette.highlightColor60).setOpacity(0.3).get(),
  57879. /**
  57880. * The color of the line marking the currently zoomed area in the
  57881. * navigator.
  57882. *
  57883. * @sample {highstock} stock/navigator/outline/
  57884. * 2px blue outline
  57885. *
  57886. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  57887. * @default #cccccc
  57888. */
  57889. outlineColor: palette.neutralColor20,
  57890. /**
  57891. * The width of the line marking the currently zoomed area in the
  57892. * navigator.
  57893. *
  57894. * @see In styled mode, the outline stroke width is set with the
  57895. * `.highcharts-navigator-outline` class.
  57896. *
  57897. * @sample {highstock} stock/navigator/outline/
  57898. * 2px blue outline
  57899. *
  57900. * @type {number}
  57901. */
  57902. outlineWidth: 1,
  57903. /**
  57904. * Options for the navigator series. Available options are the same
  57905. * as any series, documented at [plotOptions](#plotOptions.series)
  57906. * and [series](#series).
  57907. *
  57908. * Unless data is explicitly defined on navigator.series, the data
  57909. * is borrowed from the first series in the chart.
  57910. *
  57911. * Default series options for the navigator series are:
  57912. * ```js
  57913. * series: {
  57914. * type: 'areaspline',
  57915. * fillOpacity: 0.05,
  57916. * dataGrouping: {
  57917. * smoothed: true
  57918. * },
  57919. * lineWidth: 1,
  57920. * marker: {
  57921. * enabled: false
  57922. * }
  57923. * }
  57924. * ```
  57925. *
  57926. * @see In styled mode, the navigator series is styled with the
  57927. * `.highcharts-navigator-series` class.
  57928. *
  57929. * @sample {highstock} stock/navigator/series-data/
  57930. * Using a separate data set for the navigator
  57931. * @sample {highstock} stock/navigator/series/
  57932. * A green navigator series
  57933. *
  57934. * @type {*|Array<*>|Highcharts.SeriesOptionsType|Array<Highcharts.SeriesOptionsType>}
  57935. */
  57936. series: {
  57937. /**
  57938. * The type of the navigator series.
  57939. *
  57940. * Heads up:
  57941. * In column-type navigator, zooming is limited to at least one
  57942. * point with its `pointRange`.
  57943. *
  57944. * @sample {highstock} stock/navigator/column/
  57945. * Column type navigator
  57946. *
  57947. * @type {string}
  57948. * @default {highstock} `areaspline` if defined, otherwise `line`
  57949. * @default {gantt} gantt
  57950. */
  57951. type: defaultSeriesType,
  57952. /**
  57953. * The fill opacity of the navigator series.
  57954. */
  57955. fillOpacity: 0.05,
  57956. /**
  57957. * The pixel line width of the navigator series.
  57958. */
  57959. lineWidth: 1,
  57960. /**
  57961. * @ignore-option
  57962. */
  57963. compare: null,
  57964. /**
  57965. * Unless data is explicitly defined, the data is borrowed from the
  57966. * first series in the chart.
  57967. *
  57968. * @type {Array<number|Array<number|string|null>|object|null>}
  57969. * @product highstock
  57970. * @apioption navigator.series.data
  57971. */
  57972. /**
  57973. * Data grouping options for the navigator series.
  57974. *
  57975. * @extends plotOptions.series.dataGrouping
  57976. */
  57977. dataGrouping: {
  57978. approximation: 'average',
  57979. enabled: true,
  57980. groupPixelWidth: 2,
  57981. // Replace smoothed property by anchors, #12455.
  57982. firstAnchor: 'firstPoint',
  57983. anchor: 'middle',
  57984. lastAnchor: 'lastPoint',
  57985. // Day and week differs from plotOptions.series.dataGrouping
  57986. units: [
  57987. ['millisecond', [1, 2, 5, 10, 20, 25, 50, 100, 200, 500]],
  57988. ['second', [1, 2, 5, 10, 15, 30]],
  57989. ['minute', [1, 2, 5, 10, 15, 30]],
  57990. ['hour', [1, 2, 3, 4, 6, 8, 12]],
  57991. ['day', [1, 2, 3, 4]],
  57992. ['week', [1, 2, 3]],
  57993. ['month', [1, 3, 6]],
  57994. ['year', null]
  57995. ]
  57996. },
  57997. /**
  57998. * Data label options for the navigator series. Data labels are
  57999. * disabled by default on the navigator series.
  58000. *
  58001. * @extends plotOptions.series.dataLabels
  58002. */
  58003. dataLabels: {
  58004. enabled: false,
  58005. zIndex: 2 // #1839
  58006. },
  58007. id: 'highcharts-navigator-series',
  58008. className: 'highcharts-navigator-series',
  58009. /**
  58010. * Sets the fill color of the navigator series.
  58011. *
  58012. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  58013. * @apioption navigator.series.color
  58014. */
  58015. /**
  58016. * Line color for the navigator series. Allows setting the color
  58017. * while disallowing the default candlestick setting.
  58018. *
  58019. * @type {Highcharts.ColorString|null}
  58020. */
  58021. lineColor: null,
  58022. marker: {
  58023. enabled: false
  58024. },
  58025. /**
  58026. * Since Highcharts Stock v8, default value is the same as default
  58027. * `pointRange` defined for a specific type (e.g. `null` for
  58028. * column type).
  58029. *
  58030. * In Highcharts Stock version < 8, defaults to 0.
  58031. *
  58032. * @extends plotOptions.series.pointRange
  58033. * @type {number|null}
  58034. * @apioption navigator.series.pointRange
  58035. */
  58036. /**
  58037. * The threshold option. Setting it to 0 will make the default
  58038. * navigator area series draw its area from the 0 value and up.
  58039. *
  58040. * @type {number|null}
  58041. */
  58042. threshold: null
  58043. },
  58044. /**
  58045. * Options for the navigator X axis. Default series options for the
  58046. * navigator xAxis are:
  58047. * ```js
  58048. * xAxis: {
  58049. * tickWidth: 0,
  58050. * lineWidth: 0,
  58051. * gridLineWidth: 1,
  58052. * tickPixelInterval: 200,
  58053. * labels: {
  58054. * align: 'left',
  58055. * style: {
  58056. * color: '#888'
  58057. * },
  58058. * x: 3,
  58059. * y: -4
  58060. * }
  58061. * }
  58062. * ```
  58063. *
  58064. * @extends xAxis
  58065. * @excluding linkedTo, maxZoom, minRange, opposite, range, scrollbar,
  58066. * showEmpty, maxRange
  58067. */
  58068. xAxis: {
  58069. /**
  58070. * Additional range on the right side of the xAxis. Works similar to
  58071. * xAxis.maxPadding, but value is set in milliseconds.
  58072. * Can be set for both, main xAxis and navigator's xAxis.
  58073. *
  58074. * @since 6.0.0
  58075. */
  58076. overscroll: 0,
  58077. className: 'highcharts-navigator-xaxis',
  58078. tickLength: 0,
  58079. lineWidth: 0,
  58080. gridLineColor: palette.neutralColor10,
  58081. gridLineWidth: 1,
  58082. tickPixelInterval: 200,
  58083. labels: {
  58084. align: 'left',
  58085. /**
  58086. * @type {Highcharts.CSSObject}
  58087. */
  58088. style: {
  58089. /** @ignore */
  58090. color: palette.neutralColor40
  58091. },
  58092. x: 3,
  58093. y: -4
  58094. },
  58095. crosshair: false
  58096. },
  58097. /**
  58098. * Options for the navigator Y axis. Default series options for the
  58099. * navigator yAxis are:
  58100. * ```js
  58101. * yAxis: {
  58102. * gridLineWidth: 0,
  58103. * startOnTick: false,
  58104. * endOnTick: false,
  58105. * minPadding: 0.1,
  58106. * maxPadding: 0.1,
  58107. * labels: {
  58108. * enabled: false
  58109. * },
  58110. * title: {
  58111. * text: null
  58112. * },
  58113. * tickWidth: 0
  58114. * }
  58115. * ```
  58116. *
  58117. * @extends yAxis
  58118. * @excluding height, linkedTo, maxZoom, minRange, ordinal, range,
  58119. * showEmpty, scrollbar, top, units, maxRange, minLength,
  58120. * maxLength, resize
  58121. */
  58122. yAxis: {
  58123. className: 'highcharts-navigator-yaxis',
  58124. gridLineWidth: 0,
  58125. startOnTick: false,
  58126. endOnTick: false,
  58127. minPadding: 0.1,
  58128. maxPadding: 0.1,
  58129. labels: {
  58130. enabled: false
  58131. },
  58132. crosshair: false,
  58133. title: {
  58134. text: null
  58135. },
  58136. tickLength: 0,
  58137. tickWidth: 0
  58138. }
  58139. }
  58140. });
  58141. /* eslint-disable no-invalid-this, valid-jsdoc */
  58142. /**
  58143. * Draw one of the handles on the side of the zoomed range in the navigator
  58144. *
  58145. * @private
  58146. * @function Highcharts.Renderer#symbols.navigator-handle
  58147. * @param {number} x
  58148. * @param {number} y
  58149. * @param {number} w
  58150. * @param {number} h
  58151. * @param {Highcharts.NavigatorHandlesOptions} options
  58152. * @return {Highcharts.SVGPathArray}
  58153. * Path to be used in a handle
  58154. */
  58155. H.Renderer.prototype.symbols['navigator-handle'] = function (x, y, w, h, options) {
  58156. var halfWidth = (options && options.width || 0) / 2,
  58157. markerPosition = Math.round(halfWidth / 3) + 0.5,
  58158. height = options && options.height || 0;
  58159. return [
  58160. ['M', -halfWidth - 1, 0.5],
  58161. ['L', halfWidth, 0.5],
  58162. ['L', halfWidth, height + 0.5],
  58163. ['L', -halfWidth - 1, height + 0.5],
  58164. ['L', -halfWidth - 1, 0.5],
  58165. ['M', -markerPosition, 4],
  58166. ['L', -markerPosition, height - 3],
  58167. ['M', markerPosition - 1, 4],
  58168. ['L', markerPosition - 1, height - 3]
  58169. ];
  58170. };
  58171. /**
  58172. * The Navigator class
  58173. *
  58174. * @private
  58175. * @class
  58176. * @name Highcharts.Navigator
  58177. *
  58178. * @param {Highcharts.Chart} chart
  58179. * Chart object
  58180. */
  58181. var Navigator = /** @class */ (function () {
  58182. function Navigator(chart) {
  58183. this.baseSeries = void 0;
  58184. this.chart = void 0;
  58185. this.handles = void 0;
  58186. this.height = void 0;
  58187. this.left = void 0;
  58188. this.navigatorEnabled = void 0;
  58189. this.navigatorGroup = void 0;
  58190. this.navigatorOptions = void 0;
  58191. this.navigatorSeries = void 0;
  58192. this.navigatorSize = void 0;
  58193. this.opposite = void 0;
  58194. this.outline = void 0;
  58195. this.outlineHeight = void 0;
  58196. this.range = void 0;
  58197. this.rendered = void 0;
  58198. this.shades = void 0;
  58199. this.size = void 0;
  58200. this.top = void 0;
  58201. this.xAxis = void 0;
  58202. this.yAxis = void 0;
  58203. this.zoomedMax = void 0;
  58204. this.zoomedMin = void 0;
  58205. this.init(chart);
  58206. }
  58207. /**
  58208. * Draw one of the handles on the side of the zoomed range in the navigator
  58209. *
  58210. * @private
  58211. * @function Highcharts.Navigator#drawHandle
  58212. *
  58213. * @param {number} x
  58214. * The x center for the handle
  58215. *
  58216. * @param {number} index
  58217. * 0 for left and 1 for right
  58218. *
  58219. * @param {boolean|undefined} inverted
  58220. * flag for chart.inverted
  58221. *
  58222. * @param {string} verb
  58223. * use 'animate' or 'attr'
  58224. */
  58225. Navigator.prototype.drawHandle = function (x, index, inverted, verb) {
  58226. var navigator = this,
  58227. height = navigator.navigatorOptions.handles.height;
  58228. // Place it
  58229. navigator.handles[index][verb](inverted ? {
  58230. translateX: Math.round(navigator.left + navigator.height / 2),
  58231. translateY: Math.round(navigator.top + parseInt(x, 10) + 0.5 - height)
  58232. } : {
  58233. translateX: Math.round(navigator.left + parseInt(x, 10)),
  58234. translateY: Math.round(navigator.top + navigator.height / 2 - height / 2 - 1)
  58235. });
  58236. };
  58237. /**
  58238. * Render outline around the zoomed range
  58239. *
  58240. * @private
  58241. * @function Highcharts.Navigator#drawOutline
  58242. *
  58243. * @param {number} zoomedMin
  58244. * in pixels position where zoomed range starts
  58245. *
  58246. * @param {number} zoomedMax
  58247. * in pixels position where zoomed range ends
  58248. *
  58249. * @param {boolean|undefined} inverted
  58250. * flag if chart is inverted
  58251. *
  58252. * @param {string} verb
  58253. * use 'animate' or 'attr'
  58254. */
  58255. Navigator.prototype.drawOutline = function (zoomedMin, zoomedMax, inverted, verb) {
  58256. var navigator = this,
  58257. maskInside = navigator.navigatorOptions.maskInside,
  58258. outlineWidth = navigator.outline.strokeWidth(),
  58259. halfOutline = outlineWidth / 2,
  58260. outlineCorrection = (outlineWidth % 2) / 2, // #5800
  58261. outlineHeight = navigator.outlineHeight,
  58262. scrollbarHeight = navigator.scrollbarHeight || 0,
  58263. navigatorSize = navigator.size,
  58264. left = navigator.left - scrollbarHeight,
  58265. navigatorTop = navigator.top,
  58266. verticalMin,
  58267. path;
  58268. if (inverted) {
  58269. left -= halfOutline;
  58270. verticalMin = navigatorTop + zoomedMax + outlineCorrection;
  58271. zoomedMax = navigatorTop + zoomedMin + outlineCorrection;
  58272. path = [
  58273. ['M', left + outlineHeight, navigatorTop - scrollbarHeight - outlineCorrection],
  58274. ['L', left + outlineHeight, verticalMin],
  58275. ['L', left, verticalMin],
  58276. ['L', left, zoomedMax],
  58277. ['L', left + outlineHeight, zoomedMax],
  58278. ['L', left + outlineHeight, navigatorTop + navigatorSize + scrollbarHeight]
  58279. ];
  58280. if (maskInside) {
  58281. path.push(['M', left + outlineHeight, verticalMin - halfOutline], // upper left of zoomed range
  58282. ['L', left + outlineHeight, zoomedMax + halfOutline] // upper right of z.r.
  58283. );
  58284. }
  58285. }
  58286. else {
  58287. zoomedMin += left + scrollbarHeight - outlineCorrection;
  58288. zoomedMax += left + scrollbarHeight - outlineCorrection;
  58289. navigatorTop += halfOutline;
  58290. path = [
  58291. ['M', left, navigatorTop],
  58292. ['L', zoomedMin, navigatorTop],
  58293. ['L', zoomedMin, navigatorTop + outlineHeight],
  58294. ['L', zoomedMax, navigatorTop + outlineHeight],
  58295. ['L', zoomedMax, navigatorTop],
  58296. ['L', left + navigatorSize + scrollbarHeight * 2, navigatorTop] // right
  58297. ];
  58298. if (maskInside) {
  58299. path.push(['M', zoomedMin - halfOutline, navigatorTop], // upper left of zoomed range
  58300. ['L', zoomedMax + halfOutline, navigatorTop] // upper right of z.r.
  58301. );
  58302. }
  58303. }
  58304. navigator.outline[verb]({
  58305. d: path
  58306. });
  58307. };
  58308. /**
  58309. * Render outline around the zoomed range
  58310. *
  58311. * @private
  58312. * @function Highcharts.Navigator#drawMasks
  58313. *
  58314. * @param {number} zoomedMin
  58315. * in pixels position where zoomed range starts
  58316. *
  58317. * @param {number} zoomedMax
  58318. * in pixels position where zoomed range ends
  58319. *
  58320. * @param {boolean|undefined} inverted
  58321. * flag if chart is inverted
  58322. *
  58323. * @param {string} verb
  58324. * use 'animate' or 'attr'
  58325. */
  58326. Navigator.prototype.drawMasks = function (zoomedMin, zoomedMax, inverted, verb) {
  58327. var navigator = this,
  58328. left = navigator.left,
  58329. top = navigator.top,
  58330. navigatorHeight = navigator.height,
  58331. height,
  58332. width,
  58333. x,
  58334. y;
  58335. // Determine rectangle position & size
  58336. // According to (non)inverted position:
  58337. if (inverted) {
  58338. x = [left, left, left];
  58339. y = [top, top + zoomedMin, top + zoomedMax];
  58340. width = [navigatorHeight, navigatorHeight, navigatorHeight];
  58341. height = [
  58342. zoomedMin,
  58343. zoomedMax - zoomedMin,
  58344. navigator.size - zoomedMax
  58345. ];
  58346. }
  58347. else {
  58348. x = [left, left + zoomedMin, left + zoomedMax];
  58349. y = [top, top, top];
  58350. width = [
  58351. zoomedMin,
  58352. zoomedMax - zoomedMin,
  58353. navigator.size - zoomedMax
  58354. ];
  58355. height = [navigatorHeight, navigatorHeight, navigatorHeight];
  58356. }
  58357. navigator.shades.forEach(function (shade, i) {
  58358. shade[verb]({
  58359. x: x[i],
  58360. y: y[i],
  58361. width: width[i],
  58362. height: height[i]
  58363. });
  58364. });
  58365. };
  58366. /**
  58367. * Generate DOM elements for a navigator:
  58368. *
  58369. * - main navigator group
  58370. *
  58371. * - all shades
  58372. *
  58373. * - outline
  58374. *
  58375. * - handles
  58376. *
  58377. * @private
  58378. * @function Highcharts.Navigator#renderElements
  58379. */
  58380. Navigator.prototype.renderElements = function () {
  58381. var navigator = this,
  58382. navigatorOptions = navigator.navigatorOptions,
  58383. maskInside = navigatorOptions.maskInside,
  58384. chart = navigator.chart,
  58385. inverted = chart.inverted,
  58386. renderer = chart.renderer,
  58387. navigatorGroup,
  58388. mouseCursor = {
  58389. cursor: inverted ? 'ns-resize' : 'ew-resize'
  58390. };
  58391. // Create the main navigator group
  58392. navigator.navigatorGroup = navigatorGroup = renderer.g('navigator')
  58393. .attr({
  58394. zIndex: 8,
  58395. visibility: 'hidden'
  58396. })
  58397. .add();
  58398. // Create masks, each mask will get events and fill:
  58399. [
  58400. !maskInside,
  58401. maskInside,
  58402. !maskInside
  58403. ].forEach(function (hasMask, index) {
  58404. navigator.shades[index] = renderer.rect()
  58405. .addClass('highcharts-navigator-mask' +
  58406. (index === 1 ? '-inside' : '-outside'))
  58407. .add(navigatorGroup);
  58408. if (!chart.styledMode) {
  58409. navigator.shades[index]
  58410. .attr({
  58411. fill: hasMask ?
  58412. navigatorOptions.maskFill :
  58413. 'rgba(0,0,0,0)'
  58414. })
  58415. .css((index === 1) && mouseCursor);
  58416. }
  58417. });
  58418. // Create the outline:
  58419. navigator.outline = renderer.path()
  58420. .addClass('highcharts-navigator-outline')
  58421. .add(navigatorGroup);
  58422. if (!chart.styledMode) {
  58423. navigator.outline.attr({
  58424. 'stroke-width': navigatorOptions.outlineWidth,
  58425. stroke: navigatorOptions.outlineColor
  58426. });
  58427. }
  58428. // Create the handlers:
  58429. if (navigatorOptions.handles.enabled) {
  58430. [0, 1].forEach(function (index) {
  58431. navigatorOptions.handles.inverted = chart.inverted;
  58432. navigator.handles[index] = renderer.symbol(navigatorOptions.handles.symbols[index], -navigatorOptions.handles.width / 2 - 1, 0, navigatorOptions.handles.width, navigatorOptions.handles.height, navigatorOptions.handles);
  58433. // zIndex = 6 for right handle, 7 for left.
  58434. // Can't be 10, because of the tooltip in inverted chart #2908
  58435. navigator.handles[index].attr({ zIndex: 7 - index })
  58436. .addClass('highcharts-navigator-handle ' +
  58437. 'highcharts-navigator-handle-' +
  58438. ['left', 'right'][index]).add(navigatorGroup);
  58439. if (!chart.styledMode) {
  58440. var handlesOptions = navigatorOptions.handles;
  58441. navigator.handles[index]
  58442. .attr({
  58443. fill: handlesOptions.backgroundColor,
  58444. stroke: handlesOptions.borderColor,
  58445. 'stroke-width': handlesOptions.lineWidth
  58446. })
  58447. .css(mouseCursor);
  58448. }
  58449. });
  58450. }
  58451. };
  58452. /**
  58453. * Update navigator
  58454. *
  58455. * @private
  58456. * @function Highcharts.Navigator#update
  58457. *
  58458. * @param {Highcharts.NavigatorOptions} options
  58459. * Options to merge in when updating navigator
  58460. */
  58461. Navigator.prototype.update = function (options) {
  58462. // Remove references to old navigator series in base series
  58463. (this.series || []).forEach(function (series) {
  58464. if (series.baseSeries) {
  58465. delete series.baseSeries.navigatorSeries;
  58466. }
  58467. });
  58468. // Destroy and rebuild navigator
  58469. this.destroy();
  58470. var chartOptions = this.chart.options;
  58471. merge(true, chartOptions.navigator, this.options, options);
  58472. this.init(this.chart);
  58473. };
  58474. /**
  58475. * Render the navigator
  58476. *
  58477. * @private
  58478. * @function Highcharts.Navigator#render
  58479. * @param {number} min
  58480. * X axis value minimum
  58481. * @param {number} max
  58482. * X axis value maximum
  58483. * @param {number} [pxMin]
  58484. * Pixel value minimum
  58485. * @param {number} [pxMax]
  58486. * Pixel value maximum
  58487. * @return {void}
  58488. */
  58489. Navigator.prototype.render = function (min, max, pxMin, pxMax) {
  58490. var navigator = this,
  58491. chart = navigator.chart,
  58492. navigatorWidth,
  58493. scrollbarLeft,
  58494. scrollbarTop,
  58495. scrollbarHeight = navigator.scrollbarHeight,
  58496. navigatorSize,
  58497. xAxis = navigator.xAxis,
  58498. pointRange = xAxis.pointRange || 0,
  58499. scrollbarXAxis = xAxis.navigatorAxis.fake ? chart.xAxis[0] : xAxis,
  58500. navigatorEnabled = navigator.navigatorEnabled,
  58501. zoomedMin,
  58502. zoomedMax,
  58503. rendered = navigator.rendered,
  58504. inverted = chart.inverted,
  58505. verb,
  58506. newMin,
  58507. newMax,
  58508. currentRange,
  58509. minRange = chart.xAxis[0].minRange,
  58510. maxRange = chart.xAxis[0].options.maxRange;
  58511. // Don't redraw while moving the handles (#4703).
  58512. if (this.hasDragged && !defined(pxMin)) {
  58513. return;
  58514. }
  58515. min = correctFloat(min - pointRange / 2);
  58516. max = correctFloat(max + pointRange / 2);
  58517. // Don't render the navigator until we have data (#486, #4202, #5172).
  58518. if (!isNumber(min) || !isNumber(max)) {
  58519. // However, if navigator was already rendered, we may need to resize
  58520. // it. For example hidden series, but visible navigator (#6022).
  58521. if (rendered) {
  58522. pxMin = 0;
  58523. pxMax = pick(xAxis.width, scrollbarXAxis.width);
  58524. }
  58525. else {
  58526. return;
  58527. }
  58528. }
  58529. navigator.left = pick(xAxis.left,
  58530. // in case of scrollbar only, without navigator
  58531. chart.plotLeft + scrollbarHeight +
  58532. (inverted ? chart.plotWidth : 0));
  58533. navigator.size = zoomedMax = navigatorSize = pick(xAxis.len, (inverted ? chart.plotHeight : chart.plotWidth) -
  58534. 2 * scrollbarHeight);
  58535. if (inverted) {
  58536. navigatorWidth = scrollbarHeight;
  58537. }
  58538. else {
  58539. navigatorWidth = navigatorSize + 2 * scrollbarHeight;
  58540. }
  58541. // Get the pixel position of the handles
  58542. pxMin = pick(pxMin, xAxis.toPixels(min, true));
  58543. pxMax = pick(pxMax, xAxis.toPixels(max, true));
  58544. // Verify (#1851, #2238)
  58545. if (!isNumber(pxMin) || Math.abs(pxMin) === Infinity) {
  58546. pxMin = 0;
  58547. pxMax = navigatorWidth;
  58548. }
  58549. // Are we below the minRange? (#2618, #6191)
  58550. newMin = xAxis.toValue(pxMin, true);
  58551. newMax = xAxis.toValue(pxMax, true);
  58552. currentRange = Math.abs(correctFloat(newMax - newMin));
  58553. if (currentRange < minRange) {
  58554. if (this.grabbedLeft) {
  58555. pxMin = xAxis.toPixels(newMax - minRange - pointRange, true);
  58556. }
  58557. else if (this.grabbedRight) {
  58558. pxMax = xAxis.toPixels(newMin + minRange + pointRange, true);
  58559. }
  58560. }
  58561. else if (defined(maxRange) &&
  58562. correctFloat(currentRange - pointRange) > maxRange) {
  58563. if (this.grabbedLeft) {
  58564. pxMin = xAxis.toPixels(newMax - maxRange - pointRange, true);
  58565. }
  58566. else if (this.grabbedRight) {
  58567. pxMax = xAxis.toPixels(newMin + maxRange + pointRange, true);
  58568. }
  58569. }
  58570. // Handles are allowed to cross, but never exceed the plot area
  58571. navigator.zoomedMax = clamp(Math.max(pxMin, pxMax), 0, zoomedMax);
  58572. navigator.zoomedMin = clamp(navigator.fixedWidth ?
  58573. navigator.zoomedMax - navigator.fixedWidth :
  58574. Math.min(pxMin, pxMax), 0, zoomedMax);
  58575. navigator.range = navigator.zoomedMax - navigator.zoomedMin;
  58576. zoomedMax = Math.round(navigator.zoomedMax);
  58577. zoomedMin = Math.round(navigator.zoomedMin);
  58578. if (navigatorEnabled) {
  58579. navigator.navigatorGroup.attr({
  58580. visibility: 'visible'
  58581. });
  58582. // Place elements
  58583. verb = rendered && !navigator.hasDragged ? 'animate' : 'attr';
  58584. navigator.drawMasks(zoomedMin, zoomedMax, inverted, verb);
  58585. navigator.drawOutline(zoomedMin, zoomedMax, inverted, verb);
  58586. if (navigator.navigatorOptions.handles.enabled) {
  58587. navigator.drawHandle(zoomedMin, 0, inverted, verb);
  58588. navigator.drawHandle(zoomedMax, 1, inverted, verb);
  58589. }
  58590. }
  58591. if (navigator.scrollbar) {
  58592. if (inverted) {
  58593. scrollbarTop = navigator.top - scrollbarHeight;
  58594. scrollbarLeft = navigator.left - scrollbarHeight +
  58595. (navigatorEnabled || !scrollbarXAxis.opposite ? 0 :
  58596. // Multiple axes has offsets:
  58597. (scrollbarXAxis.titleOffset || 0) +
  58598. // Self margin from the axis.title
  58599. scrollbarXAxis.axisTitleMargin);
  58600. scrollbarHeight = navigatorSize + 2 * scrollbarHeight;
  58601. }
  58602. else {
  58603. scrollbarTop = navigator.top + (navigatorEnabled ?
  58604. navigator.height :
  58605. -scrollbarHeight);
  58606. scrollbarLeft = navigator.left - scrollbarHeight;
  58607. }
  58608. // Reposition scrollbar
  58609. navigator.scrollbar.position(scrollbarLeft, scrollbarTop, navigatorWidth, scrollbarHeight);
  58610. // Keep scale 0-1
  58611. navigator.scrollbar.setRange(
  58612. // Use real value, not rounded because range can be very small
  58613. // (#1716)
  58614. navigator.zoomedMin / (navigatorSize || 1), navigator.zoomedMax / (navigatorSize || 1));
  58615. }
  58616. navigator.rendered = true;
  58617. };
  58618. /**
  58619. * Set up the mouse and touch events for the navigator
  58620. *
  58621. * @private
  58622. * @function Highcharts.Navigator#addMouseEvents
  58623. */
  58624. Navigator.prototype.addMouseEvents = function () {
  58625. var navigator = this,
  58626. chart = navigator.chart,
  58627. container = chart.container,
  58628. eventsToUnbind = [],
  58629. mouseMoveHandler,
  58630. mouseUpHandler;
  58631. /**
  58632. * Create mouse events' handlers.
  58633. * Make them as separate functions to enable wrapping them:
  58634. */
  58635. navigator.mouseMoveHandler = mouseMoveHandler = function (e) {
  58636. navigator.onMouseMove(e);
  58637. };
  58638. navigator.mouseUpHandler = mouseUpHandler = function (e) {
  58639. navigator.onMouseUp(e);
  58640. };
  58641. // Add shades and handles mousedown events
  58642. eventsToUnbind = navigator.getPartsEvents('mousedown');
  58643. // Add mouse move and mouseup events. These are bind to doc/container,
  58644. // because Navigator.grabbedSomething flags are stored in mousedown
  58645. // events
  58646. eventsToUnbind.push(addEvent(chart.renderTo, 'mousemove', mouseMoveHandler), addEvent(container.ownerDocument, 'mouseup', mouseUpHandler));
  58647. // Touch events
  58648. if (hasTouch) {
  58649. eventsToUnbind.push(addEvent(chart.renderTo, 'touchmove', mouseMoveHandler), addEvent(container.ownerDocument, 'touchend', mouseUpHandler));
  58650. eventsToUnbind.concat(navigator.getPartsEvents('touchstart'));
  58651. }
  58652. navigator.eventsToUnbind = eventsToUnbind;
  58653. // Data events
  58654. if (navigator.series && navigator.series[0]) {
  58655. eventsToUnbind.push(addEvent(navigator.series[0].xAxis, 'foundExtremes', function () {
  58656. chart.navigator.modifyNavigatorAxisExtremes();
  58657. }));
  58658. }
  58659. };
  58660. /**
  58661. * Generate events for handles and masks
  58662. *
  58663. * @private
  58664. * @function Highcharts.Navigator#getPartsEvents
  58665. *
  58666. * @param {string} eventName
  58667. * Event name handler, 'mousedown' or 'touchstart'
  58668. *
  58669. * @return {Array<Function>}
  58670. * An array of functions to remove navigator functions from the
  58671. * events again.
  58672. */
  58673. Navigator.prototype.getPartsEvents = function (eventName) {
  58674. var navigator = this,
  58675. events = [];
  58676. ['shades', 'handles'].forEach(function (name) {
  58677. navigator[name].forEach(function (navigatorItem, index) {
  58678. events.push(addEvent(navigatorItem.element, eventName, function (e) {
  58679. navigator[name + 'Mousedown'](e, index);
  58680. }));
  58681. });
  58682. });
  58683. return events;
  58684. };
  58685. /**
  58686. * Mousedown on a shaded mask, either:
  58687. *
  58688. * - will be stored for future drag&drop
  58689. *
  58690. * - will directly shift to a new range
  58691. *
  58692. * @private
  58693. * @function Highcharts.Navigator#shadesMousedown
  58694. *
  58695. * @param {Highcharts.PointerEventObject} e
  58696. * Mouse event
  58697. *
  58698. * @param {number} index
  58699. * Index of a mask in Navigator.shades array
  58700. */
  58701. Navigator.prototype.shadesMousedown = function (e, index) {
  58702. e = this.chart.pointer.normalize(e);
  58703. var navigator = this,
  58704. chart = navigator.chart,
  58705. xAxis = navigator.xAxis,
  58706. zoomedMin = navigator.zoomedMin,
  58707. navigatorPosition = navigator.left,
  58708. navigatorSize = navigator.size,
  58709. range = navigator.range,
  58710. chartX = e.chartX,
  58711. fixedMax,
  58712. fixedMin,
  58713. ext,
  58714. left;
  58715. // For inverted chart, swap some options:
  58716. if (chart.inverted) {
  58717. chartX = e.chartY;
  58718. navigatorPosition = navigator.top;
  58719. }
  58720. if (index === 1) {
  58721. // Store information for drag&drop
  58722. navigator.grabbedCenter = chartX;
  58723. navigator.fixedWidth = range;
  58724. navigator.dragOffset = chartX - zoomedMin;
  58725. }
  58726. else {
  58727. // Shift the range by clicking on shaded areas
  58728. left = chartX - navigatorPosition - range / 2;
  58729. if (index === 0) {
  58730. left = Math.max(0, left);
  58731. }
  58732. else if (index === 2 && left + range >= navigatorSize) {
  58733. left = navigatorSize - range;
  58734. if (navigator.reversedExtremes) {
  58735. // #7713
  58736. left -= range;
  58737. fixedMin = navigator.getUnionExtremes().dataMin;
  58738. }
  58739. else {
  58740. // #2293, #3543
  58741. fixedMax = navigator.getUnionExtremes().dataMax;
  58742. }
  58743. }
  58744. if (left !== zoomedMin) { // it has actually moved
  58745. navigator.fixedWidth = range; // #1370
  58746. ext = xAxis.navigatorAxis.toFixedRange(left, left + range, fixedMin, fixedMax);
  58747. if (defined(ext.min)) { // #7411
  58748. chart.xAxis[0].setExtremes(Math.min(ext.min, ext.max), Math.max(ext.min, ext.max), true, null, // auto animation
  58749. { trigger: 'navigator' });
  58750. }
  58751. }
  58752. }
  58753. };
  58754. /**
  58755. * Mousedown on a handle mask.
  58756. * Will store necessary information for drag&drop.
  58757. *
  58758. * @private
  58759. * @function Highcharts.Navigator#handlesMousedown
  58760. * @param {Highcharts.PointerEventObject} e
  58761. * Mouse event
  58762. * @param {number} index
  58763. * Index of a handle in Navigator.handles array
  58764. * @return {void}
  58765. */
  58766. Navigator.prototype.handlesMousedown = function (e, index) {
  58767. e = this.chart.pointer.normalize(e);
  58768. var navigator = this,
  58769. chart = navigator.chart,
  58770. baseXAxis = chart.xAxis[0],
  58771. // For reversed axes, min and max are changed,
  58772. // so the other extreme should be stored
  58773. reverse = navigator.reversedExtremes;
  58774. if (index === 0) {
  58775. // Grab the left handle
  58776. navigator.grabbedLeft = true;
  58777. navigator.otherHandlePos = navigator.zoomedMax;
  58778. navigator.fixedExtreme = reverse ? baseXAxis.min : baseXAxis.max;
  58779. }
  58780. else {
  58781. // Grab the right handle
  58782. navigator.grabbedRight = true;
  58783. navigator.otherHandlePos = navigator.zoomedMin;
  58784. navigator.fixedExtreme = reverse ? baseXAxis.max : baseXAxis.min;
  58785. }
  58786. chart.fixedRange = null;
  58787. };
  58788. /**
  58789. * Mouse move event based on x/y mouse position.
  58790. *
  58791. * @private
  58792. * @function Highcharts.Navigator#onMouseMove
  58793. *
  58794. * @param {Highcharts.PointerEventObject} e
  58795. * Mouse event
  58796. */
  58797. Navigator.prototype.onMouseMove = function (e) {
  58798. var navigator = this,
  58799. chart = navigator.chart,
  58800. left = navigator.left,
  58801. navigatorSize = navigator.navigatorSize,
  58802. range = navigator.range,
  58803. dragOffset = navigator.dragOffset,
  58804. inverted = chart.inverted,
  58805. chartX;
  58806. // In iOS, a mousemove event with e.pageX === 0 is fired when holding
  58807. // the finger down in the center of the scrollbar. This should be
  58808. // ignored.
  58809. if (!e.touches || e.touches[0].pageX !== 0) { // #4696
  58810. e = chart.pointer.normalize(e);
  58811. chartX = e.chartX;
  58812. // Swap some options for inverted chart
  58813. if (inverted) {
  58814. left = navigator.top;
  58815. chartX = e.chartY;
  58816. }
  58817. // Drag left handle or top handle
  58818. if (navigator.grabbedLeft) {
  58819. navigator.hasDragged = true;
  58820. navigator.render(0, 0, chartX - left, navigator.otherHandlePos);
  58821. // Drag right handle or bottom handle
  58822. }
  58823. else if (navigator.grabbedRight) {
  58824. navigator.hasDragged = true;
  58825. navigator.render(0, 0, navigator.otherHandlePos, chartX - left);
  58826. // Drag scrollbar or open area in navigator
  58827. }
  58828. else if (navigator.grabbedCenter) {
  58829. navigator.hasDragged = true;
  58830. if (chartX < dragOffset) { // outside left
  58831. chartX = dragOffset;
  58832. // outside right
  58833. }
  58834. else if (chartX >
  58835. navigatorSize + dragOffset - range) {
  58836. chartX = navigatorSize + dragOffset - range;
  58837. }
  58838. navigator.render(0, 0, chartX - dragOffset, chartX - dragOffset + range);
  58839. }
  58840. if (navigator.hasDragged &&
  58841. navigator.scrollbar &&
  58842. pick(navigator.scrollbar.options.liveRedraw,
  58843. // By default, don't run live redraw on VML, on touch
  58844. // devices or if the chart is in boost.
  58845. H.svg && !isTouchDevice && !this.chart.isBoosting)) {
  58846. e.DOMType = e.type; // DOMType is for IE8
  58847. setTimeout(function () {
  58848. navigator.onMouseUp(e);
  58849. }, 0);
  58850. }
  58851. }
  58852. };
  58853. /**
  58854. * Mouse up event based on x/y mouse position.
  58855. *
  58856. * @private
  58857. * @function Highcharts.Navigator#onMouseUp
  58858. * @param {Highcharts.PointerEventObject} e
  58859. * Mouse event
  58860. * @return {void}
  58861. */
  58862. Navigator.prototype.onMouseUp = function (e) {
  58863. var navigator = this,
  58864. chart = navigator.chart,
  58865. xAxis = navigator.xAxis,
  58866. scrollbar = navigator.scrollbar,
  58867. DOMEvent = e.DOMEvent || e,
  58868. inverted = chart.inverted,
  58869. verb = navigator.rendered && !navigator.hasDragged ?
  58870. 'animate' : 'attr',
  58871. zoomedMax,
  58872. zoomedMin,
  58873. unionExtremes,
  58874. fixedMin,
  58875. fixedMax,
  58876. ext;
  58877. if (
  58878. // MouseUp is called for both, navigator and scrollbar (that order),
  58879. // which causes calling afterSetExtremes twice. Prevent first call
  58880. // by checking if scrollbar is going to set new extremes (#6334)
  58881. (navigator.hasDragged && (!scrollbar || !scrollbar.hasDragged)) ||
  58882. e.trigger === 'scrollbar') {
  58883. unionExtremes = navigator.getUnionExtremes();
  58884. // When dragging one handle, make sure the other one doesn't change
  58885. if (navigator.zoomedMin === navigator.otherHandlePos) {
  58886. fixedMin = navigator.fixedExtreme;
  58887. }
  58888. else if (navigator.zoomedMax === navigator.otherHandlePos) {
  58889. fixedMax = navigator.fixedExtreme;
  58890. }
  58891. // Snap to right edge (#4076)
  58892. if (navigator.zoomedMax === navigator.size) {
  58893. fixedMax = navigator.reversedExtremes ?
  58894. unionExtremes.dataMin :
  58895. unionExtremes.dataMax;
  58896. }
  58897. // Snap to left edge (#7576)
  58898. if (navigator.zoomedMin === 0) {
  58899. fixedMin = navigator.reversedExtremes ?
  58900. unionExtremes.dataMax :
  58901. unionExtremes.dataMin;
  58902. }
  58903. ext = xAxis.navigatorAxis.toFixedRange(navigator.zoomedMin, navigator.zoomedMax, fixedMin, fixedMax);
  58904. if (defined(ext.min)) {
  58905. chart.xAxis[0].setExtremes(Math.min(ext.min, ext.max), Math.max(ext.min, ext.max), true,
  58906. // Run animation when clicking buttons, scrollbar track etc,
  58907. // but not when dragging handles or scrollbar
  58908. navigator.hasDragged ? false : null, {
  58909. trigger: 'navigator',
  58910. triggerOp: 'navigator-drag',
  58911. DOMEvent: DOMEvent // #1838
  58912. });
  58913. }
  58914. }
  58915. if (e.DOMType !== 'mousemove' &&
  58916. e.DOMType !== 'touchmove') {
  58917. navigator.grabbedLeft = navigator.grabbedRight =
  58918. navigator.grabbedCenter = navigator.fixedWidth =
  58919. navigator.fixedExtreme = navigator.otherHandlePos =
  58920. navigator.hasDragged = navigator.dragOffset = null;
  58921. }
  58922. // Update position of navigator shades, outline and handles (#12573)
  58923. if (navigator.navigatorEnabled &&
  58924. isNumber(navigator.zoomedMin) &&
  58925. isNumber(navigator.zoomedMax)) {
  58926. zoomedMin = Math.round(navigator.zoomedMin);
  58927. zoomedMax = Math.round(navigator.zoomedMax);
  58928. if (navigator.shades) {
  58929. navigator.drawMasks(zoomedMin, zoomedMax, inverted, verb);
  58930. }
  58931. if (navigator.outline) {
  58932. navigator.drawOutline(zoomedMin, zoomedMax, inverted, verb);
  58933. }
  58934. if (navigator.navigatorOptions.handles.enabled &&
  58935. Object.keys(navigator.handles).length ===
  58936. navigator.handles.length) {
  58937. navigator.drawHandle(zoomedMin, 0, inverted, verb);
  58938. navigator.drawHandle(zoomedMax, 1, inverted, verb);
  58939. }
  58940. }
  58941. };
  58942. /**
  58943. * Removes the event handlers attached previously with addEvents.
  58944. *
  58945. * @private
  58946. * @function Highcharts.Navigator#removeEvents
  58947. * @return {void}
  58948. */
  58949. Navigator.prototype.removeEvents = function () {
  58950. if (this.eventsToUnbind) {
  58951. this.eventsToUnbind.forEach(function (unbind) {
  58952. unbind();
  58953. });
  58954. this.eventsToUnbind = void 0;
  58955. }
  58956. this.removeBaseSeriesEvents();
  58957. };
  58958. /**
  58959. * Remove data events.
  58960. *
  58961. * @private
  58962. * @function Highcharts.Navigator#removeBaseSeriesEvents
  58963. * @return {void}
  58964. */
  58965. Navigator.prototype.removeBaseSeriesEvents = function () {
  58966. var baseSeries = this.baseSeries || [];
  58967. if (this.navigatorEnabled && baseSeries[0]) {
  58968. if (this.navigatorOptions.adaptToUpdatedData !== false) {
  58969. baseSeries.forEach(function (series) {
  58970. removeEvent(series, 'updatedData', this.updatedDataHandler);
  58971. }, this);
  58972. }
  58973. // We only listen for extremes-events on the first baseSeries
  58974. if (baseSeries[0].xAxis) {
  58975. removeEvent(baseSeries[0].xAxis, 'foundExtremes', this.modifyBaseAxisExtremes);
  58976. }
  58977. }
  58978. };
  58979. /**
  58980. * Initialize the Navigator object
  58981. *
  58982. * @private
  58983. * @function Highcharts.Navigator#init
  58984. *
  58985. * @param {Highcharts.Chart} chart
  58986. */
  58987. Navigator.prototype.init = function (chart) {
  58988. var chartOptions = chart.options,
  58989. navigatorOptions = chartOptions.navigator,
  58990. navigatorEnabled = navigatorOptions.enabled,
  58991. scrollbarOptions = chartOptions.scrollbar,
  58992. scrollbarEnabled = scrollbarOptions.enabled,
  58993. height = navigatorEnabled ? navigatorOptions.height : 0,
  58994. scrollbarHeight = scrollbarEnabled ?
  58995. scrollbarOptions.height :
  58996. 0;
  58997. this.handles = [];
  58998. this.shades = [];
  58999. this.chart = chart;
  59000. this.setBaseSeries();
  59001. this.height = height;
  59002. this.scrollbarHeight = scrollbarHeight;
  59003. this.scrollbarEnabled = scrollbarEnabled;
  59004. this.navigatorEnabled = navigatorEnabled;
  59005. this.navigatorOptions = navigatorOptions;
  59006. this.scrollbarOptions = scrollbarOptions;
  59007. this.outlineHeight = height + scrollbarHeight;
  59008. this.opposite = pick(navigatorOptions.opposite, Boolean(!navigatorEnabled && chart.inverted)); // #6262
  59009. var navigator = this,
  59010. baseSeries = navigator.baseSeries,
  59011. xAxisIndex = chart.xAxis.length,
  59012. yAxisIndex = chart.yAxis.length,
  59013. baseXaxis = baseSeries && baseSeries[0] && baseSeries[0].xAxis ||
  59014. chart.xAxis[0] || { options: {} };
  59015. chart.isDirtyBox = true;
  59016. if (navigator.navigatorEnabled) {
  59017. // an x axis is required for scrollbar also
  59018. navigator.xAxis = new Axis(chart, merge({
  59019. // inherit base xAxis' break and ordinal options
  59020. breaks: baseXaxis.options.breaks,
  59021. ordinal: baseXaxis.options.ordinal
  59022. }, navigatorOptions.xAxis, {
  59023. id: 'navigator-x-axis',
  59024. yAxis: 'navigator-y-axis',
  59025. isX: true,
  59026. type: 'datetime',
  59027. index: xAxisIndex,
  59028. isInternal: true,
  59029. offset: 0,
  59030. keepOrdinalPadding: true,
  59031. startOnTick: false,
  59032. endOnTick: false,
  59033. minPadding: 0,
  59034. maxPadding: 0,
  59035. zoomEnabled: false
  59036. }, chart.inverted ? {
  59037. offsets: [scrollbarHeight, 0, -scrollbarHeight, 0],
  59038. width: height
  59039. } : {
  59040. offsets: [0, -scrollbarHeight, 0, scrollbarHeight],
  59041. height: height
  59042. }));
  59043. navigator.yAxis = new Axis(chart, merge(navigatorOptions.yAxis, {
  59044. id: 'navigator-y-axis',
  59045. alignTicks: false,
  59046. offset: 0,
  59047. index: yAxisIndex,
  59048. isInternal: true,
  59049. reversed: pick((navigatorOptions.yAxis && navigatorOptions.yAxis.reversed), (chart.yAxis[0] && chart.yAxis[0].reversed), false),
  59050. zoomEnabled: false
  59051. }, chart.inverted ? {
  59052. width: height
  59053. } : {
  59054. height: height
  59055. }));
  59056. // If we have a base series, initialize the navigator series
  59057. if (baseSeries || navigatorOptions.series.data) {
  59058. navigator.updateNavigatorSeries(false);
  59059. // If not, set up an event to listen for added series
  59060. }
  59061. else if (chart.series.length === 0) {
  59062. navigator.unbindRedraw = addEvent(chart, 'beforeRedraw', function () {
  59063. // We've got one, now add it as base
  59064. if (chart.series.length > 0 && !navigator.series) {
  59065. navigator.setBaseSeries();
  59066. navigator.unbindRedraw(); // reset
  59067. }
  59068. });
  59069. }
  59070. navigator.reversedExtremes = (chart.inverted && !navigator.xAxis.reversed) || (!chart.inverted && navigator.xAxis.reversed);
  59071. // Render items, so we can bind events to them:
  59072. navigator.renderElements();
  59073. // Add mouse events
  59074. navigator.addMouseEvents();
  59075. // in case of scrollbar only, fake an x axis to get translation
  59076. }
  59077. else {
  59078. navigator.xAxis = {
  59079. chart: chart,
  59080. navigatorAxis: {
  59081. fake: true
  59082. },
  59083. translate: function (value, reverse) {
  59084. var axis = chart.xAxis[0], ext = axis.getExtremes(), scrollTrackWidth = axis.len - 2 * scrollbarHeight, min = numExt('min', axis.options.min, ext.dataMin), valueRange = numExt('max', axis.options.max, ext.dataMax) - min;
  59085. return reverse ?
  59086. // from pixel to value
  59087. (value * valueRange / scrollTrackWidth) + min :
  59088. // from value to pixel
  59089. scrollTrackWidth * (value - min) / valueRange;
  59090. },
  59091. toPixels: function (value) {
  59092. return this.translate(value);
  59093. },
  59094. toValue: function (value) {
  59095. return this.translate(value, true);
  59096. }
  59097. };
  59098. navigator.xAxis.navigatorAxis.axis = navigator.xAxis;
  59099. navigator.xAxis.navigatorAxis.toFixedRange = (NavigatorAxis.AdditionsClass.prototype.toFixedRange.bind(navigator.xAxis.navigatorAxis));
  59100. }
  59101. // Initialize the scrollbar
  59102. if (chart.options.scrollbar.enabled) {
  59103. chart.scrollbar = navigator.scrollbar = new Scrollbar(chart.renderer, merge(chart.options.scrollbar, {
  59104. margin: navigator.navigatorEnabled ? 0 : 10,
  59105. vertical: chart.inverted
  59106. }), chart);
  59107. addEvent(navigator.scrollbar, 'changed', function (e) {
  59108. var range = navigator.size,
  59109. to = range * this.to,
  59110. from = range * this.from;
  59111. navigator.hasDragged = navigator.scrollbar.hasDragged;
  59112. navigator.render(0, 0, from, to);
  59113. if (this.shouldUpdateExtremes(e.DOMType)) {
  59114. setTimeout(function () {
  59115. navigator.onMouseUp(e);
  59116. });
  59117. }
  59118. });
  59119. }
  59120. // Add data events
  59121. navigator.addBaseSeriesEvents();
  59122. // Add redraw events
  59123. navigator.addChartEvents();
  59124. };
  59125. /**
  59126. * Get the union data extremes of the chart - the outer data extremes of the
  59127. * base X axis and the navigator axis.
  59128. *
  59129. * @private
  59130. * @function Highcharts.Navigator#getUnionExtremes
  59131. * @param {boolean} [returnFalseOnNoBaseSeries]
  59132. * as the param says.
  59133. * @return {Highcharts.Dictionary<(number|undefined)>|undefined}
  59134. */
  59135. Navigator.prototype.getUnionExtremes = function (returnFalseOnNoBaseSeries) {
  59136. var baseAxis = this.chart.xAxis[0],
  59137. navAxis = this.xAxis,
  59138. navAxisOptions = navAxis.options,
  59139. baseAxisOptions = baseAxis.options,
  59140. ret;
  59141. if (!returnFalseOnNoBaseSeries || baseAxis.dataMin !== null) {
  59142. ret = {
  59143. dataMin: pick(// #4053
  59144. navAxisOptions && navAxisOptions.min, numExt('min', baseAxisOptions.min, baseAxis.dataMin, navAxis.dataMin, navAxis.min)),
  59145. dataMax: pick(navAxisOptions && navAxisOptions.max, numExt('max', baseAxisOptions.max, baseAxis.dataMax, navAxis.dataMax, navAxis.max))
  59146. };
  59147. }
  59148. return ret;
  59149. };
  59150. /**
  59151. * Set the base series and update the navigator series from this. With a bit
  59152. * of modification we should be able to make this an API method to be called
  59153. * from the outside
  59154. *
  59155. * @private
  59156. * @function Highcharts.Navigator#setBaseSeries
  59157. * @param {Highcharts.SeriesOptionsType} [baseSeriesOptions]
  59158. * Additional series options for a navigator
  59159. * @param {boolean} [redraw]
  59160. * Whether to redraw after update.
  59161. * @return {void}
  59162. */
  59163. Navigator.prototype.setBaseSeries = function (baseSeriesOptions, redraw) {
  59164. var chart = this.chart,
  59165. baseSeries = this.baseSeries = [];
  59166. baseSeriesOptions = (baseSeriesOptions ||
  59167. chart.options && chart.options.navigator.baseSeries ||
  59168. (chart.series.length ?
  59169. // Find the first non-navigator series (#8430)
  59170. find(chart.series, function (s) {
  59171. return !s.options.isInternal;
  59172. }).index :
  59173. 0));
  59174. // Iterate through series and add the ones that should be shown in
  59175. // navigator.
  59176. (chart.series || []).forEach(function (series, i) {
  59177. if (
  59178. // Don't include existing nav series
  59179. !series.options.isInternal &&
  59180. (series.options.showInNavigator ||
  59181. (i === baseSeriesOptions ||
  59182. series.options.id === baseSeriesOptions) &&
  59183. series.options.showInNavigator !== false)) {
  59184. baseSeries.push(series);
  59185. }
  59186. });
  59187. // When run after render, this.xAxis already exists
  59188. if (this.xAxis && !this.xAxis.navigatorAxis.fake) {
  59189. this.updateNavigatorSeries(true, redraw);
  59190. }
  59191. };
  59192. /**
  59193. * Update series in the navigator from baseSeries, adding new if does not
  59194. * exist.
  59195. *
  59196. * @private
  59197. * @function Highcharts.Navigator.updateNavigatorSeries
  59198. * @param {boolean} addEvents
  59199. * @param {boolean} [redraw]
  59200. * @return {void}
  59201. */
  59202. Navigator.prototype.updateNavigatorSeries = function (addEvents, redraw) {
  59203. var navigator = this,
  59204. chart = navigator.chart,
  59205. baseSeries = navigator.baseSeries,
  59206. baseOptions,
  59207. mergedNavSeriesOptions,
  59208. chartNavigatorSeriesOptions = navigator.navigatorOptions.series,
  59209. baseNavigatorOptions,
  59210. navSeriesMixin = {
  59211. enableMouseTracking: false,
  59212. index: null,
  59213. linkedTo: null,
  59214. group: 'nav',
  59215. padXAxis: false,
  59216. xAxis: 'navigator-x-axis',
  59217. yAxis: 'navigator-y-axis',
  59218. showInLegend: false,
  59219. stacking: void 0,
  59220. isInternal: true,
  59221. states: {
  59222. inactive: {
  59223. opacity: 1
  59224. }
  59225. }
  59226. },
  59227. // Remove navigator series that are no longer in the baseSeries
  59228. navigatorSeries = navigator.series =
  59229. (navigator.series || []).filter(function (navSeries) {
  59230. var base = navSeries.baseSeries;
  59231. if (baseSeries.indexOf(base) < 0) { // Not in array
  59232. // If there is still a base series connected to this
  59233. // series, remove event handler and reference.
  59234. if (base) {
  59235. removeEvent(base, 'updatedData', navigator.updatedDataHandler);
  59236. delete base.navigatorSeries;
  59237. }
  59238. // Kill the nav series. It may already have been
  59239. // destroyed (#8715).
  59240. if (navSeries.chart) {
  59241. navSeries.destroy();
  59242. }
  59243. return false;
  59244. }
  59245. return true;
  59246. });
  59247. // Go through each base series and merge the options to create new
  59248. // series
  59249. if (baseSeries && baseSeries.length) {
  59250. baseSeries.forEach(function eachBaseSeries(base) {
  59251. var linkedNavSeries = base.navigatorSeries,
  59252. userNavOptions = extend(
  59253. // Grab color and visibility from base as default
  59254. {
  59255. color: base.color,
  59256. visible: base.visible
  59257. }, !isArray(chartNavigatorSeriesOptions) ?
  59258. chartNavigatorSeriesOptions :
  59259. defaultOptions.navigator.series);
  59260. // Don't update if the series exists in nav and we have disabled
  59261. // adaptToUpdatedData.
  59262. if (linkedNavSeries &&
  59263. navigator.navigatorOptions.adaptToUpdatedData === false) {
  59264. return;
  59265. }
  59266. navSeriesMixin.name = 'Navigator ' + baseSeries.length;
  59267. baseOptions = base.options || {};
  59268. baseNavigatorOptions = baseOptions.navigatorOptions || {};
  59269. // The dataLabels options are not merged correctly
  59270. // if the settings are an array, #13847.
  59271. userNavOptions.dataLabels = splat(userNavOptions.dataLabels);
  59272. mergedNavSeriesOptions = merge(baseOptions, navSeriesMixin, userNavOptions, baseNavigatorOptions);
  59273. // Once nav series type is resolved, pick correct pointRange
  59274. mergedNavSeriesOptions.pointRange = pick(
  59275. // Stricte set pointRange in options
  59276. userNavOptions.pointRange, baseNavigatorOptions.pointRange,
  59277. // Fallback to default values, e.g. `null` for column
  59278. defaultOptions.plotOptions[mergedNavSeriesOptions.type || 'line'].pointRange);
  59279. // Merge data separately. Do a slice to avoid mutating the
  59280. // navigator options from base series (#4923).
  59281. var navigatorSeriesData = baseNavigatorOptions.data || userNavOptions.data;
  59282. navigator.hasNavigatorData =
  59283. navigator.hasNavigatorData || !!navigatorSeriesData;
  59284. mergedNavSeriesOptions.data =
  59285. navigatorSeriesData ||
  59286. baseOptions.data && baseOptions.data.slice(0);
  59287. // Update or add the series
  59288. if (linkedNavSeries && linkedNavSeries.options) {
  59289. linkedNavSeries.update(mergedNavSeriesOptions, redraw);
  59290. }
  59291. else {
  59292. base.navigatorSeries = chart.initSeries(mergedNavSeriesOptions);
  59293. base.navigatorSeries.baseSeries = base; // Store ref
  59294. navigatorSeries.push(base.navigatorSeries);
  59295. }
  59296. });
  59297. }
  59298. // If user has defined data (and no base series) or explicitly defined
  59299. // navigator.series as an array, we create these series on top of any
  59300. // base series.
  59301. if (chartNavigatorSeriesOptions.data &&
  59302. !(baseSeries && baseSeries.length) ||
  59303. isArray(chartNavigatorSeriesOptions)) {
  59304. navigator.hasNavigatorData = false;
  59305. // Allow navigator.series to be an array
  59306. chartNavigatorSeriesOptions =
  59307. splat(chartNavigatorSeriesOptions);
  59308. chartNavigatorSeriesOptions.forEach(function (userSeriesOptions, i) {
  59309. navSeriesMixin.name =
  59310. 'Navigator ' + (navigatorSeries.length + 1);
  59311. mergedNavSeriesOptions = merge(defaultOptions.navigator.series, {
  59312. // Since we don't have a base series to pull color from,
  59313. // try to fake it by using color from series with same
  59314. // index. Otherwise pull from the colors array. We need
  59315. // an explicit color as otherwise updates will increment
  59316. // color counter and we'll get a new color for each
  59317. // update of the nav series.
  59318. color: chart.series[i] &&
  59319. !chart.series[i].options.isInternal &&
  59320. chart.series[i].color ||
  59321. chart.options.colors[i] ||
  59322. chart.options.colors[0]
  59323. }, navSeriesMixin, userSeriesOptions);
  59324. mergedNavSeriesOptions.data = userSeriesOptions.data;
  59325. if (mergedNavSeriesOptions.data) {
  59326. navigator.hasNavigatorData = true;
  59327. navigatorSeries.push(chart.initSeries(mergedNavSeriesOptions));
  59328. }
  59329. });
  59330. }
  59331. if (addEvents) {
  59332. this.addBaseSeriesEvents();
  59333. }
  59334. };
  59335. /**
  59336. * Add data events.
  59337. * For example when main series is updated we need to recalculate extremes
  59338. *
  59339. * @private
  59340. * @function Highcharts.Navigator#addBaseSeriesEvent
  59341. * @return {void}
  59342. */
  59343. Navigator.prototype.addBaseSeriesEvents = function () {
  59344. var navigator = this,
  59345. baseSeries = navigator.baseSeries || [];
  59346. // Bind modified extremes event to first base's xAxis only.
  59347. // In event of > 1 base-xAxes, the navigator will ignore those.
  59348. // Adding this multiple times to the same axis is no problem, as
  59349. // duplicates should be discarded by the browser.
  59350. if (baseSeries[0] && baseSeries[0].xAxis) {
  59351. baseSeries[0].eventsToUnbind.push(addEvent(baseSeries[0].xAxis, 'foundExtremes', this.modifyBaseAxisExtremes));
  59352. }
  59353. baseSeries.forEach(function (base) {
  59354. // Link base series show/hide to navigator series visibility
  59355. base.eventsToUnbind.push(addEvent(base, 'show', function () {
  59356. if (this.navigatorSeries) {
  59357. this.navigatorSeries.setVisible(true, false);
  59358. }
  59359. }));
  59360. base.eventsToUnbind.push(addEvent(base, 'hide', function () {
  59361. if (this.navigatorSeries) {
  59362. this.navigatorSeries.setVisible(false, false);
  59363. }
  59364. }));
  59365. // Respond to updated data in the base series, unless explicitily
  59366. // not adapting to data changes.
  59367. if (this.navigatorOptions.adaptToUpdatedData !== false) {
  59368. if (base.xAxis) {
  59369. base.eventsToUnbind.push(addEvent(base, 'updatedData', this.updatedDataHandler));
  59370. }
  59371. }
  59372. // Handle series removal
  59373. base.eventsToUnbind.push(addEvent(base, 'remove', function () {
  59374. if (this.navigatorSeries) {
  59375. erase(navigator.series, this.navigatorSeries);
  59376. if (defined(this.navigatorSeries.options)) {
  59377. this.navigatorSeries.remove(false);
  59378. }
  59379. delete this.navigatorSeries;
  59380. }
  59381. }));
  59382. }, this);
  59383. };
  59384. /**
  59385. * Get minimum from all base series connected to the navigator
  59386. * @private
  59387. * @param {number} currentSeriesMin
  59388. * Minium from the current series
  59389. * @return {number} Minimum from all series
  59390. */
  59391. Navigator.prototype.getBaseSeriesMin = function (currentSeriesMin) {
  59392. return this.baseSeries.reduce(function (min, series) {
  59393. // (#10193)
  59394. return Math.min(min, series.xData ? series.xData[0] : min);
  59395. }, currentSeriesMin);
  59396. };
  59397. /**
  59398. * Set the navigator x axis extremes to reflect the total. The navigator
  59399. * extremes should always be the extremes of the union of all series in the
  59400. * chart as well as the navigator series.
  59401. *
  59402. * @private
  59403. * @function Highcharts.Navigator#modifyNavigatorAxisExtremes
  59404. */
  59405. Navigator.prototype.modifyNavigatorAxisExtremes = function () {
  59406. var xAxis = this.xAxis,
  59407. unionExtremes;
  59408. if (typeof xAxis.getExtremes !== 'undefined') {
  59409. unionExtremes = this.getUnionExtremes(true);
  59410. if (unionExtremes &&
  59411. (unionExtremes.dataMin !== xAxis.min ||
  59412. unionExtremes.dataMax !== xAxis.max)) {
  59413. xAxis.min = unionExtremes.dataMin;
  59414. xAxis.max = unionExtremes.dataMax;
  59415. }
  59416. }
  59417. };
  59418. /**
  59419. * Hook to modify the base axis extremes with information from the Navigator
  59420. *
  59421. * @private
  59422. * @function Highcharts.Navigator#modifyBaseAxisExtremes
  59423. */
  59424. Navigator.prototype.modifyBaseAxisExtremes = function () {
  59425. var baseXAxis = this,
  59426. navigator = baseXAxis.chart.navigator,
  59427. baseExtremes = baseXAxis.getExtremes(),
  59428. baseMin = baseExtremes.min,
  59429. baseMax = baseExtremes.max,
  59430. baseDataMin = baseExtremes.dataMin,
  59431. baseDataMax = baseExtremes.dataMax,
  59432. range = baseMax - baseMin,
  59433. stickToMin = navigator.stickToMin,
  59434. stickToMax = navigator.stickToMax,
  59435. overscroll = pick(baseXAxis.options.overscroll, 0),
  59436. newMax,
  59437. newMin,
  59438. navigatorSeries = navigator.series && navigator.series[0],
  59439. hasSetExtremes = !!baseXAxis.setExtremes,
  59440. // When the extremes have been set by range selector button, don't
  59441. // stick to min or max. The range selector buttons will handle the
  59442. // extremes. (#5489)
  59443. unmutable = baseXAxis.eventArgs &&
  59444. baseXAxis.eventArgs.trigger === 'rangeSelectorButton';
  59445. if (!unmutable) {
  59446. // If the zoomed range is already at the min, move it to the right
  59447. // as new data comes in
  59448. if (stickToMin) {
  59449. newMin = baseDataMin;
  59450. newMax = newMin + range;
  59451. }
  59452. // If the zoomed range is already at the max, move it to the right
  59453. // as new data comes in
  59454. if (stickToMax) {
  59455. newMax = baseDataMax + overscroll;
  59456. // If stickToMin is true, the new min value is set above
  59457. if (!stickToMin) {
  59458. newMin = Math.max(baseDataMin, // don't go below data extremes (#13184)
  59459. newMax - range, navigator.getBaseSeriesMin(navigatorSeries && navigatorSeries.xData ?
  59460. navigatorSeries.xData[0] :
  59461. -Number.MAX_VALUE));
  59462. }
  59463. }
  59464. // Update the extremes
  59465. if (hasSetExtremes && (stickToMin || stickToMax)) {
  59466. if (isNumber(newMin)) {
  59467. baseXAxis.min = baseXAxis.userMin = newMin;
  59468. baseXAxis.max = baseXAxis.userMax = newMax;
  59469. }
  59470. }
  59471. }
  59472. // Reset
  59473. navigator.stickToMin =
  59474. navigator.stickToMax = null;
  59475. };
  59476. /**
  59477. * Handler for updated data on the base series. When data is modified, the
  59478. * navigator series must reflect it. This is called from the Chart.redraw
  59479. * function before axis and series extremes are computed.
  59480. *
  59481. * @private
  59482. * @function Highcharts.Navigator#updateDataHandler
  59483. */
  59484. Navigator.prototype.updatedDataHandler = function () {
  59485. var navigator = this.chart.navigator,
  59486. baseSeries = this,
  59487. navigatorSeries = this.navigatorSeries,
  59488. xDataMin = navigator.getBaseSeriesMin(baseSeries.xData[0]);
  59489. // If the scrollbar is scrolled all the way to the right, keep right as
  59490. // new data comes in.
  59491. navigator.stickToMax = navigator.reversedExtremes ?
  59492. Math.round(navigator.zoomedMin) === 0 :
  59493. Math.round(navigator.zoomedMax) >= Math.round(navigator.size);
  59494. // Detect whether the zoomed area should stick to the minimum or
  59495. // maximum. If the current axis minimum falls outside the new updated
  59496. // dataset, we must adjust.
  59497. navigator.stickToMin = isNumber(baseSeries.xAxis.min) &&
  59498. (baseSeries.xAxis.min <= xDataMin) &&
  59499. (!this.chart.fixedRange || !navigator.stickToMax);
  59500. // Set the navigator series data to the new data of the base series
  59501. if (navigatorSeries && !navigator.hasNavigatorData) {
  59502. navigatorSeries.options.pointStart = baseSeries.xData[0];
  59503. navigatorSeries.setData(baseSeries.options.data, false, null, false); // #5414
  59504. }
  59505. };
  59506. /**
  59507. * Add chart events, like redrawing navigator, when chart requires that.
  59508. *
  59509. * @private
  59510. * @function Highcharts.Navigator#addChartEvents
  59511. * @return {void}
  59512. */
  59513. Navigator.prototype.addChartEvents = function () {
  59514. if (!this.eventsToUnbind) {
  59515. this.eventsToUnbind = [];
  59516. }
  59517. this.eventsToUnbind.push(
  59518. // Move the scrollbar after redraw, like after data updata even if
  59519. // axes don't redraw
  59520. addEvent(this.chart, 'redraw', function () {
  59521. var navigator = this.navigator,
  59522. xAxis = navigator && (navigator.baseSeries &&
  59523. navigator.baseSeries[0] &&
  59524. navigator.baseSeries[0].xAxis ||
  59525. this.xAxis[0]); // #5709, #13114
  59526. if (xAxis) {
  59527. navigator.render(xAxis.min,
  59528. xAxis.max);
  59529. }
  59530. }),
  59531. // Make room for the navigator, can be placed around the chart:
  59532. addEvent(this.chart, 'getMargins', function () {
  59533. var chart = this,
  59534. navigator = chart.navigator,
  59535. marginName = navigator.opposite ?
  59536. 'plotTop' : 'marginBottom';
  59537. if (chart.inverted) {
  59538. marginName = navigator.opposite ?
  59539. 'marginRight' : 'plotLeft';
  59540. }
  59541. chart[marginName] =
  59542. (chart[marginName] || 0) + (navigator.navigatorEnabled || !chart.inverted ?
  59543. navigator.outlineHeight :
  59544. 0) + navigator.navigatorOptions.margin;
  59545. }));
  59546. };
  59547. /**
  59548. * Destroys allocated elements.
  59549. *
  59550. * @private
  59551. * @function Highcharts.Navigator#destroy
  59552. */
  59553. Navigator.prototype.destroy = function () {
  59554. // Disconnect events added in addEvents
  59555. this.removeEvents();
  59556. if (this.xAxis) {
  59557. erase(this.chart.xAxis, this.xAxis);
  59558. erase(this.chart.axes, this.xAxis);
  59559. }
  59560. if (this.yAxis) {
  59561. erase(this.chart.yAxis, this.yAxis);
  59562. erase(this.chart.axes, this.yAxis);
  59563. }
  59564. // Destroy series
  59565. (this.series || []).forEach(function (s) {
  59566. if (s.destroy) {
  59567. s.destroy();
  59568. }
  59569. });
  59570. // Destroy properties
  59571. [
  59572. 'series', 'xAxis', 'yAxis', 'shades', 'outline', 'scrollbarTrack',
  59573. 'scrollbarRifles', 'scrollbarGroup', 'scrollbar', 'navigatorGroup',
  59574. 'rendered'
  59575. ].forEach(function (prop) {
  59576. if (this[prop] && this[prop].destroy) {
  59577. this[prop].destroy();
  59578. }
  59579. this[prop] = null;
  59580. }, this);
  59581. // Destroy elements in collection
  59582. [this.handles].forEach(function (coll) {
  59583. destroyObjectProperties(coll);
  59584. }, this);
  59585. };
  59586. return Navigator;
  59587. }());
  59588. // End of prototype
  59589. if (!H.Navigator) {
  59590. H.Navigator = Navigator;
  59591. NavigatorAxis.compose(Axis);
  59592. // For Stock charts. For x only zooming, do not to create the zoom button
  59593. // because X axis zooming is already allowed by the Navigator and Range
  59594. // selector. (#9285)
  59595. addEvent(Chart, 'beforeShowResetZoom', function () {
  59596. var chartOptions = this.options,
  59597. navigator = chartOptions.navigator,
  59598. rangeSelector = chartOptions.rangeSelector;
  59599. if (((navigator && navigator.enabled) ||
  59600. (rangeSelector && rangeSelector.enabled)) &&
  59601. ((!isTouchDevice && chartOptions.chart.zoomType === 'x') ||
  59602. (isTouchDevice && chartOptions.chart.pinchType === 'x'))) {
  59603. return false;
  59604. }
  59605. });
  59606. // Initialize navigator for stock charts
  59607. addEvent(Chart, 'beforeRender', function () {
  59608. var options = this.options;
  59609. if (options.navigator.enabled ||
  59610. options.scrollbar.enabled) {
  59611. this.scroller = this.navigator = new Navigator(this);
  59612. }
  59613. });
  59614. // For stock charts, extend the Chart.setChartSize method so that we can set
  59615. // the final top position of the navigator once the height of the chart,
  59616. // including the legend, is determined. #367. We can't use Chart.getMargins,
  59617. // because labels offsets are not calculated yet.
  59618. addEvent(Chart, 'afterSetChartSize', function () {
  59619. var legend = this.legend,
  59620. navigator = this.navigator,
  59621. scrollbarHeight,
  59622. legendOptions,
  59623. xAxis,
  59624. yAxis;
  59625. if (navigator) {
  59626. legendOptions = legend && legend.options;
  59627. xAxis = navigator.xAxis;
  59628. yAxis = navigator.yAxis;
  59629. scrollbarHeight = navigator.scrollbarHeight;
  59630. // Compute the top position
  59631. if (this.inverted) {
  59632. navigator.left = navigator.opposite ?
  59633. this.chartWidth - scrollbarHeight -
  59634. navigator.height :
  59635. this.spacing[3] + scrollbarHeight;
  59636. navigator.top = this.plotTop + scrollbarHeight;
  59637. }
  59638. else {
  59639. navigator.left = this.plotLeft + scrollbarHeight;
  59640. navigator.top = navigator.navigatorOptions.top ||
  59641. this.chartHeight -
  59642. navigator.height -
  59643. scrollbarHeight -
  59644. this.spacing[2] -
  59645. (this.rangeSelector && this.extraBottomMargin ?
  59646. this.rangeSelector.getHeight() :
  59647. 0) -
  59648. ((legendOptions &&
  59649. legendOptions.verticalAlign === 'bottom' &&
  59650. legendOptions.layout !== 'proximate' && // #13392
  59651. legendOptions.enabled &&
  59652. !legendOptions.floating) ?
  59653. legend.legendHeight +
  59654. pick(legendOptions.margin, 10) :
  59655. 0) -
  59656. (this.titleOffset ? this.titleOffset[2] : 0);
  59657. }
  59658. if (xAxis && yAxis) { // false if navigator is disabled (#904)
  59659. if (this.inverted) {
  59660. xAxis.options.left = yAxis.options.left = navigator.left;
  59661. }
  59662. else {
  59663. xAxis.options.top = yAxis.options.top = navigator.top;
  59664. }
  59665. xAxis.setAxisSize();
  59666. yAxis.setAxisSize();
  59667. }
  59668. }
  59669. });
  59670. // Merge options, if no scrolling exists yet
  59671. addEvent(Chart, 'update', function (e) {
  59672. var navigatorOptions = (e.options.navigator || {}),
  59673. scrollbarOptions = (e.options.scrollbar || {});
  59674. if (!this.navigator && !this.scroller &&
  59675. (navigatorOptions.enabled || scrollbarOptions.enabled)) {
  59676. merge(true, this.options.navigator, navigatorOptions);
  59677. merge(true, this.options.scrollbar, scrollbarOptions);
  59678. delete e.options.navigator;
  59679. delete e.options.scrollbar;
  59680. }
  59681. });
  59682. // Initialize navigator, if no scrolling exists yet
  59683. addEvent(Chart, 'afterUpdate', function (event) {
  59684. if (!this.navigator && !this.scroller &&
  59685. (this.options.navigator.enabled ||
  59686. this.options.scrollbar.enabled)) {
  59687. this.scroller = this.navigator = new Navigator(this);
  59688. if (pick(event.redraw, true)) {
  59689. this.redraw(event.animation); // #7067
  59690. }
  59691. }
  59692. });
  59693. // Handle adding new series
  59694. addEvent(Chart, 'afterAddSeries', function () {
  59695. if (this.navigator) {
  59696. // Recompute which series should be shown in navigator, and add them
  59697. this.navigator.setBaseSeries(null, false);
  59698. }
  59699. });
  59700. // Handle updating series
  59701. addEvent(Series, 'afterUpdate', function () {
  59702. if (this.chart.navigator && !this.options.isInternal) {
  59703. this.chart.navigator.setBaseSeries(null, false);
  59704. }
  59705. });
  59706. Chart.prototype.callbacks.push(function (chart) {
  59707. var extremes,
  59708. navigator = chart.navigator;
  59709. // Initialize the navigator
  59710. if (navigator && chart.xAxis[0]) {
  59711. extremes = chart.xAxis[0].getExtremes();
  59712. navigator.render(extremes.min, extremes.max);
  59713. }
  59714. });
  59715. }
  59716. H.Navigator = Navigator;
  59717. return H.Navigator;
  59718. });
  59719. _registerModule(_modules, 'masters/modules/gantt.src.js', [_modules['Core/Globals.js'], _modules['Core/Chart/GanttChart.js']], function (Highcharts, GanttChart) {
  59720. Highcharts.GanttChart = GanttChart;
  59721. Highcharts.ganttChart = GanttChart.ganttChart;
  59722. });
  59723. _registerModule(_modules, 'masters/highcharts-gantt.src.js', [_modules['masters/highcharts.src.js']], function (Highcharts) {
  59724. Highcharts.product = 'Highcharts Gantt';
  59725. return Highcharts;
  59726. });
  59727. _modules['masters/highcharts-gantt.src.js']._modules = _modules;
  59728. return _modules['masters/highcharts-gantt.src.js'];
  59729. }));