highstock.src.js 2.5 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018460194602046021460224602346024460254602646027460284602946030460314603246033460344603546036460374603846039460404604146042460434604446045460464604746048460494605046051460524605346054460554605646057460584605946060460614606246063460644606546066460674606846069460704607146072460734607446075460764607746078460794608046081460824608346084460854608646087460884608946090460914609246093460944609546096460974609846099461004610146102461034610446105461064610746108461094611046111461124611346114461154611646117461184611946120461214612246123461244612546126461274612846129461304613146132461334613446135461364613746138461394614046141461424614346144461454614646147461484614946150461514615246153461544615546156461574615846159461604616146162461634616446165461664616746168461694617046171461724617346174461754617646177461784617946180461814618246183461844618546186461874618846189461904619146192461934619446195461964619746198461994620046201462024620346204462054620646207462084620946210462114621246213462144621546216462174621846219462204622146222462234622446225462264622746228462294623046231462324623346234462354623646237462384623946240462414624246243462444624546246462474624846249462504625146252462534625446255462564625746258462594626046261462624626346264462654626646267462684626946270462714627246273462744627546276462774627846279462804628146282462834628446285462864628746288462894629046291462924629346294462954629646297462984629946300463014630246303463044630546306463074630846309463104631146312463134631446315463164631746318463194632046321463224632346324463254632646327463284632946330463314633246333463344633546336463374633846339463404634146342463434634446345463464634746348463494635046351463524635346354463554635646357463584635946360463614636246363463644636546366463674636846369463704637146372463734637446375463764637746378463794638046381463824638346384463854638646387463884638946390463914639246393463944639546396463974639846399464004640146402464034640446405464064640746408464094641046411464124641346414464154641646417464184641946420464214642246423464244642546426464274642846429464304643146432464334643446435464364643746438464394644046441464424644346444464454644646447464484644946450464514645246453464544645546456464574645846459464604646146462464634646446465464664646746468464694647046471464724647346474464754647646477464784647946480464814648246483464844648546486464874648846489464904649146492464934649446495464964649746498464994650046501465024650346504465054650646507465084650946510465114651246513465144651546516465174651846519465204652146522465234652446525465264652746528465294653046531465324653346534465354653646537465384653946540465414654246543465444654546546465474654846549465504655146552465534655446555465564655746558465594656046561465624656346564465654656646567465684656946570465714657246573465744657546576465774657846579465804658146582465834658446585465864658746588465894659046591465924659346594465954659646597465984659946600466014660246603466044660546606466074660846609466104661146612466134661446615466164661746618466194662046621466224662346624466254662646627466284662946630466314663246633466344663546636466374663846639466404664146642466434664446645466464664746648466494665046651466524665346654466554665646657466584665946660466614666246663466644666546666466674666846669466704667146672466734667446675466764667746678466794668046681466824668346684466854668646687466884668946690466914669246693466944669546696466974669846699467004670146702467034670446705467064670746708467094671046711467124671346714467154671646717467184671946720467214672246723467244672546726467274672846729467304673146732467334673446735467364673746738467394674046741467424674346744467454674646747467484674946750467514675246753467544675546756467574675846759467604676146762467634676446765467664676746768467694677046771467724677346774467754677646777467784677946780467814678246783467844678546786467874678846789467904679146792467934679446795467964679746798467994680046801468024680346804468054680646807468084680946810468114681246813468144681546816468174681846819468204682146822468234682446825468264682746828468294683046831468324683346834468354683646837468384683946840468414684246843468444684546846468474684846849468504685146852468534685446855468564685746858468594686046861468624686346864468654686646867468684686946870468714687246873468744687546876468774687846879468804688146882468834688446885468864688746888468894689046891468924689346894468954689646897468984689946900469014690246903469044690546906469074690846909469104691146912469134691446915469164691746918469194692046921469224692346924469254692646927469284692946930469314693246933469344693546936469374693846939469404694146942469434694446945469464694746948469494695046951469524695346954469554695646957469584695946960469614696246963469644696546966469674696846969469704697146972469734697446975469764697746978469794698046981469824698346984469854698646987469884698946990469914699246993469944699546996469974699846999470004700147002470034700447005470064700747008470094701047011470124701347014470154701647017470184701947020470214702247023470244702547026470274702847029470304703147032470334703447035470364703747038470394704047041470424704347044470454704647047470484704947050470514705247053470544705547056470574705847059470604706147062470634706447065470664706747068470694707047071470724707347074470754707647077470784707947080470814708247083470844708547086470874708847089470904709147092470934709447095470964709747098470994710047101471024710347104471054710647107471084710947110471114711247113471144711547116471174711847119471204712147122471234712447125471264712747128471294713047131471324713347134471354713647137471384713947140471414714247143471444714547146471474714847149471504715147152471534715447155471564715747158471594716047161471624716347164471654716647167471684716947170471714717247173471744717547176471774717847179471804718147182471834718447185471864718747188471894719047191471924719347194471954719647197471984719947200472014720247203472044720547206472074720847209472104721147212472134721447215472164721747218472194722047221472224722347224472254722647227472284722947230472314723247233472344723547236472374723847239472404724147242472434724447245472464724747248472494725047251472524725347254472554725647257472584725947260472614726247263472644726547266472674726847269472704727147272472734727447275472764727747278472794728047281472824728347284472854728647287472884728947290472914729247293472944729547296472974729847299473004730147302473034730447305473064730747308473094731047311473124731347314473154731647317473184731947320473214732247323473244732547326473274732847329473304733147332473334733447335473364733747338473394734047341473424734347344473454734647347473484734947350473514735247353473544735547356473574735847359473604736147362473634736447365473664736747368473694737047371473724737347374473754737647377473784737947380473814738247383473844738547386473874738847389473904739147392473934739447395473964739747398473994740047401474024740347404474054740647407474084740947410474114741247413474144741547416474174741847419474204742147422474234742447425474264742747428474294743047431474324743347434474354743647437474384743947440474414744247443474444744547446474474744847449474504745147452474534745447455474564745747458474594746047461474624746347464474654746647467474684746947470474714747247473474744747547476474774747847479474804748147482474834748447485474864748747488474894749047491474924749347494474954749647497474984749947500475014750247503475044750547506475074750847509475104751147512475134751447515475164751747518475194752047521475224752347524475254752647527475284752947530475314753247533475344753547536475374753847539475404754147542475434754447545475464754747548475494755047551475524755347554475554755647557475584755947560475614756247563475644756547566475674756847569475704757147572475734757447575475764757747578475794758047581475824758347584475854758647587475884758947590475914759247593475944759547596475974759847599476004760147602476034760447605476064760747608476094761047611476124761347614476154761647617476184761947620476214762247623476244762547626476274762847629476304763147632476334763447635476364763747638476394764047641476424764347644476454764647647476484764947650476514765247653476544765547656476574765847659476604766147662476634766447665476664766747668476694767047671476724767347674476754767647677476784767947680476814768247683476844768547686476874768847689476904769147692476934769447695476964769747698476994770047701477024770347704477054770647707477084770947710477114771247713477144771547716477174771847719477204772147722477234772447725477264772747728477294773047731477324773347734477354773647737477384773947740477414774247743477444774547746477474774847749477504775147752477534775447755477564775747758477594776047761477624776347764477654776647767477684776947770477714777247773477744777547776477774777847779477804778147782477834778447785477864778747788477894779047791477924779347794477954779647797477984779947800478014780247803478044780547806478074780847809478104781147812478134781447815478164781747818478194782047821478224782347824478254782647827478284782947830478314783247833478344783547836478374783847839478404784147842478434784447845478464784747848478494785047851478524785347854478554785647857478584785947860478614786247863478644786547866478674786847869478704787147872478734787447875478764787747878478794788047881478824788347884478854788647887478884788947890478914789247893478944789547896478974789847899479004790147902479034790447905479064790747908479094791047911479124791347914479154791647917479184791947920479214792247923479244792547926479274792847929479304793147932479334793447935479364793747938479394794047941479424794347944479454794647947479484794947950479514795247953479544795547956479574795847959479604796147962479634796447965479664796747968479694797047971479724797347974479754797647977479784797947980479814798247983479844798547986479874798847989479904799147992479934799447995479964799747998479994800048001480024800348004480054800648007480084800948010480114801248013480144801548016480174801848019480204802148022480234802448025480264802748028480294803048031480324803348034480354803648037480384803948040480414804248043480444804548046480474804848049480504805148052480534805448055480564805748058480594806048061480624806348064480654806648067480684806948070480714807248073480744807548076480774807848079480804808148082480834808448085480864808748088480894809048091480924809348094480954809648097480984809948100481014810248103481044810548106481074810848109481104811148112481134811448115481164811748118481194812048121481224812348124481254812648127481284812948130481314813248133481344813548136481374813848139481404814148142481434814448145481464814748148481494815048151481524815348154481554815648157481584815948160481614816248163481644816548166481674816848169481704817148172481734817448175481764817748178481794818048181481824818348184481854818648187481884818948190481914819248193481944819548196481974819848199482004820148202482034820448205482064820748208482094821048211482124821348214482154821648217482184821948220482214822248223482244822548226482274822848229482304823148232482334823448235482364823748238482394824048241482424824348244482454824648247482484824948250482514825248253482544825548256482574825848259482604826148262482634826448265482664826748268482694827048271482724827348274482754827648277482784827948280482814828248283482844828548286482874828848289482904829148292482934829448295482964829748298482994830048301483024830348304483054830648307483084830948310483114831248313483144831548316483174831848319483204832148322483234832448325483264832748328483294833048331483324833348334483354833648337483384833948340483414834248343483444834548346483474834848349483504835148352483534835448355483564835748358483594836048361483624836348364483654836648367483684836948370483714837248373483744837548376483774837848379483804838148382483834838448385483864838748388483894839048391483924839348394483954839648397483984839948400484014840248403484044840548406484074840848409484104841148412484134841448415484164841748418484194842048421484224842348424484254842648427484284842948430484314843248433484344843548436484374843848439484404844148442484434844448445484464844748448484494845048451484524845348454484554845648457484584845948460484614846248463484644846548466484674846848469484704847148472484734847448475484764847748478484794848048481484824848348484484854848648487484884848948490484914849248493484944849548496484974849848499485004850148502485034850448505485064850748508485094851048511485124851348514485154851648517485184851948520485214852248523485244852548526485274852848529485304853148532485334853448535485364853748538485394854048541485424854348544485454854648547485484854948550485514855248553485544855548556485574855848559485604856148562485634856448565485664856748568485694857048571485724857348574485754857648577485784857948580485814858248583485844858548586485874858848589485904859148592485934859448595485964859748598485994860048601486024860348604486054860648607486084860948610486114861248613486144861548616486174861848619486204862148622486234862448625486264862748628486294863048631486324863348634486354863648637486384863948640486414864248643486444864548646486474864848649486504865148652486534865448655486564865748658486594866048661486624866348664486654866648667486684866948670486714867248673486744867548676486774867848679486804868148682486834868448685486864868748688486894869048691486924869348694486954869648697486984869948700487014870248703487044870548706487074870848709487104871148712487134871448715487164871748718487194872048721487224872348724487254872648727487284872948730487314873248733487344873548736487374873848739487404874148742487434874448745487464874748748487494875048751487524875348754487554875648757487584875948760487614876248763487644876548766487674876848769487704877148772487734877448775487764877748778487794878048781487824878348784487854878648787487884878948790487914879248793487944879548796487974879848799488004880148802488034880448805488064880748808488094881048811488124881348814488154881648817488184881948820488214882248823488244882548826488274882848829488304883148832488334883448835488364883748838488394884048841488424884348844488454884648847488484884948850488514885248853488544885548856488574885848859488604886148862488634886448865488664886748868488694887048871488724887348874488754887648877488784887948880488814888248883488844888548886488874888848889488904889148892488934889448895488964889748898488994890048901489024890348904489054890648907489084890948910489114891248913489144891548916489174891848919489204892148922489234892448925489264892748928489294893048931489324893348934489354893648937489384893948940489414894248943489444894548946489474894848949489504895148952489534895448955489564895748958489594896048961489624896348964489654896648967489684896948970489714897248973489744897548976489774897848979489804898148982489834898448985489864898748988489894899048991489924899348994489954899648997489984899949000490014900249003490044900549006490074900849009490104901149012490134901449015490164901749018490194902049021490224902349024490254902649027490284902949030490314903249033490344903549036490374903849039490404904149042490434904449045490464904749048490494905049051490524905349054490554905649057490584905949060490614906249063490644906549066490674906849069490704907149072490734907449075490764907749078490794908049081490824908349084490854908649087490884908949090490914909249093490944909549096490974909849099491004910149102491034910449105491064910749108491094911049111491124911349114491154911649117491184911949120491214912249123491244912549126491274912849129491304913149132491334913449135491364913749138491394914049141491424914349144491454914649147491484914949150491514915249153491544915549156491574915849159491604916149162491634916449165491664916749168491694917049171491724917349174491754917649177491784917949180491814918249183491844918549186491874918849189491904919149192491934919449195491964919749198491994920049201492024920349204492054920649207492084920949210492114921249213492144921549216492174921849219492204922149222492234922449225492264922749228492294923049231492324923349234492354923649237492384923949240492414924249243492444924549246492474924849249492504925149252492534925449255492564925749258492594926049261492624926349264492654926649267492684926949270492714927249273492744927549276492774927849279492804928149282492834928449285492864928749288492894929049291492924929349294492954929649297492984929949300493014930249303493044930549306493074930849309493104931149312493134931449315493164931749318493194932049321493224932349324493254932649327493284932949330493314933249333493344933549336493374933849339493404934149342493434934449345493464934749348493494935049351493524935349354493554935649357493584935949360493614936249363493644936549366493674936849369493704937149372493734937449375493764937749378493794938049381493824938349384493854938649387493884938949390493914939249393493944939549396493974939849399494004940149402494034940449405494064940749408494094941049411494124941349414494154941649417494184941949420494214942249423494244942549426494274942849429494304943149432494334943449435494364943749438494394944049441494424944349444494454944649447494484944949450494514945249453494544945549456494574945849459494604946149462494634946449465494664946749468494694947049471494724947349474494754947649477494784947949480494814948249483494844948549486494874948849489494904949149492494934949449495494964949749498494994950049501495024950349504495054950649507495084950949510495114951249513495144951549516495174951849519495204952149522495234952449525495264952749528495294953049531495324953349534495354953649537495384953949540495414954249543495444954549546495474954849549495504955149552495534955449555495564955749558495594956049561495624956349564495654956649567495684956949570495714957249573495744957549576495774957849579495804958149582495834958449585495864958749588495894959049591495924959349594495954959649597495984959949600496014960249603496044960549606496074960849609496104961149612496134961449615496164961749618496194962049621496224962349624496254962649627496284962949630496314963249633496344963549636496374963849639496404964149642496434964449645496464964749648496494965049651496524965349654496554965649657496584965949660496614966249663496644966549666496674966849669496704967149672496734967449675496764967749678496794968049681496824968349684496854968649687496884968949690496914969249693496944969549696496974969849699497004970149702497034970449705497064970749708497094971049711497124971349714497154971649717497184971949720497214972249723497244972549726497274972849729497304973149732497334973449735497364973749738497394974049741497424974349744497454974649747497484974949750497514975249753497544975549756497574975849759497604976149762497634976449765497664976749768497694977049771497724977349774497754977649777497784977949780497814978249783497844978549786497874978849789497904979149792497934979449795497964979749798497994980049801498024980349804498054980649807498084980949810498114981249813498144981549816498174981849819498204982149822498234982449825498264982749828498294983049831498324983349834498354983649837498384983949840498414984249843498444984549846498474984849849498504985149852498534985449855498564985749858498594986049861498624986349864498654986649867498684986949870498714987249873498744987549876498774987849879498804988149882498834988449885498864988749888498894989049891498924989349894498954989649897498984989949900499014990249903499044990549906499074990849909499104991149912499134991449915499164991749918499194992049921499224992349924499254992649927499284992949930499314993249933499344993549936499374993849939499404994149942499434994449945499464994749948499494995049951499524995349954499554995649957499584995949960499614996249963499644996549966499674996849969499704997149972499734997449975499764997749978499794998049981499824998349984499854998649987499884998949990499914999249993499944999549996499974999849999500005000150002500035000450005500065000750008500095001050011500125001350014500155001650017500185001950020500215002250023500245002550026500275002850029500305003150032500335003450035500365003750038500395004050041500425004350044500455004650047500485004950050500515005250053500545005550056500575005850059500605006150062500635006450065500665006750068500695007050071500725007350074500755007650077500785007950080500815008250083500845008550086500875008850089500905009150092500935009450095500965009750098500995010050101501025010350104501055010650107501085010950110501115011250113501145011550116501175011850119501205012150122501235012450125501265012750128501295013050131501325013350134501355013650137501385013950140501415014250143501445014550146501475014850149501505015150152501535015450155501565015750158501595016050161501625016350164501655016650167501685016950170501715017250173501745017550176501775017850179501805018150182501835018450185501865018750188501895019050191501925019350194501955019650197501985019950200502015020250203502045020550206502075020850209502105021150212502135021450215502165021750218502195022050221502225022350224502255022650227502285022950230502315023250233502345023550236502375023850239502405024150242502435024450245502465024750248502495025050251502525025350254502555025650257502585025950260502615026250263502645026550266502675026850269502705027150272502735027450275502765027750278502795028050281502825028350284502855028650287502885028950290502915029250293502945029550296502975029850299503005030150302503035030450305503065030750308503095031050311503125031350314503155031650317503185031950320503215032250323503245032550326503275032850329503305033150332503335033450335503365033750338503395034050341503425034350344503455034650347503485034950350503515035250353503545035550356503575035850359503605036150362503635036450365503665036750368503695037050371503725037350374503755037650377503785037950380503815038250383503845038550386503875038850389503905039150392503935039450395503965039750398503995040050401504025040350404504055040650407504085040950410504115041250413504145041550416504175041850419504205042150422504235042450425504265042750428504295043050431504325043350434504355043650437504385043950440504415044250443504445044550446504475044850449504505045150452504535045450455504565045750458504595046050461504625046350464504655046650467504685046950470504715047250473504745047550476504775047850479504805048150482504835048450485504865048750488504895049050491504925049350494504955049650497504985049950500505015050250503505045050550506505075050850509505105051150512505135051450515505165051750518505195052050521505225052350524505255052650527505285052950530505315053250533505345053550536505375053850539505405054150542505435054450545505465054750548505495055050551505525055350554505555055650557505585055950560505615056250563505645056550566505675056850569505705057150572505735057450575505765057750578505795058050581505825058350584505855058650587505885058950590505915059250593505945059550596505975059850599506005060150602506035060450605506065060750608506095061050611506125061350614506155061650617506185061950620506215062250623506245062550626506275062850629506305063150632506335063450635506365063750638506395064050641506425064350644506455064650647506485064950650506515065250653506545065550656506575065850659506605066150662506635066450665506665066750668506695067050671506725067350674506755067650677506785067950680506815068250683506845068550686506875068850689506905069150692506935069450695506965069750698506995070050701507025070350704507055070650707507085070950710507115071250713507145071550716507175071850719507205072150722507235072450725507265072750728507295073050731507325073350734507355073650737507385073950740507415074250743507445074550746507475074850749507505075150752507535075450755507565075750758507595076050761507625076350764507655076650767507685076950770507715077250773507745077550776507775077850779507805078150782507835078450785507865078750788507895079050791507925079350794507955079650797507985079950800508015080250803508045080550806508075080850809508105081150812508135081450815508165081750818508195082050821508225082350824508255082650827508285082950830508315083250833508345083550836508375083850839508405084150842508435084450845508465084750848508495085050851508525085350854508555085650857508585085950860508615086250863508645086550866508675086850869508705087150872508735087450875508765087750878508795088050881508825088350884508855088650887508885088950890508915089250893508945089550896508975089850899509005090150902509035090450905509065090750908509095091050911509125091350914509155091650917509185091950920509215092250923509245092550926509275092850929509305093150932509335093450935509365093750938509395094050941509425094350944509455094650947509485094950950509515095250953509545095550956509575095850959509605096150962509635096450965509665096750968509695097050971509725097350974509755097650977509785097950980509815098250983509845098550986509875098850989509905099150992509935099450995509965099750998509995100051001510025100351004510055100651007510085100951010510115101251013510145101551016510175101851019510205102151022510235102451025510265102751028510295103051031510325103351034510355103651037510385103951040510415104251043510445104551046510475104851049510505105151052510535105451055510565105751058510595106051061510625106351064510655106651067510685106951070510715107251073510745107551076510775107851079510805108151082510835108451085510865108751088510895109051091510925109351094510955109651097510985109951100511015110251103511045110551106511075110851109511105111151112511135111451115511165111751118511195112051121511225112351124511255112651127511285112951130511315113251133511345113551136511375113851139511405114151142511435114451145511465114751148511495115051151511525115351154511555115651157511585115951160511615116251163511645116551166511675116851169511705117151172511735117451175511765117751178511795118051181511825118351184511855118651187511885118951190511915119251193511945119551196511975119851199512005120151202512035120451205512065120751208512095121051211512125121351214512155121651217512185121951220512215122251223512245122551226512275122851229512305123151232512335123451235512365123751238512395124051241512425124351244512455124651247512485124951250512515125251253512545125551256512575125851259512605126151262512635126451265512665126751268512695127051271512725127351274512755127651277512785127951280512815128251283512845128551286512875128851289512905129151292512935129451295512965129751298512995130051301513025130351304513055130651307513085130951310513115131251313513145131551316513175131851319513205132151322513235132451325513265132751328513295133051331513325133351334513355133651337513385133951340513415134251343513445134551346513475134851349513505135151352513535135451355513565135751358513595136051361513625136351364513655136651367513685136951370513715137251373513745137551376513775137851379513805138151382513835138451385513865138751388513895139051391513925139351394513955139651397513985139951400514015140251403514045140551406514075140851409514105141151412514135141451415514165141751418514195142051421514225142351424514255142651427514285142951430514315143251433514345143551436514375143851439514405144151442514435144451445514465144751448514495145051451514525145351454514555145651457514585145951460514615146251463514645146551466514675146851469514705147151472514735147451475514765147751478514795148051481514825148351484514855148651487514885148951490514915149251493514945149551496514975149851499515005150151502515035150451505515065150751508515095151051511515125151351514515155151651517515185151951520515215152251523515245152551526515275152851529515305153151532515335153451535515365153751538515395154051541515425154351544515455154651547515485154951550515515155251553515545155551556515575155851559515605156151562515635156451565515665156751568515695157051571515725157351574515755157651577515785157951580515815158251583515845158551586515875158851589515905159151592515935159451595515965159751598515995160051601516025160351604516055160651607516085160951610516115161251613516145161551616516175161851619516205162151622516235162451625516265162751628516295163051631516325163351634516355163651637516385163951640516415164251643516445164551646516475164851649516505165151652516535165451655516565165751658516595166051661516625166351664516655166651667516685166951670516715167251673516745167551676516775167851679516805168151682516835168451685516865168751688516895169051691516925169351694516955169651697516985169951700517015170251703517045170551706517075170851709517105171151712517135171451715517165171751718517195172051721517225172351724517255172651727517285172951730517315173251733517345173551736517375173851739517405174151742517435174451745517465174751748517495175051751517525175351754517555175651757517585175951760517615176251763517645176551766517675176851769517705177151772517735177451775517765177751778517795178051781517825178351784517855178651787517885178951790517915179251793517945179551796517975179851799518005180151802518035180451805518065180751808518095181051811518125181351814518155181651817518185181951820518215182251823518245182551826518275182851829518305183151832518335183451835518365183751838518395184051841518425184351844518455184651847518485184951850518515185251853518545185551856518575185851859518605186151862518635186451865518665186751868518695187051871518725187351874518755187651877518785187951880518815188251883518845188551886518875188851889518905189151892518935189451895518965189751898518995190051901519025190351904519055190651907519085190951910519115191251913519145191551916519175191851919519205192151922519235192451925519265192751928519295193051931519325193351934519355193651937519385193951940519415194251943519445194551946519475194851949519505195151952519535195451955519565195751958519595196051961519625196351964519655196651967519685196951970519715197251973519745197551976519775197851979519805198151982519835198451985519865198751988519895199051991519925199351994519955199651997519985199952000520015200252003520045200552006520075200852009520105201152012520135201452015520165201752018520195202052021520225202352024520255202652027520285202952030520315203252033520345203552036520375203852039520405204152042520435204452045520465204752048520495205052051520525205352054520555205652057520585205952060520615206252063520645206552066520675206852069520705207152072520735207452075520765207752078520795208052081520825208352084520855208652087520885208952090520915209252093520945209552096520975209852099521005210152102521035210452105521065210752108521095211052111521125211352114521155211652117521185211952120521215212252123521245212552126521275212852129521305213152132521335213452135521365213752138521395214052141521425214352144521455214652147521485214952150521515215252153521545215552156521575215852159521605216152162521635216452165521665216752168521695217052171521725217352174521755217652177521785217952180521815218252183521845218552186521875218852189521905219152192521935219452195521965219752198521995220052201522025220352204522055220652207522085220952210522115221252213522145221552216522175221852219522205222152222522235222452225522265222752228522295223052231522325223352234522355223652237522385223952240522415224252243522445224552246522475224852249522505225152252522535225452255522565225752258522595226052261522625226352264522655226652267522685226952270522715227252273522745227552276522775227852279522805228152282522835228452285522865228752288522895229052291522925229352294522955229652297522985229952300523015230252303523045230552306523075230852309523105231152312523135231452315523165231752318523195232052321523225232352324523255232652327523285232952330523315233252333523345233552336523375233852339523405234152342523435234452345523465234752348523495235052351523525235352354523555235652357523585235952360523615236252363523645236552366523675236852369523705237152372523735237452375523765237752378523795238052381523825238352384523855238652387523885238952390523915239252393523945239552396523975239852399524005240152402524035240452405524065240752408524095241052411524125241352414524155241652417524185241952420524215242252423524245242552426524275242852429524305243152432524335243452435524365243752438524395244052441524425244352444524455244652447524485244952450524515245252453524545245552456524575245852459524605246152462524635246452465524665246752468524695247052471524725247352474524755247652477524785247952480524815248252483524845248552486524875248852489524905249152492524935249452495524965249752498524995250052501525025250352504525055250652507525085250952510525115251252513525145251552516525175251852519525205252152522525235252452525525265252752528525295253052531525325253352534525355253652537525385253952540525415254252543525445254552546525475254852549525505255152552525535255452555525565255752558525595256052561525625256352564525655256652567525685256952570525715257252573525745257552576525775257852579525805258152582525835258452585525865258752588525895259052591525925259352594525955259652597525985259952600526015260252603526045260552606526075260852609526105261152612526135261452615526165261752618526195262052621526225262352624526255262652627526285262952630526315263252633526345263552636526375263852639526405264152642526435264452645526465264752648526495265052651526525265352654526555265652657526585265952660526615266252663526645266552666526675266852669526705267152672526735267452675526765267752678526795268052681526825268352684526855268652687526885268952690526915269252693526945269552696526975269852699527005270152702527035270452705527065270752708527095271052711527125271352714527155271652717527185271952720527215272252723527245272552726527275272852729527305273152732527335273452735527365273752738527395274052741527425274352744527455274652747527485274952750527515275252753527545275552756527575275852759527605276152762527635276452765527665276752768527695277052771527725277352774527755277652777527785277952780527815278252783527845278552786527875278852789527905279152792527935279452795527965279752798527995280052801528025280352804528055280652807528085280952810528115281252813528145281552816528175281852819528205282152822528235282452825528265282752828528295283052831528325283352834528355283652837528385283952840528415284252843528445284552846528475284852849528505285152852528535285452855528565285752858528595286052861528625286352864528655286652867528685286952870528715287252873528745287552876528775287852879528805288152882528835288452885528865288752888528895289052891528925289352894528955289652897528985289952900529015290252903529045290552906529075290852909529105291152912529135291452915529165291752918529195292052921529225292352924529255292652927529285292952930529315293252933529345293552936529375293852939529405294152942529435294452945529465294752948529495295052951529525295352954529555295652957529585295952960529615296252963529645296552966529675296852969529705297152972529735297452975529765297752978529795298052981529825298352984529855298652987529885298952990529915299252993529945299552996529975299852999530005300153002530035300453005530065300753008530095301053011530125301353014530155301653017530185301953020530215302253023530245302553026530275302853029530305303153032530335303453035530365303753038530395304053041530425304353044530455304653047530485304953050530515305253053530545305553056530575305853059530605306153062530635306453065530665306753068530695307053071530725307353074530755307653077530785307953080530815308253083530845308553086530875308853089530905309153092530935309453095530965309753098530995310053101531025310353104531055310653107531085310953110531115311253113531145311553116531175311853119531205312153122531235312453125531265312753128531295313053131531325313353134531355313653137531385313953140531415314253143531445314553146531475314853149531505315153152531535315453155531565315753158531595316053161531625316353164531655316653167531685316953170531715317253173531745317553176531775317853179531805318153182531835318453185531865318753188531895319053191531925319353194531955319653197531985319953200532015320253203532045320553206532075320853209532105321153212532135321453215532165321753218532195322053221532225322353224532255322653227532285322953230532315323253233532345323553236532375323853239532405324153242532435324453245532465324753248532495325053251532525325353254532555325653257532585325953260532615326253263532645326553266532675326853269532705327153272532735327453275532765327753278532795328053281532825328353284532855328653287532885328953290532915329253293532945329553296532975329853299533005330153302533035330453305533065330753308533095331053311533125331353314533155331653317533185331953320533215332253323533245332553326533275332853329533305333153332533335333453335533365333753338533395334053341533425334353344533455334653347533485334953350533515335253353533545335553356533575335853359533605336153362533635336453365533665336753368533695337053371533725337353374533755337653377533785337953380533815338253383533845338553386533875338853389533905339153392533935339453395533965339753398533995340053401534025340353404534055340653407534085340953410534115341253413534145341553416534175341853419534205342153422534235342453425534265342753428534295343053431534325343353434534355343653437534385343953440534415344253443534445344553446534475344853449534505345153452534535345453455534565345753458534595346053461534625346353464534655346653467534685346953470534715347253473534745347553476534775347853479534805348153482534835348453485534865348753488534895349053491534925349353494534955349653497534985349953500535015350253503535045350553506535075350853509535105351153512535135351453515535165351753518535195352053521535225352353524535255352653527535285352953530535315353253533535345353553536535375353853539535405354153542535435354453545535465354753548535495355053551535525355353554535555355653557535585355953560535615356253563535645356553566535675356853569535705357153572535735357453575535765357753578535795358053581535825358353584535855358653587535885358953590535915359253593535945359553596535975359853599536005360153602536035360453605536065360753608536095361053611536125361353614536155361653617536185361953620536215362253623536245362553626536275362853629536305363153632536335363453635536365363753638536395364053641536425364353644536455364653647536485364953650536515365253653536545365553656536575365853659536605366153662536635366453665536665366753668536695367053671536725367353674536755367653677536785367953680536815368253683536845368553686536875368853689536905369153692536935369453695536965369753698536995370053701537025370353704537055370653707537085370953710537115371253713537145371553716537175371853719537205372153722537235372453725537265372753728537295373053731537325373353734537355373653737537385373953740537415374253743537445374553746537475374853749537505375153752537535375453755537565375753758537595376053761537625376353764537655376653767537685376953770537715377253773537745377553776537775377853779537805378153782537835378453785537865378753788537895379053791537925379353794537955379653797537985379953800538015380253803538045380553806538075380853809538105381153812538135381453815538165381753818538195382053821538225382353824538255382653827538285382953830538315383253833538345383553836538375383853839538405384153842538435384453845538465384753848538495385053851538525385353854538555385653857538585385953860538615386253863538645386553866538675386853869538705387153872538735387453875538765387753878538795388053881538825388353884538855388653887538885388953890538915389253893538945389553896538975389853899539005390153902539035390453905539065390753908539095391053911539125391353914539155391653917539185391953920539215392253923539245392553926539275392853929539305393153932539335393453935539365393753938539395394053941539425394353944539455394653947539485394953950539515395253953539545395553956539575395853959539605396153962539635396453965539665396753968539695397053971539725397353974539755397653977539785397953980539815398253983539845398553986539875398853989539905399153992539935399453995539965399753998539995400054001540025400354004540055400654007540085400954010540115401254013540145401554016540175401854019540205402154022540235402454025540265402754028540295403054031540325403354034540355403654037540385403954040540415404254043540445404554046540475404854049540505405154052540535405454055540565405754058540595406054061540625406354064540655406654067540685406954070540715407254073540745407554076540775407854079540805408154082540835408454085540865408754088540895409054091540925409354094540955409654097540985409954100541015410254103541045410554106541075410854109541105411154112541135411454115541165411754118541195412054121541225412354124541255412654127541285412954130541315413254133541345413554136541375413854139541405414154142541435414454145541465414754148541495415054151541525415354154541555415654157541585415954160541615416254163541645416554166541675416854169541705417154172541735417454175541765417754178541795418054181541825418354184541855418654187541885418954190541915419254193541945419554196541975419854199542005420154202542035420454205542065420754208542095421054211542125421354214542155421654217542185421954220542215422254223542245422554226542275422854229542305423154232542335423454235542365423754238542395424054241542425424354244542455424654247542485424954250542515425254253542545425554256542575425854259542605426154262542635426454265542665426754268542695427054271542725427354274542755427654277542785427954280542815428254283542845428554286542875428854289542905429154292542935429454295542965429754298542995430054301543025430354304543055430654307543085430954310543115431254313543145431554316543175431854319543205432154322543235432454325543265432754328543295433054331543325433354334543355433654337543385433954340543415434254343543445434554346543475434854349543505435154352543535435454355543565435754358543595436054361543625436354364543655436654367543685436954370543715437254373543745437554376543775437854379543805438154382543835438454385543865438754388543895439054391543925439354394543955439654397543985439954400544015440254403544045440554406544075440854409544105441154412544135441454415544165441754418544195442054421544225442354424544255442654427544285442954430544315443254433544345443554436544375443854439544405444154442544435444454445544465444754448544495445054451544525445354454544555445654457544585445954460544615446254463544645446554466544675446854469544705447154472544735447454475544765447754478544795448054481544825448354484544855448654487544885448954490544915449254493544945449554496544975449854499545005450154502545035450454505545065450754508545095451054511545125451354514545155451654517545185451954520545215452254523545245452554526545275452854529545305453154532545335453454535545365453754538545395454054541545425454354544545455454654547545485454954550545515455254553545545455554556545575455854559545605456154562545635456454565545665456754568545695457054571545725457354574545755457654577545785457954580545815458254583545845458554586545875458854589545905459154592545935459454595545965459754598545995460054601546025460354604546055460654607546085460954610546115461254613546145461554616546175461854619546205462154622546235462454625546265462754628546295463054631546325463354634546355463654637546385463954640546415464254643546445464554646546475464854649546505465154652546535465454655546565465754658546595466054661546625466354664546655466654667546685466954670546715467254673546745467554676546775467854679546805468154682546835468454685546865468754688546895469054691546925469354694546955469654697546985469954700547015470254703547045470554706547075470854709547105471154712547135471454715547165471754718547195472054721547225472354724547255472654727547285472954730547315473254733547345473554736547375473854739547405474154742547435474454745547465474754748547495475054751547525475354754547555475654757547585475954760547615476254763547645476554766547675476854769547705477154772547735477454775547765477754778547795478054781547825478354784547855478654787547885478954790547915479254793547945479554796547975479854799548005480154802548035480454805548065480754808548095481054811548125481354814548155481654817548185481954820548215482254823548245482554826548275482854829548305483154832548335483454835548365483754838548395484054841548425484354844548455484654847548485484954850548515485254853548545485554856548575485854859548605486154862548635486454865548665486754868548695487054871548725487354874548755487654877548785487954880548815488254883548845488554886548875488854889548905489154892548935489454895548965489754898548995490054901549025490354904549055490654907549085490954910549115491254913549145491554916549175491854919549205492154922549235492454925549265492754928549295493054931549325493354934549355493654937549385493954940549415494254943549445494554946549475494854949549505495154952549535495454955549565495754958549595496054961549625496354964549655496654967549685496954970549715497254973549745497554976549775497854979549805498154982549835498454985549865498754988549895499054991549925499354994549955499654997549985499955000550015500255003550045500555006550075500855009550105501155012550135501455015550165501755018550195502055021550225502355024550255502655027550285502955030550315503255033550345503555036550375503855039550405504155042550435504455045550465504755048550495505055051550525505355054550555505655057550585505955060550615506255063550645506555066550675506855069550705507155072550735507455075550765507755078550795508055081550825508355084550855508655087550885508955090550915509255093550945509555096550975509855099551005510155102551035510455105551065510755108551095511055111551125511355114551155511655117551185511955120551215512255123551245512555126551275512855129551305513155132551335513455135551365513755138551395514055141551425514355144551455514655147551485514955150551515515255153551545515555156551575515855159551605516155162551635516455165551665516755168551695517055171551725517355174551755517655177551785517955180551815518255183551845518555186551875518855189551905519155192551935519455195551965519755198551995520055201552025520355204552055520655207552085520955210552115521255213552145521555216552175521855219552205522155222552235522455225552265522755228552295523055231552325523355234552355523655237552385523955240552415524255243552445524555246552475524855249552505525155252552535525455255552565525755258552595526055261552625526355264552655526655267552685526955270552715527255273552745527555276552775527855279552805528155282552835528455285552865528755288552895529055291552925529355294552955529655297552985529955300553015530255303553045530555306553075530855309553105531155312553135531455315553165531755318553195532055321553225532355324553255532655327553285532955330553315533255333553345533555336553375533855339553405534155342553435534455345553465534755348553495535055351553525535355354553555535655357553585535955360553615536255363553645536555366553675536855369553705537155372553735537455375553765537755378553795538055381553825538355384553855538655387553885538955390553915539255393553945539555396553975539855399554005540155402554035540455405554065540755408554095541055411554125541355414554155541655417554185541955420554215542255423554245542555426554275542855429554305543155432554335543455435554365543755438554395544055441554425544355444554455544655447554485544955450554515545255453554545545555456554575545855459554605546155462554635546455465554665546755468554695547055471554725547355474554755547655477554785547955480554815548255483554845548555486554875548855489554905549155492554935549455495554965549755498554995550055501555025550355504555055550655507555085550955510555115551255513555145551555516555175551855519555205552155522555235552455525555265552755528555295553055531555325553355534555355553655537555385553955540555415554255543555445554555546555475554855549555505555155552555535555455555555565555755558555595556055561555625556355564555655556655567555685556955570555715557255573555745557555576555775557855579555805558155582555835558455585555865558755588555895559055591555925559355594555955559655597555985559955600556015560255603556045560555606556075560855609556105561155612556135561455615556165561755618556195562055621556225562355624556255562655627556285562955630556315563255633556345563555636556375563855639556405564155642556435564455645556465564755648556495565055651556525565355654556555565655657556585565955660556615566255663556645566555666556675566855669556705567155672556735567455675556765567755678556795568055681556825568355684556855568655687556885568955690556915569255693556945569555696556975569855699557005570155702557035570455705557065570755708557095571055711557125571355714557155571655717557185571955720557215572255723557245572555726557275572855729557305573155732557335573455735557365573755738557395574055741557425574355744557455574655747557485574955750557515575255753557545575555756557575575855759557605576155762557635576455765557665576755768557695577055771557725577355774557755577655777557785577955780557815578255783557845578555786557875578855789557905579155792557935579455795557965579755798557995580055801558025580355804558055580655807558085580955810558115581255813558145581555816558175581855819558205582155822558235582455825558265582755828558295583055831558325583355834558355583655837558385583955840558415584255843558445584555846558475584855849558505585155852558535585455855558565585755858558595586055861558625586355864558655586655867558685586955870558715587255873558745587555876558775587855879558805588155882558835588455885558865588755888558895589055891558925589355894558955589655897558985589955900559015590255903559045590555906559075590855909559105591155912559135591455915559165591755918559195592055921559225592355924559255592655927559285592955930559315593255933559345593555936559375593855939559405594155942559435594455945559465594755948559495595055951559525595355954559555595655957559585595955960559615596255963559645596555966559675596855969559705597155972559735597455975559765597755978559795598055981559825598355984559855598655987559885598955990559915599255993559945599555996559975599855999560005600156002560035600456005560065600756008560095601056011560125601356014560155601656017560185601956020560215602256023560245602556026560275602856029560305603156032560335603456035560365603756038560395604056041560425604356044560455604656047560485604956050560515605256053560545605556056560575605856059560605606156062560635606456065560665606756068560695607056071560725607356074560755607656077560785607956080560815608256083560845608556086560875608856089560905609156092560935609456095560965609756098560995610056101561025610356104561055610656107561085610956110561115611256113561145611556116561175611856119561205612156122561235612456125561265612756128561295613056131561325613356134561355613656137561385613956140561415614256143561445614556146561475614856149561505615156152561535615456155561565615756158561595616056161561625616356164561655616656167561685616956170561715617256173561745617556176561775617856179561805618156182561835618456185561865618756188561895619056191561925619356194561955619656197561985619956200562015620256203562045620556206562075620856209562105621156212562135621456215562165621756218562195622056221562225622356224562255622656227562285622956230562315623256233562345623556236562375623856239562405624156242562435624456245562465624756248562495625056251562525625356254562555625656257562585625956260562615626256263562645626556266562675626856269562705627156272562735627456275562765627756278562795628056281562825628356284562855628656287562885628956290562915629256293562945629556296562975629856299563005630156302563035630456305563065630756308563095631056311563125631356314563155631656317563185631956320563215632256323563245632556326563275632856329563305633156332563335633456335563365633756338563395634056341563425634356344563455634656347563485634956350563515635256353563545635556356563575635856359563605636156362563635636456365563665636756368563695637056371563725637356374563755637656377563785637956380563815638256383563845638556386563875638856389563905639156392563935639456395563965639756398563995640056401564025640356404564055640656407564085640956410564115641256413564145641556416564175641856419564205642156422564235642456425564265642756428564295643056431564325643356434564355643656437564385643956440564415644256443564445644556446564475644856449564505645156452564535645456455564565645756458564595646056461564625646356464564655646656467564685646956470564715647256473564745647556476564775647856479564805648156482564835648456485564865648756488564895649056491564925649356494564955649656497564985649956500565015650256503565045650556506565075650856509565105651156512565135651456515565165651756518565195652056521565225652356524565255652656527565285652956530565315653256533565345653556536565375653856539565405654156542565435654456545565465654756548565495655056551565525655356554565555655656557565585655956560565615656256563565645656556566565675656856569565705657156572565735657456575565765657756578565795658056581565825658356584565855658656587565885658956590565915659256593565945659556596565975659856599566005660156602566035660456605566065660756608566095661056611566125661356614566155661656617566185661956620566215662256623566245662556626566275662856629566305663156632566335663456635566365663756638566395664056641566425664356644566455664656647566485664956650566515665256653566545665556656566575665856659566605666156662566635666456665566665666756668566695667056671566725667356674566755667656677566785667956680566815668256683566845668556686566875668856689566905669156692566935669456695566965669756698566995670056701567025670356704567055670656707567085670956710567115671256713567145671556716567175671856719567205672156722567235672456725567265672756728567295673056731567325673356734567355673656737567385673956740567415674256743567445674556746567475674856749567505675156752567535675456755567565675756758567595676056761567625676356764567655676656767567685676956770567715677256773567745677556776567775677856779567805678156782567835678456785567865678756788567895679056791567925679356794567955679656797567985679956800568015680256803568045680556806568075680856809568105681156812568135681456815568165681756818568195682056821568225682356824568255682656827568285682956830568315683256833568345683556836568375683856839568405684156842568435684456845568465684756848568495685056851568525685356854568555685656857568585685956860568615686256863568645686556866568675686856869568705687156872568735687456875568765687756878568795688056881568825688356884568855688656887568885688956890568915689256893568945689556896568975689856899569005690156902569035690456905569065690756908569095691056911569125691356914569155691656917569185691956920569215692256923569245692556926569275692856929569305693156932569335693456935569365693756938569395694056941569425694356944569455694656947569485694956950569515695256953569545695556956569575695856959569605696156962569635696456965569665696756968569695697056971569725697356974569755697656977569785697956980569815698256983569845698556986569875698856989569905699156992569935699456995569965699756998569995700057001570025700357004570055700657007570085700957010570115701257013570145701557016570175701857019570205702157022570235702457025570265702757028570295703057031570325703357034570355703657037570385703957040570415704257043570445704557046570475704857049570505705157052570535705457055570565705757058570595706057061570625706357064570655706657067570685706957070570715707257073570745707557076570775707857079570805708157082570835708457085570865708757088570895709057091570925709357094570955709657097570985709957100571015710257103571045710557106571075710857109571105711157112571135711457115571165711757118571195712057121571225712357124571255712657127571285712957130571315713257133571345713557136571375713857139571405714157142571435714457145571465714757148571495715057151571525715357154571555715657157571585715957160571615716257163571645716557166571675716857169571705717157172571735717457175571765717757178571795718057181571825718357184571855718657187571885718957190571915719257193571945719557196571975719857199572005720157202572035720457205572065720757208572095721057211572125721357214572155721657217572185721957220572215722257223572245722557226572275722857229572305723157232572335723457235572365723757238572395724057241572425724357244572455724657247572485724957250572515725257253572545725557256572575725857259572605726157262572635726457265572665726757268572695727057271572725727357274572755727657277572785727957280572815728257283572845728557286572875728857289572905729157292572935729457295572965729757298572995730057301573025730357304573055730657307573085730957310573115731257313573145731557316573175731857319573205732157322573235732457325573265732757328573295733057331573325733357334573355733657337573385733957340573415734257343573445734557346573475734857349573505735157352573535735457355573565735757358573595736057361573625736357364573655736657367573685736957370573715737257373573745737557376573775737857379573805738157382573835738457385573865738757388573895739057391573925739357394573955739657397573985739957400574015740257403574045740557406574075740857409574105741157412574135741457415574165741757418574195742057421574225742357424574255742657427574285742957430574315743257433574345743557436574375743857439574405744157442574435744457445574465744757448574495745057451574525745357454574555745657457574585745957460574615746257463574645746557466574675746857469574705747157472574735747457475574765747757478574795748057481574825748357484574855748657487574885748957490574915749257493574945749557496574975749857499575005750157502575035750457505575065750757508575095751057511575125751357514575155751657517575185751957520575215752257523575245752557526575275752857529575305753157532575335753457535575365753757538575395754057541575425754357544575455754657547575485754957550575515755257553575545755557556575575755857559575605756157562575635756457565575665756757568575695757057571575725757357574575755757657577575785757957580575815758257583575845758557586575875758857589575905759157592575935759457595575965759757598575995760057601576025760357604576055760657607576085760957610576115761257613576145761557616576175761857619576205762157622576235762457625576265762757628576295763057631576325763357634576355763657637576385763957640576415764257643576445764557646576475764857649576505765157652576535765457655576565765757658576595766057661576625766357664576655766657667576685766957670576715767257673576745767557676576775767857679576805768157682576835768457685576865768757688576895769057691576925769357694576955769657697576985769957700577015770257703577045770557706577075770857709577105771157712577135771457715577165771757718577195772057721577225772357724577255772657727577285772957730577315773257733577345773557736577375773857739577405774157742577435774457745577465774757748577495775057751577525775357754577555775657757577585775957760577615776257763577645776557766577675776857769577705777157772577735777457775577765777757778577795778057781577825778357784577855778657787577885778957790577915779257793577945779557796577975779857799578005780157802578035780457805578065780757808578095781057811578125781357814578155781657817578185781957820578215782257823578245782557826578275782857829578305783157832578335783457835578365783757838578395784057841578425784357844578455784657847578485784957850578515785257853578545785557856578575785857859578605786157862578635786457865578665786757868578695787057871578725787357874578755787657877578785787957880578815788257883578845788557886578875788857889578905789157892578935789457895578965789757898578995790057901579025790357904579055790657907579085790957910579115791257913579145791557916579175791857919579205792157922579235792457925579265792757928579295793057931579325793357934579355793657937579385793957940579415794257943579445794557946579475794857949579505795157952579535795457955579565795757958579595796057961579625796357964579655796657967579685796957970579715797257973579745797557976579775797857979579805798157982579835798457985579865798757988579895799057991579925799357994579955799657997579985799958000580015800258003580045800558006580075800858009580105801158012580135801458015580165801758018580195802058021580225802358024580255802658027580285802958030580315803258033580345803558036580375803858039580405804158042580435804458045580465804758048580495805058051580525805358054580555805658057580585805958060580615806258063580645806558066580675806858069580705807158072580735807458075580765807758078580795808058081580825808358084580855808658087580885808958090580915809258093580945809558096580975809858099581005810158102581035810458105581065810758108581095811058111581125811358114581155811658117581185811958120581215812258123581245812558126581275812858129581305813158132581335813458135581365813758138581395814058141581425814358144581455814658147581485814958150581515815258153581545815558156581575815858159581605816158162581635816458165581665816758168581695817058171581725817358174581755817658177581785817958180581815818258183581845818558186581875818858189581905819158192581935819458195581965819758198581995820058201582025820358204582055820658207582085820958210582115821258213582145821558216582175821858219582205822158222582235822458225582265822758228582295823058231582325823358234582355823658237582385823958240582415824258243582445824558246582475824858249582505825158252582535825458255582565825758258582595826058261582625826358264582655826658267582685826958270582715827258273582745827558276582775827858279582805828158282582835828458285582865828758288582895829058291582925829358294582955829658297582985829958300583015830258303583045830558306583075830858309583105831158312583135831458315583165831758318583195832058321583225832358324583255832658327583285832958330583315833258333
  1. /**
  2. * @license Highstock JS v9.1.1 (2021-06-04)
  3. *
  4. * (c) 2009-2021 Torstein Honsi
  5. *
  6. * License: www.highcharts.com/license
  7. */
  8. 'use strict';
  9. (function (root, factory) {
  10. if (typeof module === 'object' && module.exports) {
  11. factory['default'] = factory;
  12. module.exports = root.document ?
  13. factory(root) :
  14. factory;
  15. } else if (typeof define === 'function' && define.amd) {
  16. define('highcharts/highstock', 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.1', 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(H, '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. /**
  1510. * Return the value of the first element in the array that satisfies the
  1511. * provided testing function.
  1512. *
  1513. * @function Highcharts.find<T>
  1514. *
  1515. * @param {Array<T>} arr
  1516. * The array to test.
  1517. *
  1518. * @param {Function} callback
  1519. * The callback function. The function receives the item as the first
  1520. * argument. Return `true` if this item satisfies the condition.
  1521. *
  1522. * @return {T|undefined}
  1523. * The value of the element.
  1524. */
  1525. var find = Array.prototype.find ?
  1526. function (arr,
  1527. callback) {
  1528. return arr.find(callback);
  1529. } :
  1530. // Legacy implementation. PhantomJS, IE <= 11 etc. #7223.
  1531. function (arr, callback) {
  1532. var i;
  1533. var length = arr.length;
  1534. for (i = 0; i < length; i++) {
  1535. if (callback(arr[i], i)) { // eslint-disable-line callback-return
  1536. return arr[i];
  1537. }
  1538. }
  1539. };
  1540. /**
  1541. * Returns an array of a given object's own properties.
  1542. *
  1543. * @function Highcharts.keys
  1544. * @deprecated
  1545. *
  1546. * @param {*} obj
  1547. * The object of which the properties are to be returned.
  1548. *
  1549. * @return {Array<string>}
  1550. * An array of strings that represents all the properties.
  1551. */
  1552. function keys(obj) {
  1553. error(32, false, void 0, { 'Highcharts.keys': 'use Object.keys' });
  1554. return Object.keys(obj);
  1555. }
  1556. /**
  1557. * Get the element's offset position, corrected for `overflow: auto`.
  1558. *
  1559. * @function Highcharts.offset
  1560. *
  1561. * @param {global.Element} el
  1562. * The DOM element.
  1563. *
  1564. * @return {Highcharts.OffsetObject}
  1565. * An object containing `left` and `top` properties for the position in
  1566. * the page.
  1567. */
  1568. function offset(el) {
  1569. var docElem = doc.documentElement,
  1570. box = (el.parentElement || el.parentNode) ?
  1571. el.getBoundingClientRect() :
  1572. { top: 0,
  1573. left: 0,
  1574. width: 0,
  1575. height: 0 };
  1576. return {
  1577. top: box.top + (win.pageYOffset || docElem.scrollTop) -
  1578. (docElem.clientTop || 0),
  1579. left: box.left + (win.pageXOffset || docElem.scrollLeft) -
  1580. (docElem.clientLeft || 0),
  1581. width: box.width,
  1582. height: box.height
  1583. };
  1584. }
  1585. /* eslint-disable valid-jsdoc */
  1586. /**
  1587. * Iterate over object key pairs in an object.
  1588. *
  1589. * @function Highcharts.objectEach<T>
  1590. *
  1591. * @param {*} obj
  1592. * The object to iterate over.
  1593. *
  1594. * @param {Highcharts.ObjectEachCallbackFunction<T>} fn
  1595. * The iterator callback. It passes three arguments:
  1596. * * value - The property value.
  1597. * * key - The property key.
  1598. * * obj - The object that objectEach is being applied to.
  1599. *
  1600. * @param {T} [ctx]
  1601. * The context.
  1602. *
  1603. * @return {void}
  1604. */
  1605. function objectEach(obj, fn, ctx) {
  1606. /* eslint-enable valid-jsdoc */
  1607. for (var key in obj) {
  1608. if (Object.hasOwnProperty.call(obj, key)) {
  1609. fn.call(ctx || obj[key], obj[key], key, obj);
  1610. }
  1611. }
  1612. }
  1613. /**
  1614. * Iterate over an array.
  1615. *
  1616. * @deprecated
  1617. * @function Highcharts.each
  1618. *
  1619. * @param {Array<*>} arr
  1620. * The array to iterate over.
  1621. *
  1622. * @param {Function} fn
  1623. * The iterator callback. It passes three arguments:
  1624. * - `item`: The array item.
  1625. * - `index`: The item's index in the array.
  1626. * - `arr`: The array that each is being applied to.
  1627. *
  1628. * @param {*} [ctx]
  1629. * The context.
  1630. *
  1631. * @return {void}
  1632. */
  1633. /**
  1634. * Filter an array by a callback.
  1635. *
  1636. * @deprecated
  1637. * @function Highcharts.grep
  1638. *
  1639. * @param {Array<*>} arr
  1640. * The array to filter.
  1641. *
  1642. * @param {Function} callback
  1643. * The callback function. The function receives the item as the first
  1644. * argument. Return `true` if the item is to be preserved.
  1645. *
  1646. * @return {Array<*>}
  1647. * A new, filtered array.
  1648. */
  1649. /**
  1650. * Map an array by a callback.
  1651. *
  1652. * @deprecated
  1653. * @function Highcharts.map
  1654. *
  1655. * @param {Array<*>} arr
  1656. * The array to map.
  1657. *
  1658. * @param {Function} fn
  1659. * The callback function. Return the new value for the new array.
  1660. *
  1661. * @return {Array<*>}
  1662. * A new array item with modified items.
  1663. */
  1664. /**
  1665. * Reduce an array to a single value.
  1666. *
  1667. * @deprecated
  1668. * @function Highcharts.reduce
  1669. *
  1670. * @param {Array<*>} arr
  1671. * The array to reduce.
  1672. *
  1673. * @param {Function} fn
  1674. * The callback function. Return the reduced value. Receives 4
  1675. * arguments: Accumulated/reduced value, current value, current array
  1676. * index, and the array.
  1677. *
  1678. * @param {*} initialValue
  1679. * The initial value of the accumulator.
  1680. *
  1681. * @return {*}
  1682. * The reduced value.
  1683. */
  1684. /**
  1685. * Test whether at least one element in the array passes the test implemented by
  1686. * the provided function.
  1687. *
  1688. * @deprecated
  1689. * @function Highcharts.some
  1690. *
  1691. * @param {Array<*>} arr
  1692. * The array to test
  1693. *
  1694. * @param {Function} fn
  1695. * The function to run on each item. Return truty to pass the test.
  1696. * Receives arguments `currentValue`, `index` and `array`.
  1697. *
  1698. * @param {*} ctx
  1699. * The context.
  1700. *
  1701. * @return {boolean}
  1702. */
  1703. objectEach({
  1704. map: 'map',
  1705. each: 'forEach',
  1706. grep: 'filter',
  1707. reduce: 'reduce',
  1708. some: 'some'
  1709. }, function (val, key) {
  1710. H[key] = function (arr) {
  1711. var _a;
  1712. error(32, false, void 0, (_a = {}, _a["Highcharts." + key] = "use Array." + val, _a));
  1713. return Array.prototype[val].apply(arr, [].slice.call(arguments, 1));
  1714. };
  1715. });
  1716. /* eslint-disable valid-jsdoc */
  1717. /**
  1718. * Add an event listener.
  1719. *
  1720. * @function Highcharts.addEvent<T>
  1721. *
  1722. * @param {Highcharts.Class<T>|T} el
  1723. * The element or object to add a listener to. It can be a
  1724. * {@link HTMLDOMElement}, an {@link SVGElement} or any other object.
  1725. *
  1726. * @param {string} type
  1727. * The event type.
  1728. *
  1729. * @param {Highcharts.EventCallbackFunction<T>|Function} fn
  1730. * The function callback to execute when the event is fired.
  1731. *
  1732. * @param {Highcharts.EventOptionsObject} [options]
  1733. * Options for adding the event.
  1734. *
  1735. * @return {Function}
  1736. * A callback function to remove the added event.
  1737. */
  1738. function addEvent(el, type, fn, options) {
  1739. /* eslint-enable valid-jsdoc */
  1740. if (options === void 0) { options = {}; }
  1741. // Add hcEvents to either the prototype (in case we're running addEvent on a
  1742. // class) or the instance. If hasOwnProperty('hcEvents') is false, it is
  1743. // inherited down the prototype chain, in which case we need to set the
  1744. // property on this instance (which may itself be a prototype).
  1745. var owner = typeof el === 'function' && el.prototype || el;
  1746. if (!Object.hasOwnProperty.call(owner, 'hcEvents')) {
  1747. owner.hcEvents = {};
  1748. }
  1749. var events = owner.hcEvents;
  1750. // Allow click events added to points, otherwise they will be prevented by
  1751. // the TouchPointer.pinch function after a pinch zoom operation (#7091).
  1752. if (H.Point && // without H a dependency loop occurs
  1753. el instanceof H.Point &&
  1754. el.series &&
  1755. el.series.chart) {
  1756. el.series.chart.runTrackerClick = true;
  1757. }
  1758. // Handle DOM events
  1759. // If the browser supports passive events, add it to improve performance
  1760. // on touch events (#11353).
  1761. var addEventListener = (el.addEventListener || H.addEventListenerPolyfill);
  1762. if (addEventListener) {
  1763. addEventListener.call(el, type, fn, H.supportsPassiveEvents ? {
  1764. passive: options.passive === void 0 ?
  1765. type.indexOf('touch') !== -1 : options.passive,
  1766. capture: false
  1767. } : false);
  1768. }
  1769. if (!events[type]) {
  1770. events[type] = [];
  1771. }
  1772. var eventObject = {
  1773. fn: fn,
  1774. order: typeof options.order === 'number' ? options.order : Infinity
  1775. };
  1776. events[type].push(eventObject);
  1777. // Order the calls
  1778. events[type].sort(function (a, b) { return a.order - b.order; });
  1779. // Return a function that can be called to remove this event.
  1780. return function () {
  1781. removeEvent(el, type, fn);
  1782. };
  1783. }
  1784. /* eslint-disable valid-jsdoc */
  1785. /**
  1786. * Remove an event that was added with {@link Highcharts#addEvent}.
  1787. *
  1788. * @function Highcharts.removeEvent<T>
  1789. *
  1790. * @param {Highcharts.Class<T>|T} el
  1791. * The element to remove events on.
  1792. *
  1793. * @param {string} [type]
  1794. * The type of events to remove. If undefined, all events are removed
  1795. * from the element.
  1796. *
  1797. * @param {Highcharts.EventCallbackFunction<T>} [fn]
  1798. * The specific callback to remove. If undefined, all events that match
  1799. * the element and optionally the type are removed.
  1800. *
  1801. * @return {void}
  1802. */
  1803. function removeEvent(el, type, fn) {
  1804. /* eslint-enable valid-jsdoc */
  1805. /**
  1806. * @private
  1807. * @param {string} type - event type
  1808. * @param {Highcharts.EventCallbackFunction<T>} fn - callback
  1809. * @return {void}
  1810. */
  1811. function removeOneEvent(type, fn) {
  1812. var removeEventListener = (el.removeEventListener || H.removeEventListenerPolyfill);
  1813. if (removeEventListener) {
  1814. removeEventListener.call(el, type, fn, false);
  1815. }
  1816. }
  1817. /**
  1818. * @private
  1819. * @param {any} eventCollection - collection
  1820. * @return {void}
  1821. */
  1822. function removeAllEvents(eventCollection) {
  1823. var types,
  1824. len;
  1825. if (!el.nodeName) {
  1826. return; // break on non-DOM events
  1827. }
  1828. if (type) {
  1829. types = {};
  1830. types[type] = true;
  1831. }
  1832. else {
  1833. types = eventCollection;
  1834. }
  1835. objectEach(types, function (_val, n) {
  1836. if (eventCollection[n]) {
  1837. len = eventCollection[n].length;
  1838. while (len--) {
  1839. removeOneEvent(n, eventCollection[n][len].fn);
  1840. }
  1841. }
  1842. });
  1843. }
  1844. var owner = typeof el === 'function' && el.prototype || el;
  1845. if (Object.hasOwnProperty.call(owner, 'hcEvents')) {
  1846. var events = owner.hcEvents;
  1847. if (type) {
  1848. var typeEvents = (events[type] || []);
  1849. if (fn) {
  1850. events[type] = typeEvents.filter(function (obj) {
  1851. return fn !== obj.fn;
  1852. });
  1853. removeOneEvent(type, fn);
  1854. }
  1855. else {
  1856. removeAllEvents(events);
  1857. events[type] = [];
  1858. }
  1859. }
  1860. else {
  1861. removeAllEvents(events);
  1862. delete owner.hcEvents;
  1863. }
  1864. }
  1865. }
  1866. /* eslint-disable valid-jsdoc */
  1867. /**
  1868. * Fire an event that was registered with {@link Highcharts#addEvent}.
  1869. *
  1870. * @function Highcharts.fireEvent<T>
  1871. *
  1872. * @param {T} el
  1873. * The object to fire the event on. It can be a {@link HTMLDOMElement},
  1874. * an {@link SVGElement} or any other object.
  1875. *
  1876. * @param {string} type
  1877. * The type of event.
  1878. *
  1879. * @param {Highcharts.Dictionary<*>|Event} [eventArguments]
  1880. * Custom event arguments that are passed on as an argument to the event
  1881. * handler.
  1882. *
  1883. * @param {Highcharts.EventCallbackFunction<T>|Function} [defaultFunction]
  1884. * The default function to execute if the other listeners haven't
  1885. * returned false.
  1886. *
  1887. * @return {void}
  1888. */
  1889. function fireEvent(el, type, eventArguments, defaultFunction) {
  1890. /* eslint-enable valid-jsdoc */
  1891. var e,
  1892. i;
  1893. eventArguments = eventArguments || {};
  1894. if (doc.createEvent &&
  1895. (el.dispatchEvent ||
  1896. (el.fireEvent &&
  1897. // Enable firing events on Highcharts instance.
  1898. el !== H))) {
  1899. e = doc.createEvent('Events');
  1900. e.initEvent(type, true, true);
  1901. eventArguments = extend(e, eventArguments);
  1902. if (el.dispatchEvent) {
  1903. el.dispatchEvent(eventArguments);
  1904. }
  1905. else {
  1906. el.fireEvent(type, eventArguments);
  1907. }
  1908. }
  1909. else if (el.hcEvents) {
  1910. if (!eventArguments.target) {
  1911. // We're running a custom event
  1912. extend(eventArguments, {
  1913. // Attach a simple preventDefault function to skip
  1914. // default handler if called. The built-in
  1915. // defaultPrevented property is not overwritable (#5112)
  1916. preventDefault: function () {
  1917. eventArguments.defaultPrevented = true;
  1918. },
  1919. // Setting target to native events fails with clicking
  1920. // the zoom-out button in Chrome.
  1921. target: el,
  1922. // If the type is not set, we're running a custom event
  1923. // (#2297). If it is set, we're running a browser event,
  1924. // and setting it will cause en error in IE8 (#2465).
  1925. type: type
  1926. });
  1927. }
  1928. var events = [];
  1929. var object = el;
  1930. var multilevel = false;
  1931. // Recurse up the inheritance chain and collect hcEvents set as own
  1932. // objects on the prototypes.
  1933. while (object.hcEvents) {
  1934. if (Object.hasOwnProperty.call(object, 'hcEvents') &&
  1935. object.hcEvents[type]) {
  1936. if (events.length) {
  1937. multilevel = true;
  1938. }
  1939. events.unshift.apply(events, object.hcEvents[type]);
  1940. }
  1941. object = Object.getPrototypeOf(object);
  1942. }
  1943. // For performance reasons, only sort the event handlers in case we are
  1944. // dealing with multiple levels in the prototype chain. Otherwise, the
  1945. // events are already sorted in the addEvent function.
  1946. if (multilevel) {
  1947. // Order the calls
  1948. events.sort(function (a, b) { return a.order - b.order; });
  1949. }
  1950. // Call the collected event handlers
  1951. events.forEach(function (obj) {
  1952. // If the event handler returns false, prevent the default handler
  1953. // from executing
  1954. if (obj.fn.call(el, eventArguments) === false) {
  1955. eventArguments.preventDefault();
  1956. }
  1957. });
  1958. }
  1959. // Run the default if not prevented
  1960. if (defaultFunction && !eventArguments.defaultPrevented) {
  1961. defaultFunction.call(el, eventArguments);
  1962. }
  1963. }
  1964. var serialMode;
  1965. /**
  1966. * Get a unique key for using in internal element id's and pointers. The key is
  1967. * composed of a random hash specific to this Highcharts instance, and a
  1968. * counter.
  1969. *
  1970. * @example
  1971. * let id = uniqueKey(); // => 'highcharts-x45f6hp-0'
  1972. *
  1973. * @function Highcharts.uniqueKey
  1974. *
  1975. * @return {string}
  1976. * A unique key.
  1977. */
  1978. var uniqueKey = (function () {
  1979. var hash = Math.random().toString(36).substring(2, 9) + '-';
  1980. var id = 0;
  1981. return function () {
  1982. return 'highcharts-' + (serialMode ? '' : hash) + id++;
  1983. };
  1984. }());
  1985. /**
  1986. * Activates a serial mode for element IDs provided by
  1987. * {@link Highcharts.uniqueKey}. This mode can be used in automated tests, where
  1988. * a simple comparison of two rendered SVG graphics is needed.
  1989. *
  1990. * **Note:** This is only for testing purposes and will break functionality in
  1991. * webpages with multiple charts.
  1992. *
  1993. * @example
  1994. * if (
  1995. * process &&
  1996. * process.env.NODE_ENV === 'development'
  1997. * ) {
  1998. * Highcharts.useSerialIds(true);
  1999. * }
  2000. *
  2001. * @function Highcharts.useSerialIds
  2002. *
  2003. * @param {boolean} [mode]
  2004. * Changes the state of serial mode.
  2005. *
  2006. * @return {boolean|undefined}
  2007. * State of the serial mode.
  2008. */
  2009. function useSerialIds(mode) {
  2010. return (serialMode = pick(mode, serialMode));
  2011. }
  2012. function isFunction(obj) {
  2013. return typeof obj === 'function';
  2014. }
  2015. // Register Highcharts as a plugin in jQuery
  2016. if (win.jQuery) {
  2017. /**
  2018. * Highcharts-extended JQuery.
  2019. *
  2020. * @external JQuery
  2021. */
  2022. /**
  2023. * Helper function to return the chart of the current JQuery selector
  2024. * element.
  2025. *
  2026. * @function external:JQuery#highcharts
  2027. *
  2028. * @return {Highcharts.Chart}
  2029. * The chart that is linked to the JQuery selector element.
  2030. */ /**
  2031. * Factory function to create a chart in the current JQuery selector
  2032. * element.
  2033. *
  2034. * @function external:JQuery#highcharts
  2035. *
  2036. * @param {'Chart'|'Map'|'StockChart'|string} [className]
  2037. * Name of the factory class in the Highcharts namespace.
  2038. *
  2039. * @param {Highcharts.Options} [options]
  2040. * The chart options structure.
  2041. *
  2042. * @param {Highcharts.ChartCallbackFunction} [callback]
  2043. * Function to run when the chart has loaded and and all external
  2044. * images are loaded. Defining a
  2045. * [chart.events.load](https://api.highcharts.com/highcharts/chart.events.load)
  2046. * handler is equivalent.
  2047. *
  2048. * @return {JQuery}
  2049. * The current JQuery selector.
  2050. */
  2051. win.jQuery.fn.highcharts = function () {
  2052. var args = [].slice.call(arguments);
  2053. if (this[0]) { // this[0] is the renderTo div
  2054. // Create the chart
  2055. if (args[0]) {
  2056. new H[ // eslint-disable-line computed-property-spacing, no-new
  2057. // Constructor defaults to Chart
  2058. isString(args[0]) ? args.shift() : 'Chart'](this[0], args[0], args[1]);
  2059. return this;
  2060. }
  2061. // When called without parameters or with the return argument,
  2062. // return an existing chart
  2063. return charts[attr(this[0], 'data-highcharts-chart')];
  2064. }
  2065. };
  2066. }
  2067. // TODO use named exports when supported.
  2068. var Utilities = {
  2069. addEvent: addEvent,
  2070. arrayMax: arrayMax,
  2071. arrayMin: arrayMin,
  2072. attr: attr,
  2073. clamp: clamp,
  2074. cleanRecursively: cleanRecursively,
  2075. clearTimeout: internalClearTimeout,
  2076. correctFloat: correctFloat,
  2077. createElement: createElement,
  2078. css: css,
  2079. defined: defined,
  2080. destroyObjectProperties: destroyObjectProperties,
  2081. discardElement: discardElement,
  2082. erase: erase,
  2083. error: error,
  2084. extend: extend,
  2085. extendClass: extendClass,
  2086. find: find,
  2087. fireEvent: fireEvent,
  2088. getMagnitude: getMagnitude,
  2089. getNestedProperty: getNestedProperty,
  2090. getStyle: getStyle,
  2091. inArray: inArray,
  2092. isArray: isArray,
  2093. isClass: isClass,
  2094. isDOMElement: isDOMElement,
  2095. isFunction: isFunction,
  2096. isNumber: isNumber,
  2097. isObject: isObject,
  2098. isString: isString,
  2099. keys: keys,
  2100. merge: merge,
  2101. normalizeTickInterval: normalizeTickInterval,
  2102. objectEach: objectEach,
  2103. offset: offset,
  2104. pad: pad,
  2105. pick: pick,
  2106. pInt: pInt,
  2107. relativeLength: relativeLength,
  2108. removeEvent: removeEvent,
  2109. splat: splat,
  2110. stableSort: stableSort,
  2111. syncTimeout: syncTimeout,
  2112. timeUnits: timeUnits,
  2113. uniqueKey: uniqueKey,
  2114. useSerialIds: useSerialIds,
  2115. wrap: wrap
  2116. };
  2117. return Utilities;
  2118. });
  2119. _registerModule(_modules, 'Core/Color/Palette.js', [], function () {
  2120. var palette = {
  2121. /**
  2122. * Colors for data series and points.
  2123. */
  2124. colors: [
  2125. '#7cb5ec',
  2126. '#434348',
  2127. '#90ed7d',
  2128. '#f7a35c',
  2129. '#8085e9',
  2130. '#f15c80',
  2131. '#e4d354',
  2132. '#2b908f',
  2133. '#f45b5b',
  2134. '#91e8e1'
  2135. ],
  2136. /**
  2137. * Chart background,
  2138. point stroke for markers and columns etc
  2139. */
  2140. backgroundColor: '#ffffff',
  2141. /**
  2142. * Strong text.
  2143. */
  2144. neutralColor100: '#000000',
  2145. /**
  2146. * Main text and some strokes.
  2147. */
  2148. neutralColor80: '#333333',
  2149. /**
  2150. * Axis labels,
  2151. axis title,
  2152. connector fallback.
  2153. */
  2154. neutralColor60: '#666666',
  2155. /**
  2156. * Credits text,
  2157. export menu stroke.
  2158. */
  2159. neutralColor40: '#999999',
  2160. /**
  2161. * Disabled texts,
  2162. button strokes,
  2163. crosshair etc.
  2164. */
  2165. neutralColor20: '#cccccc',
  2166. /**
  2167. * Grid lines etc.
  2168. */
  2169. neutralColor10: '#e6e6e6',
  2170. /**
  2171. * Minor grid lines etc.
  2172. */
  2173. neutralColor5: '#f2f2f2',
  2174. /**
  2175. * Tooltip backgroud,
  2176. button fills,
  2177. map null points.
  2178. */
  2179. neutralColor3: '#f7f7f7',
  2180. /**
  2181. * Drilldown clickable labels,
  2182. color axis max color.
  2183. */
  2184. highlightColor100: '#003399',
  2185. /**
  2186. * Selection marker,
  2187. menu hover,
  2188. button hover,
  2189. chart border,
  2190. navigator series.
  2191. */
  2192. highlightColor80: '#335cad',
  2193. /**
  2194. * Navigator mask fill.
  2195. */
  2196. highlightColor60: '#6685c2',
  2197. /**
  2198. * Ticks and axis line.
  2199. */
  2200. highlightColor20: '#ccd6eb',
  2201. /**
  2202. * Pressed button,
  2203. color axis min color.
  2204. */
  2205. highlightColor10: '#e6ebf5',
  2206. /**
  2207. * Positive indicator color
  2208. */
  2209. positiveColor: '#06b535',
  2210. /**
  2211. * Negative indicator color
  2212. */
  2213. negativeColor: '#f21313'
  2214. };
  2215. return palette;
  2216. });
  2217. _registerModule(_modules, 'Core/Chart/ChartDefaults.js', [_modules['Core/Color/Palette.js']], function (Palette) {
  2218. /* *
  2219. *
  2220. * (c) 2010-2021 Torstein Honsi
  2221. *
  2222. * License: www.highcharts.com/license
  2223. *
  2224. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  2225. *
  2226. * */
  2227. /* *
  2228. *
  2229. * Constants
  2230. *
  2231. * */
  2232. /**
  2233. * General options for the chart.
  2234. *
  2235. * @optionparent chart
  2236. */
  2237. var ChartDefaults = {
  2238. /**
  2239. * Default `mapData` for all series. If set to a string,
  2240. it functions
  2241. * as an index into the `Highcharts.maps` array. Otherwise it is
  2242. * interpreted as map data.
  2243. *
  2244. * @see [mapData](#series.map.mapData)
  2245. *
  2246. * @sample maps/demo/geojson
  2247. * Loading geoJSON data
  2248. * @sample maps/chart/topojson
  2249. * Loading topoJSON converted to geoJSON
  2250. *
  2251. * @type {string|Array<*>|Highcharts.GeoJSON}
  2252. * @since 5.0.0
  2253. * @product highmaps
  2254. * @apioption chart.map
  2255. */
  2256. /**
  2257. * Set lat/lon transformation definitions for the chart. If not defined,
  2258. * these are extracted from the map data.
  2259. *
  2260. * @type {*}
  2261. * @since 5.0.0
  2262. * @product highmaps
  2263. * @apioption chart.mapTransforms
  2264. */
  2265. /**
  2266. * When using multiple axis,
  2267. the ticks of two or more opposite axes
  2268. * will automatically be aligned by adding ticks to the axis or axes
  2269. * with the least ticks,
  2270. as if `tickAmount` were specified.
  2271. *
  2272. * This can be prevented by setting `alignTicks` to false. If the grid
  2273. * lines look messy,
  2274. it's a good idea to hide them for the secondary
  2275. * axis by setting `gridLineWidth` to 0.
  2276. *
  2277. * If `startOnTick` or `endOnTick` in an Axis options are set to false,
  2278. * then the `alignTicks ` will be disabled for the Axis.
  2279. *
  2280. * Disabled for logarithmic axes.
  2281. *
  2282. * @sample {highcharts} highcharts/chart/alignticks-true/
  2283. * True by default
  2284. * @sample {highcharts} highcharts/chart/alignticks-false/
  2285. * False
  2286. * @sample {highstock} stock/chart/alignticks-true/
  2287. * True by default
  2288. * @sample {highstock} stock/chart/alignticks-false/
  2289. * False
  2290. *
  2291. * @type {boolean}
  2292. * @default true
  2293. * @product highcharts highstock gantt
  2294. * @apioption chart.alignTicks
  2295. */
  2296. /**
  2297. * Set the overall animation for all chart updating. Animation can be
  2298. * disabled throughout the chart by setting it to false here. It can
  2299. * be overridden for each individual API method as a function parameter.
  2300. * The only animation not affected by this option is the initial series
  2301. * animation,
  2302. see [plotOptions.series.animation](
  2303. * #plotOptions.series.animation).
  2304. *
  2305. * The animation can either be set as a boolean or a configuration
  2306. * object. If `true`,
  2307. it will use the 'swing' jQuery easing and a
  2308. * duration of 500 ms. If used as a configuration object,
  2309. the following
  2310. * properties are supported:
  2311. *
  2312. * - `defer`: The animation delay time in milliseconds.
  2313. *
  2314. * - `duration`: The duration of the animation in milliseconds.
  2315. *
  2316. * - `easing`: A string reference to an easing function set on the
  2317. * `Math` object. See
  2318. * [the easing demo](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-animation-easing/).
  2319. *
  2320. * When zooming on a series with less than 100 points,
  2321. the chart redraw
  2322. * will be done with animation,
  2323. but in case of more data points,
  2324. it is
  2325. * necessary to set this option to ensure animation on zoom.
  2326. *
  2327. * @sample {highcharts} highcharts/chart/animation-none/
  2328. * Updating with no animation
  2329. * @sample {highcharts} highcharts/chart/animation-duration/
  2330. * With a longer duration
  2331. * @sample {highcharts} highcharts/chart/animation-easing/
  2332. * With a jQuery UI easing
  2333. * @sample {highmaps} maps/chart/animation-none/
  2334. * Updating with no animation
  2335. * @sample {highmaps} maps/chart/animation-duration/
  2336. * With a longer duration
  2337. *
  2338. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  2339. * @default undefined
  2340. * @apioption chart.animation
  2341. */
  2342. /**
  2343. * A CSS class name to apply to the charts container `div`,
  2344. allowing
  2345. * unique CSS styling for each chart.
  2346. *
  2347. * @type {string}
  2348. * @apioption chart.className
  2349. */
  2350. /**
  2351. * Event listeners for the chart.
  2352. *
  2353. * @apioption chart.events
  2354. */
  2355. /**
  2356. * Fires when a series is added to the chart after load time,
  2357. using the
  2358. * `addSeries` method. One parameter,
  2359. `event`,
  2360. is passed to the
  2361. * function,
  2362. containing common event information. Through
  2363. * `event.options` you can access the series options that were passed to
  2364. * the `addSeries` method. Returning false prevents the series from
  2365. * being added.
  2366. *
  2367. * @sample {highcharts} highcharts/chart/events-addseries/
  2368. * Alert on add series
  2369. * @sample {highstock} stock/chart/events-addseries/
  2370. * Alert on add series
  2371. *
  2372. * @type {Highcharts.ChartAddSeriesCallbackFunction}
  2373. * @since 1.2.0
  2374. * @context Highcharts.Chart
  2375. * @apioption chart.events.addSeries
  2376. */
  2377. /**
  2378. * Fires when clicking on the plot background. One parameter,
  2379. `event`,
  2380. * is passed to the function,
  2381. containing common event information.
  2382. *
  2383. * Information on the clicked spot can be found through `event.xAxis`
  2384. * and `event.yAxis`,
  2385. which are arrays containing the axes of each
  2386. * dimension and each axis' value at the clicked spot. The primary axes
  2387. * are `event.xAxis[0]` and `event.yAxis[0]`. Remember the unit of a
  2388. * datetime axis is milliseconds since 1970-01-01 00:00:00.
  2389. *
  2390. * ```js
  2391. * click: function(e) {
  2392. * console.log(
  2393. * Highcharts.dateFormat('%Y-%m-%d %H:%M:%S',
  2394. e.xAxis[0].value),
  2395. * e.yAxis[0].value
  2396. * )
  2397. * }
  2398. * ```
  2399. *
  2400. * @sample {highcharts} highcharts/chart/events-click/
  2401. * Alert coordinates on click
  2402. * @sample {highcharts} highcharts/chart/events-container/
  2403. * Alternatively,
  2404. attach event to container
  2405. * @sample {highstock} stock/chart/events-click/
  2406. * Alert coordinates on click
  2407. * @sample {highstock} highcharts/chart/events-container/
  2408. * Alternatively,
  2409. attach event to container
  2410. * @sample {highmaps} maps/chart/events-click/
  2411. * Record coordinates on click
  2412. * @sample {highmaps} highcharts/chart/events-container/
  2413. * Alternatively,
  2414. attach event to container
  2415. *
  2416. * @type {Highcharts.ChartClickCallbackFunction}
  2417. * @since 1.2.0
  2418. * @context Highcharts.Chart
  2419. * @apioption chart.events.click
  2420. */
  2421. /**
  2422. * Fires when the chart is finished loading. Since v4.2.2,
  2423. it also waits
  2424. * for images to be loaded,
  2425. for example from point markers. One
  2426. * parameter,
  2427. `event`,
  2428. is passed to the function,
  2429. containing common
  2430. * event information.
  2431. *
  2432. * There is also a second parameter to the chart constructor where a
  2433. * callback function can be passed to be executed on chart.load.
  2434. *
  2435. * @sample {highcharts} highcharts/chart/events-load/
  2436. * Alert on chart load
  2437. * @sample {highstock} stock/chart/events-load/
  2438. * Alert on chart load
  2439. * @sample {highmaps} maps/chart/events-load/
  2440. * Add series on chart load
  2441. *
  2442. * @type {Highcharts.ChartLoadCallbackFunction}
  2443. * @context Highcharts.Chart
  2444. * @apioption chart.events.load
  2445. */
  2446. /**
  2447. * Fires when the chart is redrawn,
  2448. either after a call to
  2449. * `chart.redraw()` or after an axis,
  2450. series or point is modified with
  2451. * the `redraw` option set to `true`. One parameter,
  2452. `event`,
  2453. is passed
  2454. * to the function,
  2455. containing common event information.
  2456. *
  2457. * @sample {highcharts} highcharts/chart/events-redraw/
  2458. * Alert on chart redraw
  2459. * @sample {highstock} stock/chart/events-redraw/
  2460. * Alert on chart redraw when adding a series or moving the
  2461. * zoomed range
  2462. * @sample {highmaps} maps/chart/events-redraw/
  2463. * Set subtitle on chart redraw
  2464. *
  2465. * @type {Highcharts.ChartRedrawCallbackFunction}
  2466. * @since 1.2.0
  2467. * @context Highcharts.Chart
  2468. * @apioption chart.events.redraw
  2469. */
  2470. /**
  2471. * Fires after initial load of the chart (directly after the `load`
  2472. * event),
  2473. and after each redraw (directly after the `redraw` event).
  2474. *
  2475. * @type {Highcharts.ChartRenderCallbackFunction}
  2476. * @since 5.0.7
  2477. * @context Highcharts.Chart
  2478. * @apioption chart.events.render
  2479. */
  2480. /**
  2481. * Fires when an area of the chart has been selected. Selection is
  2482. * enabled by setting the chart's zoomType. One parameter,
  2483. `event`,
  2484. is
  2485. * passed to the function,
  2486. containing common event information. The
  2487. * default action for the selection event is to zoom the chart to the
  2488. * selected area. It can be prevented by calling
  2489. * `event.preventDefault()` or return false.
  2490. *
  2491. * Information on the selected area can be found through `event.xAxis`
  2492. * and `event.yAxis`,
  2493. which are arrays containing the axes of each
  2494. * dimension and each axis' min and max values. The primary axes are
  2495. * `event.xAxis[0]` and `event.yAxis[0]`. Remember the unit of a
  2496. * datetime axis is milliseconds since 1970-01-01 00:00:00.
  2497. *
  2498. * ```js
  2499. * selection: function(event) {
  2500. * // log the min and max of the primary, datetime x-axis
  2501. * console.log(
  2502. * Highcharts.dateFormat(
  2503. * '%Y-%m-%d %H:%M:%S',
  2504. * event.xAxis[0].min
  2505. * ),
  2506. * Highcharts.dateFormat(
  2507. * '%Y-%m-%d %H:%M:%S',
  2508. * event.xAxis[0].max
  2509. * )
  2510. * );
  2511. * // log the min and max of the y axis
  2512. * console.log(event.yAxis[0].min, event.yAxis[0].max);
  2513. * }
  2514. * ```
  2515. *
  2516. * @sample {highcharts} highcharts/chart/events-selection/
  2517. * Report on selection and reset
  2518. * @sample {highcharts} highcharts/chart/events-selection-points/
  2519. * Select a range of points through a drag selection
  2520. * @sample {highstock} stock/chart/events-selection/
  2521. * Report on selection and reset
  2522. * @sample {highstock} highcharts/chart/events-selection-points/
  2523. * Select a range of points through a drag selection
  2524. * (Highcharts)
  2525. *
  2526. * @type {Highcharts.ChartSelectionCallbackFunction}
  2527. * @apioption chart.events.selection
  2528. */
  2529. /**
  2530. * The margin between the outer edge of the chart and the plot area.
  2531. * The numbers in the array designate top, right, bottom and left
  2532. * respectively. Use the options `marginTop`, `marginRight`,
  2533. * `marginBottom` and `marginLeft` for shorthand setting of one option.
  2534. *
  2535. * By default there is no margin. The actual space is dynamically
  2536. * calculated from the offset of axis labels, axis title, title,
  2537. * subtitle and legend in addition to the `spacingTop`, `spacingRight`,
  2538. * `spacingBottom` and `spacingLeft` options.
  2539. *
  2540. * @sample {highcharts} highcharts/chart/margins-zero/
  2541. * Zero margins
  2542. * @sample {highstock} stock/chart/margin-zero/
  2543. * Zero margins
  2544. *
  2545. * @type {number|Array<number>}
  2546. * @apioption chart.margin
  2547. */
  2548. /**
  2549. * The margin between the bottom outer edge of the chart and the plot
  2550. * area. Use this to set a fixed pixel value for the margin as opposed
  2551. * to the default dynamic margin. See also `spacingBottom`.
  2552. *
  2553. * @sample {highcharts} highcharts/chart/marginbottom/
  2554. * 100px bottom margin
  2555. * @sample {highstock} stock/chart/marginbottom/
  2556. * 100px bottom margin
  2557. * @sample {highmaps} maps/chart/margin/
  2558. * 100px margins
  2559. *
  2560. * @type {number}
  2561. * @since 2.0
  2562. * @apioption chart.marginBottom
  2563. */
  2564. /**
  2565. * The margin between the left outer edge of the chart and the plot
  2566. * area. Use this to set a fixed pixel value for the margin as opposed
  2567. * to the default dynamic margin. See also `spacingLeft`.
  2568. *
  2569. * @sample {highcharts} highcharts/chart/marginleft/
  2570. * 150px left margin
  2571. * @sample {highstock} stock/chart/marginleft/
  2572. * 150px left margin
  2573. * @sample {highmaps} maps/chart/margin/
  2574. * 100px margins
  2575. *
  2576. * @type {number}
  2577. * @since 2.0
  2578. * @apioption chart.marginLeft
  2579. */
  2580. /**
  2581. * The margin between the right outer edge of the chart and the plot
  2582. * area. Use this to set a fixed pixel value for the margin as opposed
  2583. * to the default dynamic margin. See also `spacingRight`.
  2584. *
  2585. * @sample {highcharts} highcharts/chart/marginright/
  2586. * 100px right margin
  2587. * @sample {highstock} stock/chart/marginright/
  2588. * 100px right margin
  2589. * @sample {highmaps} maps/chart/margin/
  2590. * 100px margins
  2591. *
  2592. * @type {number}
  2593. * @since 2.0
  2594. * @apioption chart.marginRight
  2595. */
  2596. /**
  2597. * The margin between the top outer edge of the chart and the plot area.
  2598. * Use this to set a fixed pixel value for the margin as opposed to
  2599. * the default dynamic margin. See also `spacingTop`.
  2600. *
  2601. * @sample {highcharts} highcharts/chart/margintop/ 100px top margin
  2602. * @sample {highstock} stock/chart/margintop/
  2603. * 100px top margin
  2604. * @sample {highmaps} maps/chart/margin/
  2605. * 100px margins
  2606. *
  2607. * @type {number}
  2608. * @since 2.0
  2609. * @apioption chart.marginTop
  2610. */
  2611. /**
  2612. * Callback function to override the default function that formats all
  2613. * the numbers in the chart. Returns a string with the formatted number.
  2614. *
  2615. * @sample highcharts/members/highcharts-numberformat
  2616. * Arabic digits in Highcharts
  2617. * @type {Highcharts.NumberFormatterCallbackFunction}
  2618. * @since 8.0.0
  2619. * @apioption chart.numberFormatter
  2620. */
  2621. /**
  2622. * Allows setting a key to switch between zooming and panning. Can be
  2623. * one of `alt`, `ctrl`, `meta` (the command key on Mac and Windows
  2624. * key on Windows) or `shift`. The keys are mapped directly to the key
  2625. * properties of the click event argument (`event.altKey`,
  2626. * `event.ctrlKey`, `event.metaKey` and `event.shiftKey`).
  2627. *
  2628. * @type {string}
  2629. * @since 4.0.3
  2630. * @product highcharts gantt
  2631. * @validvalue ["alt", "ctrl", "meta", "shift"]
  2632. * @apioption chart.panKey
  2633. */
  2634. /**
  2635. * Allow panning in a chart. Best used with [panKey](#chart.panKey)
  2636. * to combine zooming and panning.
  2637. *
  2638. * On touch devices, when the [tooltip.followTouchMove](
  2639. * #tooltip.followTouchMove) option is `true` (default), panning
  2640. * requires two fingers. To allow panning with one finger, set
  2641. * `followTouchMove` to `false`.
  2642. *
  2643. * @sample {highcharts} highcharts/chart/pankey/ Zooming and panning
  2644. * @sample {highstock} stock/chart/panning/ Zooming and xy panning
  2645. */
  2646. panning: {
  2647. /**
  2648. * Enable or disable chart panning.
  2649. *
  2650. * @type {boolean}
  2651. * @default {highcharts} false
  2652. * @default {highstock|highmaps} true
  2653. */
  2654. enabled: false,
  2655. /**
  2656. * Decides in what dimensions the user can pan the chart. Can be
  2657. * one of `x`, `y`, or `xy`.
  2658. *
  2659. * @sample {highcharts} highcharts/chart/panning-type
  2660. * Zooming and xy panning
  2661. *
  2662. * @type {string}
  2663. * @validvalue ["x", "y", "xy"]
  2664. * @default {highcharts|highstock} x
  2665. * @default {highmaps} xy
  2666. */
  2667. type: 'x'
  2668. },
  2669. /**
  2670. * Equivalent to [zoomType](#chart.zoomType), but for multitouch
  2671. * gestures only. By default, the `pinchType` is the same as the
  2672. * `zoomType` setting. However, pinching can be enabled separately in
  2673. * some cases, for example in stock charts where a mouse drag pans the
  2674. * chart, while pinching is enabled. When [tooltip.followTouchMove](
  2675. * #tooltip.followTouchMove) is true, pinchType only applies to
  2676. * two-finger touches.
  2677. *
  2678. * @type {string}
  2679. * @default {highcharts} undefined
  2680. * @default {highstock} x
  2681. * @since 3.0
  2682. * @product highcharts highstock gantt
  2683. * @validvalue ["x", "y", "xy"]
  2684. * @apioption chart.pinchType
  2685. */
  2686. /**
  2687. * Whether to apply styled mode. When in styled mode, no presentational
  2688. * attributes or CSS are applied to the chart SVG. Instead, CSS rules
  2689. * are required to style the chart. The default style sheet is
  2690. * available from `https://code.highcharts.com/css/highcharts.css`.
  2691. *
  2692. * @type {boolean}
  2693. * @default false
  2694. * @since 7.0
  2695. * @apioption chart.styledMode
  2696. */
  2697. styledMode: false,
  2698. /**
  2699. * The corner radius of the outer chart border.
  2700. *
  2701. * @sample {highcharts} highcharts/chart/borderradius/
  2702. * 20px radius
  2703. * @sample {highstock} stock/chart/border/
  2704. * 10px radius
  2705. * @sample {highmaps} maps/chart/border/
  2706. * Border options
  2707. *
  2708. */
  2709. borderRadius: 0,
  2710. /**
  2711. * In styled mode, this sets how many colors the class names
  2712. * should rotate between. With ten colors, series (or points) are
  2713. * given class names like `highcharts-color-0`, `highcharts-color-0`
  2714. * [...] `highcharts-color-9`. The equivalent in non-styled mode
  2715. * is to set colors using the [colors](#colors) setting.
  2716. *
  2717. * @since 5.0.0
  2718. */
  2719. colorCount: 10,
  2720. /**
  2721. * Alias of `type`.
  2722. *
  2723. * @sample {highcharts} highcharts/chart/defaultseriestype/
  2724. * Bar
  2725. *
  2726. * @deprecated
  2727. *
  2728. * @product highcharts
  2729. */
  2730. defaultSeriesType: 'line',
  2731. /**
  2732. * If true, the axes will scale to the remaining visible series once
  2733. * one series is hidden. If false, hiding and showing a series will
  2734. * not affect the axes or the other series. For stacks, once one series
  2735. * within the stack is hidden, the rest of the stack will close in
  2736. * around it even if the axis is not affected.
  2737. *
  2738. * @sample {highcharts} highcharts/chart/ignorehiddenseries-true/
  2739. * True by default
  2740. * @sample {highcharts} highcharts/chart/ignorehiddenseries-false/
  2741. * False
  2742. * @sample {highcharts} highcharts/chart/ignorehiddenseries-true-stacked/
  2743. * True with stack
  2744. * @sample {highstock} stock/chart/ignorehiddenseries-true/
  2745. * True by default
  2746. * @sample {highstock} stock/chart/ignorehiddenseries-false/
  2747. * False
  2748. *
  2749. * @since 1.2.0
  2750. * @product highcharts highstock gantt
  2751. */
  2752. ignoreHiddenSeries: true,
  2753. /**
  2754. * Whether to invert the axes so that the x axis is vertical and y axis
  2755. * is horizontal. When `true`, the x axis is [reversed](#xAxis.reversed)
  2756. * by default.
  2757. *
  2758. * @productdesc {highcharts}
  2759. * If a bar series is present in the chart, it will be inverted
  2760. * automatically. Inverting the chart doesn't have an effect if there
  2761. * are no cartesian series in the chart, or if the chart is
  2762. * [polar](#chart.polar).
  2763. *
  2764. * @sample {highcharts} highcharts/chart/inverted/
  2765. * Inverted line
  2766. * @sample {highstock} stock/navigator/inverted/
  2767. * Inverted stock chart
  2768. *
  2769. * @type {boolean}
  2770. * @default false
  2771. * @product highcharts highstock gantt
  2772. * @apioption chart.inverted
  2773. */
  2774. /**
  2775. * The distance between the outer edge of the chart and the content,
  2776. * like title or legend, or axis title and labels if present. The
  2777. * numbers in the array designate top, right, bottom and left
  2778. * respectively. Use the options spacingTop, spacingRight, spacingBottom
  2779. * and spacingLeft options for shorthand setting of one option.
  2780. *
  2781. * @type {Array<number>}
  2782. * @see [chart.margin](#chart.margin)
  2783. * @default [10, 10, 15, 10]
  2784. * @since 3.0.6
  2785. */
  2786. spacing: [10, 10, 15, 10],
  2787. /**
  2788. * The button that appears after a selection zoom, allowing the user
  2789. * to reset zoom.
  2790. */
  2791. resetZoomButton: {
  2792. /**
  2793. * What frame the button placement should be related to. Can be
  2794. * either `plotBox` or `spacingBox`.
  2795. *
  2796. * @sample {highcharts} highcharts/chart/resetzoombutton-relativeto/
  2797. * Relative to the chart
  2798. * @sample {highstock} highcharts/chart/resetzoombutton-relativeto/
  2799. * Relative to the chart
  2800. *
  2801. * @type {Highcharts.ButtonRelativeToValue}
  2802. * @default plot
  2803. * @since 2.2
  2804. * @apioption chart.resetZoomButton.relativeTo
  2805. */
  2806. /**
  2807. * A collection of attributes for the button. The object takes SVG
  2808. * attributes like `fill`, `stroke`, `stroke-width` or `r`, the
  2809. * border radius. The theme also supports `style`, a collection of
  2810. * CSS properties for the text. Equivalent attributes for the hover
  2811. * state are given in `theme.states.hover`.
  2812. *
  2813. * @sample {highcharts} highcharts/chart/resetzoombutton-theme/
  2814. * Theming the button
  2815. * @sample {highstock} highcharts/chart/resetzoombutton-theme/
  2816. * Theming the button
  2817. *
  2818. * @type {Highcharts.SVGAttributes}
  2819. * @since 2.2
  2820. */
  2821. theme: {
  2822. /** @internal */
  2823. zIndex: 6
  2824. },
  2825. /**
  2826. * The position of the button.
  2827. *
  2828. * @sample {highcharts} highcharts/chart/resetzoombutton-position/
  2829. * Above the plot area
  2830. * @sample {highstock} highcharts/chart/resetzoombutton-position/
  2831. * Above the plot area
  2832. * @sample {highmaps} highcharts/chart/resetzoombutton-position/
  2833. * Above the plot area
  2834. *
  2835. * @type {Highcharts.AlignObject}
  2836. * @since 2.2
  2837. */
  2838. position: {
  2839. /**
  2840. * The horizontal alignment of the button.
  2841. */
  2842. align: 'right',
  2843. /**
  2844. * The horizontal offset of the button.
  2845. */
  2846. x: -10,
  2847. /**
  2848. * The vertical alignment of the button.
  2849. *
  2850. * @type {Highcharts.VerticalAlignValue}
  2851. * @default top
  2852. * @apioption chart.resetZoomButton.position.verticalAlign
  2853. */
  2854. /**
  2855. * The vertical offset of the button.
  2856. */
  2857. y: 10
  2858. }
  2859. },
  2860. /**
  2861. * The pixel width of the plot area border.
  2862. *
  2863. * @sample {highcharts} highcharts/chart/plotborderwidth/
  2864. * 1px border
  2865. * @sample {highstock} stock/chart/plotborder/
  2866. * 2px border
  2867. * @sample {highmaps} maps/chart/plotborder/
  2868. * Plot border options
  2869. *
  2870. * @type {number}
  2871. * @default 0
  2872. * @apioption chart.plotBorderWidth
  2873. */
  2874. /**
  2875. * Whether to apply a drop shadow to the plot area. Requires that
  2876. * plotBackgroundColor be set. The shadow can be an object configuration
  2877. * containing `color`, `offsetX`, `offsetY`, `opacity` and `width`.
  2878. *
  2879. * @sample {highcharts} highcharts/chart/plotshadow/
  2880. * Plot shadow
  2881. * @sample {highstock} stock/chart/plotshadow/
  2882. * Plot shadow
  2883. * @sample {highmaps} maps/chart/plotborder/
  2884. * Plot border options
  2885. *
  2886. * @type {boolean|Highcharts.CSSObject}
  2887. * @default false
  2888. * @apioption chart.plotShadow
  2889. */
  2890. /**
  2891. * When true, cartesian charts like line, spline, area and column are
  2892. * transformed into the polar coordinate system. This produces _polar
  2893. * charts_, also known as _radar charts_.
  2894. *
  2895. * @sample {highcharts} highcharts/demo/polar/
  2896. * Polar chart
  2897. * @sample {highcharts} highcharts/demo/polar-wind-rose/
  2898. * Wind rose, stacked polar column chart
  2899. * @sample {highcharts} highcharts/demo/polar-spider/
  2900. * Spider web chart
  2901. * @sample {highcharts} highcharts/parallel-coordinates/polar/
  2902. * Star plot, multivariate data in a polar chart
  2903. *
  2904. * @type {boolean}
  2905. * @default false
  2906. * @since 2.3.0
  2907. * @product highcharts
  2908. * @requires highcharts-more
  2909. * @apioption chart.polar
  2910. */
  2911. /**
  2912. * Whether to reflow the chart to fit the width of the container div
  2913. * on resizing the window.
  2914. *
  2915. * @sample {highcharts} highcharts/chart/reflow-true/
  2916. * True by default
  2917. * @sample {highcharts} highcharts/chart/reflow-false/
  2918. * False
  2919. * @sample {highstock} stock/chart/reflow-true/
  2920. * True by default
  2921. * @sample {highstock} stock/chart/reflow-false/
  2922. * False
  2923. * @sample {highmaps} maps/chart/reflow-true/
  2924. * True by default
  2925. * @sample {highmaps} maps/chart/reflow-false/
  2926. * False
  2927. *
  2928. * @type {boolean}
  2929. * @default true
  2930. * @since 2.1
  2931. * @apioption chart.reflow
  2932. */
  2933. /**
  2934. * The HTML element where the chart will be rendered. If it is a string,
  2935. * the element by that id is used. The HTML element can also be passed
  2936. * by direct reference, or as the first argument of the chart
  2937. * constructor, in which case the option is not needed.
  2938. *
  2939. * @sample {highcharts} highcharts/chart/reflow-true/
  2940. * String
  2941. * @sample {highcharts} highcharts/chart/renderto-object/
  2942. * Object reference
  2943. * @sample {highstock} stock/chart/renderto-string/
  2944. * String
  2945. * @sample {highstock} stock/chart/renderto-object/
  2946. * Object reference
  2947. *
  2948. * @type {string|Highcharts.HTMLDOMElement}
  2949. * @apioption chart.renderTo
  2950. */
  2951. /**
  2952. * The background color of the marker square when selecting (zooming
  2953. * in on) an area of the chart.
  2954. *
  2955. * @see In styled mode, the selection marker fill is set with the
  2956. * `.highcharts-selection-marker` class.
  2957. *
  2958. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  2959. * @default rgba(51,92,173,0.25)
  2960. * @since 2.1.7
  2961. * @apioption chart.selectionMarkerFill
  2962. */
  2963. /**
  2964. * Whether to apply a drop shadow to the outer chart area. Requires
  2965. * that backgroundColor be set. The shadow can be an object
  2966. * configuration containing `color`, `offsetX`, `offsetY`, `opacity` and
  2967. * `width`.
  2968. *
  2969. * @sample {highcharts} highcharts/chart/shadow/
  2970. * Shadow
  2971. * @sample {highstock} stock/chart/shadow/
  2972. * Shadow
  2973. * @sample {highmaps} maps/chart/border/
  2974. * Chart border and shadow
  2975. *
  2976. * @type {boolean|Highcharts.CSSObject}
  2977. * @default false
  2978. * @apioption chart.shadow
  2979. */
  2980. /**
  2981. * Whether to show the axes initially. This only applies to empty charts
  2982. * where series are added dynamically, as axes are automatically added
  2983. * to cartesian series.
  2984. *
  2985. * @sample {highcharts} highcharts/chart/showaxes-false/
  2986. * False by default
  2987. * @sample {highcharts} highcharts/chart/showaxes-true/
  2988. * True
  2989. *
  2990. * @type {boolean}
  2991. * @since 1.2.5
  2992. * @product highcharts gantt
  2993. * @apioption chart.showAxes
  2994. */
  2995. /**
  2996. * The space between the bottom edge of the chart and the content (plot
  2997. * area, axis title and labels, title, subtitle or legend in top
  2998. * position).
  2999. *
  3000. * @sample {highcharts} highcharts/chart/spacingbottom/
  3001. * Spacing bottom set to 100
  3002. * @sample {highstock} stock/chart/spacingbottom/
  3003. * Spacing bottom set to 100
  3004. * @sample {highmaps} maps/chart/spacing/
  3005. * Spacing 100 all around
  3006. *
  3007. * @type {number}
  3008. * @default 15
  3009. * @since 2.1
  3010. * @apioption chart.spacingBottom
  3011. */
  3012. /**
  3013. * The space between the left edge of the chart and the content (plot
  3014. * area, axis title and labels, title, subtitle or legend in top
  3015. * position).
  3016. *
  3017. * @sample {highcharts} highcharts/chart/spacingleft/
  3018. * Spacing left set to 100
  3019. * @sample {highstock} stock/chart/spacingleft/
  3020. * Spacing left set to 100
  3021. * @sample {highmaps} maps/chart/spacing/
  3022. * Spacing 100 all around
  3023. *
  3024. * @type {number}
  3025. * @default 10
  3026. * @since 2.1
  3027. * @apioption chart.spacingLeft
  3028. */
  3029. /**
  3030. * The space between the right edge of the chart and the content (plot
  3031. * area, axis title and labels, title, subtitle or legend in top
  3032. * position).
  3033. *
  3034. * @sample {highcharts} highcharts/chart/spacingright-100/
  3035. * Spacing set to 100
  3036. * @sample {highcharts} highcharts/chart/spacingright-legend/
  3037. * Legend in right position with default spacing
  3038. * @sample {highstock} stock/chart/spacingright/
  3039. * Spacing set to 100
  3040. * @sample {highmaps} maps/chart/spacing/
  3041. * Spacing 100 all around
  3042. *
  3043. * @type {number}
  3044. * @default 10
  3045. * @since 2.1
  3046. * @apioption chart.spacingRight
  3047. */
  3048. /**
  3049. * The space between the top edge of the chart and the content (plot
  3050. * area, axis title and labels, title, subtitle or legend in top
  3051. * position).
  3052. *
  3053. * @sample {highcharts} highcharts/chart/spacingtop-100/
  3054. * A top spacing of 100
  3055. * @sample {highcharts} highcharts/chart/spacingtop-10/
  3056. * Floating chart title makes the plot area align to the default
  3057. * spacingTop of 10.
  3058. * @sample {highstock} stock/chart/spacingtop/
  3059. * A top spacing of 100
  3060. * @sample {highmaps} maps/chart/spacing/
  3061. * Spacing 100 all around
  3062. *
  3063. * @type {number}
  3064. * @default 10
  3065. * @since 2.1
  3066. * @apioption chart.spacingTop
  3067. */
  3068. /**
  3069. * Additional CSS styles to apply inline to the container `div`. Note
  3070. * that since the default font styles are applied in the renderer, it
  3071. * is ignorant of the individual chart options and must be set globally.
  3072. *
  3073. * @see In styled mode, general chart styles can be set with the
  3074. * `.highcharts-root` class.
  3075. * @sample {highcharts} highcharts/chart/style-serif-font/
  3076. * Using a serif type font
  3077. * @sample {highcharts} highcharts/css/em/
  3078. * Styled mode with relative font sizes
  3079. * @sample {highstock} stock/chart/style/
  3080. * Using a serif type font
  3081. * @sample {highmaps} maps/chart/style-serif-font/
  3082. * Using a serif type font
  3083. *
  3084. * @type {Highcharts.CSSObject}
  3085. * @default {"fontFamily": "\"Lucida Grande\", \"Lucida Sans Unicode\", Verdana, Arial, Helvetica, sans-serif","fontSize":"12px"}
  3086. * @apioption chart.style
  3087. */
  3088. /**
  3089. * The default series type for the chart. Can be any of the chart types
  3090. * listed under [plotOptions](#plotOptions) and [series](#series) or can
  3091. * be a series provided by an additional module.
  3092. *
  3093. * In TypeScript this option has no effect in sense of typing and
  3094. * instead the `type` option must always be set in the series.
  3095. *
  3096. * @sample {highcharts} highcharts/chart/type-bar/
  3097. * Bar
  3098. * @sample {highstock} stock/chart/type/
  3099. * Areaspline
  3100. * @sample {highmaps} maps/chart/type-mapline/
  3101. * Mapline
  3102. *
  3103. * @type {string}
  3104. * @default {highcharts} line
  3105. * @default {highstock} line
  3106. * @default {highmaps} map
  3107. * @since 2.1.0
  3108. * @apioption chart.type
  3109. */
  3110. /**
  3111. * Decides in what dimensions the user can zoom by dragging the mouse.
  3112. * Can be one of `x`, `y` or `xy`.
  3113. *
  3114. * @see [panKey](#chart.panKey)
  3115. *
  3116. * @sample {highcharts} highcharts/chart/zoomtype-none/
  3117. * None by default
  3118. * @sample {highcharts} highcharts/chart/zoomtype-x/
  3119. * X
  3120. * @sample {highcharts} highcharts/chart/zoomtype-y/
  3121. * Y
  3122. * @sample {highcharts} highcharts/chart/zoomtype-xy/
  3123. * Xy
  3124. * @sample {highstock} stock/demo/basic-line/
  3125. * None by default
  3126. * @sample {highstock} stock/chart/zoomtype-x/
  3127. * X
  3128. * @sample {highstock} stock/chart/zoomtype-y/
  3129. * Y
  3130. * @sample {highstock} stock/chart/zoomtype-xy/
  3131. * Xy
  3132. *
  3133. * @type {string}
  3134. * @product highcharts highstock gantt
  3135. * @validvalue ["x", "y", "xy"]
  3136. * @apioption chart.zoomType
  3137. */
  3138. /**
  3139. * Enables zooming by a single touch, in combination with
  3140. * [chart.zoomType](#chart.zoomType). When enabled, two-finger pinch
  3141. * will still work as set up by [chart.pinchType](#chart.pinchType).
  3142. * However, `zoomBySingleTouch` will interfere with touch-dragging the
  3143. * chart to read the tooltip. And especially when vertical zooming is
  3144. * enabled, it will make it hard to scroll vertically on the page.
  3145. * @since 9.0.0
  3146. * @sample highcharts/chart/zoombysingletouch
  3147. * Zoom by single touch enabled, with buttons to toggle
  3148. * @product highcharts highstock gantt
  3149. */
  3150. zoomBySingleTouch: false,
  3151. /**
  3152. * An explicit width for the chart. By default (when `null`) the width
  3153. * is calculated from the offset width of the containing element.
  3154. *
  3155. * @sample {highcharts} highcharts/chart/width/
  3156. * 800px wide
  3157. * @sample {highstock} stock/chart/width/
  3158. * 800px wide
  3159. * @sample {highmaps} maps/chart/size/
  3160. * Chart with explicit size
  3161. *
  3162. * @type {null|number|string}
  3163. */
  3164. width: null,
  3165. /**
  3166. * An explicit height for the chart. If a _number_, the height is
  3167. * given in pixels. If given a _percentage string_ (for example
  3168. * `'56%'`), the height is given as the percentage of the actual chart
  3169. * width. This allows for preserving the aspect ratio across responsive
  3170. * sizes.
  3171. *
  3172. * By default (when `null`) the height is calculated from the offset
  3173. * height of the containing element, or 400 pixels if the containing
  3174. * element's height is 0.
  3175. *
  3176. * @sample {highcharts} highcharts/chart/height/
  3177. * 500px height
  3178. * @sample {highstock} stock/chart/height/
  3179. * 300px height
  3180. * @sample {highmaps} maps/chart/size/
  3181. * Chart with explicit size
  3182. * @sample highcharts/chart/height-percent/
  3183. * Highcharts with percentage height
  3184. *
  3185. * @type {null|number|string}
  3186. */
  3187. height: null,
  3188. /**
  3189. * The color of the outer chart border.
  3190. *
  3191. * @see In styled mode, the stroke is set with the
  3192. * `.highcharts-background` class.
  3193. *
  3194. * @sample {highcharts} highcharts/chart/bordercolor/
  3195. * Brown border
  3196. * @sample {highstock} stock/chart/border/
  3197. * Brown border
  3198. * @sample {highmaps} maps/chart/border/
  3199. * Border options
  3200. *
  3201. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  3202. */
  3203. borderColor: Palette.highlightColor80,
  3204. /**
  3205. * The pixel width of the outer chart border.
  3206. *
  3207. * @see In styled mode, the stroke is set with the
  3208. * `.highcharts-background` class.
  3209. *
  3210. * @sample {highcharts} highcharts/chart/borderwidth/
  3211. * 5px border
  3212. * @sample {highstock} stock/chart/border/
  3213. * 2px border
  3214. * @sample {highmaps} maps/chart/border/
  3215. * Border options
  3216. *
  3217. * @type {number}
  3218. * @default 0
  3219. * @apioption chart.borderWidth
  3220. */
  3221. /**
  3222. * The background color or gradient for the outer chart area.
  3223. *
  3224. * @see In styled mode, the background is set with the
  3225. * `.highcharts-background` class.
  3226. *
  3227. * @sample {highcharts} highcharts/chart/backgroundcolor-color/
  3228. * Color
  3229. * @sample {highcharts} highcharts/chart/backgroundcolor-gradient/
  3230. * Gradient
  3231. * @sample {highstock} stock/chart/backgroundcolor-color/
  3232. * Color
  3233. * @sample {highstock} stock/chart/backgroundcolor-gradient/
  3234. * Gradient
  3235. * @sample {highmaps} maps/chart/backgroundcolor-color/
  3236. * Color
  3237. * @sample {highmaps} maps/chart/backgroundcolor-gradient/
  3238. * Gradient
  3239. *
  3240. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  3241. */
  3242. backgroundColor: Palette.backgroundColor,
  3243. /**
  3244. * The background color or gradient for the plot area.
  3245. *
  3246. * @see In styled mode, the plot background is set with the
  3247. * `.highcharts-plot-background` class.
  3248. *
  3249. * @sample {highcharts} highcharts/chart/plotbackgroundcolor-color/
  3250. * Color
  3251. * @sample {highcharts} highcharts/chart/plotbackgroundcolor-gradient/
  3252. * Gradient
  3253. * @sample {highstock} stock/chart/plotbackgroundcolor-color/
  3254. * Color
  3255. * @sample {highstock} stock/chart/plotbackgroundcolor-gradient/
  3256. * Gradient
  3257. * @sample {highmaps} maps/chart/plotbackgroundcolor-color/
  3258. * Color
  3259. * @sample {highmaps} maps/chart/plotbackgroundcolor-gradient/
  3260. * Gradient
  3261. *
  3262. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  3263. * @apioption chart.plotBackgroundColor
  3264. */
  3265. /**
  3266. * The URL for an image to use as the plot background. To set an image
  3267. * as the background for the entire chart, set a CSS background image
  3268. * to the container element. Note that for the image to be applied to
  3269. * exported charts, its URL needs to be accessible by the export server.
  3270. *
  3271. * @see In styled mode, a plot background image can be set with the
  3272. * `.highcharts-plot-background` class and a [custom pattern](
  3273. * https://www.highcharts.com/docs/chart-design-and-style/
  3274. * gradients-shadows-and-patterns).
  3275. *
  3276. * @sample {highcharts} highcharts/chart/plotbackgroundimage/
  3277. * Skies
  3278. * @sample {highstock} stock/chart/plotbackgroundimage/
  3279. * Skies
  3280. *
  3281. * @type {string}
  3282. * @apioption chart.plotBackgroundImage
  3283. */
  3284. /**
  3285. * The color of the inner chart or plot area border.
  3286. *
  3287. * @see In styled mode, a plot border stroke can be set with the
  3288. * `.highcharts-plot-border` class.
  3289. *
  3290. * @sample {highcharts} highcharts/chart/plotbordercolor/
  3291. * Blue border
  3292. * @sample {highstock} stock/chart/plotborder/
  3293. * Blue border
  3294. * @sample {highmaps} maps/chart/plotborder/
  3295. * Plot border options
  3296. *
  3297. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  3298. */
  3299. plotBorderColor: Palette.neutralColor20
  3300. };
  3301. /* *
  3302. *
  3303. * Default Export
  3304. *
  3305. * */
  3306. return ChartDefaults;
  3307. });
  3308. _registerModule(_modules, 'Core/Color/Color.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  3309. /* *
  3310. *
  3311. * (c) 2010-2021 Torstein Honsi
  3312. *
  3313. * License: www.highcharts.com/license
  3314. *
  3315. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  3316. *
  3317. * */
  3318. var isNumber = U.isNumber,
  3319. merge = U.merge,
  3320. pInt = U.pInt;
  3321. /* *
  3322. *
  3323. * Class
  3324. *
  3325. * */
  3326. /* eslint-disable no-invalid-this, valid-jsdoc */
  3327. /**
  3328. * Handle color operations. Some object methods are chainable.
  3329. *
  3330. * @class
  3331. * @name Highcharts.Color
  3332. *
  3333. * @param {Highcharts.ColorType} input
  3334. * The input color in either rbga or hex format
  3335. */
  3336. var Color = /** @class */ (function () {
  3337. /* *
  3338. *
  3339. * Constructors
  3340. *
  3341. * */
  3342. function Color(input) {
  3343. // Collection of parsers. This can be extended from the outside by pushing
  3344. // parsers to Highcharts.Color.prototype.parsers.
  3345. this.parsers = [{
  3346. // RGBA color
  3347. // eslint-disable-next-line max-len
  3348. 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*\)/,
  3349. parse: function (result) {
  3350. return [
  3351. pInt(result[1]),
  3352. pInt(result[2]),
  3353. pInt(result[3]),
  3354. parseFloat(result[4], 10)
  3355. ];
  3356. }
  3357. }, {
  3358. // RGB color
  3359. regex: /rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/,
  3360. parse: function (result) {
  3361. return [pInt(result[1]), pInt(result[2]), pInt(result[3]), 1];
  3362. }
  3363. }];
  3364. this.rgba = [];
  3365. var GlobalColor = H.Color;
  3366. // Backwards compatibility, allow class overwrite
  3367. if (GlobalColor && GlobalColor !== Color) {
  3368. return new GlobalColor(input);
  3369. }
  3370. // Backwards compatibility, allow instanciation without new (#13053)
  3371. if (!(this instanceof Color)) {
  3372. return new Color(input);
  3373. }
  3374. this.init(input);
  3375. }
  3376. /* *
  3377. *
  3378. * Static Functions
  3379. *
  3380. * */
  3381. /**
  3382. * Creates a color instance out of a color string or object.
  3383. *
  3384. * @function Highcharts.Color.parse
  3385. *
  3386. * @param {Highcharts.ColorType} input
  3387. * The input color in either rbga or hex format.
  3388. *
  3389. * @return {Highcharts.Color}
  3390. * Color instance.
  3391. */
  3392. Color.parse = function (input) {
  3393. return new Color(input);
  3394. };
  3395. /* *
  3396. *
  3397. * Functions
  3398. *
  3399. * */
  3400. /**
  3401. * Parse the input color to rgba array
  3402. *
  3403. * @private
  3404. * @function Highcharts.Color#init
  3405. *
  3406. * @param {Highcharts.ColorType} input
  3407. * The input color in either rbga or hex format
  3408. *
  3409. * @return {void}
  3410. */
  3411. Color.prototype.init = function (input) {
  3412. var result,
  3413. rgba,
  3414. i,
  3415. parser,
  3416. len;
  3417. this.input = input = Color.names[input && input.toLowerCase ?
  3418. input.toLowerCase() :
  3419. ''] || input;
  3420. // Gradients
  3421. if (input && input.stops) {
  3422. this.stops = input.stops.map(function (stop) {
  3423. return new Color(stop[1]);
  3424. });
  3425. // Solid colors
  3426. }
  3427. else {
  3428. // Bitmasking as input[0] is not working for legacy IE.
  3429. if (input &&
  3430. input.charAt &&
  3431. input.charAt() === '#') {
  3432. len = input.length;
  3433. input = parseInt(input.substr(1), 16);
  3434. // Handle long-form, e.g. #AABBCC
  3435. if (len === 7) {
  3436. rgba = [
  3437. (input & 0xFF0000) >> 16,
  3438. (input & 0xFF00) >> 8,
  3439. (input & 0xFF),
  3440. 1
  3441. ];
  3442. // Handle short-form, e.g. #ABC
  3443. // In short form, the value is assumed to be the same
  3444. // for both nibbles for each component. e.g. #ABC = #AABBCC
  3445. }
  3446. else if (len === 4) {
  3447. rgba = [
  3448. (((input & 0xF00) >> 4) |
  3449. (input & 0xF00) >> 8),
  3450. (((input & 0xF0) >> 4) |
  3451. (input & 0xF0)),
  3452. ((input & 0xF) << 4) | (input & 0xF),
  3453. 1
  3454. ];
  3455. }
  3456. }
  3457. // Otherwise, check regex parsers
  3458. if (!rgba) {
  3459. i = this.parsers.length;
  3460. while (i-- && !rgba) {
  3461. parser = this.parsers[i];
  3462. result = parser.regex.exec(input);
  3463. if (result) {
  3464. rgba = parser.parse(result);
  3465. }
  3466. }
  3467. }
  3468. }
  3469. this.rgba = rgba || [];
  3470. };
  3471. /**
  3472. * Return the color or gradient stops in the specified format
  3473. *
  3474. * @function Highcharts.Color#get
  3475. *
  3476. * @param {string} [format]
  3477. * Possible values are 'a', 'rgb', 'rgba' (default).
  3478. *
  3479. * @return {Highcharts.ColorType}
  3480. * This color as a string or gradient stops.
  3481. */
  3482. Color.prototype.get = function (format) {
  3483. var input = this.input,
  3484. rgba = this.rgba,
  3485. ret;
  3486. if (typeof this.stops !== 'undefined') {
  3487. ret = merge(input);
  3488. ret.stops = [].concat(ret.stops);
  3489. this.stops.forEach(function (stop, i) {
  3490. ret.stops[i] = [
  3491. ret.stops[i][0],
  3492. stop.get(format)
  3493. ];
  3494. });
  3495. // it's NaN if gradient colors on a column chart
  3496. }
  3497. else if (rgba && isNumber(rgba[0])) {
  3498. if (format === 'rgb' || (!format && rgba[3] === 1)) {
  3499. ret = 'rgb(' + rgba[0] + ',' + rgba[1] + ',' + rgba[2] + ')';
  3500. }
  3501. else if (format === 'a') {
  3502. ret = rgba[3];
  3503. }
  3504. else {
  3505. ret = 'rgba(' + rgba.join(',') + ')';
  3506. }
  3507. }
  3508. else {
  3509. ret = input;
  3510. }
  3511. return ret;
  3512. };
  3513. /**
  3514. * Brighten the color instance.
  3515. *
  3516. * @function Highcharts.Color#brighten
  3517. *
  3518. * @param {number} alpha
  3519. * The alpha value.
  3520. *
  3521. * @return {Highcharts.Color}
  3522. * This color with modifications.
  3523. */
  3524. Color.prototype.brighten = function (alpha) {
  3525. var i,
  3526. rgba = this.rgba;
  3527. if (this.stops) {
  3528. this.stops.forEach(function (stop) {
  3529. stop.brighten(alpha);
  3530. });
  3531. }
  3532. else if (isNumber(alpha) && alpha !== 0) {
  3533. for (i = 0; i < 3; i++) {
  3534. rgba[i] += pInt(alpha * 255);
  3535. if (rgba[i] < 0) {
  3536. rgba[i] = 0;
  3537. }
  3538. if (rgba[i] > 255) {
  3539. rgba[i] = 255;
  3540. }
  3541. }
  3542. }
  3543. return this;
  3544. };
  3545. /**
  3546. * Set the color's opacity to a given alpha value.
  3547. *
  3548. * @function Highcharts.Color#setOpacity
  3549. *
  3550. * @param {number} alpha
  3551. * Opacity between 0 and 1.
  3552. *
  3553. * @return {Highcharts.Color}
  3554. * Color with modifications.
  3555. */
  3556. Color.prototype.setOpacity = function (alpha) {
  3557. this.rgba[3] = alpha;
  3558. return this;
  3559. };
  3560. /**
  3561. * Return an intermediate color between two colors.
  3562. *
  3563. * @function Highcharts.Color#tweenTo
  3564. *
  3565. * @param {Highcharts.Color} to
  3566. * The color object to tween to.
  3567. *
  3568. * @param {number} pos
  3569. * The intermediate position, where 0 is the from color (current
  3570. * color item), and 1 is the `to` color.
  3571. *
  3572. * @return {Highcharts.ColorString}
  3573. * The intermediate color in rgba notation.
  3574. */
  3575. Color.prototype.tweenTo = function (to, pos) {
  3576. // Check for has alpha, because rgba colors perform worse due to lack of
  3577. // support in WebKit.
  3578. var fromRgba = this.rgba,
  3579. toRgba = to.rgba,
  3580. hasAlpha,
  3581. ret;
  3582. // Unsupported color, return to-color (#3920, #7034)
  3583. if (!toRgba.length || !fromRgba || !fromRgba.length) {
  3584. ret = to.input || 'none';
  3585. // Interpolate
  3586. }
  3587. else {
  3588. hasAlpha = (toRgba[3] !== 1 || fromRgba[3] !== 1);
  3589. ret = (hasAlpha ? 'rgba(' : 'rgb(') +
  3590. Math.round(toRgba[0] + (fromRgba[0] - toRgba[0]) * (1 - pos)) +
  3591. ',' +
  3592. Math.round(toRgba[1] + (fromRgba[1] - toRgba[1]) * (1 - pos)) +
  3593. ',' +
  3594. Math.round(toRgba[2] + (fromRgba[2] - toRgba[2]) * (1 - pos)) +
  3595. (hasAlpha ?
  3596. (',' +
  3597. (toRgba[3] + (fromRgba[3] - toRgba[3]) * (1 - pos))) :
  3598. '') +
  3599. ')';
  3600. }
  3601. return ret;
  3602. };
  3603. /* *
  3604. *
  3605. * Static Properties
  3606. *
  3607. * */
  3608. /**
  3609. * Collection of named colors. Can be extended from the outside by adding
  3610. * colors to Highcharts.Color.names.
  3611. * @private
  3612. */
  3613. Color.names = {
  3614. white: '#ffffff',
  3615. black: '#000000'
  3616. };
  3617. return Color;
  3618. }());
  3619. /* *
  3620. *
  3621. * Default Export
  3622. *
  3623. * */
  3624. /* *
  3625. *
  3626. * API Declarations
  3627. *
  3628. * */
  3629. /**
  3630. * A valid color to be parsed and handled by Highcharts. Highcharts internally
  3631. * supports hex colors like `#ffffff`, rgb colors like `rgb(255,255,255)` and
  3632. * rgba colors like `rgba(255,255,255,1)`. Other colors may be supported by the
  3633. * browsers and displayed correctly, but Highcharts is not able to process them
  3634. * and apply concepts like opacity and brightening.
  3635. *
  3636. * @typedef {string} Highcharts.ColorString
  3637. */
  3638. /**
  3639. * A valid color type than can be parsed and handled by Highcharts. It can be a
  3640. * color string, a gradient object, or a pattern object.
  3641. *
  3642. * @typedef {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject} Highcharts.ColorType
  3643. */
  3644. /**
  3645. * Gradient options instead of a solid color.
  3646. *
  3647. * @example
  3648. * // Linear gradient used as a color option
  3649. * color: {
  3650. * linearGradient: { x1: 0, x2: 0, y1: 0, y2: 1 },
  3651. * stops: [
  3652. * [0, '#003399'], // start
  3653. * [0.5, '#ffffff'], // middle
  3654. * [1, '#3366AA'] // end
  3655. * ]
  3656. * }
  3657. *
  3658. * @interface Highcharts.GradientColorObject
  3659. */ /**
  3660. * Holds an object that defines the start position and the end position relative
  3661. * to the shape.
  3662. * @name Highcharts.GradientColorObject#linearGradient
  3663. * @type {Highcharts.LinearGradientColorObject|undefined}
  3664. */ /**
  3665. * Holds an object that defines the center position and the radius.
  3666. * @name Highcharts.GradientColorObject#radialGradient
  3667. * @type {Highcharts.RadialGradientColorObject|undefined}
  3668. */ /**
  3669. * The first item in each tuple is the position in the gradient, where 0 is the
  3670. * start of the gradient and 1 is the end of the gradient. Multiple stops can be
  3671. * applied. The second item is the color for each stop. This color can also be
  3672. * given in the rgba format.
  3673. * @name Highcharts.GradientColorObject#stops
  3674. * @type {Array<Highcharts.GradientColorStopObject>}
  3675. */
  3676. /**
  3677. * Color stop tuple.
  3678. *
  3679. * @see Highcharts.GradientColorObject
  3680. *
  3681. * @interface Highcharts.GradientColorStopObject
  3682. */ /**
  3683. * @name Highcharts.GradientColorStopObject#0
  3684. * @type {number}
  3685. */ /**
  3686. * @name Highcharts.GradientColorStopObject#1
  3687. * @type {Highcharts.ColorString}
  3688. */ /**
  3689. * @name Highcharts.GradientColorStopObject#color
  3690. * @type {Highcharts.Color|undefined}
  3691. */
  3692. /**
  3693. * Defines the start position and the end position for a gradient relative
  3694. * to the shape. Start position (x1, y1) and end position (x2, y2) are relative
  3695. * to the shape, where 0 means top/left and 1 is bottom/right.
  3696. *
  3697. * @interface Highcharts.LinearGradientColorObject
  3698. */ /**
  3699. * Start horizontal position of the gradient. Float ranges 0-1.
  3700. * @name Highcharts.LinearGradientColorObject#x1
  3701. * @type {number}
  3702. */ /**
  3703. * End horizontal position of the gradient. Float ranges 0-1.
  3704. * @name Highcharts.LinearGradientColorObject#x2
  3705. * @type {number}
  3706. */ /**
  3707. * Start vertical position of the gradient. Float ranges 0-1.
  3708. * @name Highcharts.LinearGradientColorObject#y1
  3709. * @type {number}
  3710. */ /**
  3711. * End vertical position of the gradient. Float ranges 0-1.
  3712. * @name Highcharts.LinearGradientColorObject#y2
  3713. * @type {number}
  3714. */
  3715. /**
  3716. * Defines the center position and the radius for a gradient.
  3717. *
  3718. * @interface Highcharts.RadialGradientColorObject
  3719. */ /**
  3720. * Center horizontal position relative to the shape. Float ranges 0-1.
  3721. * @name Highcharts.RadialGradientColorObject#cx
  3722. * @type {number}
  3723. */ /**
  3724. * Center vertical position relative to the shape. Float ranges 0-1.
  3725. * @name Highcharts.RadialGradientColorObject#cy
  3726. * @type {number}
  3727. */ /**
  3728. * Radius relative to the shape. Float ranges 0-1.
  3729. * @name Highcharts.RadialGradientColorObject#r
  3730. * @type {number}
  3731. */
  3732. /**
  3733. * Creates a color instance out of a color string.
  3734. *
  3735. * @function Highcharts.color
  3736. *
  3737. * @param {Highcharts.ColorType} input
  3738. * The input color in either rbga or hex format
  3739. *
  3740. * @return {Highcharts.Color}
  3741. * Color instance
  3742. */
  3743. (''); // detach doclets above
  3744. return Color;
  3745. });
  3746. _registerModule(_modules, 'Core/Time.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  3747. /* *
  3748. *
  3749. * (c) 2010-2021 Torstein Honsi
  3750. *
  3751. * License: www.highcharts.com/license
  3752. *
  3753. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  3754. *
  3755. * */
  3756. var win = H.win;
  3757. var defined = U.defined,
  3758. error = U.error,
  3759. extend = U.extend,
  3760. isObject = U.isObject,
  3761. merge = U.merge,
  3762. objectEach = U.objectEach,
  3763. pad = U.pad,
  3764. pick = U.pick,
  3765. splat = U.splat,
  3766. timeUnits = U.timeUnits;
  3767. /* *
  3768. *
  3769. * Constants
  3770. *
  3771. * */
  3772. var hasNewSafariBug = (H.isSafari && Intl.DateTimeFormat.prototype.formatRange);
  3773. // To do: Remove this when we no longer need support for Safari < v14.1
  3774. var hasOldSafariBug = (H.isSafari && !Intl.DateTimeFormat.prototype.formatRange);
  3775. /* *
  3776. *
  3777. * Class
  3778. *
  3779. * */
  3780. /* eslint-disable no-invalid-this, valid-jsdoc */
  3781. /**
  3782. * The Time class. Time settings are applied in general for each page using
  3783. * `Highcharts.setOptions`, or individually for each Chart item through the
  3784. * [time](https://api.highcharts.com/highcharts/time) options set.
  3785. *
  3786. * The Time object is available from {@link Highcharts.Chart#time},
  3787. * which refers to `Highcharts.time` if no individual time settings are
  3788. * applied.
  3789. *
  3790. * @example
  3791. * // Apply time settings globally
  3792. * Highcharts.setOptions({
  3793. * time: {
  3794. * timezone: 'Europe/London'
  3795. * }
  3796. * });
  3797. *
  3798. * // Apply time settings by instance
  3799. * let chart = Highcharts.chart('container', {
  3800. * time: {
  3801. * timezone: 'America/New_York'
  3802. * },
  3803. * series: [{
  3804. * data: [1, 4, 3, 5]
  3805. * }]
  3806. * });
  3807. *
  3808. * // Use the Time object
  3809. * console.log(
  3810. * 'Current time in New York',
  3811. * chart.time.dateFormat('%Y-%m-%d %H:%M:%S', Date.now())
  3812. * );
  3813. *
  3814. * @since 6.0.5
  3815. *
  3816. * @class
  3817. * @name Highcharts.Time
  3818. *
  3819. * @param {Highcharts.TimeOptions} options
  3820. * Time options as defined in [chart.options.time](/highcharts/time).
  3821. */
  3822. var Time = /** @class */ (function () {
  3823. /* *
  3824. *
  3825. * Constructors
  3826. *
  3827. * */
  3828. function Time(options) {
  3829. /* *
  3830. *
  3831. * Properties
  3832. *
  3833. * */
  3834. this.options = {};
  3835. this.useUTC = false;
  3836. this.variableTimezone = false;
  3837. this.Date = win.Date;
  3838. /**
  3839. * Get the time zone offset based on the current timezone information as
  3840. * set in the global options.
  3841. *
  3842. * @function Highcharts.Time#getTimezoneOffset
  3843. *
  3844. * @param {number} timestamp
  3845. * The JavaScript timestamp to inspect.
  3846. *
  3847. * @return {number}
  3848. * The timezone offset in minutes compared to UTC.
  3849. */
  3850. this.getTimezoneOffset = this.timezoneOffsetFunction();
  3851. this.update(options);
  3852. }
  3853. /* *
  3854. *
  3855. * Functions
  3856. *
  3857. * */
  3858. /**
  3859. * Time units used in `Time.get` and `Time.set`
  3860. *
  3861. * @typedef {"Date"|"Day"|"FullYear"|"Hours"|"Milliseconds"|"Minutes"|"Month"|"Seconds"} Highcharts.TimeUnitValue
  3862. */
  3863. /**
  3864. * Get the value of a date object in given units, and subject to the Time
  3865. * object's current timezone settings. This function corresponds directly to
  3866. * JavaScripts `Date.getXXX / Date.getUTCXXX`, so instead of calling
  3867. * `date.getHours()` or `date.getUTCHours()` we will call
  3868. * `time.get('Hours')`.
  3869. *
  3870. * @function Highcharts.Time#get
  3871. *
  3872. * @param {Highcharts.TimeUnitValue} unit
  3873. * @param {Date} date
  3874. *
  3875. * @return {number}
  3876. * The given time unit
  3877. */
  3878. Time.prototype.get = function (unit, date) {
  3879. if (this.variableTimezone || this.timezoneOffset) {
  3880. var realMs = date.getTime();
  3881. var ms = realMs - this.getTimezoneOffset(date);
  3882. date.setTime(ms); // Temporary adjust to timezone
  3883. var ret = date['getUTC' + unit]();
  3884. date.setTime(realMs); // Reset
  3885. return ret;
  3886. }
  3887. // UTC time with no timezone handling
  3888. if (this.useUTC) {
  3889. return date['getUTC' + unit]();
  3890. }
  3891. // Else, local time
  3892. return date['get' + unit]();
  3893. };
  3894. /**
  3895. * Set the value of a date object in given units, and subject to the Time
  3896. * object's current timezone settings. This function corresponds directly to
  3897. * JavaScripts `Date.setXXX / Date.setUTCXXX`, so instead of calling
  3898. * `date.setHours(0)` or `date.setUTCHours(0)` we will call
  3899. * `time.set('Hours', 0)`.
  3900. *
  3901. * @function Highcharts.Time#set
  3902. *
  3903. * @param {Highcharts.TimeUnitValue} unit
  3904. * @param {Date} date
  3905. * @param {number} value
  3906. *
  3907. * @return {number}
  3908. * The epoch milliseconds of the updated date
  3909. */
  3910. Time.prototype.set = function (unit, date, value) {
  3911. // UTC time with timezone handling
  3912. if (this.variableTimezone || this.timezoneOffset) {
  3913. // For lower order time units, just set it directly using UTC
  3914. // time
  3915. if (unit === 'Milliseconds' ||
  3916. unit === 'Seconds' ||
  3917. (unit === 'Minutes' && this.getTimezoneOffset(date) % 3600000 === 0) // #13961
  3918. ) {
  3919. return date['setUTC' + unit](value);
  3920. }
  3921. // Higher order time units need to take the time zone into
  3922. // account
  3923. // Adjust by timezone
  3924. var offset = this.getTimezoneOffset(date);
  3925. var ms = date.getTime() - offset;
  3926. date.setTime(ms);
  3927. date['setUTC' + unit](value);
  3928. var newOffset = this.getTimezoneOffset(date);
  3929. ms = date.getTime() + newOffset;
  3930. return date.setTime(ms);
  3931. }
  3932. // UTC time with no timezone handling
  3933. if (this.useUTC ||
  3934. (hasNewSafariBug && unit === 'FullYear') // leap calculation in UTC only
  3935. ) {
  3936. return date['setUTC' + unit](value);
  3937. }
  3938. // Else, local time
  3939. return date['set' + unit](value);
  3940. };
  3941. /**
  3942. * Update the Time object with current options. It is called internally on
  3943. * initializing Highcharts, after running `Highcharts.setOptions` and on
  3944. * `Chart.update`.
  3945. *
  3946. * @private
  3947. * @function Highcharts.Time#update
  3948. *
  3949. * @param {Highcharts.TimeOptions} options
  3950. *
  3951. * @return {void}
  3952. */
  3953. Time.prototype.update = function (options) {
  3954. var useUTC = pick(options && options.useUTC,
  3955. true),
  3956. time = this;
  3957. this.options = options = merge(true, this.options || {}, options);
  3958. // Allow using a different Date class
  3959. this.Date = options.Date || win.Date || Date;
  3960. this.useUTC = useUTC;
  3961. this.timezoneOffset = (useUTC && options.timezoneOffset);
  3962. this.getTimezoneOffset = this.timezoneOffsetFunction();
  3963. /*
  3964. * The time object has options allowing for variable time zones, meaning
  3965. * the axis ticks or series data needs to consider this.
  3966. */
  3967. this.variableTimezone = useUTC && !!(options.getTimezoneOffset ||
  3968. options.timezone);
  3969. };
  3970. /**
  3971. * Make a time and returns milliseconds. Interprets the inputs as UTC time,
  3972. * local time or a specific timezone time depending on the current time
  3973. * settings.
  3974. *
  3975. * @function Highcharts.Time#makeTime
  3976. *
  3977. * @param {number} year
  3978. * The year
  3979. *
  3980. * @param {number} month
  3981. * The month. Zero-based, so January is 0.
  3982. *
  3983. * @param {number} [date=1]
  3984. * The day of the month
  3985. *
  3986. * @param {number} [hours=0]
  3987. * The hour of the day, 0-23.
  3988. *
  3989. * @param {number} [minutes=0]
  3990. * The minutes
  3991. *
  3992. * @param {number} [seconds=0]
  3993. * The seconds
  3994. *
  3995. * @return {number}
  3996. * The time in milliseconds since January 1st 1970.
  3997. */
  3998. Time.prototype.makeTime = function (year, month, date, hours, minutes, seconds) {
  3999. var d,
  4000. offset,
  4001. newOffset;
  4002. if (this.useUTC) {
  4003. d = this.Date.UTC.apply(0, arguments);
  4004. offset = this.getTimezoneOffset(d);
  4005. d += offset;
  4006. newOffset = this.getTimezoneOffset(d);
  4007. if (offset !== newOffset) {
  4008. d += newOffset - offset;
  4009. // A special case for transitioning from summer time to winter time.
  4010. // When the clock is set back, the same time is repeated twice, i.e.
  4011. // 02:30 am is repeated since the clock is set back from 3 am to
  4012. // 2 am. We need to make the same time as local Date does.
  4013. }
  4014. else if (offset - 36e5 === this.getTimezoneOffset(d - 36e5) &&
  4015. !hasOldSafariBug) {
  4016. d -= 36e5;
  4017. }
  4018. }
  4019. else {
  4020. d = new this.Date(year, month, pick(date, 1), pick(hours, 0), pick(minutes, 0), pick(seconds, 0)).getTime();
  4021. }
  4022. return d;
  4023. };
  4024. /**
  4025. * Sets the getTimezoneOffset function. If the `timezone` option is set, a
  4026. * default getTimezoneOffset function with that timezone is returned. If
  4027. * a `getTimezoneOffset` option is defined, it is returned. If neither are
  4028. * specified, the function using the `timezoneOffset` option or 0 offset is
  4029. * returned.
  4030. *
  4031. * @private
  4032. * @function Highcharts.Time#timezoneOffsetFunction
  4033. *
  4034. * @return {Function}
  4035. * A getTimezoneOffset function
  4036. */
  4037. Time.prototype.timezoneOffsetFunction = function () {
  4038. var time = this,
  4039. options = this.options,
  4040. moment = options.moment || win.moment;
  4041. if (!this.useUTC) {
  4042. return function (timestamp) {
  4043. return new Date(timestamp.toString()).getTimezoneOffset() * 60000;
  4044. };
  4045. }
  4046. if (options.timezone) {
  4047. if (!moment) {
  4048. // getTimezoneOffset-function stays undefined because it depends
  4049. // on Moment.js
  4050. error(25);
  4051. }
  4052. else {
  4053. return function (timestamp) {
  4054. return -moment.tz(timestamp, options.timezone).utcOffset() * 60000;
  4055. };
  4056. }
  4057. }
  4058. // If not timezone is set, look for the getTimezoneOffset callback
  4059. if (this.useUTC && options.getTimezoneOffset) {
  4060. return function (timestamp) {
  4061. return options.getTimezoneOffset(timestamp.valueOf()) * 60000;
  4062. };
  4063. }
  4064. // Last, use the `timezoneOffset` option if set
  4065. return function () {
  4066. return (time.timezoneOffset || 0) * 60000;
  4067. };
  4068. };
  4069. /**
  4070. * Formats a JavaScript date timestamp (milliseconds since Jan 1st 1970)
  4071. * into a human readable date string. The available format keys are listed
  4072. * below. Additional formats can be given in the
  4073. * {@link Highcharts.dateFormats} hook.
  4074. *
  4075. * Supported format keys:
  4076. * - `%a`: Short weekday, like 'Mon'
  4077. * - `%A`: Long weekday, like 'Monday'
  4078. * - `%d`: Two digit day of the month, 01 to 31
  4079. * - `%e`: Day of the month, 1 through 31
  4080. * - `%w`: Day of the week, 0 through 6
  4081. * - `%b`: Short month, like 'Jan'
  4082. * - `%B`: Long month, like 'January'
  4083. * - `%m`: Two digit month number, 01 through 12
  4084. * - `%y`: Two digits year, like 09 for 2009
  4085. * - `%Y`: Four digits year, like 2009
  4086. * - `%H`: Two digits hours in 24h format, 00 through 23
  4087. * - `%k`: Hours in 24h format, 0 through 23
  4088. * - `%I`: Two digits hours in 12h format, 00 through 11
  4089. * - `%l`: Hours in 12h format, 1 through 12
  4090. * - `%M`: Two digits minutes, 00 through 59
  4091. * - `%p`: Upper case AM or PM
  4092. * - `%P`: Lower case AM or PM
  4093. * - `%S`: Two digits seconds, 00 through 59
  4094. * - `%L`: Milliseconds (naming from Ruby)
  4095. *
  4096. * @example
  4097. * const time = new Highcharts.Time();
  4098. * const s = time.dateFormat('%Y-%m-%d %H:%M:%S', Date.UTC(2020, 0, 1));
  4099. * console.log(s); // => 2020-01-01 00:00:00
  4100. *
  4101. * @function Highcharts.Time#dateFormat
  4102. *
  4103. * @param {string} format
  4104. * The desired format where various time representations are
  4105. * prefixed with %.
  4106. *
  4107. * @param {number} [timestamp]
  4108. * The JavaScript timestamp.
  4109. *
  4110. * @param {boolean} [capitalize=false]
  4111. * Upper case first letter in the return.
  4112. *
  4113. * @return {string}
  4114. * The formatted date.
  4115. */
  4116. Time.prototype.dateFormat = function (format, timestamp, capitalize) {
  4117. if (!defined(timestamp) || isNaN(timestamp)) {
  4118. return (H.defaultOptions.lang &&
  4119. H.defaultOptions.lang.invalidDate ||
  4120. '');
  4121. }
  4122. format = pick(format, '%Y-%m-%d %H:%M:%S');
  4123. var time = this, date = new this.Date(timestamp),
  4124. // get the basic time values
  4125. 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),
  4126. // List all format keys. Custom formats can be added from the
  4127. // outside.
  4128. replacements = extend({
  4129. // Day
  4130. // Short weekday, like 'Mon'
  4131. a: shortWeekdays ?
  4132. shortWeekdays[day] :
  4133. langWeekdays[day].substr(0, 3),
  4134. // Long weekday, like 'Monday'
  4135. A: langWeekdays[day],
  4136. // Two digit day of the month, 01 to 31
  4137. d: pad(dayOfMonth),
  4138. // Day of the month, 1 through 31
  4139. e: pad(dayOfMonth, 2, ' '),
  4140. // Day of the week, 0 through 6
  4141. w: day,
  4142. // Week (none implemented)
  4143. // 'W': weekNumber(),
  4144. // Month
  4145. // Short month, like 'Jan'
  4146. b: lang.shortMonths[month],
  4147. // Long month, like 'January'
  4148. B: lang.months[month],
  4149. // Two digit month number, 01 through 12
  4150. m: pad(month + 1),
  4151. // Month number, 1 through 12 (#8150)
  4152. o: month + 1,
  4153. // Year
  4154. // Two digits year, like 09 for 2009
  4155. y: fullYear.toString().substr(2, 2),
  4156. // Four digits year, like 2009
  4157. Y: fullYear,
  4158. // Time
  4159. // Two digits hours in 24h format, 00 through 23
  4160. H: pad(hours),
  4161. // Hours in 24h format, 0 through 23
  4162. k: hours,
  4163. // Two digits hours in 12h format, 00 through 11
  4164. I: pad((hours % 12) || 12),
  4165. // Hours in 12h format, 1 through 12
  4166. l: (hours % 12) || 12,
  4167. // Two digits minutes, 00 through 59
  4168. M: pad(this.get('Minutes', date)),
  4169. // Upper case AM or PM
  4170. p: hours < 12 ? 'AM' : 'PM',
  4171. // Lower case AM or PM
  4172. P: hours < 12 ? 'am' : 'pm',
  4173. // Two digits seconds, 00 through 59
  4174. S: pad(date.getSeconds()),
  4175. // Milliseconds (naming from Ruby)
  4176. L: pad(Math.floor(timestamp % 1000), 3)
  4177. }, H.dateFormats);
  4178. // Do the replaces
  4179. objectEach(replacements, function (val, key) {
  4180. // Regex would do it in one line, but this is faster
  4181. while (format.indexOf('%' + key) !== -1) {
  4182. format = format.replace('%' + key, typeof val === 'function' ? val.call(time, timestamp) : val);
  4183. }
  4184. });
  4185. // Optionally capitalize the string and return
  4186. return capitalize ?
  4187. (format.substr(0, 1).toUpperCase() +
  4188. format.substr(1)) :
  4189. format;
  4190. };
  4191. /**
  4192. * Resolve legacy formats of dateTimeLabelFormats (strings and arrays) into
  4193. * an object.
  4194. * @private
  4195. * @param {string|Array<T>|Highcharts.Dictionary<T>} f - General format description
  4196. * @return {Highcharts.Dictionary<T>} - The object definition
  4197. */
  4198. Time.prototype.resolveDTLFormat = function (f) {
  4199. if (!isObject(f, true)) { // check for string or array
  4200. f = splat(f);
  4201. return {
  4202. main: f[0],
  4203. from: f[1],
  4204. to: f[2]
  4205. };
  4206. }
  4207. return f;
  4208. };
  4209. /**
  4210. * Return an array with time positions distributed on round time values
  4211. * right and right after min and max. Used in datetime axes as well as for
  4212. * grouping data on a datetime axis.
  4213. *
  4214. * @function Highcharts.Time#getTimeTicks
  4215. *
  4216. * @param {Highcharts.TimeNormalizedObject} normalizedInterval
  4217. * The interval in axis values (ms) and the count
  4218. *
  4219. * @param {number} [min]
  4220. * The minimum in axis values
  4221. *
  4222. * @param {number} [max]
  4223. * The maximum in axis values
  4224. *
  4225. * @param {number} [startOfWeek=1]
  4226. *
  4227. * @return {Highcharts.AxisTickPositionsArray}
  4228. */
  4229. Time.prototype.getTimeTicks = function (normalizedInterval, min, max, startOfWeek) {
  4230. var time = this,
  4231. Date = time.Date,
  4232. tickPositions = [],
  4233. higherRanks = {},
  4234. // When crossing DST, use the max. Resolves #6278.
  4235. minDate = new Date(min),
  4236. interval = normalizedInterval.unitRange,
  4237. count = normalizedInterval.count || 1;
  4238. var i,
  4239. minYear, // used in months and years as a basis for Date.UTC()
  4240. variableDayLength,
  4241. minDay;
  4242. startOfWeek = pick(startOfWeek, 1);
  4243. if (defined(min)) { // #1300
  4244. time.set('Milliseconds', minDate, interval >= timeUnits.second ?
  4245. 0 : // #3935
  4246. count * Math.floor(time.get('Milliseconds', minDate) / count)); // #3652, #3654
  4247. if (interval >= timeUnits.second) { // second
  4248. time.set('Seconds', minDate, interval >= timeUnits.minute ?
  4249. 0 : // #3935
  4250. count * Math.floor(time.get('Seconds', minDate) / count));
  4251. }
  4252. if (interval >= timeUnits.minute) { // minute
  4253. time.set('Minutes', minDate, interval >= timeUnits.hour ?
  4254. 0 :
  4255. count * Math.floor(time.get('Minutes', minDate) / count));
  4256. }
  4257. if (interval >= timeUnits.hour) { // hour
  4258. time.set('Hours', minDate, interval >= timeUnits.day ?
  4259. 0 :
  4260. count * Math.floor(time.get('Hours', minDate) / count));
  4261. }
  4262. if (interval >= timeUnits.day) { // day
  4263. time.set('Date', minDate, interval >= timeUnits.month ?
  4264. 1 :
  4265. Math.max(1, count * Math.floor(time.get('Date', minDate) / count)));
  4266. }
  4267. if (interval >= timeUnits.month) { // month
  4268. time.set('Month', minDate, interval >= timeUnits.year ? 0 :
  4269. count * Math.floor(time.get('Month', minDate) / count));
  4270. minYear = time.get('FullYear', minDate);
  4271. }
  4272. if (interval >= timeUnits.year) { // year
  4273. minYear -= minYear % count;
  4274. time.set('FullYear', minDate, minYear);
  4275. }
  4276. // week is a special case that runs outside the hierarchy
  4277. if (interval === timeUnits.week) {
  4278. // get start of current week, independent of count
  4279. minDay = time.get('Day', minDate);
  4280. time.set('Date', minDate, (time.get('Date', minDate) -
  4281. minDay + startOfWeek +
  4282. // We don't want to skip days that are before
  4283. // startOfWeek (#7051)
  4284. (minDay < startOfWeek ? -7 : 0)));
  4285. }
  4286. // Get basics for variable time spans
  4287. minYear = time.get('FullYear', minDate);
  4288. var minMonth = time.get('Month', minDate), minDateDate = time.get('Date', minDate), minHours = time.get('Hours', minDate);
  4289. // Redefine min to the floored/rounded minimum time (#7432)
  4290. min = minDate.getTime();
  4291. // Handle local timezone offset
  4292. if ((time.variableTimezone || !time.useUTC) && defined(max)) {
  4293. // Detect whether we need to take the DST crossover into
  4294. // consideration. If we're crossing over DST, the day length may
  4295. // be 23h or 25h and we need to compute the exact clock time for
  4296. // each tick instead of just adding hours. This comes at a cost,
  4297. // so first we find out if it is needed (#4951).
  4298. variableDayLength = (
  4299. // Long range, assume we're crossing over.
  4300. max - min > 4 * timeUnits.month ||
  4301. // Short range, check if min and max are in different time
  4302. // zones.
  4303. time.getTimezoneOffset(min) !==
  4304. time.getTimezoneOffset(max));
  4305. }
  4306. // Iterate and add tick positions at appropriate values
  4307. var t = minDate.getTime();
  4308. i = 1;
  4309. while (t < max) {
  4310. tickPositions.push(t);
  4311. // if the interval is years, use Date.UTC to increase years
  4312. if (interval === timeUnits.year) {
  4313. t = time.makeTime(minYear + i * count, 0);
  4314. // if the interval is months, use Date.UTC to increase months
  4315. }
  4316. else if (interval === timeUnits.month) {
  4317. t = time.makeTime(minYear, minMonth + i * count);
  4318. // if we're using global time, the interval is not fixed as it
  4319. // jumps one hour at the DST crossover
  4320. }
  4321. else if (variableDayLength &&
  4322. (interval === timeUnits.day || interval === timeUnits.week)) {
  4323. t = time.makeTime(minYear, minMonth, minDateDate +
  4324. i * count * (interval === timeUnits.day ? 1 : 7));
  4325. }
  4326. else if (variableDayLength &&
  4327. interval === timeUnits.hour &&
  4328. count > 1) {
  4329. // make sure higher ranks are preserved across DST (#6797,
  4330. // #7621)
  4331. t = time.makeTime(minYear, minMonth, minDateDate, minHours + i * count);
  4332. // else, the interval is fixed and we use simple addition
  4333. }
  4334. else {
  4335. t += interval * count;
  4336. }
  4337. i++;
  4338. }
  4339. // push the last time
  4340. tickPositions.push(t);
  4341. // Handle higher ranks. Mark new days if the time is on midnight
  4342. // (#950, #1649, #1760, #3349). Use a reasonable dropout threshold
  4343. // to prevent looping over dense data grouping (#6156).
  4344. if (interval <= timeUnits.hour && tickPositions.length < 10000) {
  4345. tickPositions.forEach(function (t) {
  4346. if (
  4347. // Speed optimization, no need to run dateFormat unless
  4348. // we're on a full or half hour
  4349. t % 1800000 === 0 &&
  4350. // Check for local or global midnight
  4351. time.dateFormat('%H%M%S%L', t) === '000000000') {
  4352. higherRanks[t] = 'day';
  4353. }
  4354. });
  4355. }
  4356. }
  4357. // record information on the chosen unit - for dynamic label formatter
  4358. tickPositions.info = extend(normalizedInterval, {
  4359. higherRanks: higherRanks,
  4360. totalRange: interval * count
  4361. });
  4362. return tickPositions;
  4363. };
  4364. return Time;
  4365. }());
  4366. /**
  4367. * Normalized interval.
  4368. *
  4369. * @interface Highcharts.TimeNormalizedObject
  4370. */ /**
  4371. * The count.
  4372. *
  4373. * @name Highcharts.TimeNormalizedObject#count
  4374. * @type {number}
  4375. */ /**
  4376. * The interval in axis values (ms).
  4377. *
  4378. * @name Highcharts.TimeNormalizedObject#unitRange
  4379. * @type {number}
  4380. */
  4381. /**
  4382. * Function of an additional date format specifier.
  4383. *
  4384. * @callback Highcharts.TimeFormatCallbackFunction
  4385. *
  4386. * @param {number} timestamp
  4387. * The time to format.
  4388. *
  4389. * @return {string}
  4390. * The formatted portion of the date.
  4391. */
  4392. /**
  4393. * Time ticks.
  4394. *
  4395. * @interface Highcharts.AxisTickPositionsArray
  4396. * @extends global.Array<number>
  4397. */ /**
  4398. * @name Highcharts.AxisTickPositionsArray#info
  4399. * @type {Highcharts.TimeTicksInfoObject|undefined}
  4400. */
  4401. /**
  4402. * A callback to return the time zone offset for a given datetime. It
  4403. * takes the timestamp in terms of milliseconds since January 1 1970,
  4404. * and returns the timezone offset in minutes. This provides a hook
  4405. * for drawing time based charts in specific time zones using their
  4406. * local DST crossover dates, with the help of external libraries.
  4407. *
  4408. * @callback Highcharts.TimezoneOffsetCallbackFunction
  4409. *
  4410. * @param {number} timestamp
  4411. * Timestamp in terms of milliseconds since January 1 1970.
  4412. *
  4413. * @return {number}
  4414. * Timezone offset in minutes.
  4415. */
  4416. /**
  4417. * Allows to manually load the `moment.js` library from Highcharts options
  4418. * instead of the `window`.
  4419. * In case of loading the library from a `script` tag,
  4420. * this option is not needed, it will be loaded from there by default.
  4421. *
  4422. * @type {function}
  4423. * @since 8.2.0
  4424. * @apioption time.moment
  4425. */
  4426. ''; // keeps doclets above in JS file
  4427. return Time;
  4428. });
  4429. _registerModule(_modules, 'Core/DefaultOptions.js', [_modules['Core/Globals.js'], _modules['Core/Chart/ChartDefaults.js'], _modules['Core/Color/Color.js'], _modules['Core/Color/Palette.js'], _modules['Core/Time.js'], _modules['Core/Utilities.js']], function (H, ChartDefaults, Color, palette, Time, U) {
  4430. /* *
  4431. *
  4432. * (c) 2010-2021 Torstein Honsi
  4433. *
  4434. * License: www.highcharts.com/license
  4435. *
  4436. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  4437. *
  4438. * */
  4439. var isTouchDevice = H.isTouchDevice,
  4440. svg = H.svg;
  4441. var color = Color.parse;
  4442. var merge = U.merge;
  4443. /* *
  4444. *
  4445. * API Declarations
  4446. *
  4447. * */
  4448. /**
  4449. * @typedef {"plotBox"|"spacingBox"} Highcharts.ButtonRelativeToValue
  4450. */
  4451. /**
  4452. * Gets fired when a series is added to the chart after load time, using the
  4453. * `addSeries` method. Returning `false` prevents the series from being added.
  4454. *
  4455. * @callback Highcharts.ChartAddSeriesCallbackFunction
  4456. *
  4457. * @param {Highcharts.Chart} this
  4458. * The chart on which the event occured.
  4459. *
  4460. * @param {Highcharts.ChartAddSeriesEventObject} event
  4461. * The event that occured.
  4462. */
  4463. /**
  4464. * Contains common event information. Through the `options` property you can
  4465. * access the series options that were passed to the `addSeries` method.
  4466. *
  4467. * @interface Highcharts.ChartAddSeriesEventObject
  4468. */ /**
  4469. * The series options that were passed to the `addSeries` method.
  4470. * @name Highcharts.ChartAddSeriesEventObject#options
  4471. * @type {Highcharts.SeriesOptionsType}
  4472. */ /**
  4473. * Prevents the default behaviour of the event.
  4474. * @name Highcharts.ChartAddSeriesEventObject#preventDefault
  4475. * @type {Function}
  4476. */ /**
  4477. * The event target.
  4478. * @name Highcharts.ChartAddSeriesEventObject#target
  4479. * @type {Highcharts.Chart}
  4480. */ /**
  4481. * The event type.
  4482. * @name Highcharts.ChartAddSeriesEventObject#type
  4483. * @type {"addSeries"}
  4484. */
  4485. /**
  4486. * Gets fired when clicking on the plot background.
  4487. *
  4488. * @callback Highcharts.ChartClickCallbackFunction
  4489. *
  4490. * @param {Highcharts.Chart} this
  4491. * The chart on which the event occured.
  4492. *
  4493. * @param {Highcharts.PointerEventObject} event
  4494. * The event that occured.
  4495. */
  4496. /**
  4497. * Contains an axes of the clicked spot.
  4498. *
  4499. * @interface Highcharts.ChartClickEventAxisObject
  4500. */ /**
  4501. * Axis at the clicked spot.
  4502. * @name Highcharts.ChartClickEventAxisObject#axis
  4503. * @type {Highcharts.Axis}
  4504. */ /**
  4505. * Axis value at the clicked spot.
  4506. * @name Highcharts.ChartClickEventAxisObject#value
  4507. * @type {number}
  4508. */
  4509. /**
  4510. * Contains information about the clicked spot on the chart. Remember the unit
  4511. * of a datetime axis is milliseconds since 1970-01-01 00:00:00.
  4512. *
  4513. * @interface Highcharts.ChartClickEventObject
  4514. * @extends Highcharts.PointerEventObject
  4515. */ /**
  4516. * Information about the x-axis on the clicked spot.
  4517. * @name Highcharts.ChartClickEventObject#xAxis
  4518. * @type {Array<Highcharts.ChartClickEventAxisObject>}
  4519. */ /**
  4520. * Information about the y-axis on the clicked spot.
  4521. * @name Highcharts.ChartClickEventObject#yAxis
  4522. * @type {Array<Highcharts.ChartClickEventAxisObject>}
  4523. */ /**
  4524. * Information about the z-axis on the clicked spot.
  4525. * @name Highcharts.ChartClickEventObject#zAxis
  4526. * @type {Array<Highcharts.ChartClickEventAxisObject>|undefined}
  4527. */
  4528. /**
  4529. * Gets fired when the chart is finished loading.
  4530. *
  4531. * @callback Highcharts.ChartLoadCallbackFunction
  4532. *
  4533. * @param {Highcharts.Chart} this
  4534. * The chart on which the event occured.
  4535. *
  4536. * @param {global.Event} event
  4537. * The event that occured.
  4538. */
  4539. /**
  4540. * Fires when the chart is redrawn, either after a call to `chart.redraw()` or
  4541. * after an axis, series or point is modified with the `redraw` option set to
  4542. * `true`.
  4543. *
  4544. * @callback Highcharts.ChartRedrawCallbackFunction
  4545. *
  4546. * @param {Highcharts.Chart} this
  4547. * The chart on which the event occured.
  4548. *
  4549. * @param {global.Event} event
  4550. * The event that occured.
  4551. */
  4552. /**
  4553. * Gets fired after initial load of the chart (directly after the `load` event),
  4554. * and after each redraw (directly after the `redraw` event).
  4555. *
  4556. * @callback Highcharts.ChartRenderCallbackFunction
  4557. *
  4558. * @param {Highcharts.Chart} this
  4559. * The chart on which the event occured.
  4560. *
  4561. * @param {global.Event} event
  4562. * The event that occured.
  4563. */
  4564. /**
  4565. * Gets fired when an area of the chart has been selected. The default action
  4566. * for the selection event is to zoom the chart to the selected area. It can be
  4567. * prevented by calling `event.preventDefault()` or return false.
  4568. *
  4569. * @callback Highcharts.ChartSelectionCallbackFunction
  4570. *
  4571. * @param {Highcharts.Chart} this
  4572. * The chart on which the event occured.
  4573. *
  4574. * @param {global.ChartSelectionContextObject} event
  4575. * Event informations
  4576. *
  4577. * @return {boolean|undefined}
  4578. * Return false to prevent the default action, usually zoom.
  4579. */
  4580. /**
  4581. * The primary axes are `xAxis[0]` and `yAxis[0]`. Remember the unit of a
  4582. * datetime axis is milliseconds since 1970-01-01 00:00:00.
  4583. *
  4584. * @interface Highcharts.ChartSelectionContextObject
  4585. * @extends global.Event
  4586. */ /**
  4587. * Arrays containing the axes of each dimension and each axis' min and max
  4588. * values.
  4589. * @name Highcharts.ChartSelectionContextObject#xAxis
  4590. * @type {Array<Highcharts.ChartSelectionAxisContextObject>}
  4591. */ /**
  4592. * Arrays containing the axes of each dimension and each axis' min and max
  4593. * values.
  4594. * @name Highcharts.ChartSelectionContextObject#yAxis
  4595. * @type {Array<Highcharts.ChartSelectionAxisContextObject>}
  4596. */
  4597. /**
  4598. * Axis context of the selection.
  4599. *
  4600. * @interface Highcharts.ChartSelectionAxisContextObject
  4601. */ /**
  4602. * The selected Axis.
  4603. * @name Highcharts.ChartSelectionAxisContextObject#axis
  4604. * @type {Highcharts.Axis}
  4605. */ /**
  4606. * The maximum axis value, either automatic or set manually.
  4607. * @name Highcharts.ChartSelectionAxisContextObject#max
  4608. * @type {number}
  4609. */ /**
  4610. * The minimum axis value, either automatic or set manually.
  4611. * @name Highcharts.ChartSelectionAxisContextObject#min
  4612. * @type {number}
  4613. */
  4614. (''); // detach doclets above
  4615. /* *
  4616. *
  4617. * API Options
  4618. *
  4619. * */
  4620. /**
  4621. * Global default settings.
  4622. *
  4623. * @name Highcharts.defaultOptions
  4624. * @type {Highcharts.Options}
  4625. */ /**
  4626. * @optionparent
  4627. */
  4628. var defaultOptions = {
  4629. /**
  4630. * An array containing the default colors for the chart's series. When
  4631. * all colors are used, new colors are pulled from the start again.
  4632. *
  4633. * Default colors can also be set on a series or series.type basis,
  4634. * see [column.colors](#plotOptions.column.colors),
  4635. * [pie.colors](#plotOptions.pie.colors).
  4636. *
  4637. * In styled mode, the colors option doesn't exist. Instead, colors
  4638. * are defined in CSS and applied either through series or point class
  4639. * names, or through the [chart.colorCount](#chart.colorCount) option.
  4640. *
  4641. *
  4642. * ### Legacy
  4643. *
  4644. * In Highcharts 3.x, the default colors were:
  4645. * ```js
  4646. * colors: ['#2f7ed8', '#0d233a', '#8bbc21', '#910000', '#1aadce',
  4647. * '#492970', '#f28f43', '#77a1e5', '#c42525', '#a6c96a']
  4648. * ```
  4649. *
  4650. * In Highcharts 2.x, the default colors were:
  4651. * ```js
  4652. * colors: ['#4572A7', '#AA4643', '#89A54E', '#80699B', '#3D96AE',
  4653. * '#DB843D', '#92A8CD', '#A47D7C', '#B5CA92']
  4654. * ```
  4655. *
  4656. * @sample {highcharts} highcharts/chart/colors/
  4657. * Assign a global color theme
  4658. *
  4659. * @type {Array<Highcharts.ColorString>}
  4660. * @default ["#7cb5ec", "#434348", "#90ed7d", "#f7a35c", "#8085e9",
  4661. * "#f15c80", "#e4d354", "#2b908f", "#f45b5b", "#91e8e1"]
  4662. */
  4663. colors: palette.colors,
  4664. /**
  4665. * Styled mode only. Configuration object for adding SVG definitions for
  4666. * reusable elements. See [gradients, shadows and
  4667. * patterns](https://www.highcharts.com/docs/chart-design-and-style/gradients-shadows-and-patterns)
  4668. * for more information and code examples.
  4669. *
  4670. * @type {*}
  4671. * @since 5.0.0
  4672. * @apioption defs
  4673. */
  4674. /**
  4675. * @ignore-option
  4676. */
  4677. symbols: ['circle', 'diamond', 'square', 'triangle', 'triangle-down'],
  4678. /**
  4679. * The language object is global and it can't be set on each chart
  4680. * initialization. Instead, use `Highcharts.setOptions` to set it before any
  4681. * chart is initialized.
  4682. *
  4683. * ```js
  4684. * Highcharts.setOptions({
  4685. * lang: {
  4686. * months: [
  4687. * 'Janvier', 'Février', 'Mars', 'Avril',
  4688. * 'Mai', 'Juin', 'Juillet', 'Août',
  4689. * 'Septembre', 'Octobre', 'Novembre', 'Décembre'
  4690. * ],
  4691. * weekdays: [
  4692. * 'Dimanche', 'Lundi', 'Mardi', 'Mercredi',
  4693. * 'Jeudi', 'Vendredi', 'Samedi'
  4694. * ]
  4695. * }
  4696. * });
  4697. * ```
  4698. */
  4699. lang: {
  4700. /**
  4701. * The loading text that appears when the chart is set into the loading
  4702. * state following a call to `chart.showLoading`.
  4703. */
  4704. loading: 'Loading...',
  4705. /**
  4706. * An array containing the months names. Corresponds to the `%B` format
  4707. * in `Highcharts.dateFormat()`.
  4708. *
  4709. * @type {Array<string>}
  4710. * @default ["January", "February", "March", "April", "May", "June",
  4711. * "July", "August", "September", "October", "November",
  4712. * "December"]
  4713. */
  4714. months: [
  4715. 'January', 'February', 'March', 'April', 'May', 'June', 'July',
  4716. 'August', 'September', 'October', 'November', 'December'
  4717. ],
  4718. /**
  4719. * An array containing the months names in abbreviated form. Corresponds
  4720. * to the `%b` format in `Highcharts.dateFormat()`.
  4721. *
  4722. * @type {Array<string>}
  4723. * @default ["Jan", "Feb", "Mar", "Apr", "May", "Jun",
  4724. * "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
  4725. */
  4726. shortMonths: [
  4727. 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul',
  4728. 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'
  4729. ],
  4730. /**
  4731. * An array containing the weekday names.
  4732. *
  4733. * @type {Array<string>}
  4734. * @default ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday",
  4735. * "Friday", "Saturday"]
  4736. */
  4737. weekdays: [
  4738. 'Sunday', 'Monday', 'Tuesday', 'Wednesday',
  4739. 'Thursday', 'Friday', 'Saturday'
  4740. ],
  4741. /**
  4742. * Short week days, starting Sunday. If not specified, Highcharts uses
  4743. * the first three letters of the `lang.weekdays` option.
  4744. *
  4745. * @sample highcharts/lang/shortweekdays/
  4746. * Finnish two-letter abbreviations
  4747. *
  4748. * @type {Array<string>}
  4749. * @since 4.2.4
  4750. * @apioption lang.shortWeekdays
  4751. */
  4752. /**
  4753. * What to show in a date field for invalid dates. Defaults to an empty
  4754. * string.
  4755. *
  4756. * @type {string}
  4757. * @since 4.1.8
  4758. * @product highcharts highstock
  4759. * @apioption lang.invalidDate
  4760. */
  4761. /**
  4762. * The title appearing on hovering the zoom in button. The text itself
  4763. * defaults to "+" and can be changed in the button options.
  4764. *
  4765. * @type {string}
  4766. * @default Zoom in
  4767. * @product highmaps
  4768. * @apioption lang.zoomIn
  4769. */
  4770. /**
  4771. * The title appearing on hovering the zoom out button. The text itself
  4772. * defaults to "-" and can be changed in the button options.
  4773. *
  4774. * @type {string}
  4775. * @default Zoom out
  4776. * @product highmaps
  4777. * @apioption lang.zoomOut
  4778. */
  4779. /**
  4780. * The default decimal point used in the `Highcharts.numberFormat`
  4781. * method unless otherwise specified in the function arguments.
  4782. *
  4783. * @since 1.2.2
  4784. */
  4785. decimalPoint: '.',
  4786. /**
  4787. * [Metric prefixes](https://en.wikipedia.org/wiki/Metric_prefix) used
  4788. * to shorten high numbers in axis labels. Replacing any of the
  4789. * positions with `null` causes the full number to be written. Setting
  4790. * `numericSymbols` to `null` disables shortening altogether.
  4791. *
  4792. * @sample {highcharts} highcharts/lang/numericsymbols/
  4793. * Replacing the symbols with text
  4794. * @sample {highstock} highcharts/lang/numericsymbols/
  4795. * Replacing the symbols with text
  4796. *
  4797. * @type {Array<string>}
  4798. * @default ["k", "M", "G", "T", "P", "E"]
  4799. * @since 2.3.0
  4800. */
  4801. numericSymbols: ['k', 'M', 'G', 'T', 'P', 'E'],
  4802. /**
  4803. * The magnitude of [numericSymbols](#lang.numericSymbol) replacements.
  4804. * Use 10000 for Japanese, Korean and various Chinese locales, which
  4805. * use symbols for 10^4, 10^8 and 10^12.
  4806. *
  4807. * @sample highcharts/lang/numericsymbolmagnitude/
  4808. * 10000 magnitude for Japanese
  4809. *
  4810. * @type {number}
  4811. * @default 1000
  4812. * @since 5.0.3
  4813. * @apioption lang.numericSymbolMagnitude
  4814. */
  4815. /**
  4816. * The text for the label appearing when a chart is zoomed.
  4817. *
  4818. * @since 1.2.4
  4819. */
  4820. resetZoom: 'Reset zoom',
  4821. /**
  4822. * The tooltip title for the label appearing when a chart is zoomed.
  4823. *
  4824. * @since 1.2.4
  4825. */
  4826. resetZoomTitle: 'Reset zoom level 1:1',
  4827. /**
  4828. * The default thousands separator used in the `Highcharts.numberFormat`
  4829. * method unless otherwise specified in the function arguments. Defaults
  4830. * to a single space character, which is recommended in
  4831. * [ISO 31-0](https://en.wikipedia.org/wiki/ISO_31-0#Numbers) and works
  4832. * across Anglo-American and continental European languages.
  4833. *
  4834. * @default \u0020
  4835. * @since 1.2.2
  4836. */
  4837. thousandsSep: ' '
  4838. },
  4839. /**
  4840. * Global options that don't apply to each chart. These options, like
  4841. * the `lang` options, must be set using the `Highcharts.setOptions`
  4842. * method.
  4843. *
  4844. * ```js
  4845. * Highcharts.setOptions({
  4846. * global: {
  4847. * useUTC: false
  4848. * }
  4849. * });
  4850. * ```
  4851. */
  4852. /**
  4853. * _Canvg rendering for Android 2.x is removed as of Highcharts 5.0\.
  4854. * Use the [libURL](#exporting.libURL) option to configure exporting._
  4855. *
  4856. * The URL to the additional file to lazy load for Android 2.x devices.
  4857. * These devices don't support SVG, so we download a helper file that
  4858. * contains [canvg](https://github.com/canvg/canvg), its dependency
  4859. * rbcolor, and our own CanVG Renderer class. To avoid hotlinking to
  4860. * our site, you can install canvas-tools.js on your own server and
  4861. * change this option accordingly.
  4862. *
  4863. * @deprecated
  4864. *
  4865. * @type {string}
  4866. * @default https://code.highcharts.com/{version}/modules/canvas-tools.js
  4867. * @product highcharts highmaps
  4868. * @apioption global.canvasToolsURL
  4869. */
  4870. /**
  4871. * This option is deprecated since v6.0.5. Instead, use
  4872. * [time.useUTC](#time.useUTC) that supports individual time settings
  4873. * per chart.
  4874. *
  4875. * @deprecated
  4876. *
  4877. * @type {boolean}
  4878. * @apioption global.useUTC
  4879. */
  4880. /**
  4881. * This option is deprecated since v6.0.5. Instead, use
  4882. * [time.Date](#time.Date) that supports individual time settings
  4883. * per chart.
  4884. *
  4885. * @deprecated
  4886. *
  4887. * @type {Function}
  4888. * @product highcharts highstock
  4889. * @apioption global.Date
  4890. */
  4891. /**
  4892. * This option is deprecated since v6.0.5. Instead, use
  4893. * [time.getTimezoneOffset](#time.getTimezoneOffset) that supports
  4894. * individual time settings per chart.
  4895. *
  4896. * @deprecated
  4897. *
  4898. * @type {Function}
  4899. * @product highcharts highstock
  4900. * @apioption global.getTimezoneOffset
  4901. */
  4902. /**
  4903. * This option is deprecated since v6.0.5. Instead, use
  4904. * [time.timezone](#time.timezone) that supports individual time
  4905. * settings per chart.
  4906. *
  4907. * @deprecated
  4908. *
  4909. * @type {string}
  4910. * @product highcharts highstock
  4911. * @apioption global.timezone
  4912. */
  4913. /**
  4914. * This option is deprecated since v6.0.5. Instead, use
  4915. * [time.timezoneOffset](#time.timezoneOffset) that supports individual
  4916. * time settings per chart.
  4917. *
  4918. * @deprecated
  4919. *
  4920. * @type {number}
  4921. * @product highcharts highstock
  4922. * @apioption global.timezoneOffset
  4923. */
  4924. global: {},
  4925. /**
  4926. * Time options that can apply globally or to individual charts. These
  4927. * settings affect how `datetime` axes are laid out, how tooltips are
  4928. * formatted, how series
  4929. * [pointIntervalUnit](#plotOptions.series.pointIntervalUnit) works and how
  4930. * the Highcharts Stock range selector handles time.
  4931. *
  4932. * The common use case is that all charts in the same Highcharts object
  4933. * share the same time settings, in which case the global settings are set
  4934. * using `setOptions`.
  4935. *
  4936. * ```js
  4937. * // Apply time settings globally
  4938. * Highcharts.setOptions({
  4939. * time: {
  4940. * timezone: 'Europe/London'
  4941. * }
  4942. * });
  4943. * // Apply time settings by instance
  4944. * let chart = Highcharts.chart('container', {
  4945. * time: {
  4946. * timezone: 'America/New_York'
  4947. * },
  4948. * series: [{
  4949. * data: [1, 4, 3, 5]
  4950. * }]
  4951. * });
  4952. *
  4953. * // Use the Time object
  4954. * console.log(
  4955. * 'Current time in New York',
  4956. * chart.time.dateFormat('%Y-%m-%d %H:%M:%S', Date.now())
  4957. * );
  4958. * ```
  4959. *
  4960. * Since v6.0.5, the time options were moved from the `global` obect to the
  4961. * `time` object, and time options can be set on each individual chart.
  4962. *
  4963. * @sample {highcharts|highstock}
  4964. * highcharts/time/timezone/
  4965. * Set the timezone globally
  4966. * @sample {highcharts}
  4967. * highcharts/time/individual/
  4968. * Set the timezone per chart instance
  4969. * @sample {highstock}
  4970. * stock/time/individual/
  4971. * Set the timezone per chart instance
  4972. *
  4973. * @since 6.0.5
  4974. * @optionparent time
  4975. */
  4976. time: {
  4977. /**
  4978. * A custom `Date` class for advanced date handling. For example,
  4979. * [JDate](https://github.com/tahajahangir/jdate) can be hooked in to
  4980. * handle Jalali dates.
  4981. *
  4982. * @type {*}
  4983. * @since 4.0.4
  4984. * @product highcharts highstock gantt
  4985. */
  4986. Date: void 0,
  4987. /**
  4988. * A callback to return the time zone offset for a given datetime. It
  4989. * takes the timestamp in terms of milliseconds since January 1 1970,
  4990. * and returns the timezone offset in minutes. This provides a hook
  4991. * for drawing time based charts in specific time zones using their
  4992. * local DST crossover dates, with the help of external libraries.
  4993. *
  4994. * @see [global.timezoneOffset](#global.timezoneOffset)
  4995. *
  4996. * @sample {highcharts|highstock} highcharts/time/gettimezoneoffset/
  4997. * Use moment.js to draw Oslo time regardless of browser locale
  4998. *
  4999. * @type {Highcharts.TimezoneOffsetCallbackFunction}
  5000. * @since 4.1.0
  5001. * @product highcharts highstock gantt
  5002. */
  5003. getTimezoneOffset: void 0,
  5004. /**
  5005. * Requires [moment.js](https://momentjs.com/). If the timezone option
  5006. * is specified, it creates a default
  5007. * [getTimezoneOffset](#time.getTimezoneOffset) function that looks
  5008. * up the specified timezone in moment.js. If moment.js is not included,
  5009. * this throws a Highcharts error in the console, but does not crash the
  5010. * chart.
  5011. *
  5012. * @see [getTimezoneOffset](#time.getTimezoneOffset)
  5013. *
  5014. * @sample {highcharts|highstock} highcharts/time/timezone/
  5015. * Europe/Oslo
  5016. *
  5017. * @type {string}
  5018. * @since 5.0.7
  5019. * @product highcharts highstock gantt
  5020. */
  5021. timezone: void 0,
  5022. /**
  5023. * The timezone offset in minutes. Positive values are west, negative
  5024. * values are east of UTC, as in the ECMAScript
  5025. * [getTimezoneOffset](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/getTimezoneOffset)
  5026. * method. Use this to display UTC based data in a predefined time zone.
  5027. *
  5028. * @see [time.getTimezoneOffset](#time.getTimezoneOffset)
  5029. *
  5030. * @sample {highcharts|highstock} highcharts/time/timezoneoffset/
  5031. * Timezone offset
  5032. *
  5033. * @since 3.0.8
  5034. * @product highcharts highstock gantt
  5035. */
  5036. timezoneOffset: 0,
  5037. /**
  5038. * Whether to use UTC time for axis scaling, tickmark placement and
  5039. * time display in `Highcharts.dateFormat`. Advantages of using UTC
  5040. * is that the time displays equally regardless of the user agent's
  5041. * time zone settings. Local time can be used when the data is loaded
  5042. * in real time or when correct Daylight Saving Time transitions are
  5043. * required.
  5044. *
  5045. * @sample {highcharts} highcharts/time/useutc-true/
  5046. * True by default
  5047. * @sample {highcharts} highcharts/time/useutc-false/
  5048. * False
  5049. */
  5050. useUTC: true
  5051. },
  5052. chart: ChartDefaults,
  5053. /**
  5054. * The chart's main title.
  5055. *
  5056. * @sample {highmaps} maps/title/title/
  5057. * Title options demonstrated
  5058. */
  5059. title: {
  5060. /**
  5061. * When the title is floating, the plot area will not move to make space
  5062. * for it.
  5063. *
  5064. * @sample {highcharts} highcharts/chart/zoomtype-none/
  5065. * False by default
  5066. * @sample {highcharts} highcharts/title/floating/
  5067. * True - title on top of the plot area
  5068. * @sample {highstock} stock/chart/title-floating/
  5069. * True - title on top of the plot area
  5070. *
  5071. * @type {boolean}
  5072. * @default false
  5073. * @since 2.1
  5074. * @apioption title.floating
  5075. */
  5076. /**
  5077. * CSS styles for the title. Use this for font styling, but use `align`,
  5078. * `x` and `y` for text alignment.
  5079. *
  5080. * In styled mode, the title style is given in the `.highcharts-title`
  5081. * class.
  5082. *
  5083. * @sample {highcharts} highcharts/title/style/
  5084. * Custom color and weight
  5085. * @sample {highstock} stock/chart/title-style/
  5086. * Custom color and weight
  5087. * @sample highcharts/css/titles/
  5088. * Styled mode
  5089. *
  5090. * @type {Highcharts.CSSObject}
  5091. * @default {highcharts|highmaps} { "color": "#333333", "fontSize": "18px" }
  5092. * @default {highstock} { "color": "#333333", "fontSize": "16px" }
  5093. * @apioption title.style
  5094. */
  5095. /**
  5096. * Whether to
  5097. * [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  5098. * to render the text.
  5099. *
  5100. * @type {boolean}
  5101. * @default false
  5102. * @apioption title.useHTML
  5103. */
  5104. /**
  5105. * The vertical alignment of the title. Can be one of `"top"`,
  5106. * `"middle"` and `"bottom"`. When a value is given, the title behaves
  5107. * as if [floating](#title.floating) were `true`.
  5108. *
  5109. * @sample {highcharts} highcharts/title/verticalalign/
  5110. * Chart title in bottom right corner
  5111. * @sample {highstock} stock/chart/title-verticalalign/
  5112. * Chart title in bottom right corner
  5113. *
  5114. * @type {Highcharts.VerticalAlignValue}
  5115. * @since 2.1
  5116. * @apioption title.verticalAlign
  5117. */
  5118. /**
  5119. * The x position of the title relative to the alignment within
  5120. * `chart.spacingLeft` and `chart.spacingRight`.
  5121. *
  5122. * @sample {highcharts} highcharts/title/align/
  5123. * Aligned to the plot area (x = 70px = margin left - spacing
  5124. * left)
  5125. * @sample {highstock} stock/chart/title-align/
  5126. * Aligned to the plot area (x = 50px = margin left - spacing
  5127. * left)
  5128. *
  5129. * @type {number}
  5130. * @default 0
  5131. * @since 2.0
  5132. * @apioption title.x
  5133. */
  5134. /**
  5135. * The y position of the title relative to the alignment within
  5136. * [chart.spacingTop](#chart.spacingTop) and [chart.spacingBottom](
  5137. * #chart.spacingBottom). By default it depends on the font size.
  5138. *
  5139. * @sample {highcharts} highcharts/title/y/
  5140. * Title inside the plot area
  5141. * @sample {highstock} stock/chart/title-verticalalign/
  5142. * Chart title in bottom right corner
  5143. *
  5144. * @type {number}
  5145. * @since 2.0
  5146. * @apioption title.y
  5147. */
  5148. /**
  5149. * The title of the chart. To disable the title, set the `text` to
  5150. * `undefined`.
  5151. *
  5152. * @sample {highcharts} highcharts/title/text/
  5153. * Custom title
  5154. * @sample {highstock} stock/chart/title-text/
  5155. * Custom title
  5156. *
  5157. * @default {highcharts|highmaps} Chart title
  5158. * @default {highstock} undefined
  5159. */
  5160. text: 'Chart title',
  5161. /**
  5162. * The horizontal alignment of the title. Can be one of "left", "center"
  5163. * and "right".
  5164. *
  5165. * @sample {highcharts} highcharts/title/align/
  5166. * Aligned to the plot area (x = 70px = margin left - spacing
  5167. * left)
  5168. * @sample {highstock} stock/chart/title-align/
  5169. * Aligned to the plot area (x = 50px = margin left - spacing
  5170. * left)
  5171. *
  5172. * @type {Highcharts.AlignValue}
  5173. * @since 2.0
  5174. */
  5175. align: 'center',
  5176. /**
  5177. * The margin between the title and the plot area, or if a subtitle
  5178. * is present, the margin between the subtitle and the plot area.
  5179. *
  5180. * @sample {highcharts} highcharts/title/margin-50/
  5181. * A chart title margin of 50
  5182. * @sample {highcharts} highcharts/title/margin-subtitle/
  5183. * The same margin applied with a subtitle
  5184. * @sample {highstock} stock/chart/title-margin/
  5185. * A chart title margin of 50
  5186. *
  5187. * @since 2.1
  5188. */
  5189. margin: 15,
  5190. /**
  5191. * Adjustment made to the title width, normally to reserve space for
  5192. * the exporting burger menu.
  5193. *
  5194. * @sample highcharts/title/widthadjust/
  5195. * Wider menu, greater padding
  5196. *
  5197. * @since 4.2.5
  5198. */
  5199. widthAdjust: -44
  5200. },
  5201. /**
  5202. * The chart's subtitle. This can be used both to display a subtitle below
  5203. * the main title, and to display random text anywhere in the chart. The
  5204. * subtitle can be updated after chart initialization through the
  5205. * `Chart.setTitle` method.
  5206. *
  5207. * @sample {highmaps} maps/title/subtitle/
  5208. * Subtitle options demonstrated
  5209. */
  5210. subtitle: {
  5211. /**
  5212. * When the subtitle is floating, the plot area will not move to make
  5213. * space for it.
  5214. *
  5215. * @sample {highcharts} highcharts/subtitle/floating/
  5216. * Floating title and subtitle
  5217. * @sample {highstock} stock/chart/subtitle-footnote
  5218. * Footnote floating at bottom right of plot area
  5219. *
  5220. * @type {boolean}
  5221. * @default false
  5222. * @since 2.1
  5223. * @apioption subtitle.floating
  5224. */
  5225. /**
  5226. * CSS styles for the title.
  5227. *
  5228. * In styled mode, the subtitle style is given in the
  5229. * `.highcharts-subtitle` class.
  5230. *
  5231. * @sample {highcharts} highcharts/subtitle/style/
  5232. * Custom color and weight
  5233. * @sample {highcharts} highcharts/css/titles/
  5234. * Styled mode
  5235. * @sample {highstock} stock/chart/subtitle-style
  5236. * Custom color and weight
  5237. * @sample {highstock} highcharts/css/titles/
  5238. * Styled mode
  5239. * @sample {highmaps} highcharts/css/titles/
  5240. * Styled mode
  5241. *
  5242. * @type {Highcharts.CSSObject}
  5243. * @default {"color": "#666666"}
  5244. * @apioption subtitle.style
  5245. */
  5246. /**
  5247. * Whether to
  5248. * [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  5249. * to render the text.
  5250. *
  5251. * @type {boolean}
  5252. * @default false
  5253. * @apioption subtitle.useHTML
  5254. */
  5255. /**
  5256. * The vertical alignment of the title. Can be one of `"top"`,
  5257. * `"middle"` and `"bottom"`. When middle, the subtitle behaves as
  5258. * floating.
  5259. *
  5260. * @sample {highcharts} highcharts/subtitle/verticalalign/
  5261. * Footnote at the bottom right of plot area
  5262. * @sample {highstock} stock/chart/subtitle-footnote
  5263. * Footnote at the bottom right of plot area
  5264. *
  5265. * @type {Highcharts.VerticalAlignValue}
  5266. * @since 2.1
  5267. * @apioption subtitle.verticalAlign
  5268. */
  5269. /**
  5270. * The x position of the subtitle relative to the alignment within
  5271. * `chart.spacingLeft` and `chart.spacingRight`.
  5272. *
  5273. * @sample {highcharts} highcharts/subtitle/align/
  5274. * Footnote at right of plot area
  5275. * @sample {highstock} stock/chart/subtitle-footnote
  5276. * Footnote at the bottom right of plot area
  5277. *
  5278. * @type {number}
  5279. * @default 0
  5280. * @since 2.0
  5281. * @apioption subtitle.x
  5282. */
  5283. /**
  5284. * The y position of the subtitle relative to the alignment within
  5285. * `chart.spacingTop` and `chart.spacingBottom`. By default the subtitle
  5286. * is laid out below the title unless the title is floating.
  5287. *
  5288. * @sample {highcharts} highcharts/subtitle/verticalalign/
  5289. * Footnote at the bottom right of plot area
  5290. * @sample {highstock} stock/chart/subtitle-footnote
  5291. * Footnote at the bottom right of plot area
  5292. *
  5293. * @type {number}
  5294. * @since 2.0
  5295. * @apioption subtitle.y
  5296. */
  5297. /**
  5298. * The subtitle of the chart.
  5299. *
  5300. * @sample {highcharts|highstock} highcharts/subtitle/text/
  5301. * Custom subtitle
  5302. * @sample {highcharts|highstock} highcharts/subtitle/text-formatted/
  5303. * Formatted and linked text.
  5304. */
  5305. text: '',
  5306. /**
  5307. * The horizontal alignment of the subtitle. Can be one of "left",
  5308. * "center" and "right".
  5309. *
  5310. * @sample {highcharts} highcharts/subtitle/align/
  5311. * Footnote at right of plot area
  5312. * @sample {highstock} stock/chart/subtitle-footnote
  5313. * Footnote at bottom right of plot area
  5314. *
  5315. * @type {Highcharts.AlignValue}
  5316. * @since 2.0
  5317. */
  5318. align: 'center',
  5319. /**
  5320. * Adjustment made to the subtitle width, normally to reserve space
  5321. * for the exporting burger menu.
  5322. *
  5323. * @see [title.widthAdjust](#title.widthAdjust)
  5324. *
  5325. * @sample highcharts/title/widthadjust/
  5326. * Wider menu, greater padding
  5327. *
  5328. * @since 4.2.5
  5329. */
  5330. widthAdjust: -44
  5331. },
  5332. /**
  5333. * The chart's caption, which will render below the chart and will be part
  5334. * of exported charts. The caption can be updated after chart initialization
  5335. * through the `Chart.update` or `Chart.caption.update` methods.
  5336. *
  5337. * @sample highcharts/caption/text/
  5338. * A chart with a caption
  5339. * @since 7.2.0
  5340. */
  5341. caption: {
  5342. /**
  5343. * When the caption is floating, the plot area will not move to make
  5344. * space for it.
  5345. *
  5346. * @type {boolean}
  5347. * @default false
  5348. * @apioption caption.floating
  5349. */
  5350. /**
  5351. * The margin between the caption and the plot area.
  5352. */
  5353. margin: 15,
  5354. /**
  5355. * CSS styles for the caption.
  5356. *
  5357. * In styled mode, the caption style is given in the
  5358. * `.highcharts-caption` class.
  5359. *
  5360. * @sample {highcharts} highcharts/css/titles/
  5361. * Styled mode
  5362. *
  5363. * @type {Highcharts.CSSObject}
  5364. * @default {"color": "#666666"}
  5365. * @apioption caption.style
  5366. */
  5367. /**
  5368. * Whether to
  5369. * [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  5370. * to render the text.
  5371. *
  5372. * @type {boolean}
  5373. * @default false
  5374. * @apioption caption.useHTML
  5375. */
  5376. /**
  5377. * The x position of the caption relative to the alignment within
  5378. * `chart.spacingLeft` and `chart.spacingRight`.
  5379. *
  5380. * @type {number}
  5381. * @default 0
  5382. * @apioption caption.x
  5383. */
  5384. /**
  5385. * The y position of the caption relative to the alignment within
  5386. * `chart.spacingTop` and `chart.spacingBottom`.
  5387. *
  5388. * @type {number}
  5389. * @apioption caption.y
  5390. */
  5391. /**
  5392. * The caption text of the chart.
  5393. *
  5394. * @sample {highcharts} highcharts/caption/text/
  5395. * Custom caption
  5396. */
  5397. text: '',
  5398. /**
  5399. * The horizontal alignment of the caption. Can be one of "left",
  5400. * "center" and "right".
  5401. *
  5402. * @type {Highcharts.AlignValue}
  5403. */
  5404. align: 'left',
  5405. /**
  5406. * The vertical alignment of the caption. Can be one of `"top"`,
  5407. * `"middle"` and `"bottom"`. When middle, the caption behaves as
  5408. * floating.
  5409. *
  5410. * @type {Highcharts.VerticalAlignValue}
  5411. */
  5412. verticalAlign: 'bottom'
  5413. },
  5414. /**
  5415. * The plotOptions is a wrapper object for config objects for each series
  5416. * type. The config objects for each series can also be overridden for
  5417. * each series item as given in the series array.
  5418. *
  5419. * Configuration options for the series are given in three levels. Options
  5420. * for all series in a chart are given in the [plotOptions.series](
  5421. * #plotOptions.series) object. Then options for all series of a specific
  5422. * type are given in the plotOptions of that type, for example
  5423. * `plotOptions.line`. Next, options for one single series are given in
  5424. * [the series array](#series).
  5425. */
  5426. plotOptions: {},
  5427. /**
  5428. * HTML labels that can be positioned anywhere in the chart area.
  5429. *
  5430. * This option is deprecated since v7.1.2. Instead, use
  5431. * [annotations](#annotations) that support labels.
  5432. *
  5433. * @deprecated
  5434. * @product highcharts highstock
  5435. */
  5436. labels: {
  5437. /**
  5438. * An HTML label that can be positioned anywhere in the chart area.
  5439. *
  5440. * @deprecated
  5441. * @type {Array<*>}
  5442. * @apioption labels.items
  5443. */
  5444. /**
  5445. * Inner HTML or text for the label.
  5446. *
  5447. * @deprecated
  5448. * @type {string}
  5449. * @apioption labels.items.html
  5450. */
  5451. /**
  5452. * CSS styles for each label. To position the label, use left and top
  5453. * like this:
  5454. * ```js
  5455. * style: {
  5456. * left: '100px',
  5457. * top: '100px'
  5458. * }
  5459. * ```
  5460. *
  5461. * @deprecated
  5462. * @type {Highcharts.CSSObject}
  5463. * @apioption labels.items.style
  5464. */
  5465. /**
  5466. * Shared CSS styles for all labels.
  5467. *
  5468. * @deprecated
  5469. * @type {Highcharts.CSSObject}
  5470. * @default {"color": "#333333", "position": "absolute"}
  5471. */
  5472. style: {
  5473. /**
  5474. * @ignore-option
  5475. */
  5476. position: 'absolute',
  5477. /**
  5478. * @ignore-option
  5479. */
  5480. color: palette.neutralColor80
  5481. }
  5482. },
  5483. /**
  5484. * The legend is a box containing a symbol and name for each series
  5485. * item or point item in the chart. Each series (or points in case
  5486. * of pie charts) is represented by a symbol and its name in the legend.
  5487. *
  5488. * It is possible to override the symbol creator function and create
  5489. * [custom legend symbols](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/studies/legend-custom-symbol/).
  5490. *
  5491. * @productdesc {highmaps}
  5492. * A Highmaps legend by default contains one legend item per series, but if
  5493. * a `colorAxis` is defined, the axis will be displayed in the legend.
  5494. * Either as a gradient, or as multiple legend items for `dataClasses`.
  5495. */
  5496. legend: {
  5497. /**
  5498. * The background color of the legend.
  5499. *
  5500. * @see In styled mode, the legend background fill can be applied with
  5501. * the `.highcharts-legend-box` class.
  5502. *
  5503. * @sample {highcharts} highcharts/legend/backgroundcolor/
  5504. * Yellowish background
  5505. * @sample {highstock} stock/legend/align/
  5506. * Various legend options
  5507. * @sample {highmaps} maps/legend/border-background/
  5508. * Border and background options
  5509. *
  5510. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  5511. * @apioption legend.backgroundColor
  5512. */
  5513. /**
  5514. * The width of the drawn border around the legend.
  5515. *
  5516. * @see In styled mode, the legend border stroke width can be applied
  5517. * with the `.highcharts-legend-box` class.
  5518. *
  5519. * @sample {highcharts} highcharts/legend/borderwidth/
  5520. * 2px border width
  5521. * @sample {highstock} stock/legend/align/
  5522. * Various legend options
  5523. * @sample {highmaps} maps/legend/border-background/
  5524. * Border and background options
  5525. *
  5526. * @type {number}
  5527. * @default 0
  5528. * @apioption legend.borderWidth
  5529. */
  5530. /**
  5531. * Enable or disable the legend. There is also a series-specific option,
  5532. * [showInLegend](#plotOptions.series.showInLegend), that can hide the
  5533. * series from the legend. In some series types this is `false` by
  5534. * default, so it must set to `true` in order to show the legend for the
  5535. * series.
  5536. *
  5537. * @sample {highcharts} highcharts/legend/enabled-false/ Legend disabled
  5538. * @sample {highstock} stock/legend/align/ Various legend options
  5539. * @sample {highmaps} maps/legend/enabled-false/ Legend disabled
  5540. *
  5541. * @default {highstock} false
  5542. * @default {highmaps} true
  5543. * @default {gantt} false
  5544. */
  5545. enabled: true,
  5546. /**
  5547. * The horizontal alignment of the legend box within the chart area.
  5548. * Valid values are `left`, `center` and `right`.
  5549. *
  5550. * In the case that the legend is aligned in a corner position, the
  5551. * `layout` option will determine whether to place it above/below
  5552. * or on the side of the plot area.
  5553. *
  5554. * @sample {highcharts} highcharts/legend/align/
  5555. * Legend at the right of the chart
  5556. * @sample {highstock} stock/legend/align/
  5557. * Various legend options
  5558. * @sample {highmaps} maps/legend/alignment/
  5559. * Legend alignment
  5560. *
  5561. * @type {Highcharts.AlignValue}
  5562. * @since 2.0
  5563. */
  5564. align: 'center',
  5565. /**
  5566. * If the [layout](legend.layout) is `horizontal` and the legend items
  5567. * span over two lines or more, whether to align the items into vertical
  5568. * columns. Setting this to `false` makes room for more items, but will
  5569. * look more messy.
  5570. *
  5571. * @since 6.1.0
  5572. */
  5573. alignColumns: true,
  5574. /**
  5575. * A CSS class name to apply to the legend group.
  5576. */
  5577. className: 'highcharts-no-tooltip',
  5578. /**
  5579. * When the legend is floating, the plot area ignores it and is allowed
  5580. * to be placed below it.
  5581. *
  5582. * @sample {highcharts} highcharts/legend/floating-false/
  5583. * False by default
  5584. * @sample {highcharts} highcharts/legend/floating-true/
  5585. * True
  5586. * @sample {highmaps} maps/legend/alignment/
  5587. * Floating legend
  5588. *
  5589. * @type {boolean}
  5590. * @default false
  5591. * @since 2.1
  5592. * @apioption legend.floating
  5593. */
  5594. /**
  5595. * The layout of the legend items. Can be one of `horizontal` or
  5596. * `vertical` or `proximate`. When `proximate`, the legend items will be
  5597. * placed as close as possible to the graphs they're representing,
  5598. * except in inverted charts or when the legend position doesn't allow
  5599. * it.
  5600. *
  5601. * @sample {highcharts} highcharts/legend/layout-horizontal/
  5602. * Horizontal by default
  5603. * @sample {highcharts} highcharts/legend/layout-vertical/
  5604. * Vertical
  5605. * @sample highcharts/legend/layout-proximate
  5606. * Labels proximate to the data
  5607. * @sample {highstock} stock/legend/layout-horizontal/
  5608. * Horizontal by default
  5609. * @sample {highmaps} maps/legend/padding-itemmargin/
  5610. * Vertical with data classes
  5611. * @sample {highmaps} maps/legend/layout-vertical/
  5612. * Vertical with color axis gradient
  5613. *
  5614. * @validvalue ["horizontal", "vertical", "proximate"]
  5615. */
  5616. layout: 'horizontal',
  5617. /**
  5618. * In a legend with horizontal layout, the itemDistance defines the
  5619. * pixel distance between each item.
  5620. *
  5621. * @sample {highcharts} highcharts/legend/layout-horizontal/
  5622. * 50px item distance
  5623. * @sample {highstock} highcharts/legend/layout-horizontal/
  5624. * 50px item distance
  5625. *
  5626. * @type {number}
  5627. * @default {highcharts} 20
  5628. * @default {highstock} 20
  5629. * @default {highmaps} 8
  5630. * @since 3.0.3
  5631. * @apioption legend.itemDistance
  5632. */
  5633. /**
  5634. * The pixel bottom margin for each legend item.
  5635. *
  5636. * @sample {highcharts|highstock} highcharts/legend/padding-itemmargin/
  5637. * Padding and item margins demonstrated
  5638. * @sample {highmaps} maps/legend/padding-itemmargin/
  5639. * Padding and item margins demonstrated
  5640. *
  5641. * @type {number}
  5642. * @default 0
  5643. * @since 2.2.0
  5644. * @apioption legend.itemMarginBottom
  5645. */
  5646. /**
  5647. * The pixel top margin for each legend item.
  5648. *
  5649. * @sample {highcharts|highstock} highcharts/legend/padding-itemmargin/
  5650. * Padding and item margins demonstrated
  5651. * @sample {highmaps} maps/legend/padding-itemmargin/
  5652. * Padding and item margins demonstrated
  5653. *
  5654. * @type {number}
  5655. * @default 0
  5656. * @since 2.2.0
  5657. * @apioption legend.itemMarginTop
  5658. */
  5659. /**
  5660. * The width for each legend item. By default the items are laid out
  5661. * successively. In a [horizontal layout](legend.layout), if the items
  5662. * are laid out across two rows or more, they will be vertically aligned
  5663. * depending on the [legend.alignColumns](legend.alignColumns) option.
  5664. *
  5665. * @sample {highcharts} highcharts/legend/itemwidth-default/
  5666. * Undefined by default
  5667. * @sample {highcharts} highcharts/legend/itemwidth-80/
  5668. * 80 for aligned legend items
  5669. *
  5670. * @type {number}
  5671. * @since 2.0
  5672. * @apioption legend.itemWidth
  5673. */
  5674. /**
  5675. * A [format string](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting)
  5676. * for each legend label. Available variables relates to properties on
  5677. * the series, or the point in case of pies.
  5678. *
  5679. * @type {string}
  5680. * @default {name}
  5681. * @since 1.3
  5682. * @apioption legend.labelFormat
  5683. */
  5684. /* eslint-disable valid-jsdoc */
  5685. /**
  5686. * Callback function to format each of the series' labels. The `this`
  5687. * keyword refers to the series object, or the point object in case of
  5688. * pie charts. By default the series or point name is printed.
  5689. *
  5690. * @productdesc {highmaps}
  5691. * In Highmaps the context can also be a data class in case of a
  5692. * `colorAxis`.
  5693. *
  5694. * @sample {highcharts} highcharts/legend/labelformatter/
  5695. * Add text
  5696. * @sample {highmaps} maps/legend/labelformatter/
  5697. * Data classes with label formatter
  5698. *
  5699. * @type {Highcharts.FormatterCallbackFunction<Point|Series>}
  5700. */
  5701. labelFormatter: function () {
  5702. /** eslint-enable valid-jsdoc */
  5703. return this.name;
  5704. },
  5705. /**
  5706. * Line height for the legend items. Deprecated as of 2.1\. Instead,
  5707. * the line height for each item can be set using
  5708. * `itemStyle.lineHeight`, and the padding between items using
  5709. * `itemMarginTop` and `itemMarginBottom`.
  5710. *
  5711. * @sample {highcharts} highcharts/legend/lineheight/
  5712. * Setting padding
  5713. *
  5714. * @deprecated
  5715. *
  5716. * @type {number}
  5717. * @default 16
  5718. * @since 2.0
  5719. * @product highcharts gantt
  5720. * @apioption legend.lineHeight
  5721. */
  5722. /**
  5723. * If the plot area sized is calculated automatically and the legend is
  5724. * not floating, the legend margin is the space between the legend and
  5725. * the axis labels or plot area.
  5726. *
  5727. * @sample {highcharts} highcharts/legend/margin-default/
  5728. * 12 pixels by default
  5729. * @sample {highcharts} highcharts/legend/margin-30/
  5730. * 30 pixels
  5731. *
  5732. * @type {number}
  5733. * @default 12
  5734. * @since 2.1
  5735. * @apioption legend.margin
  5736. */
  5737. /**
  5738. * Maximum pixel height for the legend. When the maximum height is
  5739. * extended, navigation will show.
  5740. *
  5741. * @type {number}
  5742. * @since 2.3.0
  5743. * @apioption legend.maxHeight
  5744. */
  5745. /**
  5746. * The color of the drawn border around the legend.
  5747. *
  5748. * @see In styled mode, the legend border stroke can be applied with the
  5749. * `.highcharts-legend-box` class.
  5750. *
  5751. * @sample {highcharts} highcharts/legend/bordercolor/
  5752. * Brown border
  5753. * @sample {highstock} stock/legend/align/
  5754. * Various legend options
  5755. * @sample {highmaps} maps/legend/border-background/
  5756. * Border and background options
  5757. *
  5758. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  5759. */
  5760. borderColor: palette.neutralColor40,
  5761. /**
  5762. * The border corner radius of the legend.
  5763. *
  5764. * @sample {highcharts} highcharts/legend/borderradius-default/
  5765. * Square by default
  5766. * @sample {highcharts} highcharts/legend/borderradius-round/
  5767. * 5px rounded
  5768. * @sample {highmaps} maps/legend/border-background/
  5769. * Border and background options
  5770. */
  5771. borderRadius: 0,
  5772. /**
  5773. * Options for the paging or navigation appearing when the legend is
  5774. * overflown. Navigation works well on screen, but not in static
  5775. * exported images. One way of working around that is to
  5776. * [increase the chart height in
  5777. * export](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/legend/navigation-enabled-false/).
  5778. */
  5779. navigation: {
  5780. /**
  5781. * How to animate the pages when navigating up or down. A value of
  5782. * `true` applies the default navigation given in the
  5783. * `chart.animation` option. Additional options can be given as an
  5784. * object containing values for easing and duration.
  5785. *
  5786. * @sample {highcharts} highcharts/legend/navigation/
  5787. * Legend page navigation demonstrated
  5788. * @sample {highstock} highcharts/legend/navigation/
  5789. * Legend page navigation demonstrated
  5790. *
  5791. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  5792. * @default true
  5793. * @since 2.2.4
  5794. * @apioption legend.navigation.animation
  5795. */
  5796. /**
  5797. * The pixel size of the up and down arrows in the legend paging
  5798. * navigation.
  5799. *
  5800. * @sample {highcharts} highcharts/legend/navigation/
  5801. * Legend page navigation demonstrated
  5802. * @sample {highstock} highcharts/legend/navigation/
  5803. * Legend page navigation demonstrated
  5804. *
  5805. * @type {number}
  5806. * @default 12
  5807. * @since 2.2.4
  5808. * @apioption legend.navigation.arrowSize
  5809. */
  5810. /**
  5811. * Whether to enable the legend navigation. In most cases, disabling
  5812. * the navigation results in an unwanted overflow.
  5813. *
  5814. * See also the [adapt chart to legend](
  5815. * https://www.highcharts.com/products/plugin-registry/single/8/Adapt-Chart-To-Legend)
  5816. * plugin for a solution to extend the chart height to make room for
  5817. * the legend, optionally in exported charts only.
  5818. *
  5819. * @type {boolean}
  5820. * @default true
  5821. * @since 4.2.4
  5822. * @apioption legend.navigation.enabled
  5823. */
  5824. /**
  5825. * Text styles for the legend page navigation.
  5826. *
  5827. * @see In styled mode, the navigation items are styled with the
  5828. * `.highcharts-legend-navigation` class.
  5829. *
  5830. * @sample {highcharts} highcharts/legend/navigation/
  5831. * Legend page navigation demonstrated
  5832. * @sample {highstock} highcharts/legend/navigation/
  5833. * Legend page navigation demonstrated
  5834. *
  5835. * @type {Highcharts.CSSObject}
  5836. * @since 2.2.4
  5837. * @apioption legend.navigation.style
  5838. */
  5839. /**
  5840. * The color for the active up or down arrow in the legend page
  5841. * navigation.
  5842. *
  5843. * @see In styled mode, the active arrow be styled with the
  5844. * `.highcharts-legend-nav-active` class.
  5845. *
  5846. * @sample {highcharts} highcharts/legend/navigation/
  5847. * Legend page navigation demonstrated
  5848. * @sample {highstock} highcharts/legend/navigation/
  5849. * Legend page navigation demonstrated
  5850. *
  5851. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  5852. * @since 2.2.4
  5853. */
  5854. activeColor: palette.highlightColor100,
  5855. /**
  5856. * The color of the inactive up or down arrow in the legend page
  5857. * navigation. .
  5858. *
  5859. * @see In styled mode, the inactive arrow be styled with the
  5860. * `.highcharts-legend-nav-inactive` class.
  5861. *
  5862. * @sample {highcharts} highcharts/legend/navigation/
  5863. * Legend page navigation demonstrated
  5864. * @sample {highstock} highcharts/legend/navigation/
  5865. * Legend page navigation demonstrated
  5866. *
  5867. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  5868. * @since 2.2.4
  5869. */
  5870. inactiveColor: palette.neutralColor20
  5871. },
  5872. /**
  5873. * The inner padding of the legend box.
  5874. *
  5875. * @sample {highcharts|highstock} highcharts/legend/padding-itemmargin/
  5876. * Padding and item margins demonstrated
  5877. * @sample {highmaps} maps/legend/padding-itemmargin/
  5878. * Padding and item margins demonstrated
  5879. *
  5880. * @type {number}
  5881. * @default 8
  5882. * @since 2.2.0
  5883. * @apioption legend.padding
  5884. */
  5885. /**
  5886. * Whether to reverse the order of the legend items compared to the
  5887. * order of the series or points as defined in the configuration object.
  5888. *
  5889. * @see [yAxis.reversedStacks](#yAxis.reversedStacks),
  5890. * [series.legendIndex](#series.legendIndex)
  5891. *
  5892. * @sample {highcharts} highcharts/legend/reversed/
  5893. * Stacked bar with reversed legend
  5894. *
  5895. * @type {boolean}
  5896. * @default false
  5897. * @since 1.2.5
  5898. * @apioption legend.reversed
  5899. */
  5900. /**
  5901. * Whether to show the symbol on the right side of the text rather than
  5902. * the left side. This is common in Arabic and Hebrew.
  5903. *
  5904. * @sample {highcharts} highcharts/legend/rtl/
  5905. * Symbol to the right
  5906. *
  5907. * @type {boolean}
  5908. * @default false
  5909. * @since 2.2
  5910. * @apioption legend.rtl
  5911. */
  5912. /**
  5913. * CSS styles for the legend area. In the 1.x versions the position
  5914. * of the legend area was determined by CSS. In 2.x, the position is
  5915. * determined by properties like `align`, `verticalAlign`, `x` and `y`,
  5916. * but the styles are still parsed for backwards compatibility.
  5917. *
  5918. * @deprecated
  5919. *
  5920. * @type {Highcharts.CSSObject}
  5921. * @product highcharts highstock
  5922. * @apioption legend.style
  5923. */
  5924. /**
  5925. * CSS styles for each legend item. Only a subset of CSS is supported,
  5926. * notably those options related to text. The default `textOverflow`
  5927. * property makes long texts truncate. Set it to `undefined` to wrap
  5928. * text instead. A `width` property can be added to control the text
  5929. * width.
  5930. *
  5931. * @see In styled mode, the legend items can be styled with the
  5932. * `.highcharts-legend-item` class.
  5933. *
  5934. * @sample {highcharts} highcharts/legend/itemstyle/
  5935. * Bold black text
  5936. * @sample {highmaps} maps/legend/itemstyle/
  5937. * Item text styles
  5938. *
  5939. * @type {Highcharts.CSSObject}
  5940. * @default {"color": "#333333", "cursor": "pointer", "fontSize": "12px", "fontWeight": "bold", "textOverflow": "ellipsis"}
  5941. */
  5942. itemStyle: {
  5943. /**
  5944. * @ignore
  5945. */
  5946. color: palette.neutralColor80,
  5947. /**
  5948. * @ignore
  5949. */
  5950. cursor: 'pointer',
  5951. /**
  5952. * @ignore
  5953. */
  5954. fontSize: '12px',
  5955. /**
  5956. * @ignore
  5957. */
  5958. fontWeight: 'bold',
  5959. /**
  5960. * @ignore
  5961. */
  5962. textOverflow: 'ellipsis'
  5963. },
  5964. /**
  5965. * CSS styles for each legend item in hover mode. Only a subset of
  5966. * CSS is supported, notably those options related to text. Properties
  5967. * are inherited from `style` unless overridden here.
  5968. *
  5969. * @see In styled mode, the hovered legend items can be styled with
  5970. * the `.highcharts-legend-item:hover` pesudo-class.
  5971. *
  5972. * @sample {highcharts} highcharts/legend/itemhoverstyle/
  5973. * Red on hover
  5974. * @sample {highmaps} maps/legend/itemstyle/
  5975. * Item text styles
  5976. *
  5977. * @type {Highcharts.CSSObject}
  5978. * @default {"color": "#000000"}
  5979. */
  5980. itemHoverStyle: {
  5981. /**
  5982. * @ignore
  5983. */
  5984. color: palette.neutralColor100
  5985. },
  5986. /**
  5987. * CSS styles for each legend item when the corresponding series or
  5988. * point is hidden. Only a subset of CSS is supported, notably those
  5989. * options related to text. Properties are inherited from `style`
  5990. * unless overridden here.
  5991. *
  5992. * @see In styled mode, the hidden legend items can be styled with
  5993. * the `.highcharts-legend-item-hidden` class.
  5994. *
  5995. * @sample {highcharts} highcharts/legend/itemhiddenstyle/
  5996. * Darker gray color
  5997. *
  5998. * @type {Highcharts.CSSObject}
  5999. * @default {"color": "#cccccc"}
  6000. */
  6001. itemHiddenStyle: {
  6002. /**
  6003. * @ignore
  6004. */
  6005. color: palette.neutralColor20
  6006. },
  6007. /**
  6008. * Whether to apply a drop shadow to the legend. A `backgroundColor`
  6009. * also needs to be applied for this to take effect. The shadow can be
  6010. * an object configuration containing `color`, `offsetX`, `offsetY`,
  6011. * `opacity` and `width`.
  6012. *
  6013. * @sample {highcharts} highcharts/legend/shadow/
  6014. * White background and drop shadow
  6015. * @sample {highstock} stock/legend/align/
  6016. * Various legend options
  6017. * @sample {highmaps} maps/legend/border-background/
  6018. * Border and background options
  6019. *
  6020. * @type {boolean|Highcharts.CSSObject}
  6021. */
  6022. shadow: false,
  6023. /**
  6024. * Default styling for the checkbox next to a legend item when
  6025. * `showCheckbox` is true.
  6026. *
  6027. * @type {Highcharts.CSSObject}
  6028. * @default {"width": "13px", "height": "13px", "position":"absolute"}
  6029. */
  6030. itemCheckboxStyle: {
  6031. /**
  6032. * @ignore
  6033. */
  6034. position: 'absolute',
  6035. /**
  6036. * @ignore
  6037. */
  6038. width: '13px',
  6039. /**
  6040. * @ignore
  6041. */
  6042. height: '13px'
  6043. },
  6044. // itemWidth: undefined,
  6045. /**
  6046. * When this is true, the legend symbol width will be the same as
  6047. * the symbol height, which in turn defaults to the font size of the
  6048. * legend items.
  6049. *
  6050. * @since 5.0.0
  6051. */
  6052. squareSymbol: true,
  6053. /**
  6054. * The pixel height of the symbol for series types that use a rectangle
  6055. * in the legend. Defaults to the font size of legend items.
  6056. *
  6057. * @productdesc {highmaps}
  6058. * In Highmaps, when the symbol is the gradient of a vertical color
  6059. * axis, the height defaults to 200.
  6060. *
  6061. * @sample {highmaps} maps/legend/layout-vertical-sized/
  6062. * Sized vertical gradient
  6063. * @sample {highmaps} maps/legend/padding-itemmargin/
  6064. * No distance between data classes
  6065. *
  6066. * @type {number}
  6067. * @since 3.0.8
  6068. * @apioption legend.symbolHeight
  6069. */
  6070. /**
  6071. * The border radius of the symbol for series types that use a rectangle
  6072. * in the legend. Defaults to half the `symbolHeight`.
  6073. *
  6074. * @sample {highcharts} highcharts/legend/symbolradius/
  6075. * Round symbols
  6076. * @sample {highstock} highcharts/legend/symbolradius/
  6077. * Round symbols
  6078. * @sample {highmaps} highcharts/legend/symbolradius/
  6079. * Round symbols
  6080. *
  6081. * @type {number}
  6082. * @since 3.0.8
  6083. * @apioption legend.symbolRadius
  6084. */
  6085. /**
  6086. * The pixel width of the legend item symbol. When the `squareSymbol`
  6087. * option is set, this defaults to the `symbolHeight`, otherwise 16.
  6088. *
  6089. * @productdesc {highmaps}
  6090. * In Highmaps, when the symbol is the gradient of a horizontal color
  6091. * axis, the width defaults to 200.
  6092. *
  6093. * @sample {highcharts} highcharts/legend/symbolwidth/
  6094. * Greater symbol width and padding
  6095. * @sample {highmaps} maps/legend/padding-itemmargin/
  6096. * Padding and item margins demonstrated
  6097. * @sample {highmaps} maps/legend/layout-vertical-sized/
  6098. * Sized vertical gradient
  6099. *
  6100. * @type {number}
  6101. * @apioption legend.symbolWidth
  6102. */
  6103. /**
  6104. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  6105. * to render the legend item texts.
  6106. *
  6107. * Prior to 4.1.7, when using HTML, [legend.navigation](
  6108. * #legend.navigation) was disabled.
  6109. *
  6110. * @type {boolean}
  6111. * @default false
  6112. * @apioption legend.useHTML
  6113. */
  6114. /**
  6115. * The width of the legend box. If a number is set, it translates to
  6116. * pixels. Since v7.0.2 it allows setting a percent string of the full
  6117. * chart width, for example `40%`.
  6118. *
  6119. * Defaults to the full chart width for legends below or above the
  6120. * chart, half the chart width for legends to the left and right.
  6121. *
  6122. * @sample {highcharts} highcharts/legend/width/
  6123. * Aligned to the plot area
  6124. * @sample {highcharts} highcharts/legend/width-percent/
  6125. * A percent of the chart width
  6126. *
  6127. * @type {number|string}
  6128. * @since 2.0
  6129. * @apioption legend.width
  6130. */
  6131. /**
  6132. * The pixel padding between the legend item symbol and the legend
  6133. * item text.
  6134. *
  6135. * @sample {highcharts} highcharts/legend/symbolpadding/
  6136. * Greater symbol width and padding
  6137. */
  6138. symbolPadding: 5,
  6139. /**
  6140. * The vertical alignment of the legend box. Can be one of `top`,
  6141. * `middle` or `bottom`. Vertical position can be further determined
  6142. * by the `y` option.
  6143. *
  6144. * In the case that the legend is aligned in a corner position, the
  6145. * `layout` option will determine whether to place it above/below
  6146. * or on the side of the plot area.
  6147. *
  6148. * When the [layout](#legend.layout) option is `proximate`, the
  6149. * `verticalAlign` option doesn't apply.
  6150. *
  6151. * @sample {highcharts} highcharts/legend/verticalalign/
  6152. * Legend 100px from the top of the chart
  6153. * @sample {highstock} stock/legend/align/
  6154. * Various legend options
  6155. * @sample {highmaps} maps/legend/alignment/
  6156. * Legend alignment
  6157. *
  6158. * @type {Highcharts.VerticalAlignValue}
  6159. * @since 2.0
  6160. */
  6161. verticalAlign: 'bottom',
  6162. // width: undefined,
  6163. /**
  6164. * The x offset of the legend relative to its horizontal alignment
  6165. * `align` within chart.spacingLeft and chart.spacingRight. Negative
  6166. * x moves it to the left, positive x moves it to the right.
  6167. *
  6168. * @sample {highcharts} highcharts/legend/width/
  6169. * Aligned to the plot area
  6170. *
  6171. * @since 2.0
  6172. */
  6173. x: 0,
  6174. /**
  6175. * The vertical offset of the legend relative to it's vertical alignment
  6176. * `verticalAlign` within chart.spacingTop and chart.spacingBottom.
  6177. * Negative y moves it up, positive y moves it down.
  6178. *
  6179. * @sample {highcharts} highcharts/legend/verticalalign/
  6180. * Legend 100px from the top of the chart
  6181. * @sample {highstock} stock/legend/align/
  6182. * Various legend options
  6183. * @sample {highmaps} maps/legend/alignment/
  6184. * Legend alignment
  6185. *
  6186. * @since 2.0
  6187. */
  6188. y: 0,
  6189. /**
  6190. * A title to be added on top of the legend.
  6191. *
  6192. * @sample {highcharts} highcharts/legend/title/
  6193. * Legend title
  6194. * @sample {highmaps} maps/legend/alignment/
  6195. * Legend with title
  6196. *
  6197. * @since 3.0
  6198. */
  6199. title: {
  6200. /**
  6201. * A text or HTML string for the title.
  6202. *
  6203. * @type {string}
  6204. * @since 3.0
  6205. * @apioption legend.title.text
  6206. */
  6207. /**
  6208. * Generic CSS styles for the legend title.
  6209. *
  6210. * @see In styled mode, the legend title is styled with the
  6211. * `.highcharts-legend-title` class.
  6212. *
  6213. * @type {Highcharts.CSSObject}
  6214. * @default {"fontWeight": "bold"}
  6215. * @since 3.0
  6216. */
  6217. style: {
  6218. /**
  6219. * @ignore
  6220. */
  6221. fontWeight: 'bold'
  6222. }
  6223. }
  6224. },
  6225. /**
  6226. * The loading options control the appearance of the loading screen
  6227. * that covers the plot area on chart operations. This screen only
  6228. * appears after an explicit call to `chart.showLoading()`. It is a
  6229. * utility for developers to communicate to the end user that something
  6230. * is going on, for example while retrieving new data via an XHR connection.
  6231. * The "Loading..." text itself is not part of this configuration
  6232. * object, but part of the `lang` object.
  6233. */
  6234. loading: {
  6235. /**
  6236. * The duration in milliseconds of the fade out effect.
  6237. *
  6238. * @sample highcharts/loading/hideduration/
  6239. * Fade in and out over a second
  6240. *
  6241. * @type {number}
  6242. * @default 100
  6243. * @since 1.2.0
  6244. * @apioption loading.hideDuration
  6245. */
  6246. /**
  6247. * The duration in milliseconds of the fade in effect.
  6248. *
  6249. * @sample highcharts/loading/hideduration/
  6250. * Fade in and out over a second
  6251. *
  6252. * @type {number}
  6253. * @default 100
  6254. * @since 1.2.0
  6255. * @apioption loading.showDuration
  6256. */
  6257. /**
  6258. * CSS styles for the loading label `span`.
  6259. *
  6260. * @see In styled mode, the loading label is styled with the
  6261. * `.highcharts-loading-inner` class.
  6262. *
  6263. * @sample {highcharts|highmaps} highcharts/loading/labelstyle/
  6264. * Vertically centered
  6265. * @sample {highstock} stock/loading/general/
  6266. * Label styles
  6267. *
  6268. * @type {Highcharts.CSSObject}
  6269. * @default {"fontWeight": "bold", "position": "relative", "top": "45%"}
  6270. * @since 1.2.0
  6271. */
  6272. labelStyle: {
  6273. /**
  6274. * @ignore
  6275. */
  6276. fontWeight: 'bold',
  6277. /**
  6278. * @ignore
  6279. */
  6280. position: 'relative',
  6281. /**
  6282. * @ignore
  6283. */
  6284. top: '45%'
  6285. },
  6286. /**
  6287. * CSS styles for the loading screen that covers the plot area.
  6288. *
  6289. * In styled mode, the loading label is styled with the
  6290. * `.highcharts-loading` class.
  6291. *
  6292. * @sample {highcharts|highmaps} highcharts/loading/style/
  6293. * Gray plot area, white text
  6294. * @sample {highstock} stock/loading/general/
  6295. * Gray plot area, white text
  6296. *
  6297. * @type {Highcharts.CSSObject}
  6298. * @default {"position": "absolute", "backgroundColor": "#ffffff", "opacity": 0.5, "textAlign": "center"}
  6299. * @since 1.2.0
  6300. */
  6301. style: {
  6302. /**
  6303. * @ignore
  6304. */
  6305. position: 'absolute',
  6306. /**
  6307. * @ignore
  6308. */
  6309. backgroundColor: palette.backgroundColor,
  6310. /**
  6311. * @ignore
  6312. */
  6313. opacity: 0.5,
  6314. /**
  6315. * @ignore
  6316. */
  6317. textAlign: 'center'
  6318. }
  6319. },
  6320. /**
  6321. * Options for the tooltip that appears when the user hovers over a
  6322. * series or point.
  6323. *
  6324. * @declare Highcharts.TooltipOptions
  6325. */
  6326. tooltip: {
  6327. /**
  6328. * The color of the tooltip border. When `undefined`, the border takes
  6329. * the color of the corresponding series or point.
  6330. *
  6331. * @sample {highcharts} highcharts/tooltip/bordercolor-default/
  6332. * Follow series by default
  6333. * @sample {highcharts} highcharts/tooltip/bordercolor-black/
  6334. * Black border
  6335. * @sample {highstock} stock/tooltip/general/
  6336. * Styled tooltip
  6337. * @sample {highmaps} maps/tooltip/background-border/
  6338. * Background and border demo
  6339. *
  6340. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  6341. * @apioption tooltip.borderColor
  6342. */
  6343. /**
  6344. * A CSS class name to apply to the tooltip's container div,
  6345. * allowing unique CSS styling for each chart.
  6346. *
  6347. * @type {string}
  6348. * @apioption tooltip.className
  6349. */
  6350. /**
  6351. * Since 4.1, the crosshair definitions are moved to the Axis object
  6352. * in order for a better separation from the tooltip. See
  6353. * [xAxis.crosshair](#xAxis.crosshair).
  6354. *
  6355. * @sample {highcharts} highcharts/tooltip/crosshairs-x/
  6356. * Enable a crosshair for the x value
  6357. *
  6358. * @deprecated
  6359. *
  6360. * @type {*}
  6361. * @default true
  6362. * @apioption tooltip.crosshairs
  6363. */
  6364. /**
  6365. * Distance from point to tooltip in pixels.
  6366. *
  6367. * @type {number}
  6368. * @default 16
  6369. * @apioption tooltip.distance
  6370. */
  6371. /**
  6372. * Whether the tooltip should follow the mouse as it moves across
  6373. * columns, pie slices and other point types with an extent.
  6374. * By default it behaves this way for pie, polygon, map, sankey
  6375. * and wordcloud series by override in the `plotOptions`
  6376. * for those series types.
  6377. *
  6378. * Does not apply if [split](#tooltip.split) is `true`.
  6379. *
  6380. * For touch moves to behave the same way, [followTouchMove](
  6381. * #tooltip.followTouchMove) must be `true` also.
  6382. *
  6383. * @type {boolean}
  6384. * @default {highcharts} false
  6385. * @default {highstock} false
  6386. * @default {highmaps} true
  6387. * @since 3.0
  6388. * @apioption tooltip.followPointer
  6389. */
  6390. /**
  6391. * Whether the tooltip should update as the finger moves on a touch
  6392. * device. If this is `true` and [chart.panning](#chart.panning) is
  6393. * set,`followTouchMove` will take over one-finger touches, so the user
  6394. * needs to use two fingers for zooming and panning.
  6395. *
  6396. * Note the difference to [followPointer](#tooltip.followPointer) that
  6397. * only defines the _position_ of the tooltip. If `followPointer` is
  6398. * false in for example a column series, the tooltip will show above or
  6399. * below the column, but as `followTouchMove` is true, the tooltip will
  6400. * jump from column to column as the user swipes across the plot area.
  6401. *
  6402. * @type {boolean}
  6403. * @default {highcharts} true
  6404. * @default {highstock} true
  6405. * @default {highmaps} false
  6406. * @since 3.0.1
  6407. * @apioption tooltip.followTouchMove
  6408. */
  6409. /**
  6410. * Callback function to format the text of the tooltip from scratch. In
  6411. * case of single or [shared](#tooltip.shared) tooltips, a string should
  6412. * be returned. In case of [split](#tooltip.split) tooltips, it should
  6413. * return an array where the first item is the header, and subsequent
  6414. * items are mapped to the points. Return `false` to disable tooltip for
  6415. * a specific point on series.
  6416. *
  6417. * A subset of HTML is supported. Unless `useHTML` is true, the HTML of
  6418. * the tooltip is parsed and converted to SVG, therefore this isn't a
  6419. * complete HTML renderer. The following HTML tags are supported: `b`,
  6420. * `br`, `em`, `i`, `span`, `strong`. Spans can be styled with a `style`
  6421. * attribute, but only text-related CSS, that is shared with SVG, is
  6422. * handled.
  6423. *
  6424. * The available data in the formatter differ a bit depending on whether
  6425. * the tooltip is shared or split, or belongs to a single point. In a
  6426. * shared/split tooltip, all properties except `x`, which is common for
  6427. * all points, are kept in an array, `this.points`.
  6428. *
  6429. * Available data are:
  6430. *
  6431. * - **this.percentage (not shared) /**
  6432. * **this.points[i].percentage (shared)**:
  6433. * Stacked series and pies only. The point's percentage of the total.
  6434. *
  6435. * - **this.point (not shared) / this.points[i].point (shared)**:
  6436. * The point object. The point name, if defined, is available through
  6437. * `this.point.name`.
  6438. *
  6439. * - **this.points**:
  6440. * In a shared tooltip, this is an array containing all other
  6441. * properties for each point.
  6442. *
  6443. * - **this.series (not shared) / this.points[i].series (shared)**:
  6444. * The series object. The series name is available through
  6445. * `this.series.name`.
  6446. *
  6447. * - **this.total (not shared) / this.points[i].total (shared)**:
  6448. * Stacked series only. The total value at this point's x value.
  6449. *
  6450. * - **this.x**:
  6451. * The x value. This property is the same regardless of the tooltip
  6452. * being shared or not.
  6453. *
  6454. * - **this.y (not shared) / this.points[i].y (shared)**:
  6455. * The y value.
  6456. *
  6457. * @sample {highcharts} highcharts/tooltip/formatter-simple/
  6458. * Simple string formatting
  6459. * @sample {highcharts} highcharts/tooltip/formatter-shared/
  6460. * Formatting with shared tooltip
  6461. * @sample {highcharts|highstock} highcharts/tooltip/formatter-split/
  6462. * Formatting with split tooltip
  6463. * @sample highcharts/tooltip/formatter-conditional-default/
  6464. * Extending default formatter
  6465. * @sample {highstock} stock/tooltip/formatter/
  6466. * Formatting with shared tooltip
  6467. * @sample {highmaps} maps/tooltip/formatter/
  6468. * String formatting
  6469. *
  6470. * @type {Highcharts.TooltipFormatterCallbackFunction}
  6471. * @apioption tooltip.formatter
  6472. */
  6473. /**
  6474. * Callback function to format the text of the tooltip for
  6475. * visible null points.
  6476. * Works analogously to [formatter](#tooltip.formatter).
  6477. *
  6478. * @sample highcharts/plotoptions/series-nullformat
  6479. * Format data label and tooltip for null point.
  6480. *
  6481. * @type {Highcharts.TooltipFormatterCallbackFunction}
  6482. * @apioption tooltip.nullFormatter
  6483. */
  6484. /**
  6485. * The number of milliseconds to wait until the tooltip is hidden when
  6486. * mouse out from a point or chart.
  6487. *
  6488. * @type {number}
  6489. * @default 500
  6490. * @since 3.0
  6491. * @apioption tooltip.hideDelay
  6492. */
  6493. /**
  6494. * Whether to allow the tooltip to render outside the chart's SVG
  6495. * element box. By default (`false`), the tooltip is rendered within the
  6496. * chart's SVG element, which results in the tooltip being aligned
  6497. * inside the chart area. For small charts, this may result in clipping
  6498. * or overlapping. When `true`, a separate SVG element is created and
  6499. * overlaid on the page, allowing the tooltip to be aligned inside the
  6500. * page itself.
  6501. *
  6502. * Defaults to `true` if `chart.scrollablePlotArea` is activated,
  6503. * otherwise `false`.
  6504. *
  6505. * @sample highcharts/tooltip/outside
  6506. * Small charts with tooltips outside
  6507. *
  6508. * @type {boolean|undefined}
  6509. * @default undefined
  6510. * @since 6.1.1
  6511. * @apioption tooltip.outside
  6512. */
  6513. /**
  6514. * A callback function for formatting the HTML output for a single point
  6515. * in the tooltip. Like the `pointFormat` string, but with more
  6516. * flexibility.
  6517. *
  6518. * @type {Highcharts.FormatterCallbackFunction<Highcharts.Point>}
  6519. * @since 4.1.0
  6520. * @context Highcharts.Point
  6521. * @apioption tooltip.pointFormatter
  6522. */
  6523. /**
  6524. * A callback function to place the tooltip in a default position. The
  6525. * callback receives three parameters: `labelWidth`, `labelHeight` and
  6526. * `point`, where point contains values for `plotX` and `plotY` telling
  6527. * where the reference point is in the plot area. Add `chart.plotLeft`
  6528. * and `chart.plotTop` to get the full coordinates.
  6529. *
  6530. * Since v7, when [tooltip.split](#tooltip.split) option is enabled,
  6531. * positioner is called for each of the boxes separately, including
  6532. * xAxis header. xAxis header is not a point, instead `point` argument
  6533. * contains info:
  6534. * `{ plotX: Number, plotY: Number, isHeader: Boolean }`
  6535. *
  6536. *
  6537. * The return should be an object containing x and y values, for example
  6538. * `{ x: 100, y: 100 }`.
  6539. *
  6540. * @sample {highcharts} highcharts/tooltip/positioner/
  6541. * A fixed tooltip position
  6542. * @sample {highstock} stock/tooltip/positioner/
  6543. * A fixed tooltip position on top of the chart
  6544. * @sample {highmaps} maps/tooltip/positioner/
  6545. * A fixed tooltip position
  6546. * @sample {highstock} stock/tooltip/split-positioner/
  6547. * Split tooltip with fixed positions
  6548. * @sample {highstock} stock/tooltip/positioner-scrollable-plotarea/
  6549. * Scrollable plot area combined with tooltip positioner
  6550. *
  6551. * @type {Highcharts.TooltipPositionerCallbackFunction}
  6552. * @since 2.2.4
  6553. * @apioption tooltip.positioner
  6554. */
  6555. /**
  6556. * The name of a symbol to use for the border around the tooltip. Can
  6557. * be one of: `"callout"`, `"circle"` or `"rect"`. When
  6558. * [tooltip.split](#tooltip.split)
  6559. * option is enabled, shape is applied to all boxes except header, which
  6560. * is controlled by
  6561. * [tooltip.headerShape](#tooltip.headerShape).
  6562. *
  6563. * Custom callbacks for symbol path generation can also be added to
  6564. * `Highcharts.SVGRenderer.prototype.symbols` the same way as for
  6565. * [series.marker.symbol](plotOptions.line.marker.symbol).
  6566. *
  6567. * @type {Highcharts.TooltipShapeValue}
  6568. * @default callout
  6569. * @since 4.0
  6570. * @apioption tooltip.shape
  6571. */
  6572. /**
  6573. * The name of a symbol to use for the border around the tooltip
  6574. * header. Applies only when [tooltip.split](#tooltip.split) is
  6575. * enabled.
  6576. *
  6577. * Custom callbacks for symbol path generation can also be added to
  6578. * `Highcharts.SVGRenderer.prototype.symbols` the same way as for
  6579. * [series.marker.symbol](plotOptions.line.marker.symbol).
  6580. *
  6581. * @see [tooltip.shape](#tooltip.shape)
  6582. *
  6583. * @sample {highstock} stock/tooltip/split-positioner/
  6584. * Different shapes for header and split boxes
  6585. *
  6586. * @type {Highcharts.TooltipShapeValue}
  6587. * @default callout
  6588. * @validvalue ["callout", "square"]
  6589. * @since 7.0
  6590. * @apioption tooltip.headerShape
  6591. */
  6592. /**
  6593. * When the tooltip is shared, the entire plot area will capture mouse
  6594. * movement or touch events. Tooltip texts for series types with ordered
  6595. * data (not pie, scatter, flags etc) will be shown in a single bubble.
  6596. * This is recommended for single series charts and for tablet/mobile
  6597. * optimized charts.
  6598. *
  6599. * See also [tooltip.split](#tooltip.split), that is better suited for
  6600. * charts with many series, especially line-type series. The
  6601. * `tooltip.split` option takes precedence over `tooltip.shared`.
  6602. *
  6603. * @sample {highcharts} highcharts/tooltip/shared-false/
  6604. * False by default
  6605. * @sample {highcharts} highcharts/tooltip/shared-true/
  6606. * True
  6607. * @sample {highcharts} highcharts/tooltip/shared-x-crosshair/
  6608. * True with x axis crosshair
  6609. * @sample {highcharts} highcharts/tooltip/shared-true-mixed-types/
  6610. * True with mixed series types
  6611. *
  6612. * @type {boolean}
  6613. * @default false
  6614. * @since 2.1
  6615. * @product highcharts highstock
  6616. * @apioption tooltip.shared
  6617. */
  6618. /**
  6619. * Split the tooltip into one label per series, with the header close
  6620. * to the axis. This is recommended over [shared](#tooltip.shared)
  6621. * tooltips for charts with multiple line series, generally making them
  6622. * easier to read. This option takes precedence over `tooltip.shared`.
  6623. *
  6624. * @productdesc {highstock} In Highcharts Stock, tooltips are split
  6625. * by default since v6.0.0. Stock charts typically contain
  6626. * multi-dimension points and multiple panes, making split tooltips
  6627. * the preferred layout over
  6628. * the previous `shared` tooltip.
  6629. *
  6630. * @sample highcharts/tooltip/split/
  6631. * Split tooltip
  6632. * @sample {highcharts|highstock} highcharts/tooltip/formatter-split/
  6633. * Split tooltip and custom formatter callback
  6634. *
  6635. * @type {boolean}
  6636. * @default {highcharts} false
  6637. * @default {highstock} true
  6638. * @since 5.0.0
  6639. * @product highcharts highstock
  6640. * @apioption tooltip.split
  6641. */
  6642. /**
  6643. * Prevents the tooltip from switching or closing, when touched or
  6644. * pointed.
  6645. *
  6646. * @sample highcharts/tooltip/stickoncontact/
  6647. * Tooltip sticks on pointer contact
  6648. *
  6649. * @type {boolean}
  6650. * @since 8.0.1
  6651. * @apioption tooltip.stickOnContact
  6652. */
  6653. /**
  6654. * Use HTML to render the contents of the tooltip instead of SVG. Using
  6655. * HTML allows advanced formatting like tables and images in the
  6656. * tooltip. It is also recommended for rtl languages as it works around
  6657. * rtl bugs in early Firefox.
  6658. *
  6659. * @sample {highcharts|highstock} highcharts/tooltip/footerformat/
  6660. * A table for value alignment
  6661. * @sample {highcharts|highstock} highcharts/tooltip/fullhtml/
  6662. * Full HTML tooltip
  6663. * @sample {highmaps} maps/tooltip/usehtml/
  6664. * Pure HTML tooltip
  6665. *
  6666. * @type {boolean}
  6667. * @default false
  6668. * @since 2.2
  6669. * @apioption tooltip.useHTML
  6670. */
  6671. /**
  6672. * How many decimals to show in each series' y value. This is
  6673. * overridable in each series' tooltip options object. The default is to
  6674. * preserve all decimals.
  6675. *
  6676. * @sample {highcharts|highstock} highcharts/tooltip/valuedecimals/
  6677. * Set decimals, prefix and suffix for the value
  6678. * @sample {highmaps} maps/tooltip/valuedecimals/
  6679. * Set decimals, prefix and suffix for the value
  6680. *
  6681. * @type {number}
  6682. * @since 2.2
  6683. * @apioption tooltip.valueDecimals
  6684. */
  6685. /**
  6686. * A string to prepend to each series' y value. Overridable in each
  6687. * series' tooltip options object.
  6688. *
  6689. * @sample {highcharts|highstock} highcharts/tooltip/valuedecimals/
  6690. * Set decimals, prefix and suffix for the value
  6691. * @sample {highmaps} maps/tooltip/valuedecimals/
  6692. * Set decimals, prefix and suffix for the value
  6693. *
  6694. * @type {string}
  6695. * @since 2.2
  6696. * @apioption tooltip.valuePrefix
  6697. */
  6698. /**
  6699. * A string to append to each series' y value. Overridable in each
  6700. * series' tooltip options object.
  6701. *
  6702. * @sample {highcharts|highstock} highcharts/tooltip/valuedecimals/
  6703. * Set decimals, prefix and suffix for the value
  6704. * @sample {highmaps} maps/tooltip/valuedecimals/
  6705. * Set decimals, prefix and suffix for the value
  6706. *
  6707. * @type {string}
  6708. * @since 2.2
  6709. * @apioption tooltip.valueSuffix
  6710. */
  6711. /**
  6712. * The format for the date in the tooltip header if the X axis is a
  6713. * datetime axis. The default is a best guess based on the smallest
  6714. * distance between points in the chart.
  6715. *
  6716. * @sample {highcharts} highcharts/tooltip/xdateformat/
  6717. * A different format
  6718. *
  6719. * @type {string}
  6720. * @product highcharts highstock gantt
  6721. * @apioption tooltip.xDateFormat
  6722. */
  6723. /**
  6724. * How many decimals to show for the `point.change` value when the
  6725. * `series.compare` option is set. This is overridable in each series'
  6726. * tooltip options object. The default is to preserve all decimals.
  6727. *
  6728. * @type {number}
  6729. * @since 1.0.1
  6730. * @product highstock
  6731. * @apioption tooltip.changeDecimals
  6732. */
  6733. /**
  6734. * Enable or disable the tooltip.
  6735. *
  6736. * @sample {highcharts} highcharts/tooltip/enabled/
  6737. * Disabled
  6738. * @sample {highcharts} highcharts/plotoptions/series-point-events-mouseover/
  6739. * Disable tooltip and show values on chart instead
  6740. */
  6741. enabled: true,
  6742. /**
  6743. * Enable or disable animation of the tooltip.
  6744. *
  6745. * @type {boolean}
  6746. * @default true
  6747. * @since 2.3.0
  6748. */
  6749. animation: svg,
  6750. /**
  6751. * The radius of the rounded border corners.
  6752. *
  6753. * @sample {highcharts} highcharts/tooltip/bordercolor-default/
  6754. * 5px by default
  6755. * @sample {highcharts} highcharts/tooltip/borderradius-0/
  6756. * Square borders
  6757. * @sample {highmaps} maps/tooltip/background-border/
  6758. * Background and border demo
  6759. */
  6760. borderRadius: 3,
  6761. /**
  6762. * For series on datetime axes, the date format in the tooltip's
  6763. * header will by default be guessed based on the closest data points.
  6764. * This member gives the default string representations used for
  6765. * each unit. For an overview of the replacement codes, see
  6766. * [dateFormat](/class-reference/Highcharts#.dateFormat).
  6767. *
  6768. * @see [xAxis.dateTimeLabelFormats](#xAxis.dateTimeLabelFormats)
  6769. *
  6770. * @type {Highcharts.Dictionary<string>}
  6771. * @product highcharts highstock gantt
  6772. */
  6773. dateTimeLabelFormats: {
  6774. /** @internal */
  6775. millisecond: '%A, %b %e, %H:%M:%S.%L',
  6776. /** @internal */
  6777. second: '%A, %b %e, %H:%M:%S',
  6778. /** @internal */
  6779. minute: '%A, %b %e, %H:%M',
  6780. /** @internal */
  6781. hour: '%A, %b %e, %H:%M',
  6782. /** @internal */
  6783. day: '%A, %b %e, %Y',
  6784. /** @internal */
  6785. week: 'Week from %A, %b %e, %Y',
  6786. /** @internal */
  6787. month: '%B %Y',
  6788. /** @internal */
  6789. year: '%Y'
  6790. },
  6791. /**
  6792. * A string to append to the tooltip format.
  6793. *
  6794. * @sample {highcharts} highcharts/tooltip/footerformat/
  6795. * A table for value alignment
  6796. * @sample {highmaps} maps/tooltip/format/
  6797. * Format demo
  6798. *
  6799. * @since 2.2
  6800. */
  6801. footerFormat: '',
  6802. /**
  6803. * Padding inside the tooltip, in pixels.
  6804. *
  6805. * @since 5.0.0
  6806. */
  6807. padding: 8,
  6808. /**
  6809. * Proximity snap for graphs or single points. It defaults to 10 for
  6810. * mouse-powered devices and 25 for touch devices.
  6811. *
  6812. * Note that in most cases the whole plot area captures the mouse
  6813. * movement, and in these cases `tooltip.snap` doesn't make sense. This
  6814. * applies when [stickyTracking](#plotOptions.series.stickyTracking)
  6815. * is `true` (default) and when the tooltip is [shared](#tooltip.shared)
  6816. * or [split](#tooltip.split).
  6817. *
  6818. * @sample {highcharts} highcharts/tooltip/bordercolor-default/
  6819. * 10 px by default
  6820. * @sample {highcharts} highcharts/tooltip/snap-50/
  6821. * 50 px on graph
  6822. *
  6823. * @type {number}
  6824. * @default 10/25
  6825. * @since 1.2.0
  6826. * @product highcharts highstock
  6827. */
  6828. snap: isTouchDevice ? 25 : 10,
  6829. /**
  6830. * The HTML of the tooltip header line. Variables are enclosed by
  6831. * curly brackets. Available variables are `point.key`, `series.name`,
  6832. * `series.color` and other members from the `point` and `series`
  6833. * objects. The `point.key` variable contains the category name, x
  6834. * value or datetime string depending on the type of axis. For datetime
  6835. * axes, the `point.key` date format can be set using
  6836. * `tooltip.xDateFormat`.
  6837. *
  6838. * @sample {highcharts} highcharts/tooltip/footerformat/
  6839. * An HTML table in the tooltip
  6840. * @sample {highstock} highcharts/tooltip/footerformat/
  6841. * An HTML table in the tooltip
  6842. * @sample {highmaps} maps/tooltip/format/
  6843. * Format demo
  6844. *
  6845. * @type {string}
  6846. * @apioption tooltip.headerFormat
  6847. */
  6848. headerFormat: '<span style="font-size: 10px">{point.key}</span><br/>',
  6849. /**
  6850. * The HTML of the null point's line in the tooltip. Works analogously
  6851. * to [pointFormat](#tooltip.pointFormat).
  6852. *
  6853. * @sample {highcharts} highcharts/plotoptions/series-nullformat
  6854. * Format data label and tooltip for null point.
  6855. *
  6856. * @type {string}
  6857. * @apioption tooltip.nullFormat
  6858. */
  6859. /**
  6860. * The HTML of the point's line in the tooltip. Variables are enclosed
  6861. * by curly brackets. Available variables are `point.x`, `point.y`,
  6862. * `series.name` and `series.color` and other properties on the same
  6863. * form. Furthermore, `point.y` can be extended by the
  6864. * `tooltip.valuePrefix` and `tooltip.valueSuffix` variables. This can
  6865. * also be overridden for each series, which makes it a good hook for
  6866. * displaying units.
  6867. *
  6868. * In styled mode, the dot is colored by a class name rather
  6869. * than the point color.
  6870. *
  6871. * @sample {highcharts} highcharts/tooltip/pointformat/
  6872. * A different point format with value suffix
  6873. * @sample {highmaps} maps/tooltip/format/
  6874. * Format demo
  6875. *
  6876. * @type {string}
  6877. * @since 2.2
  6878. * @apioption tooltip.pointFormat
  6879. */
  6880. pointFormat: '<span style="color:{point.color}">\u25CF</span> {series.name}: <b>{point.y}</b><br/>',
  6881. /**
  6882. * The background color or gradient for the tooltip.
  6883. *
  6884. * In styled mode, the stroke width is set in the
  6885. * `.highcharts-tooltip-box` class.
  6886. *
  6887. * @sample {highcharts} highcharts/tooltip/backgroundcolor-solid/
  6888. * Yellowish background
  6889. * @sample {highcharts} highcharts/tooltip/backgroundcolor-gradient/
  6890. * Gradient
  6891. * @sample {highcharts} highcharts/css/tooltip-border-background/
  6892. * Tooltip in styled mode
  6893. * @sample {highstock} stock/tooltip/general/
  6894. * Custom tooltip
  6895. * @sample {highstock} highcharts/css/tooltip-border-background/
  6896. * Tooltip in styled mode
  6897. * @sample {highmaps} maps/tooltip/background-border/
  6898. * Background and border demo
  6899. * @sample {highmaps} highcharts/css/tooltip-border-background/
  6900. * Tooltip in styled mode
  6901. *
  6902. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  6903. */
  6904. backgroundColor: color(palette.neutralColor3)
  6905. .setOpacity(0.85).get(),
  6906. /**
  6907. * The pixel width of the tooltip border.
  6908. *
  6909. * In styled mode, the stroke width is set in the
  6910. * `.highcharts-tooltip-box` class.
  6911. *
  6912. * @sample {highcharts} highcharts/tooltip/bordercolor-default/
  6913. * 2px by default
  6914. * @sample {highcharts} highcharts/tooltip/borderwidth/
  6915. * No border (shadow only)
  6916. * @sample {highcharts} highcharts/css/tooltip-border-background/
  6917. * Tooltip in styled mode
  6918. * @sample {highstock} stock/tooltip/general/
  6919. * Custom tooltip
  6920. * @sample {highstock} highcharts/css/tooltip-border-background/
  6921. * Tooltip in styled mode
  6922. * @sample {highmaps} maps/tooltip/background-border/
  6923. * Background and border demo
  6924. * @sample {highmaps} highcharts/css/tooltip-border-background/
  6925. * Tooltip in styled mode
  6926. */
  6927. borderWidth: 1,
  6928. /**
  6929. * Whether to apply a drop shadow to the tooltip.
  6930. *
  6931. * @sample {highcharts} highcharts/tooltip/bordercolor-default/
  6932. * True by default
  6933. * @sample {highcharts} highcharts/tooltip/shadow/
  6934. * False
  6935. * @sample {highmaps} maps/tooltip/positioner/
  6936. * Fixed tooltip position, border and shadow disabled
  6937. *
  6938. * @type {boolean|Highcharts.ShadowOptionsObject}
  6939. */
  6940. shadow: true,
  6941. /**
  6942. * CSS styles for the tooltip. The tooltip can also be styled through
  6943. * the CSS class `.highcharts-tooltip`.
  6944. *
  6945. * Note that the default `pointerEvents` style makes the tooltip ignore
  6946. * mouse events, so in order to use clickable tooltips, this value must
  6947. * be set to `auto`.
  6948. *
  6949. * @sample {highcharts} highcharts/tooltip/style/
  6950. * Greater padding, bold text
  6951. *
  6952. * @type {Highcharts.CSSObject}
  6953. */
  6954. style: {
  6955. /** @internal */
  6956. color: palette.neutralColor80,
  6957. /** @internal */
  6958. cursor: 'default',
  6959. /** @internal */
  6960. fontSize: '12px',
  6961. /** @internal */
  6962. whiteSpace: 'nowrap'
  6963. }
  6964. },
  6965. /**
  6966. * Highchart by default puts a credits label in the lower right corner
  6967. * of the chart. This can be changed using these options.
  6968. */
  6969. credits: {
  6970. /**
  6971. * Credits for map source to be concatenated with conventional credit
  6972. * text. By default this is a format string that collects copyright
  6973. * information from the map if available.
  6974. *
  6975. * @see [mapTextFull](#credits.mapTextFull)
  6976. * @see [text](#credits.text)
  6977. *
  6978. * @type {string}
  6979. * @default \u00a9 <a href="{geojson.copyrightUrl}">{geojson.copyrightShort}</a>
  6980. * @since 4.2.2
  6981. * @product highmaps
  6982. * @apioption credits.mapText
  6983. */
  6984. /**
  6985. * Detailed credits for map source to be displayed on hover of credits
  6986. * text. By default this is a format string that collects copyright
  6987. * information from the map if available.
  6988. *
  6989. * @see [mapText](#credits.mapText)
  6990. * @see [text](#credits.text)
  6991. *
  6992. * @type {string}
  6993. * @default {geojson.copyright}
  6994. * @since 4.2.2
  6995. * @product highmaps
  6996. * @apioption credits.mapTextFull
  6997. */
  6998. /**
  6999. * Whether to show the credits text.
  7000. *
  7001. * @sample {highcharts} highcharts/credits/enabled-false/
  7002. * Credits disabled
  7003. * @sample {highstock} stock/credits/enabled/
  7004. * Credits disabled
  7005. * @sample {highmaps} maps/credits/enabled-false/
  7006. * Credits disabled
  7007. */
  7008. enabled: true,
  7009. /**
  7010. * The URL for the credits label.
  7011. *
  7012. * @sample {highcharts} highcharts/credits/href/
  7013. * Custom URL and text
  7014. * @sample {highmaps} maps/credits/customized/
  7015. * Custom URL and text
  7016. */
  7017. href: 'https://www.highcharts.com?credits',
  7018. /**
  7019. * Position configuration for the credits label.
  7020. *
  7021. * @sample {highcharts} highcharts/credits/position-left/
  7022. * Left aligned
  7023. * @sample {highcharts} highcharts/credits/position-left/
  7024. * Left aligned
  7025. * @sample {highmaps} maps/credits/customized/
  7026. * Left aligned
  7027. * @sample {highmaps} maps/credits/customized/
  7028. * Left aligned
  7029. *
  7030. * @type {Highcharts.AlignObject}
  7031. * @since 2.1
  7032. */
  7033. position: {
  7034. /** @internal */
  7035. align: 'right',
  7036. /** @internal */
  7037. x: -10,
  7038. /** @internal */
  7039. verticalAlign: 'bottom',
  7040. /** @internal */
  7041. y: -5
  7042. },
  7043. /**
  7044. * CSS styles for the credits label.
  7045. *
  7046. * @see In styled mode, credits styles can be set with the
  7047. * `.highcharts-credits` class.
  7048. *
  7049. * @type {Highcharts.CSSObject}
  7050. */
  7051. style: {
  7052. /** @internal */
  7053. cursor: 'pointer',
  7054. /** @internal */
  7055. color: palette.neutralColor40,
  7056. /** @internal */
  7057. fontSize: '9px'
  7058. },
  7059. /**
  7060. * The text for the credits label.
  7061. *
  7062. * @productdesc {highmaps}
  7063. * If a map is loaded as GeoJSON, the text defaults to
  7064. * `Highcharts @ {map-credits}`. Otherwise, it defaults to
  7065. * `Highcharts.com`.
  7066. *
  7067. * @sample {highcharts} highcharts/credits/href/
  7068. * Custom URL and text
  7069. * @sample {highmaps} maps/credits/customized/
  7070. * Custom URL and text
  7071. */
  7072. text: 'Highcharts.com'
  7073. }
  7074. };
  7075. /* eslint-disable spaced-comment */
  7076. defaultOptions.chart.styledMode = false;
  7077. '';
  7078. var defaultTime = new Time(merge(defaultOptions.global,
  7079. defaultOptions.time));
  7080. /**
  7081. * Get the updated default options. Until 3.0.7, merely exposing defaultOptions
  7082. * for outside modules wasn't enough because the setOptions method created a new
  7083. * object.
  7084. *
  7085. * @function Highcharts.getOptions
  7086. *
  7087. * @return {Highcharts.Options}
  7088. */
  7089. function getOptions() {
  7090. return defaultOptions;
  7091. }
  7092. /**
  7093. * Merge the default options with custom options and return the new options
  7094. * structure. Commonly used for defining reusable templates.
  7095. *
  7096. * @sample highcharts/global/useutc-false Setting a global option
  7097. * @sample highcharts/members/setoptions Applying a global theme
  7098. *
  7099. * @function Highcharts.setOptions
  7100. *
  7101. * @param {Highcharts.Options} options
  7102. * The new custom chart options.
  7103. *
  7104. * @return {Highcharts.Options}
  7105. * Updated options.
  7106. */
  7107. function setOptions(options) {
  7108. // Copy in the default options
  7109. merge(true, defaultOptions, options);
  7110. // Update the time object
  7111. if (options.time || options.global) {
  7112. if (H.time) {
  7113. H.time.update(merge(defaultOptions.global, defaultOptions.time, options.global, options.time));
  7114. }
  7115. else {
  7116. /**
  7117. * Global `Time` object with default options. Since v6.0.5, time
  7118. * settings can be applied individually for each chart. If no
  7119. * individual settings apply, this `Time` object is shared by all
  7120. * instances.
  7121. *
  7122. * @name Highcharts.time
  7123. * @type {Highcharts.Time}
  7124. */
  7125. H.time = defaultTime;
  7126. }
  7127. }
  7128. return defaultOptions;
  7129. }
  7130. /* *
  7131. *
  7132. * Default Export
  7133. *
  7134. * */
  7135. var DefaultOptions = {
  7136. defaultOptions: defaultOptions,
  7137. defaultTime: defaultTime,
  7138. getOptions: getOptions,
  7139. setOptions: setOptions
  7140. };
  7141. return DefaultOptions;
  7142. });
  7143. _registerModule(_modules, 'Core/Animation/Fx.js', [_modules['Core/Color/Color.js'], _modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (Color, H, U) {
  7144. /* *
  7145. *
  7146. * (c) 2010-2021 Torstein Honsi
  7147. *
  7148. * License: www.highcharts.com/license
  7149. *
  7150. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  7151. *
  7152. * */
  7153. var color = Color.parse;
  7154. var win = H.win;
  7155. var isNumber = U.isNumber,
  7156. objectEach = U.objectEach;
  7157. /* eslint-disable no-invalid-this, valid-jsdoc */
  7158. /**
  7159. * An animator object used internally. One instance applies to one property
  7160. * (attribute or style prop) on one element. Animation is always initiated
  7161. * through {@link SVGElement#animate}.
  7162. *
  7163. * @example
  7164. * let rect = renderer.rect(0, 0, 10, 10).add();
  7165. * rect.animate({ width: 100 });
  7166. *
  7167. * @private
  7168. * @class
  7169. * @name Highcharts.Fx
  7170. */
  7171. var Fx = /** @class */ (function () {
  7172. /* *
  7173. *
  7174. * Constructors
  7175. *
  7176. * */
  7177. /**
  7178. *
  7179. * @param {Highcharts.HTMLDOMElement|Highcharts.SVGElement} elem
  7180. * The element to animate.
  7181. *
  7182. * @param {Partial<Highcharts.AnimationOptionsObject>} options
  7183. * Animation options.
  7184. *
  7185. * @param {string} prop
  7186. * The single attribute or CSS property to animate.
  7187. */
  7188. function Fx(elem, options, prop) {
  7189. this.pos = NaN;
  7190. this.options = options;
  7191. this.elem = elem;
  7192. this.prop = prop;
  7193. }
  7194. /* *
  7195. *
  7196. * Functions
  7197. *
  7198. * */
  7199. /**
  7200. * Set the current step of a path definition on SVGElement.
  7201. *
  7202. * @function Highcharts.Fx#dSetter
  7203. *
  7204. * @return {void}
  7205. */
  7206. Fx.prototype.dSetter = function () {
  7207. var paths = this.paths,
  7208. start = paths && paths[0],
  7209. end = paths && paths[1],
  7210. now = this.now || 0;
  7211. var path = [];
  7212. // Land on the final path without adjustment points appended in the ends
  7213. if (now === 1 || !start || !end) {
  7214. path = this.toD || [];
  7215. }
  7216. else if (start.length === end.length && now < 1) {
  7217. for (var i = 0; i < end.length; i++) {
  7218. // Tween between the start segment and the end segment. Start
  7219. // with a copy of the end segment and tween the appropriate
  7220. // numerics
  7221. var startSeg = start[i];
  7222. var endSeg = end[i];
  7223. var tweenSeg = [];
  7224. for (var j = 0; j < endSeg.length; j++) {
  7225. var startItem = startSeg[j];
  7226. var endItem = endSeg[j];
  7227. // Tween numbers
  7228. if (isNumber(startItem) &&
  7229. isNumber(endItem) &&
  7230. // Arc boolean flags
  7231. !(endSeg[0] === 'A' && (j === 4 || j === 5))) {
  7232. tweenSeg[j] = startItem + now * (endItem - startItem);
  7233. // Strings, take directly from the end segment
  7234. }
  7235. else {
  7236. tweenSeg[j] = endItem;
  7237. }
  7238. }
  7239. path.push(tweenSeg);
  7240. }
  7241. // If animation is finished or length not matching, land on right value
  7242. }
  7243. else {
  7244. path = end;
  7245. }
  7246. this.elem.attr('d', path, void 0, true);
  7247. };
  7248. /**
  7249. * Update the element with the current animation step.
  7250. *
  7251. * @function Highcharts.Fx#update
  7252. *
  7253. * @return {void}
  7254. */
  7255. Fx.prototype.update = function () {
  7256. var elem = this.elem,
  7257. prop = this.prop, // if destroyed, it is null
  7258. now = this.now,
  7259. step = this.options.step;
  7260. // Animation setter defined from outside
  7261. if (this[prop + 'Setter']) {
  7262. this[prop + 'Setter']();
  7263. // Other animations on SVGElement
  7264. }
  7265. else if (elem.attr) {
  7266. if (elem.element) {
  7267. elem.attr(prop, now, null, true);
  7268. }
  7269. // HTML styles, raw HTML content like container size
  7270. }
  7271. else {
  7272. elem.style[prop] = now + this.unit;
  7273. }
  7274. if (step) {
  7275. step.call(elem, now, this);
  7276. }
  7277. };
  7278. /**
  7279. * Run an animation.
  7280. *
  7281. * @function Highcharts.Fx#run
  7282. *
  7283. * @param {number} from
  7284. * The current value, value to start from.
  7285. *
  7286. * @param {number} to
  7287. * The end value, value to land on.
  7288. *
  7289. * @param {string} unit
  7290. * The property unit, for example `px`.
  7291. *
  7292. * @return {void}
  7293. */
  7294. Fx.prototype.run = function (from, to, unit) {
  7295. var self = this,
  7296. options = self.options,
  7297. timer = function (gotoEnd) {
  7298. return timer.stopped ? false : self.step(gotoEnd);
  7299. }, requestAnimationFrame = win.requestAnimationFrame ||
  7300. function (step) {
  7301. setTimeout(step, 13);
  7302. }, step = function () {
  7303. for (var i = 0; i < Fx.timers.length; i++) {
  7304. if (!Fx.timers[i]()) {
  7305. Fx.timers.splice(i--, 1);
  7306. }
  7307. }
  7308. if (Fx.timers.length) {
  7309. requestAnimationFrame(step);
  7310. }
  7311. };
  7312. if (from === to && !this.elem['forceAnimate:' + this.prop]) {
  7313. delete options.curAnim[this.prop];
  7314. if (options.complete && Object.keys(options.curAnim).length === 0) {
  7315. options.complete.call(this.elem);
  7316. }
  7317. }
  7318. else { // #7166
  7319. this.startTime = +new Date();
  7320. this.start = from;
  7321. this.end = to;
  7322. this.unit = unit;
  7323. this.now = this.start;
  7324. this.pos = 0;
  7325. timer.elem = this.elem;
  7326. timer.prop = this.prop;
  7327. if (timer() && Fx.timers.push(timer) === 1) {
  7328. requestAnimationFrame(step);
  7329. }
  7330. }
  7331. };
  7332. /**
  7333. * Run a single step in the animation.
  7334. *
  7335. * @function Highcharts.Fx#step
  7336. *
  7337. * @param {boolean} [gotoEnd]
  7338. * Whether to go to the endpoint of the animation after abort.
  7339. *
  7340. * @return {boolean}
  7341. * Returns `true` if animation continues.
  7342. */
  7343. Fx.prototype.step = function (gotoEnd) {
  7344. var t = +new Date(),
  7345. options = this.options,
  7346. elem = this.elem,
  7347. complete = options.complete,
  7348. duration = options.duration,
  7349. curAnim = options.curAnim;
  7350. var ret,
  7351. done;
  7352. if (elem.attr && !elem.element) { // #2616, element is destroyed
  7353. ret = false;
  7354. }
  7355. else if (gotoEnd || t >= duration + this.startTime) {
  7356. this.now = this.end;
  7357. this.pos = 1;
  7358. this.update();
  7359. curAnim[this.prop] = true;
  7360. done = true;
  7361. objectEach(curAnim, function (val) {
  7362. if (val !== true) {
  7363. done = false;
  7364. }
  7365. });
  7366. if (done && complete) {
  7367. complete.call(elem);
  7368. }
  7369. ret = false;
  7370. }
  7371. else {
  7372. this.pos = options.easing((t - this.startTime) / duration);
  7373. this.now = this.start + ((this.end - this.start) * this.pos);
  7374. this.update();
  7375. ret = true;
  7376. }
  7377. return ret;
  7378. };
  7379. /**
  7380. * Prepare start and end values so that the path can be animated one to one.
  7381. *
  7382. * @function Highcharts.Fx#initPath
  7383. *
  7384. * @param {Highcharts.SVGElement} elem
  7385. * The SVGElement item.
  7386. *
  7387. * @param {Highcharts.SVGPathArray|undefined} fromD
  7388. * Starting path definition.
  7389. *
  7390. * @param {Highcharts.SVGPathArray} toD
  7391. * Ending path definition.
  7392. *
  7393. * @return {Array<Highcharts.SVGPathArray,Highcharts.SVGPathArray>}
  7394. * An array containing start and end paths in array form so that
  7395. * they can be animated in parallel.
  7396. */
  7397. Fx.prototype.initPath = function (elem, fromD, toD) {
  7398. var startX = elem.startX,
  7399. endX = elem.endX,
  7400. end = toD.slice(), // copy
  7401. isArea = elem.isArea,
  7402. positionFactor = isArea ? 2 : 1;
  7403. var shift,
  7404. fullLength,
  7405. i,
  7406. reverse,
  7407. start = fromD && fromD.slice(); // copy
  7408. if (!start) {
  7409. return [end,
  7410. end];
  7411. }
  7412. /**
  7413. * If shifting points, prepend a dummy point to the end path.
  7414. * @private
  7415. * @param {Highcharts.SVGPathArray} arr - array
  7416. * @param {Highcharts.SVGPathArray} other - array
  7417. * @return {void}
  7418. */
  7419. function prepend(arr, other) {
  7420. while (arr.length < fullLength) {
  7421. // Move to, line to or curve to?
  7422. var moveSegment = arr[0],
  7423. otherSegment = other[fullLength - arr.length];
  7424. if (otherSegment && moveSegment[0] === 'M') {
  7425. if (otherSegment[0] === 'C') {
  7426. arr[0] = [
  7427. 'C',
  7428. moveSegment[1],
  7429. moveSegment[2],
  7430. moveSegment[1],
  7431. moveSegment[2],
  7432. moveSegment[1],
  7433. moveSegment[2]
  7434. ];
  7435. }
  7436. else {
  7437. arr[0] = ['L', moveSegment[1], moveSegment[2]];
  7438. }
  7439. }
  7440. // Prepend a copy of the first point
  7441. arr.unshift(moveSegment);
  7442. // For areas, the bottom path goes back again to the left, so we
  7443. // need to append a copy of the last point.
  7444. if (isArea) {
  7445. var z = arr.pop();
  7446. arr.push(arr[arr.length - 1], z); // append point and the Z
  7447. }
  7448. }
  7449. }
  7450. /**
  7451. * Copy and append last point until the length matches the end length.
  7452. * @private
  7453. * @param {Highcharts.SVGPathArray} arr - array
  7454. * @param {Highcharts.SVGPathArray} other - array
  7455. * @return {void}
  7456. */
  7457. function append(arr, other) {
  7458. while (arr.length < fullLength) {
  7459. // Pull out the slice that is going to be appended or inserted.
  7460. // In a line graph, the positionFactor is 1, and the last point
  7461. // is sliced out. In an area graph, the positionFactor is 2,
  7462. // causing the middle two points to be sliced out, since an area
  7463. // path starts at left, follows the upper path then turns and
  7464. // follows the bottom back.
  7465. var segmentToAdd = arr[Math.floor(arr.length / positionFactor) - 1].slice();
  7466. // Disable the first control point of curve segments
  7467. if (segmentToAdd[0] === 'C') {
  7468. segmentToAdd[1] = segmentToAdd[5];
  7469. segmentToAdd[2] = segmentToAdd[6];
  7470. }
  7471. if (!isArea) {
  7472. arr.push(segmentToAdd);
  7473. }
  7474. else {
  7475. var lowerSegmentToAdd = arr[Math.floor(arr.length / positionFactor)].slice();
  7476. arr.splice(arr.length / 2, 0, segmentToAdd, lowerSegmentToAdd);
  7477. }
  7478. }
  7479. }
  7480. // For sideways animation, find out how much we need to shift to get the
  7481. // start path Xs to match the end path Xs.
  7482. if (startX && endX && endX.length) {
  7483. for (i = 0; i < startX.length; i++) {
  7484. // Moving left, new points coming in on right
  7485. if (startX[i] === endX[0]) {
  7486. shift = i;
  7487. break;
  7488. // Moving right
  7489. }
  7490. else if (startX[0] ===
  7491. endX[endX.length - startX.length + i]) {
  7492. shift = i;
  7493. reverse = true;
  7494. break;
  7495. // Fixed from the right side, "scaling" left
  7496. }
  7497. else if (startX[startX.length - 1] ===
  7498. endX[endX.length - startX.length + i]) {
  7499. shift = startX.length - i;
  7500. break;
  7501. }
  7502. }
  7503. if (typeof shift === 'undefined') {
  7504. start = [];
  7505. }
  7506. }
  7507. if (start.length && isNumber(shift)) {
  7508. // The common target length for the start and end array, where both
  7509. // arrays are padded in opposite ends
  7510. fullLength = end.length + shift * positionFactor;
  7511. if (!reverse) {
  7512. prepend(end, start);
  7513. append(start, end);
  7514. }
  7515. else {
  7516. prepend(start, end);
  7517. append(end, start);
  7518. }
  7519. }
  7520. return [start, end];
  7521. };
  7522. /**
  7523. * Handle animation of the color attributes directly.
  7524. *
  7525. * @function Highcharts.Fx#fillSetter
  7526. *
  7527. * @return {void}
  7528. */
  7529. Fx.prototype.fillSetter = function () {
  7530. Fx.prototype.strokeSetter.apply(this, arguments);
  7531. };
  7532. /**
  7533. * Handle animation of the color attributes directly.
  7534. *
  7535. * @function Highcharts.Fx#strokeSetter
  7536. *
  7537. * @return {void}
  7538. */
  7539. Fx.prototype.strokeSetter = function () {
  7540. this.elem.attr(this.prop, color(this.start).tweenTo(color(this.end), this.pos), null, true);
  7541. };
  7542. /* *
  7543. *
  7544. * Static properties
  7545. *
  7546. * */
  7547. Fx.timers = [];
  7548. return Fx;
  7549. }());
  7550. /* *
  7551. *
  7552. * Default Export
  7553. *
  7554. * */
  7555. return Fx;
  7556. });
  7557. _registerModule(_modules, 'Core/Animation/AnimationUtilities.js', [_modules['Core/Animation/Fx.js'], _modules['Core/Utilities.js']], function (Fx, U) {
  7558. /* *
  7559. *
  7560. * (c) 2010-2021 Torstein Honsi
  7561. *
  7562. * License: www.highcharts.com/license
  7563. *
  7564. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  7565. *
  7566. * */
  7567. var defined = U.defined,
  7568. getStyle = U.getStyle,
  7569. isArray = U.isArray,
  7570. isNumber = U.isNumber,
  7571. isObject = U.isObject,
  7572. merge = U.merge,
  7573. objectEach = U.objectEach,
  7574. pick = U.pick;
  7575. /**
  7576. * Set the global animation to either a given value, or fall back to the given
  7577. * chart's animation option.
  7578. *
  7579. * @function Highcharts.setAnimation
  7580. *
  7581. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>|undefined} animation
  7582. * The animation object.
  7583. *
  7584. * @param {Highcharts.Chart} chart
  7585. * The chart instance.
  7586. *
  7587. * @todo
  7588. * This function always relates to a chart, and sets a property on the renderer,
  7589. * so it should be moved to the SVGRenderer.
  7590. */
  7591. function setAnimation(animation, chart) {
  7592. chart.renderer.globalAnimation = pick(animation, chart.options.chart.animation, true);
  7593. }
  7594. /**
  7595. * Get the animation in object form, where a disabled animation is always
  7596. * returned as `{ duration: 0 }`.
  7597. *
  7598. * @function Highcharts.animObject
  7599. *
  7600. * @param {boolean|Highcharts.AnimationOptionsObject} [animation=0]
  7601. * An animation setting. Can be an object with duration, complete and
  7602. * easing properties, or a boolean to enable or disable.
  7603. *
  7604. * @return {Highcharts.AnimationOptionsObject}
  7605. * An object with at least a duration property.
  7606. */
  7607. function animObject(animation) {
  7608. return isObject(animation) ?
  7609. merge({ duration: 500, defer: 0 }, animation) :
  7610. { duration: animation ? 500 : 0, defer: 0 };
  7611. }
  7612. /**
  7613. * Get the defer as a number value from series animation options.
  7614. *
  7615. * @function Highcharts.getDeferredAnimation
  7616. *
  7617. * @param {Highcharts.Chart} chart
  7618. * The chart instance.
  7619. *
  7620. * @param {boolean|Highcharts.AnimationOptionsObject} animation
  7621. * An animation setting. Can be an object with duration, complete and
  7622. * easing properties, or a boolean to enable or disable.
  7623. *
  7624. * @param {Highcharts.Series} [series]
  7625. * Series to defer animation.
  7626. *
  7627. * @return {number}
  7628. * The numeric value.
  7629. */
  7630. function getDeferredAnimation(chart, animation, series) {
  7631. var labelAnimation = animObject(animation);
  7632. var s = series ? [series] : chart.series;
  7633. var defer = 0;
  7634. var duration = 0;
  7635. s.forEach(function (series) {
  7636. var seriesAnim = animObject(series.options.animation);
  7637. defer = animation && defined(animation.defer) ?
  7638. labelAnimation.defer :
  7639. Math.max(defer, seriesAnim.duration + seriesAnim.defer);
  7640. duration = Math.min(labelAnimation.duration, seriesAnim.duration);
  7641. });
  7642. // Disable defer for exporting
  7643. if (chart.renderer.forExport) {
  7644. defer = 0;
  7645. }
  7646. var anim = {
  7647. defer: Math.max(0,
  7648. defer - duration),
  7649. duration: Math.min(defer,
  7650. duration)
  7651. };
  7652. return anim;
  7653. }
  7654. /**
  7655. * The global animate method, which uses Fx to create individual animators.
  7656. *
  7657. * @function Highcharts.animate
  7658. *
  7659. * @param {Highcharts.HTMLDOMElement|Highcharts.SVGElement} el
  7660. * The element to animate.
  7661. *
  7662. * @param {Highcharts.CSSObject|Highcharts.SVGAttributes} params
  7663. * An object containing key-value pairs of the properties to animate.
  7664. * Supports numeric as pixel-based CSS properties for HTML objects and
  7665. * attributes for SVGElements.
  7666. *
  7667. * @param {Partial<Highcharts.AnimationOptionsObject>} [opt]
  7668. * Animation options.
  7669. *
  7670. * @return {void}
  7671. */
  7672. function animate(el, params, opt) {
  7673. var start,
  7674. unit = '',
  7675. end,
  7676. fx,
  7677. args;
  7678. if (!isObject(opt)) { // Number or undefined/null
  7679. args = arguments;
  7680. opt = {
  7681. duration: args[2],
  7682. easing: args[3],
  7683. complete: args[4]
  7684. };
  7685. }
  7686. if (!isNumber(opt.duration)) {
  7687. opt.duration = 400;
  7688. }
  7689. opt.easing = typeof opt.easing === 'function' ?
  7690. opt.easing :
  7691. (Math[opt.easing] || Math.easeInOutSine);
  7692. opt.curAnim = merge(params);
  7693. objectEach(params, function (val, prop) {
  7694. // Stop current running animation of this property
  7695. stop(el, prop);
  7696. fx = new Fx(el, opt, prop);
  7697. end = void 0;
  7698. if (prop === 'd' && isArray(params.d)) {
  7699. fx.paths = fx.initPath(el, el.pathArray, params.d);
  7700. fx.toD = params.d;
  7701. start = 0;
  7702. end = 1;
  7703. }
  7704. else if (el.attr) {
  7705. start = el.attr(prop);
  7706. }
  7707. else {
  7708. start = parseFloat(getStyle(el, prop)) || 0;
  7709. if (prop !== 'opacity') {
  7710. unit = 'px';
  7711. }
  7712. }
  7713. if (!end) {
  7714. end = val;
  7715. }
  7716. if (typeof end === 'string' && end.match('px')) {
  7717. end = end.replace(/px/g, ''); // #4351
  7718. }
  7719. fx.run(start, end, unit);
  7720. });
  7721. }
  7722. /**
  7723. * Stop running animation.
  7724. *
  7725. * @function Highcharts.stop
  7726. *
  7727. * @param {Highcharts.SVGElement} el
  7728. * The SVGElement to stop animation on.
  7729. *
  7730. * @param {string} [prop]
  7731. * The property to stop animating. If given, the stop method will stop a
  7732. * single property from animating, while others continue.
  7733. *
  7734. * @return {void}
  7735. *
  7736. * @todo
  7737. * A possible extension to this would be to stop a single property, when
  7738. * we want to continue animating others. Then assign the prop to the timer
  7739. * in the Fx.run method, and check for the prop here. This would be an
  7740. * improvement in all cases where we stop the animation from .attr. Instead of
  7741. * stopping everything, we can just stop the actual attributes we're setting.
  7742. */
  7743. function stop(el, prop) {
  7744. var i = Fx.timers.length;
  7745. // Remove timers related to this element (#4519)
  7746. while (i--) {
  7747. if (Fx.timers[i].elem === el && (!prop || prop === Fx.timers[i].prop)) {
  7748. Fx.timers[i].stopped = true; // #4667
  7749. }
  7750. }
  7751. }
  7752. var animationExports = {
  7753. animate: animate,
  7754. animObject: animObject,
  7755. getDeferredAnimation: getDeferredAnimation,
  7756. setAnimation: setAnimation,
  7757. stop: stop
  7758. };
  7759. return animationExports;
  7760. });
  7761. _registerModule(_modules, 'Core/Renderer/HTML/AST.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  7762. /* *
  7763. *
  7764. * (c) 2010-2020 Torstein Honsi
  7765. *
  7766. * License: www.highcharts.com/license
  7767. *
  7768. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  7769. *
  7770. * */
  7771. var SVG_NS = H.SVG_NS;
  7772. var attr = U.attr,
  7773. createElement = U.createElement,
  7774. discardElement = U.discardElement,
  7775. error = U.error,
  7776. isString = U.isString,
  7777. objectEach = U.objectEach,
  7778. splat = U.splat;
  7779. /* *
  7780. *
  7781. * Constants
  7782. *
  7783. * */
  7784. // In IE8, DOMParser is undefined. IE9 and PhantomJS are only able to parse XML.
  7785. var hasValidDOMParser = (function () {
  7786. try {
  7787. return Boolean(new DOMParser().parseFromString('', 'text/html'));
  7788. }
  7789. catch (e) {
  7790. return false;
  7791. }
  7792. }());
  7793. /* *
  7794. *
  7795. * Class
  7796. *
  7797. * */
  7798. /**
  7799. * The AST class represents an abstract syntax tree of HTML or SVG content. It
  7800. * can take HTML as an argument, parse it, optionally transform it to SVG, then
  7801. * perform sanitation before inserting it into the DOM.
  7802. *
  7803. * @class
  7804. * @name Highcharts.AST
  7805. *
  7806. * @param {string|Array<Highcharts.ASTNode>} source
  7807. * Either an HTML string or an ASTNode list to populate the tree.
  7808. */
  7809. var AST = /** @class */ (function () {
  7810. // Construct an AST from HTML markup, or wrap an array of existing AST nodes
  7811. function AST(source) {
  7812. this.nodes = typeof source === 'string' ?
  7813. this.parseMarkup(source) : source;
  7814. }
  7815. /**
  7816. * Filter an object of SVG or HTML attributes against the allow list.
  7817. *
  7818. * @static
  7819. *
  7820. * @function Highcharts.AST#filterUserAttributes
  7821. *
  7822. * @param {Highcharts.SVGAttributes} attributes The attributes to filter
  7823. *
  7824. * @return {Highcharts.SVGAttributes}
  7825. * The filtered attributes
  7826. */
  7827. AST.filterUserAttributes = function (attributes) {
  7828. objectEach(attributes, function (val, key) {
  7829. var valid = true;
  7830. if (AST.allowedAttributes.indexOf(key) === -1) {
  7831. valid = false;
  7832. }
  7833. if (['background', 'dynsrc', 'href', 'lowsrc', 'src']
  7834. .indexOf(key) !== -1) {
  7835. valid = isString(val) && AST.allowedReferences.some(function (ref) { return val.indexOf(ref) === 0; });
  7836. }
  7837. if (!valid) {
  7838. error("Highcharts warning: Invalid attribute '" + key + "' in config");
  7839. delete attributes[key];
  7840. }
  7841. });
  7842. return attributes;
  7843. };
  7844. /**
  7845. * Utility function to set html content for an element by passing in a
  7846. * markup string. The markup is safely parsed by the AST class to avoid
  7847. * XSS vulnerabilities. This function should be used instead of setting
  7848. * `innerHTML` in all cases where the content is not fully trusted.
  7849. *
  7850. * @static
  7851. *
  7852. * @function Highcharts.AST#setElementHTML
  7853. *
  7854. * @param {SVGDOMElement|HTMLDOMElement} el The node to set content of
  7855. * @param {string} html The markup string
  7856. */
  7857. AST.setElementHTML = function (el, html) {
  7858. el.innerHTML = ''; // Clear previous
  7859. if (html) {
  7860. var ast = new AST(html);
  7861. ast.addToDOM(el);
  7862. }
  7863. };
  7864. /**
  7865. * Add the tree defined as a hierarchical JS structure to the DOM
  7866. *
  7867. * @function Highcharts.AST#addToDOM
  7868. *
  7869. * @param {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement} parent
  7870. * The node where it should be added
  7871. *
  7872. * @return {Highcharts.HTMLDOMElement|Highcharts.SVGDOMElement}
  7873. * The inserted node.
  7874. */
  7875. AST.prototype.addToDOM = function (parent) {
  7876. /**
  7877. * @private
  7878. * @param {Highcharts.ASTNode} subtree - HTML/SVG definition
  7879. * @param {Element} [subParent] - parent node
  7880. * @return {Highcharts.SVGDOMElement|Highcharts.HTMLDOMElement} The inserted node.
  7881. */
  7882. function recurse(subtree, subParent) {
  7883. var ret;
  7884. splat(subtree).forEach(function (item) {
  7885. var tagName = item.tagName;
  7886. var textNode = item.textContent ?
  7887. H.doc.createTextNode(item.textContent) :
  7888. void 0;
  7889. var node;
  7890. if (tagName) {
  7891. if (tagName === '#text') {
  7892. node = textNode;
  7893. }
  7894. else if (AST.allowedTags.indexOf(tagName) !== -1) {
  7895. var NS = tagName === 'svg' ?
  7896. SVG_NS :
  7897. (subParent.namespaceURI || SVG_NS);
  7898. var element = H.doc.createElementNS(NS,
  7899. tagName);
  7900. var attributes_1 = item.attributes || {};
  7901. // Apply attributes from root of AST node, legacy from
  7902. // from before TextBuilder
  7903. objectEach(item, function (val, key) {
  7904. if (key !== 'tagName' &&
  7905. key !== 'attributes' &&
  7906. key !== 'children' &&
  7907. key !== 'textContent') {
  7908. attributes_1[key] = val;
  7909. }
  7910. });
  7911. attr(element, AST.filterUserAttributes(attributes_1));
  7912. // Add text content
  7913. if (textNode) {
  7914. element.appendChild(textNode);
  7915. }
  7916. // Recurse
  7917. recurse(item.children || [], element);
  7918. node = element;
  7919. }
  7920. else {
  7921. error("Highcharts warning: Invalid tagName '" + tagName + "' in config");
  7922. }
  7923. }
  7924. // Add to the tree
  7925. if (node) {
  7926. subParent.appendChild(node);
  7927. }
  7928. ret = node;
  7929. });
  7930. // Return last node added (on top level it's the only one)
  7931. return ret;
  7932. }
  7933. return recurse(this.nodes, parent);
  7934. };
  7935. /**
  7936. * Parse HTML/SVG markup into AST Node objects. Used internally from the
  7937. * constructor.
  7938. *
  7939. * @private
  7940. *
  7941. * @function Highcharts.AST#getNodesFromMarkup
  7942. *
  7943. * @param {string} markup The markup string.
  7944. *
  7945. * @return {Array<Highcharts.ASTNode>} The parsed nodes.
  7946. */
  7947. AST.prototype.parseMarkup = function (markup) {
  7948. var nodes = [];
  7949. var doc;
  7950. var body;
  7951. if (hasValidDOMParser) {
  7952. doc = new DOMParser().parseFromString(markup, 'text/html');
  7953. }
  7954. else {
  7955. body = createElement('div');
  7956. body.innerHTML = markup;
  7957. doc = { body: body };
  7958. }
  7959. var appendChildNodes = function (node,
  7960. addTo) {
  7961. var tagName = node.nodeName.toLowerCase();
  7962. // Add allowed tags
  7963. var astNode = {
  7964. tagName: tagName
  7965. };
  7966. if (tagName === '#text') {
  7967. var textContent = node.textContent || '';
  7968. // Whitespace text node, don't append it to the AST
  7969. if (/^[\s]*$/.test(textContent)) {
  7970. return;
  7971. }
  7972. astNode.textContent = textContent;
  7973. }
  7974. var parsedAttributes = node.attributes;
  7975. // Add attributes
  7976. if (parsedAttributes) {
  7977. var attributes_2 = {};
  7978. [].forEach.call(parsedAttributes, function (attrib) {
  7979. attributes_2[attrib.name] = attrib.value;
  7980. });
  7981. astNode.attributes = attributes_2;
  7982. }
  7983. // Handle children
  7984. if (node.childNodes.length) {
  7985. var children_1 = [];
  7986. [].forEach.call(node.childNodes, function (childNode) {
  7987. appendChildNodes(childNode, children_1);
  7988. });
  7989. if (children_1.length) {
  7990. astNode.children = children_1;
  7991. }
  7992. }
  7993. addTo.push(astNode);
  7994. };
  7995. [].forEach.call(doc.body.childNodes, function (childNode) { return appendChildNodes(childNode, nodes); });
  7996. if (body) {
  7997. discardElement(body);
  7998. }
  7999. return nodes;
  8000. };
  8001. /**
  8002. * The list of allowed SVG or HTML tags, used for sanitizing potentially
  8003. * harmful content from the chart configuration before adding to the DOM.
  8004. *
  8005. * @example
  8006. * // Allow a custom, trusted tag
  8007. * Highcharts.AST.allowedTags.push('blink'); // ;)
  8008. *
  8009. * @name Highcharts.AST.allowedTags
  8010. * @static
  8011. */
  8012. AST.allowedTags = [
  8013. 'a',
  8014. 'b',
  8015. 'br',
  8016. 'button',
  8017. 'caption',
  8018. 'circle',
  8019. 'clipPath',
  8020. 'code',
  8021. 'dd',
  8022. 'defs',
  8023. 'div',
  8024. 'dl',
  8025. 'dt',
  8026. 'em',
  8027. 'feComponentTransfer',
  8028. 'feFuncA',
  8029. 'feFuncB',
  8030. 'feFuncG',
  8031. 'feFuncR',
  8032. 'feGaussianBlur',
  8033. 'feOffset',
  8034. 'feMerge',
  8035. 'feMergeNode',
  8036. 'filter',
  8037. 'h1',
  8038. 'h2',
  8039. 'h3',
  8040. 'h4',
  8041. 'h5',
  8042. 'h6',
  8043. 'hr',
  8044. 'i',
  8045. 'img',
  8046. 'li',
  8047. 'linearGradient',
  8048. 'marker',
  8049. 'ol',
  8050. 'p',
  8051. 'path',
  8052. 'pattern',
  8053. 'pre',
  8054. 'rect',
  8055. 'small',
  8056. 'span',
  8057. 'stop',
  8058. 'strong',
  8059. 'style',
  8060. 'sub',
  8061. 'sup',
  8062. 'svg',
  8063. 'table',
  8064. 'text',
  8065. 'thead',
  8066. 'tbody',
  8067. 'tspan',
  8068. 'td',
  8069. 'th',
  8070. 'tr',
  8071. 'u',
  8072. 'ul',
  8073. '#text'
  8074. ];
  8075. /**
  8076. * The list of allowed SVG or HTML attributes, used for sanitizing
  8077. * potentially harmful content from the chart configuration before adding to
  8078. * the DOM.
  8079. *
  8080. * @example
  8081. * // Allow a custom, trusted attribute
  8082. * Highcharts.AST.allowedAttributes.push('data-value');
  8083. *
  8084. * @name Highcharts.AST.allowedAttributes
  8085. * @static
  8086. */
  8087. AST.allowedAttributes = [
  8088. 'aria-controls',
  8089. 'aria-describedby',
  8090. 'aria-expanded',
  8091. 'aria-haspopup',
  8092. 'aria-hidden',
  8093. 'aria-label',
  8094. 'aria-labelledby',
  8095. 'aria-live',
  8096. 'aria-pressed',
  8097. 'aria-readonly',
  8098. 'aria-roledescription',
  8099. 'aria-selected',
  8100. 'class',
  8101. 'clip-path',
  8102. 'color',
  8103. 'colspan',
  8104. 'cx',
  8105. 'cy',
  8106. 'd',
  8107. 'dx',
  8108. 'dy',
  8109. 'disabled',
  8110. 'fill',
  8111. 'height',
  8112. 'href',
  8113. 'id',
  8114. 'in',
  8115. 'markerHeight',
  8116. 'markerWidth',
  8117. 'offset',
  8118. 'opacity',
  8119. 'orient',
  8120. 'padding',
  8121. 'paddingLeft',
  8122. 'paddingRight',
  8123. 'patternUnits',
  8124. 'r',
  8125. 'refX',
  8126. 'refY',
  8127. 'role',
  8128. 'scope',
  8129. 'slope',
  8130. 'src',
  8131. 'startOffset',
  8132. 'stdDeviation',
  8133. 'stroke',
  8134. 'stroke-linecap',
  8135. 'stroke-width',
  8136. 'style',
  8137. 'tableValues',
  8138. 'result',
  8139. 'rowspan',
  8140. 'summary',
  8141. 'target',
  8142. 'tabindex',
  8143. 'text-align',
  8144. 'textAnchor',
  8145. 'textLength',
  8146. 'type',
  8147. 'valign',
  8148. 'width',
  8149. 'x',
  8150. 'x1',
  8151. 'x2',
  8152. 'y',
  8153. 'y1',
  8154. 'y2',
  8155. 'zIndex'
  8156. ];
  8157. /**
  8158. * The list of allowed references for referring attributes like `href` and
  8159. * `src`. Attribute values will only be allowed if they start with one of
  8160. * these strings.
  8161. *
  8162. * @example
  8163. * // Allow tel:
  8164. * Highcharts.AST.allowedReferences.push('tel:');
  8165. *
  8166. * @name Highcharts.AST.allowedReferences
  8167. * @static
  8168. */
  8169. AST.allowedReferences = [
  8170. 'https://',
  8171. 'http://',
  8172. 'mailto:',
  8173. '/',
  8174. '../',
  8175. './',
  8176. '#'
  8177. ];
  8178. return AST;
  8179. }());
  8180. /* *
  8181. *
  8182. * Default Export
  8183. *
  8184. * */
  8185. /* *
  8186. *
  8187. * API Declarations
  8188. *
  8189. * */
  8190. /**
  8191. * Serialized form of an SVG/HTML definition, including children.
  8192. *
  8193. * @interface Highcharts.ASTNode
  8194. */ /**
  8195. * @name Highcharts.ASTNode#attributes
  8196. * @type {Highcharts.SVGAttributes|undefined}
  8197. */ /**
  8198. * @name Highcharts.ASTNode#children
  8199. * @type {Array<Highcharts.ASTNode>|undefined}
  8200. */ /**
  8201. * @name Highcharts.ASTNode#tagName
  8202. * @type {string|undefined}
  8203. */ /**
  8204. * @name Highcharts.ASTNode#textContent
  8205. * @type {string|undefined}
  8206. */
  8207. ''; // detach doclets above
  8208. return AST;
  8209. });
  8210. _registerModule(_modules, 'Core/FormatUtilities.js', [_modules['Core/DefaultOptions.js'], _modules['Core/Utilities.js']], function (D, U) {
  8211. /* *
  8212. *
  8213. * (c) 2010-2021 Torstein Honsi
  8214. *
  8215. * License: www.highcharts.com/license
  8216. *
  8217. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  8218. *
  8219. * */
  8220. var defaultOptions = D.defaultOptions,
  8221. defaultTime = D.defaultTime;
  8222. var getNestedProperty = U.getNestedProperty,
  8223. isNumber = U.isNumber,
  8224. pick = U.pick,
  8225. pInt = U.pInt;
  8226. /* *
  8227. *
  8228. * Functions
  8229. *
  8230. * */
  8231. /**
  8232. * Formats a JavaScript date timestamp (milliseconds since Jan 1st 1970) into a
  8233. * human readable date string. The format is a subset of the formats for PHP's
  8234. * [strftime](https://www.php.net/manual/en/function.strftime.php) function.
  8235. * Additional formats can be given in the {@link Highcharts.dateFormats} hook.
  8236. *
  8237. * Since v6.0.5, all internal dates are formatted through the
  8238. * {@link Highcharts.Chart#time} instance to respect chart-level time settings.
  8239. * The `Highcharts.dateFormat` function only reflects global time settings set
  8240. * with `setOptions`.
  8241. *
  8242. * Supported format keys:
  8243. * - `%a`: Short weekday, like 'Mon'
  8244. * - `%A`: Long weekday, like 'Monday'
  8245. * - `%d`: Two digit day of the month, 01 to 31
  8246. * - `%e`: Day of the month, 1 through 31
  8247. * - `%w`: Day of the week, 0 through 6
  8248. * - `%b`: Short month, like 'Jan'
  8249. * - `%B`: Long month, like 'January'
  8250. * - `%m`: Two digit month number, 01 through 12
  8251. * - `%y`: Two digits year, like 09 for 2009
  8252. * - `%Y`: Four digits year, like 2009
  8253. * - `%H`: Two digits hours in 24h format, 00 through 23
  8254. * - `%k`: Hours in 24h format, 0 through 23
  8255. * - `%I`: Two digits hours in 12h format, 00 through 11
  8256. * - `%l`: Hours in 12h format, 1 through 12
  8257. * - `%M`: Two digits minutes, 00 through 59
  8258. * - `%p`: Upper case AM or PM
  8259. * - `%P`: Lower case AM or PM
  8260. * - `%S`: Two digits seconds, 00 through 59
  8261. * - `%L`: Milliseconds (naming from Ruby)
  8262. *
  8263. * @function Highcharts.dateFormat
  8264. *
  8265. * @param {string} format
  8266. * The desired format where various time representations are prefixed
  8267. * with `%`.
  8268. *
  8269. * @param {number} timestamp
  8270. * The JavaScript timestamp.
  8271. *
  8272. * @param {boolean} [capitalize=false]
  8273. * Upper case first letter in the return.
  8274. *
  8275. * @return {string}
  8276. * The formatted date.
  8277. */
  8278. function dateFormat(format, timestamp, capitalize) {
  8279. return defaultTime.dateFormat(format, timestamp, capitalize);
  8280. }
  8281. /**
  8282. * Format a string according to a subset of the rules of Python's String.format
  8283. * method.
  8284. *
  8285. * @example
  8286. * let s = Highcharts.format(
  8287. * 'The {color} fox was {len:.2f} feet long',
  8288. * { color: 'red', len: Math.PI }
  8289. * );
  8290. * // => The red fox was 3.14 feet long
  8291. *
  8292. * @function Highcharts.format
  8293. *
  8294. * @param {string} str
  8295. * The string to format.
  8296. *
  8297. * @param {Record<string, *>} ctx
  8298. * The context, a collection of key-value pairs where each key is
  8299. * replaced by its value.
  8300. *
  8301. * @param {Highcharts.Chart} [chart]
  8302. * A `Chart` instance used to get numberFormatter and time.
  8303. *
  8304. * @return {string}
  8305. * The formatted string.
  8306. */
  8307. function format(str, ctx, chart) {
  8308. var splitter = '{',
  8309. isInside = false,
  8310. segment,
  8311. valueAndFormat,
  8312. val,
  8313. index;
  8314. var floatRegex = /f$/;
  8315. var decRegex = /\.([0-9])/;
  8316. var lang = defaultOptions.lang;
  8317. var time = chart && chart.time || defaultTime;
  8318. var numberFormatter = chart && chart.numberFormatter || numberFormat;
  8319. var ret = [];
  8320. while (str) {
  8321. index = str.indexOf(splitter);
  8322. if (index === -1) {
  8323. break;
  8324. }
  8325. segment = str.slice(0, index);
  8326. if (isInside) { // we're on the closing bracket looking back
  8327. valueAndFormat = segment.split(':');
  8328. val = getNestedProperty(valueAndFormat.shift() || '', ctx);
  8329. // Format the replacement
  8330. if (valueAndFormat.length && typeof val === 'number') {
  8331. segment = valueAndFormat.join(':');
  8332. if (floatRegex.test(segment)) { // float
  8333. var decimals = parseInt((segment.match(decRegex) || ['', '-1'])[1], 10);
  8334. if (val !== null) {
  8335. val = numberFormatter(val, decimals, lang.decimalPoint, segment.indexOf(',') > -1 ? lang.thousandsSep : '');
  8336. }
  8337. }
  8338. else {
  8339. val = time.dateFormat(segment, val);
  8340. }
  8341. }
  8342. // Push the result and advance the cursor
  8343. ret.push(val);
  8344. }
  8345. else {
  8346. ret.push(segment);
  8347. }
  8348. str = str.slice(index + 1); // the rest
  8349. isInside = !isInside; // toggle
  8350. splitter = isInside ? '}' : '{'; // now look for next matching bracket
  8351. }
  8352. ret.push(str);
  8353. return ret.join('');
  8354. }
  8355. /**
  8356. * Format a number and return a string based on input settings.
  8357. *
  8358. * @sample highcharts/members/highcharts-numberformat/
  8359. * Custom number format
  8360. *
  8361. * @function Highcharts.numberFormat
  8362. *
  8363. * @param {number} number
  8364. * The input number to format.
  8365. *
  8366. * @param {number} decimals
  8367. * The amount of decimals. A value of -1 preserves the amount in the
  8368. * input number.
  8369. *
  8370. * @param {string} [decimalPoint]
  8371. * The decimal point, defaults to the one given in the lang options, or
  8372. * a dot.
  8373. *
  8374. * @param {string} [thousandsSep]
  8375. * The thousands separator, defaults to the one given in the lang
  8376. * options, or a space character.
  8377. *
  8378. * @return {string}
  8379. * The formatted number.
  8380. */
  8381. function numberFormat(number, decimals, decimalPoint, thousandsSep) {
  8382. number = +number || 0;
  8383. decimals = +decimals;
  8384. var ret,
  8385. fractionDigits;
  8386. var lang = defaultOptions.lang, origDec = (number.toString().split('.')[1] || '').split('e')[0].length, exponent = number.toString().split('e'), firstDecimals = decimals;
  8387. if (decimals === -1) {
  8388. // Preserve decimals. Not huge numbers (#3793).
  8389. decimals = Math.min(origDec, 20);
  8390. }
  8391. else if (!isNumber(decimals)) {
  8392. decimals = 2;
  8393. }
  8394. else if (decimals && exponent[1] && exponent[1] < 0) {
  8395. // Expose decimals from exponential notation (#7042)
  8396. fractionDigits = decimals + +exponent[1];
  8397. if (fractionDigits >= 0) {
  8398. // remove too small part of the number while keeping the notation
  8399. exponent[0] = (+exponent[0]).toExponential(fractionDigits)
  8400. .split('e')[0];
  8401. decimals = fractionDigits;
  8402. }
  8403. else {
  8404. // fractionDigits < 0
  8405. exponent[0] = exponent[0].split('.')[0] || 0;
  8406. if (decimals < 20) {
  8407. // use number instead of exponential notation (#7405)
  8408. number = (exponent[0] * Math.pow(10, exponent[1]))
  8409. .toFixed(decimals);
  8410. }
  8411. else {
  8412. // or zero
  8413. number = 0;
  8414. }
  8415. exponent[1] = 0;
  8416. }
  8417. }
  8418. // Add another decimal to avoid rounding errors of float numbers. (#4573)
  8419. // Then use toFixed to handle rounding.
  8420. var roundedNumber = (Math.abs(exponent[1] ? exponent[0] : number) +
  8421. Math.pow(10, -Math.max(decimals,
  8422. origDec) - 1)).toFixed(decimals);
  8423. // A string containing the positive integer component of the number
  8424. var strinteger = String(pInt(roundedNumber));
  8425. // Leftover after grouping into thousands. Can be 0, 1 or 2.
  8426. var thousands = strinteger.length > 3 ? strinteger.length % 3 : 0;
  8427. // Language
  8428. decimalPoint = pick(decimalPoint, lang.decimalPoint);
  8429. thousandsSep = pick(thousandsSep, lang.thousandsSep);
  8430. // Start building the return
  8431. ret = number < 0 ? '-' : '';
  8432. // Add the leftover after grouping into thousands. For example, in the
  8433. // number 42 000 000, this line adds 42.
  8434. ret += thousands ? strinteger.substr(0, thousands) + thousandsSep : '';
  8435. if (+exponent[1] < 0 && !firstDecimals) {
  8436. ret = '0';
  8437. }
  8438. else {
  8439. // Add the remaining thousands groups, joined by the thousands separator
  8440. ret += strinteger
  8441. .substr(thousands)
  8442. .replace(/(\d{3})(?=\d)/g, '$1' + thousandsSep);
  8443. }
  8444. // Add the decimal point and the decimal component
  8445. if (decimals) {
  8446. // Get the decimal component
  8447. ret += decimalPoint + roundedNumber.slice(-decimals);
  8448. }
  8449. if (exponent[1] && +ret !== 0) {
  8450. ret += 'e' + exponent[1];
  8451. }
  8452. return ret;
  8453. }
  8454. /* *
  8455. *
  8456. * Default Export
  8457. *
  8458. * */
  8459. var FormatUtilities = {
  8460. dateFormat: dateFormat,
  8461. format: format,
  8462. numberFormat: numberFormat
  8463. };
  8464. return FormatUtilities;
  8465. });
  8466. _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) {
  8467. /* *
  8468. *
  8469. * (c) 2010-2021 Torstein Honsi
  8470. *
  8471. * License: www.highcharts.com/license
  8472. *
  8473. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  8474. *
  8475. * */
  8476. var animate = A.animate,
  8477. animObject = A.animObject,
  8478. stop = A.stop;
  8479. var deg2rad = H.deg2rad,
  8480. doc = H.doc,
  8481. hasTouch = H.hasTouch,
  8482. noop = H.noop,
  8483. svg = H.svg,
  8484. SVG_NS = H.SVG_NS,
  8485. win = H.win;
  8486. var addEvent = U.addEvent,
  8487. attr = U.attr,
  8488. createElement = U.createElement,
  8489. css = U.css,
  8490. defined = U.defined,
  8491. erase = U.erase,
  8492. extend = U.extend,
  8493. fireEvent = U.fireEvent,
  8494. isArray = U.isArray,
  8495. isFunction = U.isFunction,
  8496. isNumber = U.isNumber,
  8497. isString = U.isString,
  8498. merge = U.merge,
  8499. objectEach = U.objectEach,
  8500. pick = U.pick,
  8501. pInt = U.pInt,
  8502. syncTimeout = U.syncTimeout,
  8503. uniqueKey = U.uniqueKey;
  8504. /* *
  8505. *
  8506. * Class
  8507. *
  8508. * */
  8509. /* eslint-disable no-invalid-this, valid-jsdoc */
  8510. /**
  8511. * The SVGElement prototype is a JavaScript wrapper for SVG elements used in the
  8512. * rendering layer of Highcharts. Combined with the
  8513. * {@link Highcharts.SVGRenderer}
  8514. * object, these prototypes allow freeform annotation in the charts or even in
  8515. * HTML pages without instanciating a chart. The SVGElement can also wrap HTML
  8516. * labels, when `text` or `label` elements are created with the `useHTML`
  8517. * parameter.
  8518. *
  8519. * The SVGElement instances are created through factory functions on the
  8520. * {@link Highcharts.SVGRenderer}
  8521. * object, like
  8522. * {@link Highcharts.SVGRenderer#rect|rect},
  8523. * {@link Highcharts.SVGRenderer#path|path},
  8524. * {@link Highcharts.SVGRenderer#text|text},
  8525. * {@link Highcharts.SVGRenderer#label|label},
  8526. * {@link Highcharts.SVGRenderer#g|g}
  8527. * and more.
  8528. *
  8529. * @class
  8530. * @name Highcharts.SVGElement
  8531. */
  8532. var SVGElement = /** @class */ (function () {
  8533. function SVGElement() {
  8534. /* *
  8535. *
  8536. * Properties
  8537. *
  8538. * */
  8539. this.element = void 0;
  8540. this.onEvents = {};
  8541. this.opacity = 1; // Default base for animation
  8542. this.renderer = void 0;
  8543. this.SVG_NS = SVG_NS;
  8544. // Custom attributes used for symbols, these should be filtered out when
  8545. // setting SVGElement attributes (#9375).
  8546. this.symbolCustomAttribs = [
  8547. 'x',
  8548. 'y',
  8549. 'width',
  8550. 'height',
  8551. 'r',
  8552. 'start',
  8553. 'end',
  8554. 'innerR',
  8555. 'anchorX',
  8556. 'anchorY',
  8557. 'rounded'
  8558. ];
  8559. }
  8560. // @todo public zIndex?: number;
  8561. /* *
  8562. *
  8563. * Functions
  8564. *
  8565. * */
  8566. /**
  8567. * Get the current value of an attribute or pseudo attribute,
  8568. * used mainly for animation. Called internally from
  8569. * the {@link Highcharts.SVGRenderer#attr} function.
  8570. *
  8571. * @private
  8572. * @function Highcharts.SVGElement#_defaultGetter
  8573. *
  8574. * @param {string} key
  8575. * Property key.
  8576. *
  8577. * @return {number|string}
  8578. * Property value.
  8579. */
  8580. SVGElement.prototype._defaultGetter = function (key) {
  8581. var ret = pick(this[key + 'Value'], // align getter
  8582. this[key],
  8583. this.element ? this.element.getAttribute(key) : null, 0);
  8584. if (/^[\-0-9\.]+$/.test(ret)) { // is numerical
  8585. ret = parseFloat(ret);
  8586. }
  8587. return ret;
  8588. };
  8589. /**
  8590. * @private
  8591. * @function Highcharts.SVGElement#_defaultSetter
  8592. *
  8593. * @param {string} value
  8594. *
  8595. * @param {string} key
  8596. *
  8597. * @param {Highcharts.SVGDOMElement} element
  8598. *
  8599. * @return {void}
  8600. */
  8601. SVGElement.prototype._defaultSetter = function (value, key, element) {
  8602. element.setAttribute(key, value);
  8603. };
  8604. /**
  8605. * Add the element to the DOM. All elements must be added this way.
  8606. *
  8607. * @sample highcharts/members/renderer-g
  8608. * Elements added to a group
  8609. *
  8610. * @function Highcharts.SVGElement#add
  8611. *
  8612. * @param {Highcharts.SVGElement} [parent]
  8613. * The parent item to add it to. If undefined, the element is added
  8614. * to the {@link Highcharts.SVGRenderer.box}.
  8615. *
  8616. * @return {Highcharts.SVGElement}
  8617. * Returns the SVGElement for chaining.
  8618. */
  8619. SVGElement.prototype.add = function (parent) {
  8620. var renderer = this.renderer,
  8621. element = this.element;
  8622. var inserted;
  8623. if (parent) {
  8624. this.parentGroup = parent;
  8625. }
  8626. // Mark as inverted
  8627. this.parentInverted = parent && parent.inverted;
  8628. // Build formatted text
  8629. if (typeof this.textStr !== 'undefined' &&
  8630. this.element.nodeName === 'text' // Not for SVGLabel instances
  8631. ) {
  8632. renderer.buildText(this);
  8633. }
  8634. // Mark as added
  8635. this.added = true;
  8636. // If we're adding to renderer root, or other elements in the group
  8637. // have a z index, we need to handle it
  8638. if (!parent || parent.handleZ || this.zIndex) {
  8639. inserted = this.zIndexSetter();
  8640. }
  8641. // If zIndex is not handled, append at the end
  8642. if (!inserted) {
  8643. (parent ?
  8644. parent.element :
  8645. renderer.box).appendChild(element);
  8646. }
  8647. // fire an event for internal hooks
  8648. if (this.onAdd) {
  8649. this.onAdd();
  8650. }
  8651. return this;
  8652. };
  8653. /**
  8654. * Add a class name to an element.
  8655. *
  8656. * @function Highcharts.SVGElement#addClass
  8657. *
  8658. * @param {string} className
  8659. * The new class name to add.
  8660. *
  8661. * @param {boolean} [replace=false]
  8662. * When true, the existing class name(s) will be overwritten with the new
  8663. * one. When false, the new one is added.
  8664. *
  8665. * @return {Highcharts.SVGElement}
  8666. * Return the SVG element for chainability.
  8667. */
  8668. SVGElement.prototype.addClass = function (className, replace) {
  8669. var currentClassName = replace ? '' : (this.attr('class') || '');
  8670. // Trim the string and remove duplicates
  8671. className = (className || '')
  8672. .split(/ /g)
  8673. .reduce(function (newClassName, name) {
  8674. if (currentClassName.indexOf(name) === -1) {
  8675. newClassName.push(name);
  8676. }
  8677. return newClassName;
  8678. }, (currentClassName ?
  8679. [currentClassName] :
  8680. []))
  8681. .join(' ');
  8682. if (className !== currentClassName) {
  8683. this.attr('class', className);
  8684. }
  8685. return this;
  8686. };
  8687. /**
  8688. * This method is executed in the end of `attr()`, after setting all
  8689. * attributes in the hash. In can be used to efficiently consolidate
  8690. * multiple attributes in one SVG property -- e.g., translate, rotate and
  8691. * scale are merged in one "transform" attribute in the SVG node.
  8692. *
  8693. * @private
  8694. * @function Highcharts.SVGElement#afterSetters
  8695. */
  8696. SVGElement.prototype.afterSetters = function () {
  8697. // Update transform. Do this outside the loop to prevent redundant
  8698. // updating for batch setting of attributes.
  8699. if (this.doTransform) {
  8700. this.updateTransform();
  8701. this.doTransform = false;
  8702. }
  8703. };
  8704. /**
  8705. * Align the element relative to the chart or another box.
  8706. *
  8707. * @function Highcharts.SVGElement#align
  8708. *
  8709. * @param {Highcharts.AlignObject} [alignOptions]
  8710. * The alignment options. The function can be called without this
  8711. * parameter in order to re-align an element after the box has been
  8712. * updated.
  8713. *
  8714. * @param {boolean} [alignByTranslate]
  8715. * Align element by translation.
  8716. *
  8717. * @param {string|Highcharts.BBoxObject} [box]
  8718. * The box to align to, needs a width and height. When the box is a
  8719. * string, it refers to an object in the Renderer. For example, when
  8720. * box is `spacingBox`, it refers to `Renderer.spacingBox` which
  8721. * holds `width`, `height`, `x` and `y` properties.
  8722. *
  8723. * @return {Highcharts.SVGElement} Returns the SVGElement for chaining.
  8724. */
  8725. SVGElement.prototype.align = function (alignOptions, alignByTranslate, box) {
  8726. var attribs = {},
  8727. renderer = this.renderer,
  8728. alignedObjects = renderer.alignedObjects;
  8729. var x,
  8730. y,
  8731. alignTo,
  8732. alignFactor,
  8733. vAlignFactor;
  8734. // First call on instanciate
  8735. if (alignOptions) {
  8736. this.alignOptions = alignOptions;
  8737. this.alignByTranslate = alignByTranslate;
  8738. if (!box || isString(box)) {
  8739. this.alignTo = alignTo = box || 'renderer';
  8740. // prevent duplicates, like legendGroup after resize
  8741. erase(alignedObjects, this);
  8742. alignedObjects.push(this);
  8743. box = void 0; // reassign it below
  8744. }
  8745. // When called on resize, no arguments are supplied
  8746. }
  8747. else {
  8748. alignOptions = this.alignOptions;
  8749. alignByTranslate = this.alignByTranslate;
  8750. alignTo = this.alignTo;
  8751. }
  8752. box = pick(box, renderer[alignTo], alignTo === 'scrollablePlotBox' ? renderer.plotBox : void 0, renderer);
  8753. // Assign variables
  8754. var align = alignOptions.align,
  8755. vAlign = alignOptions.verticalAlign;
  8756. // default: left align
  8757. x = (box.x || 0) + (alignOptions.x || 0);
  8758. // default: top align
  8759. y = (box.y || 0) + (alignOptions.y || 0);
  8760. // Align
  8761. if (align === 'right') {
  8762. alignFactor = 1;
  8763. }
  8764. else if (align === 'center') {
  8765. alignFactor = 2;
  8766. }
  8767. if (alignFactor) {
  8768. x += (box.width - (alignOptions.width || 0)) /
  8769. alignFactor;
  8770. }
  8771. attribs[alignByTranslate ? 'translateX' : 'x'] = Math.round(x);
  8772. // Vertical align
  8773. if (vAlign === 'bottom') {
  8774. vAlignFactor = 1;
  8775. }
  8776. else if (vAlign === 'middle') {
  8777. vAlignFactor = 2;
  8778. }
  8779. if (vAlignFactor) {
  8780. y += (box.height - (alignOptions.height || 0)) /
  8781. vAlignFactor;
  8782. }
  8783. attribs[alignByTranslate ? 'translateY' : 'y'] = Math.round(y);
  8784. // Animate only if already placed
  8785. this[this.placed ? 'animate' : 'attr'](attribs);
  8786. this.placed = true;
  8787. this.alignAttr = attribs;
  8788. return this;
  8789. };
  8790. /**
  8791. * @private
  8792. * @function Highcharts.SVGElement#alignSetter
  8793. * @param {"left"|"center"|"right"} value
  8794. */
  8795. SVGElement.prototype.alignSetter = function (value) {
  8796. var convert = {
  8797. left: 'start',
  8798. center: 'middle',
  8799. right: 'end'
  8800. };
  8801. if (convert[value]) {
  8802. this.alignValue = value;
  8803. this.element.setAttribute('text-anchor', convert[value]);
  8804. }
  8805. };
  8806. /**
  8807. * Animate to given attributes or CSS properties.
  8808. *
  8809. * @sample highcharts/members/element-on/
  8810. * Setting some attributes by animation
  8811. *
  8812. * @function Highcharts.SVGElement#animate
  8813. *
  8814. * @param {Highcharts.SVGAttributes} params
  8815. * SVG attributes or CSS to animate.
  8816. *
  8817. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [options]
  8818. * Animation options.
  8819. *
  8820. * @param {Function} [complete]
  8821. * Function to perform at the end of animation.
  8822. *
  8823. * @return {Highcharts.SVGElement}
  8824. * Returns the SVGElement for chaining.
  8825. */
  8826. SVGElement.prototype.animate = function (params, options, complete) {
  8827. var _this = this;
  8828. var animOptions = animObject(pick(options,
  8829. this.renderer.globalAnimation,
  8830. true)),
  8831. deferTime = animOptions.defer;
  8832. // When the page is hidden save resources in the background by not
  8833. // running animation at all (#9749).
  8834. if (pick(doc.hidden, doc.msHidden, doc.webkitHidden, false)) {
  8835. animOptions.duration = 0;
  8836. }
  8837. if (animOptions.duration !== 0) {
  8838. // allows using a callback with the global animation without
  8839. // overwriting it
  8840. if (complete) {
  8841. animOptions.complete = complete;
  8842. }
  8843. // If defer option is defined delay the animation #12901
  8844. syncTimeout(function () {
  8845. if (_this.element) {
  8846. animate(_this, params, animOptions);
  8847. }
  8848. }, deferTime);
  8849. }
  8850. else {
  8851. this.attr(params, void 0, complete);
  8852. // Call the end step synchronously
  8853. objectEach(params, function (val, prop) {
  8854. if (animOptions.step) {
  8855. animOptions.step.call(this, val, { prop: prop, pos: 1, elem: this });
  8856. }
  8857. }, this);
  8858. }
  8859. return this;
  8860. };
  8861. /**
  8862. * Apply a text outline through a custom CSS property, by copying the text
  8863. * element and apply stroke to the copy. Used internally. Contrast checks at
  8864. * [example](https://jsfiddle.net/highcharts/43soe9m1/2/).
  8865. *
  8866. * @example
  8867. * // Specific color
  8868. * text.css({
  8869. * textOutline: '1px black'
  8870. * });
  8871. * // Automatic contrast
  8872. * text.css({
  8873. * color: '#000000', // black text
  8874. * textOutline: '1px contrast' // => white outline
  8875. * });
  8876. *
  8877. * @private
  8878. * @function Highcharts.SVGElement#applyTextOutline
  8879. *
  8880. * @param {string} textOutline
  8881. * A custom CSS `text-outline` setting, defined by `width color`.
  8882. */
  8883. SVGElement.prototype.applyTextOutline = function (textOutline) {
  8884. var elem = this.element,
  8885. hasContrast = textOutline.indexOf('contrast') !== -1,
  8886. styles = {};
  8887. // When the text shadow is set to contrast, use dark stroke for light
  8888. // text and vice versa.
  8889. if (hasContrast) {
  8890. styles.textOutline = textOutline = textOutline.replace(/contrast/g, this.renderer.getContrast(elem.style.fill));
  8891. }
  8892. // Extract the stroke width and color
  8893. var parts = textOutline.split(' ');
  8894. var color = parts[parts.length - 1];
  8895. var strokeWidth = parts[0];
  8896. if (strokeWidth && strokeWidth !== 'none' && H.svg) {
  8897. this.fakeTS = true; // Fake text shadow
  8898. // In order to get the right y position of the clone,
  8899. // copy over the y setter
  8900. this.ySetter = this.xSetter;
  8901. // Since the stroke is applied on center of the actual outline, we
  8902. // need to double it to get the correct stroke-width outside the
  8903. // glyphs.
  8904. strokeWidth = strokeWidth.replace(/(^[\d\.]+)(.*?)$/g, function (match, digit, unit) {
  8905. return (2 * Number(digit)) + unit;
  8906. });
  8907. // Remove shadows from previous runs.
  8908. this.removeTextOutline();
  8909. var outline_1 = doc.createElementNS(SVG_NS, 'tspan');
  8910. attr(outline_1, {
  8911. 'class': 'highcharts-text-outline',
  8912. fill: color,
  8913. stroke: color,
  8914. 'stroke-width': strokeWidth,
  8915. 'stroke-linejoin': 'round'
  8916. });
  8917. // For each of the tspans and text nodes, create a copy in the
  8918. // outline.
  8919. [].forEach.call(elem.childNodes, function (childNode) {
  8920. var clone = childNode.cloneNode(true);
  8921. if (clone.removeAttribute) {
  8922. ['fill', 'stroke', 'stroke-width', 'stroke'].forEach(function (prop) { return clone.removeAttribute(prop); });
  8923. }
  8924. outline_1.appendChild(clone);
  8925. });
  8926. // Insert an absolutely positioned break before the original text
  8927. // to keep it in place
  8928. var br_1 = doc.createElementNS(SVG_NS, 'tspan');
  8929. br_1.textContent = '\u200B';
  8930. // Copy x and y if not null
  8931. ['x', 'y'].forEach(function (key) {
  8932. var value = elem.getAttribute(key);
  8933. if (value) {
  8934. br_1.setAttribute(key, value);
  8935. }
  8936. });
  8937. // Insert the outline
  8938. outline_1.appendChild(br_1);
  8939. elem.insertBefore(outline_1, elem.firstChild);
  8940. }
  8941. };
  8942. /**
  8943. * @function Highcharts.SVGElement#attr
  8944. * @param {string} key
  8945. * @return {number|string}
  8946. */ /**
  8947. * Apply native and custom attributes to the SVG elements.
  8948. *
  8949. * In order to set the rotation center for rotation, set x and y to 0 and
  8950. * use `translateX` and `translateY` attributes to position the element
  8951. * instead.
  8952. *
  8953. * Attributes frequently used in Highcharts are `fill`, `stroke`,
  8954. * `stroke-width`.
  8955. *
  8956. * @sample highcharts/members/renderer-rect/
  8957. * Setting some attributes
  8958. *
  8959. * @example
  8960. * // Set multiple attributes
  8961. * element.attr({
  8962. * stroke: 'red',
  8963. * fill: 'blue',
  8964. * x: 10,
  8965. * y: 10
  8966. * });
  8967. *
  8968. * // Set a single attribute
  8969. * element.attr('stroke', 'red');
  8970. *
  8971. * // Get an attribute
  8972. * element.attr('stroke'); // => 'red'
  8973. *
  8974. * @function Highcharts.SVGElement#attr
  8975. *
  8976. * @param {string|Highcharts.SVGAttributes} [hash]
  8977. * The native and custom SVG attributes.
  8978. *
  8979. * @param {number|string|Highcharts.SVGPathArray} [val]
  8980. * If the type of the first argument is `string`, the second can be a
  8981. * value, which will serve as a single attribute setter. If the first
  8982. * argument is a string and the second is undefined, the function
  8983. * serves as a getter and the current value of the property is
  8984. * returned.
  8985. *
  8986. * @param {Function} [complete]
  8987. * A callback function to execute after setting the attributes. This
  8988. * makes the function compliant and interchangeable with the
  8989. * {@link SVGElement#animate} function.
  8990. *
  8991. * @param {boolean} [continueAnimation=true]
  8992. * Used internally when `.attr` is called as part of an animation
  8993. * step. Otherwise, calling `.attr` for an attribute will stop
  8994. * animation for that attribute.
  8995. *
  8996. * @return {Highcharts.SVGElement}
  8997. * If used as a setter, it returns the current
  8998. * {@link Highcharts.SVGElement} so the calls can be chained. If
  8999. * used as a getter, the current value of the attribute is returned.
  9000. */
  9001. SVGElement.prototype.attr = function (hash, val, complete, continueAnimation) {
  9002. var element = this.element,
  9003. symbolCustomAttribs = this.symbolCustomAttribs;
  9004. var key,
  9005. hasSetSymbolSize,
  9006. ret = this,
  9007. skipAttr,
  9008. setter;
  9009. // single key-value pair
  9010. if (typeof hash === 'string' && typeof val !== 'undefined') {
  9011. key = hash;
  9012. hash = {};
  9013. hash[key] = val;
  9014. }
  9015. // used as a getter: first argument is a string, second is undefined
  9016. if (typeof hash === 'string') {
  9017. ret = (this[hash + 'Getter'] ||
  9018. this._defaultGetter).call(this, hash, element);
  9019. // setter
  9020. }
  9021. else {
  9022. objectEach(hash, function eachAttribute(val, key) {
  9023. skipAttr = false;
  9024. // Unless .attr is from the animator update, stop current
  9025. // running animation of this property
  9026. if (!continueAnimation) {
  9027. stop(this, key);
  9028. }
  9029. // Special handling of symbol attributes
  9030. if (this.symbolName &&
  9031. symbolCustomAttribs.indexOf(key) !== -1) {
  9032. if (!hasSetSymbolSize) {
  9033. this.symbolAttr(hash);
  9034. hasSetSymbolSize = true;
  9035. }
  9036. skipAttr = true;
  9037. }
  9038. if (this.rotation && (key === 'x' || key === 'y')) {
  9039. this.doTransform = true;
  9040. }
  9041. if (!skipAttr) {
  9042. setter = (this[key + 'Setter'] ||
  9043. this._defaultSetter);
  9044. setter.call(this, val, key, element);
  9045. // Let the shadow follow the main element
  9046. if (!this.styledMode &&
  9047. this.shadows &&
  9048. /^(width|height|visibility|x|y|d|transform|cx|cy|r)$/.test(key)) {
  9049. this.updateShadows(key, val, setter);
  9050. }
  9051. }
  9052. }, this);
  9053. this.afterSetters();
  9054. }
  9055. // In accordance with animate, run a complete callback
  9056. if (complete) {
  9057. complete.call(this);
  9058. }
  9059. return ret;
  9060. };
  9061. /**
  9062. * Apply a clipping rectangle to this element.
  9063. *
  9064. * @function Highcharts.SVGElement#clip
  9065. *
  9066. * @param {Highcharts.ClipRectElement} [clipRect]
  9067. * The clipping rectangle. If skipped, the current clip is removed.
  9068. *
  9069. * @return {Highcharts.SVGElement}
  9070. * Returns the SVG element to allow chaining.
  9071. */
  9072. SVGElement.prototype.clip = function (clipRect) {
  9073. return this.attr('clip-path', clipRect ?
  9074. 'url(' + this.renderer.url + '#' + clipRect.id + ')' :
  9075. 'none');
  9076. };
  9077. /**
  9078. * Calculate the coordinates needed for drawing a rectangle crisply and
  9079. * return the calculated attributes.
  9080. *
  9081. * @function Highcharts.SVGElement#crisp
  9082. *
  9083. * @param {Highcharts.RectangleObject} rect
  9084. * Rectangle to crisp.
  9085. *
  9086. * @param {number} [strokeWidth]
  9087. * The stroke width to consider when computing crisp positioning. It can
  9088. * also be set directly on the rect parameter.
  9089. *
  9090. * @return {Highcharts.RectangleObject}
  9091. * The modified rectangle arguments.
  9092. */
  9093. SVGElement.prototype.crisp = function (rect, strokeWidth) {
  9094. var wrapper = this;
  9095. strokeWidth = strokeWidth || rect.strokeWidth || 0;
  9096. // Math.round because strokeWidth can sometimes have roundoff errors
  9097. var normalizer = Math.round(strokeWidth) % 2 / 2;
  9098. // normalize for crisp edges
  9099. rect.x = Math.floor(rect.x || wrapper.x || 0) + normalizer;
  9100. rect.y = Math.floor(rect.y || wrapper.y || 0) + normalizer;
  9101. rect.width = Math.floor((rect.width || wrapper.width || 0) - 2 * normalizer);
  9102. rect.height = Math.floor((rect.height || wrapper.height || 0) - 2 * normalizer);
  9103. if (defined(rect.strokeWidth)) {
  9104. rect.strokeWidth = strokeWidth;
  9105. }
  9106. return rect;
  9107. };
  9108. /**
  9109. * Build and apply an SVG gradient out of a common JavaScript configuration
  9110. * object. This function is called from the attribute setters. An event
  9111. * hook is added for supporting other complex color types.
  9112. *
  9113. * @private
  9114. * @function Highcharts.SVGElement#complexColor
  9115. *
  9116. * @param {Highcharts.GradientColorObject|Highcharts.PatternObject} colorOptions
  9117. * The gradient or pattern options structure.
  9118. *
  9119. * @param {string} prop
  9120. * The property to apply, can either be `fill` or `stroke`.
  9121. *
  9122. * @param {Highcharts.SVGDOMElement} elem
  9123. * SVG element to apply the gradient on.
  9124. */
  9125. SVGElement.prototype.complexColor = function (colorOptions, prop, elem) {
  9126. var renderer = this.renderer;
  9127. var colorObject,
  9128. gradName,
  9129. gradAttr,
  9130. radAttr,
  9131. gradients,
  9132. stops,
  9133. stopColor,
  9134. stopOpacity,
  9135. radialReference,
  9136. id,
  9137. key = [],
  9138. value;
  9139. fireEvent(this.renderer, 'complexColor', {
  9140. args: arguments
  9141. }, function () {
  9142. // Apply linear or radial gradients
  9143. if (colorOptions.radialGradient) {
  9144. gradName = 'radialGradient';
  9145. }
  9146. else if (colorOptions.linearGradient) {
  9147. gradName = 'linearGradient';
  9148. }
  9149. if (gradName) {
  9150. gradAttr = colorOptions[gradName];
  9151. gradients = renderer.gradients;
  9152. stops = colorOptions.stops;
  9153. radialReference = elem.radialReference;
  9154. // Keep < 2.2 kompatibility
  9155. if (isArray(gradAttr)) {
  9156. colorOptions[gradName] = gradAttr = {
  9157. x1: gradAttr[0],
  9158. y1: gradAttr[1],
  9159. x2: gradAttr[2],
  9160. y2: gradAttr[3],
  9161. gradientUnits: 'userSpaceOnUse'
  9162. };
  9163. }
  9164. // Correct the radial gradient for the radial reference system
  9165. if (gradName === 'radialGradient' &&
  9166. radialReference &&
  9167. !defined(gradAttr.gradientUnits)) {
  9168. // Save the radial attributes for updating
  9169. radAttr = gradAttr;
  9170. gradAttr = merge(gradAttr, renderer.getRadialAttr(radialReference, radAttr), { gradientUnits: 'userSpaceOnUse' });
  9171. }
  9172. // Build the unique key to detect whether we need to create a
  9173. // new element (#1282)
  9174. objectEach(gradAttr, function (value, n) {
  9175. if (n !== 'id') {
  9176. key.push(n, value);
  9177. }
  9178. });
  9179. objectEach(stops, function (val) {
  9180. key.push(val);
  9181. });
  9182. key = key.join(',');
  9183. // Check if a gradient object with the same config object is
  9184. // created within this renderer
  9185. if (gradients[key]) {
  9186. id = gradients[key].attr('id');
  9187. }
  9188. else {
  9189. // Set the id and create the element
  9190. gradAttr.id = id = uniqueKey();
  9191. var gradientObject_1 = gradients[key] =
  9192. renderer.createElement(gradName)
  9193. .attr(gradAttr)
  9194. .add(renderer.defs);
  9195. gradientObject_1.radAttr = radAttr;
  9196. // The gradient needs to keep a list of stops to be able to
  9197. // destroy them
  9198. gradientObject_1.stops = [];
  9199. stops.forEach(function (stop) {
  9200. if (stop[1].indexOf('rgba') === 0) {
  9201. colorObject = Color.parse(stop[1]);
  9202. stopColor = colorObject.get('rgb');
  9203. stopOpacity = colorObject.get('a');
  9204. }
  9205. else {
  9206. stopColor = stop[1];
  9207. stopOpacity = 1;
  9208. }
  9209. var stopObject = renderer.createElement('stop').attr({
  9210. offset: stop[0],
  9211. 'stop-color': stopColor,
  9212. 'stop-opacity': stopOpacity
  9213. }).add(gradientObject_1);
  9214. // Add the stop element to the gradient
  9215. gradientObject_1.stops.push(stopObject);
  9216. });
  9217. }
  9218. // Set the reference to the gradient object
  9219. value = 'url(' + renderer.url + '#' + id + ')';
  9220. elem.setAttribute(prop, value);
  9221. elem.gradient = key;
  9222. // Allow the color to be concatenated into tooltips formatters
  9223. // etc. (#2995)
  9224. colorOptions.toString = function () {
  9225. return value;
  9226. };
  9227. }
  9228. });
  9229. };
  9230. /**
  9231. * Set styles for the element. In addition to CSS styles supported by
  9232. * native SVG and HTML elements, there are also some custom made for
  9233. * Highcharts, like `width`, `ellipsis` and `textOverflow` for SVG text
  9234. * elements.
  9235. *
  9236. * @sample highcharts/members/renderer-text-on-chart/
  9237. * Styled text
  9238. *
  9239. * @function Highcharts.SVGElement#css
  9240. *
  9241. * @param {Highcharts.CSSObject} styles
  9242. * The new CSS styles.
  9243. *
  9244. * @return {Highcharts.SVGElement}
  9245. * Return the SVG element for chaining.
  9246. */
  9247. SVGElement.prototype.css = function (styles) {
  9248. var oldStyles = this.styles, newStyles = {}, elem = this.element,
  9249. // These CSS properties are interpreted internally by the SVG
  9250. // renderer, but are not supported by SVG and should not be added to
  9251. // the DOM. In styled mode, no CSS should find its way to the DOM
  9252. // whatsoever (#6173, #6474).
  9253. svgPseudoProps = ['textOutline', 'textOverflow', 'width'];
  9254. var textWidth,
  9255. serializedCss = '',
  9256. hyphenate,
  9257. hasNew = !oldStyles;
  9258. // convert legacy
  9259. if (styles && styles.color) {
  9260. styles.fill = styles.color;
  9261. }
  9262. // Filter out existing styles to increase performance (#2640)
  9263. if (oldStyles) {
  9264. objectEach(styles, function (style, n) {
  9265. if (oldStyles && oldStyles[n] !== style) {
  9266. newStyles[n] = style;
  9267. hasNew = true;
  9268. }
  9269. });
  9270. }
  9271. if (hasNew) {
  9272. // Merge the new styles with the old ones
  9273. if (oldStyles) {
  9274. styles = extend(oldStyles, newStyles);
  9275. }
  9276. // Get the text width from style
  9277. if (styles) {
  9278. // Previously set, unset it (#8234)
  9279. if (styles.width === null || styles.width === 'auto') {
  9280. delete this.textWidth;
  9281. // Apply new
  9282. }
  9283. else if (elem.nodeName.toLowerCase() === 'text' &&
  9284. styles.width) {
  9285. textWidth = this.textWidth = pInt(styles.width);
  9286. }
  9287. }
  9288. // store object
  9289. this.styles = styles;
  9290. if (textWidth && (!svg && this.renderer.forExport)) {
  9291. delete styles.width;
  9292. }
  9293. // Serialize and set style attribute
  9294. if (elem.namespaceURI === this.SVG_NS) { // #7633
  9295. hyphenate = function (a, b) {
  9296. return '-' + b.toLowerCase();
  9297. };
  9298. objectEach(styles, function (style, n) {
  9299. if (svgPseudoProps.indexOf(n) === -1) {
  9300. serializedCss +=
  9301. n.replace(/([A-Z])/g, hyphenate) + ':' +
  9302. style + ';';
  9303. }
  9304. });
  9305. if (serializedCss) {
  9306. attr(elem, 'style', serializedCss); // #1881
  9307. }
  9308. }
  9309. else {
  9310. css(elem, styles);
  9311. }
  9312. if (this.added) {
  9313. // Rebuild text after added. Cache mechanisms in the buildText
  9314. // will prevent building if there are no significant changes.
  9315. if (this.element.nodeName === 'text') {
  9316. this.renderer.buildText(this);
  9317. }
  9318. // Apply text outline after added
  9319. if (styles && styles.textOutline) {
  9320. this.applyTextOutline(styles.textOutline);
  9321. }
  9322. }
  9323. }
  9324. return this;
  9325. };
  9326. /**
  9327. * @private
  9328. * @function Highcharts.SVGElement#dashstyleSetter
  9329. * @param {string} value
  9330. */
  9331. SVGElement.prototype.dashstyleSetter = function (value) {
  9332. var i,
  9333. strokeWidth = this['stroke-width'];
  9334. // If "inherit", like maps in IE, assume 1 (#4981). With HC5 and the new
  9335. // strokeWidth function, we should be able to use that instead.
  9336. if (strokeWidth === 'inherit') {
  9337. strokeWidth = 1;
  9338. }
  9339. value = value && value.toLowerCase();
  9340. if (value) {
  9341. var v = value
  9342. .replace('shortdashdotdot', '3,1,1,1,1,1,')
  9343. .replace('shortdashdot', '3,1,1,1')
  9344. .replace('shortdot', '1,1,')
  9345. .replace('shortdash', '3,1,')
  9346. .replace('longdash', '8,3,')
  9347. .replace(/dot/g, '1,3,')
  9348. .replace('dash', '4,3,')
  9349. .replace(/,$/, '')
  9350. .split(','); // ending comma
  9351. i = v.length;
  9352. while (i--) {
  9353. v[i] = '' + (pInt(v[i]) * pick(strokeWidth, NaN));
  9354. }
  9355. value = v.join(',').replace(/NaN/g, 'none'); // #3226
  9356. this.element.setAttribute('stroke-dasharray', value);
  9357. }
  9358. };
  9359. /**
  9360. * Destroy the element and element wrapper and clear up the DOM and event
  9361. * hooks.
  9362. *
  9363. * @function Highcharts.SVGElement#destroy
  9364. */
  9365. SVGElement.prototype.destroy = function () {
  9366. var wrapper = this,
  9367. element = wrapper.element || {},
  9368. renderer = wrapper.renderer,
  9369. ownerSVGElement = element.ownerSVGElement;
  9370. var parentToClean = (renderer.isSVG &&
  9371. element.nodeName === 'SPAN' &&
  9372. wrapper.parentGroup ||
  9373. void 0),
  9374. grandParent,
  9375. i;
  9376. // remove events
  9377. element.onclick = element.onmouseout = element.onmouseover =
  9378. element.onmousemove = element.point = null;
  9379. stop(wrapper); // stop running animations
  9380. if (wrapper.clipPath && ownerSVGElement) {
  9381. var clipPath_1 = wrapper.clipPath;
  9382. // Look for existing references to this clipPath and remove them
  9383. // before destroying the element (#6196).
  9384. // The upper case version is for Edge
  9385. [].forEach.call(ownerSVGElement.querySelectorAll('[clip-path],[CLIP-PATH]'), function (el) {
  9386. if (el.getAttribute('clip-path').indexOf(clipPath_1.element.id) > -1) {
  9387. el.removeAttribute('clip-path');
  9388. }
  9389. });
  9390. wrapper.clipPath = clipPath_1.destroy();
  9391. }
  9392. // Destroy stops in case this is a gradient object @todo old code?
  9393. if (wrapper.stops) {
  9394. for (i = 0; i < wrapper.stops.length; i++) {
  9395. wrapper.stops[i].destroy();
  9396. }
  9397. wrapper.stops.length = 0;
  9398. wrapper.stops = void 0;
  9399. }
  9400. // remove element
  9401. wrapper.safeRemoveChild(element);
  9402. if (!renderer.styledMode) {
  9403. wrapper.destroyShadows();
  9404. }
  9405. // In case of useHTML, clean up empty containers emulating SVG groups
  9406. // (#1960, #2393, #2697).
  9407. while (parentToClean &&
  9408. parentToClean.div &&
  9409. parentToClean.div.childNodes.length === 0) {
  9410. grandParent = parentToClean.parentGroup;
  9411. wrapper.safeRemoveChild(parentToClean.div);
  9412. delete parentToClean.div;
  9413. parentToClean = grandParent;
  9414. }
  9415. // remove from alignObjects
  9416. if (wrapper.alignTo) {
  9417. erase(renderer.alignedObjects, wrapper);
  9418. }
  9419. objectEach(wrapper, function (val, key) {
  9420. // Destroy child elements of a group
  9421. if (wrapper[key] &&
  9422. wrapper[key].parentGroup === wrapper &&
  9423. wrapper[key].destroy) {
  9424. wrapper[key].destroy();
  9425. }
  9426. // Delete all properties
  9427. delete wrapper[key];
  9428. });
  9429. return;
  9430. };
  9431. /**
  9432. * Destroy shadows on the element.
  9433. *
  9434. * @private
  9435. * @function Highcharts.SVGElement#destroyShadows
  9436. *
  9437. * @return {void}
  9438. */
  9439. SVGElement.prototype.destroyShadows = function () {
  9440. (this.shadows || []).forEach(function (shadow) {
  9441. this.safeRemoveChild(shadow);
  9442. }, this);
  9443. this.shadows = void 0;
  9444. };
  9445. /**
  9446. * @private
  9447. */
  9448. SVGElement.prototype.destroyTextPath = function (elem, path) {
  9449. var textElement = elem.getElementsByTagName('text')[0];
  9450. var childNodes;
  9451. if (textElement) {
  9452. // Remove textPath attributes
  9453. textElement.removeAttribute('dx');
  9454. textElement.removeAttribute('dy');
  9455. // Remove ID's:
  9456. path.element.setAttribute('id', '');
  9457. // Check if textElement includes textPath,
  9458. if (this.textPathWrapper &&
  9459. textElement.getElementsByTagName('textPath').length) {
  9460. // Move nodes to <text>
  9461. childNodes = this.textPathWrapper.element.childNodes;
  9462. // Now move all <tspan>'s and text nodes to the <textPath> node
  9463. while (childNodes.length) {
  9464. textElement.appendChild(childNodes[0]);
  9465. }
  9466. // Remove <textPath> from the DOM
  9467. textElement.removeChild(this.textPathWrapper.element);
  9468. }
  9469. }
  9470. else if (elem.getAttribute('dx') || elem.getAttribute('dy')) {
  9471. // Remove textPath attributes from elem
  9472. // to get correct text-outline position
  9473. elem.removeAttribute('dx');
  9474. elem.removeAttribute('dy');
  9475. }
  9476. if (this.textPathWrapper) {
  9477. // Set textPathWrapper to undefined and destroy it
  9478. this.textPathWrapper = this.textPathWrapper.destroy();
  9479. }
  9480. };
  9481. /**
  9482. * @private
  9483. * @function Highcharts.SVGElement#dSettter
  9484. * @param {number|string|Highcharts.SVGPathArray} value
  9485. * @param {string} key
  9486. * @param {Highcharts.SVGDOMElement} element
  9487. */
  9488. SVGElement.prototype.dSetter = function (value, key, element) {
  9489. if (isArray(value)) {
  9490. // Backwards compatibility, convert one-dimensional array into an
  9491. // array of segments
  9492. if (typeof value[0] === 'string') {
  9493. value = this.renderer.pathToSegments(value);
  9494. }
  9495. this.pathArray = value;
  9496. value = value.reduce(function (acc, seg, i) {
  9497. if (!seg || !seg.join) {
  9498. return (seg || '').toString();
  9499. }
  9500. return (i ? acc + ' ' : '') + seg.join(' ');
  9501. }, '');
  9502. }
  9503. if (/(NaN| {2}|^$)/.test(value)) {
  9504. value = 'M 0 0';
  9505. }
  9506. // Check for cache before resetting. Resetting causes disturbance in the
  9507. // DOM, causing flickering in some cases in Edge/IE (#6747). Also
  9508. // possible performance gain.
  9509. if (this[key] !== value) {
  9510. element.setAttribute(key, value);
  9511. this[key] = value;
  9512. }
  9513. };
  9514. /**
  9515. * Fade out an element by animating its opacity down to 0, and hide it on
  9516. * complete. Used internally for the tooltip.
  9517. *
  9518. * @function Highcharts.SVGElement#fadeOut
  9519. *
  9520. * @param {number} [duration=150]
  9521. * The fade duration in milliseconds.
  9522. */
  9523. SVGElement.prototype.fadeOut = function (duration) {
  9524. var elemWrapper = this;
  9525. elemWrapper.animate({
  9526. opacity: 0
  9527. }, {
  9528. duration: pick(duration, 150),
  9529. complete: function () {
  9530. // #3088, assuming we're only using this for tooltips
  9531. elemWrapper.attr({ y: -9999 }).hide();
  9532. }
  9533. });
  9534. };
  9535. /**
  9536. * @private
  9537. * @function Highcharts.SVGElement#fillSetter
  9538. * @param {Highcharts.ColorType} value
  9539. * @param {string} key
  9540. * @param {Highcharts.SVGDOMElement} element
  9541. */
  9542. SVGElement.prototype.fillSetter = function (value, key, element) {
  9543. if (typeof value === 'string') {
  9544. element.setAttribute(key, value);
  9545. }
  9546. else if (value) {
  9547. this.complexColor(value, key, element);
  9548. }
  9549. };
  9550. /**
  9551. * Get the bounding box (width, height, x and y) for the element. Generally
  9552. * used to get rendered text size. Since this is called a lot in charts,
  9553. * the results are cached based on text properties, in order to save DOM
  9554. * traffic. The returned bounding box includes the rotation, so for example
  9555. * a single text line of rotation 90 will report a greater height, and a
  9556. * width corresponding to the line-height.
  9557. *
  9558. * @sample highcharts/members/renderer-on-chart/
  9559. * Draw a rectangle based on a text's bounding box
  9560. *
  9561. * @function Highcharts.SVGElement#getBBox
  9562. *
  9563. * @param {boolean} [reload]
  9564. * Skip the cache and get the updated DOM bouding box.
  9565. *
  9566. * @param {number} [rot]
  9567. * Override the element's rotation. This is internally used on axis
  9568. * labels with a value of 0 to find out what the bounding box would
  9569. * be have been if it were not rotated.
  9570. *
  9571. * @return {Highcharts.BBoxObject}
  9572. * The bounding box with `x`, `y`, `width` and `height` properties.
  9573. */
  9574. SVGElement.prototype.getBBox = function (reload, rot) {
  9575. var wrapper = this,
  9576. renderer = wrapper.renderer,
  9577. element = wrapper.element,
  9578. styles = wrapper.styles,
  9579. textStr = wrapper.textStr,
  9580. cache = renderer.cache,
  9581. cacheKeys = renderer.cacheKeys,
  9582. isSVG = element.namespaceURI === wrapper.SVG_NS,
  9583. rotation = pick(rot,
  9584. wrapper.rotation, 0),
  9585. fontSize = renderer.styledMode ? (element &&
  9586. SVGElement.prototype.getStyle.call(element, 'font-size')) : (styles && styles.fontSize);
  9587. var bBox, // = wrapper.bBox,
  9588. width,
  9589. height,
  9590. toggleTextShadowShim,
  9591. cacheKey;
  9592. // Avoid undefined and null (#7316)
  9593. if (defined(textStr)) {
  9594. cacheKey = textStr.toString();
  9595. // Since numbers are monospaced, and numerical labels appear a lot
  9596. // in a chart, we assume that a label of n characters has the same
  9597. // bounding box as others of the same length. Unless there is inner
  9598. // HTML in the label. In that case, leave the numbers as is (#5899).
  9599. if (cacheKey.indexOf('<') === -1) {
  9600. cacheKey = cacheKey.replace(/[0-9]/g, '0');
  9601. }
  9602. // Properties that affect bounding box
  9603. cacheKey += [
  9604. '',
  9605. rotation,
  9606. fontSize,
  9607. wrapper.textWidth,
  9608. styles && styles.textOverflow,
  9609. styles && styles.fontWeight // #12163
  9610. ].join(',');
  9611. }
  9612. if (cacheKey && !reload) {
  9613. bBox = cache[cacheKey];
  9614. }
  9615. // No cache found
  9616. if (!bBox) {
  9617. // SVG elements
  9618. if (isSVG || renderer.forExport) {
  9619. try { // Fails in Firefox if the container has display: none.
  9620. // When the text shadow shim is used, we need to hide the
  9621. // fake shadows to get the correct bounding box (#3872)
  9622. toggleTextShadowShim = this.fakeTS && function (display) {
  9623. var outline = element.querySelector('.highcharts-text-outline');
  9624. if (outline) {
  9625. css(outline, { display: display });
  9626. }
  9627. };
  9628. // Workaround for #3842, Firefox reporting wrong bounding
  9629. // box for shadows
  9630. if (isFunction(toggleTextShadowShim)) {
  9631. toggleTextShadowShim('none');
  9632. }
  9633. bBox = element.getBBox ?
  9634. // SVG: use extend because IE9 is not allowed to change
  9635. // width and height in case of rotation (below)
  9636. extend({}, element.getBBox()) : {
  9637. // Legacy IE in export mode
  9638. width: element.offsetWidth,
  9639. height: element.offsetHeight
  9640. };
  9641. // #3842
  9642. if (isFunction(toggleTextShadowShim)) {
  9643. toggleTextShadowShim('');
  9644. }
  9645. }
  9646. catch (e) {
  9647. '';
  9648. }
  9649. // If the bBox is not set, the try-catch block above failed. The
  9650. // other condition is for Opera that returns a width of
  9651. // -Infinity on hidden elements.
  9652. if (!bBox || bBox.width < 0) {
  9653. bBox = { width: 0, height: 0 };
  9654. }
  9655. // VML Renderer or useHTML within SVG
  9656. }
  9657. else {
  9658. bBox = wrapper.htmlGetBBox();
  9659. }
  9660. // True SVG elements as well as HTML elements in modern browsers
  9661. // using the .useHTML option need to compensated for rotation
  9662. if (renderer.isSVG) {
  9663. width = bBox.width;
  9664. height = bBox.height;
  9665. // Workaround for wrong bounding box in IE, Edge and Chrome on
  9666. // Windows. With Highcharts' default font, IE and Edge report
  9667. // a box height of 16.899 and Chrome rounds it to 17. If this
  9668. // stands uncorrected, it results in more padding added below
  9669. // the text than above when adding a label border or background.
  9670. // Also vertical positioning is affected.
  9671. // https://jsfiddle.net/highcharts/em37nvuj/
  9672. // (#1101, #1505, #1669, #2568, #6213).
  9673. if (isSVG) {
  9674. bBox.height = height = ({
  9675. '11px,17': 14,
  9676. '13px,20': 16
  9677. }[styles &&
  9678. styles.fontSize + ',' + Math.round(height)] ||
  9679. height);
  9680. }
  9681. // Adjust for rotated text
  9682. if (rotation) {
  9683. var rad = rotation * deg2rad;
  9684. bBox.width = Math.abs(height * Math.sin(rad)) +
  9685. Math.abs(width * Math.cos(rad));
  9686. bBox.height = Math.abs(height * Math.cos(rad)) +
  9687. Math.abs(width * Math.sin(rad));
  9688. }
  9689. }
  9690. // Cache it. When loading a chart in a hidden iframe in Firefox and
  9691. // IE/Edge, the bounding box height is 0, so don't cache it (#5620).
  9692. if (cacheKey && bBox.height > 0) {
  9693. // Rotate (#4681)
  9694. while (cacheKeys.length > 250) {
  9695. delete cache[cacheKeys.shift()];
  9696. }
  9697. if (!cache[cacheKey]) {
  9698. cacheKeys.push(cacheKey);
  9699. }
  9700. cache[cacheKey] = bBox;
  9701. }
  9702. }
  9703. return bBox;
  9704. };
  9705. /**
  9706. * Get the computed style. Only in styled mode.
  9707. *
  9708. * @example
  9709. * chart.series[0].points[0].graphic.getStyle('stroke-width'); // => '1px'
  9710. *
  9711. * @function Highcharts.SVGElement#getStyle
  9712. *
  9713. * @param {string} prop
  9714. * The property name to check for.
  9715. *
  9716. * @return {string}
  9717. * The current computed value.
  9718. */
  9719. SVGElement.prototype.getStyle = function (prop) {
  9720. return win
  9721. .getComputedStyle(this.element || this, '')
  9722. .getPropertyValue(prop);
  9723. };
  9724. /**
  9725. * Check if an element has the given class name.
  9726. *
  9727. * @function Highcharts.SVGElement#hasClass
  9728. *
  9729. * @param {string} className
  9730. * The class name to check for.
  9731. *
  9732. * @return {boolean}
  9733. * Whether the class name is found.
  9734. */
  9735. SVGElement.prototype.hasClass = function (className) {
  9736. return ('' + this.attr('class'))
  9737. .split(' ')
  9738. .indexOf(className) !== -1;
  9739. };
  9740. /**
  9741. * Hide the element, similar to setting the `visibility` attribute to
  9742. * `hidden`.
  9743. *
  9744. * @function Highcharts.SVGElement#hide
  9745. *
  9746. * @param {boolean} [hideByTranslation=false]
  9747. * The flag to determine if element should be hidden by moving out
  9748. * of the viewport. Used for example for dataLabels.
  9749. *
  9750. * @return {Highcharts.SVGElement}
  9751. * Returns the SVGElement for chaining.
  9752. */
  9753. SVGElement.prototype.hide = function (hideByTranslation) {
  9754. if (hideByTranslation) {
  9755. this.attr({ y: -9999 });
  9756. }
  9757. else {
  9758. this.attr({ visibility: 'hidden' });
  9759. }
  9760. return this;
  9761. };
  9762. /**
  9763. * @private
  9764. */
  9765. SVGElement.prototype.htmlGetBBox = function () {
  9766. return { height: 0, width: 0, x: 0, y: 0 };
  9767. };
  9768. /**
  9769. * Initialize the SVG element. This function only exists to make the
  9770. * initialization process overridable. It should not be called directly.
  9771. *
  9772. * @function Highcharts.SVGElement#init
  9773. *
  9774. * @param {Highcharts.SVGRenderer} renderer
  9775. * The SVGRenderer instance to initialize to.
  9776. *
  9777. * @param {string} nodeName
  9778. * The SVG node name.
  9779. */
  9780. SVGElement.prototype.init = function (renderer, nodeName) {
  9781. /**
  9782. * The primary DOM node. Each `SVGElement` instance wraps a main DOM
  9783. * node, but may also represent more nodes.
  9784. *
  9785. * @name Highcharts.SVGElement#element
  9786. * @type {Highcharts.SVGDOMElement|Highcharts.HTMLDOMElement}
  9787. */
  9788. this.element = nodeName === 'span' ?
  9789. createElement(nodeName) :
  9790. doc.createElementNS(this.SVG_NS, nodeName);
  9791. /**
  9792. * The renderer that the SVGElement belongs to.
  9793. *
  9794. * @name Highcharts.SVGElement#renderer
  9795. * @type {Highcharts.SVGRenderer}
  9796. */
  9797. this.renderer = renderer;
  9798. fireEvent(this, 'afterInit');
  9799. };
  9800. /**
  9801. * Invert a group, rotate and flip. This is used internally on inverted
  9802. * charts, where the points and graphs are drawn as if not inverted, then
  9803. * the series group elements are inverted.
  9804. *
  9805. * @function Highcharts.SVGElement#invert
  9806. *
  9807. * @param {boolean} inverted
  9808. * Whether to invert or not. An inverted shape can be un-inverted by
  9809. * setting it to false.
  9810. *
  9811. * @return {Highcharts.SVGElement}
  9812. * Return the SVGElement for chaining.
  9813. */
  9814. SVGElement.prototype.invert = function (inverted) {
  9815. this.inverted = inverted;
  9816. this.updateTransform();
  9817. return this;
  9818. };
  9819. /**
  9820. * Add an event listener. This is a simple setter that replaces the
  9821. * previous event of the same type added by this function, as opposed to
  9822. * the {@link Highcharts#addEvent} function.
  9823. *
  9824. * @sample highcharts/members/element-on/
  9825. * A clickable rectangle
  9826. *
  9827. * @function Highcharts.SVGElement#on
  9828. *
  9829. * @param {string} eventType
  9830. * The event type.
  9831. *
  9832. * @param {Function} handler
  9833. * The handler callback.
  9834. *
  9835. * @return {Highcharts.SVGElement}
  9836. * The SVGElement for chaining.
  9837. */
  9838. SVGElement.prototype.on = function (eventType, handler) {
  9839. var onEvents = this.onEvents;
  9840. if (onEvents[eventType]) {
  9841. // Unbind existing event
  9842. onEvents[eventType]();
  9843. }
  9844. onEvents[eventType] = addEvent(this.element, eventType, handler);
  9845. return this;
  9846. };
  9847. /**
  9848. * @private
  9849. * @function Highcharts.SVGElement#opacitySetter
  9850. * @param {string} value
  9851. * @param {string} key
  9852. * @param {Highcharts.SVGDOMElement} element
  9853. */
  9854. SVGElement.prototype.opacitySetter = function (value, key, element) {
  9855. // Round off to avoid float errors, like tests where opacity lands on
  9856. // 9.86957e-06 instead of 0
  9857. var opacity = Number(Number(value).toFixed(3));
  9858. this.opacity = opacity;
  9859. element.setAttribute(key, opacity);
  9860. };
  9861. /**
  9862. * Remove a class name from the element.
  9863. *
  9864. * @function Highcharts.SVGElement#removeClass
  9865. *
  9866. * @param {string|RegExp} className
  9867. * The class name to remove.
  9868. *
  9869. * @return {Highcharts.SVGElement} Returns the SVG element for chainability.
  9870. */
  9871. SVGElement.prototype.removeClass = function (className) {
  9872. return this.attr('class', ('' + this.attr('class'))
  9873. .replace(isString(className) ?
  9874. new RegExp("(^| )" + className + "( |$)") : // #12064, #13590
  9875. className, ' ')
  9876. .replace(/ +/g, ' ')
  9877. .trim());
  9878. };
  9879. /**
  9880. *
  9881. * @private
  9882. */
  9883. SVGElement.prototype.removeTextOutline = function () {
  9884. var outline = this.element
  9885. .querySelector('tspan.highcharts-text-outline');
  9886. if (outline) {
  9887. this.safeRemoveChild(outline);
  9888. }
  9889. };
  9890. /**
  9891. * Removes an element from the DOM.
  9892. *
  9893. * @private
  9894. * @function Highcharts.SVGElement#safeRemoveChild
  9895. *
  9896. * @param {Highcharts.SVGDOMElement|Highcharts.HTMLDOMElement} element
  9897. * The DOM node to remove.
  9898. */
  9899. SVGElement.prototype.safeRemoveChild = function (element) {
  9900. var parentNode = element.parentNode;
  9901. if (parentNode) {
  9902. parentNode.removeChild(element);
  9903. }
  9904. };
  9905. /**
  9906. * Set the coordinates needed to draw a consistent radial gradient across
  9907. * a shape regardless of positioning inside the chart. Used on pie slices
  9908. * to make all the slices have the same radial reference point.
  9909. *
  9910. * @function Highcharts.SVGElement#setRadialReference
  9911. *
  9912. * @param {Array<number>} coordinates
  9913. * The center reference. The format is `[centerX, centerY, diameter]` in
  9914. * pixels.
  9915. *
  9916. * @return {Highcharts.SVGElement}
  9917. * Returns the SVGElement for chaining.
  9918. */
  9919. SVGElement.prototype.setRadialReference = function (coordinates) {
  9920. var existingGradient = (this.element.gradient &&
  9921. this.renderer.gradients[this.element.gradient]);
  9922. this.element.radialReference = coordinates;
  9923. // On redrawing objects with an existing gradient, the gradient needs
  9924. // to be repositioned (#3801)
  9925. if (existingGradient && existingGradient.radAttr) {
  9926. existingGradient.animate(this.renderer.getRadialAttr(coordinates, existingGradient.radAttr));
  9927. }
  9928. return this;
  9929. };
  9930. /**
  9931. * @private
  9932. * @function Highcharts.SVGElement#setTextPath
  9933. * @param {Highcharts.SVGElement} path
  9934. * Path to follow.
  9935. * @param {Highcharts.DataLabelsTextPathOptionsObject} textPathOptions
  9936. * Options.
  9937. * @return {Highcharts.SVGElement}
  9938. * Returns the SVGElement for chaining.
  9939. */
  9940. SVGElement.prototype.setTextPath = function (path, textPathOptions) {
  9941. var elem = this.element,
  9942. textNode = this.text ? this.text.element : elem,
  9943. attribsMap = {
  9944. textAnchor: 'text-anchor'
  9945. };
  9946. var adder = false,
  9947. textPathElement,
  9948. textPathId,
  9949. textPathWrapper = this.textPathWrapper,
  9950. firstTime = !textPathWrapper;
  9951. // Defaults
  9952. textPathOptions = merge(true, {
  9953. enabled: true,
  9954. attributes: {
  9955. dy: -5,
  9956. startOffset: '50%',
  9957. textAnchor: 'middle'
  9958. }
  9959. }, textPathOptions);
  9960. var attrs = AST.filterUserAttributes(textPathOptions.attributes);
  9961. if (path && textPathOptions && textPathOptions.enabled) {
  9962. // In case of fixed width for a text, string is rebuilt
  9963. // (e.g. ellipsis is applied), so we need to rebuild textPath too
  9964. if (textPathWrapper &&
  9965. textPathWrapper.element.parentNode === null) {
  9966. // When buildText functionality was triggered again
  9967. // and deletes textPathWrapper parentNode
  9968. firstTime = true;
  9969. textPathWrapper = textPathWrapper.destroy();
  9970. }
  9971. else if (textPathWrapper) {
  9972. // Case after drillup when spans were added into
  9973. // the DOM outside the textPathWrapper parentGroup
  9974. this.removeTextOutline.call(textPathWrapper.parentGroup);
  9975. }
  9976. // label() has padding, text() doesn't
  9977. if (this.options && this.options.padding) {
  9978. attrs.dx = -this.options.padding;
  9979. }
  9980. if (!textPathWrapper) {
  9981. // Create <textPath>, defer the DOM adder
  9982. this.textPathWrapper = textPathWrapper =
  9983. this.renderer.createElement('textPath');
  9984. adder = true;
  9985. }
  9986. textPathElement = textPathWrapper.element;
  9987. // Set ID for the path
  9988. textPathId = path.element.getAttribute('id');
  9989. if (!textPathId) {
  9990. path.element.setAttribute('id', textPathId = uniqueKey());
  9991. }
  9992. // Change DOM structure, by placing <textPath> tag in <text>
  9993. if (firstTime) {
  9994. // Adjust the position
  9995. textNode.setAttribute('y', 0); // Firefox
  9996. if (isNumber(attrs.dx)) {
  9997. textNode.setAttribute('x', -attrs.dx);
  9998. }
  9999. // Move all <tspan>'s and text nodes to the <textPath> node. Do
  10000. // not move other elements like <title> or <path>
  10001. var childNodes = [].slice.call(textNode.childNodes);
  10002. for (var i = 0; i < childNodes.length; i++) {
  10003. var childNode = childNodes[i];
  10004. if (childNode.nodeType === Node.TEXT_NODE ||
  10005. childNode.nodeName === 'tspan') {
  10006. textPathElement.appendChild(childNode);
  10007. }
  10008. }
  10009. }
  10010. // Add <textPath> to the DOM
  10011. if (adder && textPathWrapper) {
  10012. textPathWrapper.add({ element: textNode });
  10013. }
  10014. // Set basic options:
  10015. // Use `setAttributeNS` because Safari needs this..
  10016. textPathElement.setAttributeNS('http://www.w3.org/1999/xlink', 'href', this.renderer.url + '#' + textPathId);
  10017. // Presentation attributes:
  10018. // dx/dy options must by set on <text> (parent),
  10019. // the rest should be set on <textPath>
  10020. if (defined(attrs.dy)) {
  10021. textPathElement.parentNode
  10022. .setAttribute('dy', attrs.dy);
  10023. delete attrs.dy;
  10024. }
  10025. if (defined(attrs.dx)) {
  10026. textPathElement.parentNode
  10027. .setAttribute('dx', attrs.dx);
  10028. delete attrs.dx;
  10029. }
  10030. // Additional attributes
  10031. objectEach(attrs, function (val, key) {
  10032. textPathElement.setAttribute(attribsMap[key] || key, val);
  10033. });
  10034. // Remove translation, text that follows path does not need that
  10035. elem.removeAttribute('transform');
  10036. // Remove shadows and text outlines
  10037. this.removeTextOutline.call(textPathWrapper);
  10038. // Remove background and border for label(), see #10545
  10039. // Alternatively, we can disable setting background rects in
  10040. // series.drawDataLabels()
  10041. if (this.text && !this.renderer.styledMode) {
  10042. this.attr({
  10043. fill: 'none',
  10044. 'stroke-width': 0
  10045. });
  10046. }
  10047. // Disable some functions
  10048. this.updateTransform = noop;
  10049. this.applyTextOutline = noop;
  10050. }
  10051. else if (textPathWrapper) {
  10052. // Reset to prototype
  10053. delete this.updateTransform;
  10054. delete this.applyTextOutline;
  10055. // Restore DOM structure:
  10056. this.destroyTextPath(elem, path);
  10057. // Bring attributes back
  10058. this.updateTransform();
  10059. // Set textOutline back for text()
  10060. if (this.options && this.options.rotation) {
  10061. this.applyTextOutline(this.options.style.textOutline);
  10062. }
  10063. }
  10064. return this;
  10065. };
  10066. /**
  10067. * Add a shadow to the element. Must be called after the element is added to
  10068. * the DOM. In styled mode, this method is not used, instead use `defs` and
  10069. * filters.
  10070. *
  10071. * @example
  10072. * renderer.rect(10, 100, 100, 100)
  10073. * .attr({ fill: 'red' })
  10074. * .shadow(true);
  10075. *
  10076. * @function Highcharts.SVGElement#shadow
  10077. *
  10078. * @param {boolean|Highcharts.ShadowOptionsObject} [shadowOptions]
  10079. * The shadow options. If `true`, the default options are applied. If
  10080. * `false`, the current shadow will be removed.
  10081. *
  10082. * @param {Highcharts.SVGElement} [group]
  10083. * The SVG group element where the shadows will be applied. The
  10084. * default is to add it to the same parent as the current element.
  10085. * Internally, this is ised for pie slices, where all the shadows are
  10086. * added to an element behind all the slices.
  10087. *
  10088. * @param {boolean} [cutOff]
  10089. * Used internally for column shadows.
  10090. *
  10091. * @return {Highcharts.SVGElement}
  10092. * Returns the SVGElement for chaining.
  10093. */
  10094. SVGElement.prototype.shadow = function (shadowOptions, group, cutOff) {
  10095. var shadows = [],
  10096. element = this.element,
  10097. oldShadowOptions = this.oldShadowOptions,
  10098. defaultShadowOptions = {
  10099. color: palette.neutralColor100,
  10100. offsetX: this.parentInverted ? -1 : 1,
  10101. offsetY: this.parentInverted ? -1 : 1,
  10102. opacity: 0.15,
  10103. width: 3
  10104. };
  10105. var i,
  10106. shadow,
  10107. strokeWidth,
  10108. shadowElementOpacity,
  10109. update = false,
  10110. // compensate for inverted plot area
  10111. transform,
  10112. options;
  10113. if (shadowOptions === true) {
  10114. options = defaultShadowOptions;
  10115. }
  10116. else if (typeof shadowOptions === 'object') {
  10117. options = extend(defaultShadowOptions, shadowOptions);
  10118. }
  10119. // Update shadow when options change (#12091).
  10120. if (options) {
  10121. // Go over each key to look for change
  10122. if (options && oldShadowOptions) {
  10123. objectEach(options, function (value, key) {
  10124. if (value !== oldShadowOptions[key]) {
  10125. update = true;
  10126. }
  10127. });
  10128. }
  10129. if (update) {
  10130. this.destroyShadows();
  10131. }
  10132. this.oldShadowOptions = options;
  10133. }
  10134. if (!options) {
  10135. this.destroyShadows();
  10136. }
  10137. else if (!this.shadows) {
  10138. shadowElementOpacity = options.opacity / options.width;
  10139. transform = this.parentInverted ?
  10140. "translate(" + options.offsetY + ", " + options.offsetX + ")" :
  10141. "translate(" + options.offsetX + ", " + options.offsetY + ")";
  10142. for (i = 1; i <= options.width; i++) {
  10143. shadow = element.cloneNode(false);
  10144. strokeWidth = (options.width * 2) + 1 - (2 * i);
  10145. attr(shadow, {
  10146. stroke: (shadowOptions.color ||
  10147. palette.neutralColor100),
  10148. 'stroke-opacity': shadowElementOpacity * i,
  10149. 'stroke-width': strokeWidth,
  10150. transform: transform,
  10151. fill: 'none'
  10152. });
  10153. shadow.setAttribute('class', (shadow.getAttribute('class') || '') + ' highcharts-shadow');
  10154. if (cutOff) {
  10155. attr(shadow, 'height', Math.max(attr(shadow, 'height') - strokeWidth, 0));
  10156. shadow.cutHeight = strokeWidth;
  10157. }
  10158. if (group) {
  10159. group.element.appendChild(shadow);
  10160. }
  10161. else if (element.parentNode) {
  10162. element.parentNode.insertBefore(shadow, element);
  10163. }
  10164. shadows.push(shadow);
  10165. }
  10166. this.shadows = shadows;
  10167. }
  10168. return this;
  10169. };
  10170. /**
  10171. * Show the element after it has been hidden.
  10172. *
  10173. * @function Highcharts.SVGElement#show
  10174. *
  10175. * @param {boolean} [inherit=false]
  10176. * Set the visibility attribute to `inherit` rather than `visible`.
  10177. * The difference is that an element with `visibility="visible"`
  10178. * will be visible even if the parent is hidden.
  10179. *
  10180. * @return {Highcharts.SVGElement}
  10181. * Returns the SVGElement for chaining.
  10182. */
  10183. SVGElement.prototype.show = function (inherit) {
  10184. return this.attr({ visibility: inherit ? 'inherit' : 'visible' });
  10185. };
  10186. /**
  10187. * WebKit and Batik have problems with a stroke-width of zero, so in this
  10188. * case we remove the stroke attribute altogether. #1270, #1369, #3065,
  10189. * #3072.
  10190. *
  10191. * @private
  10192. * @function Highcharts.SVGElement#strokeSetter
  10193. * @param {number|string|ColorType} value
  10194. * @param {string} key
  10195. * @param {Highcharts.SVGDOMElement} element
  10196. */
  10197. SVGElement.prototype.strokeSetter = function (value, key, element) {
  10198. this[key] = value;
  10199. // Only apply the stroke attribute if the stroke width is defined and
  10200. // larger than 0
  10201. if (this.stroke && this['stroke-width']) {
  10202. // Use prototype as instance may be overridden
  10203. SVGElement.prototype.fillSetter.call(this, this.stroke, 'stroke', element);
  10204. element.setAttribute('stroke-width', this['stroke-width']);
  10205. this.hasStroke = true;
  10206. }
  10207. else if (key === 'stroke-width' && value === 0 && this.hasStroke) {
  10208. element.removeAttribute('stroke');
  10209. this.hasStroke = false;
  10210. }
  10211. else if (this.renderer.styledMode && this['stroke-width']) {
  10212. element.setAttribute('stroke-width', this['stroke-width']);
  10213. this.hasStroke = true;
  10214. }
  10215. };
  10216. /**
  10217. * Get the computed stroke width in pixel values. This is used extensively
  10218. * when drawing shapes to ensure the shapes are rendered crisp and
  10219. * positioned correctly relative to each other. Using
  10220. * `shape-rendering: crispEdges` leaves us less control over positioning,
  10221. * for example when we want to stack columns next to each other, or position
  10222. * things pixel-perfectly within the plot box.
  10223. *
  10224. * The common pattern when placing a shape is:
  10225. * - Create the SVGElement and add it to the DOM. In styled mode, it will
  10226. * now receive a stroke width from the style sheet. In classic mode we
  10227. * will add the `stroke-width` attribute.
  10228. * - Read the computed `elem.strokeWidth()`.
  10229. * - Place it based on the stroke width.
  10230. *
  10231. * @function Highcharts.SVGElement#strokeWidth
  10232. *
  10233. * @return {number}
  10234. * The stroke width in pixels. Even if the given stroke widtch (in CSS or by
  10235. * attributes) is based on `em` or other units, the pixel size is returned.
  10236. */
  10237. SVGElement.prototype.strokeWidth = function () {
  10238. // In non-styled mode, read the stroke width as set by .attr
  10239. if (!this.renderer.styledMode) {
  10240. return this['stroke-width'] || 0;
  10241. }
  10242. // In styled mode, read computed stroke width
  10243. var val = this.getStyle('stroke-width');
  10244. var ret = 0,
  10245. dummy;
  10246. // Read pixel values directly
  10247. if (val.indexOf('px') === val.length - 2) {
  10248. ret = pInt(val);
  10249. // Other values like em, pt etc need to be measured
  10250. }
  10251. else if (val !== '') {
  10252. dummy = doc.createElementNS(SVG_NS, 'rect');
  10253. attr(dummy, {
  10254. width: val,
  10255. 'stroke-width': 0
  10256. });
  10257. this.element.parentNode.appendChild(dummy);
  10258. ret = dummy.getBBox().width;
  10259. dummy.parentNode.removeChild(dummy);
  10260. }
  10261. return ret;
  10262. };
  10263. /**
  10264. * If one of the symbol size affecting parameters are changed,
  10265. * check all the others only once for each call to an element's
  10266. * .attr() method
  10267. *
  10268. * @private
  10269. * @function Highcharts.SVGElement#symbolAttr
  10270. *
  10271. * @param {Highcharts.SVGAttributes} hash
  10272. * The attributes to set.
  10273. */
  10274. SVGElement.prototype.symbolAttr = function (hash) {
  10275. var wrapper = this;
  10276. [
  10277. 'x',
  10278. 'y',
  10279. 'r',
  10280. 'start',
  10281. 'end',
  10282. 'width',
  10283. 'height',
  10284. 'innerR',
  10285. 'anchorX',
  10286. 'anchorY',
  10287. 'clockwise'
  10288. ].forEach(function (key) {
  10289. wrapper[key] = pick(hash[key], wrapper[key]);
  10290. });
  10291. wrapper.attr({
  10292. d: wrapper.renderer.symbols[wrapper.symbolName](wrapper.x, wrapper.y, wrapper.width, wrapper.height, wrapper)
  10293. });
  10294. };
  10295. /**
  10296. * @private
  10297. * @function Highcharts.SVGElement#textSetter
  10298. * @param {string} value
  10299. */
  10300. SVGElement.prototype.textSetter = function (value) {
  10301. if (value !== this.textStr) {
  10302. // Delete size caches when the text changes
  10303. // delete this.bBox; // old code in series-label
  10304. delete this.textPxLength;
  10305. this.textStr = value;
  10306. if (this.added) {
  10307. this.renderer.buildText(this);
  10308. }
  10309. }
  10310. };
  10311. /**
  10312. * @private
  10313. * @function Highcharts.SVGElement#titleSetter
  10314. * @param {string} value
  10315. */
  10316. SVGElement.prototype.titleSetter = function (value) {
  10317. var el = this.element;
  10318. var titleNode = el.getElementsByTagName('title')[0] ||
  10319. doc.createElementNS(this.SVG_NS, 'title');
  10320. // Move to first child
  10321. if (el.insertBefore) {
  10322. el.insertBefore(titleNode, el.firstChild);
  10323. }
  10324. else {
  10325. el.appendChild(titleNode);
  10326. }
  10327. // Replace text content and escape markup
  10328. titleNode.textContent =
  10329. // #3276, #3895
  10330. String(pick(value, ''))
  10331. .replace(/<[^>]*>/g, '')
  10332. .replace(/&lt;/g, '<')
  10333. .replace(/&gt;/g, '>');
  10334. };
  10335. /**
  10336. * Bring the element to the front. Alternatively, a new zIndex can be set.
  10337. *
  10338. * @sample highcharts/members/element-tofront/
  10339. * Click an element to bring it to front
  10340. *
  10341. * @function Highcharts.SVGElement#toFront
  10342. *
  10343. * @return {Highcharts.SVGElement}
  10344. * Returns the SVGElement for chaining.
  10345. */
  10346. SVGElement.prototype.toFront = function () {
  10347. var element = this.element;
  10348. element.parentNode.appendChild(element);
  10349. return this;
  10350. };
  10351. /**
  10352. * Move an object and its children by x and y values.
  10353. *
  10354. * @function Highcharts.SVGElement#translate
  10355. *
  10356. * @param {number} x
  10357. * The x value.
  10358. *
  10359. * @param {number} y
  10360. * The y value.
  10361. *
  10362. * @return {Highcharts.SVGElement}
  10363. */
  10364. SVGElement.prototype.translate = function (x, y) {
  10365. return this.attr({
  10366. translateX: x,
  10367. translateY: y
  10368. });
  10369. };
  10370. /**
  10371. * Update the shadow elements with new attributes.
  10372. *
  10373. * @private
  10374. * @function Highcharts.SVGElement#updateShadows
  10375. *
  10376. * @param {string} key
  10377. * The attribute name.
  10378. *
  10379. * @param {number} value
  10380. * The value of the attribute.
  10381. *
  10382. * @param {Function} setter
  10383. * The setter function, inherited from the parent wrapper.
  10384. */
  10385. SVGElement.prototype.updateShadows = function (key, value, setter) {
  10386. var shadows = this.shadows;
  10387. if (shadows) {
  10388. var i = shadows.length;
  10389. while (i--) {
  10390. setter.call(shadows[i], key === 'height' ?
  10391. Math.max(value - (shadows[i].cutHeight || 0), 0) :
  10392. key === 'd' ? this.d : value, key, shadows[i]);
  10393. }
  10394. }
  10395. };
  10396. /**
  10397. * Update the transform attribute based on internal properties. Deals with
  10398. * the custom `translateX`, `translateY`, `rotation`, `scaleX` and `scaleY`
  10399. * attributes and updates the SVG `transform` attribute.
  10400. *
  10401. * @private
  10402. * @function Highcharts.SVGElement#updateTransform
  10403. */
  10404. SVGElement.prototype.updateTransform = function () {
  10405. var wrapper = this,
  10406. scaleX = wrapper.scaleX,
  10407. scaleY = wrapper.scaleY,
  10408. inverted = wrapper.inverted,
  10409. rotation = wrapper.rotation,
  10410. matrix = wrapper.matrix,
  10411. element = wrapper.element;
  10412. var translateX = wrapper.translateX || 0,
  10413. translateY = wrapper.translateY || 0;
  10414. // Flipping affects translate as adjustment for flipping around the
  10415. // group's axis
  10416. if (inverted) {
  10417. translateX += wrapper.width;
  10418. translateY += wrapper.height;
  10419. }
  10420. // Apply translate. Nearly all transformed elements have translation,
  10421. // so instead of checking for translate = 0, do it always (#1767,
  10422. // #1846).
  10423. var transform = ['translate(' + translateX + ',' + translateY + ')'];
  10424. // apply matrix
  10425. if (defined(matrix)) {
  10426. transform.push('matrix(' + matrix.join(',') + ')');
  10427. }
  10428. // apply rotation
  10429. if (inverted) {
  10430. transform.push('rotate(90) scale(-1,1)');
  10431. }
  10432. else if (rotation) { // text rotation
  10433. transform.push('rotate(' + rotation + ' ' +
  10434. pick(this.rotationOriginX, element.getAttribute('x'), 0) +
  10435. ' ' +
  10436. pick(this.rotationOriginY, element.getAttribute('y') || 0) + ')');
  10437. }
  10438. // apply scale
  10439. if (defined(scaleX) || defined(scaleY)) {
  10440. transform.push('scale(' + pick(scaleX, 1) + ' ' + pick(scaleY, 1) + ')');
  10441. }
  10442. if (transform.length) {
  10443. element.setAttribute('transform', transform.join(' '));
  10444. }
  10445. };
  10446. /**
  10447. * @private
  10448. * @function Highcharts.SVGElement#visibilitySetter
  10449. *
  10450. * @param {string} value
  10451. *
  10452. * @param {string} key
  10453. *
  10454. * @param {Highcharts.SVGDOMElement} element
  10455. *
  10456. * @return {void}
  10457. */
  10458. SVGElement.prototype.visibilitySetter = function (value, key, element) {
  10459. // IE9-11 doesn't handle visibilty:inherit well, so we remove the
  10460. // attribute instead (#2881, #3909)
  10461. if (value === 'inherit') {
  10462. element.removeAttribute(key);
  10463. }
  10464. else if (this[key] !== value) { // #6747
  10465. element.setAttribute(key, value);
  10466. }
  10467. this[key] = value;
  10468. };
  10469. /**
  10470. * @private
  10471. * @function Highcharts.SVGElement#xGetter
  10472. *
  10473. * @param {string} key
  10474. *
  10475. * @return {number|string|null}
  10476. */
  10477. SVGElement.prototype.xGetter = function (key) {
  10478. if (this.element.nodeName === 'circle') {
  10479. if (key === 'x') {
  10480. key = 'cx';
  10481. }
  10482. else if (key === 'y') {
  10483. key = 'cy';
  10484. }
  10485. }
  10486. return this._defaultGetter(key);
  10487. };
  10488. /**
  10489. * @private
  10490. * @function Highcharts.SVGElement#zIndexSetter
  10491. * @param {number} [value]
  10492. * @param {string} [key]
  10493. * @return {boolean}
  10494. */
  10495. SVGElement.prototype.zIndexSetter = function (value, key) {
  10496. var renderer = this.renderer,
  10497. parentGroup = this.parentGroup,
  10498. parentWrapper = parentGroup || renderer,
  10499. parentNode = parentWrapper.element || renderer.box,
  10500. element = this.element,
  10501. svgParent = parentNode === renderer.box;
  10502. var childNodes,
  10503. otherElement,
  10504. otherZIndex,
  10505. inserted = false,
  10506. undefinedOtherZIndex,
  10507. run = this.added,
  10508. i;
  10509. if (defined(value)) {
  10510. // So we can read it for other elements in the group
  10511. element.setAttribute('data-z-index', value);
  10512. value = +value;
  10513. if (this[key] === value) {
  10514. // Only update when needed (#3865)
  10515. run = false;
  10516. }
  10517. }
  10518. else if (defined(this[key])) {
  10519. element.removeAttribute('data-z-index');
  10520. }
  10521. this[key] = value;
  10522. // Insert according to this and other elements' zIndex. Before .add() is
  10523. // called, nothing is done. Then on add, or by later calls to
  10524. // zIndexSetter, the node is placed on the right place in the DOM.
  10525. if (run) {
  10526. value = this.zIndex;
  10527. if (value && parentGroup) {
  10528. parentGroup.handleZ = true;
  10529. }
  10530. childNodes = parentNode.childNodes;
  10531. for (i = childNodes.length - 1; i >= 0 && !inserted; i--) {
  10532. otherElement = childNodes[i];
  10533. otherZIndex = otherElement.getAttribute('data-z-index');
  10534. undefinedOtherZIndex = !defined(otherZIndex);
  10535. if (otherElement !== element) {
  10536. if (
  10537. // Negative zIndex versus no zIndex:
  10538. // On all levels except the highest. If the parent is
  10539. // <svg>, then we don't want to put items before <desc>
  10540. // or <defs>
  10541. value < 0 &&
  10542. undefinedOtherZIndex &&
  10543. !svgParent &&
  10544. !i) {
  10545. parentNode.insertBefore(element, childNodes[i]);
  10546. inserted = true;
  10547. }
  10548. else if (
  10549. // Insert after the first element with a lower zIndex
  10550. pInt(otherZIndex) <= value ||
  10551. // If negative zIndex, add this before first undefined
  10552. // zIndex element
  10553. (undefinedOtherZIndex &&
  10554. (!defined(value) || value >= 0))) {
  10555. parentNode.insertBefore(element, childNodes[i + 1] || null // null for oldIE export
  10556. );
  10557. inserted = true;
  10558. }
  10559. }
  10560. }
  10561. if (!inserted) {
  10562. parentNode.insertBefore(element, childNodes[svgParent ? 3 : 0] || null // null for oldIE
  10563. );
  10564. inserted = true;
  10565. }
  10566. }
  10567. return inserted;
  10568. };
  10569. return SVGElement;
  10570. }());
  10571. // Some shared setters and getters
  10572. SVGElement.prototype['stroke-widthSetter'] = SVGElement.prototype.strokeSetter;
  10573. SVGElement.prototype.yGetter = SVGElement.prototype.xGetter;
  10574. SVGElement.prototype.matrixSetter =
  10575. SVGElement.prototype.rotationOriginXSetter =
  10576. SVGElement.prototype.rotationOriginYSetter =
  10577. SVGElement.prototype.rotationSetter =
  10578. SVGElement.prototype.scaleXSetter =
  10579. SVGElement.prototype.scaleYSetter =
  10580. SVGElement.prototype.translateXSetter =
  10581. SVGElement.prototype.translateYSetter =
  10582. SVGElement.prototype.verticalAlignSetter = function (value, key) {
  10583. this[key] = value;
  10584. this.doTransform = true;
  10585. };
  10586. /* *
  10587. *
  10588. * API Declarations
  10589. *
  10590. * */
  10591. /**
  10592. * Reference to the global SVGElement class as a workaround for a name conflict
  10593. * in the Highcharts namespace.
  10594. *
  10595. * @global
  10596. * @typedef {global.SVGElement} GlobalSVGElement
  10597. *
  10598. * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGElement
  10599. */
  10600. /**
  10601. * The horizontal alignment of an element.
  10602. *
  10603. * @typedef {"center"|"left"|"right"} Highcharts.AlignValue
  10604. */
  10605. /**
  10606. * Options to align the element relative to the chart or another box.
  10607. *
  10608. * @interface Highcharts.AlignObject
  10609. */ /**
  10610. * Horizontal alignment. Can be one of `left`, `center` and `right`.
  10611. *
  10612. * @name Highcharts.AlignObject#align
  10613. * @type {Highcharts.AlignValue|undefined}
  10614. *
  10615. * @default left
  10616. */ /**
  10617. * Vertical alignment. Can be one of `top`, `middle` and `bottom`.
  10618. *
  10619. * @name Highcharts.AlignObject#verticalAlign
  10620. * @type {Highcharts.VerticalAlignValue|undefined}
  10621. *
  10622. * @default top
  10623. */ /**
  10624. * Horizontal pixel offset from alignment.
  10625. *
  10626. * @name Highcharts.AlignObject#x
  10627. * @type {number|undefined}
  10628. *
  10629. * @default 0
  10630. */ /**
  10631. * Vertical pixel offset from alignment.
  10632. *
  10633. * @name Highcharts.AlignObject#y
  10634. * @type {number|undefined}
  10635. *
  10636. * @default 0
  10637. */ /**
  10638. * Use the `transform` attribute with translateX and translateY custom
  10639. * attributes to align this elements rather than `x` and `y` attributes.
  10640. *
  10641. * @name Highcharts.AlignObject#alignByTranslate
  10642. * @type {boolean|undefined}
  10643. *
  10644. * @default false
  10645. */
  10646. /**
  10647. * Bounding box of an element.
  10648. *
  10649. * @interface Highcharts.BBoxObject
  10650. * @extends Highcharts.PositionObject
  10651. */ /**
  10652. * Height of the bounding box.
  10653. *
  10654. * @name Highcharts.BBoxObject#height
  10655. * @type {number}
  10656. */ /**
  10657. * Width of the bounding box.
  10658. *
  10659. * @name Highcharts.BBoxObject#width
  10660. * @type {number}
  10661. */ /**
  10662. * Horizontal position of the bounding box.
  10663. *
  10664. * @name Highcharts.BBoxObject#x
  10665. * @type {number}
  10666. */ /**
  10667. * Vertical position of the bounding box.
  10668. *
  10669. * @name Highcharts.BBoxObject#y
  10670. * @type {number}
  10671. */
  10672. /**
  10673. * An object of key-value pairs for SVG attributes. Attributes in Highcharts
  10674. * elements for the most parts correspond to SVG, but some are specific to
  10675. * Highcharts, like `zIndex`, `rotation`, `rotationOriginX`,
  10676. * `rotationOriginY`, `translateX`, `translateY`, `scaleX` and `scaleY`. SVG
  10677. * attributes containing a hyphen are _not_ camel-cased, they should be
  10678. * quoted to preserve the hyphen.
  10679. *
  10680. * @example
  10681. * {
  10682. * 'stroke': '#ff0000', // basic
  10683. * 'stroke-width': 2, // hyphenated
  10684. * 'rotation': 45 // custom
  10685. * 'd': ['M', 10, 10, 'L', 30, 30, 'z'] // path definition, note format
  10686. * }
  10687. *
  10688. * @interface Highcharts.SVGAttributes
  10689. */ /**
  10690. * @name Highcharts.SVGAttributes#[key:string]
  10691. * @type {*}
  10692. */ /**
  10693. * @name Highcharts.SVGAttributes#d
  10694. * @type {string|Highcharts.SVGPathArray|undefined}
  10695. */ /**
  10696. * @name Highcharts.SVGAttributes#fill
  10697. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject|undefined}
  10698. */ /**
  10699. * @name Highcharts.SVGAttributes#inverted
  10700. * @type {boolean|undefined}
  10701. */ /**
  10702. * @name Highcharts.SVGAttributes#matrix
  10703. * @type {Array<number>|undefined}
  10704. */ /**
  10705. * @name Highcharts.SVGAttributes#rotation
  10706. * @type {number|undefined}
  10707. */ /**
  10708. * @name Highcharts.SVGAttributes#rotationOriginX
  10709. * @type {number|undefined}
  10710. */ /**
  10711. * @name Highcharts.SVGAttributes#rotationOriginY
  10712. * @type {number|undefined}
  10713. */ /**
  10714. * @name Highcharts.SVGAttributes#scaleX
  10715. * @type {number|undefined}
  10716. */ /**
  10717. * @name Highcharts.SVGAttributes#scaleY
  10718. * @type {number|undefined}
  10719. */ /**
  10720. * @name Highcharts.SVGAttributes#stroke
  10721. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject|undefined}
  10722. */ /**
  10723. * @name Highcharts.SVGAttributes#style
  10724. * @type {string|Highcharts.CSSObject|undefined}
  10725. */ /**
  10726. * @name Highcharts.SVGAttributes#translateX
  10727. * @type {number|undefined}
  10728. */ /**
  10729. * @name Highcharts.SVGAttributes#translateY
  10730. * @type {number|undefined}
  10731. */ /**
  10732. * @name Highcharts.SVGAttributes#zIndex
  10733. * @type {number|undefined}
  10734. */
  10735. /**
  10736. * An SVG DOM element. The type is a reference to the regular SVGElement in the
  10737. * global scope.
  10738. *
  10739. * @typedef {globals.GlobalSVGElement} Highcharts.SVGDOMElement
  10740. *
  10741. * @see https://developer.mozilla.org/en-US/docs/Web/API/SVGElement
  10742. */
  10743. /**
  10744. * The vertical alignment of an element.
  10745. *
  10746. * @typedef {"bottom"|"middle"|"top"} Highcharts.VerticalAlignValue
  10747. */
  10748. ''; // detach doclets above
  10749. return SVGElement;
  10750. });
  10751. _registerModule(_modules, 'Core/Renderer/RendererRegistry.js', [_modules['Core/Globals.js']], function (H) {
  10752. /* *
  10753. *
  10754. * (c) 2010-2021 Torstein Honsi
  10755. *
  10756. * License: www.highcharts.com/license
  10757. *
  10758. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  10759. *
  10760. * */
  10761. /* *
  10762. *
  10763. * Namespace
  10764. *
  10765. * */
  10766. var RendererRegistry;
  10767. (function (RendererRegistry) {
  10768. /* *
  10769. *
  10770. * Static Properties
  10771. *
  10772. * */
  10773. var defaultRenderer;
  10774. RendererRegistry.rendererTypes = {};
  10775. /* *
  10776. *
  10777. * Static Functions
  10778. *
  10779. * */
  10780. /**
  10781. * Gets a registered renderer class. If no renderer type is provided or the
  10782. * requested renderer was not founded, the default renderer is returned.
  10783. *
  10784. * @param {string} [rendererType]
  10785. * Renderer type or the default renderer.
  10786. *
  10787. * @return {Highcharts.Class<Highcharts.SVGRenderer>}
  10788. * Returns the requested renderer class or the default renderer class.
  10789. */
  10790. function getRendererType(rendererType) {
  10791. if (rendererType === void 0) { rendererType = defaultRenderer; }
  10792. return (RendererRegistry.rendererTypes[rendererType] || RendererRegistry.rendererTypes[defaultRenderer]);
  10793. }
  10794. RendererRegistry.getRendererType = getRendererType;
  10795. /**
  10796. * Register a renderer class.
  10797. *
  10798. * @param {string} rendererType
  10799. * Renderer type to register.
  10800. *
  10801. * @param {Highcharts.Class<Highcharts.SVGRenderer>} rendererClass
  10802. * Returns the requested renderer class or the default renderer class.
  10803. *
  10804. * @param {boolean} setAsDefault
  10805. * Sets the renderer class as the default renderer.
  10806. */
  10807. function registerRendererType(rendererType, rendererClass, setAsDefault) {
  10808. RendererRegistry.rendererTypes[rendererType] = rendererClass;
  10809. if (!defaultRenderer || setAsDefault) {
  10810. defaultRenderer = rendererType;
  10811. H.Renderer = rendererClass; // compatibility
  10812. }
  10813. }
  10814. RendererRegistry.registerRendererType = registerRendererType;
  10815. })(RendererRegistry || (RendererRegistry = {}));
  10816. /* *
  10817. *
  10818. * Export
  10819. *
  10820. * */
  10821. return RendererRegistry;
  10822. });
  10823. _registerModule(_modules, 'Core/Renderer/SVG/SVGLabel.js', [_modules['Core/Renderer/SVG/SVGElement.js'], _modules['Core/Utilities.js']], function (SVGElement, U) {
  10824. /* *
  10825. *
  10826. * (c) 2010-2021 Torstein Honsi
  10827. *
  10828. * License: www.highcharts.com/license
  10829. *
  10830. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  10831. *
  10832. * */
  10833. var __extends = (this && this.__extends) || (function () {
  10834. var extendStatics = function (d,
  10835. b) {
  10836. extendStatics = Object.setPrototypeOf ||
  10837. ({ __proto__: [] } instanceof Array && function (d,
  10838. b) { d.__proto__ = b; }) ||
  10839. function (d,
  10840. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  10841. return extendStatics(d, b);
  10842. };
  10843. return function (d, b) {
  10844. extendStatics(d, b);
  10845. function __() { this.constructor = d; }
  10846. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  10847. };
  10848. })();
  10849. var defined = U.defined,
  10850. extend = U.extend,
  10851. isNumber = U.isNumber,
  10852. merge = U.merge,
  10853. pick = U.pick,
  10854. removeEvent = U.removeEvent;
  10855. /* *
  10856. *
  10857. * Class
  10858. *
  10859. * */
  10860. /**
  10861. * SVG label to render text.
  10862. * @private
  10863. * @class
  10864. * @name Highcharts.SVGLabel
  10865. * @augments Highcharts.SVGElement
  10866. */
  10867. var SVGLabel = /** @class */ (function (_super) {
  10868. __extends(SVGLabel, _super);
  10869. /* *
  10870. *
  10871. * Constructors
  10872. *
  10873. * */
  10874. function SVGLabel(renderer, str, x, y, shape, anchorX, anchorY, useHTML, baseline, className) {
  10875. var _this = _super.call(this) || this;
  10876. _this.paddingLeftSetter = _this.paddingSetter;
  10877. _this.paddingRightSetter = _this.paddingSetter;
  10878. _this.init(renderer, 'g');
  10879. _this.textStr = str;
  10880. _this.x = x;
  10881. _this.y = y;
  10882. _this.anchorX = anchorX;
  10883. _this.anchorY = anchorY;
  10884. _this.baseline = baseline;
  10885. _this.className = className;
  10886. _this.addClass(className === 'button' ?
  10887. 'highcharts-no-tooltip' :
  10888. 'highcharts-label');
  10889. if (className) {
  10890. _this.addClass('highcharts-' + className);
  10891. }
  10892. _this.text = renderer.text('', 0, 0, useHTML).attr({ zIndex: 1 });
  10893. // Validate the shape argument
  10894. var hasBGImage;
  10895. if (typeof shape === 'string') {
  10896. hasBGImage = /^url\((.*?)\)$/.test(shape);
  10897. if (hasBGImage || _this.renderer.symbols[shape]) {
  10898. _this.symbolKey = shape;
  10899. }
  10900. }
  10901. _this.bBox = SVGLabel.emptyBBox;
  10902. _this.padding = 3;
  10903. _this.baselineOffset = 0;
  10904. _this.needsBox = renderer.styledMode || hasBGImage;
  10905. _this.deferredAttr = {};
  10906. _this.alignFactor = 0;
  10907. return _this;
  10908. }
  10909. /* *
  10910. *
  10911. * Functions
  10912. *
  10913. * */
  10914. SVGLabel.prototype.alignSetter = function (value) {
  10915. var alignFactor = ({
  10916. left: 0,
  10917. center: 0.5,
  10918. right: 1
  10919. })[value];
  10920. if (alignFactor !== this.alignFactor) {
  10921. this.alignFactor = alignFactor;
  10922. // Bounding box exists, means we're dynamically changing
  10923. if (this.bBox && isNumber(this.xSetting)) {
  10924. this.attr({ x: this.xSetting }); // #5134
  10925. }
  10926. }
  10927. };
  10928. SVGLabel.prototype.anchorXSetter = function (value, key) {
  10929. this.anchorX = value;
  10930. this.boxAttr(key, Math.round(value) - this.getCrispAdjust() - this.xSetting);
  10931. };
  10932. SVGLabel.prototype.anchorYSetter = function (value, key) {
  10933. this.anchorY = value;
  10934. this.boxAttr(key, value - this.ySetting);
  10935. };
  10936. /*
  10937. * Set a box attribute, or defer it if the box is not yet created
  10938. */
  10939. SVGLabel.prototype.boxAttr = function (key, value) {
  10940. if (this.box) {
  10941. this.box.attr(key, value);
  10942. }
  10943. else {
  10944. this.deferredAttr[key] = value;
  10945. }
  10946. };
  10947. /*
  10948. * Pick up some properties and apply them to the text instead of the
  10949. * wrapper.
  10950. */
  10951. SVGLabel.prototype.css = function (styles) {
  10952. if (styles) {
  10953. var textStyles_1 = {};
  10954. // Create a copy to avoid altering the original object
  10955. // (#537)
  10956. styles = merge(styles);
  10957. SVGLabel.textProps.forEach(function (prop) {
  10958. if (typeof styles[prop] !== 'undefined') {
  10959. textStyles_1[prop] = styles[prop];
  10960. delete styles[prop];
  10961. }
  10962. });
  10963. this.text.css(textStyles_1);
  10964. var isWidth = 'width' in textStyles_1, isFontStyle = ('fontSize' in textStyles_1 || 'fontWeight' in textStyles_1);
  10965. // Update existing text, box (#9400, #12163)
  10966. if (isFontStyle) {
  10967. this.updateTextPadding();
  10968. }
  10969. else if (isWidth) {
  10970. this.updateBoxSize();
  10971. }
  10972. }
  10973. return SVGElement.prototype.css.call(this, styles);
  10974. };
  10975. /*
  10976. * Destroy and release memory.
  10977. */
  10978. SVGLabel.prototype.destroy = function () {
  10979. // Added by button implementation
  10980. removeEvent(this.element, 'mouseenter');
  10981. removeEvent(this.element, 'mouseleave');
  10982. if (this.text) {
  10983. this.text.destroy();
  10984. }
  10985. if (this.box) {
  10986. this.box = this.box.destroy();
  10987. }
  10988. // Call base implementation to destroy the rest
  10989. SVGElement.prototype.destroy.call(this);
  10990. return void 0;
  10991. };
  10992. SVGLabel.prototype.fillSetter = function (value, key) {
  10993. if (value) {
  10994. this.needsBox = true;
  10995. }
  10996. // for animation getter (#6776)
  10997. this.fill = value;
  10998. this.boxAttr(key, value);
  10999. };
  11000. /*
  11001. * Return the bounding box of the box, not the group.
  11002. */
  11003. SVGLabel.prototype.getBBox = function () {
  11004. // If we have a text string and the DOM bBox was 0, it typically means
  11005. // that the label was first rendered hidden, so we need to update the
  11006. // bBox (#15246)
  11007. if (this.textStr && this.bBox.width === 0 && this.bBox.height === 0) {
  11008. this.updateBoxSize();
  11009. }
  11010. var padding = this.padding;
  11011. var paddingLeft = pick(this.paddingLeft,
  11012. padding);
  11013. return {
  11014. width: this.width,
  11015. height: this.height,
  11016. x: this.bBox.x - paddingLeft,
  11017. y: this.bBox.y - padding
  11018. };
  11019. };
  11020. SVGLabel.prototype.getCrispAdjust = function () {
  11021. return this.renderer.styledMode && this.box ?
  11022. this.box.strokeWidth() % 2 / 2 :
  11023. (this['stroke-width'] ? parseInt(this['stroke-width'], 10) : 0) % 2 / 2;
  11024. };
  11025. SVGLabel.prototype.heightSetter = function (value) {
  11026. this.heightSetting = value;
  11027. };
  11028. // Event handling. In case of useHTML, we need to make sure that events
  11029. // are captured on the span as well, and that mouseenter/mouseleave
  11030. // between the SVG group and the HTML span are not treated as real
  11031. // enter/leave events. #13310.
  11032. SVGLabel.prototype.on = function (eventType, handler) {
  11033. var label = this;
  11034. var text = label.text;
  11035. var span = text && text.element.tagName === 'SPAN' ? text : void 0;
  11036. var selectiveHandler;
  11037. if (span) {
  11038. selectiveHandler = function (e) {
  11039. if ((eventType === 'mouseenter' ||
  11040. eventType === 'mouseleave') &&
  11041. e.relatedTarget instanceof Element &&
  11042. (
  11043. // #14110
  11044. label.element.compareDocumentPosition(e.relatedTarget) & Node.DOCUMENT_POSITION_CONTAINED_BY ||
  11045. span.element.compareDocumentPosition(e.relatedTarget) & Node.DOCUMENT_POSITION_CONTAINED_BY)) {
  11046. return;
  11047. }
  11048. handler.call(label.element, e);
  11049. };
  11050. span.on(eventType, selectiveHandler);
  11051. }
  11052. SVGElement.prototype.on.call(label, eventType, selectiveHandler || handler);
  11053. return label;
  11054. };
  11055. /*
  11056. * After the text element is added, get the desired size of the border
  11057. * box and add it before the text in the DOM.
  11058. */
  11059. SVGLabel.prototype.onAdd = function () {
  11060. var str = this.textStr;
  11061. this.text.add(this);
  11062. this.attr({
  11063. // Alignment is available now (#3295, 0 not rendered if given
  11064. // as a value)
  11065. text: (defined(str) ? str : ''),
  11066. x: this.x,
  11067. y: this.y
  11068. });
  11069. if (this.box && defined(this.anchorX)) {
  11070. this.attr({
  11071. anchorX: this.anchorX,
  11072. anchorY: this.anchorY
  11073. });
  11074. }
  11075. };
  11076. SVGLabel.prototype.paddingSetter = function (value, key) {
  11077. if (!isNumber(value)) {
  11078. this[key] = void 0;
  11079. }
  11080. else if (value !== this[key]) {
  11081. this[key] = value;
  11082. this.updateTextPadding();
  11083. }
  11084. };
  11085. SVGLabel.prototype.rSetter = function (value, key) {
  11086. this.boxAttr(key, value);
  11087. };
  11088. SVGLabel.prototype.shadow = function (b) {
  11089. if (b && !this.renderer.styledMode) {
  11090. this.updateBoxSize();
  11091. if (this.box) {
  11092. this.box.shadow(b);
  11093. }
  11094. }
  11095. return this;
  11096. };
  11097. SVGLabel.prototype.strokeSetter = function (value, key) {
  11098. // for animation getter (#6776)
  11099. this.stroke = value;
  11100. this.boxAttr(key, value);
  11101. };
  11102. SVGLabel.prototype['stroke-widthSetter'] = function (value, key) {
  11103. if (value) {
  11104. this.needsBox = true;
  11105. }
  11106. this['stroke-width'] = value;
  11107. this.boxAttr(key, value);
  11108. };
  11109. SVGLabel.prototype['text-alignSetter'] = function (value) {
  11110. this.textAlign = value;
  11111. };
  11112. SVGLabel.prototype.textSetter = function (text) {
  11113. if (typeof text !== 'undefined') {
  11114. // Must use .attr to ensure transforms are done (#10009)
  11115. this.text.attr({ text: text });
  11116. }
  11117. this.updateTextPadding();
  11118. };
  11119. /*
  11120. * This function runs after the label is added to the DOM (when the bounding
  11121. * box is available), and after the text of the label is updated to detect
  11122. * the new bounding box and reflect it in the border box.
  11123. */
  11124. SVGLabel.prototype.updateBoxSize = function () {
  11125. var style = this.text.element.style,
  11126. attribs = {},
  11127. padding = this.padding,
  11128. // #12165 error when width is null (auto)
  11129. // #12163 when fontweight: bold, recalculate bBox withot cache
  11130. // #3295 && 3514 box failure when string equals 0
  11131. bBox = this.bBox = (((!isNumber(this.widthSetting) ||
  11132. !isNumber(this.heightSetting) ||
  11133. this.textAlign) && defined(this.text.textStr)) ?
  11134. this.text.getBBox() :
  11135. SVGLabel.emptyBBox);
  11136. var crispAdjust;
  11137. this.width = this.getPaddedWidth();
  11138. this.height = (this.heightSetting || bBox.height || 0) + 2 * padding;
  11139. var metrics = this.renderer.fontMetrics(style && style.fontSize,
  11140. this.text);
  11141. // Update the label-scoped y offset. Math.min because of inline
  11142. // style (#9400)
  11143. this.baselineOffset = padding + Math.min(
  11144. // When applicable, use the font size of the first line (#15707)
  11145. (this.text.firstLineMetrics || metrics).b,
  11146. // When the height is 0, there is no bBox, so go with the font
  11147. // metrics. Highmaps CSS demos.
  11148. bBox.height || Infinity);
  11149. // #15491: Vertical centering
  11150. if (this.heightSetting) {
  11151. this.baselineOffset += (this.heightSetting - metrics.h) / 2;
  11152. }
  11153. if (this.needsBox) {
  11154. // Create the border box if it is not already present
  11155. if (!this.box) {
  11156. // Symbol definition exists (#5324)
  11157. var box = this.box = this.symbolKey ?
  11158. this.renderer.symbol(this.symbolKey) :
  11159. this.renderer.rect();
  11160. box.addClass(// Don't use label className for buttons
  11161. (this.className === 'button' ? '' : 'highcharts-label-box') +
  11162. (this.className ? ' highcharts-' + this.className + '-box' : ''));
  11163. box.add(this);
  11164. }
  11165. crispAdjust = this.getCrispAdjust();
  11166. attribs.x = crispAdjust;
  11167. attribs.y = (this.baseline ? -this.baselineOffset : 0) + crispAdjust;
  11168. // Apply the box attributes
  11169. attribs.width = Math.round(this.width);
  11170. attribs.height = Math.round(this.height);
  11171. this.box.attr(extend(attribs, this.deferredAttr));
  11172. this.deferredAttr = {};
  11173. }
  11174. };
  11175. /*
  11176. * This function runs after setting text or padding, but only if padding
  11177. * is changed.
  11178. */
  11179. SVGLabel.prototype.updateTextPadding = function () {
  11180. var text = this.text;
  11181. this.updateBoxSize();
  11182. // Determine y based on the baseline
  11183. var textY = this.baseline ? 0 : this.baselineOffset;
  11184. var textX = pick(this.paddingLeft,
  11185. this.padding);
  11186. // compensate for alignment
  11187. if (defined(this.widthSetting) &&
  11188. this.bBox &&
  11189. (this.textAlign === 'center' || this.textAlign === 'right')) {
  11190. textX += { center: 0.5, right: 1 }[this.textAlign] *
  11191. (this.widthSetting - this.bBox.width);
  11192. }
  11193. // update if anything changed
  11194. if (textX !== text.x || textY !== text.y) {
  11195. text.attr('x', textX);
  11196. // #8159 - prevent misplaced data labels in treemap
  11197. // (useHTML: true)
  11198. if (text.hasBoxWidthChanged) {
  11199. this.bBox = text.getBBox(true);
  11200. }
  11201. if (typeof textY !== 'undefined') {
  11202. text.attr('y', textY);
  11203. }
  11204. }
  11205. // record current values
  11206. text.x = textX;
  11207. text.y = textY;
  11208. };
  11209. SVGLabel.prototype.widthSetter = function (value) {
  11210. // width:auto => null
  11211. this.widthSetting = isNumber(value) ? value : void 0;
  11212. };
  11213. SVGLabel.prototype.getPaddedWidth = function () {
  11214. var padding = this.padding;
  11215. var paddingLeft = pick(this.paddingLeft,
  11216. padding);
  11217. var paddingRight = pick(this.paddingRight,
  11218. padding);
  11219. return (this.widthSetting || this.bBox.width || 0) + paddingLeft + paddingRight;
  11220. };
  11221. SVGLabel.prototype.xSetter = function (value) {
  11222. this.x = value; // for animation getter
  11223. if (this.alignFactor) {
  11224. value -= this.alignFactor * this.getPaddedWidth();
  11225. // Force animation even when setting to the same value (#7898)
  11226. this['forceAnimate:x'] = true;
  11227. }
  11228. this.xSetting = Math.round(value);
  11229. this.attr('translateX', this.xSetting);
  11230. };
  11231. SVGLabel.prototype.ySetter = function (value) {
  11232. this.ySetting = this.y = Math.round(value);
  11233. this.attr('translateY', this.ySetting);
  11234. };
  11235. /* *
  11236. *
  11237. * Static Properties
  11238. *
  11239. * */
  11240. SVGLabel.emptyBBox = { width: 0, height: 0, x: 0, y: 0 };
  11241. /**
  11242. * For labels, these CSS properties are applied to the `text` node directly.
  11243. *
  11244. * @private
  11245. * @name Highcharts.SVGLabel#textProps
  11246. * @type {Array<string>}
  11247. */
  11248. SVGLabel.textProps = [
  11249. 'color', 'direction', 'fontFamily', 'fontSize', 'fontStyle',
  11250. 'fontWeight', 'lineHeight', 'textAlign', 'textDecoration',
  11251. 'textOutline', 'textOverflow', 'width'
  11252. ];
  11253. return SVGLabel;
  11254. }(SVGElement));
  11255. return SVGLabel;
  11256. });
  11257. _registerModule(_modules, 'Core/Renderer/SVG/Symbols.js', [_modules['Core/Utilities.js']], function (U) {
  11258. /* *
  11259. *
  11260. * (c) 2010-2021 Torstein Honsi
  11261. *
  11262. * License: www.highcharts.com/license
  11263. *
  11264. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  11265. *
  11266. * */
  11267. var defined = U.defined,
  11268. isNumber = U.isNumber,
  11269. pick = U.pick;
  11270. /* *
  11271. *
  11272. * Functions
  11273. *
  11274. * */
  11275. /* eslint-disable require-jsdoc, valid-jsdoc */
  11276. function arc(x, y, w, h, options) {
  11277. var arc = [];
  11278. if (options) {
  11279. var start = options.start || 0,
  11280. rx = pick(options.r,
  11281. w),
  11282. ry = pick(options.r,
  11283. h || w),
  11284. proximity = 0.001,
  11285. fullCircle = (Math.abs((options.end || 0) - start - 2 * Math.PI) <
  11286. proximity),
  11287. // Substract a small number to prevent cos and sin of start
  11288. // and end from becoming equal on 360 arcs (related: #1561)
  11289. end = (options.end || 0) - proximity,
  11290. innerRadius = options.innerR,
  11291. open_1 = pick(options.open,
  11292. fullCircle),
  11293. cosStart = Math.cos(start),
  11294. sinStart = Math.sin(start),
  11295. cosEnd = Math.cos(end),
  11296. sinEnd = Math.sin(end),
  11297. // Proximity takes care of rounding errors around PI (#6971)
  11298. longArc = pick(options.longArc,
  11299. end - start - Math.PI < proximity ? 0 : 1);
  11300. arc.push([
  11301. 'M',
  11302. x + rx * cosStart,
  11303. y + ry * sinStart
  11304. ], [
  11305. 'A',
  11306. rx,
  11307. ry,
  11308. 0,
  11309. longArc,
  11310. pick(options.clockwise, 1),
  11311. x + rx * cosEnd,
  11312. y + ry * sinEnd
  11313. ]);
  11314. if (defined(innerRadius)) {
  11315. arc.push(open_1 ?
  11316. [
  11317. 'M',
  11318. x + innerRadius * cosEnd,
  11319. y + innerRadius * sinEnd
  11320. ] : [
  11321. 'L',
  11322. x + innerRadius * cosEnd,
  11323. y + innerRadius * sinEnd
  11324. ], [
  11325. 'A',
  11326. innerRadius,
  11327. innerRadius,
  11328. 0,
  11329. longArc,
  11330. // Clockwise - opposite to the outer arc clockwise
  11331. defined(options.clockwise) ? 1 - options.clockwise : 0,
  11332. x + innerRadius * cosStart,
  11333. y + innerRadius * sinStart
  11334. ]);
  11335. }
  11336. if (!open_1) {
  11337. arc.push(['Z']);
  11338. }
  11339. }
  11340. return arc;
  11341. }
  11342. /**
  11343. * Callout shape used for default tooltips, also used for rounded
  11344. * rectangles in VML
  11345. */
  11346. function callout(x, y, w, h, options) {
  11347. var arrowLength = 6,
  11348. halfDistance = 6,
  11349. r = Math.min((options && options.r) || 0,
  11350. w,
  11351. h),
  11352. safeDistance = r + halfDistance,
  11353. anchorX = options && options.anchorX,
  11354. anchorY = options && options.anchorY || 0;
  11355. var path = roundedRect(x,
  11356. y,
  11357. w,
  11358. h, { r: r });
  11359. if (!isNumber(anchorX)) {
  11360. return path;
  11361. }
  11362. // Anchor on right side
  11363. if (x + anchorX >= w) {
  11364. // Chevron
  11365. if (anchorY > y + safeDistance &&
  11366. anchorY < y + h - safeDistance) {
  11367. 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]);
  11368. // Simple connector
  11369. }
  11370. else {
  11371. path.splice(3, 1, ['L', x + w, h / 2], ['L', anchorX, anchorY], ['L', x + w, h / 2], ['L', x + w, y + h - r]);
  11372. }
  11373. // Anchor on left side
  11374. }
  11375. else if (x + anchorX <= 0) {
  11376. // Chevron
  11377. if (anchorY > y + safeDistance &&
  11378. anchorY < y + h - safeDistance) {
  11379. path.splice(7, 1, ['L', x, anchorY + halfDistance], ['L', x - arrowLength, anchorY], ['L', x, anchorY - halfDistance], ['L', x, y + r]);
  11380. // Simple connector
  11381. }
  11382. else {
  11383. path.splice(7, 1, ['L', x, h / 2], ['L', anchorX, anchorY], ['L', x, h / 2], ['L', x, y + r]);
  11384. }
  11385. }
  11386. else if ( // replace bottom
  11387. anchorY &&
  11388. anchorY > h &&
  11389. anchorX > x + safeDistance &&
  11390. anchorX < x + w - safeDistance) {
  11391. path.splice(5, 1, ['L', anchorX + halfDistance, y + h], ['L', anchorX, y + h + arrowLength], ['L', anchorX - halfDistance, y + h], ['L', x + r, y + h]);
  11392. }
  11393. else if ( // replace top
  11394. anchorY &&
  11395. anchorY < 0 &&
  11396. anchorX > x + safeDistance &&
  11397. anchorX < x + w - safeDistance) {
  11398. path.splice(1, 1, ['L', anchorX - halfDistance, y], ['L', anchorX, y - arrowLength], ['L', anchorX + halfDistance, y], ['L', w - r, y]);
  11399. }
  11400. return path;
  11401. }
  11402. function circle(x, y, w, h) {
  11403. // Return a full arc
  11404. return arc(x + w / 2, y + h / 2, w / 2, h / 2, {
  11405. start: Math.PI * 0.5,
  11406. end: Math.PI * 2.5,
  11407. open: false
  11408. });
  11409. }
  11410. function diamond(x, y, w, h) {
  11411. return [
  11412. ['M', x + w / 2, y],
  11413. ['L', x + w, y + h / 2],
  11414. ['L', x + w / 2, y + h],
  11415. ['L', x, y + h / 2],
  11416. ['Z']
  11417. ];
  11418. }
  11419. // #15291
  11420. function rect(x, y, w, h, options) {
  11421. if (options && options.r) {
  11422. return roundedRect(x, y, w, h, options);
  11423. }
  11424. return [
  11425. ['M', x, y],
  11426. ['L', x + w, y],
  11427. ['L', x + w, y + h],
  11428. ['L', x, y + h],
  11429. ['Z']
  11430. ];
  11431. }
  11432. function roundedRect(x, y, w, h, options) {
  11433. var r = (options && options.r) || 0;
  11434. return [
  11435. ['M', x + r, y],
  11436. ['L', x + w - r, y],
  11437. ['C', x + w, y, x + w, y, x + w, y + r],
  11438. ['L', x + w, y + h - r],
  11439. ['C', x + w, y + h, x + w, y + h, x + w - r, y + h],
  11440. ['L', x + r, y + h],
  11441. ['C', x, y + h, x, y + h, x, y + h - r],
  11442. ['L', x, y + r],
  11443. ['C', x, y, x, y, x + r, y] // top-left corner
  11444. ];
  11445. }
  11446. function triangle(x, y, w, h) {
  11447. return [
  11448. ['M', x + w / 2, y],
  11449. ['L', x + w, y + h],
  11450. ['L', x, y + h],
  11451. ['Z']
  11452. ];
  11453. }
  11454. function triangleDown(x, y, w, h) {
  11455. return [
  11456. ['M', x, y],
  11457. ['L', x + w, y],
  11458. ['L', x + w / 2, y + h],
  11459. ['Z']
  11460. ];
  11461. }
  11462. var Symbols = {
  11463. arc: arc,
  11464. callout: callout,
  11465. circle: circle,
  11466. diamond: diamond,
  11467. rect: rect,
  11468. roundedRect: roundedRect,
  11469. square: rect,
  11470. triangle: triangle,
  11471. 'triangle-down': triangleDown
  11472. };
  11473. /* *
  11474. *
  11475. * Default Export
  11476. *
  11477. * */
  11478. return Symbols;
  11479. });
  11480. _registerModule(_modules, 'Core/Renderer/SVG/TextBuilder.js', [_modules['Core/Renderer/HTML/AST.js'], _modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (AST, H, U) {
  11481. /* *
  11482. *
  11483. * (c) 2010-2020 Torstein Honsi
  11484. *
  11485. * License: www.highcharts.com/license
  11486. *
  11487. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  11488. *
  11489. * */
  11490. var doc = H.doc,
  11491. SVG_NS = H.SVG_NS;
  11492. var attr = U.attr,
  11493. isString = U.isString,
  11494. objectEach = U.objectEach,
  11495. pick = U.pick;
  11496. /* *
  11497. *
  11498. * Class
  11499. *
  11500. * */
  11501. /**
  11502. * SVG Text Builder
  11503. * @private
  11504. * @class
  11505. * @name Highcharts.TextBuilder
  11506. */
  11507. var TextBuilder = /** @class */ (function () {
  11508. function TextBuilder(svgElement) {
  11509. var textStyles = svgElement.styles;
  11510. this.renderer = svgElement.renderer;
  11511. this.svgElement = svgElement;
  11512. this.width = svgElement.textWidth;
  11513. this.textLineHeight = textStyles && textStyles.lineHeight;
  11514. this.textOutline = textStyles && textStyles.textOutline;
  11515. this.ellipsis = Boolean(textStyles && textStyles.textOverflow === 'ellipsis');
  11516. this.noWrap = Boolean(textStyles && textStyles.whiteSpace === 'nowrap');
  11517. this.fontSize = textStyles && textStyles.fontSize;
  11518. }
  11519. /**
  11520. * Build an SVG representation of the pseudo HTML given in the object's
  11521. * svgElement.
  11522. *
  11523. * @private
  11524. *
  11525. * @return {void}.
  11526. */
  11527. TextBuilder.prototype.buildSVG = function () {
  11528. var wrapper = this.svgElement;
  11529. 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;
  11530. var regexMatchBreaks = /<br.*?>/g;
  11531. // The buildText code is quite heavy, so if we're not changing something
  11532. // that affects the text, skip it (#6113).
  11533. textCache = [
  11534. textStr,
  11535. this.ellipsis,
  11536. this.noWrap,
  11537. this.textLineHeight,
  11538. this.textOutline,
  11539. this.fontSize,
  11540. this.width
  11541. ].join(',');
  11542. if (textCache === wrapper.textCache) {
  11543. return;
  11544. }
  11545. wrapper.textCache = textCache;
  11546. delete wrapper.actualWidth;
  11547. // Remove old text
  11548. while (i--) {
  11549. textNode.removeChild(childNodes[i]);
  11550. }
  11551. // Simple strings, add text directly and return
  11552. if (!hasMarkup &&
  11553. !this.ellipsis &&
  11554. !this.width &&
  11555. (textStr.indexOf(' ') === -1 ||
  11556. (this.noWrap && !regexMatchBreaks.test(textStr)))) {
  11557. textNode.appendChild(doc.createTextNode(this.unescapeEntities(textStr)));
  11558. // Complex strings, add more logic
  11559. }
  11560. else if (textStr !== '') {
  11561. if (tempParent) {
  11562. // attach it to the DOM to read offset width
  11563. tempParent.appendChild(textNode);
  11564. }
  11565. // Step 1. Parse the markup safely and directly into a tree
  11566. // structure.
  11567. var ast = new AST(textStr);
  11568. // Step 2. Do as many as we can of the modifications to the tree
  11569. // structure before it is added to the DOM
  11570. this.modifyTree(ast.nodes);
  11571. ast.addToDOM(wrapper.element);
  11572. // Step 3. Some modifications can't be done until the structure is
  11573. // in the DOM, because we need to read computed metrics.
  11574. this.modifyDOM();
  11575. // Add title if an ellipsis was added
  11576. if (this.ellipsis &&
  11577. (textNode.textContent || '').indexOf('\u2026') !== -1) {
  11578. wrapper.attr('title', this.unescapeEntities(wrapper.textStr || '', ['&lt;', '&gt;']) // #7179
  11579. );
  11580. }
  11581. if (tempParent) {
  11582. tempParent.removeChild(textNode);
  11583. }
  11584. }
  11585. // Apply the text outline
  11586. if (isString(this.textOutline) && wrapper.applyTextOutline) {
  11587. wrapper.applyTextOutline(this.textOutline);
  11588. }
  11589. };
  11590. /**
  11591. * Modify the DOM of the generated SVG structure. This function only does
  11592. * operations that cannot be done until the elements are attached to the
  11593. * DOM, like doing layout based on rendered metrics of the added elements.
  11594. *
  11595. * @private
  11596. *
  11597. * @return {void}
  11598. */
  11599. TextBuilder.prototype.modifyDOM = function () {
  11600. var _this = this;
  11601. var wrapper = this.svgElement;
  11602. var x = attr(wrapper.element, 'x');
  11603. wrapper.firstLineMetrics = void 0;
  11604. // Modify hard line breaks by applying the rendered line height
  11605. [].forEach.call(wrapper.element.querySelectorAll('tspan.highcharts-br'), function (br, i) {
  11606. if (br.nextSibling && br.previousSibling) { // #5261
  11607. if (i === 0 && br.previousSibling.nodeType === 1) {
  11608. wrapper.firstLineMetrics = wrapper.renderer
  11609. .fontMetrics(void 0, br.previousSibling);
  11610. }
  11611. attr(br, {
  11612. // Since the break is inserted in front of the next
  11613. // line, we need to use the next sibling for the line
  11614. // height
  11615. dy: _this.getLineHeight(br.nextSibling),
  11616. x: x
  11617. });
  11618. }
  11619. });
  11620. // Constrain the line width, either by ellipsis or wrapping
  11621. var width = this.width || 0;
  11622. if (!width) {
  11623. return;
  11624. }
  11625. // Insert soft line breaks into each text node
  11626. var modifyTextNode = function (textNode,
  11627. parentElement) {
  11628. var text = textNode.textContent || '';
  11629. var words = text
  11630. .replace(/([^\^])-/g, '$1- ') // Split on hyphens
  11631. // .trim()
  11632. .split(' '); // #1273
  11633. var hasWhiteSpace = !_this.noWrap && (words.length > 1 || wrapper.element.childNodes.length > 1);
  11634. var dy = _this.getLineHeight(parentElement);
  11635. var lineNo = 0;
  11636. var startAt = wrapper.actualWidth;
  11637. if (_this.ellipsis) {
  11638. if (text) {
  11639. _this.truncate(textNode, text, void 0, 0,
  11640. // Target width
  11641. Math.max(0,
  11642. // Substract the font face to make room for the
  11643. // ellipsis itself
  11644. width - parseInt(_this.fontSize || 12, 10)),
  11645. // Build the text to test for
  11646. function (text, currentIndex) {
  11647. return text.substring(0, currentIndex) + '\u2026';
  11648. });
  11649. }
  11650. }
  11651. else if (hasWhiteSpace) {
  11652. var lines = [];
  11653. // Remove preceding siblings in order to make the text length
  11654. // calculation correct in the truncate function
  11655. var precedingSiblings = [];
  11656. while (parentElement.firstChild &&
  11657. parentElement.firstChild !== textNode) {
  11658. precedingSiblings.push(parentElement.firstChild);
  11659. parentElement.removeChild(parentElement.firstChild);
  11660. }
  11661. while (words.length) {
  11662. // Apply the previous line
  11663. if (words.length && !_this.noWrap && lineNo > 0) {
  11664. lines.push(textNode.textContent || '');
  11665. textNode.textContent = words.join(' ')
  11666. .replace(/- /g, '-');
  11667. }
  11668. // For each line, truncate the remaining
  11669. // words into the line length.
  11670. _this.truncate(textNode, void 0, words, lineNo === 0 ? (startAt || 0) : 0, width,
  11671. // Build the text to test for
  11672. function (t, currentIndex) {
  11673. return words
  11674. .slice(0, currentIndex)
  11675. .join(' ')
  11676. .replace(/- /g, '-');
  11677. });
  11678. startAt = wrapper.actualWidth;
  11679. lineNo++;
  11680. }
  11681. // Reinsert the preceding child nodes
  11682. precedingSiblings.forEach(function (childNode) {
  11683. parentElement.insertBefore(childNode, textNode);
  11684. });
  11685. // Insert the previous lines before the original text node
  11686. lines.forEach(function (line) {
  11687. // Insert the line
  11688. parentElement.insertBefore(doc.createTextNode(line), textNode);
  11689. // Insert a break
  11690. var br = doc.createElementNS(SVG_NS, 'tspan');
  11691. br.textContent = '\u200B'; // zero-width space
  11692. attr(br, { dy: dy, x: x });
  11693. parentElement.insertBefore(br, textNode);
  11694. });
  11695. }
  11696. };
  11697. // Recurse down the DOM tree and handle line breaks for each text node
  11698. var modifyChildren = (function (node) {
  11699. var childNodes = [].slice.call(node.childNodes);
  11700. childNodes.forEach(function (childNode) {
  11701. if (childNode.nodeType === Node.TEXT_NODE) {
  11702. modifyTextNode(childNode, node);
  11703. }
  11704. else {
  11705. // Reset word-wrap width readings after hard breaks
  11706. if (childNode.className.baseVal
  11707. .indexOf('highcharts-br') !== -1) {
  11708. wrapper.actualWidth = 0;
  11709. }
  11710. // Recurse down to child node
  11711. modifyChildren(childNode);
  11712. }
  11713. });
  11714. });
  11715. modifyChildren(wrapper.element);
  11716. };
  11717. /**
  11718. * Get the rendered line height of a <text>, <tspan> or pure text node.
  11719. *
  11720. * @param {DOMElementType|Text} node The node to check for
  11721. *
  11722. * @return {number} The rendered line height
  11723. */
  11724. TextBuilder.prototype.getLineHeight = function (node) {
  11725. var fontSizeStyle;
  11726. // If the node is a text node, use its parent
  11727. var element = node.nodeType === Node.TEXT_NODE ?
  11728. node.parentElement :
  11729. node;
  11730. if (!this.renderer.styledMode) {
  11731. fontSizeStyle =
  11732. element && /(px|em)$/.test(element.style.fontSize) ?
  11733. element.style.fontSize :
  11734. (this.fontSize || this.renderer.style.fontSize || 12);
  11735. }
  11736. return this.textLineHeight ?
  11737. parseInt(this.textLineHeight.toString(), 10) :
  11738. this.renderer.fontMetrics(fontSizeStyle, element || this.svgElement.element).h;
  11739. };
  11740. /**
  11741. * Transform a pseudo HTML AST node tree into an SVG structure. We do as
  11742. * much heavy lifting as we can here, before doing the final processing in
  11743. * the modifyDOM function. The original data is mutated.
  11744. *
  11745. * @private
  11746. *
  11747. * @param {ASTNode[]} nodes The AST nodes
  11748. *
  11749. * @return {void}
  11750. */
  11751. TextBuilder.prototype.modifyTree = function (nodes) {
  11752. var _this = this;
  11753. var modifyChild = function (node,
  11754. i) {
  11755. var tagName = node.tagName;
  11756. var styledMode = _this.renderer.styledMode;
  11757. var attributes = node.attributes || {};
  11758. // Apply styling to text tags
  11759. if (tagName === 'b' || tagName === 'strong') {
  11760. if (styledMode) {
  11761. attributes['class'] = 'highcharts-strong'; // eslint-disable-line dot-notation
  11762. }
  11763. else {
  11764. attributes.style = 'font-weight:bold;' + (attributes.style || '');
  11765. }
  11766. }
  11767. else if (tagName === 'i' || tagName === 'em') {
  11768. if (styledMode) {
  11769. attributes['class'] = 'highcharts-emphasized'; // eslint-disable-line dot-notation
  11770. }
  11771. else {
  11772. attributes.style = 'font-style:italic;' + (attributes.style || '');
  11773. }
  11774. }
  11775. // Modify attributes
  11776. if (isString(attributes.style)) {
  11777. attributes.style = attributes.style.replace(/(;| |^)color([ :])/, '$1fill$2');
  11778. }
  11779. if (tagName === 'br') {
  11780. attributes['class'] = 'highcharts-br'; // eslint-disable-line dot-notation
  11781. node.textContent = '\u200B'; // zero-width space
  11782. // Trim whitespace off the beginning of new lines
  11783. var nextNode = nodes[i + 1];
  11784. if (nextNode && nextNode.textContent) {
  11785. nextNode.textContent =
  11786. nextNode.textContent.replace(/^ +/gm, '');
  11787. }
  11788. }
  11789. if (tagName !== '#text' && tagName !== 'a') {
  11790. node.tagName = 'tspan';
  11791. }
  11792. node.attributes = attributes;
  11793. // Recurse
  11794. if (node.children) {
  11795. node.children
  11796. .filter(function (c) { return c.tagName !== '#text'; })
  11797. .forEach(modifyChild);
  11798. }
  11799. };
  11800. nodes.forEach(modifyChild);
  11801. // Remove empty spans from the beginning because SVG's getBBox doesn't
  11802. // count empty lines. The use case is tooltip where the header is empty.
  11803. while (nodes[0]) {
  11804. if (nodes[0].tagName === 'tspan' && !nodes[0].children) {
  11805. nodes.splice(0, 1);
  11806. }
  11807. else {
  11808. break;
  11809. }
  11810. }
  11811. };
  11812. /*
  11813. * Truncate the text node contents to a given length. Used when the css
  11814. * width is set. If the `textOverflow` is `ellipsis`, the text is truncated
  11815. * character by character to the given length. If not, the text is
  11816. * word-wrapped line by line.
  11817. */
  11818. TextBuilder.prototype.truncate = function (textNode, text, words, startAt, width, getString) {
  11819. var svgElement = this.svgElement;
  11820. var renderer = svgElement.renderer,
  11821. rotation = svgElement.rotation;
  11822. // Cache the lengths to avoid checking the same twice
  11823. var lengths = [];
  11824. // Word wrap can not be truncated to shorter than one word, ellipsis
  11825. // text can be completely blank.
  11826. var minIndex = words ? 1 : 0;
  11827. var maxIndex = (text || words || '').length;
  11828. var currentIndex = maxIndex;
  11829. var str;
  11830. var actualWidth;
  11831. var getSubStringLength = function (charEnd,
  11832. concatenatedEnd) {
  11833. // charEnd is used when finding the character-by-character
  11834. // break for ellipsis, concatenatedEnd is used for word-by-word
  11835. // break for word wrapping.
  11836. var end = concatenatedEnd || charEnd;
  11837. var parentNode = textNode.parentNode;
  11838. if (parentNode && typeof lengths[end] === 'undefined') {
  11839. // Modern browsers
  11840. if (parentNode.getSubStringLength) {
  11841. // Fails with DOM exception on unit-tests/legend/members
  11842. // of unknown reason. Desired width is 0, text content
  11843. // is "5" and end is 1.
  11844. try {
  11845. lengths[end] = startAt +
  11846. parentNode.getSubStringLength(0, words ? end + 1 : end);
  11847. }
  11848. catch (e) {
  11849. '';
  11850. }
  11851. // Legacy
  11852. }
  11853. else if (renderer.getSpanWidth) { // #9058 jsdom
  11854. textNode.textContent = getString(text || words, charEnd);
  11855. lengths[end] = startAt +
  11856. renderer.getSpanWidth(svgElement, textNode);
  11857. }
  11858. }
  11859. return lengths[end];
  11860. };
  11861. svgElement.rotation = 0; // discard rotation when computing box
  11862. actualWidth = getSubStringLength(textNode.textContent.length);
  11863. if (startAt + actualWidth > width) {
  11864. // Do a binary search for the index where to truncate the text
  11865. while (minIndex <= maxIndex) {
  11866. currentIndex = Math.ceil((minIndex + maxIndex) / 2);
  11867. // When checking words for word-wrap, we need to build the
  11868. // string and measure the subStringLength at the concatenated
  11869. // word length.
  11870. if (words) {
  11871. str = getString(words, currentIndex);
  11872. }
  11873. actualWidth = getSubStringLength(currentIndex, str && str.length - 1);
  11874. if (minIndex === maxIndex) {
  11875. // Complete
  11876. minIndex = maxIndex + 1;
  11877. }
  11878. else if (actualWidth > width) {
  11879. // Too large. Set max index to current.
  11880. maxIndex = currentIndex - 1;
  11881. }
  11882. else {
  11883. // Within width. Set min index to current.
  11884. minIndex = currentIndex;
  11885. }
  11886. }
  11887. // If max index was 0 it means the shortest possible text was also
  11888. // too large. For ellipsis that means only the ellipsis, while for
  11889. // word wrap it means the whole first word.
  11890. if (maxIndex === 0) {
  11891. // Remove ellipsis
  11892. textNode.textContent = '';
  11893. // If the new text length is one less than the original, we don't
  11894. // need the ellipsis
  11895. }
  11896. else if (!(text && maxIndex === text.length - 1)) {
  11897. textNode.textContent = str || getString(text || words, currentIndex);
  11898. }
  11899. }
  11900. // When doing line wrapping, prepare for the next line by removing the
  11901. // items from this line.
  11902. if (words) {
  11903. words.splice(0, currentIndex);
  11904. }
  11905. svgElement.actualWidth = actualWidth;
  11906. svgElement.rotation = rotation; // Apply rotation again.
  11907. };
  11908. /*
  11909. * Un-escape HTML entities based on the public `renderer.escapes` list
  11910. *
  11911. * @private
  11912. *
  11913. * @param {string} inputStr The string to unescape
  11914. * @param {Array<string>} [except] Exceptions
  11915. *
  11916. * @return {string} The processed string
  11917. */
  11918. TextBuilder.prototype.unescapeEntities = function (inputStr, except) {
  11919. objectEach(this.renderer.escapes, function (value, key) {
  11920. if (!except || except.indexOf(value) === -1) {
  11921. inputStr = inputStr.toString().replace(new RegExp(value, 'g'), key);
  11922. }
  11923. });
  11924. return inputStr;
  11925. };
  11926. return TextBuilder;
  11927. }());
  11928. return TextBuilder;
  11929. });
  11930. _registerModule(_modules, 'Core/Renderer/SVG/SVGRenderer.js', [_modules['Core/Renderer/HTML/AST.js'], _modules['Core/Color/Color.js'], _modules['Core/Globals.js'], _modules['Core/Color/Palette.js'], _modules['Core/Renderer/RendererRegistry.js'], _modules['Core/Renderer/SVG/SVGElement.js'], _modules['Core/Renderer/SVG/SVGLabel.js'], _modules['Core/Renderer/SVG/Symbols.js'], _modules['Core/Renderer/SVG/TextBuilder.js'], _modules['Core/Utilities.js']], function (AST, Color, H, Palette, RendererRegistry, SVGElement, SVGLabel, Symbols, TextBuilder, U) {
  11931. /* *
  11932. *
  11933. * (c) 2010-2021 Torstein Honsi
  11934. *
  11935. * License: www.highcharts.com/license
  11936. *
  11937. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  11938. *
  11939. * */
  11940. var charts = H.charts,
  11941. deg2rad = H.deg2rad,
  11942. doc = H.doc,
  11943. isFirefox = H.isFirefox,
  11944. isMS = H.isMS,
  11945. isWebKit = H.isWebKit,
  11946. noop = H.noop,
  11947. SVG_NS = H.SVG_NS,
  11948. symbolSizes = H.symbolSizes,
  11949. win = H.win;
  11950. var addEvent = U.addEvent,
  11951. attr = U.attr,
  11952. createElement = U.createElement,
  11953. css = U.css,
  11954. defined = U.defined,
  11955. destroyObjectProperties = U.destroyObjectProperties,
  11956. extend = U.extend,
  11957. isArray = U.isArray,
  11958. isNumber = U.isNumber,
  11959. isObject = U.isObject,
  11960. isString = U.isString,
  11961. merge = U.merge,
  11962. pick = U.pick,
  11963. pInt = U.pInt,
  11964. uniqueKey = U.uniqueKey;
  11965. /* *
  11966. *
  11967. * Variables
  11968. *
  11969. * */
  11970. var hasInternalReferenceBug;
  11971. /* *
  11972. *
  11973. * Class
  11974. *
  11975. * */
  11976. /* eslint-disable no-invalid-this, valid-jsdoc */
  11977. /**
  11978. * Allows direct access to the Highcharts rendering layer in order to draw
  11979. * primitive shapes like circles, rectangles, paths or text directly on a chart,
  11980. * or independent from any chart. The SVGRenderer represents a wrapper object
  11981. * for SVG in modern browsers. Through the VMLRenderer, part of the `oldie.js`
  11982. * module, it also brings vector graphics to IE <= 8.
  11983. *
  11984. * An existing chart's renderer can be accessed through {@link Chart.renderer}.
  11985. * The renderer can also be used completely decoupled from a chart.
  11986. *
  11987. * @sample highcharts/members/renderer-on-chart
  11988. * Annotating a chart programmatically.
  11989. * @sample highcharts/members/renderer-basic
  11990. * Independent SVG drawing.
  11991. *
  11992. * @example
  11993. * // Use directly without a chart object.
  11994. * let renderer = new Highcharts.Renderer(parentNode, 600, 400);
  11995. *
  11996. * @class
  11997. * @name Highcharts.SVGRenderer
  11998. *
  11999. * @param {Highcharts.HTMLDOMElement} container
  12000. * Where to put the SVG in the web page.
  12001. *
  12002. * @param {number} width
  12003. * The width of the SVG.
  12004. *
  12005. * @param {number} height
  12006. * The height of the SVG.
  12007. *
  12008. * @param {Highcharts.CSSObject} [style]
  12009. * The box style, if not in styleMode
  12010. *
  12011. * @param {boolean} [forExport=false]
  12012. * Whether the rendered content is intended for export.
  12013. *
  12014. * @param {boolean} [allowHTML=true]
  12015. * Whether the renderer is allowed to include HTML text, which will be
  12016. * projected on top of the SVG.
  12017. *
  12018. * @param {boolean} [styledMode=false]
  12019. * Whether the renderer belongs to a chart that is in styled mode.
  12020. * If it does, it will avoid setting presentational attributes in
  12021. * some cases, but not when set explicitly through `.attr` and `.css`
  12022. * etc.
  12023. */
  12024. var SVGRenderer = /** @class */ (function () {
  12025. /* *
  12026. *
  12027. * Constructors
  12028. *
  12029. * */
  12030. function SVGRenderer(container, width, height, style, forExport, allowHTML, styledMode) {
  12031. /* *
  12032. *
  12033. * Properties
  12034. *
  12035. * */
  12036. this.alignedObjects = void 0;
  12037. /**
  12038. * The root `svg` node of the renderer.
  12039. *
  12040. * @name Highcharts.SVGRenderer#box
  12041. * @type {Highcharts.SVGDOMElement}
  12042. */
  12043. this.box = void 0;
  12044. /**
  12045. * The wrapper for the root `svg` node of the renderer.
  12046. *
  12047. * @name Highcharts.SVGRenderer#boxWrapper
  12048. * @type {Highcharts.SVGElement}
  12049. */
  12050. this.boxWrapper = void 0;
  12051. this.cache = void 0;
  12052. this.cacheKeys = void 0;
  12053. this.chartIndex = void 0;
  12054. /**
  12055. * A pointer to the `defs` node of the root SVG.
  12056. *
  12057. * @name Highcharts.SVGRenderer#defs
  12058. * @type {Highcharts.SVGElement}
  12059. */
  12060. this.defs = void 0;
  12061. this.globalAnimation = void 0;
  12062. this.gradients = void 0;
  12063. this.height = void 0;
  12064. this.imgCount = void 0;
  12065. this.isSVG = void 0;
  12066. this.style = void 0;
  12067. /**
  12068. * Page url used for internal references.
  12069. *
  12070. * @private
  12071. * @name Highcharts.SVGRenderer#url
  12072. * @type {string}
  12073. */
  12074. this.url = void 0;
  12075. this.width = void 0;
  12076. this.init(container, width, height, style, forExport, allowHTML, styledMode);
  12077. }
  12078. /* *
  12079. *
  12080. * Functions
  12081. *
  12082. * */
  12083. /**
  12084. * Initialize the SVGRenderer. Overridable initializer function that takes
  12085. * the same parameters as the constructor.
  12086. *
  12087. * @function Highcharts.SVGRenderer#init
  12088. *
  12089. * @param {Highcharts.HTMLDOMElement} container
  12090. * Where to put the SVG in the web page.
  12091. *
  12092. * @param {number} width
  12093. * The width of the SVG.
  12094. *
  12095. * @param {number} height
  12096. * The height of the SVG.
  12097. *
  12098. * @param {Highcharts.CSSObject} [style]
  12099. * The box style, if not in styleMode
  12100. *
  12101. * @param {boolean} [forExport=false]
  12102. * Whether the rendered content is intended for export.
  12103. *
  12104. * @param {boolean} [allowHTML=true]
  12105. * Whether the renderer is allowed to include HTML text, which will be
  12106. * projected on top of the SVG.
  12107. *
  12108. * @param {boolean} [styledMode=false]
  12109. * Whether the renderer belongs to a chart that is in styled mode. If it
  12110. * does, it will avoid setting presentational attributes in some cases, but
  12111. * not when set explicitly through `.attr` and `.css` etc.
  12112. */
  12113. SVGRenderer.prototype.init = function (container, width, height, style, forExport, allowHTML, styledMode) {
  12114. var renderer = this,
  12115. boxWrapper = renderer
  12116. .createElement('svg')
  12117. .attr({
  12118. version: '1.1',
  12119. 'class': 'highcharts-root'
  12120. }),
  12121. element = boxWrapper.element;
  12122. if (!styledMode) {
  12123. boxWrapper.css(this.getStyle(style));
  12124. }
  12125. container.appendChild(element);
  12126. // Always use ltr on the container, otherwise text-anchor will be
  12127. // flipped and text appear outside labels, buttons, tooltip etc (#3482)
  12128. attr(container, 'dir', 'ltr');
  12129. // For browsers other than IE, add the namespace attribute (#1978)
  12130. if (container.innerHTML.indexOf('xmlns') === -1) {
  12131. attr(element, 'xmlns', this.SVG_NS);
  12132. }
  12133. // object properties
  12134. renderer.isSVG = true;
  12135. this.box = element;
  12136. this.boxWrapper = boxWrapper;
  12137. renderer.alignedObjects = [];
  12138. this.url = this.getReferenceURL();
  12139. // Add description
  12140. var desc = this.createElement('desc').add();
  12141. desc.element.appendChild(doc.createTextNode('Created with Highcharts 9.1.1'));
  12142. renderer.defs = this.createElement('defs').add();
  12143. renderer.allowHTML = allowHTML;
  12144. renderer.forExport = forExport;
  12145. renderer.styledMode = styledMode;
  12146. renderer.gradients = {}; // Object where gradient SvgElements are stored
  12147. renderer.cache = {}; // Cache for numerical bounding boxes
  12148. renderer.cacheKeys = [];
  12149. renderer.imgCount = 0;
  12150. renderer.setSize(width, height, false);
  12151. // Issue 110 workaround:
  12152. // In Firefox, if a div is positioned by percentage, its pixel position
  12153. // may land between pixels. The container itself doesn't display this,
  12154. // but an SVG element inside this container will be drawn at subpixel
  12155. // precision. In order to draw sharp lines, this must be compensated
  12156. // for. This doesn't seem to work inside iframes though (like in
  12157. // jsFiddle).
  12158. var subPixelFix,
  12159. rect;
  12160. if (isFirefox && container.getBoundingClientRect) {
  12161. subPixelFix = function () {
  12162. css(container, { left: 0, top: 0 });
  12163. rect = container.getBoundingClientRect();
  12164. css(container, {
  12165. left: (Math.ceil(rect.left) - rect.left) + 'px',
  12166. top: (Math.ceil(rect.top) - rect.top) + 'px'
  12167. });
  12168. };
  12169. // run the fix now
  12170. subPixelFix();
  12171. // run it on resize
  12172. renderer.unSubPixelFix = addEvent(win, 'resize', subPixelFix);
  12173. }
  12174. };
  12175. /**
  12176. * General method for adding a definition to the SVG `defs` tag. Can be used
  12177. * for gradients, fills, filters etc. Styled mode only. A hook for adding
  12178. * general definitions to the SVG's defs tag. Definitions can be referenced
  12179. * from the CSS by its `id`. Read more in
  12180. * [gradients, shadows and patterns](https://www.highcharts.com/docs/chart-design-and-style/gradients-shadows-and-patterns).
  12181. * Styled mode only.
  12182. *
  12183. * @function Highcharts.SVGRenderer#definition
  12184. *
  12185. * @param {Highcharts.ASTNode} def
  12186. * A serialized form of an SVG definition, including children.
  12187. *
  12188. * @return {Highcharts.SVGElement}
  12189. * The inserted node.
  12190. */
  12191. SVGRenderer.prototype.definition = function (def) {
  12192. var ast = new AST([def]);
  12193. return ast.addToDOM(this.defs.element);
  12194. };
  12195. /**
  12196. * Get the prefix needed for internal URL references to work in certain
  12197. * cases. Some older browser versions had a bug where internal url
  12198. * references in SVG attributes, on the form `url(#some-id)`, would fail if
  12199. * a base tag was present in the page. There were also issues with
  12200. * `history.pushState` related to this prefix.
  12201. *
  12202. * Related issues: #24, #672, #1070, #5244.
  12203. *
  12204. * The affected browsers are:
  12205. * - Chrome <= 53 (May 2018)
  12206. * - Firefox <= 51 (January 2017)
  12207. * - Safari/Mac <= 12.1 (2018 or 2019)
  12208. * - Safari/iOS <= 13
  12209. *
  12210. * @todo Remove this hack when time has passed. All the affected browsers
  12211. * are evergreens, so it is increasingly unlikely that users are affected by
  12212. * the bug.
  12213. *
  12214. * @return {string}
  12215. * The prefix to use. An empty string for modern browsers.
  12216. */
  12217. SVGRenderer.prototype.getReferenceURL = function () {
  12218. if ((isFirefox || isWebKit) &&
  12219. doc.getElementsByTagName('base').length) {
  12220. // Detect if a clip path is taking effect by performing a hit test
  12221. // outside the clipped area. If the hit element is the rectangle
  12222. // that was supposed to be clipped, the bug is present. This only
  12223. // has to be performed once per page load, so we store the result
  12224. // locally in the module.
  12225. if (!defined(hasInternalReferenceBug)) {
  12226. var id = uniqueKey();
  12227. var ast = new AST([{
  12228. tagName: 'svg',
  12229. attributes: {
  12230. width: 8,
  12231. height: 8
  12232. },
  12233. children: [{
  12234. tagName: 'defs',
  12235. children: [{
  12236. tagName: 'clipPath',
  12237. attributes: {
  12238. id: id
  12239. },
  12240. children: [{
  12241. tagName: 'rect',
  12242. attributes: {
  12243. width: 4,
  12244. height: 4
  12245. }
  12246. }]
  12247. }]
  12248. }, {
  12249. tagName: 'rect',
  12250. attributes: {
  12251. id: 'hitme',
  12252. width: 8,
  12253. height: 8,
  12254. 'clip-path': "url(#" + id + ")",
  12255. fill: 'rgba(0,0,0,0.001)'
  12256. }
  12257. }]
  12258. }]);
  12259. var svg = ast.addToDOM(doc.body);
  12260. css(svg, {
  12261. position: 'fixed',
  12262. top: 0,
  12263. left: 0,
  12264. zIndex: 9e5
  12265. });
  12266. var hitElement = doc.elementFromPoint(6, 6);
  12267. hasInternalReferenceBug = (hitElement && hitElement.id) === 'hitme';
  12268. doc.body.removeChild(svg);
  12269. }
  12270. if (hasInternalReferenceBug) {
  12271. return win.location.href
  12272. .split('#')[0] // remove the hash
  12273. .replace(/<[^>]*>/g, '') // wing cut HTML
  12274. // escape parantheses and quotes
  12275. .replace(/([\('\)])/g, '\\$1')
  12276. // replace spaces (needed for Safari only)
  12277. .replace(/ /g, '%20');
  12278. }
  12279. }
  12280. return '';
  12281. };
  12282. /**
  12283. * Get the global style setting for the renderer.
  12284. *
  12285. * @private
  12286. * @function Highcharts.SVGRenderer#getStyle
  12287. *
  12288. * @param {Highcharts.CSSObject} style
  12289. * Style settings.
  12290. *
  12291. * @return {Highcharts.CSSObject}
  12292. * The style settings mixed with defaults.
  12293. */
  12294. SVGRenderer.prototype.getStyle = function (style) {
  12295. this.style = extend({
  12296. fontFamily: '"Lucida Grande", "Lucida Sans Unicode", ' +
  12297. 'Arial, Helvetica, sans-serif',
  12298. fontSize: '12px'
  12299. }, style);
  12300. return this.style;
  12301. };
  12302. /**
  12303. * Apply the global style on the renderer, mixed with the default styles.
  12304. *
  12305. * @function Highcharts.SVGRenderer#setStyle
  12306. *
  12307. * @param {Highcharts.CSSObject} style
  12308. * CSS to apply.
  12309. */
  12310. SVGRenderer.prototype.setStyle = function (style) {
  12311. this.boxWrapper.css(this.getStyle(style));
  12312. };
  12313. /**
  12314. * Detect whether the renderer is hidden. This happens when one of the
  12315. * parent elements has `display: none`. Used internally to detect when we
  12316. * needto render preliminarily in another div to get the text bounding boxes
  12317. * right.
  12318. *
  12319. * @function Highcharts.SVGRenderer#isHidden
  12320. *
  12321. * @return {boolean}
  12322. * True if it is hidden.
  12323. */
  12324. SVGRenderer.prototype.isHidden = function () {
  12325. return !this.boxWrapper.getBBox().width;
  12326. };
  12327. /**
  12328. * Destroys the renderer and its allocated members.
  12329. *
  12330. * @function Highcharts.SVGRenderer#destroy
  12331. *
  12332. * @return {null}
  12333. */
  12334. SVGRenderer.prototype.destroy = function () {
  12335. var renderer = this,
  12336. rendererDefs = renderer.defs;
  12337. renderer.box = null;
  12338. renderer.boxWrapper = renderer.boxWrapper.destroy();
  12339. // Call destroy on all gradient elements
  12340. destroyObjectProperties(renderer.gradients || {});
  12341. renderer.gradients = null;
  12342. // Defs are null in VMLRenderer
  12343. // Otherwise, destroy them here.
  12344. if (rendererDefs) {
  12345. renderer.defs = rendererDefs.destroy();
  12346. }
  12347. // Remove sub pixel fix handler (#982)
  12348. if (renderer.unSubPixelFix) {
  12349. renderer.unSubPixelFix();
  12350. }
  12351. renderer.alignedObjects = null;
  12352. return null;
  12353. };
  12354. /**
  12355. * Create a wrapper for an SVG element. Serves as a factory for
  12356. * {@link SVGElement}, but this function is itself mostly called from
  12357. * primitive factories like {@link SVGRenderer#path}, {@link
  12358. * SVGRenderer#rect} or {@link SVGRenderer#text}.
  12359. *
  12360. * @function Highcharts.SVGRenderer#createElement
  12361. *
  12362. * @param {string} nodeName
  12363. * The node name, for example `rect`, `g` etc.
  12364. *
  12365. * @return {Highcharts.SVGElement}
  12366. * The generated SVGElement.
  12367. */
  12368. SVGRenderer.prototype.createElement = function (nodeName) {
  12369. var wrapper = new this.Element();
  12370. wrapper.init(this, nodeName);
  12371. return wrapper;
  12372. };
  12373. /**
  12374. * Get converted radial gradient attributes according to the radial
  12375. * reference. Used internally from the {@link SVGElement#colorGradient}
  12376. * function.
  12377. *
  12378. * @private
  12379. * @function Highcharts.SVGRenderer#getRadialAttr
  12380. */
  12381. SVGRenderer.prototype.getRadialAttr = function (radialReference, gradAttr) {
  12382. return {
  12383. cx: (radialReference[0] - radialReference[2] / 2) +
  12384. (gradAttr.cx || 0) * radialReference[2],
  12385. cy: (radialReference[1] - radialReference[2] / 2) +
  12386. (gradAttr.cy || 0) * radialReference[2],
  12387. r: (gradAttr.r || 0) * radialReference[2]
  12388. };
  12389. };
  12390. /**
  12391. * Parse a simple HTML string into SVG tspans. Called internally when text
  12392. * is set on an SVGElement. The function supports a subset of HTML tags, CSS
  12393. * text features like `width`, `text-overflow`, `white-space`, and also
  12394. * attributes like `href` and `style`.
  12395. *
  12396. * @private
  12397. * @function Highcharts.SVGRenderer#buildText
  12398. *
  12399. * @param {Highcharts.SVGElement} wrapper
  12400. * The parent SVGElement.
  12401. */
  12402. SVGRenderer.prototype.buildText = function (wrapper) {
  12403. new TextBuilder(wrapper).buildSVG();
  12404. };
  12405. /**
  12406. * Returns white for dark colors and black for bright colors.
  12407. *
  12408. * @function Highcharts.SVGRenderer#getContrast
  12409. *
  12410. * @param {Highcharts.ColorString} rgba
  12411. * The color to get the contrast for.
  12412. *
  12413. * @return {Highcharts.ColorString}
  12414. * The contrast color, either `#000000` or `#FFFFFF`.
  12415. */
  12416. SVGRenderer.prototype.getContrast = function (rgba) {
  12417. rgba = Color.parse(rgba).rgba;
  12418. // The threshold may be discussed. Here's a proposal for adding
  12419. // different weight to the color channels (#6216)
  12420. rgba[0] *= 1; // red
  12421. rgba[1] *= 1.2; // green
  12422. rgba[2] *= 0.5; // blue
  12423. return rgba[0] + rgba[1] + rgba[2] >
  12424. 1.8 * 255 ?
  12425. '#000000' :
  12426. '#FFFFFF';
  12427. };
  12428. /**
  12429. * Create a button with preset states.
  12430. *
  12431. * @function Highcharts.SVGRenderer#button
  12432. *
  12433. * @param {string} text
  12434. * The text or HTML to draw.
  12435. *
  12436. * @param {number} x
  12437. * The x position of the button's left side.
  12438. *
  12439. * @param {number} y
  12440. * The y position of the button's top side.
  12441. *
  12442. * @param {Highcharts.EventCallbackFunction<Highcharts.SVGElement>} callback
  12443. * The function to execute on button click or touch.
  12444. *
  12445. * @param {Highcharts.SVGAttributes} [theme]
  12446. * SVG attributes for the normal state.
  12447. *
  12448. * @param {Highcharts.SVGAttributes} [hoverState]
  12449. * SVG attributes for the hover state.
  12450. *
  12451. * @param {Highcharts.SVGAttributes} [pressedState]
  12452. * SVG attributes for the pressed state.
  12453. *
  12454. * @param {Highcharts.SVGAttributes} [disabledState]
  12455. * SVG attributes for the disabled state.
  12456. *
  12457. * @param {Highcharts.SymbolKeyValue} [shape=rect]
  12458. * The shape type.
  12459. *
  12460. * @param {boolean} [useHTML=false]
  12461. * Wether to use HTML to render the label.
  12462. *
  12463. * @return {Highcharts.SVGElement}
  12464. * The button element.
  12465. */
  12466. SVGRenderer.prototype.button = function (text, x, y, callback, theme, hoverState, pressedState, disabledState, shape, useHTML) {
  12467. var label = this.label(text,
  12468. x,
  12469. y,
  12470. shape,
  12471. void 0,
  12472. void 0,
  12473. useHTML,
  12474. void 0, 'button'),
  12475. styledMode = this.styledMode;
  12476. var curState = 0,
  12477. // Make a copy of normalState (#13798)
  12478. // (reference to options.rangeSelector.buttonTheme)
  12479. normalState = theme ? merge(theme) : {};
  12480. var userNormalStyle = normalState && normalState.style || {};
  12481. // Remove stylable attributes
  12482. normalState = AST.filterUserAttributes(normalState);
  12483. // Default, non-stylable attributes
  12484. label.attr(merge({ padding: 8, r: 2 }, normalState));
  12485. // Presentational
  12486. var normalStyle,
  12487. hoverStyle,
  12488. pressedStyle,
  12489. disabledStyle;
  12490. if (!styledMode) {
  12491. // Normal state - prepare the attributes
  12492. normalState = merge({
  12493. fill: Palette.neutralColor3,
  12494. stroke: Palette.neutralColor20,
  12495. 'stroke-width': 1,
  12496. style: {
  12497. color: Palette.neutralColor80,
  12498. cursor: 'pointer',
  12499. fontWeight: 'normal'
  12500. }
  12501. }, {
  12502. style: userNormalStyle
  12503. }, normalState);
  12504. normalStyle = normalState.style;
  12505. delete normalState.style;
  12506. // Hover state
  12507. hoverState = merge(normalState, {
  12508. fill: Palette.neutralColor10
  12509. }, AST.filterUserAttributes(hoverState || {}));
  12510. hoverStyle = hoverState.style;
  12511. delete hoverState.style;
  12512. // Pressed state
  12513. pressedState = merge(normalState, {
  12514. fill: Palette.highlightColor10,
  12515. style: {
  12516. color: Palette.neutralColor100,
  12517. fontWeight: 'bold'
  12518. }
  12519. }, AST.filterUserAttributes(pressedState || {}));
  12520. pressedStyle = pressedState.style;
  12521. delete pressedState.style;
  12522. // Disabled state
  12523. disabledState = merge(normalState, {
  12524. style: {
  12525. color: Palette.neutralColor20
  12526. }
  12527. }, AST.filterUserAttributes(disabledState || {}));
  12528. disabledStyle = disabledState.style;
  12529. delete disabledState.style;
  12530. }
  12531. // Add the events. IE9 and IE10 need mouseover and mouseout to funciton
  12532. // (#667).
  12533. addEvent(label.element, isMS ? 'mouseover' : 'mouseenter', function () {
  12534. if (curState !== 3) {
  12535. label.setState(1);
  12536. }
  12537. });
  12538. addEvent(label.element, isMS ? 'mouseout' : 'mouseleave', function () {
  12539. if (curState !== 3) {
  12540. label.setState(curState);
  12541. }
  12542. });
  12543. label.setState = function (state) {
  12544. // Hover state is temporary, don't record it
  12545. if (state !== 1) {
  12546. label.state = curState = state;
  12547. }
  12548. // Update visuals
  12549. label
  12550. .removeClass(/highcharts-button-(normal|hover|pressed|disabled)/)
  12551. .addClass('highcharts-button-' +
  12552. ['normal', 'hover', 'pressed', 'disabled'][state || 0]);
  12553. if (!styledMode) {
  12554. label
  12555. .attr([
  12556. normalState,
  12557. hoverState,
  12558. pressedState,
  12559. disabledState
  12560. ][state || 0])
  12561. .css([
  12562. normalStyle,
  12563. hoverStyle,
  12564. pressedStyle,
  12565. disabledStyle
  12566. ][state || 0]);
  12567. }
  12568. };
  12569. // Presentational attributes
  12570. if (!styledMode) {
  12571. label
  12572. .attr(normalState)
  12573. .css(extend({ cursor: 'default' }, normalStyle));
  12574. }
  12575. return label
  12576. .on('touchstart', function (e) { return e.stopPropagation(); })
  12577. .on('click', function (e) {
  12578. if (curState !== 3) {
  12579. callback.call(label, e);
  12580. }
  12581. });
  12582. };
  12583. /**
  12584. * Make a straight line crisper by not spilling out to neighbour pixels.
  12585. *
  12586. * @function Highcharts.SVGRenderer#crispLine
  12587. *
  12588. * @param {Highcharts.SVGPathArray} points
  12589. * The original points on the format `[['M', 0, 0], ['L', 100, 0]]`.
  12590. *
  12591. * @param {number} width
  12592. * The width of the line.
  12593. *
  12594. * @param {string} [roundingFunction=round]
  12595. * The rounding function name on the `Math` object, can be one of
  12596. * `round`, `floor` or `ceil`.
  12597. *
  12598. * @return {Highcharts.SVGPathArray}
  12599. * The original points array, but modified to render crisply.
  12600. */
  12601. SVGRenderer.prototype.crispLine = function (points, width, roundingFunction) {
  12602. if (roundingFunction === void 0) { roundingFunction = 'round'; }
  12603. var start = points[0];
  12604. var end = points[1];
  12605. // Normalize to a crisp line
  12606. if (defined(start[1]) && start[1] === end[1]) {
  12607. // Substract due to #1129. Now bottom and left axis gridlines behave
  12608. // the same.
  12609. start[1] = end[1] =
  12610. Math[roundingFunction](start[1]) - (width % 2 / 2);
  12611. }
  12612. if (defined(start[2]) && start[2] === end[2]) {
  12613. start[2] = end[2] =
  12614. Math[roundingFunction](start[2]) + (width % 2 / 2);
  12615. }
  12616. return points;
  12617. };
  12618. /**
  12619. * Draw a path, wraps the SVG `path` element.
  12620. *
  12621. * @sample highcharts/members/renderer-path-on-chart/
  12622. * Draw a path in a chart
  12623. * @sample highcharts/members/renderer-path/
  12624. * Draw a path independent from a chart
  12625. *
  12626. * @example
  12627. * let path = renderer.path(['M', 10, 10, 'L', 30, 30, 'z'])
  12628. * .attr({ stroke: '#ff00ff' })
  12629. * .add();
  12630. *
  12631. * @function Highcharts.SVGRenderer#path
  12632. *
  12633. * @param {Highcharts.SVGPathArray} [path]
  12634. * An SVG path definition in array form.
  12635. *
  12636. * @return {Highcharts.SVGElement}
  12637. * The generated wrapper element.
  12638. *
  12639. */ /**
  12640. * Draw a path, wraps the SVG `path` element.
  12641. *
  12642. * @function Highcharts.SVGRenderer#path
  12643. *
  12644. * @param {Highcharts.SVGAttributes} [attribs]
  12645. * The initial attributes.
  12646. *
  12647. * @return {Highcharts.SVGElement}
  12648. * The generated wrapper element.
  12649. */
  12650. SVGRenderer.prototype.path = function (path) {
  12651. var attribs = (this.styledMode ? {} : {
  12652. fill: 'none'
  12653. });
  12654. if (isArray(path)) {
  12655. attribs.d = path;
  12656. }
  12657. else if (isObject(path)) { // attributes
  12658. extend(attribs, path);
  12659. }
  12660. return this.createElement('path').attr(attribs);
  12661. };
  12662. /**
  12663. * Draw a circle, wraps the SVG `circle` element.
  12664. *
  12665. * @sample highcharts/members/renderer-circle/
  12666. * Drawing a circle
  12667. *
  12668. * @function Highcharts.SVGRenderer#circle
  12669. *
  12670. * @param {number} [x]
  12671. * The center x position.
  12672. *
  12673. * @param {number} [y]
  12674. * The center y position.
  12675. *
  12676. * @param {number} [r]
  12677. * The radius.
  12678. *
  12679. * @return {Highcharts.SVGElement}
  12680. * The generated wrapper element.
  12681. */ /**
  12682. * Draw a circle, wraps the SVG `circle` element.
  12683. *
  12684. * @function Highcharts.SVGRenderer#circle
  12685. *
  12686. * @param {Highcharts.SVGAttributes} [attribs]
  12687. * The initial attributes.
  12688. *
  12689. * @return {Highcharts.SVGElement}
  12690. * The generated wrapper element.
  12691. */
  12692. SVGRenderer.prototype.circle = function (x, y, r) {
  12693. var attribs = (isObject(x) ?
  12694. x :
  12695. typeof x === 'undefined' ? {} : { x: x, y: y, r: r }), wrapper = this.createElement('circle');
  12696. // Setting x or y translates to cx and cy
  12697. wrapper.xSetter = wrapper.ySetter = function (value, key, element) {
  12698. element.setAttribute('c' + key, value);
  12699. };
  12700. return wrapper.attr(attribs);
  12701. };
  12702. /**
  12703. * Draw and return an arc.
  12704. *
  12705. * @sample highcharts/members/renderer-arc/
  12706. * Drawing an arc
  12707. *
  12708. * @function Highcharts.SVGRenderer#arc
  12709. *
  12710. * @param {number} [x=0]
  12711. * Center X position.
  12712. *
  12713. * @param {number} [y=0]
  12714. * Center Y position.
  12715. *
  12716. * @param {number} [r=0]
  12717. * The outer radius' of the arc.
  12718. *
  12719. * @param {number} [innerR=0]
  12720. * Inner radius like used in donut charts.
  12721. *
  12722. * @param {number} [start=0]
  12723. * The starting angle of the arc in radians, where 0 is to the right and
  12724. * `-Math.PI/2` is up.
  12725. *
  12726. * @param {number} [end=0]
  12727. * The ending angle of the arc in radians, where 0 is to the right and
  12728. * `-Math.PI/2` is up.
  12729. *
  12730. * @return {Highcharts.SVGElement}
  12731. * The generated wrapper element.
  12732. */ /**
  12733. * Draw and return an arc. Overloaded function that takes arguments object.
  12734. *
  12735. * @function Highcharts.SVGRenderer#arc
  12736. *
  12737. * @param {Highcharts.SVGAttributes} attribs
  12738. * Initial SVG attributes.
  12739. *
  12740. * @return {Highcharts.SVGElement}
  12741. * The generated wrapper element.
  12742. */
  12743. SVGRenderer.prototype.arc = function (x, y, r, innerR, start, end) {
  12744. var options;
  12745. if (isObject(x)) {
  12746. options = x;
  12747. y = options.y;
  12748. r = options.r;
  12749. innerR = options.innerR;
  12750. start = options.start;
  12751. end = options.end;
  12752. x = options.x;
  12753. }
  12754. else {
  12755. options = { innerR: innerR, start: start, end: end };
  12756. }
  12757. // Arcs are defined as symbols for the ability to set
  12758. // attributes in attr and animate
  12759. var arc = this.symbol('arc',
  12760. x,
  12761. y,
  12762. r,
  12763. r,
  12764. options);
  12765. arc.r = r; // #959
  12766. return arc;
  12767. };
  12768. /**
  12769. * Draw and return a rectangle.
  12770. *
  12771. * @function Highcharts.SVGRenderer#rect
  12772. *
  12773. * @param {number} [x]
  12774. * Left position.
  12775. *
  12776. * @param {number} [y]
  12777. * Top position.
  12778. *
  12779. * @param {number} [width]
  12780. * Width of the rectangle.
  12781. *
  12782. * @param {number} [height]
  12783. * Height of the rectangle.
  12784. *
  12785. * @param {number} [r]
  12786. * Border corner radius.
  12787. *
  12788. * @param {number} [strokeWidth]
  12789. * A stroke width can be supplied to allow crisp drawing.
  12790. *
  12791. * @return {Highcharts.SVGElement}
  12792. * The generated wrapper element.
  12793. */ /**
  12794. * Draw and return a rectangle.
  12795. *
  12796. * @sample highcharts/members/renderer-rect-on-chart/
  12797. * Draw a rectangle in a chart
  12798. * @sample highcharts/members/renderer-rect/
  12799. * Draw a rectangle independent from a chart
  12800. *
  12801. * @function Highcharts.SVGRenderer#rect
  12802. *
  12803. * @param {Highcharts.SVGAttributes} [attributes]
  12804. * General SVG attributes for the rectangle.
  12805. *
  12806. * @return {Highcharts.SVGElement}
  12807. * The generated wrapper element.
  12808. */
  12809. SVGRenderer.prototype.rect = function (x, y, width, height, r, strokeWidth) {
  12810. r = isObject(x) ? x.r : r;
  12811. var wrapper = this.createElement('rect');
  12812. var attribs = (isObject(x) ?
  12813. x :
  12814. typeof x === 'undefined' ?
  12815. {} :
  12816. {
  12817. x: x,
  12818. y: y,
  12819. width: Math.max(width, 0),
  12820. height: Math.max(height, 0)
  12821. });
  12822. if (!this.styledMode) {
  12823. if (typeof strokeWidth !== 'undefined') {
  12824. attribs['stroke-width'] = strokeWidth;
  12825. attribs = wrapper.crisp(attribs);
  12826. }
  12827. attribs.fill = 'none';
  12828. }
  12829. if (r) {
  12830. attribs.r = r;
  12831. }
  12832. wrapper.rSetter = function (value, _key, element) {
  12833. wrapper.r = value;
  12834. attr(element, {
  12835. rx: value,
  12836. ry: value
  12837. });
  12838. };
  12839. wrapper.rGetter = function () {
  12840. return wrapper.r || 0;
  12841. };
  12842. return wrapper.attr(attribs);
  12843. };
  12844. /**
  12845. * Resize the {@link SVGRenderer#box} and re-align all aligned child
  12846. * elements.
  12847. *
  12848. * @sample highcharts/members/renderer-g/
  12849. * Show and hide grouped objects
  12850. *
  12851. * @function Highcharts.SVGRenderer#setSize
  12852. *
  12853. * @param {number} width
  12854. * The new pixel width.
  12855. *
  12856. * @param {number} height
  12857. * The new pixel height.
  12858. *
  12859. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animate=true]
  12860. * Whether and how to animate.
  12861. */
  12862. SVGRenderer.prototype.setSize = function (width, height, animate) {
  12863. var renderer = this;
  12864. renderer.width = width;
  12865. renderer.height = height;
  12866. renderer.boxWrapper.animate({
  12867. width: width,
  12868. height: height
  12869. }, {
  12870. step: function () {
  12871. this.attr({
  12872. viewBox: '0 0 ' + this.attr('width') + ' ' +
  12873. this.attr('height')
  12874. });
  12875. },
  12876. duration: pick(animate, true) ? void 0 : 0
  12877. });
  12878. renderer.alignElements();
  12879. };
  12880. /**
  12881. * Create and return an svg group element. Child
  12882. * {@link Highcharts.SVGElement} objects are added to the group by using the
  12883. * group as the first parameter in {@link Highcharts.SVGElement#add|add()}.
  12884. *
  12885. * @function Highcharts.SVGRenderer#g
  12886. *
  12887. * @param {string} [name]
  12888. * The group will be given a class name of `highcharts-{name}`. This
  12889. * can be used for styling and scripting.
  12890. *
  12891. * @return {Highcharts.SVGElement}
  12892. * The generated wrapper element.
  12893. */
  12894. SVGRenderer.prototype.g = function (name) {
  12895. var elem = this.createElement('g');
  12896. return name ?
  12897. elem.attr({ 'class': 'highcharts-' + name }) :
  12898. elem;
  12899. };
  12900. /**
  12901. * Display an image.
  12902. *
  12903. * @sample highcharts/members/renderer-image-on-chart/
  12904. * Add an image in a chart
  12905. * @sample highcharts/members/renderer-image/
  12906. * Add an image independent of a chart
  12907. *
  12908. * @function Highcharts.SVGRenderer#image
  12909. *
  12910. * @param {string} src
  12911. * The image source.
  12912. *
  12913. * @param {number} [x]
  12914. * The X position.
  12915. *
  12916. * @param {number} [y]
  12917. * The Y position.
  12918. *
  12919. * @param {number} [width]
  12920. * The image width. If omitted, it defaults to the image file width.
  12921. *
  12922. * @param {number} [height]
  12923. * The image height. If omitted it defaults to the image file
  12924. * height.
  12925. *
  12926. * @param {Function} [onload]
  12927. * Event handler for image load.
  12928. *
  12929. * @return {Highcharts.SVGElement}
  12930. * The generated wrapper element.
  12931. */
  12932. SVGRenderer.prototype.image = function (src, x, y, width, height, onload) {
  12933. var attribs = { preserveAspectRatio: 'none' }, setSVGImageSource = function (el, src) {
  12934. // Set the href in the xlink namespace
  12935. if (el.setAttributeNS) {
  12936. el.setAttributeNS('http://www.w3.org/1999/xlink', 'href', src);
  12937. }
  12938. else {
  12939. // could be exporting in IE
  12940. // using href throws "not supported" in ie7 and under,
  12941. // requries regex shim to fix later
  12942. el.setAttribute('hc-svg-href', src);
  12943. }
  12944. };
  12945. // optional properties
  12946. if (arguments.length > 1) {
  12947. extend(attribs, {
  12948. x: x,
  12949. y: y,
  12950. width: width,
  12951. height: height
  12952. });
  12953. }
  12954. var elemWrapper = this.createElement('image').attr(attribs),
  12955. onDummyLoad = function (e) {
  12956. setSVGImageSource(elemWrapper.element,
  12957. src);
  12958. onload.call(elemWrapper, e);
  12959. };
  12960. // Add load event if supplied
  12961. if (onload) {
  12962. // We have to use a dummy HTML image since IE support for SVG image
  12963. // load events is very buggy. First set a transparent src, wait for
  12964. // dummy to load, and then add the real src to the SVG image.
  12965. setSVGImageSource(elemWrapper.element, 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==' /* eslint-disable-line */);
  12966. var dummy = new win.Image();
  12967. addEvent(dummy, 'load', onDummyLoad);
  12968. dummy.src = src;
  12969. if (dummy.complete) {
  12970. onDummyLoad({});
  12971. }
  12972. }
  12973. else {
  12974. setSVGImageSource(elemWrapper.element, src);
  12975. }
  12976. return elemWrapper;
  12977. };
  12978. /**
  12979. * Draw a symbol out of pre-defined shape paths from
  12980. * {@link SVGRenderer#symbols}.
  12981. * It is used in Highcharts for point makers, which cake a `symbol` option,
  12982. * and label and button backgrounds like in the tooltip and stock flags.
  12983. *
  12984. * @function Highcharts.SVGRenderer#symbol
  12985. *
  12986. * @param {string} symbol
  12987. * The symbol name.
  12988. *
  12989. * @param {number} [x]
  12990. * The X coordinate for the top left position.
  12991. *
  12992. * @param {number} [y]
  12993. * The Y coordinate for the top left position.
  12994. *
  12995. * @param {number} [width]
  12996. * The pixel width.
  12997. *
  12998. * @param {number} [height]
  12999. * The pixel height.
  13000. *
  13001. * @param {Highcharts.SymbolOptionsObject} [options]
  13002. * Additional options, depending on the actual symbol drawn.
  13003. *
  13004. * @return {Highcharts.SVGElement}
  13005. */
  13006. SVGRenderer.prototype.symbol = function (symbol, x, y, width, height, options) {
  13007. var ren = this,
  13008. imageRegex = /^url\((.*?)\)$/,
  13009. isImage = imageRegex.test(symbol),
  13010. sym = (!isImage && (this.symbols[symbol] ? symbol : 'circle')),
  13011. // get the symbol definition function
  13012. symbolFn = (sym && this.symbols[sym]);
  13013. var obj,
  13014. path,
  13015. imageSrc,
  13016. centerImage;
  13017. if (symbolFn) {
  13018. // Check if there's a path defined for this symbol
  13019. if (typeof x === 'number') {
  13020. path = symbolFn.call(this.symbols, Math.round(x || 0), Math.round(y || 0), width || 0, height || 0, options);
  13021. }
  13022. obj = this.path(path);
  13023. if (!ren.styledMode) {
  13024. obj.attr('fill', 'none');
  13025. }
  13026. // expando properties for use in animate and attr
  13027. extend(obj, {
  13028. symbolName: (sym || void 0),
  13029. x: x,
  13030. y: y,
  13031. width: width,
  13032. height: height
  13033. });
  13034. if (options) {
  13035. extend(obj, options);
  13036. }
  13037. // Image symbols
  13038. }
  13039. else if (isImage) {
  13040. imageSrc = symbol.match(imageRegex)[1];
  13041. // Create the image synchronously, add attribs async
  13042. var img_1 = obj = this.image(imageSrc);
  13043. // The image width is not always the same as the symbol width. The
  13044. // image may be centered within the symbol, as is the case when
  13045. // image shapes are used as label backgrounds, for example in flags.
  13046. img_1.imgwidth = pick(symbolSizes[imageSrc] && symbolSizes[imageSrc].width, options && options.width);
  13047. img_1.imgheight = pick(symbolSizes[imageSrc] && symbolSizes[imageSrc].height, options && options.height);
  13048. /**
  13049. * Set the size and position
  13050. */
  13051. centerImage = function (obj) { return obj.attr({
  13052. width: obj.width,
  13053. height: obj.height
  13054. }); };
  13055. /**
  13056. * Width and height setters that take both the image's physical size
  13057. * and the label size into consideration, and translates the image
  13058. * to center within the label.
  13059. */
  13060. ['width', 'height'].forEach(function (key) {
  13061. img_1[key + 'Setter'] = function (value, key) {
  13062. var imgSize = this['img' + key];
  13063. this[key] = value;
  13064. if (defined(imgSize)) {
  13065. // Scale and center the image within its container.
  13066. // The name `backgroundSize` is taken from the CSS spec,
  13067. // but the value `within` is made up. Other possible
  13068. // values in the spec, `cover` and `contain`, can be
  13069. // implemented if needed.
  13070. if (options &&
  13071. options.backgroundSize === 'within' &&
  13072. this.width &&
  13073. this.height) {
  13074. imgSize = Math.round(imgSize * Math.min(this.width / this.imgwidth, this.height / this.imgheight));
  13075. }
  13076. if (this.element) {
  13077. this.element.setAttribute(key, imgSize);
  13078. }
  13079. if (!this.alignByTranslate) {
  13080. var translate = ((this[key] || 0) - imgSize) / 2;
  13081. var attribs = key === 'width' ?
  13082. { translateX: translate } :
  13083. { translateY: translate };
  13084. this.attr(attribs);
  13085. }
  13086. }
  13087. };
  13088. });
  13089. if (defined(x)) {
  13090. img_1.attr({
  13091. x: x,
  13092. y: y
  13093. });
  13094. }
  13095. img_1.isImg = true;
  13096. if (defined(img_1.imgwidth) && defined(img_1.imgheight)) {
  13097. centerImage(img_1);
  13098. }
  13099. else {
  13100. // Initialize image to be 0 size so export will still function
  13101. // if there's no cached sizes.
  13102. img_1.attr({ width: 0, height: 0 });
  13103. // Create a dummy JavaScript image to get the width and height.
  13104. createElement('img', {
  13105. onload: function () {
  13106. var chart = charts[ren.chartIndex];
  13107. // Special case for SVGs on IE11, the width is not
  13108. // accessible until the image is part of the DOM
  13109. // (#2854).
  13110. if (this.width === 0) {
  13111. css(this, {
  13112. position: 'absolute',
  13113. top: '-999em'
  13114. });
  13115. doc.body.appendChild(this);
  13116. }
  13117. // Center the image
  13118. symbolSizes[imageSrc] = {
  13119. width: this.width,
  13120. height: this.height
  13121. };
  13122. img_1.imgwidth = this.width;
  13123. img_1.imgheight = this.height;
  13124. if (img_1.element) {
  13125. centerImage(img_1);
  13126. }
  13127. // Clean up after #2854 workaround.
  13128. if (this.parentNode) {
  13129. this.parentNode.removeChild(this);
  13130. }
  13131. // Fire the load event when all external images are
  13132. // loaded
  13133. ren.imgCount--;
  13134. if (!ren.imgCount && chart && !chart.hasLoaded) {
  13135. chart.onload();
  13136. }
  13137. },
  13138. src: imageSrc
  13139. });
  13140. this.imgCount++;
  13141. }
  13142. }
  13143. return obj;
  13144. };
  13145. /**
  13146. * Define a clipping rectangle. The clipping rectangle is later applied
  13147. * to {@link SVGElement} objects through the {@link SVGElement#clip}
  13148. * function.
  13149. *
  13150. * @example
  13151. * let circle = renderer.circle(100, 100, 100)
  13152. * .attr({ fill: 'red' })
  13153. * .add();
  13154. * let clipRect = renderer.clipRect(100, 100, 100, 100);
  13155. *
  13156. * // Leave only the lower right quarter visible
  13157. * circle.clip(clipRect);
  13158. *
  13159. * @function Highcharts.SVGRenderer#clipRect
  13160. *
  13161. * @param {number} [x]
  13162. *
  13163. * @param {number} [y]
  13164. *
  13165. * @param {number} [width]
  13166. *
  13167. * @param {number} [height]
  13168. *
  13169. * @return {Highcharts.ClipRectElement}
  13170. * A clipping rectangle.
  13171. */
  13172. SVGRenderer.prototype.clipRect = function (x, y, width, height) {
  13173. var
  13174. // Add a hyphen at the end to avoid confusion in testing indexes
  13175. // -1 and -10, -11 etc (#6550)
  13176. id = uniqueKey() + '-', clipPath = this.createElement('clipPath').attr({
  13177. id: id
  13178. }).add(this.defs), wrapper = this.rect(x, y, width, height, 0).add(clipPath);
  13179. wrapper.id = id;
  13180. wrapper.clipPath = clipPath;
  13181. wrapper.count = 0;
  13182. return wrapper;
  13183. };
  13184. /**
  13185. * Draw text. The text can contain a subset of HTML, like spans and anchors
  13186. * and some basic text styling of these. For more advanced features like
  13187. * border and background, use {@link Highcharts.SVGRenderer#label} instead.
  13188. * To update the text after render, run `text.attr({ text: 'New text' })`.
  13189. *
  13190. * @sample highcharts/members/renderer-text-on-chart/
  13191. * Annotate the chart freely
  13192. * @sample highcharts/members/renderer-on-chart/
  13193. * Annotate with a border and in response to the data
  13194. * @sample highcharts/members/renderer-text/
  13195. * Formatted text
  13196. *
  13197. * @function Highcharts.SVGRenderer#text
  13198. *
  13199. * @param {string} [str]
  13200. * The text of (subset) HTML to draw.
  13201. *
  13202. * @param {number} [x]
  13203. * The x position of the text's lower left corner.
  13204. *
  13205. * @param {number} [y]
  13206. * The y position of the text's lower left corner.
  13207. *
  13208. * @param {boolean} [useHTML=false]
  13209. * Use HTML to render the text.
  13210. *
  13211. * @return {Highcharts.SVGElement}
  13212. * The text object.
  13213. */
  13214. SVGRenderer.prototype.text = function (str, x, y, useHTML) {
  13215. var renderer = this,
  13216. attribs = {};
  13217. if (useHTML && (renderer.allowHTML || !renderer.forExport)) {
  13218. return renderer.html(str, x, y);
  13219. }
  13220. attribs.x = Math.round(x || 0); // X always needed for line-wrap logic
  13221. if (y) {
  13222. attribs.y = Math.round(y);
  13223. }
  13224. if (defined(str)) {
  13225. attribs.text = str;
  13226. }
  13227. var wrapper = renderer.createElement('text').attr(attribs);
  13228. if (!useHTML) {
  13229. wrapper.xSetter = function (value, key, element) {
  13230. var tspans = element.getElementsByTagName('tspan'),
  13231. parentVal = element.getAttribute(key);
  13232. for (var i = 0, tspan = void 0; i < tspans.length; i++) {
  13233. tspan = tspans[i];
  13234. // If the x values are equal, the tspan represents a
  13235. // linebreak
  13236. if (tspan.getAttribute(key) === parentVal) {
  13237. tspan.setAttribute(key, value);
  13238. }
  13239. }
  13240. element.setAttribute(key, value);
  13241. };
  13242. }
  13243. return wrapper;
  13244. };
  13245. /**
  13246. * Utility to return the baseline offset and total line height from the font
  13247. * size.
  13248. *
  13249. * @function Highcharts.SVGRenderer#fontMetrics
  13250. *
  13251. * @param {number|string} [fontSize]
  13252. * The current font size to inspect. If not given, the font size
  13253. * will be found from the DOM element.
  13254. *
  13255. * @param {Highcharts.SVGElement|Highcharts.SVGDOMElement} [elem]
  13256. * The element to inspect for a current font size.
  13257. *
  13258. * @return {Highcharts.FontMetricsObject}
  13259. * The font metrics.
  13260. */
  13261. SVGRenderer.prototype.fontMetrics = function (fontSize, elem) {
  13262. if ((this.styledMode || !/px/.test(fontSize)) &&
  13263. win.getComputedStyle // old IE doesn't support it
  13264. ) {
  13265. fontSize = elem && SVGElement.prototype.getStyle.call(elem, 'font-size');
  13266. }
  13267. else {
  13268. fontSize = fontSize ||
  13269. // When the elem is a DOM element (#5932)
  13270. (elem && elem.style && elem.style.fontSize) ||
  13271. // Fall back on the renderer style default
  13272. (this.style && this.style.fontSize);
  13273. }
  13274. // Handle different units
  13275. if (/px/.test(fontSize)) {
  13276. fontSize = pInt(fontSize);
  13277. }
  13278. else {
  13279. fontSize = 12;
  13280. }
  13281. // Empirical values found by comparing font size and bounding box
  13282. // height. Applies to the default font family.
  13283. // https://jsfiddle.net/highcharts/7xvn7/
  13284. var lineHeight = (fontSize < 24 ?
  13285. fontSize + 3 :
  13286. Math.round(fontSize * 1.2)),
  13287. baseline = Math.round(lineHeight * 0.8);
  13288. return {
  13289. h: lineHeight,
  13290. b: baseline,
  13291. f: fontSize
  13292. };
  13293. };
  13294. /**
  13295. * Correct X and Y positioning of a label for rotation (#1764).
  13296. *
  13297. * @private
  13298. * @function Highcharts.SVGRenderer#rotCorr
  13299. *
  13300. * @param {number} baseline
  13301. *
  13302. * @param {number} rotation
  13303. *
  13304. * @param {boolean} [alterY]
  13305. *
  13306. * @param {Highcharts.PositionObject}
  13307. */
  13308. SVGRenderer.prototype.rotCorr = function (baseline, rotation, alterY) {
  13309. var y = baseline;
  13310. if (rotation && alterY) {
  13311. y = Math.max(y * Math.cos(rotation * deg2rad), 4);
  13312. }
  13313. return {
  13314. x: (-baseline / 3) * Math.sin(rotation * deg2rad),
  13315. y: y
  13316. };
  13317. };
  13318. /**
  13319. * Compatibility function to convert the legacy one-dimensional path array
  13320. * into an array of segments.
  13321. *
  13322. * It is used in maps to parse the `path` option, and in SVGRenderer.dSetter
  13323. * to support legacy paths from demos.
  13324. *
  13325. * @private
  13326. * @function Highcharts.SVGRenderer#pathToSegments
  13327. */
  13328. SVGRenderer.prototype.pathToSegments = function (path) {
  13329. var ret = [];
  13330. var segment = [];
  13331. var commandLength = {
  13332. A: 8,
  13333. C: 7,
  13334. H: 2,
  13335. L: 3,
  13336. M: 3,
  13337. Q: 5,
  13338. S: 5,
  13339. T: 3,
  13340. V: 2
  13341. };
  13342. // Short, non-typesafe parsing of the one-dimensional array. It splits
  13343. // the path on any string. This is not type checked against the tuple
  13344. // types, but is shorter, and doesn't require specific checks for any
  13345. // command type in SVG.
  13346. for (var i = 0; i < path.length; i++) {
  13347. // Command skipped, repeat previous or insert L/l for M/m
  13348. if (isString(segment[0]) &&
  13349. isNumber(path[i]) &&
  13350. segment.length === commandLength[(segment[0].toUpperCase())]) {
  13351. path.splice(i, 0, segment[0].replace('M', 'L').replace('m', 'l'));
  13352. }
  13353. // Split on string
  13354. if (typeof path[i] === 'string') {
  13355. if (segment.length) {
  13356. ret.push(segment.slice(0));
  13357. }
  13358. segment.length = 0;
  13359. }
  13360. segment.push(path[i]);
  13361. }
  13362. ret.push(segment.slice(0));
  13363. return ret;
  13364. /*
  13365. // Fully type-safe version where each tuple type is checked. The
  13366. // downside is filesize and a lack of flexibility for unsupported
  13367. // commands
  13368. const ret: SVGPath = [],
  13369. commands = {
  13370. A: 7,
  13371. C: 6,
  13372. H: 1,
  13373. L: 2,
  13374. M: 2,
  13375. Q: 4,
  13376. S: 4,
  13377. T: 2,
  13378. V: 1,
  13379. Z: 0
  13380. };
  13381. let i = 0,
  13382. lastI = 0,
  13383. lastCommand;
  13384. while (i < path.length) {
  13385. const item = path[i];
  13386. let command;
  13387. if (typeof item === 'string') {
  13388. command = item;
  13389. i += 1;
  13390. } else {
  13391. command = lastCommand || 'M';
  13392. }
  13393. // Upper case
  13394. const commandUC = command.toUpperCase();
  13395. if (commandUC in commands) {
  13396. // No numeric parameters
  13397. if (command === 'Z' || command === 'z') {
  13398. ret.push([command]);
  13399. // One numeric parameter
  13400. } else {
  13401. const val0 = path[i];
  13402. if (typeof val0 === 'number') {
  13403. // Horizontal line to
  13404. if (command === 'H' || command === 'h') {
  13405. ret.push([command, val0]);
  13406. i += 1;
  13407. // Vertical line to
  13408. } else if (command === 'V' || command === 'v') {
  13409. ret.push([command, val0]);
  13410. i += 1;
  13411. // Two numeric parameters
  13412. } else {
  13413. const val1 = path[i + 1];
  13414. if (typeof val1 === 'number') {
  13415. // lineTo
  13416. if (command === 'L' || command === 'l') {
  13417. ret.push([command, val0, val1]);
  13418. i += 2;
  13419. // moveTo
  13420. } else if (command === 'M' || command === 'm') {
  13421. ret.push([command, val0, val1]);
  13422. i += 2;
  13423. // Smooth quadratic bezier
  13424. } else if (command === 'T' || command === 't') {
  13425. ret.push([command, val0, val1]);
  13426. i += 2;
  13427. // Four numeric parameters
  13428. } else {
  13429. const val2 = path[i + 2],
  13430. val3 = path[i + 3];
  13431. if (
  13432. typeof val2 === 'number' &&
  13433. typeof val3 === 'number'
  13434. ) {
  13435. // Quadratic bezier to
  13436. if (
  13437. command === 'Q' ||
  13438. command === 'q'
  13439. ) {
  13440. ret.push([
  13441. command,
  13442. val0,
  13443. val1,
  13444. val2,
  13445. val3
  13446. ]);
  13447. i += 4;
  13448. // Smooth cubic bezier to
  13449. } else if (
  13450. command === 'S' ||
  13451. command === 's'
  13452. ) {
  13453. ret.push([
  13454. command,
  13455. val0,
  13456. val1,
  13457. val2,
  13458. val3
  13459. ]);
  13460. i += 4;
  13461. // Six numeric parameters
  13462. } else {
  13463. const val4 = path[i + 4],
  13464. val5 = path[i + 5];
  13465. if (
  13466. typeof val4 === 'number' &&
  13467. typeof val5 === 'number'
  13468. ) {
  13469. // Curve to
  13470. if (
  13471. command === 'C' ||
  13472. command === 'c'
  13473. ) {
  13474. ret.push([
  13475. command,
  13476. val0,
  13477. val1,
  13478. val2,
  13479. val3,
  13480. val4,
  13481. val5
  13482. ]);
  13483. i += 6;
  13484. // Seven numeric parameters
  13485. } else {
  13486. const val6 = path[i + 6];
  13487. // Arc to
  13488. if (
  13489. typeof val6 ===
  13490. 'number' &&
  13491. (
  13492. command === 'A' ||
  13493. command === 'a'
  13494. )
  13495. ) {
  13496. ret.push([
  13497. command,
  13498. val0,
  13499. val1,
  13500. val2,
  13501. val3,
  13502. val4,
  13503. val5,
  13504. val6
  13505. ]);
  13506. i += 7;
  13507. }
  13508. }
  13509. }
  13510. }
  13511. }
  13512. }
  13513. }
  13514. }
  13515. }
  13516. }
  13517. }
  13518. // An unmarked command following a moveTo is a lineTo
  13519. lastCommand = command === 'M' ? 'L' : command;
  13520. if (i === lastI) {
  13521. break;
  13522. }
  13523. lastI = i;
  13524. }
  13525. return ret;
  13526. */
  13527. };
  13528. /**
  13529. * Draw a label, which is an extended text element with support for border
  13530. * and background. Highcharts creates a `g` element with a text and a `path`
  13531. * or `rect` inside, to make it behave somewhat like a HTML div. Border and
  13532. * background are set through `stroke`, `stroke-width` and `fill` attributes
  13533. * using the {@link Highcharts.SVGElement#attr|attr} method. To update the
  13534. * text after render, run `label.attr({ text: 'New text' })`.
  13535. *
  13536. * @sample highcharts/members/renderer-label-on-chart/
  13537. * A label on the chart
  13538. *
  13539. * @function Highcharts.SVGRenderer#label
  13540. *
  13541. * @param {string} str
  13542. * The initial text string or (subset) HTML to render.
  13543. *
  13544. * @param {number} x
  13545. * The x position of the label's left side.
  13546. *
  13547. * @param {number} [y]
  13548. * The y position of the label's top side or baseline, depending on
  13549. * the `baseline` parameter.
  13550. *
  13551. * @param {string} [shape='rect']
  13552. * The shape of the label's border/background, if any. Defaults to
  13553. * `rect`. Other possible values are `callout` or other shapes
  13554. * defined in {@link Highcharts.SVGRenderer#symbols}.
  13555. *
  13556. * @param {number} [anchorX]
  13557. * In case the `shape` has a pointer, like a flag, this is the
  13558. * coordinates it should be pinned to.
  13559. *
  13560. * @param {number} [anchorY]
  13561. * In case the `shape` has a pointer, like a flag, this is the
  13562. * coordinates it should be pinned to.
  13563. *
  13564. * @param {boolean} [useHTML=false]
  13565. * Wether to use HTML to render the label.
  13566. *
  13567. * @param {boolean} [baseline=false]
  13568. * Whether to position the label relative to the text baseline,
  13569. * like {@link Highcharts.SVGRenderer#text|renderer.text}, or to the
  13570. * upper border of the rectangle.
  13571. *
  13572. * @param {string} [className]
  13573. * Class name for the group.
  13574. *
  13575. * @return {Highcharts.SVGElement}
  13576. * The generated label.
  13577. */
  13578. SVGRenderer.prototype.label = function (str, x, y, shape, anchorX, anchorY, useHTML, baseline, className) {
  13579. return new SVGLabel(this, str, x, y, shape, anchorX, anchorY, useHTML, baseline, className);
  13580. };
  13581. /**
  13582. * Re-align all aligned elements.
  13583. *
  13584. * @private
  13585. * @function Highcharts.SVGRenderer#alignElements
  13586. * @return {void}
  13587. */
  13588. SVGRenderer.prototype.alignElements = function () {
  13589. this.alignedObjects.forEach(function (el) { return el.align(); });
  13590. };
  13591. return SVGRenderer;
  13592. }());
  13593. extend(SVGRenderer.prototype, {
  13594. /**
  13595. * A pointer to the renderer's associated Element class. The VMLRenderer
  13596. * will have a pointer to VMLElement here.
  13597. *
  13598. * @name Highcharts.SVGRenderer#Element
  13599. * @type {Highcharts.SVGElement}
  13600. */
  13601. Element: SVGElement,
  13602. SVG_NS: SVG_NS,
  13603. /**
  13604. * A collection of characters mapped to HTML entities. When `useHTML` on an
  13605. * element is true, these entities will be rendered correctly by HTML. In
  13606. * the SVG pseudo-HTML, they need to be unescaped back to simple characters,
  13607. * so for example `&lt;` will render as `<`.
  13608. *
  13609. * @example
  13610. * // Add support for unescaping quotes
  13611. * Highcharts.SVGRenderer.prototype.escapes['"'] = '&quot;';
  13612. *
  13613. * @name Highcharts.SVGRenderer#escapes
  13614. * @type {Highcharts.Dictionary<string>}
  13615. */
  13616. escapes: {
  13617. '&': '&amp;',
  13618. '<': '&lt;',
  13619. '>': '&gt;',
  13620. "'": '&#39;',
  13621. '"': '&quot;'
  13622. },
  13623. /**
  13624. * An extendable collection of functions for defining symbol paths.
  13625. *
  13626. * @name Highcharts.SVGRenderer#symbols
  13627. * @type {Highcharts.SymbolDictionary}
  13628. */
  13629. symbols: Symbols,
  13630. /**
  13631. * Dummy function for plugins, called every time the renderer is updated.
  13632. * Prior to Highcharts 5, this was used for the canvg renderer.
  13633. *
  13634. * @deprecated
  13635. * @function Highcharts.SVGRenderer#draw
  13636. */
  13637. draw: noop
  13638. });
  13639. /* *
  13640. *
  13641. * Registry
  13642. *
  13643. * */
  13644. RendererRegistry.registerRendererType('svg', SVGRenderer, true);
  13645. /* *
  13646. *
  13647. * Export Default
  13648. *
  13649. * */
  13650. /* *
  13651. *
  13652. * API Declarations
  13653. *
  13654. * */
  13655. /**
  13656. * A clipping rectangle that can be applied to one or more {@link SVGElement}
  13657. * instances. It is instanciated with the {@link SVGRenderer#clipRect} function
  13658. * and applied with the {@link SVGElement#clip} function.
  13659. *
  13660. * @example
  13661. * let circle = renderer.circle(100, 100, 100)
  13662. * .attr({ fill: 'red' })
  13663. * .add();
  13664. * let clipRect = renderer.clipRect(100, 100, 100, 100);
  13665. *
  13666. * // Leave only the lower right quarter visible
  13667. * circle.clip(clipRect);
  13668. *
  13669. * @typedef {Highcharts.SVGElement} Highcharts.ClipRectElement
  13670. */
  13671. /**
  13672. * The font metrics.
  13673. *
  13674. * @interface Highcharts.FontMetricsObject
  13675. */ /**
  13676. * The baseline relative to the top of the box.
  13677. *
  13678. * @name Highcharts.FontMetricsObject#b
  13679. * @type {number}
  13680. */ /**
  13681. * The font size.
  13682. *
  13683. * @name Highcharts.FontMetricsObject#f
  13684. * @type {number}
  13685. */ /**
  13686. * The line height.
  13687. *
  13688. * @name Highcharts.FontMetricsObject#h
  13689. * @type {number}
  13690. */
  13691. /**
  13692. * An object containing `x` and `y` properties for the position of an element.
  13693. *
  13694. * @interface Highcharts.PositionObject
  13695. */ /**
  13696. * X position of the element.
  13697. * @name Highcharts.PositionObject#x
  13698. * @type {number}
  13699. */ /**
  13700. * Y position of the element.
  13701. * @name Highcharts.PositionObject#y
  13702. * @type {number}
  13703. */
  13704. /**
  13705. * A rectangle.
  13706. *
  13707. * @interface Highcharts.RectangleObject
  13708. */ /**
  13709. * Height of the rectangle.
  13710. * @name Highcharts.RectangleObject#height
  13711. * @type {number}
  13712. */ /**
  13713. * Width of the rectangle.
  13714. * @name Highcharts.RectangleObject#width
  13715. * @type {number}
  13716. */ /**
  13717. * Horizontal position of the rectangle.
  13718. * @name Highcharts.RectangleObject#x
  13719. * @type {number}
  13720. */ /**
  13721. * Vertical position of the rectangle.
  13722. * @name Highcharts.RectangleObject#y
  13723. * @type {number}
  13724. */
  13725. /**
  13726. * The shadow options.
  13727. *
  13728. * @interface Highcharts.ShadowOptionsObject
  13729. */ /**
  13730. * The shadow color.
  13731. * @name Highcharts.ShadowOptionsObject#color
  13732. * @type {Highcharts.ColorString|undefined}
  13733. * @default ${palette.neutralColor100}
  13734. */ /**
  13735. * The horizontal offset from the element.
  13736. *
  13737. * @name Highcharts.ShadowOptionsObject#offsetX
  13738. * @type {number|undefined}
  13739. * @default 1
  13740. */ /**
  13741. * The vertical offset from the element.
  13742. * @name Highcharts.ShadowOptionsObject#offsetY
  13743. * @type {number|undefined}
  13744. * @default 1
  13745. */ /**
  13746. * The shadow opacity.
  13747. *
  13748. * @name Highcharts.ShadowOptionsObject#opacity
  13749. * @type {number|undefined}
  13750. * @default 0.15
  13751. */ /**
  13752. * The shadow width or distance from the element.
  13753. * @name Highcharts.ShadowOptionsObject#width
  13754. * @type {number|undefined}
  13755. * @default 3
  13756. */
  13757. /**
  13758. * @interface Highcharts.SizeObject
  13759. */ /**
  13760. * @name Highcharts.SizeObject#height
  13761. * @type {number}
  13762. */ /**
  13763. * @name Highcharts.SizeObject#width
  13764. * @type {number}
  13765. */
  13766. /**
  13767. * Array of path commands, that will go into the `d` attribute of an SVG
  13768. * element.
  13769. *
  13770. * @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
  13771. */
  13772. /**
  13773. * Possible path commands in an SVG path array. Valid values are `A`, `C`, `H`,
  13774. * `L`, `M`, `Q`, `S`, `T`, `V`, `Z`.
  13775. *
  13776. * @typedef {string} Highcharts.SVGPathCommand
  13777. * @validvalue ["a","c","h","l","m","q","s","t","v","z","A","C","H","L","M","Q","S","T","V","Z"]
  13778. */
  13779. /**
  13780. * An extendable collection of functions for defining symbol paths. Symbols are
  13781. * used internally for point markers, button and label borders and backgrounds,
  13782. * or custom shapes. Extendable by adding to {@link SVGRenderer#symbols}.
  13783. *
  13784. * @interface Highcharts.SymbolDictionary
  13785. */ /**
  13786. * @name Highcharts.SymbolDictionary#[key:string]
  13787. * @type {Function|undefined}
  13788. */ /**
  13789. * @name Highcharts.SymbolDictionary#arc
  13790. * @type {Function|undefined}
  13791. */ /**
  13792. * @name Highcharts.SymbolDictionary#callout
  13793. * @type {Function|undefined}
  13794. */ /**
  13795. * @name Highcharts.SymbolDictionary#circle
  13796. * @type {Function|undefined}
  13797. */ /**
  13798. * @name Highcharts.SymbolDictionary#diamond
  13799. * @type {Function|undefined}
  13800. */ /**
  13801. * @name Highcharts.SymbolDictionary#square
  13802. * @type {Function|undefined}
  13803. */ /**
  13804. * @name Highcharts.SymbolDictionary#triangle
  13805. * @type {Function|undefined}
  13806. */
  13807. /**
  13808. * Can be one of `arc`, `callout`, `circle`, `diamond`, `square`, `triangle`,
  13809. * and `triangle-down`. Symbols are used internally for point markers, button
  13810. * and label borders and backgrounds, or custom shapes. Extendable by adding to
  13811. * {@link SVGRenderer#symbols}.
  13812. *
  13813. * @typedef {"arc"|"callout"|"circle"|"diamond"|"square"|"triangle"|"triangle-down"} Highcharts.SymbolKeyValue
  13814. */
  13815. /**
  13816. * Additional options, depending on the actual symbol drawn.
  13817. *
  13818. * @interface Highcharts.SymbolOptionsObject
  13819. */ /**
  13820. * The anchor X position for the `callout` symbol. This is where the chevron
  13821. * points to.
  13822. *
  13823. * @name Highcharts.SymbolOptionsObject#anchorX
  13824. * @type {number|undefined}
  13825. */ /**
  13826. * The anchor Y position for the `callout` symbol. This is where the chevron
  13827. * points to.
  13828. *
  13829. * @name Highcharts.SymbolOptionsObject#anchorY
  13830. * @type {number|undefined}
  13831. */ /**
  13832. * The end angle of an `arc` symbol.
  13833. *
  13834. * @name Highcharts.SymbolOptionsObject#end
  13835. * @type {number|undefined}
  13836. */ /**
  13837. * Whether to draw `arc` symbol open or closed.
  13838. *
  13839. * @name Highcharts.SymbolOptionsObject#open
  13840. * @type {boolean|undefined}
  13841. */ /**
  13842. * The radius of an `arc` symbol, or the border radius for the `callout` symbol.
  13843. *
  13844. * @name Highcharts.SymbolOptionsObject#r
  13845. * @type {number|undefined}
  13846. */ /**
  13847. * The start angle of an `arc` symbol.
  13848. *
  13849. * @name Highcharts.SymbolOptionsObject#start
  13850. * @type {number|undefined}
  13851. */
  13852. (''); // keeps doclets above in transpiled file
  13853. return SVGRenderer;
  13854. });
  13855. _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) {
  13856. /* *
  13857. *
  13858. * (c) 2010-2021 Torstein Honsi
  13859. *
  13860. * License: www.highcharts.com/license
  13861. *
  13862. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  13863. *
  13864. * */
  13865. var __extends = (this && this.__extends) || (function () {
  13866. var extendStatics = function (d,
  13867. b) {
  13868. extendStatics = Object.setPrototypeOf ||
  13869. ({ __proto__: [] } instanceof Array && function (d,
  13870. b) { d.__proto__ = b; }) ||
  13871. function (d,
  13872. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  13873. return extendStatics(d, b);
  13874. };
  13875. return function (d, b) {
  13876. extendStatics(d, b);
  13877. function __() { this.constructor = d; }
  13878. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  13879. };
  13880. })();
  13881. var isFirefox = H.isFirefox,
  13882. isMS = H.isMS,
  13883. isWebKit = H.isWebKit,
  13884. win = H.win;
  13885. var css = U.css,
  13886. defined = U.defined,
  13887. extend = U.extend,
  13888. pick = U.pick,
  13889. pInt = U.pInt;
  13890. /* *
  13891. *
  13892. * Composition
  13893. *
  13894. * */
  13895. /* eslint-disable valid-jsdoc */
  13896. var HTMLElement = /** @class */ (function (_super) {
  13897. __extends(HTMLElement, _super);
  13898. function HTMLElement() {
  13899. return _super !== null && _super.apply(this, arguments) || this;
  13900. }
  13901. /* *
  13902. *
  13903. * Static Functions
  13904. *
  13905. * */
  13906. /**
  13907. * Modifies SVGElement to support HTML elements.
  13908. * @private
  13909. */
  13910. HTMLElement.compose = function (SVGElementClass) {
  13911. var svgElementProto = SVGElementClass.prototype,
  13912. htmlElementProto = HTMLElement.prototype;
  13913. svgElementProto.getSpanCorrection = htmlElementProto.getSpanCorrection;
  13914. svgElementProto.htmlCss = htmlElementProto.htmlCss;
  13915. svgElementProto.htmlGetBBox = htmlElementProto.htmlGetBBox;
  13916. svgElementProto.htmlUpdateTransform = htmlElementProto.htmlUpdateTransform;
  13917. svgElementProto.setSpanRotation = htmlElementProto.setSpanRotation;
  13918. };
  13919. /* *
  13920. *
  13921. * Functions
  13922. *
  13923. * */
  13924. /**
  13925. * Get the correction in X and Y positioning as the element is rotated.
  13926. * @private
  13927. */
  13928. HTMLElement.prototype.getSpanCorrection = function (width, baseline, alignCorrection) {
  13929. this.xCorr = -width * alignCorrection;
  13930. this.yCorr = -baseline;
  13931. };
  13932. /**
  13933. * Apply CSS to HTML elements. This is used in text within SVG rendering and
  13934. * by the VML renderer
  13935. * @private
  13936. */
  13937. HTMLElement.prototype.htmlCss = function (styles) {
  13938. var wrapper = this,
  13939. element = wrapper.element,
  13940. // When setting or unsetting the width style, we need to update
  13941. // transform (#8809)
  13942. isSettingWidth = (element.tagName === 'SPAN' &&
  13943. styles &&
  13944. 'width' in styles),
  13945. textWidth = pick(isSettingWidth && styles.width,
  13946. void 0);
  13947. var doTransform;
  13948. if (isSettingWidth) {
  13949. delete styles.width;
  13950. wrapper.textWidth = textWidth;
  13951. doTransform = true;
  13952. }
  13953. if (styles && styles.textOverflow === 'ellipsis') {
  13954. styles.whiteSpace = 'nowrap';
  13955. styles.overflow = 'hidden';
  13956. }
  13957. wrapper.styles = extend(wrapper.styles, styles);
  13958. css(wrapper.element, styles);
  13959. // Now that all styles are applied, to the transform
  13960. if (doTransform) {
  13961. wrapper.htmlUpdateTransform();
  13962. }
  13963. return wrapper;
  13964. };
  13965. /**
  13966. * VML and useHTML method for calculating the bounding box based on offsets.
  13967. */
  13968. HTMLElement.prototype.htmlGetBBox = function () {
  13969. var wrapper = this,
  13970. element = wrapper.element;
  13971. return {
  13972. x: element.offsetLeft,
  13973. y: element.offsetTop,
  13974. width: element.offsetWidth,
  13975. height: element.offsetHeight
  13976. };
  13977. };
  13978. /**
  13979. * VML override private method to update elements based on internal
  13980. * properties based on SVG transform.
  13981. * @private
  13982. */
  13983. HTMLElement.prototype.htmlUpdateTransform = function () {
  13984. // aligning non added elements is expensive
  13985. if (!this.added) {
  13986. this.alignOnAdd = true;
  13987. return;
  13988. }
  13989. var wrapper = this,
  13990. renderer = wrapper.renderer,
  13991. elem = wrapper.element,
  13992. translateX = wrapper.translateX || 0,
  13993. translateY = wrapper.translateY || 0,
  13994. x = wrapper.x || 0,
  13995. y = wrapper.y || 0,
  13996. align = wrapper.textAlign || 'left',
  13997. alignCorrection = {
  13998. left: 0,
  13999. center: 0.5,
  14000. right: 1
  14001. }[align],
  14002. styles = wrapper.styles,
  14003. whiteSpace = styles && styles.whiteSpace;
  14004. /** @private */
  14005. function getTextPxLength() {
  14006. // Reset multiline/ellipsis in order to read width (#4928,
  14007. // #5417)
  14008. css(elem, {
  14009. width: '',
  14010. whiteSpace: whiteSpace || 'nowrap'
  14011. });
  14012. return elem.offsetWidth;
  14013. }
  14014. // apply translate
  14015. css(elem, {
  14016. marginLeft: translateX,
  14017. marginTop: translateY
  14018. });
  14019. if (!renderer.styledMode && wrapper.shadows) { // used in labels/tooltip
  14020. wrapper.shadows.forEach(function (shadow) {
  14021. css(shadow, {
  14022. marginLeft: translateX + 1,
  14023. marginTop: translateY + 1
  14024. });
  14025. });
  14026. }
  14027. // apply inversion
  14028. if (wrapper.inverted) { // wrapper is a group
  14029. [].forEach.call(elem.childNodes, function (child) {
  14030. renderer.invertChild(child, elem);
  14031. });
  14032. }
  14033. if (elem.tagName === 'SPAN') {
  14034. var rotation = wrapper.rotation, textWidth = wrapper.textWidth && pInt(wrapper.textWidth), currentTextTransform = [
  14035. rotation,
  14036. align,
  14037. elem.innerHTML,
  14038. wrapper.textWidth,
  14039. wrapper.textAlign
  14040. ].join(',');
  14041. var baseline = void 0;
  14042. // Update textWidth. Use the memoized textPxLength if possible, to
  14043. // avoid the getTextPxLength function using elem.offsetWidth.
  14044. // Calling offsetWidth affects rendering time as it forces layout
  14045. // (#7656).
  14046. if (textWidth !== wrapper.oldTextWidth &&
  14047. ((textWidth > wrapper.oldTextWidth) ||
  14048. (wrapper.textPxLength || getTextPxLength()) > textWidth) && (
  14049. // Only set the width if the text is able to word-wrap, or
  14050. // text-overflow is ellipsis (#9537)
  14051. /[ \-]/.test(elem.textContent || elem.innerText) ||
  14052. elem.style.textOverflow === 'ellipsis')) { // #983, #1254
  14053. css(elem, {
  14054. width: textWidth + 'px',
  14055. display: 'block',
  14056. whiteSpace: whiteSpace || 'normal' // #3331
  14057. });
  14058. wrapper.oldTextWidth = textWidth;
  14059. wrapper.hasBoxWidthChanged = true; // #8159
  14060. }
  14061. else {
  14062. wrapper.hasBoxWidthChanged = false; // #8159
  14063. }
  14064. // Do the calculations and DOM access only if properties changed
  14065. if (currentTextTransform !== wrapper.cTT) {
  14066. baseline = renderer.fontMetrics(elem.style.fontSize, elem).b;
  14067. // Renderer specific handling of span rotation, but only if we
  14068. // have something to update.
  14069. if (defined(rotation) &&
  14070. ((rotation !== (wrapper.oldRotation || 0)) ||
  14071. (align !== wrapper.oldAlign))) {
  14072. wrapper.setSpanRotation(rotation, alignCorrection, baseline);
  14073. }
  14074. wrapper.getSpanCorrection(
  14075. // Avoid elem.offsetWidth if we can, it affects rendering
  14076. // time heavily (#7656)
  14077. ((!defined(rotation) && wrapper.textPxLength) || // #7920
  14078. elem.offsetWidth), baseline, alignCorrection, rotation, align);
  14079. }
  14080. // apply position with correction
  14081. css(elem, {
  14082. left: (x + (wrapper.xCorr || 0)) + 'px',
  14083. top: (y + (wrapper.yCorr || 0)) + 'px'
  14084. });
  14085. // record current text transform
  14086. wrapper.cTT = currentTextTransform;
  14087. wrapper.oldRotation = rotation;
  14088. wrapper.oldAlign = align;
  14089. }
  14090. };
  14091. /**
  14092. * Set the rotation of an individual HTML span.
  14093. * @private
  14094. */
  14095. HTMLElement.prototype.setSpanRotation = function (rotation, alignCorrection, baseline) {
  14096. var getTransformKey = function () { return (isMS &&
  14097. !/Edge/.test(win.navigator.userAgent) ?
  14098. '-ms-transform' :
  14099. isWebKit ?
  14100. '-webkit-transform' :
  14101. isFirefox ?
  14102. 'MozTransform' :
  14103. win.opera ?
  14104. '-o-transform' :
  14105. void 0); };
  14106. var rotationStyle = {},
  14107. cssTransformKey = getTransformKey();
  14108. if (cssTransformKey) {
  14109. rotationStyle[cssTransformKey] = rotationStyle.transform =
  14110. 'rotate(' + rotation + 'deg)';
  14111. rotationStyle[cssTransformKey + (isFirefox ? 'Origin' : '-origin')] = rotationStyle.transformOrigin =
  14112. (alignCorrection * 100) + '% ' + baseline + 'px';
  14113. css(this.element, rotationStyle);
  14114. }
  14115. };
  14116. return HTMLElement;
  14117. }(SVGElement));
  14118. /* *
  14119. *
  14120. * Default Export
  14121. *
  14122. * */
  14123. return HTMLElement;
  14124. });
  14125. _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) {
  14126. /* *
  14127. *
  14128. * (c) 2010-2021 Torstein Honsi
  14129. *
  14130. * License: www.highcharts.com/license
  14131. *
  14132. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  14133. *
  14134. * */
  14135. var __extends = (this && this.__extends) || (function () {
  14136. var extendStatics = function (d,
  14137. b) {
  14138. extendStatics = Object.setPrototypeOf ||
  14139. ({ __proto__: [] } instanceof Array && function (d,
  14140. b) { d.__proto__ = b; }) ||
  14141. function (d,
  14142. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  14143. return extendStatics(d, b);
  14144. };
  14145. return function (d, b) {
  14146. extendStatics(d, b);
  14147. function __() { this.constructor = d; }
  14148. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  14149. };
  14150. })();
  14151. var attr = U.attr,
  14152. createElement = U.createElement,
  14153. extend = U.extend,
  14154. pick = U.pick;
  14155. /* *
  14156. *
  14157. * Composition
  14158. *
  14159. * */
  14160. /* eslint-disable valid-jsdoc */
  14161. // Extend SvgRenderer for useHTML option.
  14162. var HTMLRenderer = /** @class */ (function (_super) {
  14163. __extends(HTMLRenderer, _super);
  14164. function HTMLRenderer() {
  14165. return _super !== null && _super.apply(this, arguments) || this;
  14166. }
  14167. /* *
  14168. *
  14169. * Functions
  14170. *
  14171. * */
  14172. /** @private */
  14173. HTMLRenderer.compose = function (SVGRendererClass) {
  14174. var svgRendererProto = SVGRendererClass.prototype,
  14175. htmlRendererProto = HTMLRenderer.prototype;
  14176. svgRendererProto.html = htmlRendererProto.html;
  14177. };
  14178. /**
  14179. * Create HTML text node. This is used by the VML renderer as well as the
  14180. * SVG renderer through the useHTML option.
  14181. *
  14182. * @private
  14183. * @function Highcharts.SVGRenderer#html
  14184. *
  14185. * @param {string} str
  14186. * The text of (subset) HTML to draw.
  14187. *
  14188. * @param {number} x
  14189. * The x position of the text's lower left corner.
  14190. *
  14191. * @param {number} y
  14192. * The y position of the text's lower left corner.
  14193. *
  14194. * @return {Highcharts.HTMLDOMElement}
  14195. */
  14196. HTMLRenderer.prototype.html = function (str, x, y) {
  14197. var wrapper = this.createElement('span'), element = wrapper.element, renderer = wrapper.renderer, isSVG = renderer.isSVG, addSetters = function (gWrapper, style) {
  14198. // These properties are set as attributes on the SVG group, and
  14199. // as identical CSS properties on the div. (#3542)
  14200. ['opacity', 'visibility'].forEach(function (prop) {
  14201. gWrapper[prop + 'Setter'] = function (value, key, elem) {
  14202. var styleObject = gWrapper.div ?
  14203. gWrapper.div.style :
  14204. style;
  14205. SVGElement.prototype[prop + 'Setter']
  14206. .call(this, value, key, elem);
  14207. if (styleObject) {
  14208. styleObject[key] = value;
  14209. }
  14210. };
  14211. });
  14212. gWrapper.addedSetters = true;
  14213. };
  14214. // Text setter
  14215. wrapper.textSetter = function (value) {
  14216. if (value !== this.textStr) {
  14217. delete this.bBox;
  14218. delete this.oldTextWidth;
  14219. AST.setElementHTML(this.element, pick(value, ''));
  14220. this.textStr = value;
  14221. wrapper.doTransform = true;
  14222. }
  14223. };
  14224. // Add setters for the element itself (#4938)
  14225. if (isSVG) { // #4938, only for HTML within SVG
  14226. addSetters(wrapper, wrapper.element.style);
  14227. }
  14228. // Various setters which rely on update transform
  14229. wrapper.xSetter =
  14230. wrapper.ySetter =
  14231. wrapper.alignSetter =
  14232. wrapper.rotationSetter =
  14233. function (value, key) {
  14234. if (key === 'align') {
  14235. // Do not overwrite the SVGElement.align method. Same as VML.
  14236. wrapper.alignValue = wrapper.textAlign = value;
  14237. }
  14238. else {
  14239. wrapper[key] = value;
  14240. }
  14241. wrapper.doTransform = true;
  14242. };
  14243. // Runs at the end of .attr()
  14244. wrapper.afterSetters = function () {
  14245. // Update transform. Do this outside the loop to prevent redundant
  14246. // updating for batch setting of attributes.
  14247. if (this.doTransform) {
  14248. this.htmlUpdateTransform();
  14249. this.doTransform = false;
  14250. }
  14251. };
  14252. // Set the default attributes
  14253. wrapper
  14254. .attr({
  14255. text: str,
  14256. x: Math.round(x),
  14257. y: Math.round(y)
  14258. })
  14259. .css({
  14260. position: 'absolute'
  14261. });
  14262. if (!renderer.styledMode) {
  14263. wrapper.css({
  14264. fontFamily: this.style.fontFamily,
  14265. fontSize: this.style.fontSize
  14266. });
  14267. }
  14268. // Keep the whiteSpace style outside the wrapper.styles collection
  14269. element.style.whiteSpace = 'nowrap';
  14270. // Use the HTML specific .css method
  14271. wrapper.css = wrapper.htmlCss;
  14272. // This is specific for HTML within SVG
  14273. if (isSVG) {
  14274. wrapper.add = function (svgGroupWrapper) {
  14275. var htmlGroup,
  14276. container = renderer.box.parentNode,
  14277. parentGroup,
  14278. parents = [];
  14279. this.parentGroup = svgGroupWrapper;
  14280. // Create a mock group to hold the HTML elements
  14281. if (svgGroupWrapper) {
  14282. htmlGroup = svgGroupWrapper.div;
  14283. if (!htmlGroup) {
  14284. // Read the parent chain into an array and read from top
  14285. // down
  14286. parentGroup = svgGroupWrapper;
  14287. while (parentGroup) {
  14288. parents.push(parentGroup);
  14289. // Move up to the next parent group
  14290. parentGroup = parentGroup.parentGroup;
  14291. }
  14292. // Ensure dynamically updating position when any parent
  14293. // is translated
  14294. parents.reverse().forEach(function (parentGroup) {
  14295. var htmlGroupStyle,
  14296. cls = attr(parentGroup.element, 'class');
  14297. /**
  14298. * Common translate setter for X and Y on the HTML
  14299. * group. Reverted the fix for #6957 du to
  14300. * positioning problems and offline export (#7254,
  14301. * #7280, #7529)
  14302. * @private
  14303. * @param {*} value
  14304. * @param {string} key
  14305. * @return {void}
  14306. */
  14307. function translateSetter(value, key) {
  14308. parentGroup[key] = value;
  14309. if (key === 'translateX') {
  14310. htmlGroupStyle.left = value + 'px';
  14311. }
  14312. else {
  14313. htmlGroupStyle.top = value + 'px';
  14314. }
  14315. parentGroup.doTransform = true;
  14316. }
  14317. // Create a HTML div and append it to the parent div
  14318. // to emulate the SVG group structure
  14319. var parentGroupStyles = parentGroup.styles || {};
  14320. htmlGroup =
  14321. parentGroup.div =
  14322. parentGroup.div || createElement('div', cls ? { className: cls } : void 0, {
  14323. position: 'absolute',
  14324. left: (parentGroup.translateX || 0) + 'px',
  14325. top: (parentGroup.translateY || 0) + 'px',
  14326. display: parentGroup.display,
  14327. opacity: parentGroup.opacity,
  14328. cursor: parentGroupStyles.cursor,
  14329. pointerEvents: parentGroupStyles.pointerEvents // #5595
  14330. // the top group is appended to container
  14331. }, htmlGroup || container);
  14332. // Shortcut
  14333. htmlGroupStyle = htmlGroup.style;
  14334. // Set listeners to update the HTML div's position
  14335. // whenever the SVG group position is changed.
  14336. extend(parentGroup, {
  14337. // (#7287) Pass htmlGroup to use
  14338. // the related group
  14339. classSetter: (function (htmlGroup) {
  14340. return function (value) {
  14341. this.element.setAttribute('class', value);
  14342. htmlGroup.className = value;
  14343. };
  14344. }(htmlGroup)),
  14345. on: function () {
  14346. if (parents[0].div) { // #6418
  14347. wrapper.on.apply({
  14348. element: parents[0].div,
  14349. onEvents: wrapper.onEvents
  14350. }, arguments);
  14351. }
  14352. return parentGroup;
  14353. },
  14354. translateXSetter: translateSetter,
  14355. translateYSetter: translateSetter
  14356. });
  14357. if (!parentGroup.addedSetters) {
  14358. addSetters(parentGroup);
  14359. }
  14360. });
  14361. }
  14362. }
  14363. else {
  14364. htmlGroup = container;
  14365. }
  14366. htmlGroup.appendChild(element);
  14367. // Shared with VML:
  14368. wrapper.added = true;
  14369. if (wrapper.alignOnAdd) {
  14370. wrapper.htmlUpdateTransform();
  14371. }
  14372. return wrapper;
  14373. };
  14374. }
  14375. return wrapper;
  14376. };
  14377. return HTMLRenderer;
  14378. }(SVGRenderer));
  14379. /* *
  14380. *
  14381. * Default Export
  14382. *
  14383. * */
  14384. return HTMLRenderer;
  14385. });
  14386. _registerModule(_modules, 'Core/Axis/AxisDefaults.js', [_modules['Core/Color/Palette.js']], function (Palette) {
  14387. /* *
  14388. *
  14389. * (c) 2010-2021 Torstein Honsi
  14390. *
  14391. * License: www.highcharts.com/license
  14392. *
  14393. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  14394. *
  14395. * */
  14396. /* *
  14397. *
  14398. * Namespace
  14399. *
  14400. * */
  14401. var AxisDefaults;
  14402. (function (AxisDefaults) {
  14403. /* *
  14404. *
  14405. * Constants
  14406. *
  14407. * */
  14408. /**
  14409. * The X axis or category axis. Normally this is the horizontal axis,
  14410. * though if the chart is inverted this is the vertical axis. In case of
  14411. * multiple axes, the xAxis node is an array of configuration objects.
  14412. *
  14413. * See the [Axis class](/class-reference/Highcharts.Axis) for programmatic
  14414. * access to the axis.
  14415. *
  14416. * @productdesc {highmaps}
  14417. * In Highmaps, the axis is hidden, but it is used behind the scenes to
  14418. * control features like zooming and panning. Zooming is in effect the same
  14419. * as setting the extremes of one of the exes.
  14420. *
  14421. * @type {*|Array<*>}
  14422. * @optionparent xAxis
  14423. */
  14424. AxisDefaults.defaultXAxisOptions = {
  14425. /**
  14426. * When using multiple axis, the ticks of two or more opposite axes
  14427. * will automatically be aligned by adding ticks to the axis or axes
  14428. * with the least ticks, as if `tickAmount` were specified.
  14429. *
  14430. * This can be prevented by setting `alignTicks` to false. If the grid
  14431. * lines look messy, it's a good idea to hide them for the secondary
  14432. * axis by setting `gridLineWidth` to 0.
  14433. *
  14434. * If `startOnTick` or `endOnTick` in an Axis options are set to false,
  14435. * then the `alignTicks ` will be disabled for the Axis.
  14436. *
  14437. * Disabled for logarithmic axes.
  14438. *
  14439. * @product highcharts highstock gantt
  14440. */
  14441. alignTicks: true,
  14442. /**
  14443. * Whether to allow decimals in this axis' ticks. When counting
  14444. * integers, like persons or hits on a web page, decimals should
  14445. * be avoided in the labels. By default, decimals are allowed on small
  14446. * scale axes.
  14447. *
  14448. * @see [minTickInterval](#xAxis.minTickInterval)
  14449. *
  14450. * @sample {highcharts|highstock} highcharts/yaxis/allowdecimals-true/
  14451. * True by default
  14452. * @sample {highcharts|highstock} highcharts/yaxis/allowdecimals-false/
  14453. * False
  14454. *
  14455. * @type {boolean|undefined}
  14456. * @default undefined
  14457. * @since 2.0
  14458. */
  14459. allowDecimals: void 0,
  14460. /**
  14461. * When using an alternate grid color, a band is painted across the
  14462. * plot area between every other grid line.
  14463. *
  14464. * @sample {highcharts} highcharts/yaxis/alternategridcolor/
  14465. * Alternate grid color on the Y axis
  14466. * @sample {highstock} stock/xaxis/alternategridcolor/
  14467. * Alternate grid color on the Y axis
  14468. *
  14469. * @type {Highcharts.ColorType}
  14470. * @apioption xAxis.alternateGridColor
  14471. */
  14472. /**
  14473. * An array defining breaks in the axis, the sections defined will be
  14474. * left out and all the points shifted closer to each other.
  14475. *
  14476. * @productdesc {highcharts}
  14477. * Requires that the broken-axis.js module is loaded.
  14478. *
  14479. * @sample {highcharts} highcharts/axisbreak/break-simple/
  14480. * Simple break
  14481. * @sample {highcharts|highstock} highcharts/axisbreak/break-visualized/
  14482. * Advanced with callback
  14483. * @sample {highstock} stock/demo/intraday-breaks/
  14484. * Break on nights and weekends
  14485. *
  14486. * @type {Array<*>}
  14487. * @since 4.1.0
  14488. * @product highcharts highstock gantt
  14489. * @apioption xAxis.breaks
  14490. */
  14491. /**
  14492. * A number indicating how much space should be left between the start
  14493. * and the end of the break. The break size is given in axis units,
  14494. * so for instance on a `datetime` axis, a break size of 3600000 would
  14495. * indicate the equivalent of an hour.
  14496. *
  14497. * @type {number}
  14498. * @default 0
  14499. * @since 4.1.0
  14500. * @product highcharts highstock gantt
  14501. * @apioption xAxis.breaks.breakSize
  14502. */
  14503. /**
  14504. * The point where the break starts.
  14505. *
  14506. * @type {number}
  14507. * @since 4.1.0
  14508. * @product highcharts highstock gantt
  14509. * @apioption xAxis.breaks.from
  14510. */
  14511. /**
  14512. * Defines an interval after which the break appears again. By default
  14513. * the breaks do not repeat.
  14514. *
  14515. * @type {number}
  14516. * @default 0
  14517. * @since 4.1.0
  14518. * @product highcharts highstock gantt
  14519. * @apioption xAxis.breaks.repeat
  14520. */
  14521. /**
  14522. * The point where the break ends.
  14523. *
  14524. * @type {number}
  14525. * @since 4.1.0
  14526. * @product highcharts highstock gantt
  14527. * @apioption xAxis.breaks.to
  14528. */
  14529. /**
  14530. * If categories are present for the xAxis, names are used instead of
  14531. * numbers for that axis.
  14532. *
  14533. * Since Highcharts 3.0, categories can also
  14534. * be extracted by giving each point a [name](#series.data) and setting
  14535. * axis [type](#xAxis.type) to `category`. However, if you have multiple
  14536. * series, best practice remains defining the `categories` array.
  14537. *
  14538. * Example: `categories: ['Apples', 'Bananas', 'Oranges']`
  14539. *
  14540. * @sample {highcharts} highcharts/demo/line-labels/
  14541. * With
  14542. * @sample {highcharts} highcharts/xaxis/categories/
  14543. * Without
  14544. *
  14545. * @type {Array<string>}
  14546. * @product highcharts gantt
  14547. * @apioption xAxis.categories
  14548. */
  14549. /**
  14550. * The highest allowed value for automatically computed axis extremes.
  14551. *
  14552. * @see [floor](#xAxis.floor)
  14553. *
  14554. * @sample {highcharts|highstock} highcharts/yaxis/floor-ceiling/
  14555. * Floor and ceiling
  14556. *
  14557. * @type {number}
  14558. * @since 4.0
  14559. * @product highcharts highstock gantt
  14560. * @apioption xAxis.ceiling
  14561. */
  14562. /**
  14563. * A class name that opens for styling the axis by CSS, especially in
  14564. * Highcharts styled mode. The class name is applied to group elements
  14565. * for the grid, axis elements and labels.
  14566. *
  14567. * @sample {highcharts|highstock|highmaps} highcharts/css/axis/
  14568. * Multiple axes with separate styling
  14569. *
  14570. * @type {string}
  14571. * @since 5.0.0
  14572. * @apioption xAxis.className
  14573. */
  14574. /**
  14575. * Configure a crosshair that follows either the mouse pointer or the
  14576. * hovered point.
  14577. *
  14578. * In styled mode, the crosshairs are styled in the
  14579. * `.highcharts-crosshair`, `.highcharts-crosshair-thin` or
  14580. * `.highcharts-xaxis-category` classes.
  14581. *
  14582. * @productdesc {highstock}
  14583. * In Highcharts stock, by default, the crosshair is enabled on the
  14584. * X axis and disabled on the Y axis.
  14585. *
  14586. * @sample {highcharts} highcharts/xaxis/crosshair-both/
  14587. * Crosshair on both axes
  14588. * @sample {highstock} stock/xaxis/crosshairs-xy/
  14589. * Crosshair on both axes
  14590. * @sample {highmaps} highcharts/xaxis/crosshair-both/
  14591. * Crosshair on both axes
  14592. *
  14593. * @declare Highcharts.AxisCrosshairOptions
  14594. * @type {boolean|*}
  14595. * @default false
  14596. * @since 4.1
  14597. * @apioption xAxis.crosshair
  14598. */
  14599. /**
  14600. * A class name for the crosshair, especially as a hook for styling.
  14601. *
  14602. * @type {string}
  14603. * @since 5.0.0
  14604. * @apioption xAxis.crosshair.className
  14605. */
  14606. /**
  14607. * The color of the crosshair. Defaults to `#cccccc` for numeric and
  14608. * datetime axes, and `rgba(204,214,235,0.25)` for category axes, where
  14609. * the crosshair by default highlights the whole category.
  14610. *
  14611. * @sample {highcharts|highstock|highmaps} highcharts/xaxis/crosshair-customized/
  14612. * Customized crosshairs
  14613. *
  14614. * @type {Highcharts.ColorType}
  14615. * @default #cccccc
  14616. * @since 4.1
  14617. * @apioption xAxis.crosshair.color
  14618. */
  14619. /**
  14620. * The dash style for the crosshair. See
  14621. * [plotOptions.series.dashStyle](#plotOptions.series.dashStyle)
  14622. * for possible values.
  14623. *
  14624. * @sample {highcharts|highmaps} highcharts/xaxis/crosshair-dotted/
  14625. * Dotted crosshair
  14626. * @sample {highstock} stock/xaxis/crosshair-dashed/
  14627. * Dashed X axis crosshair
  14628. *
  14629. * @type {Highcharts.DashStyleValue}
  14630. * @default Solid
  14631. * @since 4.1
  14632. * @apioption xAxis.crosshair.dashStyle
  14633. */
  14634. /**
  14635. * A label on the axis next to the crosshair.
  14636. *
  14637. * In styled mode, the label is styled with the
  14638. * `.highcharts-crosshair-label` class.
  14639. *
  14640. * @sample {highstock} stock/xaxis/crosshair-label/
  14641. * Crosshair labels
  14642. * @sample {highstock} highcharts/css/crosshair-label/
  14643. * Style mode
  14644. *
  14645. * @declare Highcharts.AxisCrosshairLabelOptions
  14646. * @since 2.1
  14647. * @product highstock
  14648. * @apioption xAxis.crosshair.label
  14649. */
  14650. /**
  14651. * Alignment of the label compared to the axis. Defaults to `"left"` for
  14652. * right-side axes, `"right"` for left-side axes and `"center"` for
  14653. * horizontal axes.
  14654. *
  14655. * @type {Highcharts.AlignValue}
  14656. * @since 2.1
  14657. * @product highstock
  14658. * @apioption xAxis.crosshair.label.align
  14659. */
  14660. /**
  14661. * The background color for the label. Defaults to the related series
  14662. * color, or `#666666` if that is not available.
  14663. *
  14664. * @type {Highcharts.ColorType}
  14665. * @since 2.1
  14666. * @product highstock
  14667. * @apioption xAxis.crosshair.label.backgroundColor
  14668. */
  14669. /**
  14670. * The border color for the crosshair label
  14671. *
  14672. * @type {Highcharts.ColorType}
  14673. * @since 2.1
  14674. * @product highstock
  14675. * @apioption xAxis.crosshair.label.borderColor
  14676. */
  14677. /**
  14678. * The border corner radius of the crosshair label.
  14679. *
  14680. * @type {number}
  14681. * @default 3
  14682. * @since 2.1.10
  14683. * @product highstock
  14684. * @apioption xAxis.crosshair.label.borderRadius
  14685. */
  14686. /**
  14687. * The border width for the crosshair label.
  14688. *
  14689. * @type {number}
  14690. * @default 0
  14691. * @since 2.1
  14692. * @product highstock
  14693. * @apioption xAxis.crosshair.label.borderWidth
  14694. */
  14695. /**
  14696. * Flag to enable crosshair's label.
  14697. *
  14698. * @sample {highstock} stock/xaxis/crosshairs-xy/
  14699. * Enabled label for yAxis' crosshair
  14700. *
  14701. * @type {boolean}
  14702. * @default false
  14703. * @since 2.1
  14704. * @product highstock
  14705. * @apioption xAxis.crosshair.label.enabled
  14706. */
  14707. /**
  14708. * A format string for the crosshair label. Defaults to `{value}` for
  14709. * numeric axes and `{value:%b %d, %Y}` for datetime axes.
  14710. *
  14711. * @type {string}
  14712. * @since 2.1
  14713. * @product highstock
  14714. * @apioption xAxis.crosshair.label.format
  14715. */
  14716. /**
  14717. * Formatter function for the label text.
  14718. *
  14719. * @type {Highcharts.XAxisCrosshairLabelFormatterCallbackFunction}
  14720. * @since 2.1
  14721. * @product highstock
  14722. * @apioption xAxis.crosshair.label.formatter
  14723. */
  14724. /**
  14725. * Padding inside the crosshair label.
  14726. *
  14727. * @type {number}
  14728. * @default 8
  14729. * @since 2.1
  14730. * @product highstock
  14731. * @apioption xAxis.crosshair.label.padding
  14732. */
  14733. /**
  14734. * The shape to use for the label box.
  14735. *
  14736. * @type {string}
  14737. * @default callout
  14738. * @since 2.1
  14739. * @product highstock
  14740. * @apioption xAxis.crosshair.label.shape
  14741. */
  14742. /**
  14743. * Text styles for the crosshair label.
  14744. *
  14745. * @type {Highcharts.CSSObject}
  14746. * @default {"color": "white", "fontWeight": "normal", "fontSize": "11px", "textAlign": "center"}
  14747. * @since 2.1
  14748. * @product highstock
  14749. * @apioption xAxis.crosshair.label.style
  14750. */
  14751. /**
  14752. * Whether the crosshair should snap to the point or follow the pointer
  14753. * independent of points.
  14754. *
  14755. * @sample {highcharts|highstock} highcharts/xaxis/crosshair-snap-false/
  14756. * True by default
  14757. * @sample {highmaps} maps/demo/latlon-advanced/
  14758. * Snap is false
  14759. *
  14760. * @type {boolean}
  14761. * @default true
  14762. * @since 4.1
  14763. * @apioption xAxis.crosshair.snap
  14764. */
  14765. /**
  14766. * The pixel width of the crosshair. Defaults to 1 for numeric or
  14767. * datetime axes, and for one category width for category axes.
  14768. *
  14769. * @sample {highcharts} highcharts/xaxis/crosshair-customized/
  14770. * Customized crosshairs
  14771. * @sample {highstock} highcharts/xaxis/crosshair-customized/
  14772. * Customized crosshairs
  14773. * @sample {highmaps} highcharts/xaxis/crosshair-customized/
  14774. * Customized crosshairs
  14775. *
  14776. * @type {number}
  14777. * @default 1
  14778. * @since 4.1
  14779. * @apioption xAxis.crosshair.width
  14780. */
  14781. /**
  14782. * The Z index of the crosshair. Higher Z indices allow drawing the
  14783. * crosshair on top of the series or behind the grid lines.
  14784. *
  14785. * @type {number}
  14786. * @default 2
  14787. * @since 4.1
  14788. * @apioption xAxis.crosshair.zIndex
  14789. */
  14790. /**
  14791. * Whether to pan axis. If `chart.panning` is enabled, the option
  14792. * allows to disable panning on an individual axis.
  14793. */
  14794. panningEnabled: true,
  14795. /**
  14796. * The Z index for the axis group.
  14797. */
  14798. zIndex: 2,
  14799. /**
  14800. * Whether to zoom axis. If `chart.zoomType` is set, the option allows
  14801. * to disable zooming on an individual axis.
  14802. *
  14803. * @sample {highcharts} highcharts/xaxis/zoomenabled/
  14804. * Zoom enabled is false
  14805. */
  14806. zoomEnabled: true,
  14807. /**
  14808. * For a datetime axis, the scale will automatically adjust to the
  14809. * appropriate unit. This member gives the default string
  14810. * representations used for each unit. For intermediate values,
  14811. * different units may be used, for example the `day` unit can be used
  14812. * on midnight and `hour` unit be used for intermediate values on the
  14813. * same axis.
  14814. *
  14815. * For an overview of the replacement codes, see
  14816. * [dateFormat](/class-reference/Highcharts#.dateFormat).
  14817. *
  14818. * Defaults to:
  14819. * ```js
  14820. * {
  14821. * millisecond: '%H:%M:%S.%L',
  14822. * second: '%H:%M:%S',
  14823. * minute: '%H:%M',
  14824. * hour: '%H:%M',
  14825. * day: '%e. %b',
  14826. * week: '%e. %b',
  14827. * month: '%b \'%y',
  14828. * year: '%Y'
  14829. * }
  14830. * ```
  14831. *
  14832. * @sample {highcharts} highcharts/xaxis/datetimelabelformats/
  14833. * Different day format on X axis
  14834. * @sample {highstock} stock/xaxis/datetimelabelformats/
  14835. * More information in x axis labels
  14836. *
  14837. * @declare Highcharts.AxisDateTimeLabelFormatsOptions
  14838. * @product highcharts highstock gantt
  14839. */
  14840. dateTimeLabelFormats: {
  14841. /**
  14842. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  14843. * @type {string|*}
  14844. */
  14845. millisecond: {
  14846. main: '%H:%M:%S.%L',
  14847. range: false
  14848. },
  14849. /**
  14850. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  14851. * @type {string|*}
  14852. */
  14853. second: {
  14854. main: '%H:%M:%S',
  14855. range: false
  14856. },
  14857. /**
  14858. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  14859. * @type {string|*}
  14860. */
  14861. minute: {
  14862. main: '%H:%M',
  14863. range: false
  14864. },
  14865. /**
  14866. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  14867. * @type {string|*}
  14868. */
  14869. hour: {
  14870. main: '%H:%M',
  14871. range: false
  14872. },
  14873. /**
  14874. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  14875. * @type {string|*}
  14876. */
  14877. day: {
  14878. main: '%e. %b'
  14879. },
  14880. /**
  14881. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  14882. * @type {string|*}
  14883. */
  14884. week: {
  14885. main: '%e. %b'
  14886. },
  14887. /**
  14888. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  14889. * @type {string|*}
  14890. */
  14891. month: {
  14892. main: '%b \'%y'
  14893. },
  14894. /**
  14895. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  14896. * @type {string|*}
  14897. */
  14898. year: {
  14899. main: '%Y'
  14900. }
  14901. },
  14902. /**
  14903. * Whether to force the axis to end on a tick. Use this option with
  14904. * the `maxPadding` option to control the axis end.
  14905. *
  14906. * @productdesc {highstock}
  14907. * In Highcharts Stock, `endOnTick` is always `false` when the navigator
  14908. * is enabled, to prevent jumpy scrolling.
  14909. *
  14910. * @sample {highcharts} highcharts/chart/reflow-true/
  14911. * True by default
  14912. * @sample {highcharts} highcharts/yaxis/endontick/
  14913. * False
  14914. * @sample {highstock} stock/demo/basic-line/
  14915. * True by default
  14916. * @sample {highstock} stock/xaxis/endontick/
  14917. * False
  14918. *
  14919. * @since 1.2.0
  14920. */
  14921. endOnTick: false,
  14922. /**
  14923. * Event handlers for the axis.
  14924. *
  14925. * @type {*}
  14926. * @apioption xAxis.events
  14927. */
  14928. /**
  14929. * An event fired after the breaks have rendered.
  14930. *
  14931. * @see [breaks](#xAxis.breaks)
  14932. *
  14933. * @sample {highcharts} highcharts/axisbreak/break-event/
  14934. * AfterBreak Event
  14935. *
  14936. * @type {Highcharts.AxisEventCallbackFunction}
  14937. * @since 4.1.0
  14938. * @product highcharts gantt
  14939. * @apioption xAxis.events.afterBreaks
  14940. */
  14941. /**
  14942. * As opposed to the `setExtremes` event, this event fires after the
  14943. * final min and max values are computed and corrected for `minRange`.
  14944. *
  14945. * Fires when the minimum and maximum is set for the axis, either by
  14946. * calling the `.setExtremes()` method or by selecting an area in the
  14947. * chart. One parameter, `event`, is passed to the function, containing
  14948. * common event information.
  14949. *
  14950. * The new user set minimum and maximum values can be found by
  14951. * `event.min` and `event.max`. These reflect the axis minimum and
  14952. * maximum in axis values. The actual data extremes are found in
  14953. * `event.dataMin` and `event.dataMax`.
  14954. *
  14955. * @type {Highcharts.AxisSetExtremesEventCallbackFunction}
  14956. * @since 2.3
  14957. * @context Highcharts.Axis
  14958. * @apioption xAxis.events.afterSetExtremes
  14959. */
  14960. /**
  14961. * An event fired when a break from this axis occurs on a point.
  14962. *
  14963. * @see [breaks](#xAxis.breaks)
  14964. *
  14965. * @sample {highcharts} highcharts/axisbreak/break-visualized/
  14966. * Visualization of a Break
  14967. *
  14968. * @type {Highcharts.AxisPointBreakEventCallbackFunction}
  14969. * @since 4.1.0
  14970. * @product highcharts gantt
  14971. * @context Highcharts.Axis
  14972. * @apioption xAxis.events.pointBreak
  14973. */
  14974. /**
  14975. * An event fired when a point falls inside a break from this axis.
  14976. *
  14977. * @type {Highcharts.AxisPointBreakEventCallbackFunction}
  14978. * @product highcharts highstock gantt
  14979. * @context Highcharts.Axis
  14980. * @apioption xAxis.events.pointInBreak
  14981. */
  14982. /**
  14983. * Fires when the minimum and maximum is set for the axis, either by
  14984. * calling the `.setExtremes()` method or by selecting an area in the
  14985. * chart. One parameter, `event`, is passed to the function,
  14986. * containing common event information.
  14987. *
  14988. * The new user set minimum and maximum values can be found by
  14989. * `event.min` and `event.max`. These reflect the axis minimum and
  14990. * maximum in data values. When an axis is zoomed all the way out from
  14991. * the "Reset zoom" button, `event.min` and `event.max` are null, and
  14992. * the new extremes are set based on `this.dataMin` and `this.dataMax`.
  14993. *
  14994. * @sample {highstock} stock/xaxis/events-setextremes/
  14995. * Log new extremes on x axis
  14996. *
  14997. * @type {Highcharts.AxisSetExtremesEventCallbackFunction}
  14998. * @since 1.2.0
  14999. * @context Highcharts.Axis
  15000. * @apioption xAxis.events.setExtremes
  15001. */
  15002. /**
  15003. * The lowest allowed value for automatically computed axis extremes.
  15004. *
  15005. * @see [ceiling](#yAxis.ceiling)
  15006. *
  15007. * @sample {highcharts} highcharts/yaxis/floor-ceiling/
  15008. * Floor and ceiling
  15009. * @sample {highstock} stock/demo/lazy-loading/
  15010. * Prevent negative stock price on Y axis
  15011. *
  15012. * @type {number}
  15013. * @since 4.0
  15014. * @product highcharts highstock gantt
  15015. * @apioption xAxis.floor
  15016. */
  15017. /**
  15018. * The dash or dot style of the grid lines. For possible values, see
  15019. * [this demonstration](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-dashstyle-all/).
  15020. *
  15021. * @sample {highcharts} highcharts/yaxis/gridlinedashstyle/
  15022. * Long dashes
  15023. * @sample {highstock} stock/xaxis/gridlinedashstyle/
  15024. * Long dashes
  15025. *
  15026. * @type {Highcharts.DashStyleValue}
  15027. * @since 1.2
  15028. */
  15029. gridLineDashStyle: 'Solid',
  15030. /**
  15031. * The Z index of the grid lines.
  15032. *
  15033. * @sample {highcharts|highstock} highcharts/xaxis/gridzindex/
  15034. * A Z index of 4 renders the grid above the graph
  15035. *
  15036. * @product highcharts highstock gantt
  15037. */
  15038. gridZIndex: 1,
  15039. /**
  15040. * An id for the axis. This can be used after render time to get
  15041. * a pointer to the axis object through `chart.get()`.
  15042. *
  15043. * @sample {highcharts} highcharts/xaxis/id/
  15044. * Get the object
  15045. * @sample {highstock} stock/xaxis/id/
  15046. * Get the object
  15047. *
  15048. * @type {string}
  15049. * @since 1.2.0
  15050. * @apioption xAxis.id
  15051. */
  15052. /**
  15053. * The axis labels show the number or category for each tick.
  15054. *
  15055. * Since v8.0.0: Labels are animated in categorized x-axis with
  15056. * updating data if `tickInterval` and `step` is set to 1.
  15057. *
  15058. * @productdesc {highmaps}
  15059. * X and Y axis labels are by default disabled in Highmaps, but the
  15060. * functionality is inherited from Highcharts and used on `colorAxis`,
  15061. * and can be enabled on X and Y axes too.
  15062. */
  15063. labels: {
  15064. /**
  15065. * What part of the string the given position is anchored to.
  15066. * If `left`, the left side of the string is at the axis position.
  15067. * Can be one of `"left"`, `"center"` or `"right"`. Defaults to
  15068. * an intelligent guess based on which side of the chart the axis
  15069. * is on and the rotation of the label.
  15070. *
  15071. * @see [reserveSpace](#xAxis.labels.reserveSpace)
  15072. *
  15073. * @sample {highcharts} highcharts/xaxis/labels-align-left/
  15074. * Left
  15075. * @sample {highcharts} highcharts/xaxis/labels-align-right/
  15076. * Right
  15077. * @sample {highcharts} highcharts/xaxis/labels-reservespace-true/
  15078. * Left-aligned labels on a vertical category axis
  15079. *
  15080. * @type {Highcharts.AlignValue}
  15081. * @apioption xAxis.labels.align
  15082. */
  15083. /**
  15084. * Whether to allow the axis labels to overlap.
  15085. * When false, overlapping labels are hidden.
  15086. *
  15087. * @sample {highcharts} highcharts/xaxis/labels-allowoverlap-true/
  15088. * X axis labels overlap enabled
  15089. *
  15090. * @type {boolean}
  15091. * @default false
  15092. * @apioption xAxis.labels.allowOverlap
  15093. *
  15094. */
  15095. /**
  15096. * For horizontal axes, the allowed degrees of label rotation
  15097. * to prevent overlapping labels. If there is enough space,
  15098. * labels are not rotated. As the chart gets narrower, it
  15099. * will start rotating the labels -45 degrees, then remove
  15100. * every second label and try again with rotations 0 and -45 etc.
  15101. * Set it to `undefined` to disable rotation, which will
  15102. * cause the labels to word-wrap if possible. Defaults to `[-45]``
  15103. * on bottom and top axes, `undefined` on left and right axes.
  15104. *
  15105. * @sample {highcharts|highstock} highcharts/xaxis/labels-autorotation-default/
  15106. * Default auto rotation of 0 or -45
  15107. * @sample {highcharts|highstock} highcharts/xaxis/labels-autorotation-0-90/
  15108. * Custom graded auto rotation
  15109. *
  15110. * @type {Array<number>}
  15111. * @default undefined
  15112. * @since 4.1.0
  15113. * @product highcharts highstock gantt
  15114. * @apioption xAxis.labels.autoRotation
  15115. */
  15116. autoRotation: void 0,
  15117. /**
  15118. * When each category width is more than this many pixels, we don't
  15119. * apply auto rotation. Instead, we lay out the axis label with word
  15120. * wrap. A lower limit makes sense when the label contains multiple
  15121. * short words that don't extend the available horizontal space for
  15122. * each label.
  15123. *
  15124. * @sample {highcharts} highcharts/xaxis/labels-autorotationlimit/
  15125. * Lower limit
  15126. *
  15127. * @since 4.1.5
  15128. * @product highcharts gantt
  15129. */
  15130. autoRotationLimit: 80,
  15131. /**
  15132. * Polar charts only. The label's pixel distance from the perimeter
  15133. * of the plot area.
  15134. *
  15135. * @type {number}
  15136. * @default undefined
  15137. * @product highcharts gantt
  15138. */
  15139. distance: void 0,
  15140. /**
  15141. * Enable or disable the axis labels.
  15142. *
  15143. * @sample {highcharts} highcharts/xaxis/labels-enabled/
  15144. * X axis labels disabled
  15145. * @sample {highstock} stock/xaxis/labels-enabled/
  15146. * X axis labels disabled
  15147. *
  15148. * @default {highcharts|highstock|gantt} true
  15149. * @default {highmaps} false
  15150. */
  15151. enabled: true,
  15152. /**
  15153. * A format string for the axis label. The context is available as
  15154. * format string variables. For example, you can use `{text}` to
  15155. * insert the default formatted text. The recommended way of adding
  15156. * units for the label is using `text`, for example `{text} km`.
  15157. *
  15158. * To add custom numeric or datetime formatting, use `{value}` with
  15159. * formatting, for example `{value:.1f}` or `{value:%Y-%m-%d}`.
  15160. *
  15161. * See
  15162. * [format string](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting)
  15163. * for more examples of formatting.
  15164. *
  15165. * The default value is not specified due to the dynamic
  15166. * nature of the default implementation.
  15167. *
  15168. * @sample {highcharts|highstock} highcharts/yaxis/labels-format/
  15169. * Add units to Y axis label
  15170. * @sample {highcharts} highcharts/xaxis/labels-format-linked/
  15171. * Linked category names
  15172. * @sample {highcharts} highcharts/xaxis/labels-format-custom/
  15173. * Custom number format
  15174. *
  15175. * @type {string}
  15176. * @since 3.0
  15177. * @apioption xAxis.labels.format
  15178. */
  15179. /**
  15180. * Callback JavaScript function to format the label. The value
  15181. * is given by `this.value`. Additional properties for `this` are
  15182. * `axis`, `chart`, `isFirst`, `isLast` and `text` which holds the
  15183. * value of the default formatter.
  15184. *
  15185. * Defaults to a built in function returning a formatted string
  15186. * depending on whether the axis is `category`, `datetime`,
  15187. * `numeric` or other.
  15188. *
  15189. * @sample {highcharts} highcharts/xaxis/labels-formatter-linked/
  15190. * Linked category names
  15191. * @sample {highcharts} highcharts/xaxis/labels-formatter-extended/
  15192. * Modified numeric labels
  15193. * @sample {highstock} stock/xaxis/labels-formatter/
  15194. * Added units on Y axis
  15195. *
  15196. * @type {Highcharts.AxisLabelsFormatterCallbackFunction}
  15197. * @apioption xAxis.labels.formatter
  15198. */
  15199. /**
  15200. * The number of pixels to indent the labels per level in a treegrid
  15201. * axis.
  15202. *
  15203. * @sample gantt/treegrid-axis/demo
  15204. * Indentation 10px by default.
  15205. * @sample gantt/treegrid-axis/indentation-0px
  15206. * Indentation set to 0px.
  15207. *
  15208. * @product gantt
  15209. */
  15210. indentation: 10,
  15211. /**
  15212. * Horizontal axis only. When `staggerLines` is not set,
  15213. * `maxStaggerLines` defines how many lines the axis is allowed to
  15214. * add to automatically avoid overlapping X labels. Set to `1` to
  15215. * disable overlap detection.
  15216. *
  15217. * @deprecated
  15218. * @type {number}
  15219. * @default 5
  15220. * @since 1.3.3
  15221. * @apioption xAxis.labels.maxStaggerLines
  15222. */
  15223. /**
  15224. * How to handle overflowing labels on horizontal axis. If set to
  15225. * `"allow"`, it will not be aligned at all. By default it
  15226. * `"justify"` labels inside the chart area. If there is room to
  15227. * move it, it will be aligned to the edge, else it will be removed.
  15228. *
  15229. * @since 2.2.5
  15230. * @validvalue ["allow", "justify"]
  15231. */
  15232. overflow: 'justify',
  15233. /**
  15234. * The pixel padding for axis labels, to ensure white space between
  15235. * them.
  15236. *
  15237. * @product highcharts gantt
  15238. */
  15239. padding: 5,
  15240. /**
  15241. * Whether to reserve space for the labels. By default, space is
  15242. * reserved for the labels in these cases:
  15243. *
  15244. * * On all horizontal axes.
  15245. * * On vertical axes if `label.align` is `right` on a left-side
  15246. * axis or `left` on a right-side axis.
  15247. * * On vertical axes if `label.align` is `center`.
  15248. *
  15249. * This can be turned off when for example the labels are rendered
  15250. * inside the plot area instead of outside.
  15251. *
  15252. * @see [labels.align](#xAxis.labels.align)
  15253. *
  15254. * @sample {highcharts} highcharts/xaxis/labels-reservespace/
  15255. * No reserved space, labels inside plot
  15256. * @sample {highcharts} highcharts/xaxis/labels-reservespace-true/
  15257. * Left-aligned labels on a vertical category axis
  15258. *
  15259. * @type {boolean}
  15260. * @since 4.1.10
  15261. * @product highcharts gantt
  15262. * @apioption xAxis.labels.reserveSpace
  15263. */
  15264. reserveSpace: void 0,
  15265. /**
  15266. * Rotation of the labels in degrees. When `undefined`, the
  15267. * `autoRotation` option takes precedence.
  15268. *
  15269. * @sample {highcharts} highcharts/xaxis/labels-rotation/
  15270. * X axis labels rotated 90°
  15271. *
  15272. * @type {number}
  15273. * @default 0
  15274. * @apioption xAxis.labels.rotation
  15275. */
  15276. rotation: void 0,
  15277. /**
  15278. * Horizontal axes only. The number of lines to spread the labels
  15279. * over to make room or tighter labels. 0 disables staggering.
  15280. *
  15281. * @sample {highcharts} highcharts/xaxis/labels-staggerlines/
  15282. * Show labels over two lines
  15283. * @sample {highstock} stock/xaxis/labels-staggerlines/
  15284. * Show labels over two lines
  15285. *
  15286. * @since 2.1
  15287. * @apioption xAxis.labels.staggerLines
  15288. */
  15289. staggerLines: 0,
  15290. /**
  15291. * To show only every _n_'th label on the axis, set the step to _n_.
  15292. * Setting the step to 2 shows every other label.
  15293. *
  15294. * By default, when 0, the step is calculated automatically to avoid
  15295. * overlap. To prevent this, set it to 1\. This usually only
  15296. * happens on a category axis, and is often a sign that you have
  15297. * chosen the wrong axis type.
  15298. *
  15299. * Read more at
  15300. * [Axis docs](https://www.highcharts.com/docs/chart-concepts/axes)
  15301. * => What axis should I use?
  15302. *
  15303. * @sample {highcharts} highcharts/xaxis/labels-step/
  15304. * Showing only every other axis label on a categorized
  15305. * x-axis
  15306. * @sample {highcharts} highcharts/xaxis/labels-step-auto/
  15307. * Auto steps on a category axis
  15308. *
  15309. * @since 2.1
  15310. */
  15311. step: 0,
  15312. /**
  15313. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  15314. * to render the labels.
  15315. */
  15316. useHTML: false,
  15317. /**
  15318. * The x position offset of all labels relative to the tick
  15319. * positions on the axis.
  15320. *
  15321. * @sample {highcharts} highcharts/xaxis/labels-x/
  15322. * Y axis labels placed on grid lines
  15323. */
  15324. x: 0,
  15325. /**
  15326. * The y position offset of all labels relative to the tick
  15327. * positions on the axis. The default makes it adapt to the font
  15328. * size of the bottom axis.
  15329. *
  15330. * @sample {highcharts} highcharts/xaxis/labels-x/
  15331. * Y axis labels placed on grid lines
  15332. *
  15333. * @type {number}
  15334. * @apioption xAxis.labels.y
  15335. */
  15336. /**
  15337. * The Z index for the axis labels.
  15338. */
  15339. zIndex: 7,
  15340. /**
  15341. * CSS styles for the label. Use `whiteSpace: 'nowrap'` to prevent
  15342. * wrapping of category labels. Use `textOverflow: 'none'` to
  15343. * prevent ellipsis (dots).
  15344. *
  15345. * In styled mode, the labels are styled with the
  15346. * `.highcharts-axis-labels` class.
  15347. *
  15348. * @sample {highcharts} highcharts/xaxis/labels-style/
  15349. * Red X axis labels
  15350. *
  15351. * @type {Highcharts.CSSObject}
  15352. */
  15353. style: {
  15354. /** @internal */
  15355. color: Palette.neutralColor60,
  15356. /** @internal */
  15357. cursor: 'default',
  15358. /** @internal */
  15359. fontSize: '11px'
  15360. }
  15361. },
  15362. /**
  15363. * The left position as the horizontal axis. If it's a number, it is
  15364. * interpreted as pixel position relative to the chart.
  15365. *
  15366. * Since Highcharts v5.0.13: If it's a percentage string, it is
  15367. * interpreted as percentages of the plot width, offset from plot area
  15368. * left.
  15369. *
  15370. * @type {number|string}
  15371. * @product highcharts highstock
  15372. * @apioption xAxis.left
  15373. */
  15374. /**
  15375. * The top position as the vertical axis. If it's a number, it is
  15376. * interpreted as pixel position relative to the chart.
  15377. *
  15378. * Since Highcharts 2: If it's a percentage string, it is interpreted
  15379. * as percentages of the plot height, offset from plot area top.
  15380. *
  15381. * @type {number|string}
  15382. * @product highcharts highstock
  15383. * @apioption xAxis.top
  15384. */
  15385. /**
  15386. * Index of another axis that this axis is linked to. When an axis is
  15387. * linked to a master axis, it will take the same extremes as
  15388. * the master, but as assigned by min or max or by setExtremes.
  15389. * It can be used to show additional info, or to ease reading the
  15390. * chart by duplicating the scales.
  15391. *
  15392. * @sample {highcharts} highcharts/xaxis/linkedto/
  15393. * Different string formats of the same date
  15394. * @sample {highcharts} highcharts/yaxis/linkedto/
  15395. * Y values on both sides
  15396. *
  15397. * @type {number}
  15398. * @since 2.0.2
  15399. * @product highcharts highstock gantt
  15400. * @apioption xAxis.linkedTo
  15401. */
  15402. /**
  15403. * The maximum value of the axis. If `null`, the max value is
  15404. * automatically calculated.
  15405. *
  15406. * If the [endOnTick](#yAxis.endOnTick) option is true, the `max` value
  15407. * might be rounded up.
  15408. *
  15409. * If a [tickAmount](#yAxis.tickAmount) is set, the axis may be extended
  15410. * beyond the set max in order to reach the given number of ticks. The
  15411. * same may happen in a chart with multiple axes, determined by [chart.
  15412. * alignTicks](#chart), where a `tickAmount` is applied internally.
  15413. *
  15414. * @sample {highcharts} highcharts/yaxis/max-200/
  15415. * Y axis max of 200
  15416. * @sample {highcharts} highcharts/yaxis/max-logarithmic/
  15417. * Y axis max on logarithmic axis
  15418. * @sample {highstock} stock/xaxis/min-max/
  15419. * Fixed min and max on X axis
  15420. * @sample {highmaps} maps/axis/min-max/
  15421. * Pre-zoomed to a specific area
  15422. *
  15423. * @type {number|null}
  15424. * @apioption xAxis.max
  15425. */
  15426. /**
  15427. * Padding of the max value relative to the length of the axis. A
  15428. * padding of 0.05 will make a 100px axis 5px longer. This is useful
  15429. * when you don't want the highest data value to appear on the edge
  15430. * of the plot area. When the axis' `max` option is set or a max extreme
  15431. * is set using `axis.setExtremes()`, the maxPadding will be ignored.
  15432. *
  15433. * @productdesc {highstock}
  15434. * For an [ordinal](#xAxis.ordinal) axis, `minPadding` and `maxPadding`
  15435. * are ignored. Use [overscroll](#xAxis.overscroll) instead.
  15436. *
  15437. * @sample {highcharts} highcharts/yaxis/maxpadding/
  15438. * Max padding of 0.25 on y axis
  15439. * @sample {highstock} stock/xaxis/minpadding-maxpadding/
  15440. * Greater min- and maxPadding
  15441. * @sample {highmaps} maps/chart/plotbackgroundcolor-gradient/
  15442. * Add some padding
  15443. *
  15444. * @default {highcharts} 0.01
  15445. * @default {highstock|highmaps} 0
  15446. * @since 1.2.0
  15447. */
  15448. maxPadding: 0.01,
  15449. /**
  15450. * Deprecated. Use `minRange` instead.
  15451. *
  15452. * @deprecated
  15453. * @type {number}
  15454. * @product highcharts highstock
  15455. * @apioption xAxis.maxZoom
  15456. */
  15457. /**
  15458. * The minimum value of the axis. If `null` the min value is
  15459. * automatically calculated.
  15460. *
  15461. * If the [startOnTick](#yAxis.startOnTick) option is true (default),
  15462. * the `min` value might be rounded down.
  15463. *
  15464. * The automatically calculated minimum value is also affected by
  15465. * [floor](#yAxis.floor), [softMin](#yAxis.softMin),
  15466. * [minPadding](#yAxis.minPadding), [minRange](#yAxis.minRange)
  15467. * as well as [series.threshold](#plotOptions.series.threshold)
  15468. * and [series.softThreshold](#plotOptions.series.softThreshold).
  15469. *
  15470. * @sample {highcharts} highcharts/yaxis/min-startontick-false/
  15471. * -50 with startOnTick to false
  15472. * @sample {highcharts} highcharts/yaxis/min-startontick-true/
  15473. * -50 with startOnTick true by default
  15474. * @sample {highstock} stock/xaxis/min-max/
  15475. * Set min and max on X axis
  15476. * @sample {highmaps} maps/axis/min-max/
  15477. * Pre-zoomed to a specific area
  15478. *
  15479. * @type {number|null}
  15480. * @apioption xAxis.min
  15481. */
  15482. /**
  15483. * The dash or dot style of the minor grid lines. For possible values,
  15484. * see [this demonstration](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-dashstyle-all/).
  15485. *
  15486. * @sample {highcharts} highcharts/yaxis/minorgridlinedashstyle/
  15487. * Long dashes on minor grid lines
  15488. * @sample {highstock} stock/xaxis/minorgridlinedashstyle/
  15489. * Long dashes on minor grid lines
  15490. *
  15491. * @type {Highcharts.DashStyleValue}
  15492. * @since 1.2
  15493. */
  15494. minorGridLineDashStyle: 'Solid',
  15495. /**
  15496. * Specific tick interval in axis units for the minor ticks. On a linear
  15497. * axis, if `"auto"`, the minor tick interval is calculated as a fifth
  15498. * of the tickInterval. If `null` or `undefined`, minor ticks are not
  15499. * shown.
  15500. *
  15501. * On logarithmic axes, the unit is the power of the value. For example,
  15502. * setting the minorTickInterval to 1 puts one tick on each of 0.1, 1,
  15503. * 10, 100 etc. Setting the minorTickInterval to 0.1 produces 9 ticks
  15504. * between 1 and 10, 10 and 100 etc.
  15505. *
  15506. * If user settings dictate minor ticks to become too dense, they don't
  15507. * make sense, and will be ignored to prevent performance problems.
  15508. *
  15509. * @sample {highcharts} highcharts/yaxis/minortickinterval-null/
  15510. * Null by default
  15511. * @sample {highcharts} highcharts/yaxis/minortickinterval-5/
  15512. * 5 units
  15513. * @sample {highcharts} highcharts/yaxis/minortickinterval-log-auto/
  15514. * "auto"
  15515. * @sample {highcharts} highcharts/yaxis/minortickinterval-log/
  15516. * 0.1
  15517. * @sample {highstock} stock/demo/basic-line/
  15518. * Null by default
  15519. * @sample {highstock} stock/xaxis/minortickinterval-auto/
  15520. * "auto"
  15521. *
  15522. * @type {number|string|null}
  15523. * @apioption xAxis.minorTickInterval
  15524. */
  15525. /**
  15526. * The pixel length of the minor tick marks.
  15527. *
  15528. * @sample {highcharts} highcharts/yaxis/minorticklength/
  15529. * 10px on Y axis
  15530. * @sample {highstock} stock/xaxis/minorticks/
  15531. * 10px on Y axis
  15532. */
  15533. minorTickLength: 2,
  15534. /**
  15535. * The position of the minor tick marks relative to the axis line.
  15536. * Can be one of `inside` and `outside`.
  15537. *
  15538. * @sample {highcharts} highcharts/yaxis/minortickposition-outside/
  15539. * Outside by default
  15540. * @sample {highcharts} highcharts/yaxis/minortickposition-inside/
  15541. * Inside
  15542. * @sample {highstock} stock/xaxis/minorticks/
  15543. * Inside
  15544. *
  15545. * @validvalue ["inside", "outside"]
  15546. */
  15547. minorTickPosition: 'outside',
  15548. /**
  15549. * Enable or disable minor ticks. Unless
  15550. * [minorTickInterval](#xAxis.minorTickInterval) is set, the tick
  15551. * interval is calculated as a fifth of the `tickInterval`.
  15552. *
  15553. * On a logarithmic axis, minor ticks are laid out based on a best
  15554. * guess, attempting to enter approximately 5 minor ticks between
  15555. * each major tick.
  15556. *
  15557. * Prior to v6.0.0, ticks were unabled in auto layout by setting
  15558. * `minorTickInterval` to `"auto"`.
  15559. *
  15560. * @productdesc {highcharts}
  15561. * On axes using [categories](#xAxis.categories), minor ticks are not
  15562. * supported.
  15563. *
  15564. * @sample {highcharts} highcharts/yaxis/minorticks-true/
  15565. * Enabled on linear Y axis
  15566. *
  15567. * @type {boolean}
  15568. * @default false
  15569. * @since 6.0.0
  15570. * @apioption xAxis.minorTicks
  15571. */
  15572. /**
  15573. * The pixel width of the minor tick mark.
  15574. *
  15575. * @sample {highcharts} highcharts/yaxis/minortickwidth/
  15576. * 3px width
  15577. * @sample {highstock} stock/xaxis/minorticks/
  15578. * 1px width
  15579. *
  15580. * @type {number}
  15581. * @default 0
  15582. * @apioption xAxis.minorTickWidth
  15583. */
  15584. /**
  15585. * Padding of the min value relative to the length of the axis. A
  15586. * padding of 0.05 will make a 100px axis 5px longer. This is useful
  15587. * when you don't want the lowest data value to appear on the edge
  15588. * of the plot area. When the axis' `min` option is set or a min extreme
  15589. * is set using `axis.setExtremes()`, the minPadding will be ignored.
  15590. *
  15591. * @productdesc {highstock}
  15592. * For an [ordinal](#xAxis.ordinal) axis, `minPadding` and `maxPadding`
  15593. * are ignored. Use [overscroll](#xAxis.overscroll) instead.
  15594. *
  15595. * @sample {highcharts} highcharts/yaxis/minpadding/
  15596. * Min padding of 0.2
  15597. * @sample {highstock} stock/xaxis/minpadding-maxpadding/
  15598. * Greater min- and maxPadding
  15599. * @sample {highmaps} maps/chart/plotbackgroundcolor-gradient/
  15600. * Add some padding
  15601. *
  15602. * @default {highcharts} 0.01
  15603. * @default {highstock|highmaps} 0
  15604. * @since 1.2.0
  15605. * @product highcharts highstock gantt
  15606. */
  15607. minPadding: 0.01,
  15608. /**
  15609. * The minimum range to display on this axis. The entire axis will not
  15610. * be allowed to span over a smaller interval than this. For example,
  15611. * for a datetime axis the main unit is milliseconds. If minRange is
  15612. * set to 3600000, you can't zoom in more than to one hour.
  15613. *
  15614. * The default minRange for the x axis is five times the smallest
  15615. * interval between any of the data points.
  15616. *
  15617. * On a logarithmic axis, the unit for the minimum range is the power.
  15618. * So a minRange of 1 means that the axis can be zoomed to 10-100,
  15619. * 100-1000, 1000-10000 etc.
  15620. *
  15621. * **Note**: The `minPadding`, `maxPadding`, `startOnTick` and
  15622. * `endOnTick` settings also affect how the extremes of the axis
  15623. * are computed.
  15624. *
  15625. * @sample {highcharts} highcharts/xaxis/minrange/
  15626. * Minimum range of 5
  15627. * @sample {highstock} stock/xaxis/minrange/
  15628. * Max zoom of 6 months overrides user selections
  15629. * @sample {highmaps} maps/axis/minrange/
  15630. * Minimum range of 1000
  15631. *
  15632. * @type {number}
  15633. * @apioption xAxis.minRange
  15634. */
  15635. /**
  15636. * The minimum tick interval allowed in axis values. For example on
  15637. * zooming in on an axis with daily data, this can be used to prevent
  15638. * the axis from showing hours. Defaults to the closest distance between
  15639. * two points on the axis.
  15640. *
  15641. * @type {number}
  15642. * @since 2.3.0
  15643. * @apioption xAxis.minTickInterval
  15644. */
  15645. /**
  15646. * The distance in pixels from the plot area to the axis line.
  15647. * A positive offset moves the axis with it's line, labels and ticks
  15648. * away from the plot area. This is typically used when two or more
  15649. * axes are displayed on the same side of the plot. With multiple
  15650. * axes the offset is dynamically adjusted to avoid collision, this
  15651. * can be overridden by setting offset explicitly.
  15652. *
  15653. * @sample {highcharts} highcharts/yaxis/offset/
  15654. * Y axis offset of 70
  15655. * @sample {highcharts} highcharts/yaxis/offset-centered/
  15656. * Axes positioned in the center of the plot
  15657. * @sample {highstock} stock/xaxis/offset/
  15658. * Y axis offset by 70 px
  15659. *
  15660. * @type {number}
  15661. */
  15662. offset: void 0,
  15663. /**
  15664. * Whether to display the axis on the opposite side of the normal. The
  15665. * normal is on the left side for vertical axes and bottom for
  15666. * horizontal, so the opposite sides will be right and top respectively.
  15667. * This is typically used with dual or multiple axes.
  15668. *
  15669. * @sample {highcharts} highcharts/yaxis/opposite/
  15670. * Secondary Y axis opposite
  15671. * @sample {highstock} stock/xaxis/opposite/
  15672. * Y axis on left side
  15673. *
  15674. * @default {highcharts|highstock|highmaps} false
  15675. * @default {gantt} true
  15676. */
  15677. opposite: false,
  15678. /**
  15679. * In an ordinal axis, the points are equally spaced in the chart
  15680. * regardless of the actual time or x distance between them. This means
  15681. * that missing data periods (e.g. nights or weekends for a stock chart)
  15682. * will not take up space in the chart.
  15683. * Having `ordinal: false` will show any gaps created by the `gapSize`
  15684. * setting proportionate to their duration.
  15685. *
  15686. * In stock charts the X axis is ordinal by default, unless
  15687. * the boost module is used and at least one of the series' data length
  15688. * exceeds the [boostThreshold](#series.line.boostThreshold).
  15689. *
  15690. * For an ordinal axis, `minPadding` and `maxPadding` are ignored. Use
  15691. * [overscroll](#xAxis.overscroll) instead.
  15692. *
  15693. * @sample {highstock} stock/xaxis/ordinal-true/
  15694. * True by default
  15695. * @sample {highstock} stock/xaxis/ordinal-false/
  15696. * False
  15697. *
  15698. * @see [overscroll](#xAxis.overscroll)
  15699. *
  15700. * @type {boolean}
  15701. * @default true
  15702. * @since 1.1
  15703. * @product highstock
  15704. * @apioption xAxis.ordinal
  15705. */
  15706. /**
  15707. * Additional range on the right side of the xAxis. Works similar to
  15708. * `xAxis.maxPadding`, but value is set in milliseconds. Can be set for
  15709. * both main `xAxis` and the navigator's `xAxis`.
  15710. *
  15711. * @sample {highstock} stock/xaxis/overscroll/
  15712. * One minute overscroll with live data
  15713. *
  15714. * @type {number}
  15715. * @default 0
  15716. * @since 6.0.0
  15717. * @product highstock
  15718. * @apioption xAxis.overscroll
  15719. */
  15720. /**
  15721. * Refers to the index in the [panes](#panes) array. Used for circular
  15722. * gauges and polar charts. When the option is not set then first pane
  15723. * will be used.
  15724. *
  15725. * @sample highcharts/demo/gauge-vu-meter
  15726. * Two gauges with different center
  15727. *
  15728. * @type {number}
  15729. * @product highcharts
  15730. * @apioption xAxis.pane
  15731. */
  15732. /**
  15733. * The zoomed range to display when only defining one or none of `min`
  15734. * or `max`. For example, to show the latest month, a range of one month
  15735. * can be set.
  15736. *
  15737. * @sample {highstock} stock/xaxis/range/
  15738. * Setting a zoomed range when the rangeSelector is disabled
  15739. *
  15740. * @type {number}
  15741. * @product highstock
  15742. * @apioption xAxis.range
  15743. */
  15744. /**
  15745. * Whether to reverse the axis so that the highest number is closest
  15746. * to the origin. If the chart is inverted, the x axis is reversed by
  15747. * default.
  15748. *
  15749. * @sample {highcharts} highcharts/yaxis/reversed/
  15750. * Reversed Y axis
  15751. * @sample {highstock} stock/xaxis/reversed/
  15752. * Reversed Y axis
  15753. *
  15754. * @type {boolean}
  15755. * @default undefined
  15756. * @apioption xAxis.reversed
  15757. */
  15758. reversed: void 0,
  15759. /**
  15760. * This option determines how stacks should be ordered within a group.
  15761. * For example reversed xAxis also reverses stacks, so first series
  15762. * comes last in a group. To keep order like for non-reversed xAxis
  15763. * enable this option.
  15764. *
  15765. * @sample {highcharts} highcharts/xaxis/reversedstacks/
  15766. * Reversed stacks comparison
  15767. * @sample {highstock} highcharts/xaxis/reversedstacks/
  15768. * Reversed stacks comparison
  15769. *
  15770. * @since 6.1.1
  15771. * @product highcharts highstock
  15772. */
  15773. reversedStacks: false,
  15774. /**
  15775. * An optional scrollbar to display on the X axis in response to
  15776. * limiting the minimum and maximum of the axis values.
  15777. *
  15778. * In styled mode, all the presentational options for the scrollbar are
  15779. * replaced by the classes `.highcharts-scrollbar-thumb`,
  15780. * `.highcharts-scrollbar-arrow`, `.highcharts-scrollbar-button`,
  15781. * `.highcharts-scrollbar-rifles` and `.highcharts-scrollbar-track`.
  15782. *
  15783. * @sample {highstock} stock/yaxis/heatmap-scrollbars/
  15784. * Heatmap with both scrollbars
  15785. *
  15786. * @extends scrollbar
  15787. * @since 4.2.6
  15788. * @product highstock
  15789. * @apioption xAxis.scrollbar
  15790. */
  15791. /**
  15792. * Whether to show the axis line and title when the axis has no data.
  15793. *
  15794. * @sample {highcharts} highcharts/yaxis/showempty/
  15795. * When clicking the legend to hide series, one axis preserves
  15796. * line and title, the other doesn't
  15797. * @sample {highstock} highcharts/yaxis/showempty/
  15798. * When clicking the legend to hide series, one axis preserves
  15799. * line and title, the other doesn't
  15800. *
  15801. * @since 1.1
  15802. */
  15803. showEmpty: true,
  15804. /**
  15805. * Whether to show the first tick label.
  15806. *
  15807. * @sample {highcharts} highcharts/xaxis/showfirstlabel-false/
  15808. * Set to false on X axis
  15809. * @sample {highstock} stock/xaxis/showfirstlabel/
  15810. * Labels below plot lines on Y axis
  15811. */
  15812. showFirstLabel: true,
  15813. /**
  15814. * Whether to show the last tick label. Defaults to `true` on cartesian
  15815. * charts, and `false` on polar charts.
  15816. *
  15817. * @sample {highcharts} highcharts/xaxis/showlastlabel-true/
  15818. * Set to true on X axis
  15819. * @sample {highstock} stock/xaxis/showfirstlabel/
  15820. * Labels below plot lines on Y axis
  15821. *
  15822. * @product highcharts highstock gantt
  15823. */
  15824. showLastLabel: true,
  15825. /**
  15826. * A soft maximum for the axis. If the series data maximum is less than
  15827. * this, the axis will stay at this maximum, but if the series data
  15828. * maximum is higher, the axis will flex to show all data.
  15829. *
  15830. * @sample highcharts/yaxis/softmin-softmax/
  15831. * Soft min and max
  15832. *
  15833. * @type {number}
  15834. * @since 5.0.1
  15835. * @product highcharts highstock gantt
  15836. * @apioption xAxis.softMax
  15837. */
  15838. /**
  15839. * A soft minimum for the axis. If the series data minimum is greater
  15840. * than this, the axis will stay at this minimum, but if the series
  15841. * data minimum is lower, the axis will flex to show all data.
  15842. *
  15843. * @sample highcharts/yaxis/softmin-softmax/
  15844. * Soft min and max
  15845. *
  15846. * @type {number}
  15847. * @since 5.0.1
  15848. * @product highcharts highstock gantt
  15849. * @apioption xAxis.softMin
  15850. */
  15851. /**
  15852. * For datetime axes, this decides where to put the tick between weeks.
  15853. * 0 = Sunday, 1 = Monday.
  15854. *
  15855. * @sample {highcharts} highcharts/xaxis/startofweek-monday/
  15856. * Monday by default
  15857. * @sample {highcharts} highcharts/xaxis/startofweek-sunday/
  15858. * Sunday
  15859. * @sample {highstock} stock/xaxis/startofweek-1
  15860. * Monday by default
  15861. * @sample {highstock} stock/xaxis/startofweek-0
  15862. * Sunday
  15863. *
  15864. * @product highcharts highstock gantt
  15865. */
  15866. startOfWeek: 1,
  15867. /**
  15868. * Whether to force the axis to start on a tick. Use this option with
  15869. * the `minPadding` option to control the axis start.
  15870. *
  15871. * @productdesc {highstock}
  15872. * In Highcharts Stock, `startOnTick` is always `false` when
  15873. * the navigator is enabled, to prevent jumpy scrolling.
  15874. *
  15875. * @sample {highcharts} highcharts/xaxis/startontick-false/
  15876. * False by default
  15877. * @sample {highcharts} highcharts/xaxis/startontick-true/
  15878. * True
  15879. *
  15880. * @since 1.2.0
  15881. */
  15882. startOnTick: false,
  15883. /**
  15884. * The amount of ticks to draw on the axis. This opens up for aligning
  15885. * the ticks of multiple charts or panes within a chart. This option
  15886. * overrides the `tickPixelInterval` option.
  15887. *
  15888. * This option only has an effect on linear axes. Datetime, logarithmic
  15889. * or category axes are not affected.
  15890. *
  15891. * @sample {highcharts} highcharts/yaxis/tickamount/
  15892. * 8 ticks on Y axis
  15893. * @sample {highstock} highcharts/yaxis/tickamount/
  15894. * 8 ticks on Y axis
  15895. *
  15896. * @type {number}
  15897. * @since 4.1.0
  15898. * @product highcharts highstock gantt
  15899. * @apioption xAxis.tickAmount
  15900. */
  15901. /**
  15902. * The interval of the tick marks in axis units. When `undefined`, the
  15903. * tick interval is computed to approximately follow the
  15904. * [tickPixelInterval](#xAxis.tickPixelInterval) on linear and datetime
  15905. * axes. On categorized axes, a `undefined` tickInterval will default to
  15906. * 1, one category. Note that datetime axes are based on milliseconds,
  15907. * so for example an interval of one day is expressed as
  15908. * `24 * 3600 * 1000`.
  15909. *
  15910. * On logarithmic axes, the tickInterval is based on powers, so a
  15911. * tickInterval of 1 means one tick on each of 0.1, 1, 10, 100 etc. A
  15912. * tickInterval of 2 means a tick of 0.1, 10, 1000 etc. A tickInterval
  15913. * of 0.2 puts a tick on 0.1, 0.2, 0.4, 0.6, 0.8, 1, 2, 4, 6, 8, 10, 20,
  15914. * 40 etc.
  15915. *
  15916. *
  15917. * If the tickInterval is too dense for labels to be drawn, Highcharts
  15918. * may remove ticks.
  15919. *
  15920. * If the chart has multiple axes, the [alignTicks](#chart.alignTicks)
  15921. * option may interfere with the `tickInterval` setting.
  15922. *
  15923. * @see [tickPixelInterval](#xAxis.tickPixelInterval)
  15924. * @see [tickPositions](#xAxis.tickPositions)
  15925. * @see [tickPositioner](#xAxis.tickPositioner)
  15926. *
  15927. * @sample {highcharts} highcharts/xaxis/tickinterval-5/
  15928. * Tick interval of 5 on a linear axis
  15929. * @sample {highstock} stock/xaxis/tickinterval/
  15930. * Tick interval of 0.01 on Y axis
  15931. *
  15932. * @type {number}
  15933. * @apioption xAxis.tickInterval
  15934. */
  15935. /**
  15936. * The pixel length of the main tick marks.
  15937. *
  15938. * @sample {highcharts} highcharts/xaxis/ticklength/
  15939. * 20 px tick length on the X axis
  15940. * @sample {highstock} stock/xaxis/ticks/
  15941. * Formatted ticks on X axis
  15942. */
  15943. tickLength: 10,
  15944. /**
  15945. * If tickInterval is `null` this option sets the approximate pixel
  15946. * interval of the tick marks. Not applicable to categorized axis.
  15947. *
  15948. * The tick interval is also influenced by the [minTickInterval](
  15949. * #xAxis.minTickInterval) option, that, by default prevents ticks from
  15950. * being denser than the data points.
  15951. *
  15952. * @see [tickInterval](#xAxis.tickInterval)
  15953. * @see [tickPositioner](#xAxis.tickPositioner)
  15954. * @see [tickPositions](#xAxis.tickPositions)
  15955. *
  15956. * @sample {highcharts} highcharts/xaxis/tickpixelinterval-50/
  15957. * 50 px on X axis
  15958. * @sample {highstock} stock/xaxis/tickpixelinterval/
  15959. * 200 px on X axis
  15960. */
  15961. tickPixelInterval: 100,
  15962. /**
  15963. * For categorized axes only. If `on` the tick mark is placed in the
  15964. * center of the category, if `between` the tick mark is placed between
  15965. * categories. The default is `between` if the `tickInterval` is 1, else
  15966. * `on`.
  15967. *
  15968. * @sample {highcharts} highcharts/xaxis/tickmarkplacement-between/
  15969. * "between" by default
  15970. * @sample {highcharts} highcharts/xaxis/tickmarkplacement-on/
  15971. * "on"
  15972. *
  15973. * @product highcharts gantt
  15974. * @validvalue ["on", "between"]
  15975. */
  15976. tickmarkPlacement: 'between',
  15977. /**
  15978. * The position of the major tick marks relative to the axis line.
  15979. * Can be one of `inside` and `outside`.
  15980. *
  15981. * @sample {highcharts} highcharts/xaxis/tickposition-outside/
  15982. * "outside" by default
  15983. * @sample {highcharts} highcharts/xaxis/tickposition-inside/
  15984. * "inside"
  15985. * @sample {highstock} stock/xaxis/ticks/
  15986. * Formatted ticks on X axis
  15987. *
  15988. * @validvalue ["inside", "outside"]
  15989. */
  15990. tickPosition: 'outside',
  15991. /**
  15992. * A callback function returning array defining where the ticks are
  15993. * laid out on the axis. This overrides the default behaviour of
  15994. * [tickPixelInterval](#xAxis.tickPixelInterval) and [tickInterval](
  15995. * #xAxis.tickInterval). The automatic tick positions are accessible
  15996. * through `this.tickPositions` and can be modified by the callback.
  15997. *
  15998. * @see [tickPositions](#xAxis.tickPositions)
  15999. *
  16000. * @sample {highcharts} highcharts/xaxis/tickpositions-tickpositioner/
  16001. * Demo of tickPositions and tickPositioner
  16002. * @sample {highstock} highcharts/xaxis/tickpositions-tickpositioner/
  16003. * Demo of tickPositions and tickPositioner
  16004. *
  16005. * @type {Highcharts.AxisTickPositionerCallbackFunction}
  16006. * @apioption xAxis.tickPositioner
  16007. */
  16008. /**
  16009. * An array defining where the ticks are laid out on the axis. This
  16010. * overrides the default behaviour of [tickPixelInterval](
  16011. * #xAxis.tickPixelInterval) and [tickInterval](#xAxis.tickInterval).
  16012. *
  16013. * @see [tickPositioner](#xAxis.tickPositioner)
  16014. *
  16015. * @sample {highcharts} highcharts/xaxis/tickpositions-tickpositioner/
  16016. * Demo of tickPositions and tickPositioner
  16017. * @sample {highstock} highcharts/xaxis/tickpositions-tickpositioner/
  16018. * Demo of tickPositions and tickPositioner
  16019. *
  16020. * @type {Array<number>}
  16021. * @apioption xAxis.tickPositions
  16022. */
  16023. /**
  16024. * The pixel width of the major tick marks. Defaults to 0 on category
  16025. * axes, otherwise 1.
  16026. *
  16027. * In styled mode, the stroke width is given in the `.highcharts-tick`
  16028. * class, but in order for the element to be generated on category axes,
  16029. * the option must be explicitly set to 1.
  16030. *
  16031. * @sample {highcharts} highcharts/xaxis/tickwidth/
  16032. * 10 px width
  16033. * @sample {highcharts} highcharts/css/axis-grid/
  16034. * Styled mode
  16035. * @sample {highstock} stock/xaxis/ticks/
  16036. * Formatted ticks on X axis
  16037. * @sample {highstock} highcharts/css/axis-grid/
  16038. * Styled mode
  16039. *
  16040. * @type {undefined|number}
  16041. * @default {highstock} 1
  16042. * @default {highmaps} 0
  16043. * @apioption xAxis.tickWidth
  16044. */
  16045. /**
  16046. * The axis title, showing next to the axis line.
  16047. *
  16048. * @productdesc {highmaps}
  16049. * In Highmaps, the axis is hidden by default, but adding an axis title
  16050. * is still possible. X axis and Y axis titles will appear at the bottom
  16051. * and left by default.
  16052. */
  16053. title: {
  16054. /**
  16055. * Alignment of the title relative to the axis values. Possible
  16056. * values are "low", "middle" or "high".
  16057. *
  16058. * @sample {highcharts} highcharts/xaxis/title-align-low/
  16059. * "low"
  16060. * @sample {highcharts} highcharts/xaxis/title-align-center/
  16061. * "middle" by default
  16062. * @sample {highcharts} highcharts/xaxis/title-align-high/
  16063. * "high"
  16064. * @sample {highcharts} highcharts/yaxis/title-offset/
  16065. * Place the Y axis title on top of the axis
  16066. * @sample {highstock} stock/xaxis/title-align/
  16067. * Aligned to "high" value
  16068. *
  16069. * @type {Highcharts.AxisTitleAlignValue}
  16070. */
  16071. align: 'middle',
  16072. /**
  16073. * Deprecated. Set the `text` to `undefined` to disable the title.
  16074. *
  16075. * @deprecated
  16076. * @type {boolean}
  16077. * @product highcharts
  16078. * @apioption xAxis.title.enabled
  16079. */
  16080. /**
  16081. * The pixel distance between the axis labels or line and the title.
  16082. * Defaults to 0 for horizontal axes, 10 for vertical
  16083. *
  16084. * @sample {highcharts} highcharts/xaxis/title-margin/
  16085. * Y axis title margin of 60
  16086. *
  16087. * @type {number}
  16088. * @apioption xAxis.title.margin
  16089. */
  16090. /**
  16091. * The distance of the axis title from the axis line. By default,
  16092. * this distance is computed from the offset width of the labels,
  16093. * the labels' distance from the axis and the title's margin.
  16094. * However when the offset option is set, it overrides all this.
  16095. *
  16096. * @sample {highcharts} highcharts/yaxis/title-offset/
  16097. * Place the axis title on top of the axis
  16098. * @sample {highstock} highcharts/yaxis/title-offset/
  16099. * Place the axis title on top of the Y axis
  16100. *
  16101. * @type {number}
  16102. * @since 2.2.0
  16103. * @apioption xAxis.title.offset
  16104. */
  16105. /**
  16106. * Whether to reserve space for the title when laying out the axis.
  16107. *
  16108. * @type {boolean}
  16109. * @default true
  16110. * @since 5.0.11
  16111. * @product highcharts highstock gantt
  16112. * @apioption xAxis.title.reserveSpace
  16113. */
  16114. /**
  16115. * The rotation of the text in degrees. 0 is horizontal, 270 is
  16116. * vertical reading from bottom to top.
  16117. *
  16118. * @sample {highcharts} highcharts/yaxis/title-offset/
  16119. * Horizontal
  16120. */
  16121. rotation: 0,
  16122. /**
  16123. * The actual text of the axis title. It can contain basic HTML tags
  16124. * like `b`, `i` and `span` with style.
  16125. *
  16126. * @sample {highcharts} highcharts/xaxis/title-text/
  16127. * Custom HTML
  16128. * @sample {highstock} stock/xaxis/title-text/
  16129. * Titles for both axes
  16130. *
  16131. * @type {string|null}
  16132. * @apioption xAxis.title.text
  16133. */
  16134. /**
  16135. * Alignment of the text, can be `"left"`, `"right"` or `"center"`.
  16136. * Default alignment depends on the
  16137. * [title.align](xAxis.title.align):
  16138. *
  16139. * Horizontal axes:
  16140. * - for `align` = `"low"`, `textAlign` is set to `left`
  16141. * - for `align` = `"middle"`, `textAlign` is set to `center`
  16142. * - for `align` = `"high"`, `textAlign` is set to `right`
  16143. *
  16144. * Vertical axes:
  16145. * - for `align` = `"low"` and `opposite` = `true`, `textAlign` is
  16146. * set to `right`
  16147. * - for `align` = `"low"` and `opposite` = `false`, `textAlign` is
  16148. * set to `left`
  16149. * - for `align` = `"middle"`, `textAlign` is set to `center`
  16150. * - for `align` = `"high"` and `opposite` = `true` `textAlign` is
  16151. * set to `left`
  16152. * - for `align` = `"high"` and `opposite` = `false` `textAlign` is
  16153. * set to `right`
  16154. *
  16155. * @type {Highcharts.AlignValue}
  16156. * @apioption xAxis.title.textAlign
  16157. */
  16158. /**
  16159. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  16160. * to render the axis title.
  16161. *
  16162. * @product highcharts highstock gantt
  16163. */
  16164. useHTML: false,
  16165. /**
  16166. * Horizontal pixel offset of the title position.
  16167. *
  16168. * @since 4.1.6
  16169. * @product highcharts highstock gantt
  16170. */
  16171. x: 0,
  16172. /**
  16173. * Vertical pixel offset of the title position.
  16174. *
  16175. * @product highcharts highstock gantt
  16176. */
  16177. y: 0,
  16178. /**
  16179. * CSS styles for the title. If the title text is longer than the
  16180. * axis length, it will wrap to multiple lines by default. This can
  16181. * be customized by setting `textOverflow: 'ellipsis'`, by
  16182. * setting a specific `width` or by setting `whiteSpace: 'nowrap'`.
  16183. *
  16184. * In styled mode, the stroke width is given in the
  16185. * `.highcharts-axis-title` class.
  16186. *
  16187. * @sample {highcharts} highcharts/xaxis/title-style/
  16188. * Red
  16189. * @sample {highcharts} highcharts/css/axis/
  16190. * Styled mode
  16191. *
  16192. * @type {Highcharts.CSSObject}
  16193. */
  16194. style: {
  16195. /** @internal */
  16196. color: Palette.neutralColor60
  16197. }
  16198. },
  16199. /**
  16200. * The type of axis. Can be one of `linear`, `logarithmic`, `datetime`
  16201. * or `category`. In a datetime axis, the numbers are given in
  16202. * milliseconds, and tick marks are placed on appropriate values like
  16203. * full hours or days. In a category axis, the
  16204. * [point names](#series.line.data.name) of the chart's series are used
  16205. * for categories, if not a [categories](#xAxis.categories) array is
  16206. * defined.
  16207. *
  16208. * @sample {highcharts} highcharts/xaxis/type-linear/
  16209. * Linear
  16210. * @sample {highcharts} highcharts/yaxis/type-log/
  16211. * Logarithmic
  16212. * @sample {highcharts} highcharts/yaxis/type-log-minorgrid/
  16213. * Logarithmic with minor grid lines
  16214. * @sample {highcharts} highcharts/xaxis/type-log-both/
  16215. * Logarithmic on two axes
  16216. * @sample {highcharts} highcharts/yaxis/type-log-negative/
  16217. * Logarithmic with extension to emulate negative values
  16218. *
  16219. * @type {Highcharts.AxisTypeValue}
  16220. * @product highcharts gantt
  16221. */
  16222. type: 'linear',
  16223. /**
  16224. * If there are multiple axes on the same side of the chart, the pixel
  16225. * margin between the axes. Defaults to 0 on vertical axes, 15 on
  16226. * horizontal axes.
  16227. *
  16228. * @type {number}
  16229. * @since 7.0.3
  16230. * @apioption xAxis.margin
  16231. */
  16232. /**
  16233. * Applies only when the axis `type` is `category`. When `uniqueNames`
  16234. * is true, points are placed on the X axis according to their names.
  16235. * If the same point name is repeated in the same or another series,
  16236. * the point is placed on the same X position as other points of the
  16237. * same name. When `uniqueNames` is false, the points are laid out in
  16238. * increasing X positions regardless of their names, and the X axis
  16239. * category will take the name of the last point in each position.
  16240. *
  16241. * @sample {highcharts} highcharts/xaxis/uniquenames-true/
  16242. * True by default
  16243. * @sample {highcharts} highcharts/xaxis/uniquenames-false/
  16244. * False
  16245. *
  16246. * @since 4.2.7
  16247. * @product highcharts gantt
  16248. */
  16249. uniqueNames: true,
  16250. /**
  16251. * Datetime axis only. An array determining what time intervals the
  16252. * ticks are allowed to fall on. Each array item is an array where the
  16253. * first value is the time unit and the second value another array of
  16254. * allowed multiples.
  16255. *
  16256. * Defaults to:
  16257. * ```js
  16258. * units: [[
  16259. * 'millisecond', // unit name
  16260. * [1, 2, 5, 10, 20, 25, 50, 100, 200, 500] // allowed multiples
  16261. * ], [
  16262. * 'second',
  16263. * [1, 2, 5, 10, 15, 30]
  16264. * ], [
  16265. * 'minute',
  16266. * [1, 2, 5, 10, 15, 30]
  16267. * ], [
  16268. * 'hour',
  16269. * [1, 2, 3, 4, 6, 8, 12]
  16270. * ], [
  16271. * 'day',
  16272. * [1, 2]
  16273. * ], [
  16274. * 'week',
  16275. * [1, 2]
  16276. * ], [
  16277. * 'month',
  16278. * [1, 2, 3, 4, 6]
  16279. * ], [
  16280. * 'year',
  16281. * null
  16282. * ]]
  16283. * ```
  16284. *
  16285. * @type {Array<Array<string,(Array<number>|null)>>}
  16286. * @product highcharts highstock gantt
  16287. * @apioption xAxis.units
  16288. */
  16289. /**
  16290. * Whether axis, including axis title, line, ticks and labels, should
  16291. * be visible.
  16292. *
  16293. * @since 4.1.9
  16294. * @product highcharts highstock gantt
  16295. */
  16296. visible: true,
  16297. /**
  16298. * Color of the minor, secondary grid lines.
  16299. *
  16300. * In styled mode, the stroke width is given in the
  16301. * `.highcharts-minor-grid-line` class.
  16302. *
  16303. * @sample {highcharts} highcharts/yaxis/minorgridlinecolor/
  16304. * Bright grey lines from Y axis
  16305. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  16306. * Styled mode
  16307. * @sample {highstock} stock/xaxis/minorgridlinecolor/
  16308. * Bright grey lines from Y axis
  16309. *
  16310. * @type {Highcharts.ColorType}
  16311. * @default #f2f2f2
  16312. */
  16313. minorGridLineColor: Palette.neutralColor5,
  16314. /**
  16315. * Width of the minor, secondary grid lines.
  16316. *
  16317. * In styled mode, the stroke width is given in the
  16318. * `.highcharts-grid-line` class.
  16319. *
  16320. * @sample {highcharts} highcharts/yaxis/minorgridlinewidth/
  16321. * 2px lines from Y axis
  16322. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  16323. * Styled mode
  16324. * @sample {highstock} stock/xaxis/minorgridlinewidth/
  16325. * 2px lines from Y axis
  16326. */
  16327. minorGridLineWidth: 1,
  16328. /**
  16329. * Color for the minor tick marks.
  16330. *
  16331. * @sample {highcharts} highcharts/yaxis/minortickcolor/
  16332. * Black tick marks on Y axis
  16333. * @sample {highstock} stock/xaxis/minorticks/
  16334. * Black tick marks on Y axis
  16335. *
  16336. * @type {Highcharts.ColorType}
  16337. * @default #999999
  16338. */
  16339. minorTickColor: Palette.neutralColor40,
  16340. /**
  16341. * The color of the line marking the axis itself.
  16342. *
  16343. * In styled mode, the line stroke is given in the
  16344. * `.highcharts-axis-line` or `.highcharts-xaxis-line` class.
  16345. *
  16346. * @productdesc {highmaps}
  16347. * In Highmaps, the axis line is hidden by default, because the axis is
  16348. * not visible by default.
  16349. *
  16350. * @sample {highcharts} highcharts/yaxis/linecolor/
  16351. * A red line on Y axis
  16352. * @sample {highcharts|highstock} highcharts/css/axis/
  16353. * Axes in styled mode
  16354. * @sample {highstock} stock/xaxis/linecolor/
  16355. * A red line on X axis
  16356. *
  16357. * @type {Highcharts.ColorType}
  16358. * @default #ccd6eb
  16359. */
  16360. lineColor: Palette.highlightColor20,
  16361. /**
  16362. * The width of the line marking the axis itself.
  16363. *
  16364. * In styled mode, the stroke width is given in the
  16365. * `.highcharts-axis-line` or `.highcharts-xaxis-line` class.
  16366. *
  16367. * @sample {highcharts} highcharts/yaxis/linecolor/
  16368. * A 1px line on Y axis
  16369. * @sample {highcharts|highstock} highcharts/css/axis/
  16370. * Axes in styled mode
  16371. * @sample {highstock} stock/xaxis/linewidth/
  16372. * A 2px line on X axis
  16373. *
  16374. * @default {highcharts|highstock} 1
  16375. * @default {highmaps} 0
  16376. */
  16377. lineWidth: 1,
  16378. /**
  16379. * Color of the grid lines extending the ticks across the plot area.
  16380. *
  16381. * In styled mode, the stroke is given in the `.highcharts-grid-line`
  16382. * class.
  16383. *
  16384. * @productdesc {highmaps}
  16385. * In Highmaps, the grid lines are hidden by default.
  16386. *
  16387. * @sample {highcharts} highcharts/yaxis/gridlinecolor/
  16388. * Green lines
  16389. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  16390. * Styled mode
  16391. * @sample {highstock} stock/xaxis/gridlinecolor/
  16392. * Green lines
  16393. *
  16394. * @type {Highcharts.ColorType}
  16395. * @default #e6e6e6
  16396. */
  16397. gridLineColor: Palette.neutralColor10,
  16398. /**
  16399. * The width of the grid lines extending the ticks across the plot area.
  16400. * Defaults to 1 on the Y axis and 0 on the X axis, except for 3d
  16401. * charts.
  16402. *
  16403. * In styled mode, the stroke width is given in the
  16404. * `.highcharts-grid-line` class.
  16405. *
  16406. * @sample {highcharts} highcharts/yaxis/gridlinewidth/
  16407. * 2px lines
  16408. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  16409. * Styled mode
  16410. * @sample {highstock} stock/xaxis/gridlinewidth/
  16411. * 2px lines
  16412. *
  16413. * @type {number}
  16414. * @apioption xAxis.gridLineWidth
  16415. */
  16416. gridLineWidth: void 0,
  16417. /**
  16418. * The height as the vertical axis. If it's a number, it is
  16419. * interpreted as pixels.
  16420. *
  16421. * Since Highcharts 2: If it's a percentage string, it is interpreted
  16422. * as percentages of the total plot height.
  16423. *
  16424. * @type {number|string}
  16425. * @product highcharts highstock
  16426. * @apioption xAxis.height
  16427. */
  16428. /**
  16429. * The width as the horizontal axis. If it's a number, it is interpreted
  16430. * as pixels.
  16431. *
  16432. * Since Highcharts v5.0.13: If it's a percentage string, it is
  16433. * interpreted as percentages of the total plot width.
  16434. *
  16435. * @type {number|string}
  16436. * @product highcharts highstock
  16437. * @apioption xAxis.width
  16438. */
  16439. /**
  16440. * Color for the main tick marks.
  16441. *
  16442. * In styled mode, the stroke is given in the `.highcharts-tick`
  16443. * class.
  16444. *
  16445. * @sample {highcharts} highcharts/xaxis/tickcolor/
  16446. * Red ticks on X axis
  16447. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  16448. * Styled mode
  16449. * @sample {highstock} stock/xaxis/ticks/
  16450. * Formatted ticks on X axis
  16451. *
  16452. * @type {Highcharts.ColorType}
  16453. * @default #ccd6eb
  16454. */
  16455. tickColor: Palette.highlightColor20
  16456. // tickWidth: 1
  16457. };
  16458. /**
  16459. * The Y axis or value axis. Normally this is the vertical axis,
  16460. * though if the chart is inverted this is the horizontal axis.
  16461. * In case of multiple axes, the yAxis node is an array of
  16462. * configuration objects.
  16463. *
  16464. * See [the Axis object](/class-reference/Highcharts.Axis) for programmatic
  16465. * access to the axis.
  16466. *
  16467. * @type {*|Array<*>}
  16468. * @extends xAxis
  16469. * @excluding currentDateIndicator,ordinal,overscroll
  16470. * @optionparent yAxis
  16471. */
  16472. AxisDefaults.defaultYAxisOptions = {
  16473. /**
  16474. * The type of axis. Can be one of `linear`, `logarithmic`, `datetime`,
  16475. * `category` or `treegrid`. Defaults to `treegrid` for Gantt charts,
  16476. * `linear` for other chart types.
  16477. *
  16478. * In a datetime axis, the numbers are given in milliseconds, and tick
  16479. * marks are placed on appropriate values, like full hours or days. In a
  16480. * category or treegrid axis, the [point names](#series.line.data.name)
  16481. * of the chart's series are used for categories, if a
  16482. * [categories](#xAxis.categories) array is not defined.
  16483. *
  16484. * @sample {highcharts} highcharts/yaxis/type-log-minorgrid/
  16485. * Logarithmic with minor grid lines
  16486. * @sample {highcharts} highcharts/yaxis/type-log-negative/
  16487. * Logarithmic with extension to emulate negative values
  16488. * @sample {gantt} gantt/treegrid-axis/demo
  16489. * Treegrid axis
  16490. *
  16491. * @type {Highcharts.AxisTypeValue}
  16492. * @default {highcharts} linear
  16493. * @default {gantt} treegrid
  16494. * @product highcharts gantt
  16495. * @apioption yAxis.type
  16496. */
  16497. /**
  16498. * The height of the Y axis. If it's a number, it is interpreted as
  16499. * pixels.
  16500. *
  16501. * Since Highcharts 2: If it's a percentage string, it is interpreted as
  16502. * percentages of the total plot height.
  16503. *
  16504. * @see [yAxis.top](#yAxis.top)
  16505. *
  16506. * @sample {highstock} stock/demo/candlestick-and-volume/
  16507. * Percentage height panes
  16508. *
  16509. * @type {number|string}
  16510. * @product highcharts highstock
  16511. * @apioption yAxis.height
  16512. */
  16513. /**
  16514. * Solid gauge only. Unless [stops](#yAxis.stops) are set, the color
  16515. * to represent the maximum value of the Y axis.
  16516. *
  16517. * @sample {highcharts} highcharts/yaxis/mincolor-maxcolor/
  16518. * Min and max colors
  16519. *
  16520. * @type {Highcharts.ColorType}
  16521. * @default #003399
  16522. * @since 4.0
  16523. * @product highcharts
  16524. * @apioption yAxis.maxColor
  16525. */
  16526. /**
  16527. * Solid gauge only. Unless [stops](#yAxis.stops) are set, the color
  16528. * to represent the minimum value of the Y axis.
  16529. *
  16530. * @sample {highcharts} highcharts/yaxis/mincolor-maxcolor/
  16531. * Min and max color
  16532. *
  16533. * @type {Highcharts.ColorType}
  16534. * @default #e6ebf5
  16535. * @since 4.0
  16536. * @product highcharts
  16537. * @apioption yAxis.minColor
  16538. */
  16539. /**
  16540. * Whether to reverse the axis so that the highest number is closest
  16541. * to the origin.
  16542. *
  16543. * @sample {highcharts} highcharts/yaxis/reversed/
  16544. * Reversed Y axis
  16545. * @sample {highstock} stock/xaxis/reversed/
  16546. * Reversed Y axis
  16547. *
  16548. * @type {boolean}
  16549. * @default {highcharts} false
  16550. * @default {highstock} false
  16551. * @default {highmaps} true
  16552. * @default {gantt} true
  16553. * @apioption yAxis.reversed
  16554. */
  16555. /**
  16556. * If `true`, the first series in a stack will be drawn on top in a
  16557. * positive, non-reversed Y axis. If `false`, the first series is in
  16558. * the base of the stack.
  16559. *
  16560. * @sample {highcharts} highcharts/yaxis/reversedstacks-false/
  16561. * Non-reversed stacks
  16562. * @sample {highstock} highcharts/yaxis/reversedstacks-false/
  16563. * Non-reversed stacks
  16564. *
  16565. * @type {boolean}
  16566. * @default true
  16567. * @since 3.0.10
  16568. * @product highcharts highstock
  16569. * @apioption yAxis.reversedStacks
  16570. */
  16571. reversedStacks: true,
  16572. /**
  16573. * Solid gauge series only. Color stops for the solid gauge. Use this
  16574. * in cases where a linear gradient between a `minColor` and `maxColor`
  16575. * is not sufficient. The stops is an array of tuples, where the first
  16576. * item is a float between 0 and 1 assigning the relative position in
  16577. * the gradient, and the second item is the color.
  16578. *
  16579. * For solid gauges, the Y axis also inherits the concept of
  16580. * [data classes](https://api.highcharts.com/highmaps#colorAxis.dataClasses)
  16581. * from the Highmaps color axis.
  16582. *
  16583. * @see [minColor](#yAxis.minColor)
  16584. * @see [maxColor](#yAxis.maxColor)
  16585. *
  16586. * @sample {highcharts} highcharts/demo/gauge-solid/
  16587. * True by default
  16588. *
  16589. * @type {Array<Array<number,Highcharts.ColorType>>}
  16590. * @since 4.0
  16591. * @product highcharts
  16592. * @apioption yAxis.stops
  16593. */
  16594. /**
  16595. * The pixel width of the major tick marks.
  16596. *
  16597. * @sample {highcharts} highcharts/xaxis/tickwidth/ 10 px width
  16598. * @sample {highstock} stock/xaxis/ticks/ Formatted ticks on X axis
  16599. *
  16600. * @type {number}
  16601. * @default 0
  16602. * @product highcharts highstock gantt
  16603. * @apioption yAxis.tickWidth
  16604. */
  16605. /**
  16606. * Whether to force the axis to end on a tick. Use this option with
  16607. * the `maxPadding` option to control the axis end.
  16608. *
  16609. * This option is always disabled, when panning type is
  16610. * either `y` or `xy`.
  16611. *
  16612. * @see [type](#chart.panning.type)
  16613. *
  16614. *
  16615. * @sample {highcharts} highcharts/chart/reflow-true/
  16616. * True by default
  16617. * @sample {highcharts} highcharts/yaxis/endontick/
  16618. * False
  16619. * @sample {highstock} stock/demo/basic-line/
  16620. * True by default
  16621. * @sample {highstock} stock/xaxis/endontick/
  16622. * False for Y axis
  16623. *
  16624. * @since 1.2.0
  16625. */
  16626. endOnTick: true,
  16627. /**
  16628. * Padding of the max value relative to the length of the axis. A
  16629. * padding of 0.05 will make a 100px axis 5px longer. This is useful
  16630. * when you don't want the highest data value to appear on the edge
  16631. * of the plot area. When the axis' `max` option is set or a max extreme
  16632. * is set using `axis.setExtremes()`, the maxPadding will be ignored.
  16633. *
  16634. * Also the `softThreshold` option takes precedence over `maxPadding`,
  16635. * so if the data is tangent to the threshold, `maxPadding` may not
  16636. * apply unless `softThreshold` is set to false.
  16637. *
  16638. * @sample {highcharts} highcharts/yaxis/maxpadding-02/
  16639. * Max padding of 0.2
  16640. * @sample {highstock} stock/xaxis/minpadding-maxpadding/
  16641. * Greater min- and maxPadding
  16642. *
  16643. * @since 1.2.0
  16644. * @product highcharts highstock gantt
  16645. */
  16646. maxPadding: 0.05,
  16647. /**
  16648. * Padding of the min value relative to the length of the axis. A
  16649. * padding of 0.05 will make a 100px axis 5px longer. This is useful
  16650. * when you don't want the lowest data value to appear on the edge
  16651. * of the plot area. When the axis' `min` option is set or a max extreme
  16652. * is set using `axis.setExtremes()`, the maxPadding will be ignored.
  16653. *
  16654. * Also the `softThreshold` option takes precedence over `minPadding`,
  16655. * so if the data is tangent to the threshold, `minPadding` may not
  16656. * apply unless `softThreshold` is set to false.
  16657. *
  16658. * @sample {highcharts} highcharts/yaxis/minpadding/
  16659. * Min padding of 0.2
  16660. * @sample {highstock} stock/xaxis/minpadding-maxpadding/
  16661. * Greater min- and maxPadding
  16662. *
  16663. * @since 1.2.0
  16664. * @product highcharts highstock gantt
  16665. */
  16666. minPadding: 0.05,
  16667. /**
  16668. * @productdesc {highstock}
  16669. * In Highcharts Stock 1.x, the Y axis was placed
  16670. * on the left side by default.
  16671. *
  16672. * @sample {highcharts} highcharts/yaxis/opposite/
  16673. * Secondary Y axis opposite
  16674. * @sample {highstock} stock/xaxis/opposite/
  16675. * Y axis on left side
  16676. *
  16677. * @type {boolean}
  16678. * @default {highstock} true
  16679. * @default {highcharts} false
  16680. * @product highstock highcharts gantt
  16681. * @apioption yAxis.opposite
  16682. */
  16683. /**
  16684. * @see [tickInterval](#xAxis.tickInterval)
  16685. * @see [tickPositioner](#xAxis.tickPositioner)
  16686. * @see [tickPositions](#xAxis.tickPositions)
  16687. */
  16688. tickPixelInterval: 72,
  16689. showLastLabel: true,
  16690. /**
  16691. * @extends xAxis.labels
  16692. */
  16693. labels: {
  16694. /**
  16695. * Angular gauges and solid gauges only.
  16696. * The label's pixel distance from the perimeter of the plot area.
  16697. *
  16698. * Since v7.1.2: If it's a percentage string, it is interpreted the
  16699. * same as [series.radius](#plotOptions.gauge.radius), so label can be
  16700. * aligned under the gauge's shape.
  16701. *
  16702. * @sample {highcharts} highcharts/yaxis/labels-distance/
  16703. * Labels centered under the arc
  16704. *
  16705. * @type {number|string}
  16706. * @default -25
  16707. * @product highcharts
  16708. * @apioption yAxis.labels.distance
  16709. */
  16710. /**
  16711. * The y position offset of all labels relative to the tick
  16712. * positions on the axis. For polar and radial axis consider the use
  16713. * of the [distance](#yAxis.labels.distance) option.
  16714. *
  16715. * @sample {highcharts} highcharts/xaxis/labels-x/
  16716. * Y axis labels placed on grid lines
  16717. *
  16718. * @type {number}
  16719. * @default {highcharts} 3
  16720. * @default {highstock} -2
  16721. * @default {highmaps} 3
  16722. * @apioption yAxis.labels.y
  16723. */
  16724. /**
  16725. * What part of the string the given position is anchored to. Can
  16726. * be one of `"left"`, `"center"` or `"right"`. The exact position
  16727. * also depends on the `labels.x` setting.
  16728. *
  16729. * Angular gauges and solid gauges defaults to `"center"`.
  16730. * Solid gauges with two labels have additional option `"auto"`
  16731. * for automatic horizontal and vertical alignment.
  16732. *
  16733. * @see [yAxis.labels.distance](#yAxis.labels.distance)
  16734. *
  16735. * @sample {highcharts} highcharts/yaxis/labels-align-left/
  16736. * Left
  16737. * @sample {highcharts} highcharts/series-solidgauge/labels-auto-aligned/
  16738. * Solid gauge labels auto aligned
  16739. *
  16740. * @type {Highcharts.AlignValue}
  16741. * @default {highcharts|highmaps} right
  16742. * @default {highstock} left
  16743. * @apioption yAxis.labels.align
  16744. */
  16745. /**
  16746. * The x position offset of all labels relative to the tick
  16747. * positions on the axis. Defaults to -15 for left axis, 15 for
  16748. * right axis.
  16749. *
  16750. * @sample {highcharts} highcharts/xaxis/labels-x/
  16751. * Y axis labels placed on grid lines
  16752. */
  16753. x: -8
  16754. },
  16755. /**
  16756. * @productdesc {highmaps}
  16757. * In Highmaps, the axis line is hidden by default, because the axis is
  16758. * not visible by default.
  16759. *
  16760. * @type {Highcharts.ColorType}
  16761. * @apioption yAxis.lineColor
  16762. */
  16763. /**
  16764. * @sample {highcharts} highcharts/yaxis/max-200/
  16765. * Y axis max of 200
  16766. * @sample {highcharts} highcharts/yaxis/max-logarithmic/
  16767. * Y axis max on logarithmic axis
  16768. * @sample {highstock} stock/yaxis/min-max/
  16769. * Fixed min and max on Y axis
  16770. * @sample {highmaps} maps/axis/min-max/
  16771. * Pre-zoomed to a specific area
  16772. *
  16773. * @apioption yAxis.max
  16774. */
  16775. /**
  16776. * @sample {highcharts} highcharts/yaxis/min-startontick-false/
  16777. * -50 with startOnTick to false
  16778. * @sample {highcharts} highcharts/yaxis/min-startontick-true/
  16779. * -50 with startOnTick true by default
  16780. * @sample {highstock} stock/yaxis/min-max/
  16781. * Fixed min and max on Y axis
  16782. * @sample {highmaps} maps/axis/min-max/
  16783. * Pre-zoomed to a specific area
  16784. *
  16785. * @apioption yAxis.min
  16786. */
  16787. /**
  16788. * An optional scrollbar to display on the Y axis in response to
  16789. * limiting the minimum an maximum of the axis values.
  16790. *
  16791. * In styled mode, all the presentational options for the scrollbar
  16792. * are replaced by the classes `.highcharts-scrollbar-thumb`,
  16793. * `.highcharts-scrollbar-arrow`, `.highcharts-scrollbar-button`,
  16794. * `.highcharts-scrollbar-rifles` and `.highcharts-scrollbar-track`.
  16795. *
  16796. * @sample {highstock} stock/yaxis/scrollbar/
  16797. * Scrollbar on the Y axis
  16798. *
  16799. * @extends scrollbar
  16800. * @since 4.2.6
  16801. * @product highstock
  16802. * @excluding height
  16803. * @apioption yAxis.scrollbar
  16804. */
  16805. /**
  16806. * Enable the scrollbar on the Y axis.
  16807. *
  16808. * @sample {highstock} stock/yaxis/scrollbar/
  16809. * Enabled on Y axis
  16810. *
  16811. * @type {boolean}
  16812. * @default false
  16813. * @since 4.2.6
  16814. * @product highstock
  16815. * @apioption yAxis.scrollbar.enabled
  16816. */
  16817. /**
  16818. * Pixel margin between the scrollbar and the axis elements.
  16819. *
  16820. * @type {number}
  16821. * @default 10
  16822. * @since 4.2.6
  16823. * @product highstock
  16824. * @apioption yAxis.scrollbar.margin
  16825. */
  16826. /**
  16827. * Whether to show the scrollbar when it is fully zoomed out at max
  16828. * range. Setting it to `false` on the Y axis makes the scrollbar stay
  16829. * hidden until the user zooms in, like common in browsers.
  16830. *
  16831. * @type {boolean}
  16832. * @default true
  16833. * @since 4.2.6
  16834. * @product highstock
  16835. * @apioption yAxis.scrollbar.showFull
  16836. */
  16837. /**
  16838. * The width of a vertical scrollbar or height of a horizontal
  16839. * scrollbar. Defaults to 20 on touch devices.
  16840. *
  16841. * @type {number}
  16842. * @default 14
  16843. * @since 4.2.6
  16844. * @product highstock
  16845. * @apioption yAxis.scrollbar.size
  16846. */
  16847. /**
  16848. * Z index of the scrollbar elements.
  16849. *
  16850. * @type {number}
  16851. * @default 3
  16852. * @since 4.2.6
  16853. * @product highstock
  16854. * @apioption yAxis.scrollbar.zIndex
  16855. */
  16856. /**
  16857. * A soft maximum for the axis. If the series data maximum is less
  16858. * than this, the axis will stay at this maximum, but if the series
  16859. * data maximum is higher, the axis will flex to show all data.
  16860. *
  16861. * **Note**: The [series.softThreshold](
  16862. * #plotOptions.series.softThreshold) option takes precedence over this
  16863. * option.
  16864. *
  16865. * @sample highcharts/yaxis/softmin-softmax/
  16866. * Soft min and max
  16867. *
  16868. * @type {number}
  16869. * @since 5.0.1
  16870. * @product highcharts highstock gantt
  16871. * @apioption yAxis.softMax
  16872. */
  16873. /**
  16874. * A soft minimum for the axis. If the series data minimum is greater
  16875. * than this, the axis will stay at this minimum, but if the series
  16876. * data minimum is lower, the axis will flex to show all data.
  16877. *
  16878. * **Note**: The [series.softThreshold](
  16879. * #plotOptions.series.softThreshold) option takes precedence over this
  16880. * option.
  16881. *
  16882. * @sample highcharts/yaxis/softmin-softmax/
  16883. * Soft min and max
  16884. *
  16885. * @type {number}
  16886. * @since 5.0.1
  16887. * @product highcharts highstock gantt
  16888. * @apioption yAxis.softMin
  16889. */
  16890. /**
  16891. * Defines the horizontal alignment of the stack total label. Can be one
  16892. * of `"left"`, `"center"` or `"right"`. The default value is calculated
  16893. * at runtime and depends on orientation and whether the stack is
  16894. * positive or negative.
  16895. *
  16896. * @sample {highcharts} highcharts/yaxis/stacklabels-align-left/
  16897. * Aligned to the left
  16898. * @sample {highcharts} highcharts/yaxis/stacklabels-align-center/
  16899. * Aligned in center
  16900. * @sample {highcharts} highcharts/yaxis/stacklabels-align-right/
  16901. * Aligned to the right
  16902. *
  16903. * @type {Highcharts.AlignValue}
  16904. * @since 2.1.5
  16905. * @product highcharts
  16906. * @apioption yAxis.stackLabels.align
  16907. */
  16908. /**
  16909. * A format string for the data label. Available variables are the same
  16910. * as for `formatter`.
  16911. *
  16912. * @type {string}
  16913. * @default {total}
  16914. * @since 3.0.2
  16915. * @product highcharts highstock
  16916. * @apioption yAxis.stackLabels.format
  16917. */
  16918. /**
  16919. * Rotation of the labels in degrees.
  16920. *
  16921. * @sample {highcharts} highcharts/yaxis/stacklabels-rotation/
  16922. * Labels rotated 45°
  16923. *
  16924. * @type {number}
  16925. * @default 0
  16926. * @since 2.1.5
  16927. * @product highcharts
  16928. * @apioption yAxis.stackLabels.rotation
  16929. */
  16930. /**
  16931. * The text alignment for the label. While `align` determines where the
  16932. * texts anchor point is placed with regards to the stack, `textAlign`
  16933. * determines how the text is aligned against its anchor point. Possible
  16934. * values are `"left"`, `"center"` and `"right"`. The default value is
  16935. * calculated at runtime and depends on orientation and whether the
  16936. * stack is positive or negative.
  16937. *
  16938. * @sample {highcharts} highcharts/yaxis/stacklabels-textalign-left/
  16939. * Label in center position but text-aligned left
  16940. *
  16941. * @type {Highcharts.AlignValue}
  16942. * @since 2.1.5
  16943. * @product highcharts
  16944. * @apioption yAxis.stackLabels.textAlign
  16945. */
  16946. /**
  16947. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  16948. * to render the labels.
  16949. *
  16950. * @type {boolean}
  16951. * @default false
  16952. * @since 3.0
  16953. * @product highcharts highstock
  16954. * @apioption yAxis.stackLabels.useHTML
  16955. */
  16956. /**
  16957. * Defines the vertical alignment of the stack total label. Can be one
  16958. * of `"top"`, `"middle"` or `"bottom"`. The default value is calculated
  16959. * at runtime and depends on orientation and whether the stack is
  16960. * positive or negative.
  16961. *
  16962. * @sample {highcharts} highcharts/yaxis/stacklabels-verticalalign-top/
  16963. * Vertically aligned top
  16964. * @sample {highcharts} highcharts/yaxis/stacklabels-verticalalign-middle/
  16965. * Vertically aligned middle
  16966. * @sample {highcharts} highcharts/yaxis/stacklabels-verticalalign-bottom/
  16967. * Vertically aligned bottom
  16968. *
  16969. * @type {Highcharts.VerticalAlignValue}
  16970. * @since 2.1.5
  16971. * @product highcharts
  16972. * @apioption yAxis.stackLabels.verticalAlign
  16973. */
  16974. /**
  16975. * The x position offset of the label relative to the left of the
  16976. * stacked bar. The default value is calculated at runtime and depends
  16977. * on orientation and whether the stack is positive or negative.
  16978. *
  16979. * @sample {highcharts} highcharts/yaxis/stacklabels-x/
  16980. * Stack total labels with x offset
  16981. *
  16982. * @type {number}
  16983. * @since 2.1.5
  16984. * @product highcharts
  16985. * @apioption yAxis.stackLabels.x
  16986. */
  16987. /**
  16988. * The y position offset of the label relative to the tick position
  16989. * on the axis. The default value is calculated at runtime and depends
  16990. * on orientation and whether the stack is positive or negative.
  16991. *
  16992. * @sample {highcharts} highcharts/yaxis/stacklabels-y/
  16993. * Stack total labels with y offset
  16994. *
  16995. * @type {number}
  16996. * @since 2.1.5
  16997. * @product highcharts
  16998. * @apioption yAxis.stackLabels.y
  16999. */
  17000. /**
  17001. * Whether to force the axis to start on a tick. Use this option with
  17002. * the `maxPadding` option to control the axis start.
  17003. *
  17004. * This option is always disabled, when panning type is
  17005. * either `y` or `xy`.
  17006. *
  17007. * @see [type](#chart.panning.type)
  17008. *
  17009. * @sample {highcharts} highcharts/xaxis/startontick-false/
  17010. * False by default
  17011. * @sample {highcharts} highcharts/xaxis/startontick-true/
  17012. * True
  17013. * @sample {highstock} stock/xaxis/endontick/
  17014. * False for Y axis
  17015. *
  17016. * @since 1.2.0
  17017. * @product highcharts highstock gantt
  17018. */
  17019. startOnTick: true,
  17020. title: {
  17021. /**
  17022. * The pixel distance between the axis labels and the title.
  17023. * Positive values are outside the axis line, negative are inside.
  17024. *
  17025. * @sample {highcharts} highcharts/xaxis/title-margin/
  17026. * Y axis title margin of 60
  17027. *
  17028. * @type {number}
  17029. * @default 40
  17030. * @apioption yAxis.title.margin
  17031. */
  17032. /**
  17033. * The rotation of the text in degrees. 0 is horizontal, 270 is
  17034. * vertical reading from bottom to top.
  17035. *
  17036. * @sample {highcharts} highcharts/yaxis/title-offset/
  17037. * Horizontal
  17038. */
  17039. rotation: 270,
  17040. /**
  17041. * The actual text of the axis title. Horizontal texts can contain
  17042. * HTML, but rotated texts are painted using vector techniques and
  17043. * must be clean text. The Y axis title is disabled by setting the
  17044. * `text` option to `undefined`.
  17045. *
  17046. * @sample {highcharts} highcharts/xaxis/title-text/
  17047. * Custom HTML
  17048. *
  17049. * @type {string|null}
  17050. * @default {highcharts} Values
  17051. * @default {highstock} undefined
  17052. * @product highcharts highstock gantt
  17053. */
  17054. text: 'Values'
  17055. },
  17056. /**
  17057. * The top position of the Y axis. If it's a number, it is interpreted
  17058. * as pixel position relative to the chart.
  17059. *
  17060. * Since Highcharts 2: If it's a percentage string, it is interpreted as
  17061. * percentages of the plot height, offset from plot area top.
  17062. *
  17063. * @see [yAxis.height](#yAxis.height)
  17064. *
  17065. * @sample {highstock} stock/demo/candlestick-and-volume/
  17066. * Percentage height panes
  17067. *
  17068. * @type {number|string}
  17069. * @product highcharts highstock
  17070. * @apioption yAxis.top
  17071. */
  17072. /**
  17073. * The stack labels show the total value for each bar in a stacked
  17074. * column or bar chart. The label will be placed on top of positive
  17075. * columns and below negative columns. In case of an inverted column
  17076. * chart or a bar chart the label is placed to the right of positive
  17077. * bars and to the left of negative bars.
  17078. *
  17079. * @product highcharts
  17080. */
  17081. stackLabels: {
  17082. /**
  17083. * Enable or disable the initial animation when a series is
  17084. * displayed for the `stackLabels`. The animation can also be set as
  17085. * a configuration object. Please note that this option only
  17086. * applies to the initial animation.
  17087. * For other animations, see [chart.animation](#chart.animation)
  17088. * and the animation parameter under the API methods.
  17089. * The following properties are supported:
  17090. *
  17091. * - `defer`: The animation delay time in milliseconds.
  17092. *
  17093. * @sample {highcharts} highcharts/plotoptions/animation-defer/
  17094. * Animation defer settings
  17095. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  17096. * @since 8.2.0
  17097. * @apioption yAxis.stackLabels.animation
  17098. */
  17099. animation: {},
  17100. /**
  17101. * The animation delay time in milliseconds.
  17102. * Set to `0` renders stackLabel immediately.
  17103. * As `undefined` inherits defer time from the [series.animation.defer](#plotOptions.series.animation.defer).
  17104. *
  17105. * @type {number}
  17106. * @since 8.2.0
  17107. * @apioption yAxis.stackLabels.animation.defer
  17108. */
  17109. /**
  17110. * Allow the stack labels to overlap.
  17111. *
  17112. * @sample {highcharts} highcharts/yaxis/stacklabels-allowoverlap-false/
  17113. * Default false
  17114. *
  17115. * @since 5.0.13
  17116. * @product highcharts
  17117. */
  17118. allowOverlap: false,
  17119. /**
  17120. * The background color or gradient for the stack label.
  17121. *
  17122. * @sample {highcharts} highcharts/yaxis/stacklabels-box/
  17123. * Stack labels box options
  17124. * @type {Highcharts.ColorType}
  17125. * @since 8.1.0
  17126. * @apioption yAxis.stackLabels.backgroundColor
  17127. */
  17128. /**
  17129. * The border color for the stack label. Defaults to `undefined`.
  17130. *
  17131. * @sample {highcharts} highcharts/yaxis/stacklabels-box/
  17132. * Stack labels box options
  17133. * @type {Highcharts.ColorType}
  17134. * @since 8.1.0
  17135. * @apioption yAxis.stackLabels.borderColor
  17136. */
  17137. /**
  17138. * The border radius in pixels for the stack label.
  17139. *
  17140. * @sample {highcharts} highcharts/yaxis/stacklabels-box/
  17141. * Stack labels box options
  17142. * @type {number}
  17143. * @default 0
  17144. * @since 8.1.0
  17145. * @apioption yAxis.stackLabels.borderRadius
  17146. */
  17147. /**
  17148. * The border width in pixels for the stack label.
  17149. *
  17150. * @sample {highcharts} highcharts/yaxis/stacklabels-box/
  17151. * Stack labels box options
  17152. * @type {number}
  17153. * @default 0
  17154. * @since 8.1.0
  17155. * @apioption yAxis.stackLabels.borderWidth
  17156. */
  17157. /**
  17158. * Enable or disable the stack total labels.
  17159. *
  17160. * @sample {highcharts} highcharts/yaxis/stacklabels-enabled/
  17161. * Enabled stack total labels
  17162. * @sample {highcharts} highcharts/yaxis/stacklabels-enabled-waterfall/
  17163. * Enabled stack labels in waterfall chart
  17164. *
  17165. * @since 2.1.5
  17166. * @product highcharts
  17167. */
  17168. enabled: false,
  17169. /**
  17170. * Whether to hide stack labels that are outside the plot area.
  17171. * By default, the stack label is moved
  17172. * inside the plot area according to the
  17173. * [overflow](/highcharts/#yAxis/stackLabels/overflow)
  17174. * option.
  17175. *
  17176. * @type {boolean}
  17177. * @since 7.1.3
  17178. */
  17179. crop: true,
  17180. /**
  17181. * How to handle stack total labels that flow outside the plot area.
  17182. * The default is set to `"justify"`,
  17183. * which aligns them inside the plot area.
  17184. * For columns and bars, this means it will be moved inside the bar.
  17185. * To display stack labels outside the plot area,
  17186. * set `crop` to `false` and `overflow` to `"allow"`.
  17187. *
  17188. * @sample highcharts/yaxis/stacklabels-overflow/
  17189. * Stack labels flows outside the plot area.
  17190. *
  17191. * @type {Highcharts.DataLabelsOverflowValue}
  17192. * @since 7.1.3
  17193. */
  17194. overflow: 'justify',
  17195. /* eslint-disable valid-jsdoc */
  17196. /**
  17197. * Callback JavaScript function to format the label. The value is
  17198. * given by `this.total`.
  17199. *
  17200. * @sample {highcharts} highcharts/yaxis/stacklabels-formatter/
  17201. * Added units to stack total value
  17202. *
  17203. * @type {Highcharts.FormatterCallbackFunction<Highcharts.StackItemObject>}
  17204. * @since 2.1.5
  17205. * @product highcharts
  17206. */
  17207. formatter: function () {
  17208. var numberFormatter = this.axis.chart.numberFormatter;
  17209. /* eslint-enable valid-jsdoc */
  17210. return numberFormatter(this.total, -1);
  17211. },
  17212. /**
  17213. * CSS styles for the label.
  17214. *
  17215. * In styled mode, the styles are set in the
  17216. * `.highcharts-stack-label` class.
  17217. *
  17218. * @sample {highcharts} highcharts/yaxis/stacklabels-style/
  17219. * Red stack total labels
  17220. *
  17221. * @type {Highcharts.CSSObject}
  17222. * @since 2.1.5
  17223. * @product highcharts
  17224. */
  17225. style: {
  17226. /** @internal */
  17227. color: Palette.neutralColor100,
  17228. /** @internal */
  17229. fontSize: '11px',
  17230. /** @internal */
  17231. fontWeight: 'bold',
  17232. /** @internal */
  17233. textOutline: '1px contrast'
  17234. }
  17235. },
  17236. gridLineWidth: 1,
  17237. lineWidth: 0
  17238. // tickWidth: 0
  17239. };
  17240. /**
  17241. * The Z axis or depth axis for 3D plots.
  17242. *
  17243. * See the [Axis class](/class-reference/Highcharts.Axis) for programmatic
  17244. * access to the axis.
  17245. *
  17246. * @sample {highcharts} highcharts/3d/scatter-zaxis-categories/
  17247. * Z-Axis with Categories
  17248. * @sample {highcharts} highcharts/3d/scatter-zaxis-grid/
  17249. * Z-Axis with styling
  17250. *
  17251. * @type {*|Array<*>}
  17252. * @extends xAxis
  17253. * @since 5.0.0
  17254. * @product highcharts
  17255. * @excluding breaks, crosshair, height, left, lineColor, lineWidth,
  17256. * nameToX, showEmpty, top, width
  17257. * @apioption zAxis
  17258. */
  17259. // This variable extends the defaultOptions for left axes.
  17260. AxisDefaults.defaultLeftAxisOptions = {
  17261. labels: {
  17262. x: -15
  17263. },
  17264. title: {
  17265. rotation: 270
  17266. }
  17267. };
  17268. // This variable extends the defaultOptions for right axes.
  17269. AxisDefaults.defaultRightAxisOptions = {
  17270. labels: {
  17271. x: 15
  17272. },
  17273. title: {
  17274. rotation: 90
  17275. }
  17276. };
  17277. // This variable extends the defaultOptions for bottom axes.
  17278. AxisDefaults.defaultBottomAxisOptions = {
  17279. labels: {
  17280. autoRotation: [-45],
  17281. x: 0
  17282. // overflow: undefined,
  17283. // staggerLines: null
  17284. },
  17285. margin: 15,
  17286. title: {
  17287. rotation: 0
  17288. }
  17289. };
  17290. // This variable extends the defaultOptions for top axes.
  17291. AxisDefaults.defaultTopAxisOptions = {
  17292. labels: {
  17293. autoRotation: [-45],
  17294. x: 0
  17295. // overflow: undefined
  17296. // staggerLines: null
  17297. },
  17298. margin: 15,
  17299. title: {
  17300. rotation: 0
  17301. }
  17302. };
  17303. })(AxisDefaults || (AxisDefaults = {}));
  17304. /* *
  17305. *
  17306. * Default Export
  17307. *
  17308. * */
  17309. return AxisDefaults;
  17310. });
  17311. _registerModule(_modules, 'Core/Foundation.js', [_modules['Core/Utilities.js']], function (U) {
  17312. /* *
  17313. *
  17314. * (c) 2010-2021 Torstein Honsi
  17315. *
  17316. * License: www.highcharts.com/license
  17317. *
  17318. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  17319. *
  17320. * */
  17321. var addEvent = U.addEvent,
  17322. isFunction = U.isFunction,
  17323. objectEach = U.objectEach,
  17324. removeEvent = U.removeEvent;
  17325. /* *
  17326. *
  17327. * Functions
  17328. *
  17329. * */
  17330. /*
  17331. * Register event options. If an event handler is set on the options, it should
  17332. * be subject to Chart.update, Axis.update and Series.update. This is contrary
  17333. * to general handlers that are set directly using addEvent either on the class
  17334. * or on the instance. #6538, #6943, #10861.
  17335. */
  17336. var registerEventOptions = function (component,
  17337. options) {
  17338. // A lookup over those events that are added by _options_ (not
  17339. // programmatically). These are updated through .update()
  17340. component.eventOptions = component.eventOptions || {};
  17341. // Register event listeners
  17342. objectEach(options.events, function (event, eventType) {
  17343. if (isFunction(event)) {
  17344. // If event does not exist, or is changed by the .update()
  17345. // function
  17346. if (component.eventOptions[eventType] !== event) {
  17347. // Remove existing if set by option
  17348. if (isFunction(component.eventOptions[eventType])) {
  17349. removeEvent(component, eventType, component.eventOptions[eventType]);
  17350. }
  17351. component.eventOptions[eventType] = event;
  17352. addEvent(component, eventType, event);
  17353. }
  17354. }
  17355. });
  17356. };
  17357. /* *
  17358. *
  17359. * Default Export
  17360. *
  17361. * */
  17362. var exports = {
  17363. registerEventOptions: registerEventOptions
  17364. };
  17365. return exports;
  17366. });
  17367. _registerModule(_modules, 'Core/Axis/Tick.js', [_modules['Core/FormatUtilities.js'], _modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (F, H, U) {
  17368. /* *
  17369. *
  17370. * (c) 2010-2021 Torstein Honsi
  17371. *
  17372. * License: www.highcharts.com/license
  17373. *
  17374. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  17375. *
  17376. * */
  17377. var deg2rad = H.deg2rad;
  17378. var clamp = U.clamp,
  17379. correctFloat = U.correctFloat,
  17380. defined = U.defined,
  17381. destroyObjectProperties = U.destroyObjectProperties,
  17382. extend = U.extend,
  17383. fireEvent = U.fireEvent,
  17384. isNumber = U.isNumber,
  17385. merge = U.merge,
  17386. objectEach = U.objectEach,
  17387. pick = U.pick;
  17388. /* *
  17389. *
  17390. * Class
  17391. *
  17392. * */
  17393. /* eslint-disable no-invalid-this, valid-jsdoc */
  17394. /**
  17395. * The Tick class.
  17396. *
  17397. * @class
  17398. * @name Highcharts.Tick
  17399. *
  17400. * @param {Highcharts.Axis} axis
  17401. * The axis of the tick.
  17402. *
  17403. * @param {number} pos
  17404. * The position of the tick on the axis in terms of axis values.
  17405. *
  17406. * @param {string} [type]
  17407. * The type of tick, either 'minor' or an empty string
  17408. *
  17409. * @param {boolean} [noLabel=false]
  17410. * Whether to disable the label or not. Defaults to false.
  17411. *
  17412. * @param {object} [parameters]
  17413. * Optional parameters for the tick.
  17414. */
  17415. var Tick = /** @class */ (function () {
  17416. /* *
  17417. *
  17418. * Constructors
  17419. *
  17420. * */
  17421. function Tick(axis, pos, type, noLabel, parameters) {
  17422. this.isNew = true;
  17423. this.isNewLabel = true;
  17424. /**
  17425. * The related axis of the tick.
  17426. * @name Highcharts.Tick#axis
  17427. * @type {Highcharts.Axis}
  17428. */
  17429. this.axis = axis;
  17430. /**
  17431. * The logical position of the tick on the axis in terms of axis values.
  17432. * @name Highcharts.Tick#pos
  17433. * @type {number}
  17434. */
  17435. this.pos = pos;
  17436. /**
  17437. * The tick type, which can be `"minor"`, or an empty string.
  17438. * @name Highcharts.Tick#type
  17439. * @type {string}
  17440. */
  17441. this.type = type || '';
  17442. this.parameters = parameters || {};
  17443. /**
  17444. * The mark offset of the tick on the axis. Usually `undefined`, numeric
  17445. * for grid axes.
  17446. * @name Highcharts.Tick#tickmarkOffset
  17447. * @type {number|undefined}
  17448. */
  17449. this.tickmarkOffset = this.parameters.tickmarkOffset;
  17450. this.options = this.parameters.options;
  17451. fireEvent(this, 'init');
  17452. if (!type && !noLabel) {
  17453. this.addLabel();
  17454. }
  17455. }
  17456. /* *
  17457. *
  17458. * Functions
  17459. *
  17460. * */
  17461. /**
  17462. * Write the tick label.
  17463. *
  17464. * @private
  17465. * @function Highcharts.Tick#addLabel
  17466. * @return {void}
  17467. */
  17468. Tick.prototype.addLabel = function () {
  17469. var tick = this,
  17470. axis = tick.axis,
  17471. options = axis.options,
  17472. chart = axis.chart,
  17473. categories = axis.categories,
  17474. log = axis.logarithmic,
  17475. names = axis.names,
  17476. pos = tick.pos,
  17477. labelOptions = pick(tick.options && tick.options.labels,
  17478. options.labels),
  17479. tickPositions = axis.tickPositions,
  17480. isFirst = pos === tickPositions[0],
  17481. isLast = pos === tickPositions[tickPositions.length - 1],
  17482. animateLabels = (!labelOptions.step || labelOptions.step === 1) &&
  17483. axis.tickInterval === 1,
  17484. tickPositionInfo = tickPositions.info;
  17485. var label = tick.label,
  17486. dateTimeLabelFormat,
  17487. dateTimeLabelFormats,
  17488. i;
  17489. // The context value
  17490. var value = this.parameters.category || (categories ?
  17491. pick(categories[pos],
  17492. names[pos],
  17493. pos) :
  17494. pos);
  17495. if (log && isNumber(value)) {
  17496. value = correctFloat(log.lin2log(value));
  17497. }
  17498. // Set the datetime label format. If a higher rank is set for this
  17499. // position, use that. If not, use the general format.
  17500. if (axis.dateTime && tickPositionInfo) {
  17501. dateTimeLabelFormats = chart.time.resolveDTLFormat(options.dateTimeLabelFormats[(!options.grid &&
  17502. tickPositionInfo.higherRanks[pos]) ||
  17503. tickPositionInfo.unitName]);
  17504. dateTimeLabelFormat = dateTimeLabelFormats.main;
  17505. }
  17506. // set properties for access in render method
  17507. /**
  17508. * True if the tick is the first one on the axis.
  17509. * @name Highcharts.Tick#isFirst
  17510. * @readonly
  17511. * @type {boolean|undefined}
  17512. */
  17513. tick.isFirst = isFirst;
  17514. /**
  17515. * True if the tick is the last one on the axis.
  17516. * @name Highcharts.Tick#isLast
  17517. * @readonly
  17518. * @type {boolean|undefined}
  17519. */
  17520. tick.isLast = isLast;
  17521. // Get the string
  17522. var ctx = {
  17523. axis: axis,
  17524. chart: chart,
  17525. dateTimeLabelFormat: dateTimeLabelFormat,
  17526. isFirst: isFirst,
  17527. isLast: isLast,
  17528. pos: pos,
  17529. tick: tick,
  17530. tickPositionInfo: tickPositionInfo,
  17531. value: value
  17532. };
  17533. // Fire an event that allows modifying the context for use in
  17534. // `labels.format` and `labels.formatter`.
  17535. fireEvent(this, 'labelFormat', ctx);
  17536. // Label formatting. When `labels.format` is given, we first run the
  17537. // defaultFormatter and append the result to the context as `text`.
  17538. // Handy for adding prefix or suffix while keeping default number
  17539. // formatting.
  17540. var labelFormatter = function (ctx) {
  17541. if (labelOptions.formatter) {
  17542. return labelOptions.formatter.call(ctx,
  17543. ctx);
  17544. }
  17545. if (labelOptions.format) {
  17546. ctx.text = axis.defaultLabelFormatter.call(ctx);
  17547. return F.format(labelOptions.format, ctx, chart);
  17548. }
  17549. return axis.defaultLabelFormatter.call(ctx, ctx);
  17550. };
  17551. var str = labelFormatter.call(ctx,
  17552. ctx);
  17553. // Set up conditional formatting based on the format list if existing.
  17554. var list = dateTimeLabelFormats && dateTimeLabelFormats.list;
  17555. if (list) {
  17556. tick.shortenLabel = function () {
  17557. for (i = 0; i < list.length; i++) {
  17558. extend(ctx, { dateTimeLabelFormat: list[i] });
  17559. label.attr({
  17560. text: labelFormatter.call(ctx, ctx)
  17561. });
  17562. if (label.getBBox().width <
  17563. axis.getSlotWidth(tick) - 2 *
  17564. labelOptions.padding) {
  17565. return;
  17566. }
  17567. }
  17568. label.attr({
  17569. text: ''
  17570. });
  17571. };
  17572. }
  17573. else {
  17574. // #15692
  17575. tick.shortenLabel = void 0;
  17576. }
  17577. // Call only after first render
  17578. if (animateLabels && axis._addedPlotLB) {
  17579. tick.moveLabel(str, labelOptions);
  17580. }
  17581. // First call
  17582. if (!defined(label) && !tick.movedLabel) {
  17583. /**
  17584. * The rendered text label of the tick.
  17585. * @name Highcharts.Tick#label
  17586. * @type {Highcharts.SVGElement|undefined}
  17587. */
  17588. tick.label = label = tick.createLabel({ x: 0, y: 0 }, str, labelOptions);
  17589. // Base value to detect change for new calls to getBBox
  17590. tick.rotation = 0;
  17591. // update
  17592. }
  17593. else if (label && label.textStr !== str && !animateLabels) {
  17594. // When resetting text, also reset the width if dynamically set
  17595. // (#8809)
  17596. if (label.textWidth &&
  17597. !labelOptions.style.width &&
  17598. !label.styles.width) {
  17599. label.css({ width: null });
  17600. }
  17601. label.attr({ text: str });
  17602. label.textPxLength = label.getBBox().width;
  17603. }
  17604. };
  17605. /**
  17606. * Render and return the label of the tick.
  17607. *
  17608. * @private
  17609. * @function Highcharts.Tick#createLabel
  17610. * @param {Highcharts.PositionObject} xy
  17611. * @param {string} str
  17612. * @param {Highcharts.XAxisLabelsOptions} labelOptions
  17613. * @return {Highcharts.SVGElement|undefined}
  17614. */
  17615. Tick.prototype.createLabel = function (xy, str, labelOptions) {
  17616. var axis = this.axis,
  17617. chart = axis.chart,
  17618. label = defined(str) && labelOptions.enabled ?
  17619. chart.renderer
  17620. .text(str,
  17621. xy.x,
  17622. xy.y,
  17623. labelOptions.useHTML)
  17624. .add(axis.labelGroup) :
  17625. null;
  17626. // Un-rotated length
  17627. if (label) {
  17628. // Without position absolute, IE export sometimes is wrong
  17629. if (!chart.styledMode) {
  17630. label.css(merge(labelOptions.style));
  17631. }
  17632. label.textPxLength = label.getBBox().width;
  17633. }
  17634. return label;
  17635. };
  17636. /**
  17637. * Destructor for the tick prototype
  17638. *
  17639. * @private
  17640. * @function Highcharts.Tick#destroy
  17641. * @return {void}
  17642. */
  17643. Tick.prototype.destroy = function () {
  17644. destroyObjectProperties(this, this.axis);
  17645. };
  17646. /**
  17647. * Gets the x and y positions for ticks in terms of pixels.
  17648. *
  17649. * @private
  17650. * @function Highcharts.Tick#getPosition
  17651. *
  17652. * @param {boolean} horiz
  17653. * Whether the tick is on an horizontal axis or not.
  17654. *
  17655. * @param {number} tickPos
  17656. * Position of the tick.
  17657. *
  17658. * @param {number} tickmarkOffset
  17659. * Tickmark offset for all ticks.
  17660. *
  17661. * @param {boolean} [old]
  17662. * Whether the axis has changed or not.
  17663. *
  17664. * @return {Highcharts.PositionObject}
  17665. * The tick position.
  17666. *
  17667. * @fires Highcharts.Tick#event:afterGetPosition
  17668. */
  17669. Tick.prototype.getPosition = function (horiz, tickPos, tickmarkOffset, old) {
  17670. var axis = this.axis,
  17671. chart = axis.chart,
  17672. cHeight = (old && chart.oldChartHeight) || chart.chartHeight,
  17673. pos = {
  17674. x: horiz ?
  17675. correctFloat(axis.translate(tickPos + tickmarkOffset,
  17676. null,
  17677. null,
  17678. old) +
  17679. axis.transB) :
  17680. (axis.left +
  17681. axis.offset +
  17682. (axis.opposite ?
  17683. (((old && chart.oldChartWidth) ||
  17684. chart.chartWidth) -
  17685. axis.right -
  17686. axis.left) :
  17687. 0)),
  17688. y: horiz ?
  17689. (cHeight -
  17690. axis.bottom +
  17691. axis.offset -
  17692. (axis.opposite ? axis.height : 0)) :
  17693. correctFloat(cHeight -
  17694. axis.translate(tickPos + tickmarkOffset,
  17695. null,
  17696. null,
  17697. old) -
  17698. axis.transB)
  17699. };
  17700. // Chrome workaround for #10516
  17701. pos.y = clamp(pos.y, -1e5, 1e5);
  17702. fireEvent(this, 'afterGetPosition', { pos: pos });
  17703. return pos;
  17704. };
  17705. /**
  17706. * Get the x, y position of the tick label
  17707. *
  17708. * @private
  17709. * @return {Highcharts.PositionObject}
  17710. */
  17711. Tick.prototype.getLabelPosition = function (x, y, label, horiz, labelOptions, tickmarkOffset, index, step) {
  17712. var axis = this.axis,
  17713. transA = axis.transA,
  17714. reversed = ( // #7911
  17715. axis.isLinked && axis.linkedParent ?
  17716. axis.linkedParent.reversed :
  17717. axis.reversed),
  17718. staggerLines = axis.staggerLines,
  17719. rotCorr = axis.tickRotCorr || { x: 0,
  17720. y: 0 },
  17721. // Adjust for label alignment if we use reserveSpace: true (#5286)
  17722. labelOffsetCorrection = (!horiz && !axis.reserveSpaceDefault ?
  17723. -axis.labelOffset * (axis.labelAlign === 'center' ? 0.5 : 1) :
  17724. 0),
  17725. pos = {};
  17726. var yOffset = labelOptions.y,
  17727. line;
  17728. if (!defined(yOffset)) {
  17729. if (axis.side === 0) {
  17730. yOffset = label.rotation ? -8 : -label.getBBox().height;
  17731. }
  17732. else if (axis.side === 2) {
  17733. yOffset = rotCorr.y + 8;
  17734. }
  17735. else {
  17736. // #3140, #3140
  17737. yOffset = Math.cos(label.rotation * deg2rad) *
  17738. (rotCorr.y - label.getBBox(false, 0).height / 2);
  17739. }
  17740. }
  17741. x = x +
  17742. labelOptions.x +
  17743. labelOffsetCorrection +
  17744. rotCorr.x -
  17745. (tickmarkOffset && horiz ?
  17746. tickmarkOffset * transA * (reversed ? -1 : 1) :
  17747. 0);
  17748. y = y + yOffset - (tickmarkOffset && !horiz ?
  17749. tickmarkOffset * transA * (reversed ? 1 : -1) : 0);
  17750. // Correct for staggered labels
  17751. if (staggerLines) {
  17752. line = (index / (step || 1) % staggerLines);
  17753. if (axis.opposite) {
  17754. line = staggerLines - line - 1;
  17755. }
  17756. y += line * (axis.labelOffset / staggerLines);
  17757. }
  17758. pos.x = x;
  17759. pos.y = Math.round(y);
  17760. fireEvent(this, 'afterGetLabelPosition', { pos: pos, tickmarkOffset: tickmarkOffset, index: index });
  17761. return pos;
  17762. };
  17763. /**
  17764. * Get the offset height or width of the label
  17765. *
  17766. * @private
  17767. * @function Highcharts.Tick#getLabelSize
  17768. * @return {number}
  17769. */
  17770. Tick.prototype.getLabelSize = function () {
  17771. return this.label ?
  17772. this.label.getBBox()[this.axis.horiz ? 'height' : 'width'] :
  17773. 0;
  17774. };
  17775. /**
  17776. * Extendible method to return the path of the marker
  17777. *
  17778. * @private
  17779. *
  17780. */
  17781. Tick.prototype.getMarkPath = function (x, y, tickLength, tickWidth, horiz, renderer) {
  17782. return renderer.crispLine([[
  17783. 'M',
  17784. x,
  17785. y
  17786. ], [
  17787. 'L',
  17788. x + (horiz ? 0 : -tickLength),
  17789. y + (horiz ? tickLength : 0)
  17790. ]], tickWidth);
  17791. };
  17792. /**
  17793. * Handle the label overflow by adjusting the labels to the left and right
  17794. * edge, or hide them if they collide into the neighbour label.
  17795. *
  17796. * @private
  17797. * @function Highcharts.Tick#handleOverflow
  17798. * @param {Highcharts.PositionObject} xy
  17799. * @return {void}
  17800. */
  17801. Tick.prototype.handleOverflow = function (xy) {
  17802. var tick = this,
  17803. axis = this.axis,
  17804. labelOptions = axis.options.labels,
  17805. pxPos = xy.x,
  17806. chartWidth = axis.chart.chartWidth,
  17807. spacing = axis.chart.spacing,
  17808. leftBound = pick(axis.labelLeft,
  17809. Math.min(axis.pos,
  17810. spacing[3])),
  17811. rightBound = pick(axis.labelRight,
  17812. Math.max(!axis.isRadial ? axis.pos + axis.len : 0,
  17813. chartWidth - spacing[1])),
  17814. label = this.label,
  17815. rotation = this.rotation,
  17816. factor = {
  17817. left: 0,
  17818. center: 0.5,
  17819. right: 1
  17820. }[axis.labelAlign || label.attr('align')],
  17821. labelWidth = label.getBBox().width,
  17822. slotWidth = axis.getSlotWidth(tick),
  17823. xCorrection = factor,
  17824. css = {};
  17825. var modifiedSlotWidth = slotWidth,
  17826. goRight = 1,
  17827. leftPos,
  17828. rightPos,
  17829. textWidth;
  17830. // Check if the label overshoots the chart spacing box. If it does, move
  17831. // it. If it now overshoots the slotWidth, add ellipsis.
  17832. if (!rotation && labelOptions.overflow === 'justify') {
  17833. leftPos = pxPos - factor * labelWidth;
  17834. rightPos = pxPos + (1 - factor) * labelWidth;
  17835. if (leftPos < leftBound) {
  17836. modifiedSlotWidth =
  17837. xy.x + modifiedSlotWidth * (1 - factor) - leftBound;
  17838. }
  17839. else if (rightPos > rightBound) {
  17840. modifiedSlotWidth =
  17841. rightBound - xy.x + modifiedSlotWidth * factor;
  17842. goRight = -1;
  17843. }
  17844. modifiedSlotWidth = Math.min(slotWidth, modifiedSlotWidth); // #4177
  17845. if (modifiedSlotWidth < slotWidth && axis.labelAlign === 'center') {
  17846. xy.x += (goRight *
  17847. (slotWidth -
  17848. modifiedSlotWidth -
  17849. xCorrection * (slotWidth - Math.min(labelWidth, modifiedSlotWidth))));
  17850. }
  17851. // If the label width exceeds the available space, set a text width
  17852. // to be picked up below. Also, if a width has been set before, we
  17853. // need to set a new one because the reported labelWidth will be
  17854. // limited by the box (#3938).
  17855. if (labelWidth > modifiedSlotWidth ||
  17856. (axis.autoRotation && (label.styles || {}).width)) {
  17857. textWidth = modifiedSlotWidth;
  17858. }
  17859. // Add ellipsis to prevent rotated labels to be clipped against the edge
  17860. // of the chart
  17861. }
  17862. else if (rotation < 0 &&
  17863. pxPos - factor * labelWidth < leftBound) {
  17864. textWidth = Math.round(pxPos / Math.cos(rotation * deg2rad) - leftBound);
  17865. }
  17866. else if (rotation > 0 &&
  17867. pxPos + factor * labelWidth > rightBound) {
  17868. textWidth = Math.round((chartWidth - pxPos) /
  17869. Math.cos(rotation * deg2rad));
  17870. }
  17871. if (textWidth) {
  17872. if (tick.shortenLabel) {
  17873. tick.shortenLabel();
  17874. }
  17875. else {
  17876. css.width = Math.floor(textWidth) + 'px';
  17877. if (!(labelOptions.style || {}).textOverflow) {
  17878. css.textOverflow = 'ellipsis';
  17879. }
  17880. label.css(css);
  17881. }
  17882. }
  17883. };
  17884. /**
  17885. * Try to replace the label if the same one already exists.
  17886. *
  17887. * @private
  17888. * @function Highcharts.Tick#moveLabel
  17889. * @param {string} str
  17890. * @param {Highcharts.XAxisLabelsOptions} labelOptions
  17891. *
  17892. * @return {void}
  17893. */
  17894. Tick.prototype.moveLabel = function (str, labelOptions) {
  17895. var tick = this,
  17896. label = tick.label,
  17897. axis = tick.axis,
  17898. reversed = axis.reversed;
  17899. var moved = false,
  17900. labelPos,
  17901. xPos,
  17902. yPos;
  17903. if (label && label.textStr === str) {
  17904. tick.movedLabel = label;
  17905. moved = true;
  17906. delete tick.label;
  17907. }
  17908. else { // Find a label with the same string
  17909. objectEach(axis.ticks, function (currentTick) {
  17910. if (!moved &&
  17911. !currentTick.isNew &&
  17912. currentTick !== tick &&
  17913. currentTick.label &&
  17914. currentTick.label.textStr === str) {
  17915. tick.movedLabel = currentTick.label;
  17916. moved = true;
  17917. currentTick.labelPos = tick.movedLabel.xy;
  17918. delete currentTick.label;
  17919. }
  17920. });
  17921. }
  17922. // Create new label if the actual one is moved
  17923. if (!moved && (tick.labelPos || label)) {
  17924. labelPos = tick.labelPos || label.xy;
  17925. xPos = axis.horiz ?
  17926. (reversed ? 0 : axis.width + axis.left) : labelPos.x;
  17927. yPos = axis.horiz ?
  17928. labelPos.y : (reversed ? (axis.width + axis.left) : 0);
  17929. tick.movedLabel = tick.createLabel({ x: xPos, y: yPos }, str, labelOptions);
  17930. if (tick.movedLabel) {
  17931. tick.movedLabel.attr({ opacity: 0 });
  17932. }
  17933. }
  17934. };
  17935. /**
  17936. * Put everything in place
  17937. *
  17938. * @private
  17939. * @param {number} index
  17940. * @param {boolean} [old]
  17941. * Use old coordinates to prepare an animation into new position
  17942. * @param {number} [opacity]
  17943. * @return {voids}
  17944. */
  17945. Tick.prototype.render = function (index, old, opacity) {
  17946. var tick = this,
  17947. axis = tick.axis,
  17948. horiz = axis.horiz,
  17949. pos = tick.pos,
  17950. tickmarkOffset = pick(tick.tickmarkOffset,
  17951. axis.tickmarkOffset),
  17952. xy = tick.getPosition(horiz,
  17953. pos,
  17954. tickmarkOffset,
  17955. old),
  17956. x = xy.x,
  17957. y = xy.y,
  17958. reverseCrisp = ((horiz && x === axis.pos + axis.len) ||
  17959. (!horiz && y === axis.pos)) ? -1 : 1; // #1480, #1687
  17960. var labelOpacity = pick(opacity,
  17961. tick.label && tick.label.newOpacity, // #15528
  17962. 1);
  17963. opacity = pick(opacity, 1);
  17964. this.isActive = true;
  17965. // Create the grid line
  17966. this.renderGridLine(old, opacity, reverseCrisp);
  17967. // create the tick mark
  17968. this.renderMark(xy, opacity, reverseCrisp);
  17969. // the label is created on init - now move it into place
  17970. this.renderLabel(xy, old, labelOpacity, index);
  17971. tick.isNew = false;
  17972. fireEvent(this, 'afterRender');
  17973. };
  17974. /**
  17975. * Renders the gridLine.
  17976. *
  17977. * @private
  17978. * @param {boolean} old Whether or not the tick is old
  17979. * @param {number} opacity The opacity of the grid line
  17980. * @param {number} reverseCrisp Modifier for avoiding overlapping 1 or -1
  17981. * @return {void}
  17982. */
  17983. Tick.prototype.renderGridLine = function (old, opacity, reverseCrisp) {
  17984. var tick = this,
  17985. axis = tick.axis,
  17986. options = axis.options,
  17987. attribs = {},
  17988. pos = tick.pos,
  17989. type = tick.type,
  17990. tickmarkOffset = pick(tick.tickmarkOffset,
  17991. axis.tickmarkOffset),
  17992. renderer = axis.chart.renderer;
  17993. var gridLine = tick.gridLine,
  17994. gridLinePath,
  17995. gridLineWidth = options.gridLineWidth,
  17996. gridLineColor = options.gridLineColor,
  17997. dashStyle = options.gridLineDashStyle;
  17998. if (tick.type === 'minor') {
  17999. gridLineWidth = options.minorGridLineWidth;
  18000. gridLineColor = options.minorGridLineColor;
  18001. dashStyle = options.minorGridLineDashStyle;
  18002. }
  18003. if (!gridLine) {
  18004. if (!axis.chart.styledMode) {
  18005. attribs.stroke = gridLineColor;
  18006. attribs['stroke-width'] = gridLineWidth || 0;
  18007. attribs.dashstyle = dashStyle;
  18008. }
  18009. if (!type) {
  18010. attribs.zIndex = 1;
  18011. }
  18012. if (old) {
  18013. opacity = 0;
  18014. }
  18015. /**
  18016. * The rendered grid line of the tick.
  18017. * @name Highcharts.Tick#gridLine
  18018. * @type {Highcharts.SVGElement|undefined}
  18019. */
  18020. tick.gridLine = gridLine = renderer.path()
  18021. .attr(attribs)
  18022. .addClass('highcharts-' + (type ? type + '-' : '') + 'grid-line')
  18023. .add(axis.gridGroup);
  18024. }
  18025. if (gridLine) {
  18026. gridLinePath = axis.getPlotLinePath({
  18027. value: pos + tickmarkOffset,
  18028. lineWidth: gridLine.strokeWidth() * reverseCrisp,
  18029. force: 'pass',
  18030. old: old
  18031. });
  18032. // If the parameter 'old' is set, the current call will be followed
  18033. // by another call, therefore do not do any animations this time
  18034. if (gridLinePath) {
  18035. gridLine[old || tick.isNew ? 'attr' : 'animate']({
  18036. d: gridLinePath,
  18037. opacity: opacity
  18038. });
  18039. }
  18040. }
  18041. };
  18042. /**
  18043. * Renders the tick mark.
  18044. *
  18045. * @private
  18046. * @param {Highcharts.PositionObject} xy The position vector of the mark
  18047. * @param {number} opacity The opacity of the mark
  18048. * @param {number} reverseCrisp Modifier for avoiding overlapping 1 or -1
  18049. * @return {void}
  18050. */
  18051. Tick.prototype.renderMark = function (xy, opacity, reverseCrisp) {
  18052. var tick = this, axis = tick.axis, options = axis.options, renderer = axis.chart.renderer, type = tick.type, tickSize = axis.tickSize(type ? type + 'Tick' : 'tick'), x = xy.x, y = xy.y, tickWidth = pick(options[type !== 'minor' ? 'tickWidth' : 'minorTickWidth'], !type && axis.isXAxis ? 1 : 0), // X axis defaults to 1
  18053. tickColor = options[type !== 'minor' ? 'tickColor' : 'minorTickColor'];
  18054. var mark = tick.mark;
  18055. var isNewMark = !mark;
  18056. if (tickSize) {
  18057. // negate the length
  18058. if (axis.opposite) {
  18059. tickSize[0] = -tickSize[0];
  18060. }
  18061. // First time, create it
  18062. if (!mark) {
  18063. /**
  18064. * The rendered mark of the tick.
  18065. * @name Highcharts.Tick#mark
  18066. * @type {Highcharts.SVGElement|undefined}
  18067. */
  18068. tick.mark = mark = renderer.path()
  18069. .addClass('highcharts-' + (type ? type + '-' : '') + 'tick')
  18070. .add(axis.axisGroup);
  18071. if (!axis.chart.styledMode) {
  18072. mark.attr({
  18073. stroke: tickColor,
  18074. 'stroke-width': tickWidth
  18075. });
  18076. }
  18077. }
  18078. mark[isNewMark ? 'attr' : 'animate']({
  18079. d: tick.getMarkPath(x, y, tickSize[0], mark.strokeWidth() * reverseCrisp, axis.horiz, renderer),
  18080. opacity: opacity
  18081. });
  18082. }
  18083. };
  18084. /**
  18085. * Renders the tick label.
  18086. * Note: The label should already be created in init(), so it should only
  18087. * have to be moved into place.
  18088. *
  18089. * @private
  18090. * @param {Highcharts.PositionObject} xy The position vector of the label
  18091. * @param {boolean} old Whether or not the tick is old
  18092. * @param {number} opacity The opacity of the label
  18093. * @param {number} index The index of the tick
  18094. * @return {void}
  18095. */
  18096. Tick.prototype.renderLabel = function (xy, old, opacity, index) {
  18097. var tick = this,
  18098. axis = tick.axis,
  18099. horiz = axis.horiz,
  18100. options = axis.options,
  18101. label = tick.label,
  18102. labelOptions = options.labels,
  18103. step = labelOptions.step,
  18104. tickmarkOffset = pick(tick.tickmarkOffset,
  18105. axis.tickmarkOffset),
  18106. x = xy.x,
  18107. y = xy.y;
  18108. var show = true;
  18109. if (label && isNumber(x)) {
  18110. label.xy = xy = tick.getLabelPosition(x, y, label, horiz, labelOptions, tickmarkOffset, index, step);
  18111. // Apply show first and show last. If the tick is both first and
  18112. // last, it is a single centered tick, in which case we show the
  18113. // label anyway (#2100).
  18114. if ((tick.isFirst &&
  18115. !tick.isLast &&
  18116. !options.showFirstLabel) ||
  18117. (tick.isLast &&
  18118. !tick.isFirst &&
  18119. !options.showLastLabel)) {
  18120. show = false;
  18121. // Handle label overflow and show or hide accordingly
  18122. }
  18123. else if (horiz &&
  18124. !labelOptions.step &&
  18125. !labelOptions.rotation &&
  18126. !old &&
  18127. opacity !== 0) {
  18128. tick.handleOverflow(xy);
  18129. }
  18130. // apply step
  18131. if (step && index % step) {
  18132. // show those indices dividable by step
  18133. show = false;
  18134. }
  18135. // Set the new position, and show or hide
  18136. if (show && isNumber(xy.y)) {
  18137. xy.opacity = opacity;
  18138. label[tick.isNewLabel ? 'attr' : 'animate'](xy);
  18139. tick.isNewLabel = false;
  18140. }
  18141. else {
  18142. label.attr('y', -9999); // #1338
  18143. tick.isNewLabel = true;
  18144. }
  18145. }
  18146. };
  18147. /**
  18148. * Replace labels with the moved ones to perform animation. Additionally
  18149. * destroy unused labels.
  18150. *
  18151. * @private
  18152. * @function Highcharts.Tick#replaceMovedLabel
  18153. * @return {void}
  18154. */
  18155. Tick.prototype.replaceMovedLabel = function () {
  18156. var tick = this,
  18157. label = tick.label,
  18158. axis = tick.axis,
  18159. reversed = axis.reversed;
  18160. var x,
  18161. y;
  18162. // Animate and destroy
  18163. if (label && !tick.isNew) {
  18164. x = axis.horiz ? (reversed ? axis.left : axis.width + axis.left) : label.xy.x;
  18165. y = axis.horiz ?
  18166. label.xy.y :
  18167. (reversed ? axis.width + axis.top : axis.top);
  18168. label.animate({ x: x, y: y, opacity: 0 }, void 0, label.destroy);
  18169. delete tick.label;
  18170. }
  18171. axis.isDirty = true;
  18172. tick.label = tick.movedLabel;
  18173. delete tick.movedLabel;
  18174. };
  18175. return Tick;
  18176. }());
  18177. /* *
  18178. *
  18179. * Default Export
  18180. *
  18181. * */
  18182. /* *
  18183. *
  18184. * API Declarations
  18185. *
  18186. * */
  18187. /**
  18188. * Optional parameters for the tick.
  18189. * @private
  18190. * @interface Highcharts.TickParametersObject
  18191. */ /**
  18192. * Set category for the tick.
  18193. * @name Highcharts.TickParametersObject#category
  18194. * @type {string|undefined}
  18195. */ /**
  18196. * @name Highcharts.TickParametersObject#options
  18197. * @type {Highcharts.Dictionary<any>|undefined}
  18198. */ /**
  18199. * Set tickmarkOffset for the tick.
  18200. * @name Highcharts.TickParametersObject#tickmarkOffset
  18201. * @type {number|undefined}
  18202. */
  18203. /**
  18204. * Additonal time tick information.
  18205. *
  18206. * @interface Highcharts.TimeTicksInfoObject
  18207. * @extends Highcharts.TimeNormalizedObject
  18208. */ /**
  18209. * @name Highcharts.TimeTicksInfoObject#higherRanks
  18210. * @type {Array<string>}
  18211. */ /**
  18212. * @name Highcharts.TimeTicksInfoObject#totalRange
  18213. * @type {number}
  18214. */
  18215. ''; // detach doclets above
  18216. return Tick;
  18217. });
  18218. _registerModule(_modules, 'Core/Axis/Axis.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Axis/AxisDefaults.js'], _modules['Core/Color/Color.js'], _modules['Core/Foundation.js'], _modules['Core/Globals.js'], _modules['Core/Color/Palette.js'], _modules['Core/DefaultOptions.js'], _modules['Core/Axis/Tick.js'], _modules['Core/Utilities.js']], function (A, AxisDefaults, Color, F, H, Palette, D, Tick, U) {
  18219. /* *
  18220. *
  18221. * (c) 2010-2021 Torstein Honsi
  18222. *
  18223. * License: www.highcharts.com/license
  18224. *
  18225. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  18226. *
  18227. * */
  18228. var animObject = A.animObject;
  18229. var registerEventOptions = F.registerEventOptions;
  18230. var deg2rad = H.deg2rad;
  18231. var defaultOptions = D.defaultOptions;
  18232. var arrayMax = U.arrayMax,
  18233. arrayMin = U.arrayMin,
  18234. clamp = U.clamp,
  18235. correctFloat = U.correctFloat,
  18236. defined = U.defined,
  18237. destroyObjectProperties = U.destroyObjectProperties,
  18238. erase = U.erase,
  18239. error = U.error,
  18240. extend = U.extend,
  18241. fireEvent = U.fireEvent,
  18242. getMagnitude = U.getMagnitude,
  18243. isArray = U.isArray,
  18244. isNumber = U.isNumber,
  18245. isString = U.isString,
  18246. merge = U.merge,
  18247. normalizeTickInterval = U.normalizeTickInterval,
  18248. objectEach = U.objectEach,
  18249. pick = U.pick,
  18250. relativeLength = U.relativeLength,
  18251. removeEvent = U.removeEvent,
  18252. splat = U.splat,
  18253. syncTimeout = U.syncTimeout;
  18254. /* *
  18255. *
  18256. * Class
  18257. *
  18258. * */
  18259. /**
  18260. * Create a new axis object. Called internally when instanciating a new chart or
  18261. * adding axes by {@link Highcharts.Chart#addAxis}.
  18262. *
  18263. * A chart can have from 0 axes (pie chart) to multiples. In a normal, single
  18264. * series cartesian chart, there is one X axis and one Y axis.
  18265. *
  18266. * The X axis or axes are referenced by {@link Highcharts.Chart.xAxis}, which is
  18267. * an array of Axis objects. If there is only one axis, it can be referenced
  18268. * through `chart.xAxis[0]`, and multiple axes have increasing indices. The same
  18269. * pattern goes for Y axes.
  18270. *
  18271. * If you need to get the axes from a series object, use the `series.xAxis` and
  18272. * `series.yAxis` properties. These are not arrays, as one series can only be
  18273. * associated to one X and one Y axis.
  18274. *
  18275. * A third way to reference the axis programmatically is by `id`. Add an `id` in
  18276. * the axis configuration options, and get the axis by
  18277. * {@link Highcharts.Chart#get}.
  18278. *
  18279. * Configuration options for the axes are given in options.xAxis and
  18280. * options.yAxis.
  18281. *
  18282. * @class
  18283. * @name Highcharts.Axis
  18284. *
  18285. * @param {Highcharts.Chart} chart
  18286. * The Chart instance to apply the axis on.
  18287. *
  18288. * @param {Highcharts.AxisOptions} userOptions
  18289. * Axis options.
  18290. */
  18291. var Axis = /** @class */ (function () {
  18292. /* *
  18293. *
  18294. * Constructors
  18295. *
  18296. * */
  18297. function Axis(chart, userOptions) {
  18298. this.alternateBands = void 0;
  18299. this.bottom = void 0;
  18300. this.categories = void 0;
  18301. this.chart = void 0;
  18302. this.closestPointRange = void 0;
  18303. this.coll = void 0;
  18304. this.eventOptions = void 0;
  18305. this.hasNames = void 0;
  18306. this.hasVisibleSeries = void 0;
  18307. this.height = void 0;
  18308. this.isLinked = void 0;
  18309. this.labelEdge = void 0; // @todo
  18310. this.labelFormatter = void 0;
  18311. this.left = void 0;
  18312. this.len = void 0;
  18313. this.max = void 0;
  18314. this.maxLabelLength = void 0;
  18315. this.min = void 0;
  18316. this.minorTickInterval = void 0;
  18317. this.minorTicks = void 0;
  18318. this.minPixelPadding = void 0;
  18319. this.names = void 0;
  18320. this.offset = void 0;
  18321. this.options = void 0;
  18322. this.overlap = void 0;
  18323. this.paddedTicks = void 0;
  18324. this.plotLinesAndBands = void 0;
  18325. this.plotLinesAndBandsGroups = void 0;
  18326. this.pointRange = void 0;
  18327. this.pointRangePadding = void 0;
  18328. this.pos = void 0;
  18329. this.positiveValuesOnly = void 0;
  18330. this.right = void 0;
  18331. this.series = void 0;
  18332. this.side = void 0;
  18333. this.tickAmount = void 0;
  18334. this.tickInterval = void 0;
  18335. this.tickmarkOffset = void 0;
  18336. this.tickPositions = void 0;
  18337. this.tickRotCorr = void 0;
  18338. this.ticks = void 0;
  18339. this.top = void 0;
  18340. this.transA = void 0;
  18341. this.transB = void 0;
  18342. this.translationSlope = void 0;
  18343. this.userOptions = void 0;
  18344. this.visible = void 0;
  18345. this.width = void 0;
  18346. this.zoomEnabled = void 0;
  18347. this.init(chart, userOptions);
  18348. }
  18349. /* *
  18350. *
  18351. * Functions
  18352. *
  18353. * */
  18354. /**
  18355. * Overrideable function to initialize the axis.
  18356. *
  18357. * @see {@link Axis}
  18358. *
  18359. * @function Highcharts.Axis#init
  18360. *
  18361. * @param {Highcharts.Chart} chart
  18362. * The Chart instance to apply the axis on.
  18363. *
  18364. * @param {AxisOptions} userOptions
  18365. * Axis options.
  18366. *
  18367. * @fires Highcharts.Axis#event:afterInit
  18368. * @fires Highcharts.Axis#event:init
  18369. */
  18370. Axis.prototype.init = function (chart, userOptions) {
  18371. var isXAxis = userOptions.isX,
  18372. axis = this;
  18373. /**
  18374. * The Chart that the axis belongs to.
  18375. *
  18376. * @name Highcharts.Axis#chart
  18377. * @type {Highcharts.Chart}
  18378. */
  18379. axis.chart = chart;
  18380. /**
  18381. * Whether the axis is horizontal.
  18382. *
  18383. * @name Highcharts.Axis#horiz
  18384. * @type {boolean|undefined}
  18385. */
  18386. axis.horiz = chart.inverted && !axis.isZAxis ? !isXAxis : isXAxis;
  18387. /**
  18388. * Whether the axis is the x-axis.
  18389. *
  18390. * @name Highcharts.Axis#isXAxis
  18391. * @type {boolean|undefined}
  18392. */
  18393. axis.isXAxis = isXAxis;
  18394. /**
  18395. * The collection where the axis belongs, for example `xAxis`, `yAxis`
  18396. * or `colorAxis`. Corresponds to properties on Chart, for example
  18397. * {@link Chart.xAxis}.
  18398. *
  18399. * @name Highcharts.Axis#coll
  18400. * @type {string}
  18401. */
  18402. axis.coll = axis.coll || (isXAxis ? 'xAxis' : 'yAxis');
  18403. fireEvent(this, 'init', { userOptions: userOptions });
  18404. axis.opposite = pick(userOptions.opposite, axis.opposite); // needed in setOptions
  18405. /**
  18406. * The side on which the axis is rendered. 0 is top, 1 is right, 2
  18407. * is bottom and 3 is left.
  18408. *
  18409. * @name Highcharts.Axis#side
  18410. * @type {number}
  18411. */
  18412. axis.side = pick(userOptions.side, axis.side, (axis.horiz ?
  18413. (axis.opposite ? 0 : 2) : // top : bottom
  18414. (axis.opposite ? 1 : 3)) // right : left
  18415. );
  18416. /**
  18417. * Current options for the axis after merge of defaults and user's
  18418. * options.
  18419. *
  18420. * @name Highcharts.Axis#options
  18421. * @type {Highcharts.AxisOptions}
  18422. */
  18423. axis.setOptions(userOptions);
  18424. var options = this.options,
  18425. labelsOptions = options.labels,
  18426. type = options.type;
  18427. /**
  18428. * User's options for this axis without defaults.
  18429. *
  18430. * @name Highcharts.Axis#userOptions
  18431. * @type {Highcharts.AxisOptions}
  18432. */
  18433. axis.userOptions = userOptions;
  18434. axis.minPixelPadding = 0;
  18435. /**
  18436. * Whether the axis is reversed. Based on the `axis.reversed`,
  18437. * option, but inverted charts have reversed xAxis by default.
  18438. *
  18439. * @name Highcharts.Axis#reversed
  18440. * @type {boolean}
  18441. */
  18442. axis.reversed = pick(options.reversed, axis.reversed);
  18443. axis.visible = options.visible;
  18444. axis.zoomEnabled = options.zoomEnabled;
  18445. // Initial categories
  18446. axis.hasNames =
  18447. type === 'category' || options.categories === true;
  18448. /**
  18449. * If categories are present for the axis, names are used instead of
  18450. * numbers for that axis.
  18451. *
  18452. * Since Highcharts 3.0, categories can also be extracted by giving each
  18453. * point a name and setting axis type to `category`. However, if you
  18454. * have multiple series, best practice remains defining the `categories`
  18455. * array.
  18456. *
  18457. * @see [xAxis.categories](/highcharts/xAxis.categories)
  18458. *
  18459. * @name Highcharts.Axis#categories
  18460. * @type {Array<string>}
  18461. * @readonly
  18462. */
  18463. axis.categories = options.categories || axis.hasNames;
  18464. if (!axis.names) { // Preserve on update (#3830)
  18465. axis.names = [];
  18466. axis.names.keys = {};
  18467. }
  18468. // Placeholder for plotlines and plotbands groups
  18469. axis.plotLinesAndBandsGroups = {};
  18470. // Shorthand types
  18471. axis.positiveValuesOnly = !!axis.logarithmic;
  18472. // Flag, if axis is linked to another axis
  18473. axis.isLinked = defined(options.linkedTo);
  18474. /**
  18475. * List of major ticks mapped by postition on axis.
  18476. *
  18477. * @see {@link Highcharts.Tick}
  18478. *
  18479. * @name Highcharts.Axis#ticks
  18480. * @type {Highcharts.Dictionary<Highcharts.Tick>}
  18481. */
  18482. axis.ticks = {};
  18483. axis.labelEdge = [];
  18484. /**
  18485. * List of minor ticks mapped by position on the axis.
  18486. *
  18487. * @see {@link Highcharts.Tick}
  18488. *
  18489. * @name Highcharts.Axis#minorTicks
  18490. * @type {Highcharts.Dictionary<Highcharts.Tick>}
  18491. */
  18492. axis.minorTicks = {};
  18493. // List of plotLines/Bands
  18494. axis.plotLinesAndBands = [];
  18495. // Alternate bands
  18496. axis.alternateBands = {};
  18497. // Axis metrics
  18498. axis.len = 0;
  18499. axis.minRange = axis.userMinRange = options.minRange || options.maxZoom;
  18500. axis.range = options.range;
  18501. axis.offset = options.offset || 0;
  18502. /**
  18503. * The maximum value of the axis. In a logarithmic axis, this is the
  18504. * logarithm of the real value, and the real value can be obtained from
  18505. * {@link Axis#getExtremes}.
  18506. *
  18507. * @name Highcharts.Axis#max
  18508. * @type {number|null}
  18509. */
  18510. axis.max = null;
  18511. /**
  18512. * The minimum value of the axis. In a logarithmic axis, this is the
  18513. * logarithm of the real value, and the real value can be obtained from
  18514. * {@link Axis#getExtremes}.
  18515. *
  18516. * @name Highcharts.Axis#min
  18517. * @type {number|null}
  18518. */
  18519. axis.min = null;
  18520. /**
  18521. * The processed crosshair options.
  18522. *
  18523. * @name Highcharts.Axis#crosshair
  18524. * @type {boolean|Highcharts.AxisCrosshairOptions}
  18525. */
  18526. var crosshair = pick(options.crosshair,
  18527. splat(chart.options.tooltip.crosshairs)[isXAxis ? 0 : 1]);
  18528. axis.crosshair = crosshair === true ? {} : crosshair;
  18529. // Register. Don't add it again on Axis.update().
  18530. if (chart.axes.indexOf(axis) === -1) { //
  18531. if (isXAxis) { // #2713
  18532. chart.axes.splice(chart.xAxis.length, 0, axis);
  18533. }
  18534. else {
  18535. chart.axes.push(axis);
  18536. }
  18537. chart[axis.coll].push(axis);
  18538. }
  18539. /**
  18540. * All series associated to the axis.
  18541. *
  18542. * @name Highcharts.Axis#series
  18543. * @type {Array<Highcharts.Series>}
  18544. */
  18545. axis.series = axis.series || []; // populated by Series
  18546. // Reversed axis
  18547. if (chart.inverted &&
  18548. !axis.isZAxis &&
  18549. isXAxis &&
  18550. typeof axis.reversed === 'undefined') {
  18551. axis.reversed = true;
  18552. }
  18553. axis.labelRotation = isNumber(labelsOptions.rotation) ?
  18554. labelsOptions.rotation :
  18555. void 0;
  18556. // Register event listeners
  18557. registerEventOptions(axis, options);
  18558. fireEvent(this, 'afterInit');
  18559. };
  18560. /**
  18561. * Merge and set options.
  18562. *
  18563. * @private
  18564. * @function Highcharts.Axis#setOptions
  18565. *
  18566. * @param {Highcharts.AxisOptions} userOptions
  18567. * Axis options.
  18568. *
  18569. * @fires Highcharts.Axis#event:afterSetOptions
  18570. */
  18571. Axis.prototype.setOptions = function (userOptions) {
  18572. this.options = merge(AxisDefaults.defaultXAxisOptions, (this.coll === 'yAxis') && AxisDefaults.defaultYAxisOptions, [
  18573. AxisDefaults.defaultTopAxisOptions,
  18574. AxisDefaults.defaultRightAxisOptions,
  18575. AxisDefaults.defaultBottomAxisOptions,
  18576. AxisDefaults.defaultLeftAxisOptions
  18577. ][this.side], merge(
  18578. // if set in setOptions (#1053):
  18579. defaultOptions[this.coll], userOptions));
  18580. fireEvent(this, 'afterSetOptions', { userOptions: userOptions });
  18581. };
  18582. /**
  18583. * The default label formatter. The context is a special config object for
  18584. * the label. In apps, use the
  18585. * [labels.formatter](https://api.highcharts.com/highcharts/xAxis.labels.formatter)
  18586. * instead, except when a modification is needed.
  18587. *
  18588. * @function Highcharts.Axis#defaultLabelFormatter
  18589. *
  18590. * @param {Highcharts.AxisLabelsFormatterContextObject} this
  18591. * Formatter context of axis label.
  18592. *
  18593. * @param {Highcharts.AxisLabelsFormatterContextObject} [ctx]
  18594. * Formatter context of axis label.
  18595. *
  18596. * @return {string}
  18597. * The formatted label content.
  18598. */
  18599. Axis.prototype.defaultLabelFormatter = function (ctx) {
  18600. var axis = this.axis,
  18601. chart = this.chart,
  18602. numberFormatter = chart.numberFormatter,
  18603. value = isNumber(this.value) ? this.value : NaN,
  18604. time = axis.chart.time,
  18605. categories = axis.categories,
  18606. dateTimeLabelFormat = this.dateTimeLabelFormat,
  18607. lang = defaultOptions.lang,
  18608. numericSymbols = lang.numericSymbols,
  18609. numSymMagnitude = lang.numericSymbolMagnitude || 1000,
  18610. // make sure the same symbol is added for all labels on a linear
  18611. // axis
  18612. numericSymbolDetector = axis.logarithmic ?
  18613. Math.abs(value) :
  18614. axis.tickInterval;
  18615. var i = numericSymbols && numericSymbols.length,
  18616. multi,
  18617. ret;
  18618. if (categories) {
  18619. ret = "" + this.value;
  18620. }
  18621. else if (dateTimeLabelFormat) { // datetime axis
  18622. ret = time.dateFormat(dateTimeLabelFormat, value);
  18623. }
  18624. else if (i && numericSymbolDetector >= 1000) {
  18625. // Decide whether we should add a numeric symbol like k (thousands)
  18626. // or M (millions). If we are to enable this in tooltip or other
  18627. // places as well, we can move this logic to the numberFormatter and
  18628. // enable it by a parameter.
  18629. while (i-- && typeof ret === 'undefined') {
  18630. multi = Math.pow(numSymMagnitude, i + 1);
  18631. if (
  18632. // Only accept a numeric symbol when the distance is more
  18633. // than a full unit. So for example if the symbol is k, we
  18634. // don't accept numbers like 0.5k.
  18635. numericSymbolDetector >= multi &&
  18636. // Accept one decimal before the symbol. Accepts 0.5k but
  18637. // not 0.25k. How does this work with the previous?
  18638. (value * 10) % multi === 0 &&
  18639. numericSymbols[i] !== null &&
  18640. value !== 0) { // #5480
  18641. ret = numberFormatter(value / multi, -1) + numericSymbols[i];
  18642. }
  18643. }
  18644. }
  18645. if (typeof ret === 'undefined') {
  18646. if (Math.abs(value) >= 10000) { // add thousands separators
  18647. ret = numberFormatter(value, -1);
  18648. }
  18649. else { // small numbers
  18650. ret = numberFormatter(value, -1, void 0, ''); // #2466
  18651. }
  18652. }
  18653. return ret;
  18654. };
  18655. /**
  18656. * Get the minimum and maximum for the series of each axis. The function
  18657. * analyzes the axis series and updates `this.dataMin` and `this.dataMax`.
  18658. *
  18659. * @private
  18660. * @function Highcharts.Axis#getSeriesExtremes
  18661. *
  18662. * @fires Highcharts.Axis#event:afterGetSeriesExtremes
  18663. * @fires Highcharts.Axis#event:getSeriesExtremes
  18664. */
  18665. Axis.prototype.getSeriesExtremes = function () {
  18666. var axis = this,
  18667. chart = axis.chart;
  18668. var xExtremes;
  18669. fireEvent(this, 'getSeriesExtremes', null, function () {
  18670. axis.hasVisibleSeries = false;
  18671. // Reset properties in case we're redrawing (#3353)
  18672. axis.dataMin = axis.dataMax = axis.threshold = null;
  18673. axis.softThreshold = !axis.isXAxis;
  18674. if (axis.stacking) {
  18675. axis.stacking.buildStacks();
  18676. }
  18677. // loop through this axis' series
  18678. axis.series.forEach(function (series) {
  18679. if (series.visible ||
  18680. !chart.options.chart.ignoreHiddenSeries) {
  18681. var seriesOptions = series.options;
  18682. var xData = void 0,
  18683. threshold = seriesOptions.threshold,
  18684. seriesDataMin = void 0,
  18685. seriesDataMax = void 0;
  18686. axis.hasVisibleSeries = true;
  18687. // Validate threshold in logarithmic axes
  18688. if (axis.positiveValuesOnly && threshold <= 0) {
  18689. threshold = null;
  18690. }
  18691. // Get dataMin and dataMax for X axes
  18692. if (axis.isXAxis) {
  18693. xData = series.xData;
  18694. if (xData.length) {
  18695. var isPositive = function (number) { return number > 0; };
  18696. xData = axis.logarithmic ?
  18697. xData.filter(axis.validatePositiveValue) :
  18698. xData;
  18699. xExtremes = series.getXExtremes(xData);
  18700. // If xData contains values which is not numbers,
  18701. // then filter them out. To prevent performance hit,
  18702. // we only do this after we have already found
  18703. // seriesDataMin because in most cases all data is
  18704. // valid. #5234.
  18705. seriesDataMin = xExtremes.min;
  18706. seriesDataMax = xExtremes.max;
  18707. if (!isNumber(seriesDataMin) &&
  18708. // #5010:
  18709. !(seriesDataMin instanceof Date)) {
  18710. xData = xData.filter(isNumber);
  18711. xExtremes = series.getXExtremes(xData);
  18712. // Do it again with valid data
  18713. seriesDataMin = xExtremes.min;
  18714. seriesDataMax = xExtremes.max;
  18715. }
  18716. if (xData.length) {
  18717. axis.dataMin = Math.min(pick(axis.dataMin, seriesDataMin), seriesDataMin);
  18718. axis.dataMax = Math.max(pick(axis.dataMax, seriesDataMax), seriesDataMax);
  18719. }
  18720. }
  18721. // Get dataMin and dataMax for Y axes, as well as handle
  18722. // stacking and processed data
  18723. }
  18724. else {
  18725. // Get this particular series extremes
  18726. var dataExtremes = series.applyExtremes();
  18727. // Get the dataMin and dataMax so far. If percentage is
  18728. // used, the min and max are always 0 and 100. If
  18729. // seriesDataMin and seriesDataMax is null, then series
  18730. // doesn't have active y data, we continue with nulls
  18731. if (isNumber(dataExtremes.dataMin)) {
  18732. seriesDataMin = dataExtremes.dataMin;
  18733. axis.dataMin = Math.min(pick(axis.dataMin, seriesDataMin), seriesDataMin);
  18734. }
  18735. if (isNumber(dataExtremes.dataMax)) {
  18736. seriesDataMax = dataExtremes.dataMax;
  18737. axis.dataMax = Math.max(pick(axis.dataMax, seriesDataMax), seriesDataMax);
  18738. }
  18739. // Adjust to threshold
  18740. if (defined(threshold)) {
  18741. axis.threshold = threshold;
  18742. }
  18743. // If any series has a hard threshold, it takes
  18744. // precedence
  18745. if (!seriesOptions.softThreshold ||
  18746. axis.positiveValuesOnly) {
  18747. axis.softThreshold = false;
  18748. }
  18749. }
  18750. }
  18751. });
  18752. });
  18753. fireEvent(this, 'afterGetSeriesExtremes');
  18754. };
  18755. /**
  18756. * Translate from axis value to pixel position on the chart, or back. Use
  18757. * the `toPixels` and `toValue` functions in applications.
  18758. *
  18759. * @private
  18760. * @function Highcharts.Axis#translate
  18761. *
  18762. * @param {number} val
  18763. * TO-DO: parameter description
  18764. *
  18765. * @param {boolean|null} [backwards]
  18766. * TO-DO: parameter description
  18767. *
  18768. * @param {boolean|null} [cvsCoord]
  18769. * TO-DO: parameter description
  18770. *
  18771. * @param {boolean|null} [old]
  18772. * TO-DO: parameter description
  18773. *
  18774. * @param {boolean} [handleLog]
  18775. * TO-DO: parameter description
  18776. *
  18777. * @param {number} [pointPlacement]
  18778. * TO-DO: parameter description
  18779. *
  18780. * @return {number|undefined}
  18781. */
  18782. Axis.prototype.translate = function (val, backwards, cvsCoord, old, handleLog, pointPlacement) {
  18783. var axis = (this.linkedParent || this), // #1417
  18784. localMin = old && axis.old ? axis.old.min : axis.min,
  18785. minPixelPadding = axis.minPixelPadding,
  18786. doPostTranslate = (axis.isOrdinal ||
  18787. axis.brokenAxis && axis.brokenAxis.hasBreaks ||
  18788. (axis.logarithmic && handleLog)) && axis.lin2val;
  18789. var sign = 1,
  18790. cvsOffset = 0,
  18791. localA = old && axis.old ? axis.old.transA : axis.transA,
  18792. returnValue = 0;
  18793. if (!localA) {
  18794. localA = axis.transA;
  18795. }
  18796. // In vertical axes, the canvas coordinates start from 0 at the top like
  18797. // in SVG.
  18798. if (cvsCoord) {
  18799. sign *= -1; // canvas coordinates inverts the value
  18800. cvsOffset = axis.len;
  18801. }
  18802. // Handle reversed axis
  18803. if (axis.reversed) {
  18804. sign *= -1;
  18805. cvsOffset -= sign * (axis.sector || axis.len);
  18806. }
  18807. // From pixels to value
  18808. if (backwards) { // reverse translation
  18809. val = val * sign + cvsOffset;
  18810. val -= minPixelPadding;
  18811. // from chart pixel to value:
  18812. returnValue = val / localA + localMin;
  18813. if (doPostTranslate) { // log and ordinal axes
  18814. returnValue = axis.lin2val(returnValue);
  18815. }
  18816. // From value to pixels
  18817. }
  18818. else {
  18819. if (doPostTranslate) { // log and ordinal axes
  18820. val = axis.val2lin(val);
  18821. }
  18822. returnValue = isNumber(localMin) ?
  18823. (sign * (val - localMin) * localA +
  18824. cvsOffset +
  18825. (sign * minPixelPadding) +
  18826. (isNumber(pointPlacement) ?
  18827. localA * pointPlacement :
  18828. 0)) :
  18829. void 0;
  18830. }
  18831. return returnValue;
  18832. };
  18833. /**
  18834. * Translate a value in terms of axis units into pixels within the chart.
  18835. *
  18836. * @function Highcharts.Axis#toPixels
  18837. *
  18838. * @param {number} value
  18839. * A value in terms of axis units.
  18840. *
  18841. * @param {boolean} paneCoordinates
  18842. * Whether to return the pixel coordinate relative to the chart or just the
  18843. * axis/pane itself.
  18844. *
  18845. * @return {number}
  18846. * Pixel position of the value on the chart or axis.
  18847. */
  18848. Axis.prototype.toPixels = function (value, paneCoordinates) {
  18849. return this.translate(value, false, !this.horiz, null, true) +
  18850. (paneCoordinates ? 0 : this.pos);
  18851. };
  18852. /**
  18853. * Translate a pixel position along the axis to a value in terms of axis
  18854. * units.
  18855. *
  18856. * @function Highcharts.Axis#toValue
  18857. *
  18858. * @param {number} pixel
  18859. * The pixel value coordinate.
  18860. *
  18861. * @param {boolean} [paneCoordinates=false]
  18862. * Whether the input pixel is relative to the chart or just the axis/pane
  18863. * itself.
  18864. *
  18865. * @return {number}
  18866. * The axis value.
  18867. */
  18868. Axis.prototype.toValue = function (pixel, paneCoordinates) {
  18869. return this.translate(pixel - (paneCoordinates ? 0 : this.pos), true, !this.horiz, null, true);
  18870. };
  18871. /**
  18872. * Create the path for a plot line that goes from the given value on
  18873. * this axis, across the plot to the opposite side. Also used internally for
  18874. * grid lines and crosshairs.
  18875. *
  18876. * @function Highcharts.Axis#getPlotLinePath
  18877. *
  18878. * @param {Highcharts.AxisPlotLinePathOptionsObject} options
  18879. * Options for the path.
  18880. *
  18881. * @return {Highcharts.SVGPathArray|null}
  18882. * The SVG path definition for the plot line.
  18883. */
  18884. Axis.prototype.getPlotLinePath = function (options) {
  18885. var axis = this,
  18886. chart = axis.chart,
  18887. axisLeft = axis.left,
  18888. axisTop = axis.top,
  18889. old = options.old,
  18890. value = options.value,
  18891. lineWidth = options.lineWidth,
  18892. cHeight = (old && chart.oldChartHeight) || chart.chartHeight,
  18893. cWidth = (old && chart.oldChartWidth) || chart.chartWidth,
  18894. transB = axis.transB;
  18895. var translatedValue = options.translatedValue,
  18896. force = options.force,
  18897. x1,
  18898. y1,
  18899. x2,
  18900. y2,
  18901. skip;
  18902. // eslint-disable-next-line valid-jsdoc
  18903. /**
  18904. * Check if x is between a and b. If not, either move to a/b
  18905. * or skip, depending on the force parameter.
  18906. * @private
  18907. */
  18908. function between(x, a, b) {
  18909. if (force !== 'pass' && x < a || x > b) {
  18910. if (force) {
  18911. x = clamp(x, a, b);
  18912. }
  18913. else {
  18914. skip = true;
  18915. }
  18916. }
  18917. return x;
  18918. }
  18919. var evt = {
  18920. value: value,
  18921. lineWidth: lineWidth,
  18922. old: old,
  18923. force: force,
  18924. acrossPanes: options.acrossPanes,
  18925. translatedValue: translatedValue
  18926. };
  18927. fireEvent(this, 'getPlotLinePath', evt, function (e) {
  18928. translatedValue = pick(translatedValue, axis.translate(value, null, null, old));
  18929. // Keep the translated value within sane bounds, and avoid Infinity
  18930. // to fail the isNumber test (#7709).
  18931. translatedValue = clamp(translatedValue, -1e5, 1e5);
  18932. x1 = x2 = Math.round(translatedValue + transB);
  18933. y1 = y2 = Math.round(cHeight - translatedValue - transB);
  18934. if (!isNumber(translatedValue)) { // no min or max
  18935. skip = true;
  18936. force = false; // #7175, don't force it when path is invalid
  18937. }
  18938. else if (axis.horiz) {
  18939. y1 = axisTop;
  18940. y2 = cHeight - axis.bottom;
  18941. x1 = x2 = between(x1, axisLeft, axisLeft + axis.width);
  18942. }
  18943. else {
  18944. x1 = axisLeft;
  18945. x2 = cWidth - axis.right;
  18946. y1 = y2 = between(y1, axisTop, axisTop + axis.height);
  18947. }
  18948. e.path = skip && !force ?
  18949. null :
  18950. chart.renderer.crispLine([['M', x1, y1], ['L', x2, y2]], lineWidth || 1);
  18951. });
  18952. return evt.path;
  18953. };
  18954. /**
  18955. * Internal function to get the tick positions of a linear axis to round
  18956. * values like whole tens or every five.
  18957. *
  18958. * @function Highcharts.Axis#getLinearTickPositions
  18959. *
  18960. * @param {number} tickInterval
  18961. * The normalized tick interval.
  18962. *
  18963. * @param {number} min
  18964. * Axis minimum.
  18965. *
  18966. * @param {number} max
  18967. * Axis maximum.
  18968. *
  18969. * @return {Array<number>}
  18970. * An array of axis values where ticks should be placed.
  18971. */
  18972. Axis.prototype.getLinearTickPositions = function (tickInterval, min, max) {
  18973. var roundedMin = correctFloat(Math.floor(min / tickInterval) * tickInterval),
  18974. roundedMax = correctFloat(Math.ceil(max / tickInterval) * tickInterval),
  18975. tickPositions = [];
  18976. var pos,
  18977. lastPos,
  18978. precision;
  18979. // When the precision is higher than what we filter out in
  18980. // correctFloat, skip it (#6183).
  18981. if (correctFloat(roundedMin + tickInterval) === roundedMin) {
  18982. precision = 20;
  18983. }
  18984. // For single points, add a tick regardless of the relative position
  18985. // (#2662, #6274)
  18986. if (this.single) {
  18987. return [min];
  18988. }
  18989. // Populate the intermediate values
  18990. pos = roundedMin;
  18991. while (pos <= roundedMax) {
  18992. // Place the tick on the rounded value
  18993. tickPositions.push(pos);
  18994. // Always add the raw tickInterval, not the corrected one.
  18995. pos = correctFloat(pos + tickInterval, precision);
  18996. // If the interval is not big enough in the current min - max range
  18997. // to actually increase the loop variable, we need to break out to
  18998. // prevent endless loop. Issue #619
  18999. if (pos === lastPos) {
  19000. break;
  19001. }
  19002. // Record the last value
  19003. lastPos = pos;
  19004. }
  19005. return tickPositions;
  19006. };
  19007. /**
  19008. * Resolve the new minorTicks/minorTickInterval options into the legacy
  19009. * loosely typed minorTickInterval option.
  19010. *
  19011. * @function Highcharts.Axis#getMinorTickInterval
  19012. *
  19013. * @return {number|"auto"|null}
  19014. */
  19015. Axis.prototype.getMinorTickInterval = function () {
  19016. var options = this.options;
  19017. if (options.minorTicks === true) {
  19018. return pick(options.minorTickInterval, 'auto');
  19019. }
  19020. if (options.minorTicks === false) {
  19021. return null;
  19022. }
  19023. return options.minorTickInterval;
  19024. };
  19025. /**
  19026. * Internal function to return the minor tick positions. For logarithmic
  19027. * axes, the same logic as for major ticks is reused.
  19028. *
  19029. * @function Highcharts.Axis#getMinorTickPositions
  19030. *
  19031. * @return {Array<number>}
  19032. * An array of axis values where ticks should be placed.
  19033. */
  19034. Axis.prototype.getMinorTickPositions = function () {
  19035. var axis = this,
  19036. options = axis.options,
  19037. tickPositions = axis.tickPositions,
  19038. minorTickInterval = axis.minorTickInterval,
  19039. pointRangePadding = axis.pointRangePadding || 0,
  19040. min = axis.min - pointRangePadding, // #1498
  19041. max = axis.max + pointRangePadding, // #1498
  19042. range = max - min;
  19043. var minorTickPositions = [],
  19044. pos;
  19045. // If minor ticks get too dense, they are hard to read, and may cause
  19046. // long running script. So we don't draw them.
  19047. if (range && range / minorTickInterval < axis.len / 3) { // #3875
  19048. var logarithmic_1 = axis.logarithmic;
  19049. if (logarithmic_1) {
  19050. // For each interval in the major ticks, compute the minor ticks
  19051. // separately.
  19052. this.paddedTicks.forEach(function (_pos, i, paddedTicks) {
  19053. if (i) {
  19054. minorTickPositions.push.apply(minorTickPositions, logarithmic_1.getLogTickPositions(minorTickInterval, paddedTicks[i - 1], paddedTicks[i], true));
  19055. }
  19056. });
  19057. }
  19058. else if (axis.dateTime &&
  19059. this.getMinorTickInterval() === 'auto') { // #1314
  19060. minorTickPositions = minorTickPositions.concat(axis.getTimeTicks(axis.dateTime.normalizeTimeTickInterval(minorTickInterval), min, max, options.startOfWeek));
  19061. }
  19062. else {
  19063. for (pos = min + (tickPositions[0] - min) % minorTickInterval; pos <= max; pos += minorTickInterval) {
  19064. // Very, very, tight grid lines (#5771)
  19065. if (pos === minorTickPositions[0]) {
  19066. break;
  19067. }
  19068. minorTickPositions.push(pos);
  19069. }
  19070. }
  19071. }
  19072. if (minorTickPositions.length !== 0) {
  19073. axis.trimTicks(minorTickPositions); // #3652 #3743 #1498 #6330
  19074. }
  19075. return minorTickPositions;
  19076. };
  19077. /**
  19078. * Adjust the min and max for the minimum range. Keep in mind that the
  19079. * series data is not yet processed, so we don't have information on data
  19080. * cropping and grouping, or updated `axis.pointRange` or
  19081. * `series.pointRange`. The data can't be processed until we have finally
  19082. * established min and max.
  19083. *
  19084. * @private
  19085. * @function Highcharts.Axis#adjustForMinRange
  19086. */
  19087. Axis.prototype.adjustForMinRange = function () {
  19088. var axis = this,
  19089. options = axis.options,
  19090. log = axis.logarithmic;
  19091. var min = axis.min,
  19092. max = axis.max,
  19093. zoomOffset,
  19094. spaceAvailable,
  19095. closestDataRange = 0,
  19096. i,
  19097. distance,
  19098. xData,
  19099. loopLength,
  19100. minArgs,
  19101. maxArgs,
  19102. minRange;
  19103. // Set the automatic minimum range based on the closest point distance
  19104. if (axis.isXAxis &&
  19105. typeof axis.minRange === 'undefined' &&
  19106. !log) {
  19107. if (defined(options.min) || defined(options.max)) {
  19108. axis.minRange = null; // don't do this again
  19109. }
  19110. else {
  19111. // Find the closest distance between raw data points, as opposed
  19112. // to closestPointRange that applies to processed points
  19113. // (cropped and grouped)
  19114. axis.series.forEach(function (series) {
  19115. xData = series.xData;
  19116. loopLength = series.xIncrement ? 1 : xData.length - 1;
  19117. if (xData.length > 1) {
  19118. for (i = loopLength; i > 0; i--) {
  19119. distance = xData[i] - xData[i - 1];
  19120. if (!closestDataRange || distance < closestDataRange) {
  19121. closestDataRange = distance;
  19122. }
  19123. }
  19124. }
  19125. });
  19126. axis.minRange = Math.min(closestDataRange * 5, axis.dataMax - axis.dataMin);
  19127. }
  19128. }
  19129. // if minRange is exceeded, adjust
  19130. if (max - min < axis.minRange) {
  19131. spaceAvailable =
  19132. axis.dataMax - axis.dataMin >=
  19133. axis.minRange;
  19134. minRange = axis.minRange;
  19135. zoomOffset = (minRange - max + min) / 2;
  19136. // if min and max options have been set, don't go beyond it
  19137. minArgs = [
  19138. min - zoomOffset,
  19139. pick(options.min, min - zoomOffset)
  19140. ];
  19141. // If space is available, stay within the data range
  19142. if (spaceAvailable) {
  19143. minArgs[2] = axis.logarithmic ?
  19144. axis.logarithmic.log2lin(axis.dataMin) :
  19145. axis.dataMin;
  19146. }
  19147. min = arrayMax(minArgs);
  19148. maxArgs = [
  19149. min + minRange,
  19150. pick(options.max, min + minRange)
  19151. ];
  19152. // If space is availabe, stay within the data range
  19153. if (spaceAvailable) {
  19154. maxArgs[2] = log ?
  19155. log.log2lin(axis.dataMax) :
  19156. axis.dataMax;
  19157. }
  19158. max = arrayMin(maxArgs);
  19159. // now if the max is adjusted, adjust the min back
  19160. if (max - min < minRange) {
  19161. minArgs[0] = max - minRange;
  19162. minArgs[1] = pick(options.min, max - minRange);
  19163. min = arrayMax(minArgs);
  19164. }
  19165. }
  19166. // Record modified extremes
  19167. axis.min = min;
  19168. axis.max = max;
  19169. };
  19170. /**
  19171. * Find the closestPointRange across all series.
  19172. *
  19173. * @private
  19174. * @function Highcharts.Axis#getClosest
  19175. *
  19176. * @return {number}
  19177. */
  19178. Axis.prototype.getClosest = function () {
  19179. var ret;
  19180. if (this.categories) {
  19181. ret = 1;
  19182. }
  19183. else {
  19184. this.series.forEach(function (series) {
  19185. var seriesClosest = series.closestPointRange,
  19186. visible = series.visible ||
  19187. !series.chart.options.chart.ignoreHiddenSeries;
  19188. if (!series.noSharedTooltip &&
  19189. defined(seriesClosest) &&
  19190. visible) {
  19191. ret = defined(ret) ?
  19192. Math.min(ret, seriesClosest) :
  19193. seriesClosest;
  19194. }
  19195. });
  19196. }
  19197. return ret;
  19198. };
  19199. /**
  19200. * When a point name is given and no x, search for the name in the existing
  19201. * categories, or if categories aren't provided, search names or create a
  19202. * new category (#2522).
  19203. *
  19204. * @private
  19205. * @function Highcharts.Axis#nameToX
  19206. *
  19207. * @param {Highcharts.Point} point
  19208. * The point to inspect.
  19209. *
  19210. * @return {number}
  19211. * The X value that the point is given.
  19212. */
  19213. Axis.prototype.nameToX = function (point) {
  19214. var explicitCategories = isArray(this.categories),
  19215. names = explicitCategories ? this.categories : this.names;
  19216. var nameX = point.options.x,
  19217. x;
  19218. point.series.requireSorting = false;
  19219. if (!defined(nameX)) {
  19220. nameX = this.options.uniqueNames ?
  19221. (explicitCategories ?
  19222. names.indexOf(point.name) :
  19223. pick(names.keys[point.name], -1)) :
  19224. point.series.autoIncrement();
  19225. }
  19226. if (nameX === -1) { // Not found in currenct categories
  19227. if (!explicitCategories) {
  19228. x = names.length;
  19229. }
  19230. }
  19231. else {
  19232. x = nameX;
  19233. }
  19234. // Write the last point's name to the names array
  19235. if (typeof x !== 'undefined') {
  19236. this.names[x] = point.name;
  19237. // Backwards mapping is much faster than array searching (#7725)
  19238. this.names.keys[point.name] = x;
  19239. }
  19240. return x;
  19241. };
  19242. /**
  19243. * When changes have been done to series data, update the axis.names.
  19244. *
  19245. * @private
  19246. * @function Highcharts.Axis#updateNames
  19247. */
  19248. Axis.prototype.updateNames = function () {
  19249. var axis = this,
  19250. names = this.names,
  19251. i = names.length;
  19252. if (i > 0) {
  19253. Object.keys(names.keys).forEach(function (key) {
  19254. delete (names.keys)[key];
  19255. });
  19256. names.length = 0;
  19257. this.minRange = this.userMinRange; // Reset
  19258. (this.series || []).forEach(function (series) {
  19259. // Reset incrementer (#5928)
  19260. series.xIncrement = null;
  19261. // When adding a series, points are not yet generated
  19262. if (!series.points || series.isDirtyData) {
  19263. // When we're updating the series with data that is longer
  19264. // than it was, and cropThreshold is passed, we need to make
  19265. // sure that the axis.max is increased _before_ running the
  19266. // premature processData. Otherwise this early iteration of
  19267. // processData will crop the points to axis.max, and the
  19268. // names array will be too short (#5857).
  19269. axis.max = Math.max(axis.max, series.xData.length - 1);
  19270. series.processData();
  19271. series.generatePoints();
  19272. }
  19273. series.data.forEach(function (point, i) {
  19274. var x;
  19275. if (point &&
  19276. point.options &&
  19277. typeof point.name !== 'undefined' // #9562
  19278. ) {
  19279. x = axis.nameToX(point);
  19280. if (typeof x !== 'undefined' && x !== point.x) {
  19281. point.x = x;
  19282. series.xData[i] = x;
  19283. }
  19284. }
  19285. });
  19286. });
  19287. }
  19288. };
  19289. /**
  19290. * Update translation information.
  19291. *
  19292. * @private
  19293. * @function Highcharts.Axis#setAxisTranslation
  19294. *
  19295. * @fires Highcharts.Axis#event:afterSetAxisTranslation
  19296. */
  19297. Axis.prototype.setAxisTranslation = function () {
  19298. var axis = this,
  19299. range = axis.max - axis.min,
  19300. linkedParent = axis.linkedParent,
  19301. hasCategories = !!axis.categories,
  19302. isXAxis = axis.isXAxis;
  19303. var pointRange = axis.axisPointRange || 0,
  19304. closestPointRange,
  19305. minPointOffset = 0,
  19306. pointRangePadding = 0,
  19307. ordinalCorrection,
  19308. transA = axis.transA;
  19309. // Adjust translation for padding. Y axis with categories need to go
  19310. // through the same (#1784).
  19311. if (isXAxis || hasCategories || pointRange) {
  19312. // Get the closest points
  19313. closestPointRange = axis.getClosest();
  19314. if (linkedParent) {
  19315. minPointOffset = linkedParent.minPointOffset;
  19316. pointRangePadding = linkedParent.pointRangePadding;
  19317. }
  19318. else {
  19319. axis.series.forEach(function (series) {
  19320. var seriesPointRange = hasCategories ?
  19321. 1 :
  19322. (isXAxis ?
  19323. pick(series.options.pointRange,
  19324. closestPointRange, 0) :
  19325. (axis.axisPointRange || 0)), // #2806
  19326. pointPlacement = series.options.pointPlacement;
  19327. pointRange = Math.max(pointRange, seriesPointRange);
  19328. if (!axis.single || hasCategories) {
  19329. // TODO: series should internally set x- and y-
  19330. // pointPlacement to simplify this logic.
  19331. var isPointPlacementAxis = series.is('xrange') ? !isXAxis : isXAxis;
  19332. // minPointOffset is the value padding to the left of
  19333. // the axis in order to make room for points with a
  19334. // pointRange, typically columns. When the
  19335. // pointPlacement option is 'between' or 'on', this
  19336. // padding does not apply.
  19337. minPointOffset = Math.max(minPointOffset, isPointPlacementAxis && isString(pointPlacement) ?
  19338. 0 :
  19339. seriesPointRange / 2);
  19340. // Determine the total padding needed to the length of
  19341. // the axis to make room for the pointRange. If the
  19342. // series' pointPlacement is 'on', no padding is added.
  19343. pointRangePadding = Math.max(pointRangePadding, isPointPlacementAxis && pointPlacement === 'on' ?
  19344. 0 :
  19345. seriesPointRange);
  19346. }
  19347. });
  19348. }
  19349. // Record minPointOffset and pointRangePadding
  19350. ordinalCorrection = axis.ordinal && axis.ordinal.slope && closestPointRange ?
  19351. axis.ordinal.slope / closestPointRange :
  19352. 1; // #988, #1853
  19353. axis.minPointOffset = minPointOffset =
  19354. minPointOffset * ordinalCorrection;
  19355. axis.pointRangePadding =
  19356. pointRangePadding = pointRangePadding * ordinalCorrection;
  19357. // pointRange means the width reserved for each point, like in a
  19358. // column chart
  19359. axis.pointRange = Math.min(pointRange, axis.single && hasCategories ? 1 : range);
  19360. // closestPointRange means the closest distance between points. In
  19361. // columns it is mostly equal to pointRange, but in lines pointRange
  19362. // is 0 while closestPointRange is some other value
  19363. if (isXAxis) {
  19364. axis.closestPointRange = closestPointRange;
  19365. }
  19366. }
  19367. // Secondary values
  19368. axis.translationSlope = axis.transA = transA =
  19369. axis.staticScale ||
  19370. axis.len / ((range + pointRangePadding) || 1);
  19371. // Translation addend
  19372. axis.transB = axis.horiz ? axis.left : axis.bottom;
  19373. axis.minPixelPadding = transA * minPointOffset;
  19374. fireEvent(this, 'afterSetAxisTranslation');
  19375. };
  19376. /**
  19377. * @private
  19378. * @function Highcharts.Axis#minFromRange
  19379. *
  19380. * @return {number|undefined}
  19381. */
  19382. Axis.prototype.minFromRange = function () {
  19383. var axis = this;
  19384. return axis.max - axis.range;
  19385. };
  19386. /**
  19387. * Set the tick positions to round values and optionally extend the extremes
  19388. * to the nearest tick.
  19389. *
  19390. * @private
  19391. * @function Highcharts.Axis#setTickInterval
  19392. *
  19393. * @param {boolean} secondPass
  19394. * TO-DO: parameter description
  19395. *
  19396. * @fires Highcharts.Axis#event:foundExtremes
  19397. */
  19398. Axis.prototype.setTickInterval = function (secondPass) {
  19399. var axis = this,
  19400. chart = axis.chart,
  19401. log = axis.logarithmic,
  19402. options = axis.options,
  19403. isXAxis = axis.isXAxis,
  19404. isLinked = axis.isLinked,
  19405. tickPixelIntervalOption = options.tickPixelInterval,
  19406. categories = axis.categories,
  19407. softThreshold = axis.softThreshold;
  19408. var maxPadding = options.maxPadding,
  19409. minPadding = options.minPadding,
  19410. length,
  19411. linkedParentExtremes,
  19412. tickIntervalOption = options.tickInterval,
  19413. threshold = isNumber(axis.threshold) ? axis.threshold : null,
  19414. thresholdMin,
  19415. thresholdMax,
  19416. hardMin,
  19417. hardMax;
  19418. if (!axis.dateTime && !categories && !isLinked) {
  19419. this.getTickAmount();
  19420. }
  19421. // Min or max set either by zooming/setExtremes or initial options
  19422. hardMin = pick(axis.userMin, options.min);
  19423. hardMax = pick(axis.userMax, options.max);
  19424. // Linked axis gets the extremes from the parent axis
  19425. if (isLinked) {
  19426. axis.linkedParent = chart[axis.coll][options.linkedTo];
  19427. linkedParentExtremes = axis.linkedParent.getExtremes();
  19428. axis.min = pick(linkedParentExtremes.min, linkedParentExtremes.dataMin);
  19429. axis.max = pick(linkedParentExtremes.max, linkedParentExtremes.dataMax);
  19430. if (options.type !== axis.linkedParent.options.type) {
  19431. // Can't link axes of different type
  19432. error(11, 1, chart);
  19433. }
  19434. // Initial min and max from the extreme data values
  19435. }
  19436. else {
  19437. // Adjust to hard threshold
  19438. if (softThreshold && defined(threshold)) {
  19439. if (axis.dataMin >= threshold) {
  19440. thresholdMin = threshold;
  19441. minPadding = 0;
  19442. }
  19443. else if (axis.dataMax <= threshold) {
  19444. thresholdMax = threshold;
  19445. maxPadding = 0;
  19446. }
  19447. }
  19448. axis.min = pick(hardMin, thresholdMin, axis.dataMin);
  19449. axis.max = pick(hardMax, thresholdMax, axis.dataMax);
  19450. }
  19451. if (log) {
  19452. if (axis.positiveValuesOnly &&
  19453. !secondPass &&
  19454. Math.min(axis.min, pick(axis.dataMin, axis.min)) <= 0) { // #978
  19455. // Can't plot negative values on log axis
  19456. error(10, 1, chart);
  19457. }
  19458. // The correctFloat cures #934, float errors on full tens. But it
  19459. // was too aggressive for #4360 because of conversion back to lin,
  19460. // therefore use precision 15.
  19461. axis.min = correctFloat(log.log2lin(axis.min), 16);
  19462. axis.max = correctFloat(log.log2lin(axis.max), 16);
  19463. }
  19464. // handle zoomed range
  19465. if (axis.range && defined(axis.max)) {
  19466. // #618, #6773:
  19467. axis.userMin = axis.min = hardMin =
  19468. Math.max(axis.dataMin, axis.minFromRange());
  19469. axis.userMax = hardMax = axis.max;
  19470. axis.range = null; // don't use it when running setExtremes
  19471. }
  19472. // Hook for Highcharts Stock Scroller.
  19473. // Consider combining with beforePadding.
  19474. fireEvent(axis, 'foundExtremes');
  19475. // Hook for adjusting this.min and this.max. Used by bubble series.
  19476. if (axis.beforePadding) {
  19477. axis.beforePadding();
  19478. }
  19479. // adjust min and max for the minimum range
  19480. axis.adjustForMinRange();
  19481. // Pad the values to get clear of the chart's edges. To avoid
  19482. // tickInterval taking the padding into account, we do this after
  19483. // computing tick interval (#1337).
  19484. if (!categories &&
  19485. !axis.axisPointRange &&
  19486. !(axis.stacking && axis.stacking.usePercentage) &&
  19487. !isLinked &&
  19488. defined(axis.min) &&
  19489. defined(axis.max)) {
  19490. length = axis.max - axis.min;
  19491. if (length) {
  19492. if (!defined(hardMin) && minPadding) {
  19493. axis.min -= length * minPadding;
  19494. }
  19495. if (!defined(hardMax) && maxPadding) {
  19496. axis.max += length * maxPadding;
  19497. }
  19498. }
  19499. }
  19500. // Handle options for floor, ceiling, softMin and softMax (#6359)
  19501. if (!isNumber(axis.userMin)) {
  19502. if (isNumber(options.softMin) && options.softMin < axis.min) {
  19503. axis.min = hardMin = options.softMin; // #6894
  19504. }
  19505. if (isNumber(options.floor)) {
  19506. axis.min = Math.max(axis.min, options.floor);
  19507. }
  19508. }
  19509. if (!isNumber(axis.userMax)) {
  19510. if (isNumber(options.softMax) && options.softMax > axis.max) {
  19511. axis.max = hardMax = options.softMax; // #6894
  19512. }
  19513. if (isNumber(options.ceiling)) {
  19514. axis.max = Math.min(axis.max, options.ceiling);
  19515. }
  19516. }
  19517. // When the threshold is soft, adjust the extreme value only if the data
  19518. // extreme and the padded extreme land on either side of the threshold.
  19519. // For example, a series of [0, 1, 2, 3] would make the yAxis add a tick
  19520. // for -1 because of the default minPadding and startOnTick options.
  19521. // This is prevented by the softThreshold option.
  19522. if (softThreshold && defined(axis.dataMin)) {
  19523. threshold = threshold || 0;
  19524. if (!defined(hardMin) &&
  19525. axis.min < threshold &&
  19526. axis.dataMin >= threshold) {
  19527. axis.min = axis.options.minRange ?
  19528. Math.min(threshold, axis.max -
  19529. axis.minRange) :
  19530. threshold;
  19531. }
  19532. else if (!defined(hardMax) &&
  19533. axis.max > threshold &&
  19534. axis.dataMax <= threshold) {
  19535. axis.max = axis.options.minRange ?
  19536. Math.max(threshold, axis.min +
  19537. axis.minRange) :
  19538. threshold;
  19539. }
  19540. }
  19541. // If min is bigger than highest, or if max less than lowest value, the
  19542. // chart should not render points. (#14417)
  19543. if (isNumber(axis.min) &&
  19544. isNumber(axis.max) &&
  19545. !this.chart.polar &&
  19546. (axis.min > axis.max)) {
  19547. if (defined(axis.options.min)) {
  19548. axis.max = axis.min;
  19549. }
  19550. else if (defined(axis.options.max)) {
  19551. axis.min = axis.max;
  19552. }
  19553. }
  19554. // get tickInterval
  19555. if (axis.min === axis.max ||
  19556. typeof axis.min === 'undefined' ||
  19557. typeof axis.max === 'undefined') {
  19558. axis.tickInterval = 1;
  19559. }
  19560. else if (isLinked &&
  19561. axis.linkedParent &&
  19562. !tickIntervalOption &&
  19563. tickPixelIntervalOption ===
  19564. axis.linkedParent.options.tickPixelInterval) {
  19565. axis.tickInterval = tickIntervalOption =
  19566. axis.linkedParent.tickInterval;
  19567. }
  19568. else {
  19569. axis.tickInterval = pick(tickIntervalOption, this.tickAmount ?
  19570. ((axis.max - axis.min) /
  19571. Math.max(this.tickAmount - 1, 1)) :
  19572. void 0,
  19573. // For categoried axis, 1 is default, for linear axis use
  19574. // tickPix
  19575. categories ?
  19576. 1 :
  19577. // don't let it be more than the data range
  19578. (axis.max - axis.min) *
  19579. tickPixelIntervalOption /
  19580. Math.max(axis.len, tickPixelIntervalOption));
  19581. }
  19582. // Now we're finished detecting min and max, crop and group series data.
  19583. // This is in turn needed in order to find tick positions in ordinal
  19584. // axes.
  19585. if (isXAxis && !secondPass) {
  19586. axis.series.forEach(function (series) {
  19587. series.processData(axis.min !== (axis.old && axis.old.min) ||
  19588. axis.max !== (axis.old && axis.old.max));
  19589. });
  19590. }
  19591. // set the translation factor used in translate function
  19592. axis.setAxisTranslation();
  19593. // hook for ordinal axes and radial axes
  19594. fireEvent(this, 'initialAxisTranslation');
  19595. // In column-like charts, don't cramp in more ticks than there are
  19596. // points (#1943, #4184)
  19597. if (axis.pointRange && !tickIntervalOption) {
  19598. axis.tickInterval = Math.max(axis.pointRange, axis.tickInterval);
  19599. }
  19600. // Before normalizing the tick interval, handle minimum tick interval.
  19601. // This applies only if tickInterval is not defined.
  19602. var minTickInterval = pick(options.minTickInterval,
  19603. // In datetime axes, don't go below the data interval, except when
  19604. // there are scatter-like series involved (#13369).
  19605. axis.dateTime &&
  19606. !axis.series.some(function (s) { return s.noSharedTooltip; }) ?
  19607. axis.closestPointRange : 0);
  19608. if (!tickIntervalOption && axis.tickInterval < minTickInterval) {
  19609. axis.tickInterval = minTickInterval;
  19610. }
  19611. // for linear axes, get magnitude and normalize the interval
  19612. if (!axis.dateTime && !axis.logarithmic && !tickIntervalOption) {
  19613. axis.tickInterval = normalizeTickInterval(axis.tickInterval, void 0, getMagnitude(axis.tickInterval), pick(options.allowDecimals,
  19614. // If the tick interval is greather than 0.5, avoid
  19615. // decimals, as linear axes are often used to render
  19616. // discrete values. #3363. If a tick amount is set, allow
  19617. // decimals by default, as it increases the chances for a
  19618. // good fit.
  19619. axis.tickInterval < 0.5 || this.tickAmount !== void 0), !!this.tickAmount);
  19620. }
  19621. // Prevent ticks from getting so close that we can't draw the labels
  19622. if (!this.tickAmount) {
  19623. axis.tickInterval = axis.unsquish();
  19624. }
  19625. this.setTickPositions();
  19626. };
  19627. /**
  19628. * Now we have computed the normalized tickInterval, get the tick positions.
  19629. *
  19630. * @private
  19631. * @function Highcharts.Axis#setTickPositions
  19632. *
  19633. * @fires Highcharts.Axis#event:afterSetTickPositions
  19634. */
  19635. Axis.prototype.setTickPositions = function () {
  19636. var axis = this,
  19637. options = this.options,
  19638. tickPositionsOption = options.tickPositions,
  19639. minorTickIntervalOption = this.getMinorTickInterval(),
  19640. hasVerticalPanning = this.hasVerticalPanning(),
  19641. isColorAxis = this.coll === 'colorAxis',
  19642. startOnTick = (isColorAxis || !hasVerticalPanning) && options.startOnTick,
  19643. endOnTick = (isColorAxis || !hasVerticalPanning) && options.endOnTick;
  19644. var tickPositions,
  19645. tickPositioner = options.tickPositioner;
  19646. // Set the tickmarkOffset
  19647. this.tickmarkOffset = (this.categories &&
  19648. options.tickmarkPlacement === 'between' &&
  19649. this.tickInterval === 1) ? 0.5 : 0; // #3202
  19650. // get minorTickInterval
  19651. this.minorTickInterval =
  19652. minorTickIntervalOption === 'auto' &&
  19653. this.tickInterval ?
  19654. this.tickInterval / 5 :
  19655. minorTickIntervalOption;
  19656. // When there is only one point, or all points have the same value on
  19657. // this axis, then min and max are equal and tickPositions.length is 0
  19658. // or 1. In this case, add some padding in order to center the point,
  19659. // but leave it with one tick. #1337.
  19660. this.single =
  19661. this.min === this.max &&
  19662. defined(this.min) &&
  19663. !this.tickAmount &&
  19664. (
  19665. // Data is on integer (#6563)
  19666. parseInt(this.min, 10) === this.min ||
  19667. // Between integers and decimals are not allowed (#6274)
  19668. options.allowDecimals !== false);
  19669. /**
  19670. * Contains the current positions that are laid out on the axis. The
  19671. * positions are numbers in terms of axis values. In a category axis
  19672. * they are integers, in a datetime axis they are also integers, but
  19673. * designating milliseconds.
  19674. *
  19675. * This property is read only - for modifying the tick positions, use
  19676. * the `tickPositioner` callback or [axis.tickPositions(
  19677. * https://api.highcharts.com/highcharts/xAxis.tickPositions) option
  19678. * instead.
  19679. *
  19680. * @name Highcharts.Axis#tickPositions
  19681. * @type {Highcharts.AxisTickPositionsArray|undefined}
  19682. */
  19683. this.tickPositions =
  19684. // Find the tick positions. Work on a copy (#1565)
  19685. tickPositions =
  19686. (tickPositionsOption && tickPositionsOption.slice());
  19687. if (!tickPositions) {
  19688. // Too many ticks (#6405). Create a friendly warning and provide two
  19689. // ticks so at least we can show the data series.
  19690. if ((!axis.ordinal || !axis.ordinal.positions) &&
  19691. ((this.max - this.min) /
  19692. this.tickInterval >
  19693. Math.max(2 * this.len, 200))) {
  19694. tickPositions = [this.min, this.max];
  19695. error(19, false, this.chart);
  19696. }
  19697. else if (axis.dateTime) {
  19698. tickPositions = axis.getTimeTicks(axis.dateTime.normalizeTimeTickInterval(this.tickInterval, options.units), this.min, this.max, options.startOfWeek, axis.ordinal && axis.ordinal.positions, this.closestPointRange, true);
  19699. }
  19700. else if (axis.logarithmic) {
  19701. tickPositions = axis.logarithmic.getLogTickPositions(this.tickInterval, this.min, this.max);
  19702. }
  19703. else {
  19704. tickPositions = this.getLinearTickPositions(this.tickInterval, this.min, this.max);
  19705. }
  19706. // Too dense ticks, keep only the first and last (#4477)
  19707. if (tickPositions.length > this.len) {
  19708. tickPositions = [tickPositions[0], tickPositions.pop()];
  19709. // Reduce doubled value (#7339)
  19710. if (tickPositions[0] === tickPositions[1]) {
  19711. tickPositions.length = 1;
  19712. }
  19713. }
  19714. this.tickPositions = tickPositions;
  19715. // Run the tick positioner callback, that allows modifying auto tick
  19716. // positions.
  19717. if (tickPositioner) {
  19718. tickPositioner = tickPositioner.apply(axis, [this.min, this.max]);
  19719. if (tickPositioner) {
  19720. this.tickPositions = tickPositions = tickPositioner;
  19721. }
  19722. }
  19723. }
  19724. // Reset min/max or remove extremes based on start/end on tick
  19725. this.paddedTicks = tickPositions.slice(0); // Used for logarithmic minor
  19726. this.trimTicks(tickPositions, startOnTick, endOnTick);
  19727. if (!this.isLinked) {
  19728. // Substract half a unit (#2619, #2846, #2515, #3390),
  19729. // but not in case of multiple ticks (#6897)
  19730. if (this.single &&
  19731. tickPositions.length < 2 &&
  19732. !this.categories &&
  19733. !this.series.some(function (s) {
  19734. return (s.is('heatmap') && s.options.pointPlacement === 'between');
  19735. })) {
  19736. this.min -= 0.5;
  19737. this.max += 0.5;
  19738. }
  19739. if (!tickPositionsOption && !tickPositioner) {
  19740. this.adjustTickAmount();
  19741. }
  19742. }
  19743. fireEvent(this, 'afterSetTickPositions');
  19744. };
  19745. /**
  19746. * Handle startOnTick and endOnTick by either adapting to padding min/max or
  19747. * rounded min/max. Also handle single data points.
  19748. *
  19749. * @private
  19750. * @function Highcharts.Axis#trimTicks
  19751. *
  19752. * @param {Array<number>} tickPositions
  19753. * TO-DO: parameter description
  19754. *
  19755. * @param {boolean} [startOnTick]
  19756. * TO-DO: parameter description
  19757. *
  19758. * @param {boolean} [endOnTick]
  19759. * TO-DO: parameter description
  19760. */
  19761. Axis.prototype.trimTicks = function (tickPositions, startOnTick, endOnTick) {
  19762. var roundedMin = tickPositions[0],
  19763. roundedMax = tickPositions[tickPositions.length - 1],
  19764. minPointOffset = (!this.isOrdinal && this.minPointOffset) || 0; // (#12716)
  19765. fireEvent(this, 'trimTicks');
  19766. if (!this.isLinked) {
  19767. if (startOnTick && roundedMin !== -Infinity) { // #6502
  19768. this.min = roundedMin;
  19769. }
  19770. else {
  19771. while (this.min - minPointOffset > tickPositions[0]) {
  19772. tickPositions.shift();
  19773. }
  19774. }
  19775. if (endOnTick) {
  19776. this.max = roundedMax;
  19777. }
  19778. else {
  19779. while (this.max + minPointOffset <
  19780. tickPositions[tickPositions.length - 1]) {
  19781. tickPositions.pop();
  19782. }
  19783. }
  19784. // If no tick are left, set one tick in the middle (#3195)
  19785. if (tickPositions.length === 0 &&
  19786. defined(roundedMin) &&
  19787. !this.options.tickPositions) {
  19788. tickPositions.push((roundedMax + roundedMin) / 2);
  19789. }
  19790. }
  19791. };
  19792. /**
  19793. * Check if there are multiple axes in the same pane.
  19794. *
  19795. * @private
  19796. * @function Highcharts.Axis#alignToOthers
  19797. *
  19798. * @return {boolean|undefined}
  19799. * True if there are other axes.
  19800. */
  19801. Axis.prototype.alignToOthers = function () {
  19802. var axis = this,
  19803. others = // Whether there is another axis to pair with this one
  19804. {},
  19805. options = axis.options;
  19806. var hasOther;
  19807. if (
  19808. // Only if alignTicks is true
  19809. this.chart.options.chart.alignTicks !== false &&
  19810. options.alignTicks &&
  19811. // Disabled when startOnTick or endOnTick are false (#7604)
  19812. options.startOnTick !== false &&
  19813. options.endOnTick !== false &&
  19814. // Don't try to align ticks on a log axis, they are not evenly
  19815. // spaced (#6021)
  19816. !axis.logarithmic) {
  19817. this.chart[this.coll].forEach(function (axis) {
  19818. var otherOptions = axis.options, horiz = axis.horiz, key = [
  19819. horiz ? otherOptions.left : otherOptions.top,
  19820. otherOptions.width,
  19821. otherOptions.height,
  19822. otherOptions.pane
  19823. ].join(',');
  19824. if (axis.series.length) { // #4442
  19825. if (others[key]) {
  19826. hasOther = true; // #4201
  19827. }
  19828. else {
  19829. others[key] = 1;
  19830. }
  19831. }
  19832. });
  19833. }
  19834. return hasOther;
  19835. };
  19836. /**
  19837. * Find the max ticks of either the x and y axis collection, and record it
  19838. * in `this.tickAmount`.
  19839. *
  19840. * @private
  19841. * @function Highcharts.Axis#getTickAmount
  19842. */
  19843. Axis.prototype.getTickAmount = function () {
  19844. var axis = this,
  19845. options = this.options,
  19846. tickPixelInterval = options.tickPixelInterval;
  19847. var tickAmount = options.tickAmount;
  19848. if (!defined(options.tickInterval) &&
  19849. !tickAmount &&
  19850. this.len < tickPixelInterval &&
  19851. !this.isRadial &&
  19852. !axis.logarithmic &&
  19853. options.startOnTick &&
  19854. options.endOnTick) {
  19855. tickAmount = 2;
  19856. }
  19857. if (!tickAmount && this.alignToOthers()) {
  19858. // Add 1 because 4 tick intervals require 5 ticks (including first
  19859. // and last)
  19860. tickAmount = Math.ceil(this.len / tickPixelInterval) + 1;
  19861. }
  19862. // For tick amounts of 2 and 3, compute five ticks and remove the
  19863. // intermediate ones. This prevents the axis from adding ticks that are
  19864. // too far away from the data extremes.
  19865. if (tickAmount < 4) {
  19866. this.finalTickAmt = tickAmount;
  19867. tickAmount = 5;
  19868. }
  19869. this.tickAmount = tickAmount;
  19870. };
  19871. /**
  19872. * When using multiple axes, adjust the number of ticks to match the highest
  19873. * number of ticks in that group.
  19874. *
  19875. * @private
  19876. * @function Highcharts.Axis#adjustTickAmount
  19877. */
  19878. Axis.prototype.adjustTickAmount = function () {
  19879. var axis = this,
  19880. axisOptions = axis.options,
  19881. tickInterval = axis.tickInterval,
  19882. tickPositions = axis.tickPositions,
  19883. tickAmount = axis.tickAmount,
  19884. finalTickAmt = axis.finalTickAmt,
  19885. currentTickAmount = tickPositions && tickPositions.length,
  19886. threshold = pick(axis.threshold,
  19887. axis.softThreshold ? 0 : null);
  19888. var len,
  19889. i;
  19890. if (axis.hasData() && isNumber(axis.min) && isNumber(axis.max)) { // #14769
  19891. if (currentTickAmount < tickAmount) {
  19892. while (tickPositions.length < tickAmount) {
  19893. // Extend evenly for both sides unless we're on the
  19894. // threshold (#3965)
  19895. if (tickPositions.length % 2 ||
  19896. axis.min === threshold) {
  19897. // to the end
  19898. tickPositions.push(correctFloat(tickPositions[tickPositions.length - 1] +
  19899. tickInterval));
  19900. }
  19901. else {
  19902. // to the start
  19903. tickPositions.unshift(correctFloat(tickPositions[0] - tickInterval));
  19904. }
  19905. }
  19906. axis.transA *= (currentTickAmount - 1) / (tickAmount - 1);
  19907. // Do not crop when ticks are not extremes (#9841)
  19908. axis.min = axisOptions.startOnTick ?
  19909. tickPositions[0] :
  19910. Math.min(axis.min, tickPositions[0]);
  19911. axis.max = axisOptions.endOnTick ?
  19912. tickPositions[tickPositions.length - 1] :
  19913. Math.max(axis.max, tickPositions[tickPositions.length - 1]);
  19914. // We have too many ticks, run second pass to try to reduce ticks
  19915. }
  19916. else if (currentTickAmount > tickAmount) {
  19917. axis.tickInterval *= 2;
  19918. axis.setTickPositions();
  19919. }
  19920. // The finalTickAmt property is set in getTickAmount
  19921. if (defined(finalTickAmt)) {
  19922. i = len = tickPositions.length;
  19923. while (i--) {
  19924. if (
  19925. // Remove every other tick
  19926. (finalTickAmt === 3 && i % 2 === 1) ||
  19927. // Remove all but first and last
  19928. (finalTickAmt <= 2 && i > 0 && i < len - 1)) {
  19929. tickPositions.splice(i, 1);
  19930. }
  19931. }
  19932. axis.finalTickAmt = void 0;
  19933. }
  19934. }
  19935. };
  19936. /**
  19937. * Set the scale based on data min and max, user set min and max or options.
  19938. *
  19939. * @private
  19940. * @function Highcharts.Axis#setScale
  19941. *
  19942. * @fires Highcharts.Axis#event:afterSetScale
  19943. */
  19944. Axis.prototype.setScale = function () {
  19945. var axis = this;
  19946. var isDirtyData = false,
  19947. isXAxisDirty = false;
  19948. axis.series.forEach(function (series) {
  19949. isDirtyData = isDirtyData || series.isDirtyData || series.isDirty;
  19950. // When x axis is dirty, we need new data extremes for y as
  19951. // well:
  19952. isXAxisDirty = (isXAxisDirty ||
  19953. (series.xAxis && series.xAxis.isDirty) ||
  19954. false);
  19955. });
  19956. // set the new axisLength
  19957. axis.setAxisSize();
  19958. var isDirtyAxisLength = axis.len !== (axis.old && axis.old.len);
  19959. // do we really need to go through all this?
  19960. if (isDirtyAxisLength ||
  19961. isDirtyData ||
  19962. isXAxisDirty ||
  19963. axis.isLinked ||
  19964. axis.forceRedraw ||
  19965. axis.userMin !== (axis.old && axis.old.userMin) ||
  19966. axis.userMax !== (axis.old && axis.old.userMax) ||
  19967. axis.alignToOthers()) {
  19968. if (axis.stacking) {
  19969. axis.stacking.resetStacks();
  19970. }
  19971. axis.forceRedraw = false;
  19972. // get data extremes if needed
  19973. axis.getSeriesExtremes();
  19974. // get fixed positions based on tickInterval
  19975. axis.setTickInterval();
  19976. // Mark as dirty if it is not already set to dirty and extremes have
  19977. // changed. #595.
  19978. if (!axis.isDirty) {
  19979. axis.isDirty =
  19980. isDirtyAxisLength ||
  19981. axis.min !== (axis.old && axis.old.min) ||
  19982. axis.max !== (axis.old && axis.old.max);
  19983. }
  19984. }
  19985. else if (axis.stacking) {
  19986. axis.stacking.cleanStacks();
  19987. }
  19988. // Recalculate panning state object, when the data
  19989. // has changed. It is required when vertical panning is enabled.
  19990. if (isDirtyData && axis.panningState) {
  19991. axis.panningState.isDirty = true;
  19992. }
  19993. fireEvent(this, 'afterSetScale');
  19994. };
  19995. /**
  19996. * Set the minimum and maximum of the axes after render time. If the
  19997. * `startOnTick` and `endOnTick` options are true, the minimum and maximum
  19998. * values are rounded off to the nearest tick. To prevent this, these
  19999. * options can be set to false before calling setExtremes. Also, setExtremes
  20000. * will not allow a range lower than the `minRange` option, which by default
  20001. * is the range of five points.
  20002. *
  20003. * @sample highcharts/members/axis-setextremes/
  20004. * Set extremes from a button
  20005. * @sample highcharts/members/axis-setextremes-datetime/
  20006. * Set extremes on a datetime axis
  20007. * @sample highcharts/members/axis-setextremes-off-ticks/
  20008. * Set extremes off ticks
  20009. * @sample stock/members/axis-setextremes/
  20010. * Set extremes in Highcharts Stock
  20011. * @sample maps/members/axis-setextremes/
  20012. * Set extremes in Highmaps
  20013. *
  20014. * @function Highcharts.Axis#setExtremes
  20015. *
  20016. * @param {number} [newMin]
  20017. * The new minimum value.
  20018. *
  20019. * @param {number} [newMax]
  20020. * The new maximum value.
  20021. *
  20022. * @param {boolean} [redraw=true]
  20023. * Whether to redraw the chart or wait for an explicit call to
  20024. * {@link Highcharts.Chart#redraw}
  20025. *
  20026. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  20027. * Enable or modify animations.
  20028. *
  20029. * @param {*} [eventArguments]
  20030. * Arguments to be accessed in event handler.
  20031. *
  20032. * @fires Highcharts.Axis#event:setExtremes
  20033. */
  20034. Axis.prototype.setExtremes = function (newMin, newMax, redraw, animation, eventArguments) {
  20035. var axis = this,
  20036. chart = axis.chart;
  20037. redraw = pick(redraw, true); // defaults to true
  20038. axis.series.forEach(function (serie) {
  20039. delete serie.kdTree;
  20040. });
  20041. // Extend the arguments with min and max
  20042. eventArguments = extend(eventArguments, {
  20043. min: newMin,
  20044. max: newMax
  20045. });
  20046. // Fire the event
  20047. fireEvent(axis, 'setExtremes', eventArguments, function () {
  20048. axis.userMin = newMin;
  20049. axis.userMax = newMax;
  20050. axis.eventArgs = eventArguments;
  20051. if (redraw) {
  20052. chart.redraw(animation);
  20053. }
  20054. });
  20055. };
  20056. /**
  20057. * Overridable method for zooming chart. Pulled out in a separate method to
  20058. * allow overriding in stock charts.
  20059. *
  20060. * @private
  20061. * @function Highcharts.Axis#zoom
  20062. *
  20063. * @param {number} newMin
  20064. * TO-DO: parameter description
  20065. *
  20066. * @param {number} newMax
  20067. * TO-DO: parameter description
  20068. *
  20069. * @return {boolean}
  20070. */
  20071. Axis.prototype.zoom = function (newMin, newMax) {
  20072. var axis = this,
  20073. dataMin = this.dataMin,
  20074. dataMax = this.dataMax,
  20075. options = this.options,
  20076. min = Math.min(dataMin,
  20077. pick(options.min,
  20078. dataMin)),
  20079. max = Math.max(dataMax,
  20080. pick(options.max,
  20081. dataMax)),
  20082. evt = {
  20083. newMin: newMin,
  20084. newMax: newMax
  20085. };
  20086. fireEvent(this, 'zoom', evt, function (e) {
  20087. // Use e.newMin and e.newMax - event handlers may have altered them
  20088. var newMin = e.newMin,
  20089. newMax = e.newMax;
  20090. if (newMin !== axis.min || newMax !== axis.max) { // #5790
  20091. // Prevent pinch zooming out of range. Check for defined is for
  20092. // #1946. #1734.
  20093. if (!axis.allowZoomOutside) {
  20094. // #6014, sometimes newMax will be smaller than min (or
  20095. // newMin will be larger than max).
  20096. if (defined(dataMin)) {
  20097. if (newMin < min) {
  20098. newMin = min;
  20099. }
  20100. if (newMin > max) {
  20101. newMin = max;
  20102. }
  20103. }
  20104. if (defined(dataMax)) {
  20105. if (newMax < min) {
  20106. newMax = min;
  20107. }
  20108. if (newMax > max) {
  20109. newMax = max;
  20110. }
  20111. }
  20112. }
  20113. // In full view, displaying the reset zoom button is not
  20114. // required
  20115. axis.displayBtn = (typeof newMin !== 'undefined' ||
  20116. typeof newMax !== 'undefined');
  20117. // Do it
  20118. axis.setExtremes(newMin, newMax, false, void 0, { trigger: 'zoom' });
  20119. }
  20120. e.zoomed = true;
  20121. });
  20122. return evt.zoomed;
  20123. };
  20124. /**
  20125. * Update the axis metrics.
  20126. *
  20127. * @private
  20128. * @function Highcharts.Axis#setAxisSize
  20129. */
  20130. Axis.prototype.setAxisSize = function () {
  20131. var chart = this.chart,
  20132. options = this.options,
  20133. // [top, right, bottom, left]
  20134. offsets = options.offsets || [0, 0, 0, 0],
  20135. horiz = this.horiz,
  20136. // Check for percentage based input values. Rounding fixes problems
  20137. // with column overflow and plot line filtering (#4898, #4899)
  20138. width = this.width = Math.round(relativeLength(pick(options.width,
  20139. chart.plotWidth - offsets[3] + offsets[1]),
  20140. chart.plotWidth)),
  20141. height = this.height = Math.round(relativeLength(pick(options.height,
  20142. chart.plotHeight - offsets[0] + offsets[2]),
  20143. chart.plotHeight)),
  20144. top = this.top = Math.round(relativeLength(pick(options.top,
  20145. chart.plotTop + offsets[0]),
  20146. chart.plotHeight,
  20147. chart.plotTop)),
  20148. left = this.left = Math.round(relativeLength(pick(options.left,
  20149. chart.plotLeft + offsets[3]),
  20150. chart.plotWidth,
  20151. chart.plotLeft));
  20152. // Expose basic values to use in Series object and navigator
  20153. this.bottom = chart.chartHeight - height - top;
  20154. this.right = chart.chartWidth - width - left;
  20155. // Direction agnostic properties
  20156. this.len = Math.max(horiz ? width : height, 0); // Math.max fixes #905
  20157. this.pos = horiz ? left : top; // distance from SVG origin
  20158. };
  20159. /**
  20160. * Get the current extremes for the axis.
  20161. *
  20162. * @sample highcharts/members/axis-getextremes/
  20163. * Report extremes by click on a button
  20164. * @sample maps/members/axis-getextremes/
  20165. * Get extremes in Highmaps
  20166. *
  20167. * @function Highcharts.Axis#getExtremes
  20168. *
  20169. * @return {Highcharts.ExtremesObject}
  20170. * An object containing extremes information.
  20171. */
  20172. Axis.prototype.getExtremes = function () {
  20173. var axis = this,
  20174. log = axis.logarithmic;
  20175. return {
  20176. min: log ?
  20177. correctFloat(log.lin2log(axis.min)) :
  20178. axis.min,
  20179. max: log ?
  20180. correctFloat(log.lin2log(axis.max)) :
  20181. axis.max,
  20182. dataMin: axis.dataMin,
  20183. dataMax: axis.dataMax,
  20184. userMin: axis.userMin,
  20185. userMax: axis.userMax
  20186. };
  20187. };
  20188. /**
  20189. * Get the zero plane either based on zero or on the min or max value.
  20190. * Used in bar and area plots.
  20191. *
  20192. * @function Highcharts.Axis#getThreshold
  20193. *
  20194. * @param {number} threshold
  20195. * The threshold in axis values.
  20196. *
  20197. * @return {number|undefined}
  20198. * The translated threshold position in terms of pixels, and corrected to
  20199. * stay within the axis bounds.
  20200. */
  20201. Axis.prototype.getThreshold = function (threshold) {
  20202. var axis = this,
  20203. log = axis.logarithmic,
  20204. realMin = log ? log.lin2log(axis.min) : axis.min,
  20205. realMax = log ? log.lin2log(axis.max) : axis.max;
  20206. if (threshold === null || threshold === -Infinity) {
  20207. threshold = realMin;
  20208. }
  20209. else if (threshold === Infinity) {
  20210. threshold = realMax;
  20211. }
  20212. else if (realMin > threshold) {
  20213. threshold = realMin;
  20214. }
  20215. else if (realMax < threshold) {
  20216. threshold = realMax;
  20217. }
  20218. return axis.translate(threshold, 0, 1, 0, 1);
  20219. };
  20220. /**
  20221. * Compute auto alignment for the axis label based on which side the axis is
  20222. * on and the given rotation for the label.
  20223. *
  20224. * @private
  20225. * @function Highcharts.Axis#autoLabelAlign
  20226. *
  20227. * @param {number} rotation
  20228. * The rotation in degrees as set by either the `rotation` or `autoRotation`
  20229. * options.
  20230. *
  20231. * @return {Highcharts.AlignValue}
  20232. * Can be `"center"`, `"left"` or `"right"`.
  20233. */
  20234. Axis.prototype.autoLabelAlign = function (rotation) {
  20235. var angle = (pick(rotation, 0) - (this.side * 90) + 720) % 360,
  20236. evt = { align: 'center' };
  20237. fireEvent(this, 'autoLabelAlign', evt, function (e) {
  20238. if (angle > 15 && angle < 165) {
  20239. e.align = 'right';
  20240. }
  20241. else if (angle > 195 && angle < 345) {
  20242. e.align = 'left';
  20243. }
  20244. });
  20245. return evt.align;
  20246. };
  20247. /**
  20248. * Get the tick length and width for the axis based on axis options.
  20249. *
  20250. * @private
  20251. * @function Highcharts.Axis#tickSize
  20252. *
  20253. * @param {string} [prefix]
  20254. * 'tick' or 'minorTick'
  20255. *
  20256. * @return {Array<number,number>|undefined}
  20257. * An array of tickLength and tickWidth
  20258. */
  20259. Axis.prototype.tickSize = function (prefix) {
  20260. var options = this.options,
  20261. tickWidth = pick(options[prefix === 'tick' ? 'tickWidth' : 'minorTickWidth'],
  20262. // Default to 1 on linear and datetime X axes
  20263. prefix === 'tick' && this.isXAxis && !this.categories ? 1 : 0);
  20264. var tickLength = options[prefix === 'tick' ? 'tickLength' : 'minorTickLength'],
  20265. tickSize;
  20266. if (tickWidth && tickLength) {
  20267. // Negate the length
  20268. if (options[prefix + 'Position'] === 'inside') {
  20269. tickLength = -tickLength;
  20270. }
  20271. tickSize = [tickLength, tickWidth];
  20272. }
  20273. var e = { tickSize: tickSize };
  20274. fireEvent(this, 'afterTickSize', e);
  20275. return e.tickSize;
  20276. };
  20277. /**
  20278. * Return the size of the labels.
  20279. *
  20280. * @private
  20281. * @function Highcharts.Axis#labelMetrics
  20282. *
  20283. * @return {Highcharts.FontMetricsObject}
  20284. */
  20285. Axis.prototype.labelMetrics = function () {
  20286. var index = this.tickPositions && this.tickPositions[0] || 0;
  20287. return this.chart.renderer.fontMetrics(this.options.labels.style.fontSize, this.ticks[index] && this.ticks[index].label);
  20288. };
  20289. /**
  20290. * Prevent the ticks from getting so close we can't draw the labels. On a
  20291. * horizontal axis, this is handled by rotating the labels, removing ticks
  20292. * and adding ellipsis. On a vertical axis remove ticks and add ellipsis.
  20293. *
  20294. * @private
  20295. * @function Highcharts.Axis#unsquish
  20296. *
  20297. * @return {number}
  20298. */
  20299. Axis.prototype.unsquish = function () {
  20300. var labelOptions = this.options.labels,
  20301. horiz = this.horiz,
  20302. tickInterval = this.tickInterval,
  20303. slotSize = this.len / (((this.categories ? 1 : 0) +
  20304. this.max -
  20305. this.min) /
  20306. tickInterval),
  20307. rotationOption = labelOptions.rotation,
  20308. labelMetrics = this.labelMetrics(),
  20309. range = Math.max(this.max - this.min, 0),
  20310. // Return the multiple of tickInterval that is needed to avoid
  20311. // collision
  20312. getStep = function (spaceNeeded) {
  20313. var step = spaceNeeded / (slotSize || 1);
  20314. step = step > 1 ? Math.ceil(step) : 1;
  20315. // Guard for very small or negative angles (#9835)
  20316. if (step * tickInterval > range &&
  20317. spaceNeeded !== Infinity &&
  20318. slotSize !== Infinity &&
  20319. range) {
  20320. step = Math.ceil(range / tickInterval);
  20321. }
  20322. return correctFloat(step * tickInterval);
  20323. };
  20324. var newTickInterval = tickInterval,
  20325. rotation,
  20326. step,
  20327. bestScore = Number.MAX_VALUE,
  20328. autoRotation;
  20329. if (horiz) {
  20330. if (!labelOptions.staggerLines && !labelOptions.step) {
  20331. if (isNumber(rotationOption)) {
  20332. autoRotation = [rotationOption];
  20333. }
  20334. else if (slotSize < labelOptions.autoRotationLimit) {
  20335. autoRotation = labelOptions.autoRotation;
  20336. }
  20337. }
  20338. if (autoRotation) {
  20339. // Loop over the given autoRotation options, and determine
  20340. // which gives the best score. The best score is that with
  20341. // the lowest number of steps and a rotation closest
  20342. // to horizontal.
  20343. autoRotation.forEach(function (rot) {
  20344. var score;
  20345. if (rot === rotationOption ||
  20346. (rot && rot >= -90 && rot <= 90)) { // #3891
  20347. step = getStep(Math.abs(labelMetrics.h / Math.sin(deg2rad * rot)));
  20348. score = step + Math.abs(rot / 360);
  20349. if (score < bestScore) {
  20350. bestScore = score;
  20351. rotation = rot;
  20352. newTickInterval = step;
  20353. }
  20354. }
  20355. });
  20356. }
  20357. }
  20358. else if (!labelOptions.step) { // #4411
  20359. newTickInterval = getStep(labelMetrics.h);
  20360. }
  20361. this.autoRotation = autoRotation;
  20362. this.labelRotation = pick(rotation, isNumber(rotationOption) ? rotationOption : 0);
  20363. return newTickInterval;
  20364. };
  20365. /**
  20366. * Get the general slot width for labels/categories on this axis. This may
  20367. * change between the pre-render (from Axis.getOffset) and the final tick
  20368. * rendering and placement.
  20369. *
  20370. * @private
  20371. * @function Highcharts.Axis#getSlotWidth
  20372. *
  20373. * @param {Highcharts.Tick} [tick] Optionally, calculate the slot width
  20374. * basing on tick label. It is used in highcharts-3d module, where the slots
  20375. * has different widths depending on perspective angles.
  20376. *
  20377. * @return {number}
  20378. * The pixel width allocated to each axis label.
  20379. */
  20380. Axis.prototype.getSlotWidth = function (tick) {
  20381. // #5086, #1580, #1931
  20382. var chart = this.chart,
  20383. horiz = this.horiz,
  20384. labelOptions = this.options.labels,
  20385. slotCount = Math.max(this.tickPositions.length - (this.categories ? 0 : 1), 1),
  20386. marginLeft = chart.margin[3];
  20387. // Used by grid axis
  20388. if (tick && isNumber(tick.slotWidth)) { // #13221, can be 0
  20389. return tick.slotWidth;
  20390. }
  20391. if (horiz && labelOptions.step < 2) {
  20392. if (labelOptions.rotation) { // #4415
  20393. return 0;
  20394. }
  20395. return ((this.staggerLines || 1) * this.len) / slotCount;
  20396. }
  20397. if (!horiz) {
  20398. // #7028
  20399. var cssWidth = labelOptions.style.width;
  20400. if (cssWidth !== void 0) {
  20401. return parseInt(String(cssWidth), 10);
  20402. }
  20403. if (marginLeft) {
  20404. return marginLeft - chart.spacing[3];
  20405. }
  20406. }
  20407. // Last resort, a fraction of the available size
  20408. return chart.chartWidth * 0.33;
  20409. };
  20410. /**
  20411. * Render the axis labels and determine whether ellipsis or rotation need to
  20412. * be applied.
  20413. *
  20414. * @private
  20415. * @function Highcharts.Axis#renderUnsquish
  20416. */
  20417. Axis.prototype.renderUnsquish = function () {
  20418. var chart = this.chart,
  20419. renderer = chart.renderer,
  20420. tickPositions = this.tickPositions,
  20421. ticks = this.ticks,
  20422. labelOptions = this.options.labels,
  20423. labelStyleOptions = labelOptions.style,
  20424. horiz = this.horiz,
  20425. slotWidth = this.getSlotWidth(),
  20426. innerWidth = Math.max(1,
  20427. Math.round(slotWidth - 2 * labelOptions.padding)),
  20428. attr = {},
  20429. labelMetrics = this.labelMetrics(),
  20430. textOverflowOption = labelStyleOptions.textOverflow;
  20431. var commonWidth,
  20432. commonTextOverflow,
  20433. maxLabelLength = 0,
  20434. label,
  20435. i,
  20436. pos;
  20437. // Set rotation option unless it is "auto", like in gauges
  20438. if (!isString(labelOptions.rotation)) {
  20439. // #4443
  20440. attr.rotation = labelOptions.rotation || 0;
  20441. }
  20442. // Get the longest label length
  20443. tickPositions.forEach(function (tickPosition) {
  20444. var tick = ticks[tickPosition];
  20445. // Replace label - sorting animation
  20446. if (tick.movedLabel) {
  20447. tick.replaceMovedLabel();
  20448. }
  20449. if (tick &&
  20450. tick.label &&
  20451. tick.label.textPxLength > maxLabelLength) {
  20452. maxLabelLength = tick.label.textPxLength;
  20453. }
  20454. });
  20455. this.maxLabelLength = maxLabelLength;
  20456. // Handle auto rotation on horizontal axis
  20457. if (this.autoRotation) {
  20458. // Apply rotation only if the label is too wide for the slot, and
  20459. // the label is wider than its height.
  20460. if (maxLabelLength > innerWidth &&
  20461. maxLabelLength > labelMetrics.h) {
  20462. attr.rotation = this.labelRotation;
  20463. }
  20464. else {
  20465. this.labelRotation = 0;
  20466. }
  20467. // Handle word-wrap or ellipsis on vertical axis
  20468. }
  20469. else if (slotWidth) {
  20470. // For word-wrap or ellipsis
  20471. commonWidth = innerWidth;
  20472. if (!textOverflowOption) {
  20473. commonTextOverflow = 'clip';
  20474. // On vertical axis, only allow word wrap if there is room
  20475. // for more lines.
  20476. i = tickPositions.length;
  20477. while (!horiz && i--) {
  20478. pos = tickPositions[i];
  20479. label = ticks[pos].label;
  20480. if (label) {
  20481. // Reset ellipsis in order to get the correct
  20482. // bounding box (#4070)
  20483. if (label.styles &&
  20484. label.styles.textOverflow === 'ellipsis') {
  20485. label.css({ textOverflow: 'clip' });
  20486. // Set the correct width in order to read
  20487. // the bounding box height (#4678, #5034)
  20488. }
  20489. else if (label.textPxLength > slotWidth) {
  20490. label.css({ width: slotWidth + 'px' });
  20491. }
  20492. if (label.getBBox().height > (this.len / tickPositions.length -
  20493. (labelMetrics.h - labelMetrics.f))) {
  20494. label.specificTextOverflow = 'ellipsis';
  20495. }
  20496. }
  20497. }
  20498. }
  20499. }
  20500. // Add ellipsis if the label length is significantly longer than ideal
  20501. if (attr.rotation) {
  20502. commonWidth = (maxLabelLength > chart.chartHeight * 0.5 ?
  20503. chart.chartHeight * 0.33 :
  20504. maxLabelLength);
  20505. if (!textOverflowOption) {
  20506. commonTextOverflow = 'ellipsis';
  20507. }
  20508. }
  20509. // Set the explicit or automatic label alignment
  20510. this.labelAlign = labelOptions.align ||
  20511. this.autoLabelAlign(this.labelRotation);
  20512. if (this.labelAlign) {
  20513. attr.align = this.labelAlign;
  20514. }
  20515. // Apply general and specific CSS
  20516. tickPositions.forEach(function (pos) {
  20517. var tick = ticks[pos],
  20518. label = tick && tick.label,
  20519. widthOption = labelStyleOptions.width,
  20520. css = {};
  20521. if (label) {
  20522. // This needs to go before the CSS in old IE (#4502)
  20523. label.attr(attr);
  20524. if (tick.shortenLabel) {
  20525. tick.shortenLabel();
  20526. }
  20527. else if (commonWidth &&
  20528. !widthOption &&
  20529. // Setting width in this case messes with the bounding box
  20530. // (#7975)
  20531. labelStyleOptions.whiteSpace !== 'nowrap' &&
  20532. (
  20533. // Speed optimizing, #7656
  20534. commonWidth < label.textPxLength ||
  20535. // Resetting CSS, #4928
  20536. label.element.tagName === 'SPAN')) {
  20537. css.width = commonWidth + 'px';
  20538. if (!textOverflowOption) {
  20539. css.textOverflow = (label.specificTextOverflow ||
  20540. commonTextOverflow);
  20541. }
  20542. label.css(css);
  20543. // Reset previously shortened label (#8210)
  20544. }
  20545. else if (label.styles &&
  20546. label.styles.width &&
  20547. !css.width &&
  20548. !widthOption) {
  20549. label.css({ width: null });
  20550. }
  20551. delete label.specificTextOverflow;
  20552. tick.rotation = attr.rotation;
  20553. }
  20554. }, this);
  20555. // Note: Why is this not part of getLabelPosition?
  20556. this.tickRotCorr = renderer.rotCorr(labelMetrics.b, this.labelRotation || 0, this.side !== 0);
  20557. };
  20558. /**
  20559. * Return true if the axis has associated data.
  20560. *
  20561. * @function Highcharts.Axis#hasData
  20562. *
  20563. * @return {boolean}
  20564. * True if the axis has associated visible series and those series have
  20565. * either valid data points or explicit `min` and `max` settings.
  20566. */
  20567. Axis.prototype.hasData = function () {
  20568. return this.series.some(function (s) {
  20569. return s.hasData();
  20570. }) ||
  20571. (this.options.showEmpty &&
  20572. defined(this.min) &&
  20573. defined(this.max));
  20574. };
  20575. /**
  20576. * Adds the title defined in axis.options.title.
  20577. *
  20578. * @function Highcharts.Axis#addTitle
  20579. *
  20580. * @param {boolean} [display]
  20581. * Whether or not to display the title.
  20582. */
  20583. Axis.prototype.addTitle = function (display) {
  20584. var axis = this,
  20585. renderer = axis.chart.renderer,
  20586. horiz = axis.horiz,
  20587. opposite = axis.opposite,
  20588. options = axis.options,
  20589. axisTitleOptions = options.title,
  20590. styledMode = axis.chart.styledMode;
  20591. var textAlign;
  20592. if (!axis.axisTitle) {
  20593. textAlign = axisTitleOptions.textAlign;
  20594. if (!textAlign) {
  20595. textAlign = (horiz ? {
  20596. low: 'left',
  20597. middle: 'center',
  20598. high: 'right'
  20599. } : {
  20600. low: opposite ? 'right' : 'left',
  20601. middle: 'center',
  20602. high: opposite ? 'left' : 'right'
  20603. })[axisTitleOptions.align];
  20604. }
  20605. axis.axisTitle = renderer
  20606. .text(axisTitleOptions.text || '', 0, 0, axisTitleOptions.useHTML)
  20607. .attr({
  20608. zIndex: 7,
  20609. rotation: axisTitleOptions.rotation,
  20610. align: textAlign
  20611. })
  20612. .addClass('highcharts-axis-title');
  20613. // #7814, don't mutate style option
  20614. if (!styledMode) {
  20615. axis.axisTitle.css(merge(axisTitleOptions.style));
  20616. }
  20617. axis.axisTitle.add(axis.axisGroup);
  20618. axis.axisTitle.isNew = true;
  20619. }
  20620. // Max width defaults to the length of the axis
  20621. if (!styledMode &&
  20622. !axisTitleOptions.style.width &&
  20623. !axis.isRadial) {
  20624. axis.axisTitle.css({
  20625. width: axis.len + 'px'
  20626. });
  20627. }
  20628. // hide or show the title depending on whether showEmpty is set
  20629. axis.axisTitle[display ? 'show' : 'hide'](display);
  20630. };
  20631. /**
  20632. * Generates a tick for initial positioning.
  20633. *
  20634. * @private
  20635. * @function Highcharts.Axis#generateTick
  20636. *
  20637. * @param {number} pos
  20638. * The tick position in axis values.
  20639. *
  20640. * @param {number} [i]
  20641. * The index of the tick in {@link Axis.tickPositions}.
  20642. */
  20643. Axis.prototype.generateTick = function (pos) {
  20644. var axis = this,
  20645. ticks = axis.ticks;
  20646. if (!ticks[pos]) {
  20647. ticks[pos] = new Tick(axis, pos);
  20648. }
  20649. else {
  20650. ticks[pos].addLabel(); // update labels depending on tick interval
  20651. }
  20652. };
  20653. /**
  20654. * Render the tick labels to a preliminary position to get their sizes
  20655. *
  20656. * @private
  20657. * @function Highcharts.Axis#getOffset
  20658. *
  20659. * @fires Highcharts.Axis#event:afterGetOffset
  20660. */
  20661. Axis.prototype.getOffset = function () {
  20662. var _this = this;
  20663. var axis = this,
  20664. chart = axis.chart,
  20665. renderer = chart.renderer,
  20666. options = axis.options,
  20667. tickPositions = axis.tickPositions,
  20668. ticks = axis.ticks,
  20669. horiz = axis.horiz,
  20670. side = axis.side,
  20671. invertedSide = (chart.inverted && !axis.isZAxis ?
  20672. [1, 0, 3, 2][side] :
  20673. side),
  20674. hasData = axis.hasData(),
  20675. axisTitleOptions = options.title,
  20676. labelOptions = options.labels,
  20677. axisOffset = chart.axisOffset,
  20678. clipOffset = chart.clipOffset,
  20679. directionFactor = [-1, 1, 1, -1][side],
  20680. className = options.className,
  20681. axisParent = axis.axisParent; // Used in color axis
  20682. var showAxis,
  20683. titleOffset = 0,
  20684. titleOffsetOption,
  20685. titleMargin = 0,
  20686. labelOffset = 0, // reset
  20687. labelOffsetPadded,
  20688. lineHeightCorrection;
  20689. // For reuse in Axis.render
  20690. axis.showAxis = showAxis = hasData || options.showEmpty;
  20691. // Set/reset staggerLines
  20692. axis.staggerLines = (axis.horiz && labelOptions.staggerLines) || void 0;
  20693. // Create the axisGroup and gridGroup elements on first iteration
  20694. if (!axis.axisGroup) {
  20695. var createGroup = function (name,
  20696. suffix,
  20697. zIndex) { return renderer.g(name)
  20698. .attr({ zIndex: zIndex })
  20699. .addClass("highcharts-" + _this.coll.toLowerCase() + suffix + " " +
  20700. (_this.isRadial ? "highcharts-radial-axis" + suffix + " " : '') +
  20701. (className || ''))
  20702. .add(axisParent); };
  20703. axis.gridGroup = createGroup('grid', '-grid', options.gridZIndex);
  20704. axis.axisGroup = createGroup('axis', '', options.zIndex);
  20705. axis.labelGroup = createGroup('axis-labels', '-labels', labelOptions.zIndex);
  20706. }
  20707. if (hasData || axis.isLinked) {
  20708. // Generate ticks
  20709. tickPositions.forEach(function (pos) {
  20710. // i is not used here, but may be used in overrides
  20711. axis.generateTick(pos);
  20712. });
  20713. axis.renderUnsquish();
  20714. // Left side must be align: right and right side must
  20715. // have align: left for labels
  20716. axis.reserveSpaceDefault = (side === 0 ||
  20717. side === 2 ||
  20718. { 1: 'left', 3: 'right' }[side] === axis.labelAlign);
  20719. if (pick(labelOptions.reserveSpace, axis.labelAlign === 'center' ? true : null, axis.reserveSpaceDefault)) {
  20720. tickPositions.forEach(function (pos) {
  20721. // get the highest offset
  20722. labelOffset = Math.max(ticks[pos].getLabelSize(), labelOffset);
  20723. });
  20724. }
  20725. if (axis.staggerLines) {
  20726. labelOffset *= axis.staggerLines;
  20727. }
  20728. axis.labelOffset = labelOffset * (axis.opposite ? -1 : 1);
  20729. }
  20730. else { // doesn't have data
  20731. objectEach(ticks, function (tick, n) {
  20732. tick.destroy();
  20733. delete ticks[n];
  20734. });
  20735. }
  20736. if (axisTitleOptions &&
  20737. axisTitleOptions.text &&
  20738. axisTitleOptions.enabled !== false) {
  20739. axis.addTitle(showAxis);
  20740. if (showAxis && axisTitleOptions.reserveSpace !== false) {
  20741. axis.titleOffset = titleOffset =
  20742. axis.axisTitle.getBBox()[horiz ? 'height' : 'width'];
  20743. titleOffsetOption = axisTitleOptions.offset;
  20744. titleMargin = defined(titleOffsetOption) ?
  20745. 0 :
  20746. pick(axisTitleOptions.margin, horiz ? 5 : 10);
  20747. }
  20748. }
  20749. // Render the axis line
  20750. axis.renderLine();
  20751. // handle automatic or user set offset
  20752. axis.offset = directionFactor * pick(options.offset, axisOffset[side] ? axisOffset[side] + (options.margin || 0) : 0);
  20753. axis.tickRotCorr = axis.tickRotCorr || { x: 0, y: 0 }; // polar
  20754. if (side === 0) {
  20755. lineHeightCorrection = -axis.labelMetrics().h;
  20756. }
  20757. else if (side === 2) {
  20758. lineHeightCorrection = axis.tickRotCorr.y;
  20759. }
  20760. else {
  20761. lineHeightCorrection = 0;
  20762. }
  20763. // Find the padded label offset
  20764. labelOffsetPadded = Math.abs(labelOffset) + titleMargin;
  20765. if (labelOffset) {
  20766. labelOffsetPadded -= lineHeightCorrection;
  20767. labelOffsetPadded += directionFactor * (horiz ?
  20768. pick(labelOptions.y, axis.tickRotCorr.y + directionFactor * 8) :
  20769. labelOptions.x);
  20770. }
  20771. axis.axisTitleMargin = pick(titleOffsetOption, labelOffsetPadded);
  20772. if (axis.getMaxLabelDimensions) {
  20773. axis.maxLabelDimensions = axis.getMaxLabelDimensions(ticks, tickPositions);
  20774. }
  20775. // Due to GridAxis.tickSize, tickSize should be calculated after ticks
  20776. // has rendered.
  20777. var tickSize = this.tickSize('tick');
  20778. axisOffset[side] = Math.max(axisOffset[side], (axis.axisTitleMargin || 0) + titleOffset +
  20779. directionFactor * axis.offset, labelOffsetPadded, // #3027
  20780. tickPositions && tickPositions.length && tickSize ?
  20781. tickSize[0] + directionFactor * axis.offset :
  20782. 0 // #4866
  20783. );
  20784. // Decide the clipping needed to keep the graph inside
  20785. // the plot area and axis lines
  20786. var clip = options.offset ?
  20787. 0 :
  20788. // #4308, #4371:
  20789. Math.floor(axis.axisLine.strokeWidth() / 2) * 2;
  20790. clipOffset[invertedSide] =
  20791. Math.max(clipOffset[invertedSide], clip);
  20792. fireEvent(this, 'afterGetOffset');
  20793. };
  20794. /**
  20795. * Internal function to get the path for the axis line. Extended for polar
  20796. * charts.
  20797. *
  20798. * @function Highcharts.Axis#getLinePath
  20799. *
  20800. * @param {number} lineWidth
  20801. * The line width in pixels.
  20802. *
  20803. * @return {Highcharts.SVGPathArray}
  20804. * The SVG path definition in array form.
  20805. */
  20806. Axis.prototype.getLinePath = function (lineWidth) {
  20807. var chart = this.chart,
  20808. opposite = this.opposite,
  20809. offset = this.offset,
  20810. horiz = this.horiz,
  20811. lineLeft = this.left + (opposite ? this.width : 0) + offset,
  20812. lineTop = chart.chartHeight - this.bottom -
  20813. (opposite ? this.height : 0) + offset;
  20814. if (opposite) {
  20815. lineWidth *= -1; // crispify the other way - #1480, #1687
  20816. }
  20817. return chart.renderer
  20818. .crispLine([
  20819. [
  20820. 'M',
  20821. horiz ?
  20822. this.left :
  20823. lineLeft,
  20824. horiz ?
  20825. lineTop :
  20826. this.top
  20827. ],
  20828. [
  20829. 'L',
  20830. horiz ?
  20831. chart.chartWidth - this.right :
  20832. lineLeft,
  20833. horiz ?
  20834. lineTop :
  20835. chart.chartHeight - this.bottom
  20836. ]
  20837. ], lineWidth);
  20838. };
  20839. /**
  20840. * Render the axis line. Called internally when rendering and redrawing the
  20841. * axis.
  20842. *
  20843. * @function Highcharts.Axis#renderLine
  20844. */
  20845. Axis.prototype.renderLine = function () {
  20846. if (!this.axisLine) {
  20847. this.axisLine = this.chart.renderer.path()
  20848. .addClass('highcharts-axis-line')
  20849. .add(this.axisGroup);
  20850. if (!this.chart.styledMode) {
  20851. this.axisLine.attr({
  20852. stroke: this.options.lineColor,
  20853. 'stroke-width': this.options.lineWidth,
  20854. zIndex: 7
  20855. });
  20856. }
  20857. }
  20858. };
  20859. /**
  20860. * Position the axis title.
  20861. *
  20862. * @private
  20863. * @function Highcharts.Axis#getTitlePosition
  20864. *
  20865. * @return {Highcharts.PositionObject}
  20866. * X and Y positions for the title.
  20867. */
  20868. Axis.prototype.getTitlePosition = function () {
  20869. // compute anchor points for each of the title align options
  20870. var horiz = this.horiz,
  20871. axisLeft = this.left,
  20872. axisTop = this.top,
  20873. axisLength = this.len,
  20874. axisTitleOptions = this.options.title,
  20875. margin = horiz ? axisLeft : axisTop,
  20876. opposite = this.opposite,
  20877. offset = this.offset,
  20878. xOption = axisTitleOptions.x,
  20879. yOption = axisTitleOptions.y,
  20880. axisTitle = this.axisTitle,
  20881. fontMetrics = this.chart.renderer.fontMetrics(axisTitleOptions.style.fontSize,
  20882. axisTitle),
  20883. // The part of a multiline text that is below the baseline of the
  20884. // first line. Subtract 1 to preserve pixel-perfectness from the
  20885. // old behaviour (v5.0.12), where only one line was allowed.
  20886. textHeightOvershoot = Math.max(axisTitle.getBBox(null, 0).height - fontMetrics.h - 1, 0),
  20887. // the position in the length direction of the axis
  20888. alongAxis = {
  20889. low: margin + (horiz ? 0 : axisLength),
  20890. middle: margin + axisLength / 2,
  20891. high: margin + (horiz ? axisLength : 0)
  20892. }[axisTitleOptions.align],
  20893. // the position in the perpendicular direction of the axis
  20894. offAxis = (horiz ? axisTop + this.height : axisLeft) +
  20895. (horiz ? 1 : -1) * // horizontal axis reverses the margin
  20896. (opposite ? -1 : 1) * // so does opposite axes
  20897. this.axisTitleMargin +
  20898. [
  20899. -textHeightOvershoot,
  20900. textHeightOvershoot,
  20901. fontMetrics.f,
  20902. -textHeightOvershoot // left
  20903. ][this.side],
  20904. titlePosition = {
  20905. x: horiz ?
  20906. alongAxis + xOption :
  20907. offAxis + (opposite ? this.width : 0) + offset + xOption,
  20908. y: horiz ?
  20909. offAxis + yOption - (opposite ? this.height : 0) + offset :
  20910. alongAxis + yOption
  20911. };
  20912. fireEvent(this, 'afterGetTitlePosition', { titlePosition: titlePosition });
  20913. return titlePosition;
  20914. };
  20915. /**
  20916. * Render a minor tick into the given position. If a minor tick already
  20917. * exists in this position, move it.
  20918. *
  20919. * @function Highcharts.Axis#renderMinorTick
  20920. *
  20921. * @param {number} pos
  20922. * The position in axis values.
  20923. */
  20924. Axis.prototype.renderMinorTick = function (pos) {
  20925. var axis = this;
  20926. var slideInTicks = axis.chart.hasRendered && axis.old;
  20927. var minorTicks = axis.minorTicks;
  20928. if (!minorTicks[pos]) {
  20929. minorTicks[pos] = new Tick(axis, pos, 'minor');
  20930. }
  20931. // Render new ticks in old position
  20932. if (slideInTicks && minorTicks[pos].isNew) {
  20933. minorTicks[pos].render(null, true);
  20934. }
  20935. minorTicks[pos].render(null, false, 1);
  20936. };
  20937. /**
  20938. * Render a major tick into the given position. If a tick already exists
  20939. * in this position, move it.
  20940. *
  20941. * @function Highcharts.Axis#renderTick
  20942. *
  20943. * @param {number} pos
  20944. * The position in axis values.
  20945. *
  20946. * @param {number} i
  20947. * The tick index.
  20948. */
  20949. Axis.prototype.renderTick = function (pos, i) {
  20950. var axis = this,
  20951. isLinked = axis.isLinked,
  20952. ticks = axis.ticks,
  20953. slideInTicks = axis.chart.hasRendered && axis.old;
  20954. // Linked axes need an extra check to find out if
  20955. if (!isLinked ||
  20956. (pos >= axis.min && pos <= axis.max) ||
  20957. (axis.grid && axis.grid.isColumn)) {
  20958. if (!ticks[pos]) {
  20959. ticks[pos] = new Tick(axis, pos);
  20960. }
  20961. // NOTE this seems like overkill. Could be handled in tick.render by
  20962. // setting old position in attr, then set new position in animate.
  20963. // render new ticks in old position
  20964. if (slideInTicks && ticks[pos].isNew) {
  20965. // Start with negative opacity so that it is visible from
  20966. // halfway into the animation
  20967. ticks[pos].render(i, true, -1);
  20968. }
  20969. ticks[pos].render(i);
  20970. }
  20971. };
  20972. /**
  20973. * Render the axis.
  20974. *
  20975. * @private
  20976. * @function Highcharts.Axis#render
  20977. *
  20978. * @fires Highcharts.Axis#event:afterRender
  20979. */
  20980. Axis.prototype.render = function () {
  20981. var axis = this,
  20982. chart = axis.chart,
  20983. log = axis.logarithmic,
  20984. renderer = chart.renderer,
  20985. options = axis.options,
  20986. isLinked = axis.isLinked,
  20987. tickPositions = axis.tickPositions,
  20988. axisTitle = axis.axisTitle,
  20989. ticks = axis.ticks,
  20990. minorTicks = axis.minorTicks,
  20991. alternateBands = axis.alternateBands,
  20992. stackLabelOptions = options.stackLabels,
  20993. alternateGridColor = options.alternateGridColor,
  20994. tickmarkOffset = axis.tickmarkOffset,
  20995. axisLine = axis.axisLine,
  20996. showAxis = axis.showAxis,
  20997. animation = animObject(renderer.globalAnimation);
  20998. var from,
  20999. to;
  21000. // Reset
  21001. axis.labelEdge.length = 0;
  21002. axis.overlap = false;
  21003. // Mark all elements inActive before we go over and mark the active ones
  21004. [ticks, minorTicks, alternateBands].forEach(function (coll) {
  21005. objectEach(coll, function (tick) {
  21006. tick.isActive = false;
  21007. });
  21008. });
  21009. // If the series has data draw the ticks. Else only the line and title
  21010. if (axis.hasData() || isLinked) {
  21011. // minor ticks
  21012. if (axis.minorTickInterval && !axis.categories) {
  21013. axis.getMinorTickPositions().forEach(function (pos) {
  21014. axis.renderMinorTick(pos);
  21015. });
  21016. }
  21017. // Major ticks. Pull out the first item and render it last so that
  21018. // we can get the position of the neighbour label. #808.
  21019. if (tickPositions.length) { // #1300
  21020. tickPositions.forEach(function (pos, i) {
  21021. axis.renderTick(pos, i);
  21022. });
  21023. // In a categorized axis, the tick marks are displayed
  21024. // between labels. So we need to add a tick mark and
  21025. // grid line at the left edge of the X axis.
  21026. if (tickmarkOffset && (axis.min === 0 || axis.single)) {
  21027. if (!ticks[-1]) {
  21028. ticks[-1] = new Tick(axis, -1, null, true);
  21029. }
  21030. ticks[-1].render(-1);
  21031. }
  21032. }
  21033. // alternate grid color
  21034. if (alternateGridColor) {
  21035. tickPositions.forEach(function (pos, i) {
  21036. to = typeof tickPositions[i + 1] !== 'undefined' ?
  21037. tickPositions[i + 1] + tickmarkOffset :
  21038. axis.max - tickmarkOffset;
  21039. if (i % 2 === 0 &&
  21040. pos < axis.max &&
  21041. to <= axis.max + (chart.polar ?
  21042. -tickmarkOffset :
  21043. tickmarkOffset)) { // #2248, #4660
  21044. if (!alternateBands[pos]) {
  21045. // Should be imported from PlotLineOrBand.js, but
  21046. // the dependency cycle with axis is a problem
  21047. alternateBands[pos] = new H.PlotLineOrBand(axis);
  21048. }
  21049. from = pos + tickmarkOffset; // #949
  21050. alternateBands[pos].options = {
  21051. from: log ? log.lin2log(from) : from,
  21052. to: log ? log.lin2log(to) : to,
  21053. color: alternateGridColor,
  21054. className: 'highcharts-alternate-grid'
  21055. };
  21056. alternateBands[pos].render();
  21057. alternateBands[pos].isActive = true;
  21058. }
  21059. });
  21060. }
  21061. // custom plot lines and bands
  21062. if (!axis._addedPlotLB) { // only first time
  21063. axis._addedPlotLB = true;
  21064. (options.plotLines || [])
  21065. .concat(options.plotBands || [])
  21066. .forEach(function (plotLineOptions) {
  21067. axis.addPlotBandOrLine(plotLineOptions);
  21068. });
  21069. }
  21070. } // end if hasData
  21071. // Remove inactive ticks
  21072. [ticks, minorTicks, alternateBands].forEach(function (coll) {
  21073. var forDestruction = [],
  21074. delay = animation.duration,
  21075. destroyInactiveItems = function () {
  21076. var i = forDestruction.length;
  21077. while (i--) {
  21078. // When resizing rapidly, the same items
  21079. // may be destroyed in different timeouts,
  21080. // or the may be reactivated
  21081. if (coll[forDestruction[i]] &&
  21082. !coll[forDestruction[i]].isActive) {
  21083. coll[forDestruction[i]].destroy();
  21084. delete coll[forDestruction[i]];
  21085. }
  21086. }
  21087. };
  21088. objectEach(coll, function (tick, pos) {
  21089. if (!tick.isActive) {
  21090. // Render to zero opacity
  21091. tick.render(pos, false, 0);
  21092. tick.isActive = false;
  21093. forDestruction.push(pos);
  21094. }
  21095. });
  21096. // When the objects are finished fading out, destroy them
  21097. syncTimeout(destroyInactiveItems, coll === alternateBands ||
  21098. !chart.hasRendered ||
  21099. !delay ?
  21100. 0 :
  21101. delay);
  21102. });
  21103. // Set the axis line path
  21104. if (axisLine) {
  21105. axisLine[axisLine.isPlaced ? 'animate' : 'attr']({
  21106. d: this.getLinePath(axisLine.strokeWidth())
  21107. });
  21108. axisLine.isPlaced = true;
  21109. // Show or hide the line depending on options.showEmpty
  21110. axisLine[showAxis ? 'show' : 'hide'](showAxis);
  21111. }
  21112. if (axisTitle && showAxis) {
  21113. var titleXy = axis.getTitlePosition();
  21114. if (isNumber(titleXy.y)) {
  21115. axisTitle[axisTitle.isNew ? 'attr' : 'animate'](titleXy);
  21116. axisTitle.isNew = false;
  21117. }
  21118. else {
  21119. axisTitle.attr('y', -9999);
  21120. axisTitle.isNew = true;
  21121. }
  21122. }
  21123. // Stacked totals:
  21124. if (stackLabelOptions && stackLabelOptions.enabled && axis.stacking) {
  21125. axis.stacking.renderStackTotals();
  21126. }
  21127. // End stacked totals
  21128. // Record old scaling for updating/animation
  21129. axis.old = {
  21130. len: axis.len,
  21131. max: axis.max,
  21132. min: axis.min,
  21133. transA: axis.transA,
  21134. userMax: axis.userMax,
  21135. userMin: axis.userMin
  21136. };
  21137. axis.isDirty = false;
  21138. fireEvent(this, 'afterRender');
  21139. };
  21140. /**
  21141. * Redraw the axis to reflect changes in the data or axis extremes. Called
  21142. * internally from Highcharts.Chart#redraw.
  21143. *
  21144. * @private
  21145. * @function Highcharts.Axis#redraw
  21146. */
  21147. Axis.prototype.redraw = function () {
  21148. if (this.visible) {
  21149. // render the axis
  21150. this.render();
  21151. // move plot lines and bands
  21152. this.plotLinesAndBands.forEach(function (plotLine) {
  21153. plotLine.render();
  21154. });
  21155. }
  21156. // mark associated series as dirty and ready for redraw
  21157. this.series.forEach(function (series) {
  21158. series.isDirty = true;
  21159. });
  21160. };
  21161. /**
  21162. * Returns an array of axis properties, that should be untouched during
  21163. * reinitialization.
  21164. *
  21165. * @private
  21166. * @function Highcharts.Axis#getKeepProps
  21167. *
  21168. * @return {Array<string>}
  21169. */
  21170. Axis.prototype.getKeepProps = function () {
  21171. return (this.keepProps || Axis.keepProps);
  21172. };
  21173. /**
  21174. * Destroys an Axis instance. See {@link Axis#remove} for the API endpoint
  21175. * to fully remove the axis.
  21176. *
  21177. * @private
  21178. * @function Highcharts.Axis#destroy
  21179. *
  21180. * @param {boolean} [keepEvents]
  21181. * Whether to preserve events, used internally in Axis.update.
  21182. */
  21183. Axis.prototype.destroy = function (keepEvents) {
  21184. var axis = this,
  21185. plotLinesAndBands = axis.plotLinesAndBands,
  21186. eventOptions = this.eventOptions;
  21187. fireEvent(this, 'destroy', { keepEvents: keepEvents });
  21188. // Remove the events
  21189. if (!keepEvents) {
  21190. removeEvent(axis);
  21191. }
  21192. // Destroy collections
  21193. [axis.ticks, axis.minorTicks, axis.alternateBands].forEach(function (coll) {
  21194. destroyObjectProperties(coll);
  21195. });
  21196. if (plotLinesAndBands) {
  21197. var i = plotLinesAndBands.length;
  21198. while (i--) { // #1975
  21199. plotLinesAndBands[i].destroy();
  21200. }
  21201. }
  21202. // Destroy elements
  21203. ['axisLine', 'axisTitle', 'axisGroup',
  21204. 'gridGroup', 'labelGroup', 'cross', 'scrollbar'].forEach(function (prop) {
  21205. if (axis[prop]) {
  21206. axis[prop] = axis[prop].destroy();
  21207. }
  21208. });
  21209. // Destroy each generated group for plotlines and plotbands
  21210. for (var plotGroup in axis.plotLinesAndBandsGroups) { // eslint-disable-line guard-for-in
  21211. axis.plotLinesAndBandsGroups[plotGroup] =
  21212. axis.plotLinesAndBandsGroups[plotGroup].destroy();
  21213. }
  21214. // Delete all properties and fall back to the prototype.
  21215. objectEach(axis, function (val, key) {
  21216. if (axis.getKeepProps().indexOf(key) === -1) {
  21217. delete axis[key];
  21218. }
  21219. });
  21220. this.eventOptions = eventOptions;
  21221. };
  21222. /**
  21223. * Internal function to draw a crosshair.
  21224. *
  21225. * @function Highcharts.Axis#drawCrosshair
  21226. *
  21227. * @param {Highcharts.PointerEventObject} [e]
  21228. * The event arguments from the modified pointer event, extended with
  21229. * `chartX` and `chartY`
  21230. *
  21231. * @param {Highcharts.Point} [point]
  21232. * The Point object if the crosshair snaps to points.
  21233. *
  21234. * @fires Highcharts.Axis#event:afterDrawCrosshair
  21235. * @fires Highcharts.Axis#event:drawCrosshair
  21236. */
  21237. Axis.prototype.drawCrosshair = function (e, point) {
  21238. var options = this.crosshair,
  21239. snap = pick(options && options.snap,
  21240. true),
  21241. chart = this.chart;
  21242. var path,
  21243. pos,
  21244. categorized,
  21245. graphic = this.cross,
  21246. crossOptions;
  21247. fireEvent(this, 'drawCrosshair', { e: e, point: point });
  21248. // Use last available event when updating non-snapped crosshairs without
  21249. // mouse interaction (#5287)
  21250. if (!e) {
  21251. e = this.cross && this.cross.e;
  21252. }
  21253. if (
  21254. // Disabled in options
  21255. !options ||
  21256. // Snap
  21257. ((defined(point) || !snap) === false)) {
  21258. this.hideCrosshair();
  21259. }
  21260. else {
  21261. // Get the path
  21262. if (!snap) {
  21263. pos = e &&
  21264. (this.horiz ?
  21265. e.chartX - this.pos :
  21266. this.len - e.chartY + this.pos);
  21267. }
  21268. else if (defined(point)) {
  21269. // #3834
  21270. pos = pick(this.coll !== 'colorAxis' ?
  21271. point.crosshairPos : // 3D axis extension
  21272. null, this.isXAxis ?
  21273. point.plotX :
  21274. this.len - point.plotY);
  21275. }
  21276. if (defined(pos)) {
  21277. crossOptions = {
  21278. // value, only used on radial
  21279. value: point && (this.isXAxis ?
  21280. point.x :
  21281. pick(point.stackY, point.y)),
  21282. translatedValue: pos
  21283. };
  21284. if (chart.polar) {
  21285. // Additional information required for crosshairs in
  21286. // polar chart
  21287. extend(crossOptions, {
  21288. isCrosshair: true,
  21289. chartX: e && e.chartX,
  21290. chartY: e && e.chartY,
  21291. point: point
  21292. });
  21293. }
  21294. path = this.getPlotLinePath(crossOptions) ||
  21295. null; // #3189
  21296. }
  21297. if (!defined(path)) {
  21298. this.hideCrosshair();
  21299. return;
  21300. }
  21301. categorized = this.categories && !this.isRadial;
  21302. // Draw the cross
  21303. if (!graphic) {
  21304. this.cross = graphic = chart.renderer
  21305. .path()
  21306. .addClass('highcharts-crosshair highcharts-crosshair-' +
  21307. (categorized ? 'category ' : 'thin ') +
  21308. (options.className || ''))
  21309. .attr({
  21310. zIndex: pick(options.zIndex, 2)
  21311. })
  21312. .add();
  21313. // Presentational attributes
  21314. if (!chart.styledMode) {
  21315. graphic.attr({
  21316. stroke: options.color ||
  21317. (categorized ?
  21318. Color
  21319. .parse(Palette.highlightColor20)
  21320. .setOpacity(0.25)
  21321. .get() :
  21322. Palette.neutralColor20),
  21323. 'stroke-width': pick(options.width, 1)
  21324. }).css({
  21325. 'pointer-events': 'none'
  21326. });
  21327. if (options.dashStyle) {
  21328. graphic.attr({
  21329. dashstyle: options.dashStyle
  21330. });
  21331. }
  21332. }
  21333. }
  21334. graphic.show().attr({
  21335. d: path
  21336. });
  21337. if (categorized && !options.width) {
  21338. graphic.attr({
  21339. 'stroke-width': this.transA
  21340. });
  21341. }
  21342. this.cross.e = e;
  21343. }
  21344. fireEvent(this, 'afterDrawCrosshair', { e: e, point: point });
  21345. };
  21346. /**
  21347. * Hide the crosshair if visible.
  21348. *
  21349. * @function Highcharts.Axis#hideCrosshair
  21350. */
  21351. Axis.prototype.hideCrosshair = function () {
  21352. if (this.cross) {
  21353. this.cross.hide();
  21354. }
  21355. fireEvent(this, 'afterHideCrosshair');
  21356. };
  21357. /**
  21358. * Check whether the chart has vertical panning ('y' or 'xy' type).
  21359. *
  21360. * @private
  21361. * @function Highcharts.Axis#hasVerticalPanning
  21362. *
  21363. * @return {boolean}
  21364. */
  21365. Axis.prototype.hasVerticalPanning = function () {
  21366. var panningOptions = this.chart.options.chart.panning;
  21367. return Boolean(panningOptions &&
  21368. panningOptions.enabled && // #14624
  21369. /y/.test(panningOptions.type));
  21370. };
  21371. /**
  21372. * Check whether the given value is a positive valid axis value.
  21373. *
  21374. * @private
  21375. * @function Highcharts.Axis#validatePositiveValue
  21376. *
  21377. * @param {unknown} value
  21378. * The axis value
  21379. *
  21380. * @return {boolean}
  21381. */
  21382. Axis.prototype.validatePositiveValue = function (value) {
  21383. return isNumber(value) && value > 0;
  21384. };
  21385. /**
  21386. * Update an axis object with a new set of options. The options are merged
  21387. * with the existing options, so only new or altered options need to be
  21388. * specified.
  21389. *
  21390. * @sample highcharts/members/axis-update/
  21391. * Axis update demo
  21392. *
  21393. * @function Highcharts.Axis#update
  21394. *
  21395. * @param {Highcharts.AxisOptions} options
  21396. * The new options that will be merged in with existing options on the axis.
  21397. *
  21398. * @param {boolean} [redraw=true]
  21399. * Whether to redraw the chart after the axis is altered. If doing more
  21400. * operations on the chart, it is a good idea to set redraw to false and
  21401. * call {@link Chart#redraw} after.
  21402. */
  21403. Axis.prototype.update = function (options, redraw) {
  21404. var chart = this.chart;
  21405. options = merge(this.userOptions, options);
  21406. this.destroy(true);
  21407. this.init(chart, options);
  21408. chart.isDirtyBox = true;
  21409. if (pick(redraw, true)) {
  21410. chart.redraw();
  21411. }
  21412. };
  21413. /**
  21414. * Remove the axis from the chart.
  21415. *
  21416. * @sample highcharts/members/chart-addaxis/
  21417. * Add and remove axes
  21418. *
  21419. * @function Highcharts.Axis#remove
  21420. *
  21421. * @param {boolean} [redraw=true]
  21422. * Whether to redraw the chart following the remove.
  21423. */
  21424. Axis.prototype.remove = function (redraw) {
  21425. var chart = this.chart,
  21426. key = this.coll, // xAxis or yAxis
  21427. axisSeries = this.series;
  21428. var i = axisSeries.length;
  21429. // Remove associated series (#2687)
  21430. while (i--) {
  21431. if (axisSeries[i]) {
  21432. axisSeries[i].remove(false);
  21433. }
  21434. }
  21435. // Remove the axis
  21436. erase(chart.axes, this);
  21437. erase(chart[key], this);
  21438. chart[key].forEach(function (axis, i) {
  21439. // Re-index, #1706, #8075
  21440. axis.options.index = axis.userOptions.index = i;
  21441. });
  21442. this.destroy();
  21443. chart.isDirtyBox = true;
  21444. if (pick(redraw, true)) {
  21445. chart.redraw();
  21446. }
  21447. };
  21448. /**
  21449. * Update the axis title by options after render time.
  21450. *
  21451. * @sample highcharts/members/axis-settitle/
  21452. * Set a new Y axis title
  21453. *
  21454. * @function Highcharts.Axis#setTitle
  21455. *
  21456. * @param {Highcharts.AxisTitleOptions} titleOptions
  21457. * The additional title options.
  21458. *
  21459. * @param {boolean} [redraw=true]
  21460. * Whether to redraw the chart after setting the title.
  21461. */
  21462. Axis.prototype.setTitle = function (titleOptions, redraw) {
  21463. this.update({ title: titleOptions }, redraw);
  21464. };
  21465. /**
  21466. * Set new axis categories and optionally redraw.
  21467. *
  21468. * @sample highcharts/members/axis-setcategories/
  21469. * Set categories by click on a button
  21470. *
  21471. * @function Highcharts.Axis#setCategories
  21472. *
  21473. * @param {Array<string>} categories
  21474. * The new categories.
  21475. *
  21476. * @param {boolean} [redraw=true]
  21477. * Whether to redraw the chart.
  21478. */
  21479. Axis.prototype.setCategories = function (categories, redraw) {
  21480. this.update({ categories: categories }, redraw);
  21481. };
  21482. /* *
  21483. *
  21484. * Static Properties
  21485. *
  21486. * */
  21487. Axis.defaultOptions = AxisDefaults.defaultXAxisOptions;
  21488. // Properties to survive after destroy, needed for Axis.update (#4317,
  21489. // #5773, #5881).
  21490. Axis.keepProps = ['extKey', 'hcEvents', 'names', 'series', 'userMax', 'userMin'];
  21491. return Axis;
  21492. }());
  21493. /* *
  21494. *
  21495. * Default Export
  21496. *
  21497. * */
  21498. /* *
  21499. *
  21500. * API Declarations
  21501. *
  21502. * */
  21503. /**
  21504. * Options for the path on the Axis to be calculated.
  21505. * @interface Highcharts.AxisPlotLinePathOptionsObject
  21506. */ /**
  21507. * Axis value.
  21508. * @name Highcharts.AxisPlotLinePathOptionsObject#value
  21509. * @type {number|undefined}
  21510. */ /**
  21511. * Line width used for calculation crisp line coordinates. Defaults to 1.
  21512. * @name Highcharts.AxisPlotLinePathOptionsObject#lineWidth
  21513. * @type {number|undefined}
  21514. */ /**
  21515. * If `false`, the function will return null when it falls outside the axis
  21516. * bounds. If `true`, the function will return a path aligned to the plot area
  21517. * sides if it falls outside. If `pass`, it will return a path outside.
  21518. * @name Highcharts.AxisPlotLinePathOptionsObject#force
  21519. * @type {string|boolean|undefined}
  21520. */ /**
  21521. * Used in Highcharts Stock. When `true`, plot paths
  21522. * (crosshair, plotLines, gridLines)
  21523. * will be rendered on all axes when defined on the first axis.
  21524. * @name Highcharts.AxisPlotLinePathOptionsObject#acrossPanes
  21525. * @type {boolean|undefined}
  21526. */ /**
  21527. * Use old coordinates (for resizing and rescaling).
  21528. * If not set, defaults to `false`.
  21529. * @name Highcharts.AxisPlotLinePathOptionsObject#old
  21530. * @type {boolean|undefined}
  21531. */ /**
  21532. * If given, return the plot line path of a pixel position on the axis.
  21533. * @name Highcharts.AxisPlotLinePathOptionsObject#translatedValue
  21534. * @type {number|undefined}
  21535. */ /**
  21536. * Used in Polar axes. Reverse the positions for concatenation of polygonal
  21537. * plot bands
  21538. * @name Highcharts.AxisPlotLinePathOptionsObject#reverse
  21539. * @type {boolean|undefined}
  21540. */
  21541. /**
  21542. * Options for crosshairs on axes.
  21543. *
  21544. * @product highstock
  21545. *
  21546. * @typedef {Highcharts.XAxisCrosshairOptions|Highcharts.YAxisCrosshairOptions} Highcharts.AxisCrosshairOptions
  21547. */
  21548. /**
  21549. * @typedef {"navigator"|"pan"|"rangeSelectorButton"|"rangeSelectorInput"|"scrollbar"|"traverseUpButton"|"zoom"} Highcharts.AxisExtremesTriggerValue
  21550. */
  21551. /**
  21552. * @callback Highcharts.AxisEventCallbackFunction
  21553. *
  21554. * @param {Highcharts.Axis} this
  21555. */
  21556. /**
  21557. * @callback Highcharts.AxisLabelsFormatterCallbackFunction
  21558. *
  21559. * @param {Highcharts.AxisLabelsFormatterContextObject} this
  21560. *
  21561. * @param {Highcharts.AxisLabelsFormatterContextObject} ctx
  21562. *
  21563. * @return {string}
  21564. */
  21565. /**
  21566. * @interface Highcharts.AxisLabelsFormatterContextObject
  21567. */ /**
  21568. * The axis item of the label
  21569. * @name Highcharts.AxisLabelsFormatterContextObject#axis
  21570. * @type {Highcharts.Axis}
  21571. */ /**
  21572. * The chart instance.
  21573. * @name Highcharts.AxisLabelsFormatterContextObject#chart
  21574. * @type {Highcharts.Chart}
  21575. */ /**
  21576. * Whether the label belongs to the first tick on the axis.
  21577. * @name Highcharts.AxisLabelsFormatterContextObject#isFirst
  21578. * @type {boolean}
  21579. */ /**
  21580. * Whether the label belongs to the last tick on the axis.
  21581. * @name Highcharts.AxisLabelsFormatterContextObject#isLast
  21582. * @type {boolean}
  21583. */ /**
  21584. * The position on the axis in terms of axis values. For category axes, a
  21585. * zero-based index. For datetime axes, the JavaScript time in milliseconds
  21586. * since 1970.
  21587. * @name Highcharts.AxisLabelsFormatterContextObject#pos
  21588. * @type {number}
  21589. */ /**
  21590. * The preformatted text as the result of the default formatting. For example
  21591. * dates will be formatted as strings, and numbers with language-specific comma
  21592. * separators, thousands separators and numeric symbols like `k` or `M`.
  21593. * @name Highcharts.AxisLabelsFormatterContextObject#text
  21594. * @type {string}
  21595. */ /**
  21596. * The Tick instance.
  21597. * @name Highcharts.AxisLabelsFormatterContextObject#tick
  21598. * @type {Highcharts.Tick}
  21599. */ /**
  21600. * This can be either a numeric value or a category string.
  21601. * @name Highcharts.AxisLabelsFormatterContextObject#value
  21602. * @type {number|string}
  21603. */
  21604. /**
  21605. * Options for axes.
  21606. *
  21607. * @typedef {Highcharts.XAxisOptions|Highcharts.YAxisOptions|Highcharts.ZAxisOptions} Highcharts.AxisOptions
  21608. */
  21609. /**
  21610. * @callback Highcharts.AxisPointBreakEventCallbackFunction
  21611. *
  21612. * @param {Highcharts.Axis} this
  21613. *
  21614. * @param {Highcharts.AxisPointBreakEventObject} evt
  21615. */
  21616. /**
  21617. * @interface Highcharts.AxisPointBreakEventObject
  21618. */ /**
  21619. * @name Highcharts.AxisPointBreakEventObject#brk
  21620. * @type {Highcharts.Dictionary<number>}
  21621. */ /**
  21622. * @name Highcharts.AxisPointBreakEventObject#point
  21623. * @type {Highcharts.Point}
  21624. */ /**
  21625. * @name Highcharts.AxisPointBreakEventObject#preventDefault
  21626. * @type {Function}
  21627. */ /**
  21628. * @name Highcharts.AxisPointBreakEventObject#target
  21629. * @type {Highcharts.SVGElement}
  21630. */ /**
  21631. * @name Highcharts.AxisPointBreakEventObject#type
  21632. * @type {"pointBreak"|"pointInBreak"}
  21633. */
  21634. /**
  21635. * @callback Highcharts.AxisSetExtremesEventCallbackFunction
  21636. *
  21637. * @param {Highcharts.Axis} this
  21638. *
  21639. * @param {Highcharts.AxisSetExtremesEventObject} evt
  21640. */
  21641. /**
  21642. * @interface Highcharts.AxisSetExtremesEventObject
  21643. * @extends Highcharts.ExtremesObject
  21644. */ /**
  21645. * @name Highcharts.AxisSetExtremesEventObject#preventDefault
  21646. * @type {Function}
  21647. */ /**
  21648. * @name Highcharts.AxisSetExtremesEventObject#target
  21649. * @type {Highcharts.SVGElement}
  21650. */ /**
  21651. * @name Highcharts.AxisSetExtremesEventObject#trigger
  21652. * @type {Highcharts.AxisExtremesTriggerValue|string}
  21653. */ /**
  21654. * @name Highcharts.AxisSetExtremesEventObject#type
  21655. * @type {"setExtremes"}
  21656. */
  21657. /**
  21658. * @callback Highcharts.AxisTickPositionerCallbackFunction
  21659. *
  21660. * @param {Highcharts.Axis} this
  21661. *
  21662. * @return {Highcharts.AxisTickPositionsArray}
  21663. */
  21664. /**
  21665. * @interface Highcharts.AxisTickPositionsArray
  21666. * @augments Array<number>
  21667. */
  21668. /**
  21669. * @typedef {"high"|"low"|"middle"} Highcharts.AxisTitleAlignValue
  21670. */
  21671. /**
  21672. * @typedef {Highcharts.XAxisTitleOptions|Highcharts.YAxisTitleOptions|Highcharts.ZAxisTitleOptions} Highcharts.AxisTitleOptions
  21673. */
  21674. /**
  21675. * @typedef {"linear"|"logarithmic"|"datetime"|"category"|"treegrid"} Highcharts.AxisTypeValue
  21676. */
  21677. /**
  21678. * The returned object literal from the {@link Highcharts.Axis#getExtremes}
  21679. * function.
  21680. *
  21681. * @interface Highcharts.ExtremesObject
  21682. */ /**
  21683. * The maximum value of the axis' associated series.
  21684. * @name Highcharts.ExtremesObject#dataMax
  21685. * @type {number}
  21686. */ /**
  21687. * The minimum value of the axis' associated series.
  21688. * @name Highcharts.ExtremesObject#dataMin
  21689. * @type {number}
  21690. */ /**
  21691. * The maximum axis value, either automatic or set manually. If the `max` option
  21692. * is not set, `maxPadding` is 0 and `endOnTick` is false, this value will be
  21693. * the same as `dataMax`.
  21694. * @name Highcharts.ExtremesObject#max
  21695. * @type {number}
  21696. */ /**
  21697. * The minimum axis value, either automatic or set manually. If the `min` option
  21698. * is not set, `minPadding` is 0 and `startOnTick` is false, this value will be
  21699. * the same as `dataMin`.
  21700. * @name Highcharts.ExtremesObject#min
  21701. * @type {number}
  21702. */ /**
  21703. * The user defined maximum, either from the `max` option or from a zoom or
  21704. * `setExtremes` action.
  21705. * @name Highcharts.ExtremesObject#userMax
  21706. * @type {number}
  21707. */ /**
  21708. * The user defined minimum, either from the `min` option or from a zoom or
  21709. * `setExtremes` action.
  21710. * @name Highcharts.ExtremesObject#userMin
  21711. * @type {number}
  21712. */
  21713. /**
  21714. * Formatter function for the text of a crosshair label.
  21715. *
  21716. * @callback Highcharts.XAxisCrosshairLabelFormatterCallbackFunction
  21717. *
  21718. * @param {Highcharts.Axis} this
  21719. * Axis context
  21720. *
  21721. * @param {number} value
  21722. * Y value of the data point
  21723. *
  21724. * @return {string}
  21725. */
  21726. ''; // keeps doclets above in JS file
  21727. return Axis;
  21728. });
  21729. _registerModule(_modules, 'Core/Axis/DateTimeAxis.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Utilities.js']], function (Axis, U) {
  21730. /* *
  21731. *
  21732. * (c) 2010-2021 Torstein Honsi
  21733. *
  21734. * License: www.highcharts.com/license
  21735. *
  21736. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  21737. *
  21738. * */
  21739. var addEvent = U.addEvent,
  21740. getMagnitude = U.getMagnitude,
  21741. normalizeTickInterval = U.normalizeTickInterval,
  21742. timeUnits = U.timeUnits;
  21743. /* eslint-disable valid-jsdoc */
  21744. var DateTimeAxisAdditions = /** @class */ (function () {
  21745. /* *
  21746. *
  21747. * Constructors
  21748. *
  21749. * */
  21750. function DateTimeAxisAdditions(axis) {
  21751. this.axis = axis;
  21752. }
  21753. /* *
  21754. *
  21755. * Functions
  21756. *
  21757. * */
  21758. /**
  21759. * Get a normalized tick interval for dates. Returns a configuration object
  21760. * with unit range (interval), count and name. Used to prepare data for
  21761. * `getTimeTicks`. Previously this logic was part of getTimeTicks, but as
  21762. * `getTimeTicks` now runs of segments in stock charts, the normalizing
  21763. * logic was extracted in order to prevent it for running over again for
  21764. * each segment having the same interval. #662, #697.
  21765. * @private
  21766. */
  21767. /**
  21768. * Get a normalized tick interval for dates. Returns a configuration object
  21769. * with unit range (interval), count and name. Used to prepare data for
  21770. * `getTimeTicks`. Previously this logic was part of getTimeTicks, but as
  21771. * `getTimeTicks` now runs of segments in stock charts, the normalizing
  21772. * logic was extracted in order to prevent it for running over again for
  21773. * each segment having the same interval. #662, #697.
  21774. * @private
  21775. */
  21776. DateTimeAxisAdditions.prototype.normalizeTimeTickInterval = function (tickInterval, unitsOption) {
  21777. var units = unitsOption || [[
  21778. 'millisecond',
  21779. [1, 2, 5, 10, 20, 25, 50, 100, 200, 500] // allowed multiples
  21780. ],
  21781. [
  21782. 'second',
  21783. [1, 2, 5, 10, 15, 30]
  21784. ],
  21785. [
  21786. 'minute',
  21787. [1, 2, 5, 10, 15, 30]
  21788. ],
  21789. [
  21790. 'hour',
  21791. [1, 2, 3, 4, 6, 8, 12]
  21792. ],
  21793. [
  21794. 'day',
  21795. [1, 2]
  21796. ],
  21797. [
  21798. 'week',
  21799. [1, 2]
  21800. ],
  21801. [
  21802. 'month',
  21803. [1, 2, 3, 4, 6]
  21804. ],
  21805. [
  21806. 'year',
  21807. null
  21808. ]],
  21809. unit = units[units.length - 1], // default unit is years
  21810. interval = timeUnits[unit[0]],
  21811. multiples = unit[1],
  21812. count,
  21813. i;
  21814. // loop through the units to find the one that best fits the
  21815. // tickInterval
  21816. for (i = 0; i < units.length; i++) {
  21817. unit = units[i];
  21818. interval = timeUnits[unit[0]];
  21819. multiples = unit[1];
  21820. if (units[i + 1]) {
  21821. // lessThan is in the middle between the highest multiple and
  21822. // the next unit.
  21823. var lessThan = (interval *
  21824. multiples[multiples.length - 1] +
  21825. timeUnits[units[i + 1][0]]) / 2;
  21826. // break and keep the current unit
  21827. if (tickInterval <= lessThan) {
  21828. break;
  21829. }
  21830. }
  21831. }
  21832. // prevent 2.5 years intervals, though 25, 250 etc. are allowed
  21833. if (interval === timeUnits.year && tickInterval < 5 * interval) {
  21834. multiples = [1, 2, 5];
  21835. }
  21836. // get the count
  21837. count = normalizeTickInterval(tickInterval / interval, multiples, unit[0] === 'year' ? // #1913, #2360
  21838. Math.max(getMagnitude(tickInterval / interval), 1) :
  21839. 1);
  21840. return {
  21841. unitRange: interval,
  21842. count: count,
  21843. unitName: unit[0]
  21844. };
  21845. };
  21846. return DateTimeAxisAdditions;
  21847. }());
  21848. /**
  21849. * Date and time support for axes.
  21850. *
  21851. * @private
  21852. * @class
  21853. */
  21854. var DateTimeAxis = /** @class */ (function () {
  21855. function DateTimeAxis() {
  21856. }
  21857. /* *
  21858. *
  21859. * Static Functions
  21860. *
  21861. * */
  21862. /**
  21863. * Extends axis class with date and time support.
  21864. * @private
  21865. */
  21866. DateTimeAxis.compose = function (AxisClass) {
  21867. AxisClass.keepProps.push('dateTime');
  21868. var axisProto = AxisClass.prototype;
  21869. /**
  21870. * Set the tick positions to a time unit that makes sense, for example
  21871. * on the first of each month or on every Monday. Return an array with
  21872. * the time positions. Used in datetime axes as well as for grouping
  21873. * data on a datetime axis.
  21874. *
  21875. * @private
  21876. * @function Highcharts.Axis#getTimeTicks
  21877. *
  21878. * @param {Highcharts.TimeNormalizeObject} normalizedInterval
  21879. * The interval in axis values (ms) and thecount.
  21880. *
  21881. * @param {number} min
  21882. * The minimum in axis values.
  21883. *
  21884. * @param {number} max
  21885. * The maximum in axis values.
  21886. *
  21887. * @param {number} startOfWeek
  21888. *
  21889. * @return {Highcharts.AxisTickPositionsArray}
  21890. */
  21891. axisProto.getTimeTicks = function () {
  21892. return this.chart.time.getTimeTicks.apply(this.chart.time, arguments);
  21893. };
  21894. /* eslint-disable no-invalid-this */
  21895. addEvent(AxisClass, 'init', function (e) {
  21896. var axis = this;
  21897. var options = e.userOptions;
  21898. if (options.type !== 'datetime') {
  21899. axis.dateTime = void 0;
  21900. return;
  21901. }
  21902. if (!axis.dateTime) {
  21903. axis.dateTime = new DateTimeAxisAdditions(axis);
  21904. }
  21905. });
  21906. /* eslint-enable no-invalid-this */
  21907. };
  21908. /* *
  21909. *
  21910. * Static Properties
  21911. *
  21912. * */
  21913. DateTimeAxis.AdditionsClass = DateTimeAxisAdditions;
  21914. return DateTimeAxis;
  21915. }());
  21916. DateTimeAxis.compose(Axis);
  21917. return DateTimeAxis;
  21918. });
  21919. _registerModule(_modules, 'Core/Axis/LogarithmicAxis.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Utilities.js']], function (Axis, U) {
  21920. /* *
  21921. *
  21922. * (c) 2010-2021 Torstein Honsi
  21923. *
  21924. * License: www.highcharts.com/license
  21925. *
  21926. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  21927. *
  21928. * */
  21929. var addEvent = U.addEvent,
  21930. getMagnitude = U.getMagnitude,
  21931. normalizeTickInterval = U.normalizeTickInterval,
  21932. pick = U.pick;
  21933. /* eslint-disable valid-jsdoc */
  21934. /**
  21935. * Provides logarithmic support for axes.
  21936. *
  21937. * @private
  21938. * @class
  21939. */
  21940. var LogarithmicAxisAdditions = /** @class */ (function () {
  21941. /* *
  21942. *
  21943. * Constructors
  21944. *
  21945. * */
  21946. function LogarithmicAxisAdditions(axis) {
  21947. this.axis = axis;
  21948. }
  21949. /* *
  21950. *
  21951. * Functions
  21952. *
  21953. * */
  21954. /**
  21955. * Set the tick positions of a logarithmic axis.
  21956. */
  21957. LogarithmicAxisAdditions.prototype.getLogTickPositions = function (interval, min, max, minor) {
  21958. var log = this;
  21959. var axis = log.axis;
  21960. var axisLength = axis.len;
  21961. var options = axis.options;
  21962. // Since we use this method for both major and minor ticks,
  21963. // use a local variable and return the result
  21964. var positions = [];
  21965. // Reset
  21966. if (!minor) {
  21967. log.minorAutoInterval = void 0;
  21968. }
  21969. // First case: All ticks fall on whole logarithms: 1, 10, 100 etc.
  21970. if (interval >= 0.5) {
  21971. interval = Math.round(interval);
  21972. positions = axis.getLinearTickPositions(interval, min, max);
  21973. // Second case: We need intermediary ticks. For example
  21974. // 1, 2, 4, 6, 8, 10, 20, 40 etc.
  21975. }
  21976. else if (interval >= 0.08) {
  21977. var roundedMin = Math.floor(min),
  21978. intermediate = void 0,
  21979. i = void 0,
  21980. j = void 0,
  21981. len = void 0,
  21982. pos = void 0,
  21983. lastPos = void 0,
  21984. break2 = void 0;
  21985. if (interval > 0.3) {
  21986. intermediate = [1, 2, 4];
  21987. // 0.2 equals five minor ticks per 1, 10, 100 etc
  21988. }
  21989. else if (interval > 0.15) {
  21990. intermediate = [1, 2, 4, 6, 8];
  21991. }
  21992. else { // 0.1 equals ten minor ticks per 1, 10, 100 etc
  21993. intermediate = [1, 2, 3, 4, 5, 6, 7, 8, 9];
  21994. }
  21995. for (i = roundedMin; i < max + 1 && !break2; i++) {
  21996. len = intermediate.length;
  21997. for (j = 0; j < len && !break2; j++) {
  21998. pos = log.log2lin(log.lin2log(i) * intermediate[j]);
  21999. // #1670, lastPos is #3113
  22000. if (pos > min &&
  22001. (!minor || lastPos <= max) &&
  22002. typeof lastPos !== 'undefined') {
  22003. positions.push(lastPos);
  22004. }
  22005. if (lastPos > max) {
  22006. break2 = true;
  22007. }
  22008. lastPos = pos;
  22009. }
  22010. }
  22011. // Third case: We are so deep in between whole logarithmic values that
  22012. // we might as well handle the tick positions like a linear axis. For
  22013. // example 1.01, 1.02, 1.03, 1.04.
  22014. }
  22015. else {
  22016. var realMin = log.lin2log(min),
  22017. realMax = log.lin2log(max),
  22018. tickIntervalOption = minor ?
  22019. axis.getMinorTickInterval() :
  22020. options.tickInterval,
  22021. filteredTickIntervalOption = tickIntervalOption === 'auto' ?
  22022. null :
  22023. tickIntervalOption,
  22024. tickPixelIntervalOption = options.tickPixelInterval / (minor ? 5 : 1),
  22025. totalPixelLength = minor ?
  22026. axisLength / axis.tickPositions.length :
  22027. axisLength;
  22028. interval = pick(filteredTickIntervalOption, log.minorAutoInterval, (realMax - realMin) *
  22029. tickPixelIntervalOption / (totalPixelLength || 1));
  22030. interval = normalizeTickInterval(interval, void 0, getMagnitude(interval));
  22031. positions = axis.getLinearTickPositions(interval, realMin, realMax).map(log.log2lin);
  22032. if (!minor) {
  22033. log.minorAutoInterval = interval / 5;
  22034. }
  22035. }
  22036. // Set the axis-level tickInterval variable
  22037. if (!minor) {
  22038. axis.tickInterval = interval;
  22039. }
  22040. return positions;
  22041. };
  22042. LogarithmicAxisAdditions.prototype.lin2log = function (num) {
  22043. return Math.pow(10, num);
  22044. };
  22045. LogarithmicAxisAdditions.prototype.log2lin = function (num) {
  22046. return Math.log(num) / Math.LN10;
  22047. };
  22048. return LogarithmicAxisAdditions;
  22049. }());
  22050. var LogarithmicAxis = /** @class */ (function () {
  22051. function LogarithmicAxis() {
  22052. }
  22053. /**
  22054. * Provides logarithmic support for axes.
  22055. *
  22056. * @private
  22057. */
  22058. LogarithmicAxis.compose = function (AxisClass) {
  22059. AxisClass.keepProps.push('logarithmic');
  22060. /* eslint-disable no-invalid-this */
  22061. addEvent(AxisClass, 'init', function (e) {
  22062. var axis = this;
  22063. var options = e.userOptions;
  22064. var logarithmic = axis.logarithmic;
  22065. if (options.type !== 'logarithmic') {
  22066. axis.logarithmic = void 0;
  22067. }
  22068. else {
  22069. if (!logarithmic) {
  22070. logarithmic = axis.logarithmic = new LogarithmicAxisAdditions(axis);
  22071. }
  22072. }
  22073. });
  22074. addEvent(AxisClass, 'afterInit', function () {
  22075. var axis = this;
  22076. var log = axis.logarithmic;
  22077. // extend logarithmic axis
  22078. if (log) {
  22079. axis.lin2val = function (num) {
  22080. return log.lin2log(num);
  22081. };
  22082. axis.val2lin = function (num) {
  22083. return log.log2lin(num);
  22084. };
  22085. }
  22086. });
  22087. };
  22088. return LogarithmicAxis;
  22089. }());
  22090. LogarithmicAxis.compose(Axis); // @todo move to factory functions
  22091. return LogarithmicAxis;
  22092. });
  22093. _registerModule(_modules, 'Core/Axis/PlotLineOrBand.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Color/Palette.js'], _modules['Core/Utilities.js']], function (Axis, palette, U) {
  22094. /* *
  22095. *
  22096. * (c) 2010-2021 Torstein Honsi
  22097. *
  22098. * License: www.highcharts.com/license
  22099. *
  22100. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  22101. *
  22102. * */
  22103. /**
  22104. * Options for plot bands on axes.
  22105. *
  22106. * @typedef {Highcharts.XAxisPlotBandsOptions|Highcharts.YAxisPlotBandsOptions|Highcharts.ZAxisPlotBandsOptions} Highcharts.AxisPlotBandsOptions
  22107. */
  22108. /**
  22109. * Options for plot band labels on axes.
  22110. *
  22111. * @typedef {Highcharts.XAxisPlotBandsLabelOptions|Highcharts.YAxisPlotBandsLabelOptions|Highcharts.ZAxisPlotBandsLabelOptions} Highcharts.AxisPlotBandsLabelOptions
  22112. */
  22113. /**
  22114. * Options for plot lines on axes.
  22115. *
  22116. * @typedef {Highcharts.XAxisPlotLinesOptions|Highcharts.YAxisPlotLinesOptions|Highcharts.ZAxisPlotLinesOptions} Highcharts.AxisPlotLinesOptions
  22117. */
  22118. /**
  22119. * Options for plot line labels on axes.
  22120. *
  22121. * @typedef {Highcharts.XAxisPlotLinesLabelOptions|Highcharts.YAxisPlotLinesLabelOptions|Highcharts.ZAxisPlotLinesLabelOptions} Highcharts.AxisPlotLinesLabelOptions
  22122. */
  22123. var arrayMax = U.arrayMax,
  22124. arrayMin = U.arrayMin,
  22125. defined = U.defined,
  22126. destroyObjectProperties = U.destroyObjectProperties,
  22127. erase = U.erase,
  22128. extend = U.extend,
  22129. fireEvent = U.fireEvent,
  22130. isNumber = U.isNumber,
  22131. merge = U.merge,
  22132. objectEach = U.objectEach,
  22133. pick = U.pick;
  22134. /* eslint-disable no-invalid-this, valid-jsdoc */
  22135. /**
  22136. * The object wrapper for plot lines and plot bands
  22137. *
  22138. * @class
  22139. * @name Highcharts.PlotLineOrBand
  22140. *
  22141. * @param {Highcharts.Axis} axis
  22142. *
  22143. * @param {Highcharts.AxisPlotLinesOptions|Highcharts.AxisPlotBandsOptions} [options]
  22144. */
  22145. var PlotLineOrBand = /** @class */ (function () {
  22146. function PlotLineOrBand(axis, options) {
  22147. this.axis = axis;
  22148. if (options) {
  22149. this.options = options;
  22150. this.id = options.id;
  22151. }
  22152. }
  22153. /**
  22154. * Render the plot line or plot band. If it is already existing,
  22155. * move it.
  22156. *
  22157. * @private
  22158. * @function Highcharts.PlotLineOrBand#render
  22159. * @return {Highcharts.PlotLineOrBand|undefined}
  22160. */
  22161. PlotLineOrBand.prototype.render = function () {
  22162. fireEvent(this, 'render');
  22163. var plotLine = this,
  22164. axis = plotLine.axis,
  22165. horiz = axis.horiz,
  22166. log = axis.logarithmic,
  22167. options = plotLine.options,
  22168. optionsLabel = options.label,
  22169. label = plotLine.label,
  22170. to = options.to,
  22171. from = options.from,
  22172. value = options.value,
  22173. isBand = defined(from) && defined(to),
  22174. isLine = defined(value),
  22175. svgElem = plotLine.svgElem,
  22176. isNew = !svgElem,
  22177. path = [],
  22178. color = options.color,
  22179. zIndex = pick(options.zIndex, 0),
  22180. events = options.events,
  22181. attribs = {
  22182. 'class': 'highcharts-plot-' + (isBand ? 'band ' : 'line ') +
  22183. (options.className || '')
  22184. },
  22185. groupAttribs = {},
  22186. renderer = axis.chart.renderer,
  22187. groupName = isBand ? 'bands' : 'lines',
  22188. group;
  22189. // logarithmic conversion
  22190. if (log) {
  22191. from = log.log2lin(from);
  22192. to = log.log2lin(to);
  22193. value = log.log2lin(value);
  22194. }
  22195. // Set the presentational attributes
  22196. if (!axis.chart.styledMode) {
  22197. if (isLine) {
  22198. attribs.stroke = color || palette.neutralColor40;
  22199. attribs['stroke-width'] = pick(options.width, 1);
  22200. if (options.dashStyle) {
  22201. attribs.dashstyle =
  22202. options.dashStyle;
  22203. }
  22204. }
  22205. else if (isBand) { // plot band
  22206. attribs.fill = color || palette.highlightColor10;
  22207. if (options.borderWidth) {
  22208. attribs.stroke = options.borderColor;
  22209. attribs['stroke-width'] = options.borderWidth;
  22210. }
  22211. }
  22212. }
  22213. // Grouping and zIndex
  22214. groupAttribs.zIndex = zIndex;
  22215. groupName += '-' + zIndex;
  22216. group = axis.plotLinesAndBandsGroups[groupName];
  22217. if (!group) {
  22218. axis.plotLinesAndBandsGroups[groupName] = group =
  22219. renderer.g('plot-' + groupName)
  22220. .attr(groupAttribs).add();
  22221. }
  22222. // Create the path
  22223. if (isNew) {
  22224. /**
  22225. * SVG element of the plot line or band.
  22226. *
  22227. * @name Highcharts.PlotLineOrBand#svgElement
  22228. * @type {Highcharts.SVGElement}
  22229. */
  22230. plotLine.svgElem = svgElem = renderer
  22231. .path()
  22232. .attr(attribs)
  22233. .add(group);
  22234. }
  22235. // Set the path or return
  22236. if (isLine) {
  22237. path = axis.getPlotLinePath({
  22238. value: value,
  22239. lineWidth: svgElem.strokeWidth(),
  22240. acrossPanes: options.acrossPanes
  22241. });
  22242. }
  22243. else if (isBand) { // plot band
  22244. path = axis.getPlotBandPath(from, to, options);
  22245. }
  22246. else {
  22247. return;
  22248. }
  22249. // common for lines and bands
  22250. // Add events only if they were not added before.
  22251. if (!plotLine.eventsAdded && events) {
  22252. objectEach(events, function (event, eventType) {
  22253. svgElem.on(eventType, function (e) {
  22254. events[eventType].apply(plotLine, [e]);
  22255. });
  22256. });
  22257. plotLine.eventsAdded = true;
  22258. }
  22259. if ((isNew || !svgElem.d) && path && path.length) {
  22260. svgElem.attr({ d: path });
  22261. }
  22262. else if (svgElem) {
  22263. if (path) {
  22264. svgElem.show(true);
  22265. svgElem.animate({ d: path });
  22266. }
  22267. else if (svgElem.d) {
  22268. svgElem.hide();
  22269. if (label) {
  22270. plotLine.label = label = label.destroy();
  22271. }
  22272. }
  22273. }
  22274. // the plot band/line label
  22275. if (optionsLabel &&
  22276. (defined(optionsLabel.text) || defined(optionsLabel.formatter)) &&
  22277. path &&
  22278. path.length &&
  22279. axis.width > 0 &&
  22280. axis.height > 0 &&
  22281. !path.isFlat) {
  22282. // apply defaults
  22283. optionsLabel = merge({
  22284. align: horiz && isBand && 'center',
  22285. x: horiz ? !isBand && 4 : 10,
  22286. verticalAlign: !horiz && isBand && 'middle',
  22287. y: horiz ? isBand ? 16 : 10 : isBand ? 6 : -4,
  22288. rotation: horiz && !isBand && 90
  22289. }, optionsLabel);
  22290. this.renderLabel(optionsLabel, path, isBand, zIndex);
  22291. }
  22292. else if (label) { // move out of sight
  22293. label.hide();
  22294. }
  22295. // chainable
  22296. return plotLine;
  22297. };
  22298. /**
  22299. * Render and align label for plot line or band.
  22300. *
  22301. * @private
  22302. * @function Highcharts.PlotLineOrBand#renderLabel
  22303. * @param {Highcharts.AxisPlotLinesLabelOptions|Highcharts.AxisPlotBandsLabelOptions} optionsLabel
  22304. * @param {Highcharts.SVGPathArray} path
  22305. * @param {boolean} [isBand]
  22306. * @param {number} [zIndex]
  22307. * @return {void}
  22308. */
  22309. PlotLineOrBand.prototype.renderLabel = function (optionsLabel, path, isBand, zIndex) {
  22310. var plotLine = this,
  22311. label = plotLine.label,
  22312. renderer = plotLine.axis.chart.renderer,
  22313. attribs,
  22314. xBounds,
  22315. yBounds,
  22316. x,
  22317. y,
  22318. labelText;
  22319. // add the SVG element
  22320. if (!label) {
  22321. attribs = {
  22322. align: optionsLabel.textAlign || optionsLabel.align,
  22323. rotation: optionsLabel.rotation,
  22324. 'class': 'highcharts-plot-' + (isBand ? 'band' : 'line') +
  22325. '-label ' + (optionsLabel.className || '')
  22326. };
  22327. attribs.zIndex = zIndex;
  22328. labelText = this.getLabelText(optionsLabel);
  22329. /**
  22330. * SVG element of the label.
  22331. *
  22332. * @name Highcharts.PlotLineOrBand#label
  22333. * @type {Highcharts.SVGElement}
  22334. */
  22335. plotLine.label = label = renderer
  22336. .text(labelText, 0, 0, optionsLabel.useHTML)
  22337. .attr(attribs)
  22338. .add();
  22339. if (!this.axis.chart.styledMode) {
  22340. label.css(optionsLabel.style);
  22341. }
  22342. }
  22343. // get the bounding box and align the label
  22344. // #3000 changed to better handle choice between plotband or plotline
  22345. xBounds = path.xBounds ||
  22346. [path[0][1], path[1][1], (isBand ? path[2][1] : path[0][1])];
  22347. yBounds = path.yBounds ||
  22348. [path[0][2], path[1][2], (isBand ? path[2][2] : path[0][2])];
  22349. x = arrayMin(xBounds);
  22350. y = arrayMin(yBounds);
  22351. label.align(optionsLabel, false, {
  22352. x: x,
  22353. y: y,
  22354. width: arrayMax(xBounds) - x,
  22355. height: arrayMax(yBounds) - y
  22356. });
  22357. label.show(true);
  22358. };
  22359. /**
  22360. * Get label's text content.
  22361. *
  22362. * @private
  22363. * @function Highcharts.PlotLineOrBand#getLabelText
  22364. * @param {Highcharts.AxisPlotLinesLabelOptions|Highcharts.AxisPlotBandsLabelOptions} optionsLabel
  22365. * @return {string}
  22366. */
  22367. PlotLineOrBand.prototype.getLabelText = function (optionsLabel) {
  22368. return defined(optionsLabel.formatter) ?
  22369. optionsLabel.formatter
  22370. .call(this) :
  22371. optionsLabel.text;
  22372. };
  22373. /**
  22374. * Remove the plot line or band.
  22375. *
  22376. * @function Highcharts.PlotLineOrBand#destroy
  22377. * @return {void}
  22378. */
  22379. PlotLineOrBand.prototype.destroy = function () {
  22380. // remove it from the lookup
  22381. erase(this.axis.plotLinesAndBands, this);
  22382. delete this.axis;
  22383. destroyObjectProperties(this);
  22384. };
  22385. return PlotLineOrBand;
  22386. }());
  22387. /* eslint-enable no-invalid-this, valid-jsdoc */
  22388. // Object with members for extending the Axis prototype
  22389. extend(Axis.prototype, /** @lends Highcharts.Axis.prototype */ {
  22390. /**
  22391. * An array of colored bands stretching across the plot area marking an
  22392. * interval on the axis.
  22393. *
  22394. * In styled mode, the plot bands are styled by the `.highcharts-plot-band`
  22395. * class in addition to the `className` option.
  22396. *
  22397. * @productdesc {highcharts}
  22398. * In a gauge, a plot band on the Y axis (value axis) will stretch along the
  22399. * perimeter of the gauge.
  22400. *
  22401. * @type {Array<*>}
  22402. * @product highcharts highstock gantt
  22403. * @apioption xAxis.plotBands
  22404. */
  22405. /**
  22406. * Flag to decide if plotBand should be rendered across all panes.
  22407. *
  22408. * @since 7.1.2
  22409. * @product highstock
  22410. * @type {boolean}
  22411. * @default true
  22412. * @apioption xAxis.plotBands.acrossPanes
  22413. */
  22414. /**
  22415. * Border color for the plot band. Also requires `borderWidth` to be set.
  22416. *
  22417. * @type {Highcharts.ColorString}
  22418. * @apioption xAxis.plotBands.borderColor
  22419. */
  22420. /**
  22421. * Border width for the plot band. Also requires `borderColor` to be set.
  22422. *
  22423. * @type {number}
  22424. * @default 0
  22425. * @apioption xAxis.plotBands.borderWidth
  22426. */
  22427. /**
  22428. * A custom class name, in addition to the default `highcharts-plot-band`,
  22429. * to apply to each individual band.
  22430. *
  22431. * @type {string}
  22432. * @since 5.0.0
  22433. * @apioption xAxis.plotBands.className
  22434. */
  22435. /**
  22436. * The color of the plot band.
  22437. *
  22438. * @sample {highcharts} highcharts/xaxis/plotbands-color/
  22439. * Color band
  22440. * @sample {highstock} stock/xaxis/plotbands/
  22441. * Plot band on Y axis
  22442. *
  22443. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  22444. * @default ${palette.highlightColor10}
  22445. * @apioption xAxis.plotBands.color
  22446. */
  22447. /**
  22448. * An object defining mouse events for the plot band. Supported properties
  22449. * are `click`, `mouseover`, `mouseout`, `mousemove`.
  22450. *
  22451. * @sample {highcharts} highcharts/xaxis/plotbands-events/
  22452. * Mouse events demonstrated
  22453. *
  22454. * @since 1.2
  22455. * @apioption xAxis.plotBands.events
  22456. */
  22457. /**
  22458. * Click event on a plot band.
  22459. *
  22460. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  22461. * @apioption xAxis.plotBands.events.click
  22462. */
  22463. /**
  22464. * Mouse move event on a plot band.
  22465. *
  22466. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  22467. * @apioption xAxis.plotBands.events.mousemove
  22468. */
  22469. /**
  22470. * Mouse out event on the corner of a plot band.
  22471. *
  22472. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  22473. * @apioption xAxis.plotBands.events.mouseout
  22474. */
  22475. /**
  22476. * Mouse over event on a plot band.
  22477. *
  22478. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  22479. * @apioption xAxis.plotBands.events.mouseover
  22480. */
  22481. /**
  22482. * The start position of the plot band in axis units.
  22483. *
  22484. * @sample {highcharts} highcharts/xaxis/plotbands-color/
  22485. * Datetime axis
  22486. * @sample {highcharts} highcharts/xaxis/plotbands-from/
  22487. * Categorized axis
  22488. * @sample {highstock} stock/xaxis/plotbands/
  22489. * Plot band on Y axis
  22490. *
  22491. * @type {number}
  22492. * @apioption xAxis.plotBands.from
  22493. */
  22494. /**
  22495. * An id used for identifying the plot band in Axis.removePlotBand.
  22496. *
  22497. * @sample {highcharts} highcharts/xaxis/plotbands-id/
  22498. * Remove plot band by id
  22499. * @sample {highstock} highcharts/xaxis/plotbands-id/
  22500. * Remove plot band by id
  22501. *
  22502. * @type {string}
  22503. * @apioption xAxis.plotBands.id
  22504. */
  22505. /**
  22506. * The end position of the plot band in axis units.
  22507. *
  22508. * @sample {highcharts} highcharts/xaxis/plotbands-color/
  22509. * Datetime axis
  22510. * @sample {highcharts} highcharts/xaxis/plotbands-from/
  22511. * Categorized axis
  22512. * @sample {highstock} stock/xaxis/plotbands/
  22513. * Plot band on Y axis
  22514. *
  22515. * @type {number}
  22516. * @apioption xAxis.plotBands.to
  22517. */
  22518. /**
  22519. * The z index of the plot band within the chart, relative to other
  22520. * elements. Using the same z index as another element may give
  22521. * unpredictable results, as the last rendered element will be on top.
  22522. * Values from 0 to 20 make sense.
  22523. *
  22524. * @sample {highcharts} highcharts/xaxis/plotbands-color/
  22525. * Behind plot lines by default
  22526. * @sample {highcharts} highcharts/xaxis/plotbands-zindex/
  22527. * Above plot lines
  22528. * @sample {highcharts} highcharts/xaxis/plotbands-zindex-above-series/
  22529. * Above plot lines and series
  22530. *
  22531. * @type {number}
  22532. * @since 1.2
  22533. * @apioption xAxis.plotBands.zIndex
  22534. */
  22535. /**
  22536. * Text labels for the plot bands
  22537. *
  22538. * @product highcharts highstock gantt
  22539. * @apioption xAxis.plotBands.label
  22540. */
  22541. /**
  22542. * Horizontal alignment of the label. Can be one of "left", "center" or
  22543. * "right".
  22544. *
  22545. * @sample {highcharts} highcharts/xaxis/plotbands-label-align/
  22546. * Aligned to the right
  22547. * @sample {highstock} stock/xaxis/plotbands-label/
  22548. * Plot band with labels
  22549. *
  22550. * @type {Highcharts.AlignValue}
  22551. * @default center
  22552. * @since 2.1
  22553. * @apioption xAxis.plotBands.label.align
  22554. */
  22555. /**
  22556. * Rotation of the text label in degrees .
  22557. *
  22558. * @sample {highcharts} highcharts/xaxis/plotbands-label-rotation/
  22559. * Vertical text
  22560. *
  22561. * @type {number}
  22562. * @default 0
  22563. * @since 2.1
  22564. * @apioption xAxis.plotBands.label.rotation
  22565. */
  22566. /**
  22567. * CSS styles for the text label.
  22568. *
  22569. * In styled mode, the labels are styled by the
  22570. * `.highcharts-plot-band-label` class.
  22571. *
  22572. * @sample {highcharts} highcharts/xaxis/plotbands-label-style/
  22573. * Blue and bold label
  22574. *
  22575. * @type {Highcharts.CSSObject}
  22576. * @since 2.1
  22577. * @apioption xAxis.plotBands.label.style
  22578. */
  22579. /**
  22580. * The string text itself. A subset of HTML is supported.
  22581. *
  22582. * @type {string}
  22583. * @since 2.1
  22584. * @apioption xAxis.plotBands.label.text
  22585. */
  22586. /**
  22587. * The text alignment for the label. While `align` determines where the
  22588. * texts anchor point is placed within the plot band, `textAlign` determines
  22589. * how the text is aligned against its anchor point. Possible values are
  22590. * "left", "center" and "right". Defaults to the same as the `align` option.
  22591. *
  22592. * @sample {highcharts} highcharts/xaxis/plotbands-label-rotation/
  22593. * Vertical text in center position but text-aligned left
  22594. *
  22595. * @type {Highcharts.AlignValue}
  22596. * @since 2.1
  22597. * @apioption xAxis.plotBands.label.textAlign
  22598. */
  22599. /**
  22600. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  22601. * to render the labels.
  22602. *
  22603. * @type {boolean}
  22604. * @default false
  22605. * @since 3.0.3
  22606. * @apioption xAxis.plotBands.label.useHTML
  22607. */
  22608. /**
  22609. * Vertical alignment of the label relative to the plot band. Can be one of
  22610. * "top", "middle" or "bottom".
  22611. *
  22612. * @sample {highcharts} highcharts/xaxis/plotbands-label-verticalalign/
  22613. * Vertically centered label
  22614. * @sample {highstock} stock/xaxis/plotbands-label/
  22615. * Plot band with labels
  22616. *
  22617. * @type {Highcharts.VerticalAlignValue}
  22618. * @default top
  22619. * @since 2.1
  22620. * @apioption xAxis.plotBands.label.verticalAlign
  22621. */
  22622. /**
  22623. * Horizontal position relative the alignment. Default varies by
  22624. * orientation.
  22625. *
  22626. * @sample {highcharts} highcharts/xaxis/plotbands-label-align/
  22627. * Aligned 10px from the right edge
  22628. * @sample {highstock} stock/xaxis/plotbands-label/
  22629. * Plot band with labels
  22630. *
  22631. * @type {number}
  22632. * @since 2.1
  22633. * @apioption xAxis.plotBands.label.x
  22634. */
  22635. /**
  22636. * Vertical position of the text baseline relative to the alignment. Default
  22637. * varies by orientation.
  22638. *
  22639. * @sample {highcharts} highcharts/xaxis/plotbands-label-y/
  22640. * Label on x axis
  22641. * @sample {highstock} stock/xaxis/plotbands-label/
  22642. * Plot band with labels
  22643. *
  22644. * @type {number}
  22645. * @since 2.1
  22646. * @apioption xAxis.plotBands.label.y
  22647. */
  22648. /**
  22649. * An array of lines stretching across the plot area, marking a specific
  22650. * value on one of the axes.
  22651. *
  22652. * In styled mode, the plot lines are styled by the
  22653. * `.highcharts-plot-line` class in addition to the `className` option.
  22654. *
  22655. * @type {Array<*>}
  22656. * @product highcharts highstock gantt
  22657. * @sample {highcharts} highcharts/xaxis/plotlines-color/
  22658. * Basic plot line
  22659. * @sample {highcharts} highcharts/series-solidgauge/labels-auto-aligned/
  22660. * Solid gauge plot line
  22661. * @apioption xAxis.plotLines
  22662. */
  22663. /**
  22664. * Flag to decide if plotLine should be rendered across all panes.
  22665. *
  22666. * @sample {highstock} stock/xaxis/plotlines-acrosspanes/
  22667. * Plot lines on different panes
  22668. *
  22669. * @since 7.1.2
  22670. * @product highstock
  22671. * @type {boolean}
  22672. * @default true
  22673. * @apioption xAxis.plotLines.acrossPanes
  22674. */
  22675. /**
  22676. * A custom class name, in addition to the default `highcharts-plot-line`,
  22677. * to apply to each individual line.
  22678. *
  22679. * @type {string}
  22680. * @since 5.0.0
  22681. * @apioption xAxis.plotLines.className
  22682. */
  22683. /**
  22684. * The color of the line.
  22685. *
  22686. * @sample {highcharts} highcharts/xaxis/plotlines-color/
  22687. * A red line from X axis
  22688. * @sample {highstock} stock/xaxis/plotlines/
  22689. * Plot line on Y axis
  22690. *
  22691. * @type {Highcharts.ColorString}
  22692. * @default ${palette.neutralColor40}
  22693. * @apioption xAxis.plotLines.color
  22694. */
  22695. /**
  22696. * The dashing or dot style for the plot line. For possible values see
  22697. * [this overview](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-dashstyle-all/).
  22698. *
  22699. * @sample {highcharts} highcharts/xaxis/plotlines-dashstyle/
  22700. * Dash and dot pattern
  22701. * @sample {highstock} stock/xaxis/plotlines/
  22702. * Plot line on Y axis
  22703. *
  22704. * @type {Highcharts.DashStyleValue}
  22705. * @default Solid
  22706. * @since 1.2
  22707. * @apioption xAxis.plotLines.dashStyle
  22708. */
  22709. /**
  22710. * An object defining mouse events for the plot line. Supported
  22711. * properties are `click`, `mouseover`, `mouseout`, `mousemove`.
  22712. *
  22713. * @sample {highcharts} highcharts/xaxis/plotlines-events/
  22714. * Mouse events demonstrated
  22715. *
  22716. * @since 1.2
  22717. * @apioption xAxis.plotLines.events
  22718. */
  22719. /**
  22720. * Click event on a plot band.
  22721. *
  22722. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  22723. * @apioption xAxis.plotLines.events.click
  22724. */
  22725. /**
  22726. * Mouse move event on a plot band.
  22727. *
  22728. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  22729. * @apioption xAxis.plotLines.events.mousemove
  22730. */
  22731. /**
  22732. * Mouse out event on the corner of a plot band.
  22733. *
  22734. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  22735. * @apioption xAxis.plotLines.events.mouseout
  22736. */
  22737. /**
  22738. * Mouse over event on a plot band.
  22739. *
  22740. * @type {Highcharts.EventCallbackFunction<Highcharts.PlotLineOrBand>}
  22741. * @apioption xAxis.plotLines.events.mouseover
  22742. */
  22743. /**
  22744. * An id used for identifying the plot line in Axis.removePlotLine.
  22745. *
  22746. * @sample {highcharts} highcharts/xaxis/plotlines-id/
  22747. * Remove plot line by id
  22748. *
  22749. * @type {string}
  22750. * @apioption xAxis.plotLines.id
  22751. */
  22752. /**
  22753. * The position of the line in axis units.
  22754. *
  22755. * @sample {highcharts} highcharts/xaxis/plotlines-color/
  22756. * Between two categories on X axis
  22757. * @sample {highstock} stock/xaxis/plotlines/
  22758. * Plot line on Y axis
  22759. *
  22760. * @type {number}
  22761. * @apioption xAxis.plotLines.value
  22762. */
  22763. /**
  22764. * The width or thickness of the plot line.
  22765. *
  22766. * @sample {highcharts} highcharts/xaxis/plotlines-color/
  22767. * 2px wide line from X axis
  22768. * @sample {highstock} stock/xaxis/plotlines/
  22769. * Plot line on Y axis
  22770. *
  22771. * @type {number}
  22772. * @default 2
  22773. * @apioption xAxis.plotLines.width
  22774. */
  22775. /**
  22776. * The z index of the plot line within the chart.
  22777. *
  22778. * @sample {highcharts} highcharts/xaxis/plotlines-zindex-behind/
  22779. * Behind plot lines by default
  22780. * @sample {highcharts} highcharts/xaxis/plotlines-zindex-above/
  22781. * Above plot lines
  22782. * @sample {highcharts} highcharts/xaxis/plotlines-zindex-above-all/
  22783. * Above plot lines and series
  22784. *
  22785. * @type {number}
  22786. * @since 1.2
  22787. * @apioption xAxis.plotLines.zIndex
  22788. */
  22789. /**
  22790. * Text labels for the plot bands
  22791. *
  22792. * @apioption xAxis.plotLines.label
  22793. */
  22794. /**
  22795. * Horizontal alignment of the label. Can be one of "left", "center" or
  22796. * "right".
  22797. *
  22798. * @sample {highcharts} highcharts/xaxis/plotlines-label-align-right/
  22799. * Aligned to the right
  22800. * @sample {highstock} stock/xaxis/plotlines/
  22801. * Plot line on Y axis
  22802. *
  22803. * @type {Highcharts.AlignValue}
  22804. * @default left
  22805. * @since 2.1
  22806. * @apioption xAxis.plotLines.label.align
  22807. */
  22808. /**
  22809. * Callback JavaScript function to format the label. Useful properties like
  22810. * the value of plot line or the range of plot band (`from` & `to`
  22811. * properties) can be found in `this.options` object.
  22812. *
  22813. * @sample {highcharts} highcharts/xaxis/plotlines-plotbands-label-formatter
  22814. * Label formatters for plot line and plot band.
  22815. * @type {Highcharts.FormatterCallbackFunction<Highcharts.PlotLineOrBand>}
  22816. * @apioption xAxis.plotLines.label.formatter
  22817. */
  22818. /**
  22819. * Rotation of the text label in degrees. Defaults to 0 for horizontal plot
  22820. * lines and 90 for vertical lines.
  22821. *
  22822. * @sample {highcharts} highcharts/xaxis/plotlines-label-verticalalign-middle/
  22823. * Slanted text
  22824. *
  22825. * @type {number}
  22826. * @since 2.1
  22827. * @apioption xAxis.plotLines.label.rotation
  22828. */
  22829. /**
  22830. * CSS styles for the text label.
  22831. *
  22832. * In styled mode, the labels are styled by the
  22833. * `.highcharts-plot-line-label` class.
  22834. *
  22835. * @sample {highcharts} highcharts/xaxis/plotlines-label-style/
  22836. * Blue and bold label
  22837. *
  22838. * @type {Highcharts.CSSObject}
  22839. * @since 2.1
  22840. * @apioption xAxis.plotLines.label.style
  22841. */
  22842. /**
  22843. * The text itself. A subset of HTML is supported.
  22844. *
  22845. * @type {string}
  22846. * @since 2.1
  22847. * @apioption xAxis.plotLines.label.text
  22848. */
  22849. /**
  22850. * The text alignment for the label. While `align` determines where the
  22851. * texts anchor point is placed within the plot band, `textAlign` determines
  22852. * how the text is aligned against its anchor point. Possible values are
  22853. * "left", "center" and "right". Defaults to the same as the `align` option.
  22854. *
  22855. * @sample {highcharts} highcharts/xaxis/plotlines-label-textalign/
  22856. * Text label in bottom position
  22857. *
  22858. * @type {Highcharts.AlignValue}
  22859. * @since 2.1
  22860. * @apioption xAxis.plotLines.label.textAlign
  22861. */
  22862. /**
  22863. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  22864. * to render the labels.
  22865. *
  22866. * @type {boolean}
  22867. * @default false
  22868. * @since 3.0.3
  22869. * @apioption xAxis.plotLines.label.useHTML
  22870. */
  22871. /**
  22872. * Vertical alignment of the label relative to the plot line. Can be
  22873. * one of "top", "middle" or "bottom".
  22874. *
  22875. * @sample {highcharts} highcharts/xaxis/plotlines-label-verticalalign-middle/
  22876. * Vertically centered label
  22877. *
  22878. * @type {Highcharts.VerticalAlignValue}
  22879. * @default {highcharts} top
  22880. * @default {highstock} top
  22881. * @since 2.1
  22882. * @apioption xAxis.plotLines.label.verticalAlign
  22883. */
  22884. /**
  22885. * Horizontal position relative the alignment. Default varies by
  22886. * orientation.
  22887. *
  22888. * @sample {highcharts} highcharts/xaxis/plotlines-label-align-right/
  22889. * Aligned 10px from the right edge
  22890. * @sample {highstock} stock/xaxis/plotlines/
  22891. * Plot line on Y axis
  22892. *
  22893. * @type {number}
  22894. * @since 2.1
  22895. * @apioption xAxis.plotLines.label.x
  22896. */
  22897. /**
  22898. * Vertical position of the text baseline relative to the alignment. Default
  22899. * varies by orientation.
  22900. *
  22901. * @sample {highcharts} highcharts/xaxis/plotlines-label-y/
  22902. * Label below the plot line
  22903. * @sample {highstock} stock/xaxis/plotlines/
  22904. * Plot line on Y axis
  22905. *
  22906. * @type {number}
  22907. * @since 2.1
  22908. * @apioption xAxis.plotLines.label.y
  22909. */
  22910. /**
  22911. *
  22912. * @type {Array<*>}
  22913. * @extends xAxis.plotBands
  22914. * @apioption yAxis.plotBands
  22915. */
  22916. /**
  22917. * In a gauge chart, this option determines the inner radius of the
  22918. * plot band that stretches along the perimeter. It can be given as
  22919. * a percentage string, like `"100%"`, or as a pixel number, like `100`.
  22920. * By default, the inner radius is controlled by the [thickness](
  22921. * #yAxis.plotBands.thickness) option.
  22922. *
  22923. * @sample {highcharts} highcharts/xaxis/plotbands-gauge
  22924. * Gauge plot band
  22925. *
  22926. * @type {number|string}
  22927. * @since 2.3
  22928. * @product highcharts
  22929. * @apioption yAxis.plotBands.innerRadius
  22930. */
  22931. /**
  22932. * In a gauge chart, this option determines the outer radius of the
  22933. * plot band that stretches along the perimeter. It can be given as
  22934. * a percentage string, like `"100%"`, or as a pixel number, like `100`.
  22935. *
  22936. * @sample {highcharts} highcharts/xaxis/plotbands-gauge
  22937. * Gauge plot band
  22938. *
  22939. * @type {number|string}
  22940. * @default 100%
  22941. * @since 2.3
  22942. * @product highcharts
  22943. * @apioption yAxis.plotBands.outerRadius
  22944. */
  22945. /**
  22946. * In a gauge chart, this option sets the width of the plot band
  22947. * stretching along the perimeter. It can be given as a percentage
  22948. * string, like `"10%"`, or as a pixel number, like `10`. The default
  22949. * value 10 is the same as the default [tickLength](#yAxis.tickLength),
  22950. * thus making the plot band act as a background for the tick markers.
  22951. *
  22952. * @sample {highcharts} highcharts/xaxis/plotbands-gauge
  22953. * Gauge plot band
  22954. *
  22955. * @type {number|string}
  22956. * @default 10
  22957. * @since 2.3
  22958. * @product highcharts
  22959. * @apioption yAxis.plotBands.thickness
  22960. */
  22961. /**
  22962. * @type {Array<*>}
  22963. * @extends xAxis.plotLines
  22964. * @apioption yAxis.plotLines
  22965. */
  22966. /* eslint-disable no-invalid-this, valid-jsdoc */
  22967. /**
  22968. * Internal function to create the SVG path definition for a plot band.
  22969. *
  22970. * @function Highcharts.Axis#getPlotBandPath
  22971. *
  22972. * @param {number} from
  22973. * The axis value to start from.
  22974. *
  22975. * @param {number} to
  22976. * The axis value to end on.
  22977. *
  22978. * @param {Highcharts.AxisPlotBandsOptions|Highcharts.AxisPlotLinesOptions} options
  22979. * The plotBand or plotLine configuration object.
  22980. *
  22981. * @return {Highcharts.SVGPathArray}
  22982. * The SVG path definition in array form.
  22983. */
  22984. getPlotBandPath: function (from, to, options) {
  22985. if (options === void 0) { options = this.options; }
  22986. var toPath = this.getPlotLinePath({
  22987. value: to,
  22988. force: true,
  22989. acrossPanes: options.acrossPanes
  22990. }),
  22991. path = this.getPlotLinePath({
  22992. value: from,
  22993. force: true,
  22994. acrossPanes: options.acrossPanes
  22995. }),
  22996. result = [],
  22997. i,
  22998. // #4964 check if chart is inverted or plotband is on yAxis
  22999. horiz = this.horiz,
  23000. plus = 1,
  23001. isFlat,
  23002. outside = !isNumber(this.min) ||
  23003. !isNumber(this.max) ||
  23004. (from < this.min && to < this.min) ||
  23005. (from > this.max && to > this.max);
  23006. if (path && toPath) {
  23007. // Flat paths don't need labels (#3836)
  23008. if (outside) {
  23009. isFlat = path.toString() === toPath.toString();
  23010. plus = 0;
  23011. }
  23012. // Go over each subpath - for panes in Highcharts Stock
  23013. for (i = 0; i < path.length; i += 2) {
  23014. var pathStart = path[i],
  23015. pathEnd = path[i + 1],
  23016. toPathStart = toPath[i],
  23017. toPathEnd = toPath[i + 1];
  23018. // Type checking all affected path segments. Consider something
  23019. // smarter.
  23020. if ((pathStart[0] === 'M' || pathStart[0] === 'L') &&
  23021. (pathEnd[0] === 'M' || pathEnd[0] === 'L') &&
  23022. (toPathStart[0] === 'M' || toPathStart[0] === 'L') &&
  23023. (toPathEnd[0] === 'M' || toPathEnd[0] === 'L')) {
  23024. // Add 1 pixel when coordinates are the same
  23025. if (horiz && toPathStart[1] === pathStart[1]) {
  23026. toPathStart[1] += plus;
  23027. toPathEnd[1] += plus;
  23028. }
  23029. else if (!horiz && toPathStart[2] === pathStart[2]) {
  23030. toPathStart[2] += plus;
  23031. toPathEnd[2] += plus;
  23032. }
  23033. result.push(['M', pathStart[1], pathStart[2]], ['L', pathEnd[1], pathEnd[2]], ['L', toPathEnd[1], toPathEnd[2]], ['L', toPathStart[1], toPathStart[2]], ['Z']);
  23034. }
  23035. result.isFlat = isFlat;
  23036. }
  23037. }
  23038. else { // outside the axis area
  23039. path = null;
  23040. }
  23041. return result;
  23042. },
  23043. /**
  23044. * Add a plot band after render time.
  23045. *
  23046. * @sample highcharts/members/axis-addplotband/
  23047. * Toggle the plot band from a button
  23048. *
  23049. * @function Highcharts.Axis#addPlotBand
  23050. *
  23051. * @param {Highcharts.AxisPlotBandsOptions} options
  23052. * A configuration object for the plot band, as defined in
  23053. * [xAxis.plotBands](https://api.highcharts.com/highcharts/xAxis.plotBands).
  23054. *
  23055. * @return {Highcharts.PlotLineOrBand|undefined}
  23056. * The added plot band.
  23057. */
  23058. addPlotBand: function (options) {
  23059. return this.addPlotBandOrLine(options, 'plotBands');
  23060. },
  23061. /**
  23062. * Add a plot line after render time.
  23063. *
  23064. * @sample highcharts/members/axis-addplotline/
  23065. * Toggle the plot line from a button
  23066. *
  23067. * @function Highcharts.Axis#addPlotLine
  23068. *
  23069. * @param {Highcharts.AxisPlotLinesOptions} options
  23070. * A configuration object for the plot line, as defined in
  23071. * [xAxis.plotLines](https://api.highcharts.com/highcharts/xAxis.plotLines).
  23072. *
  23073. * @return {Highcharts.PlotLineOrBand|undefined}
  23074. * The added plot line.
  23075. */
  23076. addPlotLine: function (options) {
  23077. return this.addPlotBandOrLine(options, 'plotLines');
  23078. },
  23079. /**
  23080. * Add a plot band or plot line after render time. Called from addPlotBand
  23081. * and addPlotLine internally.
  23082. *
  23083. * @private
  23084. * @function Highcharts.Axis#addPlotBandOrLine
  23085. *
  23086. * @param {Highcharts.AxisPlotBandsOptions|Highcharts.AxisPlotLinesOptions} options
  23087. * The plotBand or plotLine configuration object.
  23088. *
  23089. * @param {"plotBands"|"plotLines"} [coll]
  23090. *
  23091. * @return {Highcharts.PlotLineOrBand|undefined}
  23092. */
  23093. addPlotBandOrLine: function (options, coll) {
  23094. var _this = this;
  23095. var obj = new PlotLineOrBand(this,
  23096. options),
  23097. userOptions = this.userOptions;
  23098. if (this.visible) {
  23099. obj = obj.render();
  23100. }
  23101. if (obj) { // #2189
  23102. if (!this._addedPlotLB) {
  23103. this._addedPlotLB = true;
  23104. (userOptions.plotLines || [])
  23105. .concat(userOptions.plotBands || [])
  23106. .forEach(function (plotLineOptions) {
  23107. _this.addPlotBandOrLine(plotLineOptions);
  23108. });
  23109. }
  23110. // Add it to the user options for exporting and Axis.update
  23111. if (coll) {
  23112. // Workaround Microsoft/TypeScript issue #32693
  23113. var updatedOptions = (userOptions[coll] || []);
  23114. updatedOptions.push(options);
  23115. userOptions[coll] = updatedOptions;
  23116. }
  23117. this.plotLinesAndBands.push(obj);
  23118. }
  23119. return obj;
  23120. },
  23121. /**
  23122. * Remove a plot band or plot line from the chart by id. Called internally
  23123. * from `removePlotBand` and `removePlotLine`.
  23124. *
  23125. * @private
  23126. * @function Highcharts.Axis#removePlotBandOrLine
  23127. * @param {string} id
  23128. * @return {void}
  23129. */
  23130. removePlotBandOrLine: function (id) {
  23131. var plotLinesAndBands = this.plotLinesAndBands,
  23132. options = this.options,
  23133. userOptions = this.userOptions;
  23134. if (plotLinesAndBands) { // #15639
  23135. var i_1 = plotLinesAndBands.length;
  23136. while (i_1--) {
  23137. if (plotLinesAndBands[i_1].id === id) {
  23138. plotLinesAndBands[i_1].destroy();
  23139. }
  23140. }
  23141. ([
  23142. options.plotLines || [],
  23143. userOptions.plotLines || [],
  23144. options.plotBands || [],
  23145. userOptions.plotBands || []
  23146. ]).forEach(function (arr) {
  23147. i_1 = arr.length;
  23148. while (i_1--) {
  23149. if ((arr[i_1] || {}).id === id) {
  23150. erase(arr, arr[i_1]);
  23151. }
  23152. }
  23153. });
  23154. }
  23155. },
  23156. /**
  23157. * Remove a plot band by its id.
  23158. *
  23159. * @sample highcharts/members/axis-removeplotband/
  23160. * Remove plot band by id
  23161. * @sample highcharts/members/axis-addplotband/
  23162. * Toggle the plot band from a button
  23163. *
  23164. * @function Highcharts.Axis#removePlotBand
  23165. *
  23166. * @param {string} id
  23167. * The plot band's `id` as given in the original configuration
  23168. * object or in the `addPlotBand` option.
  23169. *
  23170. * @return {void}
  23171. */
  23172. removePlotBand: function (id) {
  23173. this.removePlotBandOrLine(id);
  23174. },
  23175. /**
  23176. * Remove a plot line by its id.
  23177. *
  23178. * @sample highcharts/xaxis/plotlines-id/
  23179. * Remove plot line by id
  23180. * @sample highcharts/members/axis-addplotline/
  23181. * Toggle the plot line from a button
  23182. *
  23183. * @function Highcharts.Axis#removePlotLine
  23184. *
  23185. * @param {string} id
  23186. * The plot line's `id` as given in the original configuration
  23187. * object or in the `addPlotLine` option.
  23188. */
  23189. removePlotLine: function (id) {
  23190. this.removePlotBandOrLine(id);
  23191. }
  23192. });
  23193. return PlotLineOrBand;
  23194. });
  23195. _registerModule(_modules, 'Core/Tooltip.js', [_modules['Core/FormatUtilities.js'], _modules['Core/Globals.js'], _modules['Core/Color/Palette.js'], _modules['Core/Renderer/RendererRegistry.js'], _modules['Core/Utilities.js']], function (F, H, palette, RendererRegistry, U) {
  23196. /* *
  23197. *
  23198. * (c) 2010-2021 Torstein Honsi
  23199. *
  23200. * License: www.highcharts.com/license
  23201. *
  23202. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  23203. *
  23204. * */
  23205. var format = F.format;
  23206. var doc = H.doc;
  23207. var clamp = U.clamp,
  23208. css = U.css,
  23209. defined = U.defined,
  23210. discardElement = U.discardElement,
  23211. extend = U.extend,
  23212. fireEvent = U.fireEvent,
  23213. isArray = U.isArray,
  23214. isNumber = U.isNumber,
  23215. isString = U.isString,
  23216. merge = U.merge,
  23217. pick = U.pick,
  23218. splat = U.splat,
  23219. syncTimeout = U.syncTimeout,
  23220. timeUnits = U.timeUnits;
  23221. /**
  23222. * Callback function to format the text of the tooltip from scratch.
  23223. *
  23224. * In case of single or shared tooltips, a string should be be returned. In case
  23225. * of splitted tooltips, it should return an array where the first item is the
  23226. * header, and subsequent items are mapped to the points. Return `false` to
  23227. * disable tooltip for a specific point on series.
  23228. *
  23229. * @callback Highcharts.TooltipFormatterCallbackFunction
  23230. *
  23231. * @param {Highcharts.TooltipFormatterContextObject} this
  23232. * Context to format
  23233. *
  23234. * @param {Highcharts.Tooltip} tooltip
  23235. * The tooltip instance
  23236. *
  23237. * @return {false|string|Array<(string|null|undefined)>|null|undefined}
  23238. * Formatted text or false
  23239. */
  23240. /**
  23241. * @interface Highcharts.TooltipFormatterContextObject
  23242. */ /**
  23243. * @name Highcharts.TooltipFormatterContextObject#color
  23244. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  23245. */ /**
  23246. * @name Highcharts.TooltipFormatterContextObject#colorIndex
  23247. * @type {number|undefined}
  23248. */ /**
  23249. * @name Highcharts.TooltipFormatterContextObject#key
  23250. * @type {number}
  23251. */ /**
  23252. * @name Highcharts.TooltipFormatterContextObject#percentage
  23253. * @type {number|undefined}
  23254. */ /**
  23255. * @name Highcharts.TooltipFormatterContextObject#point
  23256. * @type {Highcharts.Point}
  23257. */ /**
  23258. * @name Highcharts.TooltipFormatterContextObject#points
  23259. * @type {Array<Highcharts.TooltipFormatterContextObject>|undefined}
  23260. */ /**
  23261. * @name Highcharts.TooltipFormatterContextObject#series
  23262. * @type {Highcharts.Series}
  23263. */ /**
  23264. * @name Highcharts.TooltipFormatterContextObject#total
  23265. * @type {number|undefined}
  23266. */ /**
  23267. * @name Highcharts.TooltipFormatterContextObject#x
  23268. * @type {number}
  23269. */ /**
  23270. * @name Highcharts.TooltipFormatterContextObject#y
  23271. * @type {number}
  23272. */
  23273. /**
  23274. * A callback function to place the tooltip in a specific position.
  23275. *
  23276. * @callback Highcharts.TooltipPositionerCallbackFunction
  23277. *
  23278. * @param {Highcharts.Tooltip} this
  23279. * Tooltip context of the callback.
  23280. *
  23281. * @param {number} labelWidth
  23282. * Width of the tooltip.
  23283. *
  23284. * @param {number} labelHeight
  23285. * Height of the tooltip.
  23286. *
  23287. * @param {Highcharts.TooltipPositionerPointObject} point
  23288. * Point information for positioning a tooltip.
  23289. *
  23290. * @return {Highcharts.PositionObject}
  23291. * New position for the tooltip.
  23292. */
  23293. /**
  23294. * Point information for positioning a tooltip.
  23295. *
  23296. * @interface Highcharts.TooltipPositionerPointObject
  23297. * @extends Highcharts.Point
  23298. */ /**
  23299. * If `tooltip.split` option is enabled and positioner is called for each of the
  23300. * boxes separately, this property indicates the call on the xAxis header, which
  23301. * is not a point itself.
  23302. * @name Highcharts.TooltipPositionerPointObject#isHeader
  23303. * @type {boolean}
  23304. */ /**
  23305. * The reference point relative to the plot area. Add chart.plotLeft to get the
  23306. * full coordinates.
  23307. * @name Highcharts.TooltipPositionerPointObject#plotX
  23308. * @type {number}
  23309. */ /**
  23310. * The reference point relative to the plot area. Add chart.plotTop to get the
  23311. * full coordinates.
  23312. * @name Highcharts.TooltipPositionerPointObject#plotY
  23313. * @type {number}
  23314. */
  23315. /**
  23316. * @typedef {"callout"|"circle"|"square"} Highcharts.TooltipShapeValue
  23317. */
  23318. ''; // separates doclets above from variables below
  23319. /* eslint-disable no-invalid-this, valid-jsdoc */
  23320. /**
  23321. * Tooltip of a chart.
  23322. *
  23323. * @class
  23324. * @name Highcharts.Tooltip
  23325. *
  23326. * @param {Highcharts.Chart} chart
  23327. * The chart instance.
  23328. *
  23329. * @param {Highcharts.TooltipOptions} options
  23330. * Tooltip options.
  23331. */
  23332. var Tooltip = /** @class */ (function () {
  23333. /* *
  23334. *
  23335. * Constructors
  23336. *
  23337. * */
  23338. function Tooltip(chart, options) {
  23339. this.container = void 0;
  23340. this.crosshairs = [];
  23341. this.distance = 0;
  23342. this.isHidden = true;
  23343. this.isSticky = false;
  23344. this.now = {};
  23345. this.options = {};
  23346. this.outside = false;
  23347. this.chart = chart;
  23348. this.init(chart, options);
  23349. }
  23350. /* *
  23351. *
  23352. * Functions
  23353. *
  23354. * */
  23355. /**
  23356. * In styled mode, apply the default filter for the tooltip drop-shadow. It
  23357. * needs to have an id specific to the chart, otherwise there will be issues
  23358. * when one tooltip adopts the filter of a different chart, specifically one
  23359. * where the container is hidden.
  23360. *
  23361. * @private
  23362. * @function Highcharts.Tooltip#applyFilter
  23363. */
  23364. Tooltip.prototype.applyFilter = function () {
  23365. var chart = this.chart;
  23366. chart.renderer.definition({
  23367. tagName: 'filter',
  23368. attributes: {
  23369. id: 'drop-shadow-' + chart.index,
  23370. opacity: 0.5
  23371. },
  23372. children: [{
  23373. tagName: 'feGaussianBlur',
  23374. attributes: {
  23375. 'in': 'SourceAlpha',
  23376. stdDeviation: 1
  23377. }
  23378. }, {
  23379. tagName: 'feOffset',
  23380. attributes: {
  23381. dx: 1,
  23382. dy: 1
  23383. }
  23384. }, {
  23385. tagName: 'feComponentTransfer',
  23386. children: [{
  23387. tagName: 'feFuncA',
  23388. attributes: {
  23389. type: 'linear',
  23390. slope: 0.3
  23391. }
  23392. }]
  23393. }, {
  23394. tagName: 'feMerge',
  23395. children: [{
  23396. tagName: 'feMergeNode'
  23397. }, {
  23398. tagName: 'feMergeNode',
  23399. attributes: {
  23400. 'in': 'SourceGraphic'
  23401. }
  23402. }]
  23403. }]
  23404. });
  23405. chart.renderer.definition({
  23406. tagName: 'style',
  23407. textContent: '.highcharts-tooltip-' + chart.index + '{' +
  23408. 'filter:url(#drop-shadow-' + chart.index + ')' +
  23409. '}'
  23410. });
  23411. };
  23412. /**
  23413. * Build the body (lines) of the tooltip by iterating over the items and
  23414. * returning one entry for each item, abstracting this functionality allows
  23415. * to easily overwrite and extend it.
  23416. *
  23417. * @private
  23418. * @function Highcharts.Tooltip#bodyFormatter
  23419. * @param {Array<(Highcharts.Point|Highcharts.Series)>} items
  23420. * @return {Array<string>}
  23421. */
  23422. Tooltip.prototype.bodyFormatter = function (items) {
  23423. return items.map(function (item) {
  23424. var tooltipOptions = item.series.tooltipOptions;
  23425. return (tooltipOptions[(item.point.formatPrefix || 'point') + 'Formatter'] ||
  23426. item.point.tooltipFormatter).call(item.point, tooltipOptions[(item.point.formatPrefix || 'point') + 'Format'] || '');
  23427. });
  23428. };
  23429. /**
  23430. * Destroy the single tooltips in a split tooltip.
  23431. * If the tooltip is active then it is not destroyed, unless forced to.
  23432. *
  23433. * @private
  23434. * @function Highcharts.Tooltip#cleanSplit
  23435. *
  23436. * @param {boolean} [force]
  23437. * Force destroy all tooltips.
  23438. */
  23439. Tooltip.prototype.cleanSplit = function (force) {
  23440. this.chart.series.forEach(function (series) {
  23441. var tt = series && series.tt;
  23442. if (tt) {
  23443. if (!tt.isActive || force) {
  23444. series.tt = tt.destroy();
  23445. }
  23446. else {
  23447. tt.isActive = false;
  23448. }
  23449. }
  23450. });
  23451. };
  23452. /**
  23453. * In case no user defined formatter is given, this will be used. Note that
  23454. * the context here is an object holding point, series, x, y etc.
  23455. *
  23456. * @function Highcharts.Tooltip#defaultFormatter
  23457. *
  23458. * @param {Highcharts.Tooltip} tooltip
  23459. *
  23460. * @return {Array<string>}
  23461. */
  23462. Tooltip.prototype.defaultFormatter = function (tooltip) {
  23463. var items = this.points || splat(this),
  23464. s;
  23465. // Build the header
  23466. s = [tooltip.tooltipFooterHeaderFormatter(items[0])];
  23467. // build the values
  23468. s = s.concat(tooltip.bodyFormatter(items));
  23469. // footer
  23470. s.push(tooltip.tooltipFooterHeaderFormatter(items[0], true));
  23471. return s;
  23472. };
  23473. /**
  23474. * Removes and destroys the tooltip and its elements.
  23475. *
  23476. * @function Highcharts.Tooltip#destroy
  23477. */
  23478. Tooltip.prototype.destroy = function () {
  23479. // Destroy and clear local variables
  23480. if (this.label) {
  23481. this.label = this.label.destroy();
  23482. }
  23483. if (this.split && this.tt) {
  23484. this.cleanSplit(this.chart, true);
  23485. this.tt = this.tt.destroy();
  23486. }
  23487. if (this.renderer) {
  23488. this.renderer = this.renderer.destroy();
  23489. discardElement(this.container);
  23490. }
  23491. U.clearTimeout(this.hideTimer);
  23492. U.clearTimeout(this.tooltipTimeout);
  23493. };
  23494. /**
  23495. * Extendable method to get the anchor position of the tooltip
  23496. * from a point or set of points
  23497. *
  23498. * @private
  23499. * @function Highcharts.Tooltip#getAnchor
  23500. *
  23501. * @param {Highcharts.Point|Array<Highcharts.Point>} points
  23502. *
  23503. * @param {Highcharts.PointerEventObject} [mouseEvent]
  23504. *
  23505. * @return {Array<number>}
  23506. */
  23507. Tooltip.prototype.getAnchor = function (points, mouseEvent) {
  23508. var ret,
  23509. chart = this.chart,
  23510. pointer = chart.pointer,
  23511. inverted = chart.inverted,
  23512. plotTop = chart.plotTop,
  23513. plotLeft = chart.plotLeft,
  23514. plotX = 0,
  23515. plotY = 0,
  23516. yAxis,
  23517. xAxis;
  23518. points = splat(points);
  23519. // When tooltip follows mouse, relate the position to the mouse
  23520. if (this.followPointer && mouseEvent) {
  23521. if (typeof mouseEvent.chartX === 'undefined') {
  23522. mouseEvent = pointer.normalize(mouseEvent);
  23523. }
  23524. ret = [
  23525. mouseEvent.chartX - plotLeft,
  23526. mouseEvent.chartY - plotTop
  23527. ];
  23528. // Some series types use a specificly calculated tooltip position for
  23529. // each point
  23530. }
  23531. else if (points[0].tooltipPos) {
  23532. ret = points[0].tooltipPos;
  23533. // Calculate the average position and adjust for axis positions
  23534. }
  23535. else {
  23536. points.forEach(function (point) {
  23537. yAxis = point.series.yAxis;
  23538. xAxis = point.series.xAxis;
  23539. plotX += point.plotX || 0;
  23540. plotY += (point.plotLow ?
  23541. (point.plotLow + (point.plotHigh || 0)) / 2 :
  23542. (point.plotY || 0));
  23543. // Adjust position for positioned axes (top/left settings)
  23544. if (xAxis && yAxis) {
  23545. if (!inverted) { // #1151
  23546. plotX += xAxis.pos - plotLeft;
  23547. plotY += yAxis.pos - plotTop;
  23548. }
  23549. else { // #14771
  23550. plotX += plotTop + chart.plotHeight - xAxis.len - xAxis.pos;
  23551. plotY += plotLeft + chart.plotWidth - yAxis.len - yAxis.pos;
  23552. }
  23553. }
  23554. });
  23555. plotX /= points.length;
  23556. plotY /= points.length;
  23557. // Use the average position for multiple points
  23558. ret = [
  23559. inverted ? chart.plotWidth - plotY : plotX,
  23560. inverted ? chart.plotHeight - plotX : plotY
  23561. ];
  23562. // When shared, place the tooltip next to the mouse (#424)
  23563. if (this.shared && points.length > 1 && mouseEvent) {
  23564. if (inverted) {
  23565. ret[0] = mouseEvent.chartX - plotLeft;
  23566. }
  23567. else {
  23568. ret[1] = mouseEvent.chartY - plotTop;
  23569. }
  23570. }
  23571. }
  23572. return ret.map(Math.round);
  23573. };
  23574. /**
  23575. * Get the optimal date format for a point, based on a range.
  23576. *
  23577. * @private
  23578. * @function Highcharts.Tooltip#getDateFormat
  23579. *
  23580. * @param {number} range
  23581. * The time range
  23582. *
  23583. * @param {number} date
  23584. * The date of the point in question
  23585. *
  23586. * @param {number} startOfWeek
  23587. * An integer representing the first day of the week, where 0 is
  23588. * Sunday.
  23589. *
  23590. * @param {Highcharts.Dictionary<string>} dateTimeLabelFormats
  23591. * A map of time units to formats.
  23592. *
  23593. * @return {string}
  23594. * The optimal date format for a point.
  23595. */
  23596. Tooltip.prototype.getDateFormat = function (range, date, startOfWeek, dateTimeLabelFormats) {
  23597. 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 = {
  23598. millisecond: 15,
  23599. second: 12,
  23600. minute: 9,
  23601. hour: 6,
  23602. day: 3
  23603. }, lastN = 'millisecond'; // for sub-millisecond data, #4223
  23604. for (n in timeUnits) { // eslint-disable-line guard-for-in
  23605. // If the range is exactly one week and we're looking at a
  23606. // Sunday/Monday, go for the week format
  23607. if (range === timeUnits.week &&
  23608. +time.dateFormat('%w', date) === startOfWeek &&
  23609. dateStr.substr(6) === blank.substr(6)) {
  23610. n = 'week';
  23611. break;
  23612. }
  23613. // The first format that is too great for the range
  23614. if (timeUnits[n] > range) {
  23615. n = lastN;
  23616. break;
  23617. }
  23618. // If the point is placed every day at 23:59, we need to show
  23619. // the minutes as well. #2637.
  23620. if (strpos[n] &&
  23621. dateStr.substr(strpos[n]) !== blank.substr(strpos[n])) {
  23622. break;
  23623. }
  23624. // Weeks are outside the hierarchy, only apply them on
  23625. // Mondays/Sundays like in the first condition
  23626. if (n !== 'week') {
  23627. lastN = n;
  23628. }
  23629. }
  23630. if (n) {
  23631. format = time.resolveDTLFormat(dateTimeLabelFormats[n]).main;
  23632. }
  23633. return format;
  23634. };
  23635. /**
  23636. * Creates the Tooltip label element if it does not exist, then returns it.
  23637. *
  23638. * @function Highcharts.Tooltip#getLabel
  23639. * @return {Highcharts.SVGElement}
  23640. */
  23641. Tooltip.prototype.getLabel = function () {
  23642. var tooltip = this,
  23643. renderer = this.chart.renderer,
  23644. styledMode = this.chart.styledMode,
  23645. options = this.options,
  23646. className = ('tooltip' + (defined(options.className) ?
  23647. ' ' + options.className :
  23648. '')),
  23649. pointerEvents = ((options.style && options.style.pointerEvents) ||
  23650. (!this.followPointer && options.stickOnContact ? 'auto' : 'none')),
  23651. container,
  23652. onMouseEnter = function () {
  23653. tooltip.inContact = true;
  23654. }, onMouseLeave = function () {
  23655. var series = tooltip.chart.hoverSeries;
  23656. tooltip.inContact = false;
  23657. if (series &&
  23658. series.onMouseOut) {
  23659. series.onMouseOut();
  23660. }
  23661. };
  23662. if (!this.label) {
  23663. if (this.outside) {
  23664. var chartStyle = this.chart.options.chart.style,
  23665. Renderer = RendererRegistry.getRendererType();
  23666. /**
  23667. * Reference to the tooltip's container, when
  23668. * [Highcharts.Tooltip#outside] is set to true, otherwise
  23669. * it's undefined.
  23670. *
  23671. * @name Highcharts.Tooltip#container
  23672. * @type {Highcharts.HTMLDOMElement|undefined}
  23673. */
  23674. this.container = container = H.doc.createElement('div');
  23675. container.className = 'highcharts-tooltip-container';
  23676. css(container, {
  23677. position: 'absolute',
  23678. top: '1px',
  23679. pointerEvents: pointerEvents,
  23680. zIndex: Math.max((this.options.style && this.options.style.zIndex || 0), (chartStyle && chartStyle.zIndex || 0) + 3)
  23681. });
  23682. H.doc.body.appendChild(container);
  23683. /**
  23684. * Reference to the tooltip's renderer, when
  23685. * [Highcharts.Tooltip#outside] is set to true, otherwise
  23686. * it's undefined.
  23687. *
  23688. * @name Highcharts.Tooltip#renderer
  23689. * @type {Highcharts.SVGRenderer|undefined}
  23690. */
  23691. this.renderer = renderer = new Renderer(container, 0, 0, chartStyle, void 0, void 0, renderer.styledMode);
  23692. }
  23693. // Create the label
  23694. if (this.split) {
  23695. this.label = renderer.g(className);
  23696. }
  23697. else {
  23698. this.label = renderer
  23699. .label('', 0, 0, options.shape || 'callout', null, null, options.useHTML, null, className)
  23700. .attr({
  23701. padding: options.padding,
  23702. r: options.borderRadius
  23703. });
  23704. if (!styledMode) {
  23705. this.label
  23706. .attr({
  23707. fill: options.backgroundColor,
  23708. 'stroke-width': options.borderWidth
  23709. })
  23710. // #2301, #2657
  23711. .css(options.style)
  23712. .css({ pointerEvents: pointerEvents })
  23713. .shadow(options.shadow);
  23714. }
  23715. }
  23716. if (styledMode) {
  23717. // Apply the drop-shadow filter
  23718. this.applyFilter();
  23719. this.label.addClass('highcharts-tooltip-' + this.chart.index);
  23720. }
  23721. // Split tooltip use updateTooltipContainer to position the tooltip
  23722. // container.
  23723. if (tooltip.outside && !tooltip.split) {
  23724. var label_1 = this.label;
  23725. var xSetter_1 = label_1.xSetter,
  23726. ySetter_1 = label_1.ySetter;
  23727. label_1.xSetter = function (value) {
  23728. xSetter_1.call(label_1, tooltip.distance);
  23729. container.style.left = value + 'px';
  23730. };
  23731. label_1.ySetter = function (value) {
  23732. ySetter_1.call(label_1, tooltip.distance);
  23733. container.style.top = value + 'px';
  23734. };
  23735. }
  23736. this.label
  23737. .on('mouseenter', onMouseEnter)
  23738. .on('mouseleave', onMouseLeave)
  23739. .attr({ zIndex: 8 })
  23740. .add();
  23741. }
  23742. return this.label;
  23743. };
  23744. /**
  23745. * Place the tooltip in a chart without spilling over
  23746. * and not covering the point it self.
  23747. *
  23748. * @private
  23749. * @function Highcharts.Tooltip#getPosition
  23750. *
  23751. * @param {number} boxWidth
  23752. *
  23753. * @param {number} boxHeight
  23754. *
  23755. * @param {Highcharts.Point} point
  23756. *
  23757. * @return {Highcharts.PositionObject}
  23758. */
  23759. Tooltip.prototype.getPosition = function (boxWidth, boxHeight, point) {
  23760. var chart = this.chart,
  23761. distance = this.distance,
  23762. ret = {},
  23763. // Don't use h if chart isn't inverted (#7242) ???
  23764. h = (chart.inverted && point.h) || 0, // #4117 ???
  23765. swapped,
  23766. outside = this.outside,
  23767. outerWidth = outside ?
  23768. // substract distance to prevent scrollbars
  23769. doc.documentElement.clientWidth - 2 * distance :
  23770. chart.chartWidth,
  23771. outerHeight = outside ?
  23772. Math.max(doc.body.scrollHeight,
  23773. doc.documentElement.scrollHeight,
  23774. doc.body.offsetHeight,
  23775. doc.documentElement.offsetHeight,
  23776. doc.documentElement.clientHeight) :
  23777. chart.chartHeight,
  23778. chartPosition = chart.pointer.getChartPosition(),
  23779. scaleX = function (val) { return ( // eslint-disable-line no-confusing-arrow
  23780. val * chartPosition.scaleX); },
  23781. scaleY = function (val) { return ( // eslint-disable-line no-confusing-arrow
  23782. val * chartPosition.scaleY); },
  23783. // Build parameter arrays for firstDimension()/secondDimension()
  23784. buildDimensionArray = function (dim) {
  23785. var isX = dim === 'x';
  23786. return [
  23787. dim,
  23788. isX ? outerWidth : outerHeight,
  23789. isX ? boxWidth : boxHeight
  23790. ].concat(outside ? [
  23791. // If we are using tooltip.outside, we need to scale the
  23792. // position to match scaling of the container in case there
  23793. // is a transform/zoom on the container. #11329
  23794. isX ? scaleX(boxWidth) : scaleY(boxHeight),
  23795. isX ? chartPosition.left - distance +
  23796. scaleX(point.plotX + chart.plotLeft) :
  23797. chartPosition.top - distance +
  23798. scaleY(point.plotY + chart.plotTop),
  23799. 0,
  23800. isX ? outerWidth : outerHeight
  23801. ] : [
  23802. // Not outside, no scaling is needed
  23803. isX ? boxWidth : boxHeight,
  23804. isX ? point.plotX + chart.plotLeft :
  23805. point.plotY + chart.plotTop,
  23806. isX ? chart.plotLeft : chart.plotTop,
  23807. isX ? chart.plotLeft + chart.plotWidth :
  23808. chart.plotTop + chart.plotHeight
  23809. ]);
  23810. }, first = buildDimensionArray('y'), second = buildDimensionArray('x'),
  23811. // The far side is right or bottom
  23812. preferFarSide = !this.followPointer && pick(point.ttBelow, !chart.inverted === !!point.negative), // #4984
  23813. /*
  23814. * Handle the preferred dimension. When the preferred dimension is
  23815. * tooltip on top or bottom of the point, it will look for space
  23816. * there.
  23817. *
  23818. * @private
  23819. */
  23820. firstDimension = function (dim, outerSize, innerSize, scaledInnerSize, // #11329
  23821. point, min, max) {
  23822. var scaledDist = outside ?
  23823. (dim === 'y' ? scaleY(distance) : scaleX(distance)) :
  23824. distance,
  23825. scaleDiff = (innerSize - scaledInnerSize) / 2,
  23826. roomLeft = scaledInnerSize < point - distance,
  23827. roomRight = point + distance + scaledInnerSize < outerSize,
  23828. alignedLeft = point - scaledDist - innerSize + scaleDiff,
  23829. alignedRight = point + scaledDist - scaleDiff;
  23830. if (preferFarSide && roomRight) {
  23831. ret[dim] = alignedRight;
  23832. }
  23833. else if (!preferFarSide && roomLeft) {
  23834. ret[dim] = alignedLeft;
  23835. }
  23836. else if (roomLeft) {
  23837. ret[dim] = Math.min(max - scaledInnerSize, alignedLeft - h < 0 ? alignedLeft : alignedLeft - h);
  23838. }
  23839. else if (roomRight) {
  23840. ret[dim] = Math.max(min, alignedRight + h + innerSize > outerSize ?
  23841. alignedRight :
  23842. alignedRight + h);
  23843. }
  23844. else {
  23845. return false;
  23846. }
  23847. },
  23848. /*
  23849. * Handle the secondary dimension. If the preferred dimension is
  23850. * tooltip on top or bottom of the point, the second dimension is to
  23851. * align the tooltip above the point, trying to align center but
  23852. * allowing left or right align within the chart box.
  23853. *
  23854. * @private
  23855. */
  23856. secondDimension = function (dim, outerSize, innerSize, scaledInnerSize, // #11329
  23857. point) {
  23858. var retVal;
  23859. // Too close to the edge, return false and swap dimensions
  23860. if (point < distance || point > outerSize - distance) {
  23861. retVal = false;
  23862. // Align left/top
  23863. }
  23864. else if (point < innerSize / 2) {
  23865. ret[dim] = 1;
  23866. // Align right/bottom
  23867. }
  23868. else if (point > outerSize - scaledInnerSize / 2) {
  23869. ret[dim] = outerSize - scaledInnerSize - 2;
  23870. // Align center
  23871. }
  23872. else {
  23873. ret[dim] = point - innerSize / 2;
  23874. }
  23875. return retVal;
  23876. },
  23877. /*
  23878. * Swap the dimensions
  23879. */
  23880. swap = function (count) {
  23881. var temp = first;
  23882. first = second;
  23883. second = temp;
  23884. swapped = count;
  23885. }, run = function () {
  23886. if (firstDimension.apply(0, first) !== false) {
  23887. if (secondDimension.apply(0, second) === false &&
  23888. !swapped) {
  23889. swap(true);
  23890. run();
  23891. }
  23892. }
  23893. else if (!swapped) {
  23894. swap(true);
  23895. run();
  23896. }
  23897. else {
  23898. ret.x = ret.y = 0;
  23899. }
  23900. };
  23901. // Under these conditions, prefer the tooltip on the side of the point
  23902. if (chart.inverted || this.len > 1) {
  23903. swap();
  23904. }
  23905. run();
  23906. return ret;
  23907. };
  23908. /**
  23909. * Get the best X date format based on the closest point range on the axis.
  23910. *
  23911. * @private
  23912. * @function Highcharts.Tooltip#getXDateFormat
  23913. *
  23914. * @param {Highcharts.Point} point
  23915. *
  23916. * @param {Highcharts.TooltipOptions} options
  23917. *
  23918. * @param {Highcharts.Axis} xAxis
  23919. *
  23920. * @return {string}
  23921. */
  23922. Tooltip.prototype.getXDateFormat = function (point, options, xAxis) {
  23923. var xDateFormat,
  23924. dateTimeLabelFormats = options.dateTimeLabelFormats,
  23925. closestPointRange = xAxis && xAxis.closestPointRange;
  23926. if (closestPointRange) {
  23927. xDateFormat = this.getDateFormat(closestPointRange, point.x, xAxis.options.startOfWeek, dateTimeLabelFormats);
  23928. }
  23929. else {
  23930. xDateFormat = dateTimeLabelFormats.day;
  23931. }
  23932. return xDateFormat || dateTimeLabelFormats.year; // #2546, 2581
  23933. };
  23934. /**
  23935. * Hides the tooltip with a fade out animation.
  23936. *
  23937. * @function Highcharts.Tooltip#hide
  23938. *
  23939. * @param {number} [delay]
  23940. * The fade out in milliseconds. If no value is provided the value
  23941. * of the tooltip.hideDelay option is used. A value of 0 disables
  23942. * the fade out animation.
  23943. */
  23944. Tooltip.prototype.hide = function (delay) {
  23945. var tooltip = this;
  23946. // disallow duplicate timers (#1728, #1766)
  23947. U.clearTimeout(this.hideTimer);
  23948. delay = pick(delay, this.options.hideDelay, 500);
  23949. if (!this.isHidden) {
  23950. this.hideTimer = syncTimeout(function () {
  23951. // If there is a delay, do fadeOut with the default duration. If
  23952. // the hideDelay is 0, we assume no animation is wanted, so we
  23953. // pass 0 duration. #12994.
  23954. tooltip.getLabel().fadeOut(delay ? void 0 : delay);
  23955. tooltip.isHidden = true;
  23956. }, delay);
  23957. }
  23958. };
  23959. /**
  23960. * @private
  23961. * @function Highcharts.Tooltip#init
  23962. *
  23963. * @param {Highcharts.Chart} chart
  23964. * The chart instance.
  23965. *
  23966. * @param {Highcharts.TooltipOptions} options
  23967. * Tooltip options.
  23968. */
  23969. Tooltip.prototype.init = function (chart, options) {
  23970. /**
  23971. * Chart of the tooltip.
  23972. *
  23973. * @readonly
  23974. * @name Highcharts.Tooltip#chart
  23975. * @type {Highcharts.Chart}
  23976. */
  23977. this.chart = chart;
  23978. /**
  23979. * Used tooltip options.
  23980. *
  23981. * @readonly
  23982. * @name Highcharts.Tooltip#options
  23983. * @type {Highcharts.TooltipOptions}
  23984. */
  23985. this.options = options;
  23986. /**
  23987. * List of crosshairs.
  23988. *
  23989. * @private
  23990. * @readonly
  23991. * @name Highcharts.Tooltip#crosshairs
  23992. * @type {Array<null>}
  23993. */
  23994. this.crosshairs = [];
  23995. /**
  23996. * Current values of x and y when animating.
  23997. *
  23998. * @private
  23999. * @readonly
  24000. * @name Highcharts.Tooltip#now
  24001. * @type {Highcharts.PositionObject}
  24002. */
  24003. this.now = { x: 0, y: 0 };
  24004. /**
  24005. * Tooltips are initially hidden.
  24006. *
  24007. * @private
  24008. * @readonly
  24009. * @name Highcharts.Tooltip#isHidden
  24010. * @type {boolean}
  24011. */
  24012. this.isHidden = true;
  24013. /**
  24014. * True, if the tooltip is split into one label per series, with the
  24015. * header close to the axis.
  24016. *
  24017. * @readonly
  24018. * @name Highcharts.Tooltip#split
  24019. * @type {boolean|undefined}
  24020. */
  24021. this.split = options.split && !chart.inverted && !chart.polar;
  24022. /**
  24023. * When the tooltip is shared, the entire plot area will capture mouse
  24024. * movement or touch events.
  24025. *
  24026. * @readonly
  24027. * @name Highcharts.Tooltip#shared
  24028. * @type {boolean|undefined}
  24029. */
  24030. this.shared = options.shared || this.split;
  24031. /**
  24032. * Whether to allow the tooltip to render outside the chart's SVG
  24033. * element box. By default (false), the tooltip is rendered within the
  24034. * chart's SVG element, which results in the tooltip being aligned
  24035. * inside the chart area.
  24036. *
  24037. * @readonly
  24038. * @name Highcharts.Tooltip#outside
  24039. * @type {boolean}
  24040. *
  24041. * @todo
  24042. * Split tooltip does not support outside in the first iteration. Should
  24043. * not be too complicated to implement.
  24044. */
  24045. this.outside = pick(options.outside, Boolean(chart.scrollablePixelsX || chart.scrollablePixelsY));
  24046. };
  24047. /**
  24048. * Returns true, if the pointer is in contact with the tooltip tracker.
  24049. */
  24050. Tooltip.prototype.isStickyOnContact = function () {
  24051. return !!(!this.followPointer &&
  24052. this.options.stickOnContact &&
  24053. this.inContact);
  24054. };
  24055. /**
  24056. * Moves the tooltip with a soft animation to a new position.
  24057. *
  24058. * @private
  24059. * @function Highcharts.Tooltip#move
  24060. *
  24061. * @param {number} x
  24062. *
  24063. * @param {number} y
  24064. *
  24065. * @param {number} anchorX
  24066. *
  24067. * @param {number} anchorY
  24068. */
  24069. Tooltip.prototype.move = function (x, y, anchorX, anchorY) {
  24070. var tooltip = this,
  24071. now = tooltip.now,
  24072. animate = tooltip.options.animation !== false &&
  24073. !tooltip.isHidden &&
  24074. // When we get close to the target position, abort animation and
  24075. // land on the right place (#3056)
  24076. (Math.abs(x - now.x) > 1 || Math.abs(y - now.y) > 1),
  24077. skipAnchor = tooltip.followPointer || tooltip.len > 1;
  24078. // Get intermediate values for animation
  24079. extend(now, {
  24080. x: animate ? (2 * now.x + x) / 3 : x,
  24081. y: animate ? (now.y + y) / 2 : y,
  24082. anchorX: skipAnchor ?
  24083. void 0 :
  24084. animate ? (2 * now.anchorX + anchorX) / 3 : anchorX,
  24085. anchorY: skipAnchor ?
  24086. void 0 :
  24087. animate ? (now.anchorY + anchorY) / 2 : anchorY
  24088. });
  24089. // Move to the intermediate value
  24090. tooltip.getLabel().attr(now);
  24091. tooltip.drawTracker();
  24092. // Run on next tick of the mouse tracker
  24093. if (animate) {
  24094. // Never allow two timeouts
  24095. U.clearTimeout(this.tooltipTimeout);
  24096. // Set the fixed interval ticking for the smooth tooltip
  24097. this.tooltipTimeout = setTimeout(function () {
  24098. // The interval function may still be running during destroy,
  24099. // so check that the chart is really there before calling.
  24100. if (tooltip) {
  24101. tooltip.move(x, y, anchorX, anchorY);
  24102. }
  24103. }, 32);
  24104. }
  24105. };
  24106. /**
  24107. * Refresh the tooltip's text and position.
  24108. *
  24109. * @function Highcharts.Tooltip#refresh
  24110. *
  24111. * @param {Highcharts.Point|Array<Highcharts.Point>} pointOrPoints
  24112. * Either a point or an array of points.
  24113. *
  24114. * @param {Highcharts.PointerEventObject} [mouseEvent]
  24115. * Mouse event, that is responsible for the refresh and should be
  24116. * used for the tooltip update.
  24117. */
  24118. Tooltip.prototype.refresh = function (pointOrPoints, mouseEvent) {
  24119. var tooltip = this,
  24120. chart = this.chart,
  24121. options = tooltip.options,
  24122. x,
  24123. y,
  24124. points = splat(pointOrPoints),
  24125. point = points[0],
  24126. anchor,
  24127. textConfig = {},
  24128. text,
  24129. pointConfig = [],
  24130. formatter = options.formatter || tooltip.defaultFormatter,
  24131. shared = tooltip.shared,
  24132. styledMode = chart.styledMode;
  24133. if (!options.enabled) {
  24134. return;
  24135. }
  24136. U.clearTimeout(this.hideTimer);
  24137. // get the reference point coordinates (pie charts use tooltipPos)
  24138. tooltip.followPointer = !tooltip.split && point.series.tooltipOptions.followPointer;
  24139. anchor = tooltip.getAnchor(pointOrPoints, mouseEvent);
  24140. x = anchor[0];
  24141. y = anchor[1];
  24142. // shared tooltip, array is sent over
  24143. if (shared &&
  24144. !(!isArray(pointOrPoints) &&
  24145. pointOrPoints.series &&
  24146. pointOrPoints.series.noSharedTooltip)) {
  24147. chart.pointer.applyInactiveState(points);
  24148. // Now set hover state for the choosen ones:
  24149. points.forEach(function (item) {
  24150. item.setState('hover');
  24151. pointConfig.push(item.getLabelConfig());
  24152. });
  24153. textConfig = {
  24154. x: point.category,
  24155. y: point.y
  24156. };
  24157. textConfig.points = pointConfig;
  24158. // single point tooltip
  24159. }
  24160. else {
  24161. textConfig = point.getLabelConfig();
  24162. }
  24163. this.len = pointConfig.length; // #6128
  24164. text = formatter.call(textConfig, tooltip);
  24165. // register the current series
  24166. var currentSeries = point.series;
  24167. this.distance = pick(currentSeries.tooltipOptions.distance, 16);
  24168. // update the inner HTML
  24169. if (text === false) {
  24170. this.hide();
  24171. }
  24172. else {
  24173. // update text
  24174. if (tooltip.split) {
  24175. this.renderSplit(text, points);
  24176. }
  24177. else {
  24178. var checkX = x;
  24179. var checkY = y;
  24180. if (mouseEvent && chart.pointer.isDirectTouch) {
  24181. checkX = mouseEvent.chartX - chart.plotLeft;
  24182. checkY = mouseEvent.chartY - chart.plotTop;
  24183. }
  24184. // #11493, #13095
  24185. if (chart.polar ||
  24186. currentSeries.options.clip === false ||
  24187. currentSeries.shouldShowTooltip(checkX, checkY)) {
  24188. var label = tooltip.getLabel();
  24189. // Prevent the tooltip from flowing over the chart box
  24190. // (#6659)
  24191. if (!options.style.width || styledMode) {
  24192. label.css({
  24193. width: this.chart.spacingBox.width + 'px'
  24194. });
  24195. }
  24196. label.attr({
  24197. text: text && text.join ?
  24198. text.join('') :
  24199. text
  24200. });
  24201. // Set the stroke color of the box to reflect the point
  24202. label.removeClass(/highcharts-color-[\d]+/g)
  24203. .addClass('highcharts-color-' +
  24204. pick(point.colorIndex, currentSeries.colorIndex));
  24205. if (!styledMode) {
  24206. label.attr({
  24207. stroke: (options.borderColor ||
  24208. point.color ||
  24209. currentSeries.color ||
  24210. palette.neutralColor60)
  24211. });
  24212. }
  24213. tooltip.updatePosition({
  24214. plotX: x,
  24215. plotY: y,
  24216. negative: point.negative,
  24217. ttBelow: point.ttBelow,
  24218. h: anchor[2] || 0
  24219. });
  24220. }
  24221. else {
  24222. tooltip.hide();
  24223. return;
  24224. }
  24225. }
  24226. // show it
  24227. if (tooltip.isHidden && tooltip.label) {
  24228. tooltip.label.attr({
  24229. opacity: 1
  24230. }).show();
  24231. }
  24232. tooltip.isHidden = false;
  24233. }
  24234. fireEvent(this, 'refresh');
  24235. };
  24236. /**
  24237. * Render the split tooltip. Loops over each point's text and adds
  24238. * a label next to the point, then uses the distribute function to
  24239. * find best non-overlapping positions.
  24240. *
  24241. * @private
  24242. * @function Highcharts.Tooltip#renderSplit
  24243. *
  24244. * @param {string|Array<(boolean|string)>} labels
  24245. *
  24246. * @param {Array<Highcharts.Point>} points
  24247. */
  24248. Tooltip.prototype.renderSplit = function (labels, points) {
  24249. var tooltip = this;
  24250. var chart = tooltip.chart,
  24251. _a = tooltip.chart,
  24252. chartWidth = _a.chartWidth,
  24253. chartHeight = _a.chartHeight,
  24254. plotHeight = _a.plotHeight,
  24255. plotLeft = _a.plotLeft,
  24256. plotTop = _a.plotTop,
  24257. pointer = _a.pointer,
  24258. _b = _a.scrollablePixelsY,
  24259. scrollablePixelsY = _b === void 0 ? 0 : _b,
  24260. scrollablePixelsX = _a.scrollablePixelsX,
  24261. _c = _a.scrollingContainer,
  24262. _d = _c === void 0 ? { scrollLeft: 0,
  24263. scrollTop: 0 } : _c,
  24264. scrollLeft = _d.scrollLeft,
  24265. scrollTop = _d.scrollTop,
  24266. styledMode = _a.styledMode,
  24267. distance = tooltip.distance,
  24268. options = tooltip.options,
  24269. positioner = tooltip.options.positioner;
  24270. // The area which the tooltip should be limited to. Limit to scrollable
  24271. // plot area if enabled, otherwise limit to the chart container.
  24272. // If outside is true it should be the whole viewport
  24273. var bounds = tooltip.outside && typeof scrollablePixelsX !== 'number' ?
  24274. doc.documentElement.getBoundingClientRect() : {
  24275. left: scrollLeft,
  24276. right: scrollLeft + chartWidth,
  24277. top: scrollTop,
  24278. bottom: scrollTop + chartHeight
  24279. };
  24280. var tooltipLabel = tooltip.getLabel();
  24281. var ren = this.renderer || chart.renderer;
  24282. var headerTop = Boolean(chart.xAxis[0] && chart.xAxis[0].opposite);
  24283. var _e = pointer.getChartPosition(),
  24284. chartLeft = _e.left,
  24285. chartTop = _e.top;
  24286. var distributionBoxTop = plotTop + scrollTop;
  24287. var headerHeight = 0;
  24288. var adjustedPlotHeight = plotHeight - scrollablePixelsY;
  24289. /**
  24290. * Calculates the anchor position for the partial tooltip
  24291. *
  24292. * @private
  24293. * @param {Highcharts.Point} point The point related to the tooltip
  24294. * @return {object} Returns an object with anchorX and anchorY
  24295. */
  24296. function getAnchor(point) {
  24297. var isHeader = point.isHeader,
  24298. _a = point.plotX,
  24299. plotX = _a === void 0 ? 0 : _a,
  24300. _b = point.plotY,
  24301. plotY = _b === void 0 ? 0 : _b,
  24302. series = point.series;
  24303. var anchorX;
  24304. var anchorY;
  24305. if (isHeader) {
  24306. // Set anchorX to plotX
  24307. anchorX = plotLeft + plotX;
  24308. // Set anchorY to center of visible plot area.
  24309. anchorY = plotTop + plotHeight / 2;
  24310. }
  24311. else {
  24312. var xAxis = series.xAxis,
  24313. yAxis = series.yAxis;
  24314. // Set anchorX to plotX. Limit to within xAxis.
  24315. anchorX = xAxis.pos + clamp(plotX, -distance, xAxis.len + distance);
  24316. // Set anchorY, limit to the scrollable plot area
  24317. if (series.shouldShowTooltip(0, yAxis.pos - plotTop + plotY, {
  24318. ignoreX: true
  24319. })) {
  24320. anchorY = yAxis.pos + plotY;
  24321. }
  24322. }
  24323. // Limit values to plot area
  24324. anchorX = clamp(anchorX, bounds.left - distance, bounds.right + distance);
  24325. return { anchorX: anchorX, anchorY: anchorY };
  24326. }
  24327. /**
  24328. * Calculates the position of the partial tooltip
  24329. *
  24330. * @private
  24331. * @param {number} anchorX The partial tooltip anchor x position
  24332. * @param {number} anchorY The partial tooltip anchor y position
  24333. * @param {boolean} isHeader Whether the partial tooltip is a header
  24334. * @param {number} boxWidth Width of the partial tooltip
  24335. * @return {Highcharts.PositionObject} Returns the partial tooltip x and
  24336. * y position
  24337. */
  24338. function defaultPositioner(anchorX, anchorY, isHeader, boxWidth, alignedLeft) {
  24339. if (alignedLeft === void 0) { alignedLeft = true; }
  24340. var y;
  24341. var x;
  24342. if (isHeader) {
  24343. y = headerTop ? 0 : adjustedPlotHeight;
  24344. x = clamp(anchorX - (boxWidth / 2), bounds.left, bounds.right - boxWidth - (tooltip.outside ? chartLeft : 0));
  24345. }
  24346. else {
  24347. y = anchorY - distributionBoxTop;
  24348. x = alignedLeft ?
  24349. anchorX - boxWidth - distance :
  24350. anchorX + distance;
  24351. x = clamp(x, alignedLeft ? x : bounds.left, bounds.right);
  24352. }
  24353. // NOTE: y is relative to distributionBoxTop
  24354. return { x: x, y: y };
  24355. }
  24356. /**
  24357. * Updates the attributes and styling of the partial tooltip. Creates a
  24358. * new partial tooltip if it does not exists.
  24359. *
  24360. * @private
  24361. * @param {Highcharts.SVGElement|undefined} partialTooltip
  24362. * The partial tooltip to update
  24363. * @param {Highcharts.Point} point
  24364. * The point related to the partial tooltip
  24365. * @param {boolean|string} str The text for the partial tooltip
  24366. * @return {Highcharts.SVGElement} Returns the updated partial tooltip
  24367. */
  24368. function updatePartialTooltip(partialTooltip, point, str) {
  24369. var tt = partialTooltip;
  24370. var isHeader = point.isHeader,
  24371. series = point.series;
  24372. var colorClass = 'highcharts-color-' + pick(point.colorIndex, series.colorIndex, 'none');
  24373. if (!tt) {
  24374. var attribs = {
  24375. padding: options.padding,
  24376. r: options.borderRadius
  24377. };
  24378. if (!styledMode) {
  24379. attribs.fill = options.backgroundColor;
  24380. attribs['stroke-width'] = options.borderWidth;
  24381. }
  24382. tt = ren
  24383. .label('', 0, 0, (options[isHeader ? 'headerShape' : 'shape']) ||
  24384. 'callout', void 0, void 0, options.useHTML)
  24385. .addClass((isHeader ? 'highcharts-tooltip-header ' : '') +
  24386. 'highcharts-tooltip-box ' +
  24387. colorClass)
  24388. .attr(attribs)
  24389. .add(tooltipLabel);
  24390. }
  24391. tt.isActive = true;
  24392. tt.attr({
  24393. text: str
  24394. });
  24395. if (!styledMode) {
  24396. tt.css(options.style)
  24397. .shadow(options.shadow)
  24398. .attr({
  24399. stroke: (options.borderColor ||
  24400. point.color ||
  24401. series.color ||
  24402. palette.neutralColor80)
  24403. });
  24404. }
  24405. return tt;
  24406. }
  24407. // Graceful degradation for legacy formatters
  24408. if (isString(labels)) {
  24409. labels = [false, labels];
  24410. }
  24411. // Create the individual labels for header and points, ignore footer
  24412. var boxes = labels.slice(0,
  24413. points.length + 1).reduce(function (boxes,
  24414. str,
  24415. i) {
  24416. if (str !== false && str !== '') {
  24417. var point = (points[i - 1] ||
  24418. {
  24419. // Item 0 is the header. Instead of this, we could also
  24420. // use the crosshair label
  24421. isHeader: true,
  24422. plotX: points[0].plotX,
  24423. plotY: plotHeight,
  24424. series: {}
  24425. });
  24426. var isHeader = point.isHeader;
  24427. // Store the tooltip label referance on the series
  24428. var owner = isHeader ? tooltip : point.series;
  24429. var tt = owner.tt = updatePartialTooltip(owner.tt,
  24430. point,
  24431. str.toString());
  24432. // Get X position now, so we can move all to the other side in
  24433. // case of overflow
  24434. var bBox = tt.getBBox();
  24435. var boxWidth = bBox.width + tt.strokeWidth();
  24436. if (isHeader) {
  24437. headerHeight = bBox.height;
  24438. adjustedPlotHeight += headerHeight;
  24439. if (headerTop) {
  24440. distributionBoxTop -= headerHeight;
  24441. }
  24442. }
  24443. var _a = getAnchor(point),
  24444. anchorX = _a.anchorX,
  24445. anchorY = _a.anchorY;
  24446. if (typeof anchorY === 'number') {
  24447. var size = bBox.height + 1;
  24448. var boxPosition = (positioner ?
  24449. positioner.call(tooltip,
  24450. boxWidth,
  24451. size,
  24452. point) :
  24453. defaultPositioner(anchorX,
  24454. anchorY,
  24455. isHeader,
  24456. boxWidth));
  24457. boxes.push({
  24458. // 0-align to the top, 1-align to the bottom
  24459. align: positioner ? 0 : void 0,
  24460. anchorX: anchorX,
  24461. anchorY: anchorY,
  24462. boxWidth: boxWidth,
  24463. point: point,
  24464. rank: pick(boxPosition.rank, isHeader ? 1 : 0),
  24465. size: size,
  24466. target: boxPosition.y,
  24467. tt: tt,
  24468. x: boxPosition.x
  24469. });
  24470. }
  24471. else {
  24472. // Hide tooltips which anchorY is outside the visible plot
  24473. // area
  24474. tt.isActive = false;
  24475. }
  24476. }
  24477. return boxes;
  24478. }, []);
  24479. // Realign the tooltips towards the right if there is not enough
  24480. // space to the left and there is space to to the right
  24481. if (!positioner && boxes.some(function (box) {
  24482. // Always realign if the beginning of a label is outside bounds
  24483. var outside = tooltip.outside;
  24484. var boxStart = (outside ? chartLeft : 0) + box.anchorX;
  24485. if (boxStart < bounds.left && boxStart + box.boxWidth < bounds.right) {
  24486. return true;
  24487. }
  24488. // Otherwise, check if there is more space available to the right
  24489. return boxStart < (chartLeft - bounds.left) + box.boxWidth &&
  24490. bounds.right - boxStart > boxStart;
  24491. })) {
  24492. boxes = boxes.map(function (box) {
  24493. var _a = defaultPositioner(box.anchorX,
  24494. box.anchorY,
  24495. box.point.isHeader,
  24496. box.boxWidth,
  24497. false),
  24498. x = _a.x,
  24499. y = _a.y;
  24500. return extend(box, {
  24501. target: y,
  24502. x: x
  24503. });
  24504. });
  24505. }
  24506. // Clean previous run (for missing points)
  24507. tooltip.cleanSplit();
  24508. // Distribute and put in place
  24509. H.distribute(boxes, adjustedPlotHeight);
  24510. var boxExtremes = {
  24511. left: chartLeft,
  24512. right: chartLeft
  24513. };
  24514. // Get the extremes from series tooltips
  24515. boxes.forEach(function (box) {
  24516. var x = box.x,
  24517. boxWidth = box.boxWidth,
  24518. isHeader = box.isHeader;
  24519. if (!isHeader) {
  24520. if (tooltip.outside && chartLeft + x < boxExtremes.left) {
  24521. boxExtremes.left = chartLeft + x;
  24522. }
  24523. if (!isHeader && tooltip.outside && boxExtremes.left + boxWidth > boxExtremes.right) {
  24524. boxExtremes.right = chartLeft + x;
  24525. }
  24526. }
  24527. });
  24528. boxes.forEach(function (box) {
  24529. var x = box.x,
  24530. anchorX = box.anchorX,
  24531. anchorY = box.anchorY,
  24532. pos = box.pos,
  24533. isHeader = box.point.isHeader;
  24534. var attributes = {
  24535. visibility: typeof pos === 'undefined' ? 'hidden' : 'inherit',
  24536. x: x,
  24537. /* NOTE: y should equal pos to be consistent with !split
  24538. * tooltip,
  24539. but is currently relative to plotTop. Is left as is
  24540. * to avoid breaking change. Remove distributionBoxTop to make
  24541. * it consistent.
  24542. */
  24543. y: pos + distributionBoxTop,
  24544. anchorX: anchorX,
  24545. anchorY: anchorY
  24546. };
  24547. // Handle left-aligned tooltips overflowing the chart area
  24548. if (tooltip.outside && x < anchorX) {
  24549. var offset = chartLeft - boxExtremes.left;
  24550. // Skip this if there is no overflow
  24551. if (offset > 0) {
  24552. if (!isHeader) {
  24553. attributes.x = x + offset;
  24554. attributes.anchorX = anchorX + offset;
  24555. }
  24556. if (isHeader) {
  24557. attributes.x = (boxExtremes.right - boxExtremes.left) / 2;
  24558. attributes.anchorX = anchorX + offset;
  24559. }
  24560. }
  24561. }
  24562. // Put the label in place
  24563. box.tt.attr(attributes);
  24564. });
  24565. /* If we have a seperate tooltip container, then update the necessary
  24566. * container properties.
  24567. * Test that tooltip has its own container and renderer before executing
  24568. * the operation.
  24569. */
  24570. var container = tooltip.container,
  24571. outside = tooltip.outside,
  24572. renderer = tooltip.renderer;
  24573. if (outside && container && renderer) {
  24574. // Set container size to fit the bounds
  24575. var _f = tooltipLabel.getBBox(),
  24576. width = _f.width,
  24577. height = _f.height,
  24578. x = _f.x,
  24579. y = _f.y;
  24580. renderer.setSize(width + x, height + y, false);
  24581. // Position the tooltip container to the chart container
  24582. container.style.left = boxExtremes.left + 'px';
  24583. container.style.top = chartTop + 'px';
  24584. }
  24585. };
  24586. /**
  24587. * If the `stickOnContact` option is active, this will add a tracker shape.
  24588. *
  24589. * @private
  24590. * @function Highcharts.Tooltip#drawTracker
  24591. */
  24592. Tooltip.prototype.drawTracker = function () {
  24593. var tooltip = this;
  24594. if (tooltip.followPointer ||
  24595. !tooltip.options.stickOnContact) {
  24596. if (tooltip.tracker) {
  24597. tooltip.tracker.destroy();
  24598. }
  24599. return;
  24600. }
  24601. var chart = tooltip.chart;
  24602. var label = tooltip.label;
  24603. var point = chart.hoverPoint;
  24604. if (!label || !point) {
  24605. return;
  24606. }
  24607. var box = {
  24608. x: 0,
  24609. y: 0,
  24610. width: 0,
  24611. height: 0
  24612. };
  24613. // Combine anchor and tooltip
  24614. var anchorPos = this.getAnchor(point);
  24615. var labelBBox = label.getBBox();
  24616. anchorPos[0] += chart.plotLeft - label.translateX;
  24617. anchorPos[1] += chart.plotTop - label.translateY;
  24618. // When the mouse pointer is between the anchor point and the label,
  24619. // the label should stick.
  24620. box.x = Math.min(0, anchorPos[0]);
  24621. box.y = Math.min(0, anchorPos[1]);
  24622. box.width = (anchorPos[0] < 0 ?
  24623. Math.max(Math.abs(anchorPos[0]), (labelBBox.width - anchorPos[0])) :
  24624. Math.max(Math.abs(anchorPos[0]), labelBBox.width));
  24625. box.height = (anchorPos[1] < 0 ?
  24626. Math.max(Math.abs(anchorPos[1]), (labelBBox.height - Math.abs(anchorPos[1]))) :
  24627. Math.max(Math.abs(anchorPos[1]), labelBBox.height));
  24628. if (tooltip.tracker) {
  24629. tooltip.tracker.attr(box);
  24630. }
  24631. else {
  24632. tooltip.tracker = label.renderer
  24633. .rect(box)
  24634. .addClass('highcharts-tracker')
  24635. .add(label);
  24636. if (!chart.styledMode) {
  24637. tooltip.tracker.attr({
  24638. fill: 'rgba(0,0,0,0)'
  24639. });
  24640. }
  24641. }
  24642. };
  24643. /**
  24644. * @private
  24645. */
  24646. Tooltip.prototype.styledModeFormat = function (formatString) {
  24647. return formatString
  24648. .replace('style="font-size: 10px"', 'class="highcharts-header"')
  24649. .replace(/style="color:{(point|series)\.color}"/g, 'class="highcharts-color-{$1.colorIndex}"');
  24650. };
  24651. /**
  24652. * Format the footer/header of the tooltip
  24653. * #3397: abstraction to enable formatting of footer and header
  24654. *
  24655. * @private
  24656. * @function Highcharts.Tooltip#tooltipFooterHeaderFormatter
  24657. * @param {Highcharts.PointLabelObject} labelConfig
  24658. * @param {boolean} [isFooter]
  24659. * @return {string}
  24660. */
  24661. Tooltip.prototype.tooltipFooterHeaderFormatter = function (labelConfig, isFooter) {
  24662. var footOrHead = isFooter ? 'footer' : 'header',
  24663. series = labelConfig.series,
  24664. tooltipOptions = series.tooltipOptions,
  24665. xDateFormat = tooltipOptions.xDateFormat,
  24666. xAxis = series.xAxis,
  24667. isDateTime = (xAxis &&
  24668. xAxis.options.type === 'datetime' &&
  24669. isNumber(labelConfig.key)),
  24670. formatString = tooltipOptions[footOrHead + 'Format'],
  24671. e = {
  24672. isFooter: isFooter,
  24673. labelConfig: labelConfig
  24674. };
  24675. fireEvent(this, 'headerFormatter', e, function (e) {
  24676. // Guess the best date format based on the closest point distance
  24677. // (#568, #3418)
  24678. if (isDateTime && !xDateFormat) {
  24679. xDateFormat = this.getXDateFormat(labelConfig, tooltipOptions, xAxis);
  24680. }
  24681. // Insert the footer date format if any
  24682. if (isDateTime && xDateFormat) {
  24683. ((labelConfig.point && labelConfig.point.tooltipDateKeys) ||
  24684. ['key']).forEach(function (key) {
  24685. formatString = formatString.replace('{point.' + key + '}', '{point.' + key + ':' + xDateFormat + '}');
  24686. });
  24687. }
  24688. // Replace default header style with class name
  24689. if (series.chart.styledMode) {
  24690. formatString = this.styledModeFormat(formatString);
  24691. }
  24692. e.text = format(formatString, {
  24693. point: labelConfig,
  24694. series: series
  24695. }, this.chart);
  24696. });
  24697. return e.text;
  24698. };
  24699. /**
  24700. * Updates the tooltip with the provided tooltip options.
  24701. *
  24702. * @function Highcharts.Tooltip#update
  24703. *
  24704. * @param {Highcharts.TooltipOptions} options
  24705. * The tooltip options to update.
  24706. */
  24707. Tooltip.prototype.update = function (options) {
  24708. this.destroy();
  24709. // Update user options (#6218)
  24710. merge(true, this.chart.options.tooltip.userOptions, options);
  24711. this.init(this.chart, merge(true, this.options, options));
  24712. };
  24713. /**
  24714. * Find the new position and perform the move
  24715. *
  24716. * @private
  24717. * @function Highcharts.Tooltip#updatePosition
  24718. *
  24719. * @param {Highcharts.Point} point
  24720. */
  24721. Tooltip.prototype.updatePosition = function (point) {
  24722. var chart = this.chart,
  24723. pointer = chart.pointer,
  24724. label = this.getLabel(),
  24725. pos,
  24726. anchorX = point.plotX + chart.plotLeft,
  24727. anchorY = point.plotY + chart.plotTop,
  24728. pad;
  24729. // Needed for outside: true (#11688)
  24730. var chartPosition = pointer.getChartPosition();
  24731. pos = (this.options.positioner || this.getPosition).call(this, label.width, label.height, point);
  24732. // Set the renderer size dynamically to prevent document size to change
  24733. if (this.outside) {
  24734. pad = (this.options.borderWidth || 0) + 2 * this.distance;
  24735. this.renderer.setSize(label.width + pad, label.height + pad, false);
  24736. // Anchor and tooltip container need scaling if chart container has
  24737. // scale transform/css zoom. #11329.
  24738. if (chartPosition.scaleX !== 1 || chartPosition.scaleY !== 1) {
  24739. css(this.container, {
  24740. transform: "scale(" + chartPosition.scaleX + ", " + chartPosition.scaleY + ")"
  24741. });
  24742. anchorX *= chartPosition.scaleX;
  24743. anchorY *= chartPosition.scaleY;
  24744. }
  24745. anchorX += chartPosition.left - pos.x;
  24746. anchorY += chartPosition.top - pos.y;
  24747. }
  24748. // do the move
  24749. this.move(Math.round(pos.x), Math.round(pos.y || 0), // can be undefined (#3977)
  24750. anchorX, anchorY);
  24751. };
  24752. return Tooltip;
  24753. }());
  24754. H.Tooltip = Tooltip;
  24755. return H.Tooltip;
  24756. });
  24757. _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) {
  24758. /* *
  24759. *
  24760. * (c) 2010-2021 Torstein Honsi
  24761. *
  24762. * License: www.highcharts.com/license
  24763. *
  24764. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  24765. *
  24766. * */
  24767. var color = Color.parse;
  24768. var charts = H.charts,
  24769. noop = H.noop;
  24770. var addEvent = U.addEvent,
  24771. attr = U.attr,
  24772. css = U.css,
  24773. defined = U.defined,
  24774. extend = U.extend,
  24775. find = U.find,
  24776. fireEvent = U.fireEvent,
  24777. isNumber = U.isNumber,
  24778. isObject = U.isObject,
  24779. objectEach = U.objectEach,
  24780. offset = U.offset,
  24781. pick = U.pick,
  24782. splat = U.splat;
  24783. /* *
  24784. *
  24785. * Class
  24786. *
  24787. * */
  24788. /* eslint-disable no-invalid-this, valid-jsdoc */
  24789. /**
  24790. * The mouse and touch tracker object. Each {@link Chart} item has one
  24791. * assosiated Pointer item that can be accessed from the {@link Chart.pointer}
  24792. * property.
  24793. *
  24794. * @class
  24795. * @name Highcharts.Pointer
  24796. *
  24797. * @param {Highcharts.Chart} chart
  24798. * The chart instance.
  24799. *
  24800. * @param {Highcharts.Options} options
  24801. * The root options object. The pointer uses options from the chart and tooltip
  24802. * structures.
  24803. */
  24804. var Pointer = /** @class */ (function () {
  24805. /* *
  24806. *
  24807. * Constructors
  24808. *
  24809. * */
  24810. function Pointer(chart, options) {
  24811. this.lastValidTouch = {};
  24812. this.pinchDown = [];
  24813. this.runChartClick = false;
  24814. this.eventsToUnbind = [];
  24815. this.chart = chart;
  24816. this.hasDragged = false;
  24817. this.options = options;
  24818. this.init(chart, options);
  24819. }
  24820. /* *
  24821. *
  24822. * Functions
  24823. *
  24824. * */
  24825. /**
  24826. * Set inactive state to all series that are not currently hovered,
  24827. * or, if `inactiveOtherPoints` is set to true, set inactive state to
  24828. * all points within that series.
  24829. *
  24830. * @private
  24831. * @function Highcharts.Pointer#applyInactiveState
  24832. *
  24833. * @param {Array<Highcharts.Point>} points
  24834. * Currently hovered points
  24835. */
  24836. Pointer.prototype.applyInactiveState = function (points) {
  24837. var activeSeries = [],
  24838. series;
  24839. // Get all active series from the hovered points
  24840. (points || []).forEach(function (item) {
  24841. series = item.series;
  24842. // Include itself
  24843. activeSeries.push(series);
  24844. // Include parent series
  24845. if (series.linkedParent) {
  24846. activeSeries.push(series.linkedParent);
  24847. }
  24848. // Include all child series
  24849. if (series.linkedSeries) {
  24850. activeSeries = activeSeries.concat(series.linkedSeries);
  24851. }
  24852. // Include navigator series
  24853. if (series.navigatorSeries) {
  24854. activeSeries.push(series.navigatorSeries);
  24855. }
  24856. });
  24857. // Now loop over all series, filtering out active series
  24858. this.chart.series.forEach(function (inactiveSeries) {
  24859. if (activeSeries.indexOf(inactiveSeries) === -1) {
  24860. // Inactive series
  24861. inactiveSeries.setState('inactive', true);
  24862. }
  24863. else if (inactiveSeries.options.inactiveOtherPoints) {
  24864. // Active series, but other points should be inactivated
  24865. inactiveSeries.setAllPointsToState('inactive');
  24866. }
  24867. });
  24868. };
  24869. /**
  24870. * Destroys the Pointer object and disconnects DOM events.
  24871. *
  24872. * @function Highcharts.Pointer#destroy
  24873. */
  24874. Pointer.prototype.destroy = function () {
  24875. var pointer = this;
  24876. this.eventsToUnbind.forEach(function (unbind) { return unbind(); });
  24877. this.eventsToUnbind = [];
  24878. if (!H.chartCount) {
  24879. if (Pointer.unbindDocumentMouseUp) {
  24880. Pointer.unbindDocumentMouseUp = Pointer.unbindDocumentMouseUp();
  24881. }
  24882. if (Pointer.unbindDocumentTouchEnd) {
  24883. Pointer.unbindDocumentTouchEnd = Pointer.unbindDocumentTouchEnd();
  24884. }
  24885. }
  24886. // memory and CPU leak
  24887. clearInterval(pointer.tooltipTimeout);
  24888. objectEach(pointer, function (_val, prop) {
  24889. pointer[prop] = void 0;
  24890. });
  24891. };
  24892. /**
  24893. * Perform a drag operation in response to a mousemove event while the mouse
  24894. * is down.
  24895. * @private
  24896. * @function Highcharts.Pointer#drag
  24897. */
  24898. Pointer.prototype.drag = function (e) {
  24899. var chart = this.chart,
  24900. chartOptions = chart.options.chart,
  24901. zoomHor = this.zoomHor,
  24902. zoomVert = this.zoomVert,
  24903. plotLeft = chart.plotLeft,
  24904. plotTop = chart.plotTop,
  24905. plotWidth = chart.plotWidth,
  24906. plotHeight = chart.plotHeight,
  24907. mouseDownX = (this.mouseDownX || 0),
  24908. mouseDownY = (this.mouseDownY || 0),
  24909. panningEnabled = isObject(chartOptions.panning) ?
  24910. chartOptions.panning && chartOptions.panning.enabled :
  24911. chartOptions.panning,
  24912. panKey = (chartOptions.panKey && e[chartOptions.panKey + 'Key']);
  24913. var chartX = e.chartX,
  24914. chartY = e.chartY,
  24915. clickedInside,
  24916. size,
  24917. selectionMarker = this.selectionMarker;
  24918. // If the device supports both touch and mouse (like IE11), and we are
  24919. // touch-dragging inside the plot area, don't handle the mouse event.
  24920. // #4339.
  24921. if (selectionMarker && selectionMarker.touch) {
  24922. return;
  24923. }
  24924. // If the mouse is outside the plot area, adjust to cooordinates
  24925. // inside to prevent the selection marker from going outside
  24926. if (chartX < plotLeft) {
  24927. chartX = plotLeft;
  24928. }
  24929. else if (chartX > plotLeft + plotWidth) {
  24930. chartX = plotLeft + plotWidth;
  24931. }
  24932. if (chartY < plotTop) {
  24933. chartY = plotTop;
  24934. }
  24935. else if (chartY > plotTop + plotHeight) {
  24936. chartY = plotTop + plotHeight;
  24937. }
  24938. // determine if the mouse has moved more than 10px
  24939. this.hasDragged = Math.sqrt(Math.pow(mouseDownX - chartX, 2) +
  24940. Math.pow(mouseDownY - chartY, 2));
  24941. if (this.hasDragged > 10) {
  24942. clickedInside = chart.isInsidePlot(mouseDownX - plotLeft, mouseDownY - plotTop, {
  24943. visiblePlotOnly: true
  24944. });
  24945. // make a selection
  24946. if (chart.hasCartesianSeries &&
  24947. (this.zoomX || this.zoomY) &&
  24948. clickedInside &&
  24949. !panKey) {
  24950. if (!selectionMarker) {
  24951. this.selectionMarker = selectionMarker =
  24952. chart.renderer.rect(plotLeft, plotTop, zoomHor ? 1 : plotWidth, zoomVert ? 1 : plotHeight, 0)
  24953. .attr({
  24954. 'class': 'highcharts-selection-marker',
  24955. zIndex: 7
  24956. })
  24957. .add();
  24958. if (!chart.styledMode) {
  24959. selectionMarker.attr({
  24960. fill: (chartOptions.selectionMarkerFill ||
  24961. color(Palette.highlightColor80)
  24962. .setOpacity(0.25).get())
  24963. });
  24964. }
  24965. }
  24966. }
  24967. // adjust the width of the selection marker
  24968. if (selectionMarker && zoomHor) {
  24969. size = chartX - mouseDownX;
  24970. selectionMarker.attr({
  24971. width: Math.abs(size),
  24972. x: (size > 0 ? 0 : size) + mouseDownX
  24973. });
  24974. }
  24975. // adjust the height of the selection marker
  24976. if (selectionMarker && zoomVert) {
  24977. size = chartY - mouseDownY;
  24978. selectionMarker.attr({
  24979. height: Math.abs(size),
  24980. y: (size > 0 ? 0 : size) + mouseDownY
  24981. });
  24982. }
  24983. // panning
  24984. if (clickedInside &&
  24985. !selectionMarker &&
  24986. panningEnabled) {
  24987. chart.pan(e, chartOptions.panning);
  24988. }
  24989. }
  24990. };
  24991. /**
  24992. * Start a drag operation.
  24993. * @private
  24994. * @function Highcharts.Pointer#dragStart
  24995. */
  24996. Pointer.prototype.dragStart = function (e) {
  24997. var chart = this.chart;
  24998. // Record the start position
  24999. chart.mouseIsDown = e.type;
  25000. chart.cancelClick = false;
  25001. chart.mouseDownX = this.mouseDownX = e.chartX;
  25002. chart.mouseDownY = this.mouseDownY = e.chartY;
  25003. };
  25004. /**
  25005. * On mouse up or touch end across the entire document, drop the selection.
  25006. * @private
  25007. * @function Highcharts.Pointer#drop
  25008. */
  25009. Pointer.prototype.drop = function (e) {
  25010. var pointer = this,
  25011. chart = this.chart,
  25012. hasPinched = this.hasPinched;
  25013. if (this.selectionMarker) {
  25014. var selectionData_1 = {
  25015. originalEvent: e,
  25016. xAxis: [],
  25017. yAxis: []
  25018. },
  25019. selectionBox = this.selectionMarker,
  25020. selectionLeft_1 = selectionBox.attr ?
  25021. selectionBox.attr('x') :
  25022. selectionBox.x,
  25023. selectionTop_1 = selectionBox.attr ?
  25024. selectionBox.attr('y') :
  25025. selectionBox.y,
  25026. selectionWidth_1 = selectionBox.attr ?
  25027. selectionBox.attr('width') :
  25028. selectionBox.width,
  25029. selectionHeight_1 = selectionBox.attr ?
  25030. selectionBox.attr('height') :
  25031. selectionBox.height;
  25032. var runZoom_1;
  25033. // a selection has been made
  25034. if (this.hasDragged || hasPinched) {
  25035. // record each axis' min and max
  25036. chart.axes.forEach(function (axis) {
  25037. if (axis.zoomEnabled &&
  25038. defined(axis.min) &&
  25039. (hasPinched ||
  25040. pointer[{
  25041. xAxis: 'zoomX',
  25042. yAxis: 'zoomY'
  25043. }[axis.coll]]) &&
  25044. isNumber(selectionLeft_1) &&
  25045. isNumber(selectionTop_1)) { // #859, #3569
  25046. var horiz = axis.horiz,
  25047. minPixelPadding = e.type === 'touchend' ?
  25048. axis.minPixelPadding :
  25049. 0, // #1207, #3075
  25050. selectionMin = axis.toValue((horiz ? selectionLeft_1 : selectionTop_1) +
  25051. minPixelPadding),
  25052. selectionMax = axis.toValue((horiz ?
  25053. selectionLeft_1 + selectionWidth_1 :
  25054. selectionTop_1 + selectionHeight_1) - minPixelPadding);
  25055. selectionData_1[axis.coll].push({
  25056. axis: axis,
  25057. // Min/max for reversed axes
  25058. min: Math.min(selectionMin, selectionMax),
  25059. max: Math.max(selectionMin, selectionMax)
  25060. });
  25061. runZoom_1 = true;
  25062. }
  25063. });
  25064. if (runZoom_1) {
  25065. fireEvent(chart, 'selection', selectionData_1, function (args) {
  25066. chart.zoom(extend(args, hasPinched ?
  25067. { animation: false } :
  25068. null));
  25069. });
  25070. }
  25071. }
  25072. if (isNumber(chart.index)) {
  25073. this.selectionMarker = this.selectionMarker.destroy();
  25074. }
  25075. // Reset scaling preview
  25076. if (hasPinched) {
  25077. this.scaleGroups();
  25078. }
  25079. }
  25080. // Reset all. Check isNumber because it may be destroyed on mouse up
  25081. // (#877)
  25082. if (chart && isNumber(chart.index)) {
  25083. css(chart.container, { cursor: chart._cursor });
  25084. chart.cancelClick = this.hasDragged > 10; // #370
  25085. chart.mouseIsDown = this.hasDragged = this.hasPinched = false;
  25086. this.pinchDown = [];
  25087. }
  25088. };
  25089. /**
  25090. * Finds the closest point to a set of coordinates, using the k-d-tree
  25091. * algorithm.
  25092. *
  25093. * @function Highcharts.Pointer#findNearestKDPoint
  25094. *
  25095. * @param {Array<Highcharts.Series>} series
  25096. * All the series to search in.
  25097. *
  25098. * @param {boolean|undefined} shared
  25099. * Whether it is a shared tooltip or not.
  25100. *
  25101. * @param {Highcharts.PointerEventObject} e
  25102. * The pointer event object, containing chart coordinates of the pointer.
  25103. *
  25104. * @return {Highcharts.Point|undefined}
  25105. * The point closest to given coordinates.
  25106. */
  25107. Pointer.prototype.findNearestKDPoint = function (series, shared, e) {
  25108. var chart = this.chart;
  25109. var hoverPoint = chart.hoverPoint;
  25110. var tooltip = chart.tooltip;
  25111. if (hoverPoint &&
  25112. tooltip &&
  25113. tooltip.isStickyOnContact()) {
  25114. return hoverPoint;
  25115. }
  25116. var closest;
  25117. /** @private */
  25118. function sort(p1, p2) {
  25119. var isCloserX = p1.distX - p2.distX,
  25120. isCloser = p1.dist - p2.dist,
  25121. isAbove = ((p2.series.group && p2.series.group.zIndex) -
  25122. (p1.series.group && p1.series.group.zIndex));
  25123. var result;
  25124. // We have two points which are not in the same place on xAxis
  25125. // and shared tooltip:
  25126. if (isCloserX !== 0 && shared) { // #5721
  25127. result = isCloserX;
  25128. // Points are not exactly in the same place on x/yAxis:
  25129. }
  25130. else if (isCloser !== 0) {
  25131. result = isCloser;
  25132. // The same xAxis and yAxis position, sort by z-index:
  25133. }
  25134. else if (isAbove !== 0) {
  25135. result = isAbove;
  25136. // The same zIndex, sort by array index:
  25137. }
  25138. else {
  25139. result =
  25140. p1.series.index > p2.series.index ?
  25141. -1 :
  25142. 1;
  25143. }
  25144. return result;
  25145. }
  25146. series.forEach(function (s) {
  25147. var noSharedTooltip = s.noSharedTooltip && shared,
  25148. compareX = (!noSharedTooltip &&
  25149. s.options.findNearestPointBy.indexOf('y') < 0),
  25150. point = s.searchPoint(e,
  25151. compareX);
  25152. if ( // Check that we actually found a point on the series.
  25153. isObject(point, true) && point.series &&
  25154. // Use the new point if it is closer.
  25155. (!isObject(closest, true) ||
  25156. (sort(closest, point) > 0))) {
  25157. closest = point;
  25158. }
  25159. });
  25160. return closest;
  25161. };
  25162. /**
  25163. * @private
  25164. * @function Highcharts.Pointer#getChartCoordinatesFromPoint
  25165. */
  25166. Pointer.prototype.getChartCoordinatesFromPoint = function (point, inverted) {
  25167. var series = point.series,
  25168. xAxis = series.xAxis,
  25169. yAxis = series.yAxis,
  25170. shapeArgs = point.shapeArgs;
  25171. if (xAxis && yAxis) {
  25172. var x = pick(point.clientX,
  25173. point.plotX);
  25174. var y = point.plotY || 0;
  25175. if (point.isNode &&
  25176. shapeArgs &&
  25177. isNumber(shapeArgs.x) &&
  25178. isNumber(shapeArgs.y)) {
  25179. x = shapeArgs.x;
  25180. y = shapeArgs.y;
  25181. }
  25182. return inverted ? {
  25183. chartX: yAxis.len + yAxis.pos - y,
  25184. chartY: xAxis.len + xAxis.pos - x
  25185. } : {
  25186. chartX: x + xAxis.pos,
  25187. chartY: y + yAxis.pos
  25188. };
  25189. }
  25190. if (shapeArgs && shapeArgs.x && shapeArgs.y) {
  25191. // E.g. pies do not have axes
  25192. return {
  25193. chartX: shapeArgs.x,
  25194. chartY: shapeArgs.y
  25195. };
  25196. }
  25197. };
  25198. /**
  25199. * Return the cached chartPosition if it is available on the Pointer,
  25200. * otherwise find it. Running offset is quite expensive, so it should be
  25201. * avoided when we know the chart hasn't moved.
  25202. *
  25203. * @function Highcharts.Pointer#getChartPosition
  25204. *
  25205. * @return {Highcharts.ChartPositionObject}
  25206. * The offset of the chart container within the page
  25207. */
  25208. Pointer.prototype.getChartPosition = function () {
  25209. if (this.chartPosition) {
  25210. return this.chartPosition;
  25211. }
  25212. var container = this.chart.container;
  25213. var pos = offset(container);
  25214. this.chartPosition = {
  25215. left: pos.left,
  25216. top: pos.top,
  25217. scaleX: 1,
  25218. scaleY: 1
  25219. };
  25220. var offsetWidth = container.offsetWidth;
  25221. var offsetHeight = container.offsetHeight;
  25222. // #13342 - tooltip was not visible in Chrome, when chart
  25223. // updates height.
  25224. if (offsetWidth > 2 && // #13342
  25225. offsetHeight > 2 // #13342
  25226. ) {
  25227. this.chartPosition.scaleX = pos.width / offsetWidth;
  25228. this.chartPosition.scaleY = pos.height / offsetHeight;
  25229. }
  25230. return this.chartPosition;
  25231. };
  25232. /**
  25233. * Get the click position in terms of axis values.
  25234. *
  25235. * @function Highcharts.Pointer#getCoordinates
  25236. *
  25237. * @param {Highcharts.PointerEventObject} e
  25238. * Pointer event, extended with `chartX` and `chartY` properties.
  25239. *
  25240. * @return {Highcharts.PointerAxisCoordinatesObject}
  25241. */
  25242. Pointer.prototype.getCoordinates = function (e) {
  25243. var coordinates = {
  25244. xAxis: [],
  25245. yAxis: []
  25246. };
  25247. this.chart.axes.forEach(function (axis) {
  25248. coordinates[axis.isXAxis ? 'xAxis' : 'yAxis'].push({
  25249. axis: axis,
  25250. value: axis.toValue(e[axis.horiz ? 'chartX' : 'chartY'])
  25251. });
  25252. });
  25253. return coordinates;
  25254. };
  25255. /**
  25256. * Calculates what is the current hovered point/points and series.
  25257. *
  25258. * @private
  25259. * @function Highcharts.Pointer#getHoverData
  25260. *
  25261. * @param {Highcharts.Point|undefined} existingHoverPoint
  25262. * The point currrently beeing hovered.
  25263. *
  25264. * @param {Highcharts.Series|undefined} existingHoverSeries
  25265. * The series currently beeing hovered.
  25266. *
  25267. * @param {Array<Highcharts.Series>} series
  25268. * All the series in the chart.
  25269. *
  25270. * @param {boolean} isDirectTouch
  25271. * Is the pointer directly hovering the point.
  25272. *
  25273. * @param {boolean|undefined} shared
  25274. * Whether it is a shared tooltip or not.
  25275. *
  25276. * @param {Highcharts.PointerEventObject} [e]
  25277. * The triggering event, containing chart coordinates of the pointer.
  25278. *
  25279. * @return {object}
  25280. * Object containing resulting hover data: hoverPoint, hoverSeries, and
  25281. * hoverPoints.
  25282. */
  25283. Pointer.prototype.getHoverData = function (existingHoverPoint, existingHoverSeries, series, isDirectTouch, shared, e) {
  25284. var hoverPoints = [],
  25285. useExisting = !!(isDirectTouch && existingHoverPoint),
  25286. filter = function (s) {
  25287. return (s.visible &&
  25288. !(!shared && s.directTouch) && // #3821
  25289. pick(s.options.enableMouseTracking,
  25290. true));
  25291. };
  25292. var hoverSeries = existingHoverSeries,
  25293. // Which series to look in for the hover point
  25294. searchSeries,
  25295. // Parameters needed for beforeGetHoverData event.
  25296. eventArgs = {
  25297. chartX: e ? e.chartX : void 0,
  25298. chartY: e ? e.chartY : void 0,
  25299. shared: shared
  25300. };
  25301. // Find chart.hoverPane and update filter method in polar.
  25302. fireEvent(this, 'beforeGetHoverData', eventArgs);
  25303. var notSticky = hoverSeries && !hoverSeries.stickyTracking;
  25304. searchSeries = notSticky ?
  25305. // Only search on hovered series if it has stickyTracking false
  25306. [hoverSeries] :
  25307. // Filter what series to look in.
  25308. series.filter(function (s) {
  25309. return eventArgs.filter ? eventArgs.filter(s) : filter(s) &&
  25310. s.stickyTracking;
  25311. });
  25312. // Use existing hovered point or find the one closest to coordinates.
  25313. var hoverPoint = useExisting || !e ?
  25314. existingHoverPoint :
  25315. this.findNearestKDPoint(searchSeries,
  25316. shared,
  25317. e);
  25318. // Assign hover series
  25319. hoverSeries = hoverPoint && hoverPoint.series;
  25320. // If we have a hoverPoint, assign hoverPoints.
  25321. if (hoverPoint) {
  25322. // When tooltip is shared, it displays more than one point
  25323. if (shared && !hoverSeries.noSharedTooltip) {
  25324. searchSeries = series.filter(function (s) {
  25325. return eventArgs.filter ?
  25326. eventArgs.filter(s) : filter(s) && !s.noSharedTooltip;
  25327. });
  25328. // Get all points with the same x value as the hoverPoint
  25329. searchSeries.forEach(function (s) {
  25330. var point = find(s.points,
  25331. function (p) {
  25332. return p.x === hoverPoint.x && !p.isNull;
  25333. });
  25334. if (isObject(point)) {
  25335. /*
  25336. * Boost returns a minimal point. Convert it to a usable
  25337. * point for tooltip and states.
  25338. */
  25339. if (s.chart.isBoosting) {
  25340. point = s.getPoint(point);
  25341. }
  25342. hoverPoints.push(point);
  25343. }
  25344. });
  25345. }
  25346. else {
  25347. hoverPoints.push(hoverPoint);
  25348. }
  25349. }
  25350. // Check whether the hoverPoint is inside pane we are hovering over.
  25351. eventArgs = { hoverPoint: hoverPoint };
  25352. fireEvent(this, 'afterGetHoverData', eventArgs);
  25353. return {
  25354. hoverPoint: eventArgs.hoverPoint,
  25355. hoverSeries: hoverSeries,
  25356. hoverPoints: hoverPoints
  25357. };
  25358. };
  25359. /**
  25360. * @private
  25361. * @function Highcharts.Pointer#getPointFromEvent
  25362. */
  25363. Pointer.prototype.getPointFromEvent = function (e) {
  25364. var target = e.target,
  25365. point;
  25366. while (target && !point) {
  25367. point = target.point;
  25368. target = target.parentNode;
  25369. }
  25370. return point;
  25371. };
  25372. /**
  25373. * @private
  25374. * @function Highcharts.Pointer#onTrackerMouseOut
  25375. */
  25376. Pointer.prototype.onTrackerMouseOut = function (e) {
  25377. var chart = this.chart;
  25378. var relatedTarget = e.relatedTarget || e.toElement;
  25379. var series = chart.hoverSeries;
  25380. this.isDirectTouch = false;
  25381. if (series &&
  25382. relatedTarget &&
  25383. !series.stickyTracking &&
  25384. !this.inClass(relatedTarget, 'highcharts-tooltip') &&
  25385. (!this.inClass(relatedTarget, 'highcharts-series-' + series.index) || // #2499, #4465, #5553
  25386. !this.inClass(relatedTarget, 'highcharts-tracker'))) {
  25387. series.onMouseOut();
  25388. }
  25389. };
  25390. /**
  25391. * Utility to detect whether an element has, or has a parent with, a
  25392. * specificclass name. Used on detection of tracker objects and on deciding
  25393. * whether hovering the tooltip should cause the active series to mouse out.
  25394. *
  25395. * @function Highcharts.Pointer#inClass
  25396. *
  25397. * @param {Highcharts.SVGDOMElement|Highcharts.HTMLDOMElement} element
  25398. * The element to investigate.
  25399. *
  25400. * @param {string} className
  25401. * The class name to look for.
  25402. *
  25403. * @return {boolean|undefined}
  25404. * True if either the element or one of its parents has the given class
  25405. * name.
  25406. */
  25407. Pointer.prototype.inClass = function (element, className) {
  25408. var elemClassName;
  25409. while (element) {
  25410. elemClassName = attr(element, 'class');
  25411. if (elemClassName) {
  25412. if (elemClassName.indexOf(className) !== -1) {
  25413. return true;
  25414. }
  25415. if (elemClassName.indexOf('highcharts-container') !== -1) {
  25416. return false;
  25417. }
  25418. }
  25419. element = element.parentNode;
  25420. }
  25421. };
  25422. /**
  25423. * Initialize the Pointer.
  25424. *
  25425. * @private
  25426. * @function Highcharts.Pointer#init
  25427. *
  25428. * @param {Highcharts.Chart} chart
  25429. * The Chart instance.
  25430. *
  25431. * @param {Highcharts.Options} options
  25432. * The root options object. The pointer uses options from the chart and
  25433. * tooltip structures.
  25434. */
  25435. Pointer.prototype.init = function (chart, options) {
  25436. // Store references
  25437. this.options = options;
  25438. this.chart = chart;
  25439. // Do we need to handle click on a touch device?
  25440. this.runChartClick = Boolean(options.chart.events && options.chart.events.click);
  25441. this.pinchDown = [];
  25442. this.lastValidTouch = {};
  25443. if (Tooltip) {
  25444. /**
  25445. * Tooltip object for points of series.
  25446. *
  25447. * @name Highcharts.Chart#tooltip
  25448. * @type {Highcharts.Tooltip}
  25449. */
  25450. chart.tooltip = new Tooltip(chart, options.tooltip);
  25451. this.followTouchMove = pick(options.tooltip.followTouchMove, true);
  25452. }
  25453. this.setDOMEvents();
  25454. };
  25455. /**
  25456. * Takes a browser event object and extends it with custom Highcharts
  25457. * properties `chartX` and `chartY` in order to work on the internal
  25458. * coordinate system.
  25459. *
  25460. * @function Highcharts.Pointer#normalize
  25461. *
  25462. * @param {global.MouseEvent|global.PointerEvent|global.TouchEvent} e
  25463. * Event object in standard browsers.
  25464. *
  25465. * @param {Highcharts.OffsetObject} [chartPosition]
  25466. * Additional chart offset.
  25467. *
  25468. * @return {Highcharts.PointerEventObject}
  25469. * A browser event with extended properties `chartX` and `chartY`.
  25470. */
  25471. Pointer.prototype.normalize = function (e, chartPosition) {
  25472. var touches = e.touches;
  25473. // iOS (#2757)
  25474. var ePos = (touches ?
  25475. touches.length ?
  25476. touches.item(0) :
  25477. (pick(// #13534
  25478. touches.changedTouches,
  25479. e.changedTouches))[0] :
  25480. e);
  25481. // Get mouse position
  25482. if (!chartPosition) {
  25483. chartPosition = this.getChartPosition();
  25484. }
  25485. var chartX = ePos.pageX - chartPosition.left,
  25486. chartY = ePos.pageY - chartPosition.top;
  25487. // #11329 - when there is scaling on a parent element, we need to take
  25488. // this into account
  25489. chartX /= chartPosition.scaleX;
  25490. chartY /= chartPosition.scaleY;
  25491. return extend(e, {
  25492. chartX: Math.round(chartX),
  25493. chartY: Math.round(chartY)
  25494. });
  25495. };
  25496. /**
  25497. * @private
  25498. * @function Highcharts.Pointer#onContainerClick
  25499. */
  25500. Pointer.prototype.onContainerClick = function (e) {
  25501. var chart = this.chart;
  25502. var hoverPoint = chart.hoverPoint;
  25503. var pEvt = this.normalize(e);
  25504. var plotLeft = chart.plotLeft;
  25505. var plotTop = chart.plotTop;
  25506. if (!chart.cancelClick) {
  25507. // On tracker click, fire the series and point events. #783, #1583
  25508. if (hoverPoint &&
  25509. this.inClass(pEvt.target, 'highcharts-tracker')) {
  25510. // the series click event
  25511. fireEvent(hoverPoint.series, 'click', extend(pEvt, {
  25512. point: hoverPoint
  25513. }));
  25514. // the point click event
  25515. if (chart.hoverPoint) { // it may be destroyed (#1844)
  25516. hoverPoint.firePointEvent('click', pEvt);
  25517. }
  25518. // When clicking outside a tracker, fire a chart event
  25519. }
  25520. else {
  25521. extend(pEvt, this.getCoordinates(pEvt));
  25522. // fire a click event in the chart
  25523. if (chart.isInsidePlot(pEvt.chartX - plotLeft, pEvt.chartY - plotTop, {
  25524. visiblePlotOnly: true
  25525. })) {
  25526. fireEvent(chart, 'click', pEvt);
  25527. }
  25528. }
  25529. }
  25530. };
  25531. /**
  25532. * @private
  25533. * @function Highcharts.Pointer#onContainerMouseDown
  25534. */
  25535. Pointer.prototype.onContainerMouseDown = function (e) {
  25536. var isPrimaryButton = ((e.buttons || e.button) & 1) === 1;
  25537. // Normalize before the 'if' for the legacy IE (#7850)
  25538. e = this.normalize(e);
  25539. // #11635, Firefox does not reliable fire move event after click scroll
  25540. if (H.isFirefox &&
  25541. e.button !== 0) {
  25542. this.onContainerMouseMove(e);
  25543. }
  25544. // #11635, limiting to primary button (incl. IE 8 support)
  25545. if (typeof e.button === 'undefined' ||
  25546. isPrimaryButton) {
  25547. this.zoomOption(e);
  25548. // #295, #13737 solve conflict between container drag and chart zoom
  25549. if (isPrimaryButton &&
  25550. e.preventDefault) {
  25551. e.preventDefault();
  25552. }
  25553. this.dragStart(e);
  25554. }
  25555. };
  25556. /**
  25557. * When mouse leaves the container, hide the tooltip.
  25558. * @private
  25559. * @function Highcharts.Pointer#onContainerMouseLeave
  25560. */
  25561. Pointer.prototype.onContainerMouseLeave = function (e) {
  25562. var chart = charts[pick(Pointer.hoverChartIndex, -1)];
  25563. var tooltip = this.chart.tooltip;
  25564. e = this.normalize(e);
  25565. // #4886, MS Touch end fires mouseleave but with no related target
  25566. if (chart &&
  25567. (e.relatedTarget || e.toElement)) {
  25568. chart.pointer.reset();
  25569. // Also reset the chart position, used in #149 fix
  25570. chart.pointer.chartPosition = void 0;
  25571. }
  25572. if ( // #11635, Firefox wheel scroll does not fire out events consistently
  25573. tooltip &&
  25574. !tooltip.isHidden) {
  25575. this.reset();
  25576. }
  25577. };
  25578. /**
  25579. * When mouse enters the container, delete pointer's chartPosition.
  25580. * @private
  25581. * @function Highcharts.Pointer#onContainerMouseEnter
  25582. */
  25583. Pointer.prototype.onContainerMouseEnter = function (e) {
  25584. delete this.chartPosition;
  25585. };
  25586. /**
  25587. * The mousemove, touchmove and touchstart event handler
  25588. * @private
  25589. * @function Highcharts.Pointer#onContainerMouseMove
  25590. */
  25591. Pointer.prototype.onContainerMouseMove = function (e) {
  25592. var chart = this.chart;
  25593. var pEvt = this.normalize(e);
  25594. this.setHoverChartIndex();
  25595. // In IE8 we apparently need this returnValue set to false in order to
  25596. // avoid text being selected. But in Chrome, e.returnValue is prevented,
  25597. // plus we don't need to run e.preventDefault to prevent selected text
  25598. // in modern browsers. So we set it conditionally. Remove it when IE8 is
  25599. // no longer needed. #2251, #3224.
  25600. if (!pEvt.preventDefault) {
  25601. pEvt.returnValue = false;
  25602. }
  25603. if (chart.mouseIsDown === 'mousedown' || this.touchSelect(pEvt)) {
  25604. this.drag(pEvt);
  25605. }
  25606. // Show the tooltip and run mouse over events (#977)
  25607. if (!chart.openMenu &&
  25608. (this.inClass(pEvt.target, 'highcharts-tracker') ||
  25609. chart.isInsidePlot(pEvt.chartX - chart.plotLeft, pEvt.chartY - chart.plotTop, {
  25610. visiblePlotOnly: true
  25611. }))) {
  25612. if (this.inClass(pEvt.target, 'highcharts-no-tooltip')) {
  25613. this.reset(false, 0);
  25614. }
  25615. else {
  25616. this.runPointActions(pEvt);
  25617. }
  25618. }
  25619. };
  25620. /**
  25621. * @private
  25622. * @function Highcharts.Pointer#onDocumentTouchEnd
  25623. */
  25624. Pointer.prototype.onDocumentTouchEnd = function (e) {
  25625. var hoverChart = charts[pick(Pointer.hoverChartIndex, -1)];
  25626. if (hoverChart) {
  25627. hoverChart.pointer.drop(e);
  25628. }
  25629. };
  25630. /**
  25631. * @private
  25632. * @function Highcharts.Pointer#onContainerTouchMove
  25633. */
  25634. Pointer.prototype.onContainerTouchMove = function (e) {
  25635. if (this.touchSelect(e)) {
  25636. this.onContainerMouseMove(e);
  25637. }
  25638. else {
  25639. this.touch(e);
  25640. }
  25641. };
  25642. /**
  25643. * @private
  25644. * @function Highcharts.Pointer#onContainerTouchStart
  25645. */
  25646. Pointer.prototype.onContainerTouchStart = function (e) {
  25647. if (this.touchSelect(e)) {
  25648. this.onContainerMouseDown(e);
  25649. }
  25650. else {
  25651. this.zoomOption(e);
  25652. this.touch(e, true);
  25653. }
  25654. };
  25655. /**
  25656. * Special handler for mouse move that will hide the tooltip when the mouse
  25657. * leaves the plotarea. Issue #149 workaround. The mouseleave event does not
  25658. * always fire.
  25659. * @private
  25660. * @function Highcharts.Pointer#onDocumentMouseMove
  25661. */
  25662. Pointer.prototype.onDocumentMouseMove = function (e) {
  25663. var chart = this.chart;
  25664. var chartPosition = this.chartPosition;
  25665. var pEvt = this.normalize(e,
  25666. chartPosition);
  25667. var tooltip = chart.tooltip;
  25668. // If we're outside, hide the tooltip
  25669. if (chartPosition &&
  25670. (!tooltip ||
  25671. !tooltip.isStickyOnContact()) &&
  25672. !chart.isInsidePlot(pEvt.chartX - chart.plotLeft, pEvt.chartY - chart.plotTop, {
  25673. visiblePlotOnly: true
  25674. }) &&
  25675. !this.inClass(pEvt.target, 'highcharts-tracker')) {
  25676. this.reset();
  25677. }
  25678. };
  25679. /**
  25680. * @private
  25681. * @function Highcharts.Pointer#onDocumentMouseUp
  25682. */
  25683. Pointer.prototype.onDocumentMouseUp = function (e) {
  25684. var chart = charts[pick(Pointer.hoverChartIndex, -1)];
  25685. if (chart) {
  25686. chart.pointer.drop(e);
  25687. }
  25688. };
  25689. /**
  25690. * Handle touch events with two touches
  25691. * @private
  25692. * @function Highcharts.Pointer#pinch
  25693. */
  25694. Pointer.prototype.pinch = function (e) {
  25695. var self = this,
  25696. chart = self.chart,
  25697. pinchDown = self.pinchDown,
  25698. touches = (e.touches || []),
  25699. touchesLength = touches.length,
  25700. lastValidTouch = self.lastValidTouch,
  25701. hasZoom = self.hasZoom,
  25702. transform = {},
  25703. fireClickEvent = touchesLength === 1 && ((self.inClass(e.target, 'highcharts-tracker') &&
  25704. chart.runTrackerClick) ||
  25705. self.runChartClick),
  25706. clip = {};
  25707. var selectionMarker = self.selectionMarker;
  25708. // Don't initiate panning until the user has pinched. This prevents us
  25709. // from blocking page scrolling as users scroll down a long page
  25710. // (#4210).
  25711. if (touchesLength > 1) {
  25712. self.initiated = true;
  25713. }
  25714. // On touch devices, only proceed to trigger click if a handler is
  25715. // defined
  25716. if (hasZoom && self.initiated && !fireClickEvent && e.cancelable !== false) {
  25717. e.preventDefault();
  25718. }
  25719. // Normalize each touch
  25720. [].map.call(touches, function (e) {
  25721. return self.normalize(e);
  25722. });
  25723. // Register the touch start position
  25724. if (e.type === 'touchstart') {
  25725. [].forEach.call(touches, function (e, i) {
  25726. pinchDown[i] = { chartX: e.chartX, chartY: e.chartY };
  25727. });
  25728. lastValidTouch.x = [pinchDown[0].chartX, pinchDown[1] &&
  25729. pinchDown[1].chartX];
  25730. lastValidTouch.y = [pinchDown[0].chartY, pinchDown[1] &&
  25731. pinchDown[1].chartY];
  25732. // Identify the data bounds in pixels
  25733. chart.axes.forEach(function (axis) {
  25734. if (axis.zoomEnabled) {
  25735. var bounds = chart.bounds[axis.horiz ? 'h' : 'v'],
  25736. minPixelPadding = axis.minPixelPadding,
  25737. min = axis.toPixels(Math.min(pick(axis.options.min,
  25738. axis.dataMin),
  25739. axis.dataMin)),
  25740. max = axis.toPixels(Math.max(pick(axis.options.max,
  25741. axis.dataMax),
  25742. axis.dataMax)),
  25743. absMin = Math.min(min,
  25744. max),
  25745. absMax = Math.max(min,
  25746. max);
  25747. // Store the bounds for use in the touchmove handler
  25748. bounds.min = Math.min(axis.pos, absMin - minPixelPadding);
  25749. bounds.max = Math.max(axis.pos + axis.len, absMax + minPixelPadding);
  25750. }
  25751. });
  25752. self.res = true; // reset on next move
  25753. // Optionally move the tooltip on touchmove
  25754. }
  25755. else if (self.followTouchMove && touchesLength === 1) {
  25756. this.runPointActions(self.normalize(e));
  25757. // Event type is touchmove, handle panning and pinching
  25758. }
  25759. else if (pinchDown.length) { // can be 0 when releasing, if touchend
  25760. // fires first
  25761. // Set the marker
  25762. if (!selectionMarker) {
  25763. // @todo It's a mock object, so maybe we need a separate
  25764. // interface
  25765. self.selectionMarker = selectionMarker = extend({
  25766. destroy: noop,
  25767. touch: true
  25768. }, chart.plotBox);
  25769. }
  25770. self.pinchTranslate(pinchDown, touches, transform, selectionMarker, clip, lastValidTouch);
  25771. self.hasPinched = hasZoom;
  25772. // Scale and translate the groups to provide visual feedback during
  25773. // pinching
  25774. self.scaleGroups(transform, clip);
  25775. if (self.res) {
  25776. self.res = false;
  25777. this.reset(false, 0);
  25778. }
  25779. }
  25780. };
  25781. /**
  25782. * Run translation operations
  25783. * @private
  25784. * @function Highcharts.Pointer#pinchTranslate
  25785. */
  25786. Pointer.prototype.pinchTranslate = function (pinchDown, touches, transform, selectionMarker, clip, lastValidTouch) {
  25787. if (this.zoomHor) {
  25788. this.pinchTranslateDirection(true, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch);
  25789. }
  25790. if (this.zoomVert) {
  25791. this.pinchTranslateDirection(false, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch);
  25792. }
  25793. };
  25794. /**
  25795. * Run translation operations for each direction (horizontal and vertical)
  25796. * independently.
  25797. * @private
  25798. * @function Highcharts.Pointer#pinchTranslateDirection
  25799. */
  25800. Pointer.prototype.pinchTranslateDirection = function (horiz, pinchDown, touches, transform, selectionMarker, clip, lastValidTouch, forcedScale) {
  25801. 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')], inverted = chart.inverted, bounds = chart.bounds[horiz ? 'h' : 'v'], singleTouch = pinchDown.length === 1, touch0Start = pinchDown[0][sChartXY], touch1Start = !singleTouch && pinchDown[1][sChartXY], setScale = function () {
  25802. // Don't zoom if fingers are too close on this axis
  25803. if (typeof touch1Now === 'number' &&
  25804. Math.abs(touch0Start - touch1Start) > 20) {
  25805. scale = forcedScale ||
  25806. Math.abs(touch0Now - touch1Now) /
  25807. Math.abs(touch0Start - touch1Start);
  25808. }
  25809. clipXY = ((plotLeftTop - touch0Now) / scale) + touch0Start;
  25810. selectionWH = chart['plot' + (horiz ? 'Width' : 'Height')] / scale;
  25811. };
  25812. var selectionWH,
  25813. selectionXY,
  25814. clipXY,
  25815. scale = forcedScale || 1,
  25816. touch0Now = touches[0][sChartXY],
  25817. touch1Now = !singleTouch && touches[1][sChartXY],
  25818. outOfBounds;
  25819. // Set the scale, first pass
  25820. setScale();
  25821. // The clip position (x or y) is altered if out of bounds, the selection
  25822. // position is not
  25823. selectionXY = clipXY;
  25824. // Out of bounds
  25825. if (selectionXY < bounds.min) {
  25826. selectionXY = bounds.min;
  25827. outOfBounds = true;
  25828. }
  25829. else if (selectionXY + selectionWH > bounds.max) {
  25830. selectionXY = bounds.max - selectionWH;
  25831. outOfBounds = true;
  25832. }
  25833. // Is the chart dragged off its bounds, determined by dataMin and
  25834. // dataMax?
  25835. if (outOfBounds) {
  25836. // Modify the touchNow position in order to create an elastic drag
  25837. // movement. This indicates to the user that the chart is responsive
  25838. // but can't be dragged further.
  25839. touch0Now -= 0.8 * (touch0Now - lastValidTouch[xy][0]);
  25840. if (typeof touch1Now === 'number') {
  25841. touch1Now -= 0.8 * (touch1Now - lastValidTouch[xy][1]);
  25842. }
  25843. // Set the scale, second pass to adapt to the modified touchNow
  25844. // positions
  25845. setScale();
  25846. }
  25847. else {
  25848. lastValidTouch[xy] = [touch0Now, touch1Now];
  25849. }
  25850. // Set geometry for clipping, selection and transformation
  25851. if (!inverted) {
  25852. clip[xy] = clipXY - plotLeftTop;
  25853. clip[wh] = selectionWH;
  25854. }
  25855. var scaleKey = inverted ? (horiz ? 'scaleY' : 'scaleX') : 'scale' + XY;
  25856. var transformScale = inverted ? 1 / scale : scale;
  25857. selectionMarker[wh] = selectionWH;
  25858. selectionMarker[xy] = selectionXY;
  25859. transform[scaleKey] = scale;
  25860. transform['translate' + XY] = (transformScale * plotLeftTop) +
  25861. (touch0Now - (transformScale * touch0Start));
  25862. };
  25863. /**
  25864. * Reset the tracking by hiding the tooltip, the hover series state and the
  25865. * hover point
  25866. *
  25867. * @function Highcharts.Pointer#reset
  25868. *
  25869. * @param {boolean} [allowMove]
  25870. * Instead of destroying the tooltip altogether, allow moving it if
  25871. * possible.
  25872. *
  25873. * @param {number} [delay]
  25874. */
  25875. Pointer.prototype.reset = function (allowMove, delay) {
  25876. var pointer = this,
  25877. chart = pointer.chart,
  25878. hoverSeries = chart.hoverSeries,
  25879. hoverPoint = chart.hoverPoint,
  25880. hoverPoints = chart.hoverPoints,
  25881. tooltip = chart.tooltip,
  25882. tooltipPoints = tooltip && tooltip.shared ?
  25883. hoverPoints :
  25884. hoverPoint;
  25885. // Check if the points have moved outside the plot area (#1003, #4736,
  25886. // #5101)
  25887. if (allowMove && tooltipPoints) {
  25888. splat(tooltipPoints).forEach(function (point) {
  25889. if (point.series.isCartesian &&
  25890. typeof point.plotX === 'undefined') {
  25891. allowMove = false;
  25892. }
  25893. });
  25894. }
  25895. // Just move the tooltip, #349
  25896. if (allowMove) {
  25897. if (tooltip && tooltipPoints && splat(tooltipPoints).length) {
  25898. tooltip.refresh(tooltipPoints);
  25899. if (tooltip.shared && hoverPoints) { // #8284
  25900. hoverPoints.forEach(function (point) {
  25901. point.setState(point.state, true);
  25902. if (point.series.isCartesian) {
  25903. if (point.series.xAxis.crosshair) {
  25904. point.series.xAxis
  25905. .drawCrosshair(null, point);
  25906. }
  25907. if (point.series.yAxis.crosshair) {
  25908. point.series.yAxis
  25909. .drawCrosshair(null, point);
  25910. }
  25911. }
  25912. });
  25913. }
  25914. else if (hoverPoint) { // #2500
  25915. hoverPoint.setState(hoverPoint.state, true);
  25916. chart.axes.forEach(function (axis) {
  25917. if (axis.crosshair &&
  25918. hoverPoint.series[axis.coll] === axis) {
  25919. axis.drawCrosshair(null, hoverPoint);
  25920. }
  25921. });
  25922. }
  25923. }
  25924. // Full reset
  25925. }
  25926. else {
  25927. if (hoverPoint) {
  25928. hoverPoint.onMouseOut();
  25929. }
  25930. if (hoverPoints) {
  25931. hoverPoints.forEach(function (point) {
  25932. point.setState();
  25933. });
  25934. }
  25935. if (hoverSeries) {
  25936. hoverSeries.onMouseOut();
  25937. }
  25938. if (tooltip) {
  25939. tooltip.hide(delay);
  25940. }
  25941. if (pointer.unDocMouseMove) {
  25942. pointer.unDocMouseMove = pointer.unDocMouseMove();
  25943. }
  25944. // Remove crosshairs
  25945. chart.axes.forEach(function (axis) {
  25946. axis.hideCrosshair();
  25947. });
  25948. pointer.hoverX = chart.hoverPoints = chart.hoverPoint = null;
  25949. }
  25950. };
  25951. /**
  25952. * With line type charts with a single tracker, get the point closest to the
  25953. * mouse. Run Point.onMouseOver and display tooltip for the point or points.
  25954. *
  25955. * @private
  25956. * @function Highcharts.Pointer#runPointActions
  25957. *
  25958. * @fires Highcharts.Point#event:mouseOut
  25959. * @fires Highcharts.Point#event:mouseOver
  25960. */
  25961. Pointer.prototype.runPointActions = function (e, p) {
  25962. var pointer = this,
  25963. chart = pointer.chart,
  25964. series = chart.series,
  25965. tooltip = (chart.tooltip && chart.tooltip.options.enabled ?
  25966. chart.tooltip :
  25967. void 0),
  25968. shared = (tooltip ?
  25969. tooltip.shared :
  25970. false);
  25971. var hoverPoint = p || chart.hoverPoint,
  25972. hoverSeries = hoverPoint && hoverPoint.series || chart.hoverSeries;
  25973. var // onMouseOver or already hovering a series with directTouch
  25974. isDirectTouch = (!e || e.type !== 'touchmove') && (!!p || ((hoverSeries && hoverSeries.directTouch) &&
  25975. pointer.isDirectTouch)),
  25976. hoverData = this.getHoverData(hoverPoint,
  25977. hoverSeries,
  25978. series,
  25979. isDirectTouch,
  25980. shared,
  25981. e);
  25982. // Update variables from hoverData.
  25983. hoverPoint = hoverData.hoverPoint;
  25984. hoverSeries = hoverData.hoverSeries;
  25985. var points = hoverData.hoverPoints,
  25986. followPointer = hoverSeries &&
  25987. hoverSeries.tooltipOptions.followPointer &&
  25988. !hoverSeries.tooltipOptions.split,
  25989. useSharedTooltip = (shared &&
  25990. hoverSeries &&
  25991. !hoverSeries.noSharedTooltip);
  25992. // Refresh tooltip for kdpoint if new hover point or tooltip was hidden
  25993. // #3926, #4200
  25994. if (hoverPoint &&
  25995. // !(hoverSeries && hoverSeries.directTouch) &&
  25996. (hoverPoint !== chart.hoverPoint || (tooltip && tooltip.isHidden))) {
  25997. (chart.hoverPoints || []).forEach(function (p) {
  25998. if (points.indexOf(p) === -1) {
  25999. p.setState();
  26000. }
  26001. });
  26002. // Set normal state to previous series
  26003. if (chart.hoverSeries !== hoverSeries) {
  26004. hoverSeries.onMouseOver();
  26005. }
  26006. pointer.applyInactiveState(points);
  26007. // Do mouseover on all points (#3919, #3985, #4410, #5622)
  26008. (points || []).forEach(function (p) {
  26009. p.setState('hover');
  26010. });
  26011. // If tracking is on series in stead of on each point,
  26012. // fire mouseOver on hover point. // #4448
  26013. if (chart.hoverPoint) {
  26014. chart.hoverPoint.firePointEvent('mouseOut');
  26015. }
  26016. // Hover point may have been destroyed in the event handlers (#7127)
  26017. if (!hoverPoint.series) {
  26018. return;
  26019. }
  26020. /**
  26021. * Contains all hovered points.
  26022. *
  26023. * @name Highcharts.Chart#hoverPoints
  26024. * @type {Array<Highcharts.Point>|null}
  26025. */
  26026. chart.hoverPoints = points;
  26027. /**
  26028. * Contains the original hovered point.
  26029. *
  26030. * @name Highcharts.Chart#hoverPoint
  26031. * @type {Highcharts.Point|null}
  26032. */
  26033. chart.hoverPoint = hoverPoint;
  26034. /**
  26035. * Hover state should not be lost when axis is updated (#12569)
  26036. * Axis.update runs pointer.reset which uses chart.hoverPoint.state
  26037. * to apply state which does not exist in hoverPoint yet.
  26038. * The mouseOver event should be triggered when hoverPoint
  26039. * is correct.
  26040. */
  26041. hoverPoint.firePointEvent('mouseOver');
  26042. // Draw tooltip if necessary
  26043. if (tooltip) {
  26044. tooltip.refresh(useSharedTooltip ? points : hoverPoint, e);
  26045. }
  26046. // Update positions (regardless of kdpoint or hoverPoint)
  26047. }
  26048. else if (followPointer && tooltip && !tooltip.isHidden) {
  26049. var anchor = tooltip.getAnchor([{}],
  26050. e);
  26051. if (chart.isInsidePlot(anchor[0], anchor[1], {
  26052. visiblePlotOnly: true
  26053. })) {
  26054. tooltip.updatePosition({ plotX: anchor[0], plotY: anchor[1] });
  26055. }
  26056. }
  26057. // Start the event listener to pick up the tooltip and crosshairs
  26058. if (!pointer.unDocMouseMove) {
  26059. pointer.unDocMouseMove = addEvent(chart.container.ownerDocument, 'mousemove', function (e) {
  26060. var chart = charts[Pointer.hoverChartIndex];
  26061. if (chart) {
  26062. chart.pointer.onDocumentMouseMove(e);
  26063. }
  26064. });
  26065. pointer.eventsToUnbind.push(pointer.unDocMouseMove);
  26066. }
  26067. // Issues related to crosshair #4927, #5269 #5066, #5658
  26068. chart.axes.forEach(function drawAxisCrosshair(axis) {
  26069. var snap = pick((axis.crosshair || {}).snap,
  26070. true);
  26071. var point;
  26072. if (snap) {
  26073. point = chart.hoverPoint; // #13002
  26074. if (!point || point.series[axis.coll] !== axis) {
  26075. point = find(points, function (p) {
  26076. return p.series[axis.coll] === axis;
  26077. });
  26078. }
  26079. }
  26080. // Axis has snapping crosshairs, and one of the hover points belongs
  26081. // to axis. Always call drawCrosshair when it is not snap.
  26082. if (point || !snap) {
  26083. axis.drawCrosshair(e, point);
  26084. // Axis has snapping crosshairs, but no hover point belongs to axis
  26085. }
  26086. else {
  26087. axis.hideCrosshair();
  26088. }
  26089. });
  26090. };
  26091. /**
  26092. * Scale series groups to a certain scale and translation.
  26093. * @private
  26094. * @function Highcharts.Pointer#scaleGroups
  26095. */
  26096. Pointer.prototype.scaleGroups = function (attribs, clip) {
  26097. var chart = this.chart;
  26098. // Scale each series
  26099. chart.series.forEach(function (series) {
  26100. var seriesAttribs = attribs || series.getPlotBox(); // #1701
  26101. if (series.xAxis && series.xAxis.zoomEnabled && series.group) {
  26102. series.group.attr(seriesAttribs);
  26103. if (series.markerGroup) {
  26104. series.markerGroup.attr(seriesAttribs);
  26105. series.markerGroup.clip(clip ? chart.clipRect : null);
  26106. }
  26107. if (series.dataLabelsGroup) {
  26108. series.dataLabelsGroup.attr(seriesAttribs);
  26109. }
  26110. }
  26111. });
  26112. // Clip
  26113. chart.clipRect.attr(clip || chart.clipBox);
  26114. };
  26115. /**
  26116. * Set the JS DOM events on the container and document. This method should
  26117. * contain a one-to-one assignment between methods and their handlers. Any
  26118. * advanced logic should be moved to the handler reflecting the event's
  26119. * name.
  26120. * @private
  26121. * @function Highcharts.Pointer#setDOMEvents
  26122. */
  26123. Pointer.prototype.setDOMEvents = function () {
  26124. var _this = this;
  26125. var container = this.chart.container,
  26126. ownerDoc = container.ownerDocument;
  26127. container.onmousedown = this.onContainerMouseDown.bind(this);
  26128. container.onmousemove = this.onContainerMouseMove.bind(this);
  26129. container.onclick = this.onContainerClick.bind(this);
  26130. this.eventsToUnbind.push(addEvent(container, 'mouseenter', this.onContainerMouseEnter.bind(this)));
  26131. this.eventsToUnbind.push(addEvent(container, 'mouseleave', this.onContainerMouseLeave.bind(this)));
  26132. if (!Pointer.unbindDocumentMouseUp) {
  26133. Pointer.unbindDocumentMouseUp = addEvent(ownerDoc, 'mouseup', this.onDocumentMouseUp.bind(this));
  26134. }
  26135. // In case we are dealing with overflow, reset the chart position when
  26136. // scrolling parent elements
  26137. var parent = this.chart.renderTo.parentElement;
  26138. while (parent && parent.tagName !== 'BODY') {
  26139. this.eventsToUnbind.push(addEvent(parent, 'scroll', function () {
  26140. delete _this.chartPosition;
  26141. }));
  26142. parent = parent.parentElement;
  26143. }
  26144. if (H.hasTouch) {
  26145. this.eventsToUnbind.push(addEvent(container, 'touchstart', this.onContainerTouchStart.bind(this), { passive: false }));
  26146. this.eventsToUnbind.push(addEvent(container, 'touchmove', this.onContainerTouchMove.bind(this), { passive: false }));
  26147. if (!Pointer.unbindDocumentTouchEnd) {
  26148. Pointer.unbindDocumentTouchEnd = addEvent(ownerDoc, 'touchend', this.onDocumentTouchEnd.bind(this), { passive: false });
  26149. }
  26150. }
  26151. };
  26152. /**
  26153. * Sets the index of the hovered chart and leaves the previous hovered
  26154. * chart, to reset states like tooltip.
  26155. * @private
  26156. * @function Highcharts.Pointer#setHoverChartIndex
  26157. */
  26158. Pointer.prototype.setHoverChartIndex = function () {
  26159. var chart = this.chart;
  26160. var hoverChart = H.charts[pick(Pointer.hoverChartIndex, -1)];
  26161. if (hoverChart &&
  26162. hoverChart !== chart) {
  26163. hoverChart.pointer.onContainerMouseLeave({ relatedTarget: true });
  26164. }
  26165. if (!hoverChart ||
  26166. !hoverChart.mouseIsDown) {
  26167. Pointer.hoverChartIndex = chart.index;
  26168. }
  26169. };
  26170. /**
  26171. * General touch handler shared by touchstart and touchmove.
  26172. * @private
  26173. * @function Highcharts.Pointer#touch
  26174. */
  26175. Pointer.prototype.touch = function (e, start) {
  26176. var chart = this.chart;
  26177. var hasMoved,
  26178. pinchDown,
  26179. isInside;
  26180. this.setHoverChartIndex();
  26181. if (e.touches.length === 1) {
  26182. e = this.normalize(e);
  26183. isInside = chart.isInsidePlot(e.chartX - chart.plotLeft, e.chartY - chart.plotTop, {
  26184. visiblePlotOnly: true
  26185. });
  26186. if (isInside && !chart.openMenu) {
  26187. // Run mouse events and display tooltip etc
  26188. if (start) {
  26189. this.runPointActions(e);
  26190. }
  26191. // Android fires touchmove events after the touchstart even if
  26192. // the finger hasn't moved, or moved only a pixel or two. In iOS
  26193. // however, the touchmove doesn't fire unless the finger moves
  26194. // more than ~4px. So we emulate this behaviour in Android by
  26195. // checking how much it moved, and cancelling on small
  26196. // distances. #3450.
  26197. if (e.type === 'touchmove') {
  26198. pinchDown = this.pinchDown;
  26199. hasMoved = pinchDown[0] ? Math.sqrt(// #5266
  26200. Math.pow(pinchDown[0].chartX - e.chartX, 2) +
  26201. Math.pow(pinchDown[0].chartY - e.chartY, 2)) >= 4 : false;
  26202. }
  26203. if (pick(hasMoved, true)) {
  26204. this.pinch(e);
  26205. }
  26206. }
  26207. else if (start) {
  26208. // Hide the tooltip on touching outside the plot area (#1203)
  26209. this.reset();
  26210. }
  26211. }
  26212. else if (e.touches.length === 2) {
  26213. this.pinch(e);
  26214. }
  26215. };
  26216. /**
  26217. * Returns true if the chart is set up for zooming by single touch and the
  26218. * event is capable
  26219. * @private
  26220. * @function Highcharts.Pointer#touchSelect
  26221. */
  26222. Pointer.prototype.touchSelect = function (e) {
  26223. return Boolean(this.chart.options.chart.zoomBySingleTouch &&
  26224. e.touches &&
  26225. e.touches.length === 1);
  26226. };
  26227. /**
  26228. * Resolve the zoomType option, this is reset on all touch start and mouse
  26229. * down events.
  26230. * @private
  26231. * @function Highcharts.Pointer#zoomOption
  26232. */
  26233. Pointer.prototype.zoomOption = function (e) {
  26234. var chart = this.chart,
  26235. options = chart.options.chart,
  26236. inverted = chart.inverted;
  26237. var zoomType = options.zoomType || '',
  26238. zoomX,
  26239. zoomY;
  26240. // Look for the pinchType option
  26241. if (/touch/.test(e.type)) {
  26242. zoomType = pick(options.pinchType, zoomType);
  26243. }
  26244. this.zoomX = zoomX = /x/.test(zoomType);
  26245. this.zoomY = zoomY = /y/.test(zoomType);
  26246. this.zoomHor = (zoomX && !inverted) || (zoomY && inverted);
  26247. this.zoomVert = (zoomY && !inverted) || (zoomX && inverted);
  26248. this.hasZoom = zoomX || zoomY;
  26249. };
  26250. return Pointer;
  26251. }());
  26252. /* *
  26253. *
  26254. * Default Export
  26255. *
  26256. * */
  26257. /* *
  26258. *
  26259. * API Declarations
  26260. *
  26261. * */
  26262. /**
  26263. * One position in relation to an axis.
  26264. *
  26265. * @interface Highcharts.PointerAxisCoordinateObject
  26266. */ /**
  26267. * Related axis.
  26268. *
  26269. * @name Highcharts.PointerAxisCoordinateObject#axis
  26270. * @type {Highcharts.Axis}
  26271. */ /**
  26272. * Axis value.
  26273. *
  26274. * @name Highcharts.PointerAxisCoordinateObject#value
  26275. * @type {number}
  26276. */
  26277. /**
  26278. * Positions in terms of axis values.
  26279. *
  26280. * @interface Highcharts.PointerAxisCoordinatesObject
  26281. */ /**
  26282. * Positions on the x-axis.
  26283. * @name Highcharts.PointerAxisCoordinatesObject#xAxis
  26284. * @type {Array<Highcharts.PointerAxisCoordinateObject>}
  26285. */ /**
  26286. * Positions on the y-axis.
  26287. * @name Highcharts.PointerAxisCoordinatesObject#yAxis
  26288. * @type {Array<Highcharts.PointerAxisCoordinateObject>}
  26289. */
  26290. /**
  26291. * Pointer coordinates.
  26292. *
  26293. * @interface Highcharts.PointerCoordinatesObject
  26294. */ /**
  26295. * @name Highcharts.PointerCoordinatesObject#chartX
  26296. * @type {number}
  26297. */ /**
  26298. * @name Highcharts.PointerCoordinatesObject#chartY
  26299. * @type {number}
  26300. */
  26301. /**
  26302. * A native browser mouse or touch event, extended with position information
  26303. * relative to the {@link Chart.container}.
  26304. *
  26305. * @interface Highcharts.PointerEventObject
  26306. * @extends global.PointerEvent
  26307. */ /**
  26308. * The X coordinate of the pointer interaction relative to the chart.
  26309. *
  26310. * @name Highcharts.PointerEventObject#chartX
  26311. * @type {number}
  26312. */ /**
  26313. * The Y coordinate of the pointer interaction relative to the chart.
  26314. *
  26315. * @name Highcharts.PointerEventObject#chartY
  26316. * @type {number}
  26317. */
  26318. /**
  26319. * Axis-specific data of a selection.
  26320. *
  26321. * @interface Highcharts.SelectDataObject
  26322. */ /**
  26323. * @name Highcharts.SelectDataObject#axis
  26324. * @type {Highcharts.Axis}
  26325. */ /**
  26326. * @name Highcharts.SelectDataObject#max
  26327. * @type {number}
  26328. */ /**
  26329. * @name Highcharts.SelectDataObject#min
  26330. * @type {number}
  26331. */
  26332. /**
  26333. * Object for select events.
  26334. *
  26335. * @interface Highcharts.SelectEventObject
  26336. */ /**
  26337. * @name Highcharts.SelectEventObject#originalEvent
  26338. * @type {global.Event}
  26339. */ /**
  26340. * @name Highcharts.SelectEventObject#xAxis
  26341. * @type {Array<Highcharts.SelectDataObject>}
  26342. */ /**
  26343. * @name Highcharts.SelectEventObject#yAxis
  26344. * @type {Array<Highcharts.SelectDataObject>}
  26345. */
  26346. /**
  26347. * Chart position and scale.
  26348. *
  26349. * @interface Highcharts.ChartPositionObject
  26350. */ /**
  26351. * @name Highcharts.ChartPositionObject#left
  26352. * @type {number}
  26353. */ /**
  26354. * @name Highcharts.ChartPositionObject#scaleX
  26355. * @type {number}
  26356. */ /**
  26357. * @name Highcharts.ChartPositionObject#scaleY
  26358. * @type {number}
  26359. */ /**
  26360. * @name Highcharts.ChartPositionObject#top
  26361. * @type {number}
  26362. */
  26363. ''; // keeps doclets above in JS file
  26364. return Pointer;
  26365. });
  26366. _registerModule(_modules, 'Core/MSPointer.js', [_modules['Core/Globals.js'], _modules['Core/Pointer.js'], _modules['Core/Utilities.js']], function (H, Pointer, U) {
  26367. /* *
  26368. *
  26369. * (c) 2010-2021 Torstein Honsi
  26370. *
  26371. * License: www.highcharts.com/license
  26372. *
  26373. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  26374. *
  26375. * */
  26376. var __extends = (this && this.__extends) || (function () {
  26377. var extendStatics = function (d,
  26378. b) {
  26379. extendStatics = Object.setPrototypeOf ||
  26380. ({ __proto__: [] } instanceof Array && function (d,
  26381. b) { d.__proto__ = b; }) ||
  26382. function (d,
  26383. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  26384. return extendStatics(d, b);
  26385. };
  26386. return function (d, b) {
  26387. extendStatics(d, b);
  26388. function __() { this.constructor = d; }
  26389. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  26390. };
  26391. })();
  26392. var charts = H.charts,
  26393. doc = H.doc,
  26394. noop = H.noop,
  26395. win = H.win;
  26396. var addEvent = U.addEvent,
  26397. css = U.css,
  26398. objectEach = U.objectEach,
  26399. removeEvent = U.removeEvent;
  26400. /* *
  26401. *
  26402. * Constants
  26403. *
  26404. * */
  26405. // The touches object keeps track of the points being touched at all times
  26406. var touches = {};
  26407. var hasPointerEvent = !!win.PointerEvent;
  26408. /* *
  26409. *
  26410. * Functions
  26411. *
  26412. * */
  26413. /* eslint-disable valid-jsdoc */
  26414. /** @private */
  26415. function getWebkitTouches() {
  26416. var fake = [];
  26417. fake.item = function (i) {
  26418. return this[i];
  26419. };
  26420. objectEach(touches, function (touch) {
  26421. fake.push({
  26422. pageX: touch.pageX,
  26423. pageY: touch.pageY,
  26424. target: touch.target
  26425. });
  26426. });
  26427. return fake;
  26428. }
  26429. /** @private */
  26430. function translateMSPointer(e, method, wktype, func) {
  26431. var chart = charts[Pointer.hoverChartIndex || NaN];
  26432. if ((e.pointerType === 'touch' ||
  26433. e.pointerType === e.MSPOINTER_TYPE_TOUCH) && chart) {
  26434. var p = chart.pointer;
  26435. func(e);
  26436. p[method]({
  26437. type: wktype,
  26438. target: e.currentTarget,
  26439. preventDefault: noop,
  26440. touches: getWebkitTouches()
  26441. });
  26442. }
  26443. }
  26444. /* *
  26445. *
  26446. * Class
  26447. *
  26448. * */
  26449. /** @private */
  26450. var MSPointer = /** @class */ (function (_super) {
  26451. __extends(MSPointer, _super);
  26452. function MSPointer() {
  26453. return _super !== null && _super.apply(this, arguments) || this;
  26454. }
  26455. /* *
  26456. *
  26457. * Static Functions
  26458. *
  26459. * */
  26460. MSPointer.isRequired = function () {
  26461. return !!(!H.hasTouch && (win.PointerEvent || win.MSPointerEvent));
  26462. };
  26463. /* *
  26464. *
  26465. * Functions
  26466. *
  26467. * */
  26468. /**
  26469. * Add or remove the MS Pointer specific events
  26470. * @private
  26471. * @function Highcharts.Pointer#batchMSEvents
  26472. */
  26473. MSPointer.prototype.batchMSEvents = function (fn) {
  26474. fn(this.chart.container, hasPointerEvent ? 'pointerdown' : 'MSPointerDown', this.onContainerPointerDown);
  26475. fn(this.chart.container, hasPointerEvent ? 'pointermove' : 'MSPointerMove', this.onContainerPointerMove);
  26476. fn(doc, hasPointerEvent ? 'pointerup' : 'MSPointerUp', this.onDocumentPointerUp);
  26477. };
  26478. // Destroy MS events also
  26479. MSPointer.prototype.destroy = function () {
  26480. this.batchMSEvents(removeEvent);
  26481. _super.prototype.destroy.call(this);
  26482. };
  26483. // Disable default IE actions for pinch and such on chart element
  26484. MSPointer.prototype.init = function (chart, options) {
  26485. _super.prototype.init.call(this, chart, options);
  26486. if (this.hasZoom) { // #4014
  26487. css(chart.container, {
  26488. '-ms-touch-action': 'none',
  26489. 'touch-action': 'none'
  26490. });
  26491. }
  26492. };
  26493. /**
  26494. * @private
  26495. * @function Highcharts.Pointer#onContainerPointerDown
  26496. */
  26497. MSPointer.prototype.onContainerPointerDown = function (e) {
  26498. translateMSPointer(e, 'onContainerTouchStart', 'touchstart', function (e) {
  26499. touches[e.pointerId] = {
  26500. pageX: e.pageX,
  26501. pageY: e.pageY,
  26502. target: e.currentTarget
  26503. };
  26504. });
  26505. };
  26506. /**
  26507. * @private
  26508. * @function Highcharts.Pointer#onContainerPointerMove
  26509. */
  26510. MSPointer.prototype.onContainerPointerMove = function (e) {
  26511. translateMSPointer(e, 'onContainerTouchMove', 'touchmove', function (e) {
  26512. touches[e.pointerId] = ({ pageX: e.pageX, pageY: e.pageY });
  26513. if (!touches[e.pointerId].target) {
  26514. touches[e.pointerId].target = e.currentTarget;
  26515. }
  26516. });
  26517. };
  26518. /**
  26519. * @private
  26520. * @function Highcharts.Pointer#onDocumentPointerUp
  26521. */
  26522. MSPointer.prototype.onDocumentPointerUp = function (e) {
  26523. translateMSPointer(e, 'onDocumentTouchEnd', 'touchend', function (e) {
  26524. delete touches[e.pointerId];
  26525. });
  26526. };
  26527. // Add IE specific touch events to chart
  26528. MSPointer.prototype.setDOMEvents = function () {
  26529. _super.prototype.setDOMEvents.call(this);
  26530. if (this.hasZoom || this.followTouchMove) {
  26531. this.batchMSEvents(addEvent);
  26532. }
  26533. };
  26534. return MSPointer;
  26535. }(Pointer));
  26536. /* *
  26537. *
  26538. * Default Export
  26539. *
  26540. * */
  26541. return MSPointer;
  26542. });
  26543. _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/DefaultOptions.js'], _modules['Core/Utilities.js']], function (AST, A, F, H, D, U) {
  26544. /* *
  26545. *
  26546. * (c) 2010-2021 Torstein Honsi
  26547. *
  26548. * License: www.highcharts.com/license
  26549. *
  26550. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  26551. *
  26552. * */
  26553. var animObject = A.animObject;
  26554. var format = F.format;
  26555. var defaultOptions = D.defaultOptions;
  26556. var addEvent = U.addEvent,
  26557. defined = U.defined,
  26558. erase = U.erase,
  26559. extend = U.extend,
  26560. fireEvent = U.fireEvent,
  26561. getNestedProperty = U.getNestedProperty,
  26562. isArray = U.isArray,
  26563. isFunction = U.isFunction,
  26564. isNumber = U.isNumber,
  26565. isObject = U.isObject,
  26566. merge = U.merge,
  26567. objectEach = U.objectEach,
  26568. pick = U.pick,
  26569. syncTimeout = U.syncTimeout,
  26570. removeEvent = U.removeEvent,
  26571. uniqueKey = U.uniqueKey;
  26572. /**
  26573. * Function callback when a series point is clicked. Return false to cancel the
  26574. * action.
  26575. *
  26576. * @callback Highcharts.PointClickCallbackFunction
  26577. *
  26578. * @param {Highcharts.Point} this
  26579. * The point where the event occured.
  26580. *
  26581. * @param {Highcharts.PointClickEventObject} event
  26582. * Event arguments.
  26583. */
  26584. /**
  26585. * Common information for a click event on a series point.
  26586. *
  26587. * @interface Highcharts.PointClickEventObject
  26588. * @extends Highcharts.PointerEventObject
  26589. */ /**
  26590. * Clicked point.
  26591. * @name Highcharts.PointClickEventObject#point
  26592. * @type {Highcharts.Point}
  26593. */
  26594. /**
  26595. * Configuration hash for the data label and tooltip formatters.
  26596. *
  26597. * @interface Highcharts.PointLabelObject
  26598. */ /**
  26599. * The point's current color.
  26600. * @name Highcharts.PointLabelObject#color
  26601. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject|undefined}
  26602. */ /**
  26603. * The point's current color index, used in styled mode instead of `color`. The
  26604. * color index is inserted in class names used for styling.
  26605. * @name Highcharts.PointLabelObject#colorIndex
  26606. * @type {number}
  26607. */ /**
  26608. * The name of the related point.
  26609. * @name Highcharts.PointLabelObject#key
  26610. * @type {string|undefined}
  26611. */ /**
  26612. * The percentage for related points in a stacked series or pies.
  26613. * @name Highcharts.PointLabelObject#percentage
  26614. * @type {number}
  26615. */ /**
  26616. * The related point. The point name, if defined, is available through
  26617. * `this.point.name`.
  26618. * @name Highcharts.PointLabelObject#point
  26619. * @type {Highcharts.Point}
  26620. */ /**
  26621. * The related series. The series name is available through `this.series.name`.
  26622. * @name Highcharts.PointLabelObject#series
  26623. * @type {Highcharts.Series}
  26624. */ /**
  26625. * The total of values in either a stack for stacked series, or a pie in a pie
  26626. * series.
  26627. * @name Highcharts.PointLabelObject#total
  26628. * @type {number|undefined}
  26629. */ /**
  26630. * For categorized axes this property holds the category name for the point. For
  26631. * other axes it holds the X value.
  26632. * @name Highcharts.PointLabelObject#x
  26633. * @type {number|string|undefined}
  26634. */ /**
  26635. * The y value of the point.
  26636. * @name Highcharts.PointLabelObject#y
  26637. * @type {number|undefined}
  26638. */
  26639. /**
  26640. * Gets fired when the mouse leaves the area close to the point.
  26641. *
  26642. * @callback Highcharts.PointMouseOutCallbackFunction
  26643. *
  26644. * @param {Highcharts.Point} this
  26645. * Point where the event occured.
  26646. *
  26647. * @param {global.PointerEvent} event
  26648. * Event that occured.
  26649. */
  26650. /**
  26651. * Gets fired when the mouse enters the area close to the point.
  26652. *
  26653. * @callback Highcharts.PointMouseOverCallbackFunction
  26654. *
  26655. * @param {Highcharts.Point} this
  26656. * Point where the event occured.
  26657. *
  26658. * @param {global.Event} event
  26659. * Event that occured.
  26660. */
  26661. /**
  26662. * The generic point options for all series.
  26663. *
  26664. * In TypeScript you have to extend `PointOptionsObject` with an additional
  26665. * declaration to allow custom data options:
  26666. *
  26667. * ```
  26668. * declare interface PointOptionsObject {
  26669. * customProperty: string;
  26670. * }
  26671. * ```
  26672. *
  26673. * @interface Highcharts.PointOptionsObject
  26674. */
  26675. /**
  26676. * Possible option types for a data point. Use `null` to indicate a gap.
  26677. *
  26678. * @typedef {number|string|Highcharts.PointOptionsObject|Array<(number|string|null)>|null} Highcharts.PointOptionsType
  26679. */
  26680. /**
  26681. * Gets fired when the point is removed using the `.remove()` method.
  26682. *
  26683. * @callback Highcharts.PointRemoveCallbackFunction
  26684. *
  26685. * @param {Highcharts.Point} this
  26686. * Point where the event occured.
  26687. *
  26688. * @param {global.Event} event
  26689. * Event that occured.
  26690. */
  26691. /**
  26692. * Possible key values for the point state options.
  26693. *
  26694. * @typedef {"hover"|"inactive"|"normal"|"select"} Highcharts.PointStateValue
  26695. */
  26696. /**
  26697. * Gets fired when the point is updated programmatically through the `.update()`
  26698. * method.
  26699. *
  26700. * @callback Highcharts.PointUpdateCallbackFunction
  26701. *
  26702. * @param {Highcharts.Point} this
  26703. * Point where the event occured.
  26704. *
  26705. * @param {Highcharts.PointUpdateEventObject} event
  26706. * Event that occured.
  26707. */
  26708. /**
  26709. * Information about the update event.
  26710. *
  26711. * @interface Highcharts.PointUpdateEventObject
  26712. * @extends global.Event
  26713. */ /**
  26714. * Options data of the update event.
  26715. * @name Highcharts.PointUpdateEventObject#options
  26716. * @type {Highcharts.PointOptionsType}
  26717. */
  26718. /**
  26719. * @interface Highcharts.PointEventsOptionsObject
  26720. */ /**
  26721. * Fires when the point is selected either programmatically or following a click
  26722. * on the point. One parameter, `event`, is passed to the function. Returning
  26723. * `false` cancels the operation.
  26724. * @name Highcharts.PointEventsOptionsObject#select
  26725. * @type {Highcharts.PointSelectCallbackFunction|undefined}
  26726. */ /**
  26727. * Fires when the point is unselected either programmatically or following a
  26728. * click on the point. One parameter, `event`, is passed to the function.
  26729. * Returning `false` cancels the operation.
  26730. * @name Highcharts.PointEventsOptionsObject#unselect
  26731. * @type {Highcharts.PointUnselectCallbackFunction|undefined}
  26732. */
  26733. /**
  26734. * Information about the select/unselect event.
  26735. *
  26736. * @interface Highcharts.PointInteractionEventObject
  26737. * @extends global.Event
  26738. */ /**
  26739. * @name Highcharts.PointInteractionEventObject#accumulate
  26740. * @type {boolean}
  26741. */
  26742. /**
  26743. * Gets fired when the point is selected either programmatically or following a
  26744. * click on the point.
  26745. *
  26746. * @callback Highcharts.PointSelectCallbackFunction
  26747. *
  26748. * @param {Highcharts.Point} this
  26749. * Point where the event occured.
  26750. *
  26751. * @param {Highcharts.PointInteractionEventObject} event
  26752. * Event that occured.
  26753. */
  26754. /**
  26755. * Fires when the point is unselected either programmatically or following a
  26756. * click on the point.
  26757. *
  26758. * @callback Highcharts.PointUnselectCallbackFunction
  26759. *
  26760. * @param {Highcharts.Point} this
  26761. * Point where the event occured.
  26762. *
  26763. * @param {Highcharts.PointInteractionEventObject} event
  26764. * Event that occured.
  26765. */
  26766. ''; // detach doclet above
  26767. /* eslint-disable no-invalid-this, valid-jsdoc */
  26768. /**
  26769. * The Point object. The point objects are generated from the `series.data`
  26770. * configuration objects or raw numbers. They can be accessed from the
  26771. * `Series.points` array. Other ways to instantiate points are through {@link
  26772. * Highcharts.Series#addPoint} or {@link Highcharts.Series#setData}.
  26773. *
  26774. * @class
  26775. * @name Highcharts.Point
  26776. */
  26777. var Point = /** @class */ (function () {
  26778. function Point() {
  26779. /* *
  26780. *
  26781. * Properties
  26782. *
  26783. * */
  26784. /**
  26785. * For categorized axes this property holds the category name for the
  26786. * point. For other axes it holds the X value.
  26787. *
  26788. * @name Highcharts.Point#category
  26789. * @type {string}
  26790. */
  26791. this.category = void 0;
  26792. /**
  26793. * The point's current color index, used in styled mode instead of
  26794. * `color`. The color index is inserted in class names used for styling.
  26795. *
  26796. * @name Highcharts.Point#colorIndex
  26797. * @type {number}
  26798. */
  26799. this.colorIndex = void 0;
  26800. this.formatPrefix = 'point';
  26801. this.id = void 0;
  26802. this.isNull = false;
  26803. /**
  26804. * The name of the point. The name can be given as the first position of the
  26805. * point configuration array, or as a `name` property in the configuration:
  26806. *
  26807. * @example
  26808. * // Array config
  26809. * data: [
  26810. * ['John', 1],
  26811. * ['Jane', 2]
  26812. * ]
  26813. *
  26814. * // Object config
  26815. * data: [{
  26816. * name: 'John',
  26817. * y: 1
  26818. * }, {
  26819. * name: 'Jane',
  26820. * y: 2
  26821. * }]
  26822. *
  26823. * @name Highcharts.Point#name
  26824. * @type {string}
  26825. */
  26826. this.name = void 0;
  26827. /**
  26828. * The point's options as applied in the initial configuration, or
  26829. * extended through `Point.update`.
  26830. *
  26831. * In TypeScript you have to extend `PointOptionsObject` via an
  26832. * additional interface to allow custom data options:
  26833. *
  26834. * ```
  26835. * declare interface PointOptionsObject {
  26836. * customProperty: string;
  26837. * }
  26838. * ```
  26839. *
  26840. * @name Highcharts.Point#options
  26841. * @type {Highcharts.PointOptionsObject}
  26842. */
  26843. this.options = void 0;
  26844. /**
  26845. * The percentage for points in a stacked series or pies.
  26846. *
  26847. * @name Highcharts.Point#percentage
  26848. * @type {number|undefined}
  26849. */
  26850. this.percentage = void 0;
  26851. this.selected = false;
  26852. /**
  26853. * The series object associated with the point.
  26854. *
  26855. * @name Highcharts.Point#series
  26856. * @type {Highcharts.Series}
  26857. */
  26858. this.series = void 0;
  26859. /**
  26860. * The total of values in either a stack for stacked series, or a pie in a
  26861. * pie series.
  26862. *
  26863. * @name Highcharts.Point#total
  26864. * @type {number|undefined}
  26865. */
  26866. this.total = void 0;
  26867. /**
  26868. * For certain series types, like pie charts, where individual points can
  26869. * be shown or hidden.
  26870. *
  26871. * @name Highcharts.Point#visible
  26872. * @type {boolean}
  26873. * @default true
  26874. */
  26875. this.visible = true;
  26876. this.x = void 0;
  26877. }
  26878. /* *
  26879. *
  26880. * Functions
  26881. *
  26882. * */
  26883. /**
  26884. * Animate SVG elements associated with the point.
  26885. *
  26886. * @private
  26887. * @function Highcharts.Point#animateBeforeDestroy
  26888. */
  26889. Point.prototype.animateBeforeDestroy = function () {
  26890. var point = this,
  26891. animateParams = { x: point.startXPos,
  26892. opacity: 0 },
  26893. isDataLabel,
  26894. graphicalProps = point.getGraphicalProps();
  26895. graphicalProps.singular.forEach(function (prop) {
  26896. isDataLabel = prop === 'dataLabel';
  26897. point[prop] = point[prop].animate(isDataLabel ? {
  26898. x: point[prop].startXPos,
  26899. y: point[prop].startYPos,
  26900. opacity: 0
  26901. } : animateParams);
  26902. });
  26903. graphicalProps.plural.forEach(function (plural) {
  26904. point[plural].forEach(function (item) {
  26905. if (item.element) {
  26906. item.animate(extend({ x: point.startXPos }, (item.startYPos ? {
  26907. x: item.startXPos,
  26908. y: item.startYPos
  26909. } : {})));
  26910. }
  26911. });
  26912. });
  26913. };
  26914. /**
  26915. * Apply the options containing the x and y data and possible some extra
  26916. * properties. Called on point init or from point.update.
  26917. *
  26918. * @private
  26919. * @function Highcharts.Point#applyOptions
  26920. *
  26921. * @param {Highcharts.PointOptionsType} options
  26922. * The point options as defined in series.data.
  26923. *
  26924. * @param {number} [x]
  26925. * Optionally, the x value.
  26926. *
  26927. * @return {Highcharts.Point}
  26928. * The Point instance.
  26929. */
  26930. Point.prototype.applyOptions = function (options, x) {
  26931. var point = this,
  26932. series = point.series,
  26933. pointValKey = series.options.pointValKey || series.pointValKey;
  26934. options = Point.prototype.optionsToObject.call(this, options);
  26935. // copy options directly to point
  26936. extend(point, options);
  26937. point.options = point.options ? extend(point.options, options) : options;
  26938. // Since options are copied into the Point instance, some accidental
  26939. // options must be shielded (#5681)
  26940. if (options.group) {
  26941. delete point.group;
  26942. }
  26943. if (options.dataLabels) {
  26944. delete point.dataLabels;
  26945. }
  26946. /**
  26947. * The y value of the point.
  26948. * @name Highcharts.Point#y
  26949. * @type {number|undefined}
  26950. */
  26951. // For higher dimension series types. For instance, for ranges, point.y
  26952. // is mapped to point.low.
  26953. if (pointValKey) {
  26954. point.y = Point.prototype.getNestedProperty.call(point, pointValKey);
  26955. }
  26956. point.isNull = pick(point.isValid && !point.isValid(), point.x === null || !isNumber(point.y)); // #3571, check for NaN
  26957. point.formatPrefix = point.isNull ? 'null' : 'point'; // #9233, #10874
  26958. // The point is initially selected by options (#5777)
  26959. if (point.selected) {
  26960. point.state = 'select';
  26961. }
  26962. /**
  26963. * The x value of the point.
  26964. * @name Highcharts.Point#x
  26965. * @type {number}
  26966. */
  26967. // If no x is set by now, get auto incremented value. All points must
  26968. // have an x value, however the y value can be null to create a gap in
  26969. // the series
  26970. if ('name' in point &&
  26971. typeof x === 'undefined' &&
  26972. series.xAxis &&
  26973. series.xAxis.hasNames) {
  26974. point.x = series.xAxis.nameToX(point);
  26975. }
  26976. if (typeof point.x === 'undefined' && series) {
  26977. if (typeof x === 'undefined') {
  26978. point.x = series.autoIncrement(point);
  26979. }
  26980. else {
  26981. point.x = x;
  26982. }
  26983. }
  26984. return point;
  26985. };
  26986. /**
  26987. * Destroy a point to clear memory. Its reference still stays in
  26988. * `series.data`.
  26989. *
  26990. * @private
  26991. * @function Highcharts.Point#destroy
  26992. */
  26993. Point.prototype.destroy = function () {
  26994. var point = this,
  26995. series = point.series,
  26996. chart = series.chart,
  26997. dataSorting = series.options.dataSorting,
  26998. hoverPoints = chart.hoverPoints,
  26999. globalAnimation = point.series.chart.renderer.globalAnimation,
  27000. animation = animObject(globalAnimation),
  27001. prop;
  27002. /**
  27003. * Allow to call after animation.
  27004. * @private
  27005. */
  27006. function destroyPoint() {
  27007. // Remove all events and elements
  27008. if (point.graphic || point.dataLabel || point.dataLabels) {
  27009. removeEvent(point);
  27010. point.destroyElements();
  27011. }
  27012. for (prop in point) { // eslint-disable-line guard-for-in
  27013. point[prop] = null;
  27014. }
  27015. }
  27016. if (point.legendItem) { // pies have legend items
  27017. chart.legend.destroyItem(point);
  27018. }
  27019. if (hoverPoints) {
  27020. point.setState();
  27021. erase(hoverPoints, point);
  27022. if (!hoverPoints.length) {
  27023. chart.hoverPoints = null;
  27024. }
  27025. }
  27026. if (point === chart.hoverPoint) {
  27027. point.onMouseOut();
  27028. }
  27029. // Remove properties after animation
  27030. if (!dataSorting || !dataSorting.enabled) {
  27031. destroyPoint();
  27032. }
  27033. else {
  27034. this.animateBeforeDestroy();
  27035. syncTimeout(destroyPoint, animation.duration);
  27036. }
  27037. chart.pointCount--;
  27038. };
  27039. /**
  27040. * Destroy SVG elements associated with the point.
  27041. *
  27042. * @private
  27043. * @function Highcharts.Point#destroyElements
  27044. * @param {Highcharts.Dictionary<number>} [kinds]
  27045. */
  27046. Point.prototype.destroyElements = function (kinds) {
  27047. var point = this,
  27048. props = point.getGraphicalProps(kinds);
  27049. props.singular.forEach(function (prop) {
  27050. point[prop] = point[prop].destroy();
  27051. });
  27052. props.plural.forEach(function (plural) {
  27053. point[plural].forEach(function (item) {
  27054. if (item.element) {
  27055. item.destroy();
  27056. }
  27057. });
  27058. delete point[plural];
  27059. });
  27060. };
  27061. /**
  27062. * Fire an event on the Point object.
  27063. *
  27064. * @private
  27065. * @function Highcharts.Point#firePointEvent
  27066. *
  27067. * @param {string} eventType
  27068. * Type of the event.
  27069. *
  27070. * @param {Highcharts.Dictionary<any>|Event} [eventArgs]
  27071. * Additional event arguments.
  27072. *
  27073. * @param {Highcharts.EventCallbackFunction<Highcharts.Point>|Function} [defaultFunction]
  27074. * Default event handler.
  27075. *
  27076. * @fires Highcharts.Point#event:*
  27077. */
  27078. Point.prototype.firePointEvent = function (eventType, eventArgs, defaultFunction) {
  27079. var point = this,
  27080. series = this.series,
  27081. seriesOptions = series.options;
  27082. // load event handlers on demand to save time on mouseover/out
  27083. if (seriesOptions.point.events[eventType] ||
  27084. (point.options &&
  27085. point.options.events &&
  27086. point.options.events[eventType])) {
  27087. point.importEvents();
  27088. }
  27089. // add default handler if in selection mode
  27090. if (eventType === 'click' && seriesOptions.allowPointSelect) {
  27091. defaultFunction = function (event) {
  27092. // Control key is for Windows, meta (= Cmd key) for Mac, Shift
  27093. // for Opera.
  27094. if (point.select) { // #2911
  27095. point.select(null, event.ctrlKey || event.metaKey || event.shiftKey);
  27096. }
  27097. };
  27098. }
  27099. fireEvent(point, eventType, eventArgs, defaultFunction);
  27100. };
  27101. /**
  27102. * Get the CSS class names for individual points. Used internally where the
  27103. * returned value is set on every point.
  27104. *
  27105. * @function Highcharts.Point#getClassName
  27106. *
  27107. * @return {string}
  27108. * The class names.
  27109. */
  27110. Point.prototype.getClassName = function () {
  27111. var point = this;
  27112. return 'highcharts-point' +
  27113. (point.selected ? ' highcharts-point-select' : '') +
  27114. (point.negative ? ' highcharts-negative' : '') +
  27115. (point.isNull ? ' highcharts-null-point' : '') +
  27116. (typeof point.colorIndex !== 'undefined' ?
  27117. ' highcharts-color-' + point.colorIndex : '') +
  27118. (point.options.className ? ' ' + point.options.className : '') +
  27119. (point.zone && point.zone.className ? ' ' +
  27120. point.zone.className.replace('highcharts-negative', '') : '');
  27121. };
  27122. /**
  27123. * Get props of all existing graphical point elements.
  27124. *
  27125. * @private
  27126. * @function Highcharts.Point#getGraphicalProps
  27127. * @param {Highcharts.Dictionary<number>} [kinds]
  27128. * @return {Highcharts.PointGraphicalProps}
  27129. */
  27130. Point.prototype.getGraphicalProps = function (kinds) {
  27131. var point = this,
  27132. props = [],
  27133. prop,
  27134. i,
  27135. graphicalProps = { singular: [],
  27136. plural: [] };
  27137. kinds = kinds || { graphic: 1, dataLabel: 1 };
  27138. if (kinds.graphic) {
  27139. props.push('graphic', 'upperGraphic', 'shadowGroup');
  27140. }
  27141. if (kinds.dataLabel) {
  27142. props.push('dataLabel', 'dataLabelUpper', 'connector');
  27143. }
  27144. i = props.length;
  27145. while (i--) {
  27146. prop = props[i];
  27147. if (point[prop]) {
  27148. graphicalProps.singular.push(prop);
  27149. }
  27150. }
  27151. ['dataLabel', 'connector'].forEach(function (prop) {
  27152. var plural = prop + 's';
  27153. if (kinds[prop] && point[plural]) {
  27154. graphicalProps.plural.push(plural);
  27155. }
  27156. });
  27157. return graphicalProps;
  27158. };
  27159. /**
  27160. * Return the configuration hash needed for the data label and tooltip
  27161. * formatters.
  27162. *
  27163. * @function Highcharts.Point#getLabelConfig
  27164. *
  27165. * @return {Highcharts.PointLabelObject}
  27166. * Abstract object used in formatters and formats.
  27167. */
  27168. Point.prototype.getLabelConfig = function () {
  27169. return {
  27170. x: this.category,
  27171. y: this.y,
  27172. color: this.color,
  27173. colorIndex: this.colorIndex,
  27174. key: this.name || this.category,
  27175. series: this.series,
  27176. point: this,
  27177. percentage: this.percentage,
  27178. total: this.total || this.stackTotal
  27179. };
  27180. };
  27181. /**
  27182. * Returns the value of the point property for a given value.
  27183. * @private
  27184. */
  27185. Point.prototype.getNestedProperty = function (key) {
  27186. if (!key) {
  27187. return;
  27188. }
  27189. if (key.indexOf('custom.') === 0) {
  27190. return getNestedProperty(key, this.options);
  27191. }
  27192. return this[key];
  27193. };
  27194. /**
  27195. * In a series with `zones`, return the zone that the point belongs to.
  27196. *
  27197. * @function Highcharts.Point#getZone
  27198. *
  27199. * @return {Highcharts.SeriesZonesOptionsObject}
  27200. * The zone item.
  27201. */
  27202. Point.prototype.getZone = function () {
  27203. var series = this.series,
  27204. zones = series.zones,
  27205. zoneAxis = series.zoneAxis || 'y',
  27206. i = 0,
  27207. zone;
  27208. zone = zones[i];
  27209. while (this[zoneAxis] >= zone.value) {
  27210. zone = zones[++i];
  27211. }
  27212. // For resetting or reusing the point (#8100)
  27213. if (!this.nonZonedColor) {
  27214. this.nonZonedColor = this.color;
  27215. }
  27216. if (zone && zone.color && !this.options.color) {
  27217. this.color = zone.color;
  27218. }
  27219. else {
  27220. this.color = this.nonZonedColor;
  27221. }
  27222. return zone;
  27223. };
  27224. /**
  27225. * Utility to check if point has new shape type. Used in column series and
  27226. * all others that are based on column series.
  27227. *
  27228. * @return boolean|undefined
  27229. */
  27230. Point.prototype.hasNewShapeType = function () {
  27231. var point = this;
  27232. var oldShapeType = point.graphic &&
  27233. (point.graphic.symbolName || point.graphic.element.nodeName);
  27234. return oldShapeType !== this.shapeType;
  27235. };
  27236. /**
  27237. * Initialize the point. Called internally based on the `series.data`
  27238. * option.
  27239. *
  27240. * @function Highcharts.Point#init
  27241. *
  27242. * @param {Highcharts.Series} series
  27243. * The series object containing this point.
  27244. *
  27245. * @param {Highcharts.PointOptionsType} options
  27246. * The data in either number, array or object format.
  27247. *
  27248. * @param {number} [x]
  27249. * Optionally, the X value of the point.
  27250. *
  27251. * @return {Highcharts.Point}
  27252. * The Point instance.
  27253. *
  27254. * @fires Highcharts.Point#event:afterInit
  27255. */
  27256. Point.prototype.init = function (series, options, x) {
  27257. this.series = series;
  27258. this.applyOptions(options, x);
  27259. // Add a unique ID to the point if none is assigned
  27260. this.id = defined(this.id) ? this.id : uniqueKey();
  27261. this.resolveColor();
  27262. series.chart.pointCount++;
  27263. fireEvent(this, 'afterInit');
  27264. return this;
  27265. };
  27266. /**
  27267. * Transform number or array configs into objects. Also called for object
  27268. * configs. Used internally to unify the different configuration formats for
  27269. * points. For example, a simple number `10` in a line series will be
  27270. * transformed to `{ y: 10 }`, and an array config like `[1, 10]` in a
  27271. * scatter series will be transformed to `{ x: 1, y: 10 }`.
  27272. *
  27273. * @function Highcharts.Point#optionsToObject
  27274. *
  27275. * @param {Highcharts.PointOptionsType} options
  27276. * The input option.
  27277. *
  27278. * @return {Highcharts.Dictionary<*>}
  27279. * Transformed options.
  27280. */
  27281. Point.prototype.optionsToObject = function (options) {
  27282. var ret = {},
  27283. series = this.series,
  27284. keys = series.options.keys,
  27285. pointArrayMap = keys || series.pointArrayMap || ['y'],
  27286. valueCount = pointArrayMap.length,
  27287. firstItemType,
  27288. i = 0,
  27289. j = 0;
  27290. if (isNumber(options) || options === null) {
  27291. ret[pointArrayMap[0]] = options;
  27292. }
  27293. else if (isArray(options)) {
  27294. // with leading x value
  27295. if (!keys && options.length > valueCount) {
  27296. firstItemType = typeof options[0];
  27297. if (firstItemType === 'string') {
  27298. ret.name = options[0];
  27299. }
  27300. else if (firstItemType === 'number') {
  27301. ret.x = options[0];
  27302. }
  27303. i++;
  27304. }
  27305. while (j < valueCount) {
  27306. // Skip undefined positions for keys
  27307. if (!keys || typeof options[i] !== 'undefined') {
  27308. if (pointArrayMap[j].indexOf('.') > 0) {
  27309. // Handle nested keys, e.g. ['color.pattern.image']
  27310. // Avoid function call unless necessary.
  27311. Point.prototype.setNestedProperty(ret, options[i], pointArrayMap[j]);
  27312. }
  27313. else {
  27314. ret[pointArrayMap[j]] = options[i];
  27315. }
  27316. }
  27317. i++;
  27318. j++;
  27319. }
  27320. }
  27321. else if (typeof options === 'object') {
  27322. ret = options;
  27323. // This is the fastest way to detect if there are individual point
  27324. // dataLabels that need to be considered in drawDataLabels. These
  27325. // can only occur in object configs.
  27326. if (options.dataLabels) {
  27327. series._hasPointLabels = true;
  27328. }
  27329. // Same approach as above for markers
  27330. if (options.marker) {
  27331. series._hasPointMarkers = true;
  27332. }
  27333. }
  27334. return ret;
  27335. };
  27336. /**
  27337. * @private
  27338. * @function Highcharts.Point#resolveColor
  27339. * @return {void}
  27340. */
  27341. Point.prototype.resolveColor = function () {
  27342. var series = this.series,
  27343. colors,
  27344. optionsChart = series.chart.options.chart,
  27345. colorCount = optionsChart.colorCount,
  27346. styledMode = series.chart.styledMode,
  27347. colorIndex,
  27348. color;
  27349. // remove points nonZonedColor for later recalculation
  27350. delete this.nonZonedColor;
  27351. if (series.options.colorByPoint) {
  27352. if (!styledMode) {
  27353. colors = series.options.colors || series.chart.options.colors;
  27354. color = colors[series.colorCounter];
  27355. colorCount = colors.length;
  27356. }
  27357. colorIndex = series.colorCounter;
  27358. series.colorCounter++;
  27359. // loop back to zero
  27360. if (series.colorCounter === colorCount) {
  27361. series.colorCounter = 0;
  27362. }
  27363. }
  27364. else {
  27365. if (!styledMode) {
  27366. color = series.color;
  27367. }
  27368. colorIndex = series.colorIndex;
  27369. }
  27370. this.colorIndex = pick(this.options.colorIndex, colorIndex);
  27371. /**
  27372. * The point's current color.
  27373. *
  27374. * @name Highcharts.Point#color
  27375. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject|undefined}
  27376. */
  27377. this.color = pick(this.options.color, color);
  27378. };
  27379. /**
  27380. * Set a value in an object, on the property defined by key. The key
  27381. * supports nested properties using dot notation. The function modifies the
  27382. * input object and does not make a copy.
  27383. *
  27384. * @function Highcharts.Point#setNestedProperty<T>
  27385. *
  27386. * @param {T} object
  27387. * The object to set the value on.
  27388. *
  27389. * @param {*} value
  27390. * The value to set.
  27391. *
  27392. * @param {string} key
  27393. * Key to the property to set.
  27394. *
  27395. * @return {T}
  27396. * The modified object.
  27397. */
  27398. Point.prototype.setNestedProperty = function (object, value, key) {
  27399. var nestedKeys = key.split('.');
  27400. nestedKeys.reduce(function (result, key, i, arr) {
  27401. var isLastKey = arr.length - 1 === i;
  27402. result[key] = (isLastKey ?
  27403. value :
  27404. isObject(result[key], true) ?
  27405. result[key] :
  27406. {});
  27407. return result[key];
  27408. }, object);
  27409. return object;
  27410. };
  27411. /**
  27412. * Extendable method for formatting each point's tooltip line.
  27413. *
  27414. * @function Highcharts.Point#tooltipFormatter
  27415. *
  27416. * @param {string} pointFormat
  27417. * The point format.
  27418. *
  27419. * @return {string}
  27420. * A string to be concatenated in to the common tooltip text.
  27421. */
  27422. Point.prototype.tooltipFormatter = function (pointFormat) {
  27423. // Insert options for valueDecimals, valuePrefix, and valueSuffix
  27424. var series = this.series, seriesTooltipOptions = series.tooltipOptions, valueDecimals = pick(seriesTooltipOptions.valueDecimals, ''), valuePrefix = seriesTooltipOptions.valuePrefix || '', valueSuffix = seriesTooltipOptions.valueSuffix || '';
  27425. // Replace default point style with class name
  27426. if (series.chart.styledMode) {
  27427. pointFormat =
  27428. series.chart.tooltip.styledModeFormat(pointFormat);
  27429. }
  27430. // Loop over the point array map and replace unformatted values with
  27431. // sprintf formatting markup
  27432. (series.pointArrayMap || ['y']).forEach(function (key) {
  27433. key = '{point.' + key; // without the closing bracket
  27434. if (valuePrefix || valueSuffix) {
  27435. pointFormat = pointFormat.replace(RegExp(key + '}', 'g'), valuePrefix + key + '}' + valueSuffix);
  27436. }
  27437. pointFormat = pointFormat.replace(RegExp(key + '}', 'g'), key + ':,.' + valueDecimals + 'f}');
  27438. });
  27439. return format(pointFormat, {
  27440. point: this,
  27441. series: this.series
  27442. }, series.chart);
  27443. };
  27444. /**
  27445. * Update point with new options (typically x/y data) and optionally redraw
  27446. * the series.
  27447. *
  27448. * @sample highcharts/members/point-update-column/
  27449. * Update column value
  27450. * @sample highcharts/members/point-update-pie/
  27451. * Update pie slice
  27452. * @sample maps/members/point-update/
  27453. * Update map area value in Highmaps
  27454. *
  27455. * @function Highcharts.Point#update
  27456. *
  27457. * @param {Highcharts.PointOptionsType} options
  27458. * The point options. Point options are handled as described under
  27459. * the `series.type.data` item for each series type. For example
  27460. * for a line series, if options is a single number, the point will
  27461. * be given that number as the marin y value. If it is an array, it
  27462. * will be interpreted as x and y values respectively. If it is an
  27463. * object, advanced options are applied.
  27464. *
  27465. * @param {boolean} [redraw=true]
  27466. * Whether to redraw the chart after the point is updated. If doing
  27467. * more operations on the chart, it is best practice to set
  27468. * `redraw` to false and call `chart.redraw()` after.
  27469. *
  27470. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  27471. * Whether to apply animation, and optionally animation
  27472. * configuration.
  27473. *
  27474. * @fires Highcharts.Point#event:update
  27475. */
  27476. Point.prototype.update = function (options, redraw, animation, runEvent) {
  27477. var point = this,
  27478. series = point.series,
  27479. graphic = point.graphic,
  27480. i,
  27481. chart = series.chart,
  27482. seriesOptions = series.options;
  27483. redraw = pick(redraw, true);
  27484. /**
  27485. * @private
  27486. */
  27487. function update() {
  27488. point.applyOptions(options);
  27489. // Update visuals, #4146
  27490. // Handle dummy graphic elements for a11y, #12718
  27491. var hasDummyGraphic = graphic && point.hasDummyGraphic;
  27492. var shouldDestroyGraphic = point.y === null ? !hasDummyGraphic : hasDummyGraphic;
  27493. if (graphic && shouldDestroyGraphic) {
  27494. point.graphic = graphic.destroy();
  27495. delete point.hasDummyGraphic;
  27496. }
  27497. if (isObject(options, true)) {
  27498. // Destroy so we can get new elements
  27499. if (graphic && graphic.element) {
  27500. // "null" is also a valid symbol
  27501. if (options &&
  27502. options.marker &&
  27503. typeof options.marker.symbol !== 'undefined') {
  27504. point.graphic = graphic.destroy();
  27505. }
  27506. }
  27507. if (options && options.dataLabels && point.dataLabel) {
  27508. point.dataLabel = point.dataLabel.destroy(); // #2468
  27509. }
  27510. if (point.connector) {
  27511. point.connector = point.connector.destroy(); // #7243
  27512. }
  27513. }
  27514. // record changes in the parallel arrays
  27515. i = point.index;
  27516. series.updateParallelArrays(point, i);
  27517. // Record the options to options.data. If the old or the new config
  27518. // is an object, use point options, otherwise use raw options
  27519. // (#4701, #4916).
  27520. seriesOptions.data[i] = (isObject(seriesOptions.data[i], true) ||
  27521. isObject(options, true)) ?
  27522. point.options :
  27523. pick(options, seriesOptions.data[i]);
  27524. // redraw
  27525. series.isDirty = series.isDirtyData = true;
  27526. if (!series.fixedBox && series.hasCartesianSeries) { // #1906, #2320
  27527. chart.isDirtyBox = true;
  27528. }
  27529. if (seriesOptions.legendType === 'point') { // #1831, #1885
  27530. chart.isDirtyLegend = true;
  27531. }
  27532. if (redraw) {
  27533. chart.redraw(animation);
  27534. }
  27535. }
  27536. // Fire the event with a default handler of doing the update
  27537. if (runEvent === false) { // When called from setData
  27538. update();
  27539. }
  27540. else {
  27541. point.firePointEvent('update', { options: options }, update);
  27542. }
  27543. };
  27544. /**
  27545. * Remove a point and optionally redraw the series and if necessary the axes
  27546. *
  27547. * @sample highcharts/plotoptions/series-point-events-remove/
  27548. * Remove point and confirm
  27549. * @sample highcharts/members/point-remove/
  27550. * Remove pie slice
  27551. * @sample maps/members/point-remove/
  27552. * Remove selected points in Highmaps
  27553. *
  27554. * @function Highcharts.Point#remove
  27555. *
  27556. * @param {boolean} [redraw=true]
  27557. * Whether to redraw the chart or wait for an explicit call. When
  27558. * doing more operations on the chart, for example running
  27559. * `point.remove()` in a loop, it is best practice to set `redraw`
  27560. * to false and call `chart.redraw()` after.
  27561. *
  27562. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=false]
  27563. * Whether to apply animation, and optionally animation
  27564. * configuration.
  27565. */
  27566. Point.prototype.remove = function (redraw, animation) {
  27567. this.series.removePoint(this.series.data.indexOf(this), redraw, animation);
  27568. };
  27569. /**
  27570. * Toggle the selection status of a point.
  27571. *
  27572. * @see Highcharts.Chart#getSelectedPoints
  27573. *
  27574. * @sample highcharts/members/point-select/
  27575. * Select a point from a button
  27576. * @sample highcharts/chart/events-selection-points/
  27577. * Select a range of points through a drag selection
  27578. * @sample maps/series/data-id/
  27579. * Select a point in Highmaps
  27580. *
  27581. * @function Highcharts.Point#select
  27582. *
  27583. * @param {boolean} [selected]
  27584. * When `true`, the point is selected. When `false`, the point is
  27585. * unselected. When `null` or `undefined`, the selection state is toggled.
  27586. *
  27587. * @param {boolean} [accumulate=false]
  27588. * When `true`, the selection is added to other selected points.
  27589. * When `false`, other selected points are deselected. Internally in
  27590. * Highcharts, when
  27591. * [allowPointSelect](https://api.highcharts.com/highcharts/plotOptions.series.allowPointSelect)
  27592. * is `true`, selected points are accumulated on Control, Shift or Cmd
  27593. * clicking the point.
  27594. *
  27595. * @fires Highcharts.Point#event:select
  27596. * @fires Highcharts.Point#event:unselect
  27597. */
  27598. Point.prototype.select = function (selected, accumulate) {
  27599. var point = this,
  27600. series = point.series,
  27601. chart = series.chart;
  27602. selected = pick(selected, !point.selected);
  27603. this.selectedStaging = selected;
  27604. // fire the event with the default handler
  27605. point.firePointEvent(selected ? 'select' : 'unselect', { accumulate: accumulate }, function () {
  27606. /**
  27607. * Whether the point is selected or not.
  27608. *
  27609. * @see Point#select
  27610. * @see Chart#getSelectedPoints
  27611. *
  27612. * @name Highcharts.Point#selected
  27613. * @type {boolean}
  27614. */
  27615. point.selected = point.options.selected = selected;
  27616. series.options.data[series.data.indexOf(point)] =
  27617. point.options;
  27618. point.setState(selected && 'select');
  27619. // unselect all other points unless Ctrl or Cmd + click
  27620. if (!accumulate) {
  27621. chart.getSelectedPoints().forEach(function (loopPoint) {
  27622. var loopSeries = loopPoint.series;
  27623. if (loopPoint.selected && loopPoint !== point) {
  27624. loopPoint.selected = loopPoint.options.selected =
  27625. false;
  27626. loopSeries.options.data[loopSeries.data.indexOf(loopPoint)] = loopPoint.options;
  27627. // Programatically selecting a point should restore
  27628. // normal state, but when click happened on other
  27629. // point, set inactive state to match other points
  27630. loopPoint.setState(chart.hoverPoints &&
  27631. loopSeries.options.inactiveOtherPoints ?
  27632. 'inactive' : '');
  27633. loopPoint.firePointEvent('unselect');
  27634. }
  27635. });
  27636. }
  27637. });
  27638. delete this.selectedStaging;
  27639. };
  27640. /**
  27641. * Runs on mouse over the point. Called internally from mouse and touch
  27642. * events.
  27643. *
  27644. * @function Highcharts.Point#onMouseOver
  27645. *
  27646. * @param {Highcharts.PointerEventObject} [e]
  27647. * The event arguments.
  27648. */
  27649. Point.prototype.onMouseOver = function (e) {
  27650. var point = this,
  27651. series = point.series,
  27652. chart = series.chart,
  27653. pointer = chart.pointer;
  27654. e = e ?
  27655. pointer.normalize(e) :
  27656. // In cases where onMouseOver is called directly without an event
  27657. pointer.getChartCoordinatesFromPoint(point, chart.inverted);
  27658. pointer.runPointActions(e, point);
  27659. };
  27660. /**
  27661. * Runs on mouse out from the point. Called internally from mouse and touch
  27662. * events.
  27663. *
  27664. * @function Highcharts.Point#onMouseOut
  27665. * @fires Highcharts.Point#event:mouseOut
  27666. */
  27667. Point.prototype.onMouseOut = function () {
  27668. var point = this,
  27669. chart = point.series.chart;
  27670. point.firePointEvent('mouseOut');
  27671. if (!point.series.options.inactiveOtherPoints) {
  27672. (chart.hoverPoints || []).forEach(function (p) {
  27673. p.setState();
  27674. });
  27675. }
  27676. chart.hoverPoints = chart.hoverPoint = null;
  27677. };
  27678. /**
  27679. * Import events from the series' and point's options. Only do it on
  27680. * demand, to save processing time on hovering.
  27681. *
  27682. * @private
  27683. * @function Highcharts.Point#importEvents
  27684. */
  27685. Point.prototype.importEvents = function () {
  27686. if (!this.hasImportedEvents) {
  27687. var point_1 = this,
  27688. options = merge(point_1.series.options.point,
  27689. point_1.options),
  27690. events = options.events;
  27691. point_1.events = events;
  27692. objectEach(events, function (event, eventType) {
  27693. if (isFunction(event)) {
  27694. addEvent(point_1, eventType, event);
  27695. }
  27696. });
  27697. this.hasImportedEvents = true;
  27698. }
  27699. };
  27700. /**
  27701. * Set the point's state.
  27702. *
  27703. * @function Highcharts.Point#setState
  27704. *
  27705. * @param {Highcharts.PointStateValue|""} [state]
  27706. * The new state, can be one of `'hover'`, `'select'`, `'inactive'`,
  27707. * or `''` (an empty string), `'normal'` or `undefined` to set to
  27708. * normal state.
  27709. * @param {boolean} [move]
  27710. * State for animation.
  27711. *
  27712. * @fires Highcharts.Point#event:afterSetState
  27713. */
  27714. Point.prototype.setState = function (state, move) {
  27715. var point = this,
  27716. series = point.series,
  27717. previousState = point.state,
  27718. stateOptions = (series.options.states[state || 'normal'] ||
  27719. {}),
  27720. markerOptions = (defaultOptions.plotOptions[series.type].marker &&
  27721. series.options.marker),
  27722. normalDisabled = (markerOptions && markerOptions.enabled === false),
  27723. markerStateOptions = ((markerOptions &&
  27724. markerOptions.states &&
  27725. markerOptions.states[state || 'normal']) || {}),
  27726. stateDisabled = markerStateOptions.enabled === false,
  27727. stateMarkerGraphic = series.stateMarkerGraphic,
  27728. pointMarker = point.marker || {},
  27729. chart = series.chart,
  27730. halo = series.halo,
  27731. haloOptions,
  27732. markerAttribs,
  27733. pointAttribs,
  27734. pointAttribsAnimation,
  27735. hasMarkers = (markerOptions && series.markerAttribs),
  27736. newSymbol;
  27737. state = state || ''; // empty string
  27738. if (
  27739. // already has this state
  27740. (state === point.state && !move) ||
  27741. // selected points don't respond to hover
  27742. (point.selected && state !== 'select') ||
  27743. // series' state options is disabled
  27744. (stateOptions.enabled === false) ||
  27745. // general point marker's state options is disabled
  27746. (state && (stateDisabled ||
  27747. (normalDisabled &&
  27748. markerStateOptions.enabled === false))) ||
  27749. // individual point marker's state options is disabled
  27750. (state &&
  27751. pointMarker.states &&
  27752. pointMarker.states[state] &&
  27753. pointMarker.states[state].enabled === false) // #1610
  27754. ) {
  27755. return;
  27756. }
  27757. point.state = state;
  27758. if (hasMarkers) {
  27759. markerAttribs = series.markerAttribs(point, state);
  27760. }
  27761. // Apply hover styles to the existing point
  27762. // Prevent from dummy null points (#14966)
  27763. if (point.graphic && !point.hasDummyGraphic) {
  27764. if (previousState) {
  27765. point.graphic.removeClass('highcharts-point-' + previousState);
  27766. }
  27767. if (state) {
  27768. point.graphic.addClass('highcharts-point-' + state);
  27769. }
  27770. if (!chart.styledMode) {
  27771. pointAttribs = series.pointAttribs(point, state);
  27772. pointAttribsAnimation = pick(chart.options.chart.animation, stateOptions.animation);
  27773. // Some inactive points (e.g. slices in pie) should apply
  27774. // oppacity also for it's labels
  27775. if (series.options.inactiveOtherPoints && isNumber(pointAttribs.opacity)) {
  27776. (point.dataLabels || []).forEach(function (label) {
  27777. if (label) {
  27778. label.animate({
  27779. opacity: pointAttribs.opacity
  27780. }, pointAttribsAnimation);
  27781. }
  27782. });
  27783. if (point.connector) {
  27784. point.connector.animate({
  27785. opacity: pointAttribs.opacity
  27786. }, pointAttribsAnimation);
  27787. }
  27788. }
  27789. point.graphic.animate(pointAttribs, pointAttribsAnimation);
  27790. }
  27791. if (markerAttribs) {
  27792. point.graphic.animate(markerAttribs, pick(
  27793. // Turn off globally:
  27794. chart.options.chart.animation, markerStateOptions.animation, markerOptions.animation));
  27795. }
  27796. // Zooming in from a range with no markers to a range with markers
  27797. if (stateMarkerGraphic) {
  27798. stateMarkerGraphic.hide();
  27799. }
  27800. }
  27801. else {
  27802. // if a graphic is not applied to each point in the normal state,
  27803. // create a shared graphic for the hover state
  27804. if (state && markerStateOptions) {
  27805. newSymbol = pointMarker.symbol || series.symbol;
  27806. // If the point has another symbol than the previous one, throw
  27807. // away the state marker graphic and force a new one (#1459)
  27808. if (stateMarkerGraphic &&
  27809. stateMarkerGraphic.currentSymbol !== newSymbol) {
  27810. stateMarkerGraphic = stateMarkerGraphic.destroy();
  27811. }
  27812. // Add a new state marker graphic
  27813. if (markerAttribs) {
  27814. if (!stateMarkerGraphic) {
  27815. if (newSymbol) {
  27816. series.stateMarkerGraphic = stateMarkerGraphic =
  27817. chart.renderer
  27818. .symbol(newSymbol, markerAttribs.x, markerAttribs.y, markerAttribs.width, markerAttribs.height)
  27819. .add(series.markerGroup);
  27820. stateMarkerGraphic.currentSymbol = newSymbol;
  27821. }
  27822. // Move the existing graphic
  27823. }
  27824. else {
  27825. stateMarkerGraphic[move ? 'animate' : 'attr']({
  27826. x: markerAttribs.x,
  27827. y: markerAttribs.y
  27828. });
  27829. }
  27830. }
  27831. if (!chart.styledMode && stateMarkerGraphic) {
  27832. stateMarkerGraphic.attr(series.pointAttribs(point, state));
  27833. }
  27834. }
  27835. if (stateMarkerGraphic) {
  27836. stateMarkerGraphic[state && point.isInside ? 'show' : 'hide'](); // #2450
  27837. stateMarkerGraphic.element.point = point; // #4310
  27838. }
  27839. }
  27840. // Show me your halo
  27841. haloOptions = stateOptions.halo;
  27842. var markerGraphic = (point.graphic || stateMarkerGraphic);
  27843. var markerVisibility = (markerGraphic && markerGraphic.visibility || 'inherit');
  27844. if (haloOptions &&
  27845. haloOptions.size &&
  27846. markerGraphic &&
  27847. markerVisibility !== 'hidden' &&
  27848. !point.isCluster) {
  27849. if (!halo) {
  27850. series.halo = halo = chart.renderer.path()
  27851. // #5818, #5903, #6705
  27852. .add(markerGraphic.parentGroup);
  27853. }
  27854. halo.show()[move ? 'animate' : 'attr']({
  27855. d: point.haloPath(haloOptions.size)
  27856. });
  27857. halo.attr({
  27858. 'class': 'highcharts-halo highcharts-color-' +
  27859. pick(point.colorIndex, series.colorIndex) +
  27860. (point.className ? ' ' + point.className : ''),
  27861. 'visibility': markerVisibility,
  27862. 'zIndex': -1 // #4929, #8276
  27863. });
  27864. halo.point = point; // #6055
  27865. if (!chart.styledMode) {
  27866. halo.attr(extend({
  27867. 'fill': point.color || series.color,
  27868. 'fill-opacity': haloOptions.opacity
  27869. }, AST.filterUserAttributes(haloOptions.attributes || {})));
  27870. }
  27871. }
  27872. else if (halo && halo.point && halo.point.haloPath) {
  27873. // Animate back to 0 on the current halo point (#6055)
  27874. halo.animate({ d: halo.point.haloPath(0) }, null,
  27875. // Hide after unhovering. The `complete` callback runs in the
  27876. // halo's context (#7681).
  27877. halo.hide);
  27878. }
  27879. fireEvent(point, 'afterSetState', { state: state });
  27880. };
  27881. /**
  27882. * Get the path definition for the halo, which is usually a shadow-like
  27883. * circle around the currently hovered point.
  27884. *
  27885. * @function Highcharts.Point#haloPath
  27886. *
  27887. * @param {number} size
  27888. * The radius of the circular halo.
  27889. *
  27890. * @return {Highcharts.SVGPathArray}
  27891. * The path definition.
  27892. */
  27893. Point.prototype.haloPath = function (size) {
  27894. var series = this.series,
  27895. chart = series.chart;
  27896. return chart.renderer.symbols.circle(Math.floor(this.plotX) - size, this.plotY - size, size * 2, size * 2);
  27897. };
  27898. return Point;
  27899. }());
  27900. H.Point = Point;
  27901. return Point;
  27902. });
  27903. _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) {
  27904. /* *
  27905. *
  27906. * (c) 2010-2021 Torstein Honsi
  27907. *
  27908. * License: www.highcharts.com/license
  27909. *
  27910. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  27911. *
  27912. * */
  27913. var animObject = A.animObject,
  27914. setAnimation = A.setAnimation;
  27915. var format = F.format;
  27916. var isFirefox = H.isFirefox,
  27917. marginNames = H.marginNames,
  27918. win = H.win;
  27919. var addEvent = U.addEvent,
  27920. createElement = U.createElement,
  27921. css = U.css,
  27922. defined = U.defined,
  27923. discardElement = U.discardElement,
  27924. find = U.find,
  27925. fireEvent = U.fireEvent,
  27926. isNumber = U.isNumber,
  27927. merge = U.merge,
  27928. pick = U.pick,
  27929. relativeLength = U.relativeLength,
  27930. stableSort = U.stableSort,
  27931. syncTimeout = U.syncTimeout,
  27932. wrap = U.wrap;
  27933. /**
  27934. * Gets fired when the legend item belonging to a point is clicked. The default
  27935. * action is to toggle the visibility of the point. This can be prevented by
  27936. * returning `false` or calling `event.preventDefault()`.
  27937. *
  27938. * @callback Highcharts.PointLegendItemClickCallbackFunction
  27939. *
  27940. * @param {Highcharts.Point} this
  27941. * The point on which the event occured.
  27942. *
  27943. * @param {Highcharts.PointLegendItemClickEventObject} event
  27944. * The event that occured.
  27945. */
  27946. /**
  27947. * Information about the legend click event.
  27948. *
  27949. * @interface Highcharts.PointLegendItemClickEventObject
  27950. */ /**
  27951. * Related browser event.
  27952. * @name Highcharts.PointLegendItemClickEventObject#browserEvent
  27953. * @type {Highcharts.PointerEvent}
  27954. */ /**
  27955. * Prevent the default action of toggle the visibility of the point.
  27956. * @name Highcharts.PointLegendItemClickEventObject#preventDefault
  27957. * @type {Function}
  27958. */ /**
  27959. * Related point.
  27960. * @name Highcharts.PointLegendItemClickEventObject#target
  27961. * @type {Highcharts.Point}
  27962. */ /**
  27963. * Event type.
  27964. * @name Highcharts.PointLegendItemClickEventObject#type
  27965. * @type {"legendItemClick"}
  27966. */
  27967. /**
  27968. * Gets fired when the legend item belonging to a series is clicked. The default
  27969. * action is to toggle the visibility of the series. This can be prevented by
  27970. * returning `false` or calling `event.preventDefault()`.
  27971. *
  27972. * @callback Highcharts.SeriesLegendItemClickCallbackFunction
  27973. *
  27974. * @param {Highcharts.Series} this
  27975. * The series where the event occured.
  27976. *
  27977. * @param {Highcharts.SeriesLegendItemClickEventObject} event
  27978. * The event that occured.
  27979. */
  27980. /**
  27981. * Information about the legend click event.
  27982. *
  27983. * @interface Highcharts.SeriesLegendItemClickEventObject
  27984. */ /**
  27985. * Related browser event.
  27986. * @name Highcharts.SeriesLegendItemClickEventObject#browserEvent
  27987. * @type {Highcharts.PointerEvent}
  27988. */ /**
  27989. * Prevent the default action of toggle the visibility of the series.
  27990. * @name Highcharts.SeriesLegendItemClickEventObject#preventDefault
  27991. * @type {Function}
  27992. */ /**
  27993. * Related series.
  27994. * @name Highcharts.SeriesLegendItemClickEventObject#target
  27995. * @type {Highcharts.Series}
  27996. */ /**
  27997. * Event type.
  27998. * @name Highcharts.SeriesLegendItemClickEventObject#type
  27999. * @type {"legendItemClick"}
  28000. */
  28001. /* eslint-disable no-invalid-this, valid-jsdoc */
  28002. /**
  28003. * The overview of the chart's series. The legend object is instanciated
  28004. * internally in the chart constructor, and is available from the `chart.legend`
  28005. * property. Each chart has only one legend.
  28006. *
  28007. * @class
  28008. * @name Highcharts.Legend
  28009. *
  28010. * @param {Highcharts.Chart} chart
  28011. * The chart instance.
  28012. *
  28013. * @param {Highcharts.LegendOptions} options
  28014. * Legend options.
  28015. */
  28016. var Legend = /** @class */ (function () {
  28017. /* *
  28018. *
  28019. * Constructors
  28020. *
  28021. * */
  28022. function Legend(chart, options) {
  28023. /* *
  28024. *
  28025. * Properties
  28026. *
  28027. * */
  28028. this.allItems = [];
  28029. this.box = void 0;
  28030. this.contentGroup = void 0;
  28031. this.display = false;
  28032. this.group = void 0;
  28033. this.initialItemY = 0;
  28034. this.itemHeight = 0;
  28035. this.itemMarginBottom = 0;
  28036. this.itemMarginTop = 0;
  28037. this.itemX = 0;
  28038. this.itemY = 0;
  28039. this.lastItemY = 0;
  28040. this.lastLineHeight = 0;
  28041. this.legendHeight = 0;
  28042. this.legendWidth = 0;
  28043. this.maxItemWidth = 0;
  28044. this.maxLegendWidth = 0;
  28045. this.offsetWidth = 0;
  28046. this.options = {};
  28047. this.padding = 0;
  28048. this.pages = [];
  28049. this.proximate = false;
  28050. this.scrollGroup = void 0;
  28051. this.symbolHeight = 0;
  28052. this.symbolWidth = 0;
  28053. this.titleHeight = 0;
  28054. this.totalItemWidth = 0;
  28055. this.widthOption = 0;
  28056. this.chart = chart;
  28057. this.init(chart, options);
  28058. }
  28059. /* *
  28060. *
  28061. * Functions
  28062. *
  28063. * */
  28064. /**
  28065. * Initialize the legend.
  28066. *
  28067. * @private
  28068. * @function Highcharts.Legend#init
  28069. *
  28070. * @param {Highcharts.Chart} chart
  28071. * The chart instance.
  28072. *
  28073. * @param {Highcharts.LegendOptions} options
  28074. * Legend options.
  28075. */
  28076. Legend.prototype.init = function (chart, options) {
  28077. /**
  28078. * Chart of this legend.
  28079. *
  28080. * @readonly
  28081. * @name Highcharts.Legend#chart
  28082. * @type {Highcharts.Chart}
  28083. */
  28084. this.chart = chart;
  28085. this.setOptions(options);
  28086. if (options.enabled) {
  28087. // Render it
  28088. this.render();
  28089. // move checkboxes
  28090. addEvent(this.chart, 'endResize', function () {
  28091. this.legend.positionCheckboxes();
  28092. });
  28093. if (this.proximate) {
  28094. this.unchartrender = addEvent(this.chart, 'render', function () {
  28095. this.legend.proximatePositions();
  28096. this.legend.positionItems();
  28097. });
  28098. }
  28099. else if (this.unchartrender) {
  28100. this.unchartrender();
  28101. }
  28102. }
  28103. };
  28104. /**
  28105. * @private
  28106. * @function Highcharts.Legend#setOptions
  28107. * @param {Highcharts.LegendOptions} options
  28108. */
  28109. Legend.prototype.setOptions = function (options) {
  28110. var padding = pick(options.padding, 8);
  28111. /**
  28112. * Legend options.
  28113. *
  28114. * @readonly
  28115. * @name Highcharts.Legend#options
  28116. * @type {Highcharts.LegendOptions}
  28117. */
  28118. this.options = options;
  28119. if (!this.chart.styledMode) {
  28120. this.itemStyle = options.itemStyle;
  28121. this.itemHiddenStyle = merge(this.itemStyle, options.itemHiddenStyle);
  28122. }
  28123. this.itemMarginTop = options.itemMarginTop || 0;
  28124. this.itemMarginBottom = options.itemMarginBottom || 0;
  28125. this.padding = padding;
  28126. this.initialItemY = padding - 5; // 5 is pixels above the text
  28127. this.symbolWidth = pick(options.symbolWidth, 16);
  28128. this.pages = [];
  28129. this.proximate = options.layout === 'proximate' && !this.chart.inverted;
  28130. this.baseline = void 0; // #12705: baseline has to be reset on every update
  28131. };
  28132. /**
  28133. * Update the legend with new options. Equivalent to running `chart.update`
  28134. * with a legend configuration option.
  28135. *
  28136. * @sample highcharts/legend/legend-update/
  28137. * Legend update
  28138. *
  28139. * @function Highcharts.Legend#update
  28140. *
  28141. * @param {Highcharts.LegendOptions} options
  28142. * Legend options.
  28143. *
  28144. * @param {boolean} [redraw=true]
  28145. * Whether to redraw the chart after the axis is altered. If doing more
  28146. * operations on the chart, it is a good idea to set redraw to false and
  28147. * call {@link Chart#redraw} after. Whether to redraw the chart.
  28148. *
  28149. * @fires Highcharts.Legends#event:afterUpdate
  28150. */
  28151. Legend.prototype.update = function (options, redraw) {
  28152. var chart = this.chart;
  28153. this.setOptions(merge(true, this.options, options));
  28154. this.destroy();
  28155. chart.isDirtyLegend = chart.isDirtyBox = true;
  28156. if (pick(redraw, true)) {
  28157. chart.redraw();
  28158. }
  28159. fireEvent(this, 'afterUpdate');
  28160. };
  28161. /**
  28162. * Set the colors for the legend item.
  28163. *
  28164. * @private
  28165. * @function Highcharts.Legend#colorizeItem
  28166. * @param {Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series} item
  28167. * A Series or Point instance
  28168. * @param {boolean} [visible=false]
  28169. * Dimmed or colored
  28170. *
  28171. * @todo
  28172. * Make events official: Fires the event `afterColorizeItem`.
  28173. */
  28174. Legend.prototype.colorizeItem = function (item, visible) {
  28175. item.legendGroup[visible ? 'removeClass' : 'addClass']('highcharts-legend-item-hidden');
  28176. if (!this.chart.styledMode) {
  28177. var legend = this,
  28178. options = legend.options,
  28179. legendItem = item.legendItem,
  28180. legendLine = item.legendLine,
  28181. legendSymbol = item.legendSymbol,
  28182. hiddenColor = legend.itemHiddenStyle.color,
  28183. textColor = visible ?
  28184. options.itemStyle.color :
  28185. hiddenColor,
  28186. symbolColor = visible ?
  28187. (item.color || hiddenColor) :
  28188. hiddenColor,
  28189. markerOptions = item.options && item.options.marker,
  28190. symbolAttr = { fill: symbolColor };
  28191. if (legendItem) {
  28192. legendItem.css({
  28193. fill: textColor,
  28194. color: textColor // #1553, oldIE
  28195. });
  28196. }
  28197. if (legendLine) {
  28198. legendLine.attr({ stroke: symbolColor });
  28199. }
  28200. if (legendSymbol) {
  28201. // Apply marker options
  28202. if (markerOptions && legendSymbol.isMarker) { // #585
  28203. symbolAttr = item.pointAttribs();
  28204. if (!visible) {
  28205. // #6769
  28206. symbolAttr.stroke = symbolAttr.fill = hiddenColor;
  28207. }
  28208. }
  28209. legendSymbol.attr(symbolAttr);
  28210. }
  28211. }
  28212. fireEvent(this, 'afterColorizeItem', { item: item, visible: visible });
  28213. };
  28214. /**
  28215. * @private
  28216. * @function Highcharts.Legend#positionItems
  28217. */
  28218. Legend.prototype.positionItems = function () {
  28219. // Now that the legend width and height are established, put the items
  28220. // in the final position
  28221. this.allItems.forEach(this.positionItem, this);
  28222. if (!this.chart.isResizing) {
  28223. this.positionCheckboxes();
  28224. }
  28225. };
  28226. /**
  28227. * Position the legend item.
  28228. *
  28229. * @private
  28230. * @function Highcharts.Legend#positionItem
  28231. * @param {Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series} item
  28232. * The item to position
  28233. */
  28234. Legend.prototype.positionItem = function (item) {
  28235. var _this = this;
  28236. var legend = this,
  28237. options = legend.options,
  28238. symbolPadding = options.symbolPadding,
  28239. ltr = !options.rtl,
  28240. legendItemPos = item._legendItemPos,
  28241. itemX = legendItemPos[0],
  28242. itemY = legendItemPos[1],
  28243. checkbox = item.checkbox,
  28244. legendGroup = item.legendGroup;
  28245. if (legendGroup && legendGroup.element) {
  28246. var attribs = {
  28247. translateX: ltr ?
  28248. itemX :
  28249. legend.legendWidth - itemX - 2 * symbolPadding - 4,
  28250. translateY: itemY
  28251. };
  28252. var complete = function () {
  28253. fireEvent(_this, 'afterPositionItem', { item: item });
  28254. };
  28255. if (defined(legendGroup.translateY)) {
  28256. legendGroup.animate(attribs, void 0, complete);
  28257. }
  28258. else {
  28259. legendGroup.attr(attribs);
  28260. complete();
  28261. }
  28262. }
  28263. if (checkbox) {
  28264. checkbox.x = itemX;
  28265. checkbox.y = itemY;
  28266. }
  28267. };
  28268. /**
  28269. * Destroy a single legend item, used internally on removing series items.
  28270. *
  28271. * @private
  28272. * @function Highcharts.Legend#destroyItem
  28273. * @param {Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series} item
  28274. * The item to remove
  28275. */
  28276. Legend.prototype.destroyItem = function (item) {
  28277. var checkbox = item.checkbox;
  28278. // destroy SVG elements
  28279. ['legendItem', 'legendLine', 'legendSymbol', 'legendGroup'].forEach(function (key) {
  28280. if (item[key]) {
  28281. item[key] = item[key].destroy();
  28282. }
  28283. });
  28284. if (checkbox) {
  28285. discardElement(item.checkbox);
  28286. }
  28287. };
  28288. /**
  28289. * Destroy the legend. Used internally. To reflow objects, `chart.redraw`
  28290. * must be called after destruction.
  28291. *
  28292. * @private
  28293. * @function Highcharts.Legend#destroy
  28294. */
  28295. Legend.prototype.destroy = function () {
  28296. /**
  28297. * @private
  28298. * @param {string} key
  28299. * @return {void}
  28300. */
  28301. function destroyItems(key) {
  28302. if (this[key]) {
  28303. this[key] = this[key].destroy();
  28304. }
  28305. }
  28306. // Destroy items
  28307. this.getAllItems().forEach(function (item) {
  28308. ['legendItem', 'legendGroup'].forEach(destroyItems, item);
  28309. });
  28310. // Destroy legend elements
  28311. [
  28312. 'clipRect',
  28313. 'up',
  28314. 'down',
  28315. 'pager',
  28316. 'nav',
  28317. 'box',
  28318. 'title',
  28319. 'group'
  28320. ].forEach(destroyItems, this);
  28321. this.display = null; // Reset in .render on update.
  28322. };
  28323. /**
  28324. * Position the checkboxes after the width is determined.
  28325. *
  28326. * @private
  28327. * @function Highcharts.Legend#positionCheckboxes
  28328. */
  28329. Legend.prototype.positionCheckboxes = function () {
  28330. var alignAttr = this.group && this.group.alignAttr,
  28331. translateY,
  28332. clipHeight = this.clipHeight || this.legendHeight,
  28333. titleHeight = this.titleHeight;
  28334. if (alignAttr) {
  28335. translateY = alignAttr.translateY;
  28336. this.allItems.forEach(function (item) {
  28337. var checkbox = item.checkbox,
  28338. top;
  28339. if (checkbox) {
  28340. top = translateY + titleHeight + checkbox.y +
  28341. (this.scrollOffset || 0) + 3;
  28342. css(checkbox, {
  28343. left: (alignAttr.translateX + item.checkboxOffset +
  28344. checkbox.x - 20) + 'px',
  28345. top: top + 'px',
  28346. display: this.proximate || (top > translateY - 6 &&
  28347. top < translateY + clipHeight - 6) ?
  28348. '' :
  28349. 'none'
  28350. });
  28351. }
  28352. }, this);
  28353. }
  28354. };
  28355. /**
  28356. * Render the legend title on top of the legend.
  28357. *
  28358. * @private
  28359. * @function Highcharts.Legend#renderTitle
  28360. */
  28361. Legend.prototype.renderTitle = function () {
  28362. var options = this.options,
  28363. padding = this.padding,
  28364. titleOptions = options.title,
  28365. titleHeight = 0,
  28366. bBox;
  28367. if (titleOptions.text) {
  28368. if (!this.title) {
  28369. /**
  28370. * SVG element of the legend title.
  28371. *
  28372. * @readonly
  28373. * @name Highcharts.Legend#title
  28374. * @type {Highcharts.SVGElement}
  28375. */
  28376. this.title = this.chart.renderer.label(titleOptions.text, padding - 3, padding - 4, null, null, null, options.useHTML, null, 'legend-title')
  28377. .attr({ zIndex: 1 });
  28378. if (!this.chart.styledMode) {
  28379. this.title.css(titleOptions.style);
  28380. }
  28381. this.title.add(this.group);
  28382. }
  28383. // Set the max title width (#7253)
  28384. if (!titleOptions.width) {
  28385. this.title.css({
  28386. width: this.maxLegendWidth + 'px'
  28387. });
  28388. }
  28389. bBox = this.title.getBBox();
  28390. titleHeight = bBox.height;
  28391. this.offsetWidth = bBox.width; // #1717
  28392. this.contentGroup.attr({ translateY: titleHeight });
  28393. }
  28394. this.titleHeight = titleHeight;
  28395. };
  28396. /**
  28397. * Set the legend item text.
  28398. *
  28399. * @function Highcharts.Legend#setText
  28400. * @param {Highcharts.Point|Highcharts.Series} item
  28401. * The item for which to update the text in the legend.
  28402. */
  28403. Legend.prototype.setText = function (item) {
  28404. var options = this.options;
  28405. item.legendItem.attr({
  28406. text: options.labelFormat ?
  28407. format(options.labelFormat, item, this.chart) :
  28408. options.labelFormatter.call(item)
  28409. });
  28410. };
  28411. /**
  28412. * Render a single specific legend item. Called internally from the `render`
  28413. * function.
  28414. *
  28415. * @private
  28416. * @function Highcharts.Legend#renderItem
  28417. * @param {Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series} item
  28418. * The item to render.
  28419. */
  28420. Legend.prototype.renderItem = function (item) {
  28421. var legend = this,
  28422. chart = legend.chart,
  28423. renderer = chart.renderer,
  28424. options = legend.options,
  28425. horizontal = options.layout === 'horizontal',
  28426. symbolWidth = legend.symbolWidth,
  28427. symbolPadding = options.symbolPadding || 0,
  28428. itemStyle = legend.itemStyle,
  28429. itemHiddenStyle = legend.itemHiddenStyle,
  28430. itemDistance = horizontal ? pick(options.itemDistance, 20) : 0,
  28431. ltr = !options.rtl,
  28432. bBox,
  28433. li = item.legendItem,
  28434. isSeries = !item.series,
  28435. series = !isSeries && item.series.drawLegendSymbol ?
  28436. item.series :
  28437. item,
  28438. seriesOptions = series.options,
  28439. showCheckbox = legend.createCheckboxForItem &&
  28440. seriesOptions &&
  28441. seriesOptions.showCheckbox,
  28442. // full width minus text width
  28443. itemExtraWidth = symbolWidth + symbolPadding +
  28444. itemDistance + (showCheckbox ? 20 : 0),
  28445. useHTML = options.useHTML,
  28446. itemClassName = item.options.className;
  28447. if (!li) { // generate it once, later move it
  28448. // Generate the group box, a group to hold the symbol and text. Text
  28449. // is to be appended in Legend class.
  28450. item.legendGroup = renderer
  28451. .g('legend-item')
  28452. .addClass('highcharts-' + series.type + '-series ' +
  28453. 'highcharts-color-' + item.colorIndex +
  28454. (itemClassName ? ' ' + itemClassName : '') +
  28455. (isSeries ?
  28456. ' highcharts-series-' + item.index :
  28457. ''))
  28458. .attr({ zIndex: 1 })
  28459. .add(legend.scrollGroup);
  28460. // Generate the list item text and add it to the group
  28461. item.legendItem = li = renderer.text('', ltr ?
  28462. symbolWidth + symbolPadding :
  28463. -symbolPadding, legend.baseline || 0, useHTML);
  28464. if (!chart.styledMode) {
  28465. // merge to prevent modifying original (#1021)
  28466. li.css(merge(item.visible ?
  28467. itemStyle :
  28468. itemHiddenStyle));
  28469. }
  28470. li
  28471. .attr({
  28472. align: ltr ? 'left' : 'right',
  28473. zIndex: 2
  28474. })
  28475. .add(item.legendGroup);
  28476. // Get the baseline for the first item - the font size is equal for
  28477. // all
  28478. if (!legend.baseline) {
  28479. legend.fontMetrics = renderer.fontMetrics(chart.styledMode ? 12 : itemStyle.fontSize, li);
  28480. legend.baseline =
  28481. legend.fontMetrics.f + 3 + legend.itemMarginTop;
  28482. li.attr('y', legend.baseline);
  28483. legend.symbolHeight =
  28484. options.symbolHeight || legend.fontMetrics.f;
  28485. if (options.squareSymbol) {
  28486. legend.symbolWidth = pick(options.symbolWidth, Math.max(legend.symbolHeight, 16));
  28487. itemExtraWidth = legend.symbolWidth + symbolPadding +
  28488. itemDistance + (showCheckbox ? 20 : 0);
  28489. if (ltr) {
  28490. li.attr('x', legend.symbolWidth + symbolPadding);
  28491. }
  28492. }
  28493. }
  28494. // Draw the legend symbol inside the group box
  28495. series.drawLegendSymbol(legend, item);
  28496. if (legend.setItemEvents) {
  28497. legend.setItemEvents(item, li, useHTML);
  28498. }
  28499. }
  28500. // Add the HTML checkbox on top
  28501. if (showCheckbox && !item.checkbox && legend.createCheckboxForItem) {
  28502. legend.createCheckboxForItem(item);
  28503. }
  28504. // Colorize the items
  28505. legend.colorizeItem(item, item.visible);
  28506. // Take care of max width and text overflow (#6659)
  28507. if (chart.styledMode || !itemStyle.width) {
  28508. li.css({
  28509. width: ((options.itemWidth ||
  28510. legend.widthOption ||
  28511. chart.spacingBox.width) - itemExtraWidth) + 'px'
  28512. });
  28513. }
  28514. // Always update the text
  28515. legend.setText(item);
  28516. // calculate the positions for the next line
  28517. bBox = li.getBBox();
  28518. item.itemWidth = item.checkboxOffset =
  28519. options.itemWidth ||
  28520. item.legendItemWidth ||
  28521. bBox.width + itemExtraWidth;
  28522. legend.maxItemWidth = Math.max(legend.maxItemWidth, item.itemWidth);
  28523. legend.totalItemWidth += item.itemWidth;
  28524. legend.itemHeight = item.itemHeight = Math.round(item.legendItemHeight || bBox.height || legend.symbolHeight);
  28525. };
  28526. /**
  28527. * Get the position of the item in the layout. We now know the
  28528. * maxItemWidth from the previous loop.
  28529. *
  28530. * @private
  28531. * @function Highcharts.Legend#layoutItem
  28532. * @param {Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series} item
  28533. */
  28534. Legend.prototype.layoutItem = function (item) {
  28535. var options = this.options,
  28536. padding = this.padding,
  28537. horizontal = options.layout === 'horizontal',
  28538. itemHeight = item.itemHeight,
  28539. itemMarginBottom = this.itemMarginBottom,
  28540. itemMarginTop = this.itemMarginTop,
  28541. itemDistance = horizontal ? pick(options.itemDistance, 20) : 0,
  28542. maxLegendWidth = this.maxLegendWidth,
  28543. itemWidth = (options.alignColumns &&
  28544. this.totalItemWidth > maxLegendWidth) ?
  28545. this.maxItemWidth :
  28546. item.itemWidth;
  28547. // If the item exceeds the width, start a new line
  28548. if (horizontal &&
  28549. this.itemX - padding + itemWidth > maxLegendWidth) {
  28550. this.itemX = padding;
  28551. if (this.lastLineHeight) { // Not for the first line (#10167)
  28552. this.itemY += (itemMarginTop +
  28553. this.lastLineHeight +
  28554. itemMarginBottom);
  28555. }
  28556. this.lastLineHeight = 0; // reset for next line (#915, #3976)
  28557. }
  28558. // Set the edge positions
  28559. this.lastItemY = itemMarginTop + this.itemY + itemMarginBottom;
  28560. this.lastLineHeight = Math.max(// #915
  28561. itemHeight, this.lastLineHeight);
  28562. // cache the position of the newly generated or reordered items
  28563. item._legendItemPos = [this.itemX, this.itemY];
  28564. // advance
  28565. if (horizontal) {
  28566. this.itemX += itemWidth;
  28567. }
  28568. else {
  28569. this.itemY +=
  28570. itemMarginTop + itemHeight + itemMarginBottom;
  28571. this.lastLineHeight = itemHeight;
  28572. }
  28573. // the width of the widest item
  28574. this.offsetWidth = this.widthOption || Math.max((horizontal ? this.itemX - padding - (item.checkbox ?
  28575. // decrease by itemDistance only when no checkbox #4853
  28576. 0 :
  28577. itemDistance) : itemWidth) + padding, this.offsetWidth);
  28578. };
  28579. /**
  28580. * Get all items, which is one item per series for most series and one
  28581. * item per point for pie series and its derivatives. Fires the event
  28582. * `afterGetAllItems`.
  28583. *
  28584. * @private
  28585. * @function Highcharts.Legend#getAllItems
  28586. * @return {Array<(Highcharts.BubbleLegend|Highcharts.Point|Highcharts.Series)>}
  28587. * The current items in the legend.
  28588. * @fires Highcharts.Legend#event:afterGetAllItems
  28589. */
  28590. Legend.prototype.getAllItems = function () {
  28591. var allItems = [];
  28592. this.chart.series.forEach(function (series) {
  28593. var seriesOptions = series && series.options;
  28594. // Handle showInLegend. If the series is linked to another series,
  28595. // defaults to false.
  28596. if (series && pick(seriesOptions.showInLegend, !defined(seriesOptions.linkedTo) ? void 0 : false, true)) {
  28597. // Use points or series for the legend item depending on
  28598. // legendType
  28599. allItems = allItems.concat(series.legendItems ||
  28600. (seriesOptions.legendType === 'point' ?
  28601. series.data :
  28602. series));
  28603. }
  28604. });
  28605. fireEvent(this, 'afterGetAllItems', { allItems: allItems });
  28606. return allItems;
  28607. };
  28608. /**
  28609. * Get a short, three letter string reflecting the alignment and layout.
  28610. *
  28611. * @private
  28612. * @function Highcharts.Legend#getAlignment
  28613. * @return {string}
  28614. * The alignment, empty string if floating
  28615. */
  28616. Legend.prototype.getAlignment = function () {
  28617. var options = this.options;
  28618. // Use the first letter of each alignment option in order to detect
  28619. // the side. (#4189 - use charAt(x) notation instead of [x] for IE7)
  28620. if (this.proximate) {
  28621. return options.align.charAt(0) + 'tv';
  28622. }
  28623. return options.floating ? '' : (options.align.charAt(0) +
  28624. options.verticalAlign.charAt(0) +
  28625. options.layout.charAt(0));
  28626. };
  28627. /**
  28628. * Adjust the chart margins by reserving space for the legend on only one
  28629. * side of the chart. If the position is set to a corner, top or bottom is
  28630. * reserved for horizontal legends and left or right for vertical ones.
  28631. *
  28632. * @private
  28633. * @function Highcharts.Legend#adjustMargins
  28634. * @param {Array<number>} margin
  28635. * @param {Array<number>} spacing
  28636. */
  28637. Legend.prototype.adjustMargins = function (margin, spacing) {
  28638. var chart = this.chart,
  28639. options = this.options,
  28640. alignment = this.getAlignment();
  28641. if (alignment) {
  28642. ([
  28643. /(lth|ct|rth)/,
  28644. /(rtv|rm|rbv)/,
  28645. /(rbh|cb|lbh)/,
  28646. /(lbv|lm|ltv)/
  28647. ]).forEach(function (alignments, side) {
  28648. if (alignments.test(alignment) && !defined(margin[side])) {
  28649. // Now we have detected on which side of the chart we should
  28650. // reserve space for the legend
  28651. chart[marginNames[side]] = Math.max(chart[marginNames[side]], (chart.legend[(side + 1) % 2 ? 'legendHeight' : 'legendWidth'] +
  28652. [1, -1, -1, 1][side] * options[(side % 2) ? 'x' : 'y'] +
  28653. pick(options.margin, 12) +
  28654. spacing[side] +
  28655. (chart.titleOffset[side] || 0)));
  28656. }
  28657. });
  28658. }
  28659. };
  28660. /**
  28661. * @private
  28662. * @function Highcharts.Legend#proximatePositions
  28663. */
  28664. Legend.prototype.proximatePositions = function () {
  28665. var chart = this.chart,
  28666. boxes = [],
  28667. alignLeft = this.options.align === 'left';
  28668. this.allItems.forEach(function (item) {
  28669. var lastPoint,
  28670. height,
  28671. useFirstPoint = alignLeft,
  28672. target,
  28673. top;
  28674. if (item.yAxis) {
  28675. if (item.xAxis.options.reversed) {
  28676. useFirstPoint = !useFirstPoint;
  28677. }
  28678. if (item.points) {
  28679. lastPoint = find(useFirstPoint ?
  28680. item.points :
  28681. item.points.slice(0).reverse(), function (item) {
  28682. return isNumber(item.plotY);
  28683. });
  28684. }
  28685. height = this.itemMarginTop +
  28686. item.legendItem.getBBox().height +
  28687. this.itemMarginBottom;
  28688. top = item.yAxis.top - chart.plotTop;
  28689. if (item.visible) {
  28690. target = lastPoint ?
  28691. lastPoint.plotY :
  28692. item.yAxis.height;
  28693. target += top - 0.3 * height;
  28694. }
  28695. else {
  28696. target = top + item.yAxis.height;
  28697. }
  28698. boxes.push({
  28699. target: target,
  28700. size: height,
  28701. item: item
  28702. });
  28703. }
  28704. }, this);
  28705. H.distribute(boxes, chart.plotHeight);
  28706. boxes.forEach(function (box) {
  28707. box.item._legendItemPos[1] =
  28708. chart.plotTop - chart.spacing[0] + box.pos;
  28709. });
  28710. };
  28711. /**
  28712. * Render the legend. This method can be called both before and after
  28713. * `chart.render`. If called after, it will only rearrange items instead
  28714. * of creating new ones. Called internally on initial render and after
  28715. * redraws.
  28716. *
  28717. * @private
  28718. * @function Highcharts.Legend#render
  28719. */
  28720. Legend.prototype.render = function () {
  28721. var legend = this,
  28722. chart = legend.chart,
  28723. renderer = chart.renderer,
  28724. legendGroup = legend.group,
  28725. allItems,
  28726. display,
  28727. legendWidth,
  28728. legendHeight,
  28729. box = legend.box,
  28730. options = legend.options,
  28731. padding = legend.padding,
  28732. allowedWidth;
  28733. legend.itemX = padding;
  28734. legend.itemY = legend.initialItemY;
  28735. legend.offsetWidth = 0;
  28736. legend.lastItemY = 0;
  28737. legend.widthOption = relativeLength(options.width, chart.spacingBox.width - padding);
  28738. // Compute how wide the legend is allowed to be
  28739. allowedWidth =
  28740. chart.spacingBox.width - 2 * padding - options.x;
  28741. if (['rm', 'lm'].indexOf(legend.getAlignment().substring(0, 2)) > -1) {
  28742. allowedWidth /= 2;
  28743. }
  28744. legend.maxLegendWidth = legend.widthOption || allowedWidth;
  28745. if (!legendGroup) {
  28746. /**
  28747. * SVG group of the legend.
  28748. *
  28749. * @readonly
  28750. * @name Highcharts.Legend#group
  28751. * @type {Highcharts.SVGElement}
  28752. */
  28753. legend.group = legendGroup = renderer.g('legend')
  28754. .addClass(options.className || '')
  28755. .attr({ zIndex: 7 })
  28756. .add();
  28757. legend.contentGroup = renderer.g()
  28758. .attr({ zIndex: 1 }) // above background
  28759. .add(legendGroup);
  28760. legend.scrollGroup = renderer.g()
  28761. .add(legend.contentGroup);
  28762. }
  28763. legend.renderTitle();
  28764. // add each series or point
  28765. allItems = legend.getAllItems();
  28766. // sort by legendIndex
  28767. stableSort(allItems, function (a, b) {
  28768. return ((a.options && a.options.legendIndex) || 0) -
  28769. ((b.options && b.options.legendIndex) || 0);
  28770. });
  28771. // reversed legend
  28772. if (options.reversed) {
  28773. allItems.reverse();
  28774. }
  28775. /**
  28776. * All items for the legend, which is an array of series for most series
  28777. * and an array of points for pie series and its derivatives.
  28778. *
  28779. * @readonly
  28780. * @name Highcharts.Legend#allItems
  28781. * @type {Array<(Highcharts.Point|Highcharts.Series)>}
  28782. */
  28783. legend.allItems = allItems;
  28784. legend.display = display = !!allItems.length;
  28785. // Render the items. First we run a loop to set the text and properties
  28786. // and read all the bounding boxes. The next loop computes the item
  28787. // positions based on the bounding boxes.
  28788. legend.lastLineHeight = 0;
  28789. legend.maxItemWidth = 0;
  28790. legend.totalItemWidth = 0;
  28791. legend.itemHeight = 0;
  28792. allItems.forEach(legend.renderItem, legend);
  28793. allItems.forEach(legend.layoutItem, legend);
  28794. // Get the box
  28795. legendWidth = (legend.widthOption || legend.offsetWidth) + padding;
  28796. legendHeight = legend.lastItemY + legend.lastLineHeight +
  28797. legend.titleHeight;
  28798. legendHeight = legend.handleOverflow(legendHeight);
  28799. legendHeight += padding;
  28800. // Draw the border and/or background
  28801. if (!box) {
  28802. /**
  28803. * SVG element of the legend box.
  28804. *
  28805. * @readonly
  28806. * @name Highcharts.Legend#box
  28807. * @type {Highcharts.SVGElement}
  28808. */
  28809. legend.box = box = renderer.rect()
  28810. .addClass('highcharts-legend-box')
  28811. .attr({
  28812. r: options.borderRadius
  28813. })
  28814. .add(legendGroup);
  28815. box.isNew = true;
  28816. }
  28817. // Presentational
  28818. if (!chart.styledMode) {
  28819. box
  28820. .attr({
  28821. stroke: options.borderColor,
  28822. 'stroke-width': options.borderWidth || 0,
  28823. fill: options.backgroundColor || 'none'
  28824. })
  28825. .shadow(options.shadow);
  28826. }
  28827. if (legendWidth > 0 && legendHeight > 0) {
  28828. box[box.isNew ? 'attr' : 'animate'](box.crisp.call({}, {
  28829. x: 0,
  28830. y: 0,
  28831. width: legendWidth,
  28832. height: legendHeight
  28833. }, box.strokeWidth()));
  28834. box.isNew = false;
  28835. }
  28836. // hide the border if no items
  28837. box[display ? 'show' : 'hide']();
  28838. // Open for responsiveness
  28839. if (chart.styledMode && legendGroup.getStyle('display') === 'none') {
  28840. legendWidth = legendHeight = 0;
  28841. }
  28842. legend.legendWidth = legendWidth;
  28843. legend.legendHeight = legendHeight;
  28844. if (display) {
  28845. legend.align();
  28846. }
  28847. if (!this.proximate) {
  28848. this.positionItems();
  28849. }
  28850. fireEvent(this, 'afterRender');
  28851. };
  28852. /**
  28853. * Align the legend to chart's box.
  28854. *
  28855. * @private
  28856. * @function Highcharts.align
  28857. * @param {Highcharts.BBoxObject} alignTo
  28858. * @return {void}
  28859. */
  28860. Legend.prototype.align = function (alignTo) {
  28861. if (alignTo === void 0) { alignTo = this.chart.spacingBox; }
  28862. var chart = this.chart,
  28863. options = this.options;
  28864. // If aligning to the top and the layout is horizontal, adjust for
  28865. // the title (#7428)
  28866. var y = alignTo.y;
  28867. if (/(lth|ct|rth)/.test(this.getAlignment()) &&
  28868. chart.titleOffset[0] > 0) {
  28869. y += chart.titleOffset[0];
  28870. }
  28871. else if (/(lbh|cb|rbh)/.test(this.getAlignment()) &&
  28872. chart.titleOffset[2] > 0) {
  28873. y -= chart.titleOffset[2];
  28874. }
  28875. if (y !== alignTo.y) {
  28876. alignTo = merge(alignTo, { y: y });
  28877. }
  28878. this.group.align(merge(options, {
  28879. width: this.legendWidth,
  28880. height: this.legendHeight,
  28881. verticalAlign: this.proximate ? 'top' : options.verticalAlign
  28882. }), true, alignTo);
  28883. };
  28884. /**
  28885. * Set up the overflow handling by adding navigation with up and down arrows
  28886. * below the legend.
  28887. *
  28888. * @private
  28889. * @function Highcharts.Legend#handleOverflow
  28890. * @param {number} legendHeight
  28891. * @return {number}
  28892. */
  28893. Legend.prototype.handleOverflow = function (legendHeight) {
  28894. var legend = this,
  28895. chart = this.chart,
  28896. renderer = chart.renderer,
  28897. options = this.options,
  28898. optionsY = options.y,
  28899. alignTop = options.verticalAlign === 'top',
  28900. padding = this.padding,
  28901. spaceHeight = (chart.spacingBox.height +
  28902. (alignTop ? -optionsY : optionsY) - padding),
  28903. maxHeight = options.maxHeight,
  28904. clipHeight,
  28905. clipRect = this.clipRect,
  28906. navOptions = options.navigation,
  28907. animation = pick(navOptions.animation,
  28908. true),
  28909. arrowSize = navOptions.arrowSize || 12,
  28910. nav = this.nav,
  28911. pages = this.pages,
  28912. lastY,
  28913. allItems = this.allItems,
  28914. clipToHeight = function (height) {
  28915. if (typeof height === 'number') {
  28916. clipRect.attr({
  28917. height: height
  28918. });
  28919. }
  28920. else if (clipRect) { // Reset (#5912)
  28921. legend.clipRect = clipRect.destroy();
  28922. legend.contentGroup.clip();
  28923. }
  28924. // useHTML
  28925. if (legend.contentGroup.div) {
  28926. legend.contentGroup.div.style.clip = height ?
  28927. 'rect(' + padding + 'px,9999px,' +
  28928. (padding + height) + 'px,0)' :
  28929. 'auto';
  28930. }
  28931. }, addTracker = function (key) {
  28932. legend[key] = renderer
  28933. .circle(0, 0, arrowSize * 1.3)
  28934. .translate(arrowSize / 2, arrowSize / 2)
  28935. .add(nav);
  28936. if (!chart.styledMode) {
  28937. legend[key].attr('fill', 'rgba(0,0,0,0.0001)');
  28938. }
  28939. return legend[key];
  28940. };
  28941. // Adjust the height
  28942. if (options.layout === 'horizontal' &&
  28943. options.verticalAlign !== 'middle' &&
  28944. !options.floating) {
  28945. spaceHeight /= 2;
  28946. }
  28947. if (maxHeight) {
  28948. spaceHeight = Math.min(spaceHeight, maxHeight);
  28949. }
  28950. // Reset the legend height and adjust the clipping rectangle
  28951. pages.length = 0;
  28952. if (legendHeight &&
  28953. spaceHeight > 0 &&
  28954. legendHeight > spaceHeight &&
  28955. navOptions.enabled !== false) {
  28956. this.clipHeight = clipHeight =
  28957. Math.max(spaceHeight - 20 - this.titleHeight - padding, 0);
  28958. this.currentPage = pick(this.currentPage, 1);
  28959. this.fullHeight = legendHeight;
  28960. // Fill pages with Y positions so that the top of each a legend item
  28961. // defines the scroll top for each page (#2098)
  28962. allItems.forEach(function (item, i) {
  28963. var y = item._legendItemPos[1],
  28964. h = Math.round(item.legendItem.getBBox().height),
  28965. len = pages.length;
  28966. if (!len || (y - pages[len - 1] > clipHeight &&
  28967. (lastY || y) !== pages[len - 1])) {
  28968. pages.push(lastY || y);
  28969. len++;
  28970. }
  28971. // Keep track of which page each item is on
  28972. item.pageIx = len - 1;
  28973. if (lastY) {
  28974. allItems[i - 1].pageIx = len - 1;
  28975. }
  28976. if (i === allItems.length - 1 &&
  28977. y + h - pages[len - 1] > clipHeight &&
  28978. y !== lastY // #2617
  28979. ) {
  28980. pages.push(y);
  28981. item.pageIx = len;
  28982. }
  28983. if (y !== lastY) {
  28984. lastY = y;
  28985. }
  28986. });
  28987. // Only apply clipping if needed. Clipping causes blurred legend in
  28988. // PDF export (#1787)
  28989. if (!clipRect) {
  28990. clipRect = legend.clipRect =
  28991. renderer.clipRect(0, padding, 9999, 0);
  28992. legend.contentGroup.clip(clipRect);
  28993. }
  28994. clipToHeight(clipHeight);
  28995. // Add navigation elements
  28996. if (!nav) {
  28997. this.nav = nav = renderer.g()
  28998. .attr({ zIndex: 1 })
  28999. .add(this.group);
  29000. this.up = renderer
  29001. .symbol('triangle', 0, 0, arrowSize, arrowSize)
  29002. .add(nav);
  29003. addTracker('upTracker')
  29004. .on('click', function () {
  29005. legend.scroll(-1, animation);
  29006. });
  29007. this.pager = renderer.text('', 15, 10)
  29008. .addClass('highcharts-legend-navigation');
  29009. if (!chart.styledMode) {
  29010. this.pager.css(navOptions.style);
  29011. }
  29012. this.pager.add(nav);
  29013. this.down = renderer
  29014. .symbol('triangle-down', 0, 0, arrowSize, arrowSize)
  29015. .add(nav);
  29016. addTracker('downTracker')
  29017. .on('click', function () {
  29018. legend.scroll(1, animation);
  29019. });
  29020. }
  29021. // Set initial position
  29022. legend.scroll(0);
  29023. legendHeight = spaceHeight;
  29024. // Reset
  29025. }
  29026. else if (nav) {
  29027. clipToHeight();
  29028. this.nav = nav.destroy(); // #6322
  29029. this.scrollGroup.attr({
  29030. translateY: 1
  29031. });
  29032. this.clipHeight = 0; // #1379
  29033. }
  29034. return legendHeight;
  29035. };
  29036. /**
  29037. * Scroll the legend by a number of pages.
  29038. *
  29039. * @private
  29040. * @function Highcharts.Legend#scroll
  29041. *
  29042. * @param {number} scrollBy
  29043. * The number of pages to scroll.
  29044. *
  29045. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  29046. * Whether and how to apply animation.
  29047. *
  29048. * @return {void}
  29049. */
  29050. Legend.prototype.scroll = function (scrollBy, animation) {
  29051. var _this = this;
  29052. var chart = this.chart,
  29053. pages = this.pages,
  29054. pageCount = pages.length,
  29055. currentPage = this.currentPage + scrollBy,
  29056. clipHeight = this.clipHeight,
  29057. navOptions = this.options.navigation,
  29058. pager = this.pager,
  29059. padding = this.padding;
  29060. // When resizing while looking at the last page
  29061. if (currentPage > pageCount) {
  29062. currentPage = pageCount;
  29063. }
  29064. if (currentPage > 0) {
  29065. if (typeof animation !== 'undefined') {
  29066. setAnimation(animation, chart);
  29067. }
  29068. this.nav.attr({
  29069. translateX: padding,
  29070. translateY: clipHeight + this.padding + 7 + this.titleHeight,
  29071. visibility: 'visible'
  29072. });
  29073. [this.up, this.upTracker].forEach(function (elem) {
  29074. elem.attr({
  29075. 'class': currentPage === 1 ?
  29076. 'highcharts-legend-nav-inactive' :
  29077. 'highcharts-legend-nav-active'
  29078. });
  29079. });
  29080. pager.attr({
  29081. text: currentPage + '/' + pageCount
  29082. });
  29083. [this.down, this.downTracker].forEach(function (elem) {
  29084. elem.attr({
  29085. // adjust to text width
  29086. x: 18 + this.pager.getBBox().width,
  29087. 'class': currentPage === pageCount ?
  29088. 'highcharts-legend-nav-inactive' :
  29089. 'highcharts-legend-nav-active'
  29090. });
  29091. }, this);
  29092. if (!chart.styledMode) {
  29093. this.up
  29094. .attr({
  29095. fill: currentPage === 1 ?
  29096. navOptions.inactiveColor :
  29097. navOptions.activeColor
  29098. });
  29099. this.upTracker
  29100. .css({
  29101. cursor: currentPage === 1 ? 'default' : 'pointer'
  29102. });
  29103. this.down
  29104. .attr({
  29105. fill: currentPage === pageCount ?
  29106. navOptions.inactiveColor :
  29107. navOptions.activeColor
  29108. });
  29109. this.downTracker
  29110. .css({
  29111. cursor: currentPage === pageCount ?
  29112. 'default' :
  29113. 'pointer'
  29114. });
  29115. }
  29116. this.scrollOffset = -pages[currentPage - 1] + this.initialItemY;
  29117. this.scrollGroup.animate({
  29118. translateY: this.scrollOffset
  29119. });
  29120. this.currentPage = currentPage;
  29121. this.positionCheckboxes();
  29122. // Fire event after scroll animation is complete
  29123. var animOptions = animObject(pick(animation,
  29124. chart.renderer.globalAnimation,
  29125. true));
  29126. syncTimeout(function () {
  29127. fireEvent(_this, 'afterScroll', { currentPage: currentPage });
  29128. }, animOptions.duration);
  29129. }
  29130. };
  29131. /**
  29132. * @private
  29133. * @function Highcharts.Legend#setItemEvents
  29134. * @param {Highcharts.BubbleLegend|Point|Highcharts.Series} item
  29135. * @param {Highcharts.SVGElement} legendItem
  29136. * @param {boolean} [useHTML=false]
  29137. * @fires Highcharts.Point#event:legendItemClick
  29138. * @fires Highcharts.Series#event:legendItemClick
  29139. */
  29140. Legend.prototype.setItemEvents = function (item, legendItem, useHTML) {
  29141. var legend = this,
  29142. boxWrapper = legend.chart.renderer.boxWrapper,
  29143. isPoint = item instanceof Point,
  29144. activeClass = 'highcharts-legend-' +
  29145. (isPoint ? 'point' : 'series') + '-active',
  29146. styledMode = legend.chart.styledMode,
  29147. // When `useHTML`, the symbol is rendered in other group, so
  29148. // we need to apply events listeners to both places
  29149. legendItems = useHTML ?
  29150. [legendItem,
  29151. item.legendSymbol] :
  29152. [item.legendGroup];
  29153. // Set the events on the item group, or in case of useHTML, the item
  29154. // itself (#1249)
  29155. legendItems.forEach(function (element) {
  29156. if (element) {
  29157. element
  29158. .on('mouseover', function () {
  29159. if (item.visible) {
  29160. legend.allItems.forEach(function (inactiveItem) {
  29161. if (item !== inactiveItem) {
  29162. inactiveItem.setState('inactive', !isPoint);
  29163. }
  29164. });
  29165. }
  29166. item.setState('hover');
  29167. // A CSS class to dim or hide other than the hovered
  29168. // series.
  29169. // Works only if hovered series is visible (#10071).
  29170. if (item.visible) {
  29171. boxWrapper.addClass(activeClass);
  29172. }
  29173. if (!styledMode) {
  29174. legendItem.css(legend.options.itemHoverStyle);
  29175. }
  29176. })
  29177. .on('mouseout', function () {
  29178. if (!legend.chart.styledMode) {
  29179. legendItem.css(merge(item.visible ?
  29180. legend.itemStyle :
  29181. legend.itemHiddenStyle));
  29182. }
  29183. legend.allItems.forEach(function (inactiveItem) {
  29184. if (item !== inactiveItem) {
  29185. inactiveItem.setState('', !isPoint);
  29186. }
  29187. });
  29188. // A CSS class to dim or hide other than the hovered
  29189. // series.
  29190. boxWrapper.removeClass(activeClass);
  29191. item.setState();
  29192. })
  29193. .on('click', function (event) {
  29194. var strLegendItemClick = 'legendItemClick',
  29195. fnLegendItemClick = function () {
  29196. if (item.setVisible) {
  29197. item.setVisible();
  29198. }
  29199. // Reset inactive state
  29200. legend.allItems.forEach(function (inactiveItem) {
  29201. if (item !== inactiveItem) {
  29202. inactiveItem.setState(item.visible ? 'inactive' : '', !isPoint);
  29203. }
  29204. });
  29205. };
  29206. // A CSS class to dim or hide other than the hovered
  29207. // series. Event handling in iOS causes the activeClass
  29208. // to be added prior to click in some cases (#7418).
  29209. boxWrapper.removeClass(activeClass);
  29210. // Pass over the click/touch event. #4.
  29211. event = {
  29212. browserEvent: event
  29213. };
  29214. // click the name or symbol
  29215. if (item.firePointEvent) { // point
  29216. item.firePointEvent(strLegendItemClick, event, fnLegendItemClick);
  29217. }
  29218. else {
  29219. fireEvent(item, strLegendItemClick, event, fnLegendItemClick);
  29220. }
  29221. });
  29222. }
  29223. });
  29224. };
  29225. /**
  29226. * @private
  29227. * @function Highcharts.Legend#createCheckboxForItem
  29228. * @param {Highcharts.BubbleLegend|Point|Highcharts.Series} item
  29229. * @fires Highcharts.Series#event:checkboxClick
  29230. */
  29231. Legend.prototype.createCheckboxForItem = function (item) {
  29232. var legend = this;
  29233. item.checkbox = createElement('input', {
  29234. type: 'checkbox',
  29235. className: 'highcharts-legend-checkbox',
  29236. checked: item.selected,
  29237. defaultChecked: item.selected // required by IE7
  29238. }, legend.options.itemCheckboxStyle, legend.chart.container);
  29239. addEvent(item.checkbox, 'click', function (event) {
  29240. var target = event.target;
  29241. fireEvent(item.series || item, 'checkboxClick', {
  29242. checked: target.checked,
  29243. item: item
  29244. }, function () {
  29245. item.select();
  29246. });
  29247. });
  29248. };
  29249. return Legend;
  29250. }());
  29251. // Workaround for #2030, horizontal legend items not displaying in IE11 Preview,
  29252. // and for #2580, a similar drawing flaw in Firefox 26.
  29253. // Explore if there's a general cause for this. The problem may be related
  29254. // to nested group elements, as the legend item texts are within 4 group
  29255. // elements.
  29256. if (/Trident\/7\.0/.test(win.navigator && win.navigator.userAgent) ||
  29257. isFirefox) {
  29258. wrap(Legend.prototype, 'positionItem', function (proceed, item) {
  29259. var legend = this,
  29260. // If chart destroyed in sync, this is undefined (#2030)
  29261. runPositionItem = function () {
  29262. if (item._legendItemPos) {
  29263. proceed.call(legend,
  29264. item);
  29265. }
  29266. };
  29267. // Do it now, for export and to get checkbox placement
  29268. runPositionItem();
  29269. // Do it after to work around the core issue
  29270. if (!legend.bubbleLegend) {
  29271. setTimeout(runPositionItem);
  29272. }
  29273. });
  29274. }
  29275. H.Legend = Legend;
  29276. return H.Legend;
  29277. });
  29278. _registerModule(_modules, 'Core/Series/SeriesRegistry.js', [_modules['Core/Globals.js'], _modules['Core/DefaultOptions.js'], _modules['Core/Series/Point.js'], _modules['Core/Utilities.js']], function (H, D, Point, U) {
  29279. /* *
  29280. *
  29281. * (c) 2010-2021 Torstein Honsi
  29282. *
  29283. * License: www.highcharts.com/license
  29284. *
  29285. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  29286. *
  29287. * */
  29288. var defaultOptions = D.defaultOptions;
  29289. var error = U.error,
  29290. extendClass = U.extendClass,
  29291. merge = U.merge;
  29292. /* *
  29293. *
  29294. * Namespace
  29295. *
  29296. * */
  29297. var SeriesRegistry;
  29298. (function (SeriesRegistry) {
  29299. /* *
  29300. *
  29301. * Static Properties
  29302. *
  29303. * */
  29304. /**
  29305. * @internal
  29306. * @todo Move `Globals.seriesTypes` code to her.
  29307. */
  29308. SeriesRegistry.seriesTypes = H.seriesTypes;
  29309. /* *
  29310. *
  29311. * Static Functions
  29312. *
  29313. * */
  29314. /* eslint-disable valid-jsdoc */
  29315. /**
  29316. * Internal function to initialize an individual series.
  29317. * @private
  29318. */
  29319. function getSeries(chart, options) {
  29320. if (options === void 0) { options = {}; }
  29321. var optionsChart = chart.options.chart,
  29322. type = (options.type ||
  29323. optionsChart.type ||
  29324. optionsChart.defaultSeriesType ||
  29325. ''),
  29326. SeriesClass = SeriesRegistry.seriesTypes[type];
  29327. // No such series type
  29328. if (!SeriesRegistry) {
  29329. error(17, true, chart, { missingModuleFor: type });
  29330. }
  29331. var series = new SeriesClass();
  29332. if (typeof series.init === 'function') {
  29333. series.init(chart, options);
  29334. }
  29335. return series;
  29336. }
  29337. SeriesRegistry.getSeries = getSeries;
  29338. /**
  29339. * Registers class pattern of a series.
  29340. *
  29341. * @private
  29342. */
  29343. function registerSeriesType(seriesType, seriesClass) {
  29344. var defaultPlotOptions = defaultOptions.plotOptions || {},
  29345. seriesOptions = seriesClass.defaultOptions;
  29346. if (!seriesClass.prototype.pointClass) {
  29347. seriesClass.prototype.pointClass = Point;
  29348. }
  29349. seriesClass.prototype.type = seriesType;
  29350. if (seriesOptions) {
  29351. defaultPlotOptions[seriesType] = seriesOptions;
  29352. }
  29353. SeriesRegistry.seriesTypes[seriesType] = seriesClass;
  29354. }
  29355. SeriesRegistry.registerSeriesType = registerSeriesType;
  29356. /**
  29357. * Old factory to create new series prototypes.
  29358. *
  29359. * @deprecated
  29360. * @function Highcharts.seriesType
  29361. *
  29362. * @param {string} type
  29363. * The series type name.
  29364. *
  29365. * @param {string} parent
  29366. * The parent series type name. Use `line` to inherit from the basic
  29367. * {@link Series} object.
  29368. *
  29369. * @param {Highcharts.SeriesOptionsType|Highcharts.Dictionary<*>} options
  29370. * The additional default options that are merged with the parent's options.
  29371. *
  29372. * @param {Highcharts.Dictionary<*>} [props]
  29373. * The properties (functions and primitives) to set on the new prototype.
  29374. *
  29375. * @param {Highcharts.Dictionary<*>} [pointProps]
  29376. * Members for a series-specific extension of the {@link Point} prototype if
  29377. * needed.
  29378. *
  29379. * @return {Highcharts.Series}
  29380. * The newly created prototype as extended from {@link Series} or its
  29381. * derivatives.
  29382. */
  29383. function seriesType(type, parent, options, seriesProto, pointProto) {
  29384. var defaultPlotOptions = defaultOptions.plotOptions || {};
  29385. parent = parent || '';
  29386. // Merge the options
  29387. defaultPlotOptions[type] = merge(defaultPlotOptions[parent], options);
  29388. // Create the class
  29389. registerSeriesType(type, extendClass(SeriesRegistry.seriesTypes[parent] || function () { }, seriesProto));
  29390. SeriesRegistry.seriesTypes[type].prototype.type = type;
  29391. // Create the point class if needed
  29392. if (pointProto) {
  29393. SeriesRegistry.seriesTypes[type].prototype.pointClass =
  29394. extendClass(Point, pointProto);
  29395. }
  29396. return SeriesRegistry.seriesTypes[type];
  29397. }
  29398. SeriesRegistry.seriesType = seriesType;
  29399. /* eslint-enable valid-jsdoc */
  29400. })(SeriesRegistry || (SeriesRegistry = {}));
  29401. /* *
  29402. *
  29403. * Compatibility
  29404. *
  29405. * */
  29406. H.seriesType = SeriesRegistry.seriesType;
  29407. /* *
  29408. *
  29409. * Export
  29410. *
  29411. * */
  29412. return SeriesRegistry;
  29413. });
  29414. _registerModule(_modules, 'Core/Chart/Chart.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Axis/Axis.js'], _modules['Core/FormatUtilities.js'], _modules['Core/Foundation.js'], _modules['Core/Globals.js'], _modules['Core/Legend.js'], _modules['Core/MSPointer.js'], _modules['Core/DefaultOptions.js'], _modules['Core/Color/Palette.js'], _modules['Core/Pointer.js'], _modules['Core/Renderer/RendererRegistry.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Time.js'], _modules['Core/Utilities.js'], _modules['Core/Renderer/HTML/AST.js']], function (A, Axis, FormatUtilities, Foundation, H, Legend, MSPointer, D, palette, Pointer, RendererRegistry, SeriesRegistry, Time, U, AST) {
  29415. /* *
  29416. *
  29417. * (c) 2010-2021 Torstein Honsi
  29418. *
  29419. * License: www.highcharts.com/license
  29420. *
  29421. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  29422. *
  29423. * */
  29424. var animate = A.animate,
  29425. animObject = A.animObject,
  29426. setAnimation = A.setAnimation;
  29427. var numberFormat = FormatUtilities.numberFormat;
  29428. var registerEventOptions = Foundation.registerEventOptions;
  29429. var charts = H.charts,
  29430. doc = H.doc,
  29431. marginNames = H.marginNames,
  29432. win = H.win;
  29433. var defaultOptions = D.defaultOptions,
  29434. defaultTime = D.defaultTime;
  29435. var seriesTypes = SeriesRegistry.seriesTypes;
  29436. var addEvent = U.addEvent,
  29437. attr = U.attr,
  29438. cleanRecursively = U.cleanRecursively,
  29439. createElement = U.createElement,
  29440. css = U.css,
  29441. defined = U.defined,
  29442. discardElement = U.discardElement,
  29443. erase = U.erase,
  29444. error = U.error,
  29445. extend = U.extend,
  29446. find = U.find,
  29447. fireEvent = U.fireEvent,
  29448. getStyle = U.getStyle,
  29449. isArray = U.isArray,
  29450. isFunction = U.isFunction,
  29451. isNumber = U.isNumber,
  29452. isObject = U.isObject,
  29453. isString = U.isString,
  29454. merge = U.merge,
  29455. objectEach = U.objectEach,
  29456. pick = U.pick,
  29457. pInt = U.pInt,
  29458. relativeLength = U.relativeLength,
  29459. removeEvent = U.removeEvent,
  29460. splat = U.splat,
  29461. syncTimeout = U.syncTimeout,
  29462. uniqueKey = U.uniqueKey;
  29463. /* *
  29464. *
  29465. * Class
  29466. *
  29467. * */
  29468. /* eslint-disable no-invalid-this, valid-jsdoc */
  29469. /**
  29470. * The Chart class. The recommended constructor is {@link Highcharts#chart}.
  29471. *
  29472. * @example
  29473. * let chart = Highcharts.chart('container', {
  29474. * title: {
  29475. * text: 'My chart'
  29476. * },
  29477. * series: [{
  29478. * data: [1, 3, 2, 4]
  29479. * }]
  29480. * })
  29481. *
  29482. * @class
  29483. * @name Highcharts.Chart
  29484. *
  29485. * @param {string|Highcharts.HTMLDOMElement} [renderTo]
  29486. * The DOM element to render to, or its id.
  29487. *
  29488. * @param {Highcharts.Options} options
  29489. * The chart options structure.
  29490. *
  29491. * @param {Highcharts.ChartCallbackFunction} [callback]
  29492. * Function to run when the chart has loaded and and all external images
  29493. * are loaded. Defining a
  29494. * [chart.events.load](https://api.highcharts.com/highcharts/chart.events.load)
  29495. * handler is equivalent.
  29496. */
  29497. var Chart = /** @class */ (function () {
  29498. function Chart(a, b, c) {
  29499. this.axes = void 0;
  29500. this.axisOffset = void 0;
  29501. this.bounds = void 0;
  29502. this.chartHeight = void 0;
  29503. this.chartWidth = void 0;
  29504. this.clipBox = void 0;
  29505. this.colorCounter = void 0;
  29506. this.container = void 0;
  29507. this.eventOptions = void 0;
  29508. this.index = void 0;
  29509. this.isResizing = void 0;
  29510. this.labelCollectors = void 0;
  29511. this.legend = void 0;
  29512. this.margin = void 0;
  29513. this.numberFormatter = void 0;
  29514. this.options = void 0;
  29515. this.plotBox = void 0;
  29516. this.plotHeight = void 0;
  29517. this.plotLeft = void 0;
  29518. this.plotTop = void 0;
  29519. this.plotWidth = void 0;
  29520. this.pointCount = void 0;
  29521. this.pointer = void 0;
  29522. this.renderer = void 0;
  29523. this.renderTo = void 0;
  29524. this.series = void 0;
  29525. this.sharedClips = {};
  29526. this.spacing = void 0;
  29527. this.spacingBox = void 0;
  29528. this.symbolCounter = void 0;
  29529. this.time = void 0;
  29530. this.titleOffset = void 0;
  29531. this.userOptions = void 0;
  29532. this.xAxis = void 0;
  29533. this.yAxis = void 0;
  29534. this.getArgs(a, b, c);
  29535. }
  29536. /**
  29537. * Factory function for basic charts.
  29538. *
  29539. * @example
  29540. * // Render a chart in to div#container
  29541. * let chart = Highcharts.chart('container', {
  29542. * title: {
  29543. * text: 'My chart'
  29544. * },
  29545. * series: [{
  29546. * data: [1, 3, 2, 4]
  29547. * }]
  29548. * });
  29549. *
  29550. * @function Highcharts.chart
  29551. *
  29552. * @param {string|Highcharts.HTMLDOMElement} [renderTo]
  29553. * The DOM element to render to, or its id.
  29554. *
  29555. * @param {Highcharts.Options} options
  29556. * The chart options structure.
  29557. *
  29558. * @param {Highcharts.ChartCallbackFunction} [callback]
  29559. * Function to run when the chart has loaded and and all external images are
  29560. * loaded. Defining a
  29561. * [chart.events.load](https://api.highcharts.com/highcharts/chart.events.load)
  29562. * handler is equivalent.
  29563. *
  29564. * @return {Highcharts.Chart}
  29565. * Returns the Chart object.
  29566. */
  29567. Chart.chart = function (a, b, c) {
  29568. return new Chart(a, b, c);
  29569. };
  29570. /* *
  29571. *
  29572. * Functions
  29573. *
  29574. * */
  29575. /**
  29576. * Handle the arguments passed to the constructor.
  29577. *
  29578. * @private
  29579. * @function Highcharts.Chart#getArgs
  29580. *
  29581. * @param {...Array<*>} arguments
  29582. * All arguments for the constructor.
  29583. *
  29584. * @fires Highcharts.Chart#event:init
  29585. * @fires Highcharts.Chart#event:afterInit
  29586. */
  29587. Chart.prototype.getArgs = function (a, b, c) {
  29588. // Remove the optional first argument, renderTo, and
  29589. // set it on this.
  29590. if (isString(a) || a.nodeName) {
  29591. this.renderTo = a;
  29592. this.init(b, c);
  29593. }
  29594. else {
  29595. this.init(a, b);
  29596. }
  29597. };
  29598. /**
  29599. * Overridable function that initializes the chart. The constructor's
  29600. * arguments are passed on directly.
  29601. *
  29602. * @function Highcharts.Chart#init
  29603. *
  29604. * @param {Highcharts.Options} userOptions
  29605. * Custom options.
  29606. *
  29607. * @param {Function} [callback]
  29608. * Function to run when the chart has loaded and and all external
  29609. * images are loaded.
  29610. *
  29611. * @return {void}
  29612. *
  29613. * @fires Highcharts.Chart#event:init
  29614. * @fires Highcharts.Chart#event:afterInit
  29615. */
  29616. Chart.prototype.init = function (userOptions, callback) {
  29617. // Handle regular options
  29618. var userPlotOptions = userOptions.plotOptions || {};
  29619. // Fire the event with a default function
  29620. fireEvent(this, 'init', { args: arguments }, function () {
  29621. var options = merge(defaultOptions,
  29622. userOptions); // do the merge
  29623. var optionsChart = options.chart;
  29624. // Override (by copy of user options) or clear tooltip options
  29625. // in chart.options.plotOptions (#6218)
  29626. objectEach(options.plotOptions, function (typeOptions, type) {
  29627. if (isObject(typeOptions)) { // #8766
  29628. typeOptions.tooltip = (userPlotOptions[type] && // override by copy:
  29629. merge(userPlotOptions[type].tooltip)) || void 0; // or clear
  29630. }
  29631. });
  29632. // User options have higher priority than default options
  29633. // (#6218). In case of exporting: path is changed
  29634. options.tooltip.userOptions = (userOptions.chart &&
  29635. userOptions.chart.forExport &&
  29636. userOptions.tooltip.userOptions) || userOptions.tooltip;
  29637. /**
  29638. * The original options given to the constructor or a chart factory
  29639. * like {@link Highcharts.chart} and {@link Highcharts.stockChart}.
  29640. *
  29641. * @name Highcharts.Chart#userOptions
  29642. * @type {Highcharts.Options}
  29643. */
  29644. this.userOptions = userOptions;
  29645. this.margin = [];
  29646. this.spacing = [];
  29647. // Pixel data bounds for touch zoom
  29648. this.bounds = { h: {}, v: {} };
  29649. // An array of functions that returns labels that should be
  29650. // considered for anti-collision
  29651. this.labelCollectors = [];
  29652. this.callback = callback;
  29653. this.isResizing = 0;
  29654. /**
  29655. * The options structure for the chart after merging
  29656. * {@link #defaultOptions} and {@link #userOptions}. It contains
  29657. * members for the sub elements like series, legend, tooltip etc.
  29658. *
  29659. * @name Highcharts.Chart#options
  29660. * @type {Highcharts.Options}
  29661. */
  29662. this.options = options;
  29663. /**
  29664. * All the axes in the chart.
  29665. *
  29666. * @see Highcharts.Chart.xAxis
  29667. * @see Highcharts.Chart.yAxis
  29668. *
  29669. * @name Highcharts.Chart#axes
  29670. * @type {Array<Highcharts.Axis>}
  29671. */
  29672. this.axes = [];
  29673. /**
  29674. * All the current series in the chart.
  29675. *
  29676. * @name Highcharts.Chart#series
  29677. * @type {Array<Highcharts.Series>}
  29678. */
  29679. this.series = [];
  29680. /**
  29681. * The `Time` object associated with the chart. Since v6.0.5,
  29682. * time settings can be applied individually for each chart. If
  29683. * no individual settings apply, the `Time` object is shared by
  29684. * all instances.
  29685. *
  29686. * @name Highcharts.Chart#time
  29687. * @type {Highcharts.Time}
  29688. */
  29689. this.time =
  29690. userOptions.time && Object.keys(userOptions.time).length ?
  29691. new Time(userOptions.time) :
  29692. H.time;
  29693. /**
  29694. * Callback function to override the default function that formats
  29695. * all the numbers in the chart. Returns a string with the formatted
  29696. * number.
  29697. *
  29698. * @name Highcharts.Chart#numberFormatter
  29699. * @type {Highcharts.NumberFormatterCallbackFunction}
  29700. */
  29701. this.numberFormatter = optionsChart.numberFormatter || numberFormat;
  29702. /**
  29703. * Whether the chart is in styled mode, meaning all presentatinoal
  29704. * attributes are avoided.
  29705. *
  29706. * @name Highcharts.Chart#styledMode
  29707. * @type {boolean}
  29708. */
  29709. this.styledMode = optionsChart.styledMode;
  29710. this.hasCartesianSeries = optionsChart.showAxes;
  29711. var chart = this;
  29712. /**
  29713. * Index position of the chart in the {@link Highcharts#charts}
  29714. * property.
  29715. *
  29716. * @name Highcharts.Chart#index
  29717. * @type {number}
  29718. * @readonly
  29719. */
  29720. chart.index = charts.length; // Add the chart to the global lookup
  29721. charts.push(chart);
  29722. H.chartCount++;
  29723. // Chart event handlers
  29724. registerEventOptions(this, optionsChart);
  29725. /**
  29726. * A collection of the X axes in the chart.
  29727. *
  29728. * @name Highcharts.Chart#xAxis
  29729. * @type {Array<Highcharts.Axis>}
  29730. */
  29731. chart.xAxis = [];
  29732. /**
  29733. * A collection of the Y axes in the chart.
  29734. *
  29735. * @name Highcharts.Chart#yAxis
  29736. * @type {Array<Highcharts.Axis>}
  29737. *
  29738. * @todo
  29739. * Make events official: Fire the event `afterInit`.
  29740. */
  29741. chart.yAxis = [];
  29742. chart.pointCount = chart.colorCounter = chart.symbolCounter = 0;
  29743. // Fire after init but before first render, before axes and series
  29744. // have been initialized.
  29745. fireEvent(chart, 'afterInit');
  29746. chart.firstRender();
  29747. });
  29748. };
  29749. /**
  29750. * Internal function to unitialize an individual series.
  29751. *
  29752. * @private
  29753. * @function Highcharts.Chart#initSeries
  29754. */
  29755. Chart.prototype.initSeries = function (options) {
  29756. var chart = this,
  29757. optionsChart = chart.options.chart,
  29758. type = (options.type ||
  29759. optionsChart.type ||
  29760. optionsChart.defaultSeriesType),
  29761. SeriesClass = seriesTypes[type];
  29762. // No such series type
  29763. if (!SeriesClass) {
  29764. error(17, true, chart, { missingModuleFor: type });
  29765. }
  29766. var series = new SeriesClass();
  29767. if (typeof series.init === 'function') {
  29768. series.init(chart, options);
  29769. }
  29770. return series;
  29771. };
  29772. /**
  29773. * Internal function to set data for all series with enabled sorting.
  29774. *
  29775. * @private
  29776. * @function Highcharts.Chart#setSeriesData
  29777. */
  29778. Chart.prototype.setSeriesData = function () {
  29779. this.getSeriesOrderByLinks().forEach(function (series) {
  29780. // We need to set data for series with sorting after series init
  29781. if (!series.points && !series.data && series.enabledDataSorting) {
  29782. series.setData(series.options.data, false);
  29783. }
  29784. });
  29785. };
  29786. /**
  29787. * Sort and return chart series in order depending on the number of linked
  29788. * series.
  29789. *
  29790. * @private
  29791. * @function Highcharts.Series#getSeriesOrderByLinks
  29792. * @return {Array<Highcharts.Series>}
  29793. */
  29794. Chart.prototype.getSeriesOrderByLinks = function () {
  29795. return this.series.concat().sort(function (a, b) {
  29796. if (a.linkedSeries.length || b.linkedSeries.length) {
  29797. return b.linkedSeries.length - a.linkedSeries.length;
  29798. }
  29799. return 0;
  29800. });
  29801. };
  29802. /**
  29803. * Order all series above a given index. When series are added and ordered
  29804. * by configuration, only the last series is handled (#248, #1123, #2456,
  29805. * #6112). This function is called on series initialization and destroy.
  29806. *
  29807. * @private
  29808. * @function Highcharts.Series#orderSeries
  29809. * @param {number} [fromIndex]
  29810. * If this is given, only the series above this index are handled.
  29811. */
  29812. Chart.prototype.orderSeries = function (fromIndex) {
  29813. var series = this.series;
  29814. for (var i = (fromIndex || 0), iEnd = series.length; i < iEnd; ++i) {
  29815. if (series[i]) {
  29816. /**
  29817. * Contains the series' index in the `Chart.series` array.
  29818. *
  29819. * @name Highcharts.Series#index
  29820. * @type {number}
  29821. * @readonly
  29822. */
  29823. series[i].index = i;
  29824. series[i].name = series[i].getName();
  29825. }
  29826. }
  29827. };
  29828. /**
  29829. * Check whether a given point is within the plot area.
  29830. *
  29831. * @function Highcharts.Chart#isInsidePlot
  29832. *
  29833. * @param {number} plotX
  29834. * Pixel x relative to the plot area.
  29835. *
  29836. * @param {number} plotY
  29837. * Pixel y relative to the plot area.
  29838. *
  29839. * @param {Highcharts.ChartIsInsideOptionsObject} [options]
  29840. * Options object.
  29841. *
  29842. * @return {boolean}
  29843. * Returns true if the given point is inside the plot area.
  29844. */
  29845. Chart.prototype.isInsidePlot = function (plotX, plotY, options) {
  29846. var _a;
  29847. if (options === void 0) { options = {}; }
  29848. var _b = this,
  29849. inverted = _b.inverted,
  29850. plotBox = _b.plotBox,
  29851. plotLeft = _b.plotLeft,
  29852. plotTop = _b.plotTop,
  29853. scrollablePlotBox = _b.scrollablePlotBox;
  29854. var scrollLeft = 0,
  29855. scrollTop = 0;
  29856. if (options.visiblePlotOnly && this.scrollingContainer) {
  29857. (_a = this.scrollingContainer, scrollLeft = _a.scrollLeft, scrollTop = _a.scrollTop);
  29858. }
  29859. var series = options.series,
  29860. box = (options.visiblePlotOnly && scrollablePlotBox) || plotBox,
  29861. x = options.inverted ? plotY : plotX,
  29862. y = options.inverted ? plotX : plotY,
  29863. e = {
  29864. x: x,
  29865. y: y,
  29866. isInsidePlot: true
  29867. };
  29868. if (!options.ignoreX) {
  29869. var xAxis = (series && (inverted ? series.yAxis : series.xAxis)) || {
  29870. pos: plotLeft,
  29871. len: Infinity
  29872. };
  29873. var chartX = options.paneCoordinates ? xAxis.pos + x : plotLeft + x;
  29874. if (!(chartX >= Math.max(scrollLeft + plotLeft, xAxis.pos) &&
  29875. chartX <= Math.min(scrollLeft + plotLeft + box.width, xAxis.pos + xAxis.len))) {
  29876. e.isInsidePlot = false;
  29877. }
  29878. }
  29879. if (!options.ignoreY && e.isInsidePlot) {
  29880. var yAxis = (series && (inverted ? series.xAxis : series.yAxis)) || {
  29881. pos: plotTop,
  29882. len: Infinity
  29883. };
  29884. var chartY = options.paneCoordinates ? yAxis.pos + y : plotTop + y;
  29885. if (!(chartY >= Math.max(scrollTop + plotTop, yAxis.pos) &&
  29886. chartY <= Math.min(scrollTop + plotTop + box.height, yAxis.pos + yAxis.len))) {
  29887. e.isInsidePlot = false;
  29888. }
  29889. }
  29890. fireEvent(this, 'afterIsInsidePlot', e);
  29891. return e.isInsidePlot;
  29892. };
  29893. /**
  29894. * Redraw the chart after changes have been done to the data, axis extremes
  29895. * chart size or chart elements. All methods for updating axes, series or
  29896. * points have a parameter for redrawing the chart. This is `true` by
  29897. * default. But in many cases you want to do more than one operation on the
  29898. * chart before redrawing, for example add a number of points. In those
  29899. * cases it is a waste of resources to redraw the chart for each new point
  29900. * added. So you add the points and call `chart.redraw()` after.
  29901. *
  29902. * @function Highcharts.Chart#redraw
  29903. *
  29904. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  29905. * If or how to apply animation to the redraw.
  29906. *
  29907. * @fires Highcharts.Chart#event:afterSetExtremes
  29908. * @fires Highcharts.Chart#event:beforeRedraw
  29909. * @fires Highcharts.Chart#event:predraw
  29910. * @fires Highcharts.Chart#event:redraw
  29911. * @fires Highcharts.Chart#event:render
  29912. * @fires Highcharts.Chart#event:updatedData
  29913. */
  29914. Chart.prototype.redraw = function (animation) {
  29915. fireEvent(this, 'beforeRedraw');
  29916. var chart = this,
  29917. axes = chart.hasCartesianSeries ? chart.axes : chart.colorAxis || [],
  29918. series = chart.series,
  29919. pointer = chart.pointer,
  29920. legend = chart.legend,
  29921. legendUserOptions = chart.userOptions.legend,
  29922. renderer = chart.renderer,
  29923. isHiddenChart = renderer.isHidden(),
  29924. afterRedraw = [];
  29925. var hasDirtyStacks,
  29926. hasStackedSeries,
  29927. i,
  29928. isDirtyBox = chart.isDirtyBox,
  29929. redrawLegend = chart.isDirtyLegend,
  29930. serie;
  29931. // Handle responsive rules, not only on resize (#6130)
  29932. if (chart.setResponsive) {
  29933. chart.setResponsive(false);
  29934. }
  29935. // Set the global animation. When chart.hasRendered is not true, the
  29936. // redraw call comes from a responsive rule and animation should not
  29937. // occur.
  29938. setAnimation(chart.hasRendered ? animation : false, chart);
  29939. if (isHiddenChart) {
  29940. chart.temporaryDisplay();
  29941. }
  29942. // Adjust title layout (reflow multiline text)
  29943. chart.layOutTitles();
  29944. // link stacked series
  29945. i = series.length;
  29946. while (i--) {
  29947. serie = series[i];
  29948. if (serie.options.stacking || serie.options.centerInCategory) {
  29949. hasStackedSeries = true;
  29950. if (serie.isDirty) {
  29951. hasDirtyStacks = true;
  29952. break;
  29953. }
  29954. }
  29955. }
  29956. if (hasDirtyStacks) { // mark others as dirty
  29957. i = series.length;
  29958. while (i--) {
  29959. serie = series[i];
  29960. if (serie.options.stacking) {
  29961. serie.isDirty = true;
  29962. }
  29963. }
  29964. }
  29965. // Handle updated data in the series
  29966. series.forEach(function (serie) {
  29967. if (serie.isDirty) {
  29968. if (serie.options.legendType === 'point') {
  29969. if (typeof serie.updateTotals === 'function') {
  29970. serie.updateTotals();
  29971. }
  29972. redrawLegend = true;
  29973. }
  29974. else if (legendUserOptions &&
  29975. (legendUserOptions.labelFormatter ||
  29976. legendUserOptions.labelFormat)) {
  29977. redrawLegend = true; // #2165
  29978. }
  29979. }
  29980. if (serie.isDirtyData) {
  29981. fireEvent(serie, 'updatedData');
  29982. }
  29983. });
  29984. // handle added or removed series
  29985. if (redrawLegend && legend && legend.options.enabled) {
  29986. // draw legend graphics
  29987. legend.render();
  29988. chart.isDirtyLegend = false;
  29989. }
  29990. // reset stacks
  29991. if (hasStackedSeries) {
  29992. chart.getStacks();
  29993. }
  29994. // set axes scales
  29995. axes.forEach(function (axis) {
  29996. axis.updateNames();
  29997. axis.setScale();
  29998. });
  29999. chart.getMargins(); // #3098
  30000. // If one axis is dirty, all axes must be redrawn (#792, #2169)
  30001. axes.forEach(function (axis) {
  30002. if (axis.isDirty) {
  30003. isDirtyBox = true;
  30004. }
  30005. });
  30006. // redraw axes
  30007. axes.forEach(function (axis) {
  30008. // Fire 'afterSetExtremes' only if extremes are set
  30009. var key = axis.min + ',' + axis.max;
  30010. if (axis.extKey !== key) { // #821, #4452
  30011. axis.extKey = key;
  30012. // prevent a recursive call to chart.redraw() (#1119)
  30013. afterRedraw.push(function () {
  30014. fireEvent(axis, 'afterSetExtremes', extend(axis.eventArgs, axis.getExtremes())); // #747, #751
  30015. delete axis.eventArgs;
  30016. });
  30017. }
  30018. if (isDirtyBox || hasStackedSeries) {
  30019. axis.redraw();
  30020. }
  30021. });
  30022. // the plot areas size has changed
  30023. if (isDirtyBox) {
  30024. chart.drawChartBox();
  30025. }
  30026. // Fire an event before redrawing series, used by the boost module to
  30027. // clear previous series renderings.
  30028. fireEvent(chart, 'predraw');
  30029. // redraw affected series
  30030. series.forEach(function (serie) {
  30031. if ((isDirtyBox || serie.isDirty) && serie.visible) {
  30032. serie.redraw();
  30033. }
  30034. // Set it here, otherwise we will have unlimited 'updatedData' calls
  30035. // for a hidden series after setData(). Fixes #6012
  30036. serie.isDirtyData = false;
  30037. });
  30038. // move tooltip or reset
  30039. if (pointer) {
  30040. pointer.reset(true);
  30041. }
  30042. // redraw if canvas
  30043. renderer.draw();
  30044. // Fire the events
  30045. fireEvent(chart, 'redraw');
  30046. fireEvent(chart, 'render');
  30047. if (isHiddenChart) {
  30048. chart.temporaryDisplay(true);
  30049. }
  30050. // Fire callbacks that are put on hold until after the redraw
  30051. afterRedraw.forEach(function (callback) {
  30052. callback.call();
  30053. });
  30054. };
  30055. /**
  30056. * Get an axis, series or point object by `id` as given in the configuration
  30057. * options. Returns `undefined` if no item is found.
  30058. *
  30059. * @sample highcharts/plotoptions/series-id/
  30060. * Get series by id
  30061. *
  30062. * @function Highcharts.Chart#get
  30063. *
  30064. * @param {string} id
  30065. * The id as given in the configuration options.
  30066. *
  30067. * @return {Highcharts.Axis|Highcharts.Series|Highcharts.Point|undefined}
  30068. * The retrieved item.
  30069. */
  30070. Chart.prototype.get = function (id) {
  30071. var series = this.series;
  30072. /**
  30073. * @private
  30074. * @param {Highcharts.Axis|Highcharts.Series} item
  30075. * @return {boolean}
  30076. */
  30077. function itemById(item) {
  30078. return (item.id === id ||
  30079. (item.options && item.options.id === id));
  30080. }
  30081. var ret =
  30082. // Search axes
  30083. find(this.axes,
  30084. itemById) ||
  30085. // Search series
  30086. find(this.series,
  30087. itemById);
  30088. // Search points
  30089. for (var i = 0; !ret && i < series.length; i++) {
  30090. ret = find(series[i].points || [], itemById);
  30091. }
  30092. return ret;
  30093. };
  30094. /**
  30095. * Create the Axis instances based on the config options.
  30096. *
  30097. * @private
  30098. * @function Highcharts.Chart#getAxes
  30099. * @fires Highcharts.Chart#event:afterGetAxes
  30100. * @fires Highcharts.Chart#event:getAxes
  30101. */
  30102. Chart.prototype.getAxes = function () {
  30103. var chart = this,
  30104. options = this.options,
  30105. xAxisOptions = options.xAxis = splat(options.xAxis || {}),
  30106. yAxisOptions = options.yAxis = splat(options.yAxis || {});
  30107. fireEvent(this, 'getAxes');
  30108. // make sure the options are arrays and add some members
  30109. xAxisOptions.forEach(function (axis, i) {
  30110. axis.index = i;
  30111. axis.isX = true;
  30112. });
  30113. yAxisOptions.forEach(function (axis, i) {
  30114. axis.index = i;
  30115. });
  30116. // concatenate all axis options into one array
  30117. var optionsArray = xAxisOptions.concat(yAxisOptions);
  30118. optionsArray.forEach(function (axisOptions) {
  30119. new Axis(chart, axisOptions); // eslint-disable-line no-new
  30120. });
  30121. fireEvent(this, 'afterGetAxes');
  30122. };
  30123. /**
  30124. * Returns an array of all currently selected points in the chart. Points
  30125. * can be selected by clicking or programmatically by the
  30126. * {@link Highcharts.Point#select}
  30127. * function.
  30128. *
  30129. * @sample highcharts/plotoptions/series-allowpointselect-line/
  30130. * Get selected points
  30131. *
  30132. * @function Highcharts.Chart#getSelectedPoints
  30133. *
  30134. * @return {Array<Highcharts.Point>}
  30135. * The currently selected points.
  30136. */
  30137. Chart.prototype.getSelectedPoints = function () {
  30138. var points = [];
  30139. this.series.forEach(function (serie) {
  30140. // For one-to-one points inspect series.data in order to retrieve
  30141. // points outside the visible range (#6445). For grouped data,
  30142. // inspect the generated series.points.
  30143. points = points.concat(serie.getPointsCollection().filter(function (point) {
  30144. return pick(point.selectedStaging, point.selected);
  30145. }));
  30146. });
  30147. return points;
  30148. };
  30149. /**
  30150. * Returns an array of all currently selected series in the chart. Series
  30151. * can be selected either programmatically by the
  30152. * {@link Highcharts.Series#select}
  30153. * function or by checking the checkbox next to the legend item if
  30154. * [series.showCheckBox](https://api.highcharts.com/highcharts/plotOptions.series.showCheckbox)
  30155. * is true.
  30156. *
  30157. * @sample highcharts/members/chart-getselectedseries/
  30158. * Get selected series
  30159. *
  30160. * @function Highcharts.Chart#getSelectedSeries
  30161. *
  30162. * @return {Array<Highcharts.Series>}
  30163. * The currently selected series.
  30164. */
  30165. Chart.prototype.getSelectedSeries = function () {
  30166. return this.series.filter(function (serie) {
  30167. return serie.selected;
  30168. });
  30169. };
  30170. /**
  30171. * Set a new title or subtitle for the chart.
  30172. *
  30173. * @sample highcharts/members/chart-settitle/
  30174. * Set title text and styles
  30175. *
  30176. * @function Highcharts.Chart#setTitle
  30177. *
  30178. * @param {Highcharts.TitleOptions} [titleOptions]
  30179. * New title options. The title text itself is set by the
  30180. * `titleOptions.text` property.
  30181. *
  30182. * @param {Highcharts.SubtitleOptions} [subtitleOptions]
  30183. * New subtitle options. The subtitle text itself is set by the
  30184. * `subtitleOptions.text` property.
  30185. *
  30186. * @param {boolean} [redraw]
  30187. * Whether to redraw the chart or wait for a later call to
  30188. * `chart.redraw()`.
  30189. */
  30190. Chart.prototype.setTitle = function (titleOptions, subtitleOptions, redraw) {
  30191. this.applyDescription('title', titleOptions);
  30192. this.applyDescription('subtitle', subtitleOptions);
  30193. // The initial call also adds the caption. On update, chart.update will
  30194. // relay to Chart.setCaption.
  30195. this.applyDescription('caption', void 0);
  30196. this.layOutTitles(redraw);
  30197. };
  30198. /**
  30199. * Apply a title, subtitle or caption for the chart
  30200. *
  30201. * @private
  30202. * @function Highcharts.Chart#applyDescription
  30203. * @param name {string}
  30204. * Either title, subtitle or caption
  30205. * @param {Highcharts.TitleOptions|Highcharts.SubtitleOptions|Highcharts.CaptionOptions|undefined} explicitOptions
  30206. * The options to set, will be merged with default options.
  30207. */
  30208. Chart.prototype.applyDescription = function (name, explicitOptions) {
  30209. var chart = this;
  30210. // Default style
  30211. var style = name === 'title' ? {
  30212. color: palette.neutralColor80,
  30213. fontSize: this.options.isStock ? '16px' : '18px' // #2944
  30214. } : {
  30215. color: palette.neutralColor60
  30216. };
  30217. // Merge default options with explicit options
  30218. var options = this.options[name] = merge(
  30219. // Default styles
  30220. (!this.styledMode && { style: style }),
  30221. this.options[name],
  30222. explicitOptions);
  30223. var elem = this[name];
  30224. if (elem && explicitOptions) {
  30225. this[name] = elem = elem.destroy(); // remove old
  30226. }
  30227. if (options && !elem) {
  30228. elem = this.renderer.text(options.text, 0, 0, options.useHTML)
  30229. .attr({
  30230. align: options.align,
  30231. 'class': 'highcharts-' + name,
  30232. zIndex: options.zIndex || 4
  30233. })
  30234. .add();
  30235. // Update methods, shortcut to Chart.setTitle, Chart.setSubtitle and
  30236. // Chart.setCaption
  30237. elem.update = function (updateOptions) {
  30238. var fn = {
  30239. title: 'setTitle',
  30240. subtitle: 'setSubtitle',
  30241. caption: 'setCaption'
  30242. }[name];
  30243. chart[fn](updateOptions);
  30244. };
  30245. // Presentational
  30246. if (!this.styledMode) {
  30247. elem.css(options.style);
  30248. }
  30249. /**
  30250. * The chart title. The title has an `update` method that allows
  30251. * modifying the options directly or indirectly via
  30252. * `chart.update`.
  30253. *
  30254. * @sample highcharts/members/title-update/
  30255. * Updating titles
  30256. *
  30257. * @name Highcharts.Chart#title
  30258. * @type {Highcharts.TitleObject}
  30259. */
  30260. /**
  30261. * The chart subtitle. The subtitle has an `update` method that
  30262. * allows modifying the options directly or indirectly via
  30263. * `chart.update`.
  30264. *
  30265. * @name Highcharts.Chart#subtitle
  30266. * @type {Highcharts.SubtitleObject}
  30267. */
  30268. this[name] = elem;
  30269. }
  30270. };
  30271. /**
  30272. * Internal function to lay out the chart title, subtitle and caption, and
  30273. * cache the full offset height for use in `getMargins`. The result is
  30274. * stored in `this.titleOffset`.
  30275. *
  30276. * @private
  30277. * @function Highcharts.Chart#layOutTitles
  30278. *
  30279. * @param {boolean} [redraw=true]
  30280. * @fires Highcharts.Chart#event:afterLayOutTitles
  30281. */
  30282. Chart.prototype.layOutTitles = function (redraw) {
  30283. var titleOffset = [0, 0, 0],
  30284. renderer = this.renderer,
  30285. spacingBox = this.spacingBox;
  30286. // Lay out the title and the subtitle respectively
  30287. ['title', 'subtitle', 'caption'].forEach(function (key) {
  30288. var title = this[key], titleOptions = this.options[key], verticalAlign = titleOptions.verticalAlign || 'top', offset = key === 'title' ?
  30289. verticalAlign === 'top' ? -3 : 0 :
  30290. // Floating subtitle (#6574)
  30291. verticalAlign === 'top' ? titleOffset[0] + 2 : 0;
  30292. var titleSize,
  30293. height;
  30294. if (title) {
  30295. if (!this.styledMode) {
  30296. titleSize = titleOptions.style && titleOptions.style.fontSize;
  30297. }
  30298. titleSize = renderer.fontMetrics(titleSize, title).b;
  30299. title
  30300. .css({
  30301. width: (titleOptions.width ||
  30302. spacingBox.width + (titleOptions.widthAdjust || 0)) + 'px'
  30303. });
  30304. // Skip the cache for HTML (#3481, #11666)
  30305. height = Math.round(title.getBBox(titleOptions.useHTML).height);
  30306. title.align(extend({
  30307. y: verticalAlign === 'bottom' ?
  30308. titleSize :
  30309. offset + titleSize,
  30310. height: height
  30311. }, titleOptions), false, 'spacingBox');
  30312. if (!titleOptions.floating) {
  30313. if (verticalAlign === 'top') {
  30314. titleOffset[0] = Math.ceil(titleOffset[0] +
  30315. height);
  30316. }
  30317. else if (verticalAlign === 'bottom') {
  30318. titleOffset[2] = Math.ceil(titleOffset[2] +
  30319. height);
  30320. }
  30321. }
  30322. }
  30323. }, this);
  30324. // Handle title.margin and caption.margin
  30325. if (titleOffset[0] &&
  30326. (this.options.title.verticalAlign || 'top') === 'top') {
  30327. titleOffset[0] += this.options.title.margin;
  30328. }
  30329. if (titleOffset[2] &&
  30330. this.options.caption.verticalAlign === 'bottom') {
  30331. titleOffset[2] += this.options.caption.margin;
  30332. }
  30333. var requiresDirtyBox = (!this.titleOffset ||
  30334. this.titleOffset.join(',') !== titleOffset.join(','));
  30335. // Used in getMargins
  30336. this.titleOffset = titleOffset;
  30337. fireEvent(this, 'afterLayOutTitles');
  30338. if (!this.isDirtyBox && requiresDirtyBox) {
  30339. this.isDirtyBox = this.isDirtyLegend = requiresDirtyBox;
  30340. // Redraw if necessary (#2719, #2744)
  30341. if (this.hasRendered && pick(redraw, true) && this.isDirtyBox) {
  30342. this.redraw();
  30343. }
  30344. }
  30345. };
  30346. /**
  30347. * Internal function to get the chart width and height according to options
  30348. * and container size. Sets {@link Chart.chartWidth} and
  30349. * {@link Chart.chartHeight}.
  30350. *
  30351. * @private
  30352. * @function Highcharts.Chart#getChartSize
  30353. */
  30354. Chart.prototype.getChartSize = function () {
  30355. var chart = this,
  30356. optionsChart = chart.options.chart,
  30357. widthOption = optionsChart.width,
  30358. heightOption = optionsChart.height,
  30359. renderTo = chart.renderTo;
  30360. // Get inner width and height
  30361. if (!defined(widthOption)) {
  30362. chart.containerWidth = getStyle(renderTo, 'width');
  30363. }
  30364. if (!defined(heightOption)) {
  30365. chart.containerHeight = getStyle(renderTo, 'height');
  30366. }
  30367. /**
  30368. * The current pixel width of the chart.
  30369. *
  30370. * @name Highcharts.Chart#chartWidth
  30371. * @type {number}
  30372. */
  30373. chart.chartWidth = Math.max(// #1393
  30374. 0, widthOption || chart.containerWidth || 600 // #1460
  30375. );
  30376. /**
  30377. * The current pixel height of the chart.
  30378. *
  30379. * @name Highcharts.Chart#chartHeight
  30380. * @type {number}
  30381. */
  30382. chart.chartHeight = Math.max(0, relativeLength(heightOption, chart.chartWidth) ||
  30383. (chart.containerHeight > 1 ?
  30384. chart.containerHeight :
  30385. 400));
  30386. };
  30387. /**
  30388. * If the renderTo element has no offsetWidth, most likely one or more of
  30389. * its parents are hidden. Loop up the DOM tree to temporarily display the
  30390. * parents, then save the original display properties, and when the true
  30391. * size is retrieved, reset them. Used on first render and on redraws.
  30392. *
  30393. * @private
  30394. * @function Highcharts.Chart#temporaryDisplay
  30395. *
  30396. * @param {boolean} [revert]
  30397. * Revert to the saved original styles.
  30398. */
  30399. Chart.prototype.temporaryDisplay = function (revert) {
  30400. var node = this.renderTo,
  30401. tempStyle;
  30402. if (!revert) {
  30403. while (node && node.style) {
  30404. // When rendering to a detached node, it needs to be temporarily
  30405. // attached in order to read styling and bounding boxes (#5783,
  30406. // #7024).
  30407. if (!doc.body.contains(node) && !node.parentNode) {
  30408. node.hcOrigDetached = true;
  30409. doc.body.appendChild(node);
  30410. }
  30411. if (getStyle(node, 'display', false) === 'none' ||
  30412. node.hcOricDetached) {
  30413. node.hcOrigStyle = {
  30414. display: node.style.display,
  30415. height: node.style.height,
  30416. overflow: node.style.overflow
  30417. };
  30418. tempStyle = {
  30419. display: 'block',
  30420. overflow: 'hidden'
  30421. };
  30422. if (node !== this.renderTo) {
  30423. tempStyle.height = 0;
  30424. }
  30425. css(node, tempStyle);
  30426. // If it still doesn't have an offset width after setting
  30427. // display to block, it probably has an !important priority
  30428. // #2631, 6803
  30429. if (!node.offsetWidth) {
  30430. node.style.setProperty('display', 'block', 'important');
  30431. }
  30432. }
  30433. node = node.parentNode;
  30434. if (node === doc.body) {
  30435. break;
  30436. }
  30437. }
  30438. }
  30439. else {
  30440. while (node && node.style) {
  30441. if (node.hcOrigStyle) {
  30442. css(node, node.hcOrigStyle);
  30443. delete node.hcOrigStyle;
  30444. }
  30445. if (node.hcOrigDetached) {
  30446. doc.body.removeChild(node);
  30447. node.hcOrigDetached = false;
  30448. }
  30449. node = node.parentNode;
  30450. }
  30451. }
  30452. };
  30453. /**
  30454. * Set the {@link Chart.container|chart container's} class name, in
  30455. * addition to `highcharts-container`.
  30456. *
  30457. * @function Highcharts.Chart#setClassName
  30458. *
  30459. * @param {string} [className]
  30460. * The additional class name.
  30461. */
  30462. Chart.prototype.setClassName = function (className) {
  30463. this.container.className = 'highcharts-container ' + (className || '');
  30464. };
  30465. /**
  30466. * Get the containing element, determine the size and create the inner
  30467. * container div to hold the chart.
  30468. *
  30469. * @private
  30470. * @function Highcharts.Chart#afterGetContainer
  30471. * @fires Highcharts.Chart#event:afterGetContainer
  30472. */
  30473. Chart.prototype.getContainer = function () {
  30474. var chart = this,
  30475. options = chart.options,
  30476. optionsChart = options.chart,
  30477. indexAttrName = 'data-highcharts-chart',
  30478. containerId = uniqueKey();
  30479. var containerStyle,
  30480. renderTo = chart.renderTo;
  30481. if (!renderTo) {
  30482. chart.renderTo = renderTo =
  30483. optionsChart.renderTo;
  30484. }
  30485. if (isString(renderTo)) {
  30486. chart.renderTo = renderTo =
  30487. doc.getElementById(renderTo);
  30488. }
  30489. // Display an error if the renderTo is wrong
  30490. if (!renderTo) {
  30491. error(13, true, chart);
  30492. }
  30493. // If the container already holds a chart, destroy it. The check for
  30494. // hasRendered is there because web pages that are saved to disk from
  30495. // the browser, will preserve the data-highcharts-chart attribute and
  30496. // the SVG contents, but not an interactive chart. So in this case,
  30497. // charts[oldChartIndex] will point to the wrong chart if any (#2609).
  30498. var oldChartIndex = pInt(attr(renderTo,
  30499. indexAttrName));
  30500. if (isNumber(oldChartIndex) &&
  30501. charts[oldChartIndex] &&
  30502. charts[oldChartIndex].hasRendered) {
  30503. charts[oldChartIndex].destroy();
  30504. }
  30505. // Make a reference to the chart from the div
  30506. attr(renderTo, indexAttrName, chart.index);
  30507. // remove previous chart
  30508. renderTo.innerHTML = '';
  30509. // If the container doesn't have an offsetWidth, it has or is a child of
  30510. // a node that has display:none. We need to temporarily move it out to a
  30511. // visible state to determine the size, else the legend and tooltips
  30512. // won't render properly. The skipClone option is used in sparklines as
  30513. // a micro optimization, saving about 1-2 ms each chart.
  30514. if (!optionsChart.skipClone && !renderTo.offsetWidth) {
  30515. chart.temporaryDisplay();
  30516. }
  30517. // get the width and height
  30518. chart.getChartSize();
  30519. var chartWidth = chart.chartWidth;
  30520. var chartHeight = chart.chartHeight;
  30521. // Allow table cells and flex-boxes to shrink without the chart blocking
  30522. // them out (#6427)
  30523. css(renderTo, { overflow: 'hidden' });
  30524. // Create the inner container
  30525. if (!chart.styledMode) {
  30526. containerStyle = extend({
  30527. position: 'relative',
  30528. // needed for context menu (avoidscrollbars) and content
  30529. // overflow in IE
  30530. overflow: 'hidden',
  30531. width: chartWidth + 'px',
  30532. height: chartHeight + 'px',
  30533. textAlign: 'left',
  30534. lineHeight: 'normal',
  30535. zIndex: 0,
  30536. '-webkit-tap-highlight-color': 'rgba(0,0,0,0)',
  30537. userSelect: 'none',
  30538. 'touch-action': 'manipulation',
  30539. outline: 'none'
  30540. }, optionsChart.style || {});
  30541. }
  30542. /**
  30543. * The containing HTML element of the chart. The container is
  30544. * dynamically inserted into the element given as the `renderTo`
  30545. * parameter in the {@link Highcharts#chart} constructor.
  30546. *
  30547. * @name Highcharts.Chart#container
  30548. * @type {Highcharts.HTMLDOMElement}
  30549. */
  30550. var container = createElement('div', {
  30551. id: containerId
  30552. },
  30553. containerStyle,
  30554. renderTo);
  30555. chart.container = container;
  30556. // cache the cursor (#1650)
  30557. chart._cursor = container.style.cursor;
  30558. // Initialize the renderer
  30559. var Renderer = RendererRegistry.getRendererType(optionsChart.renderer);
  30560. /**
  30561. * The renderer instance of the chart. Each chart instance has only one
  30562. * associated renderer.
  30563. *
  30564. * @name Highcharts.Chart#renderer
  30565. * @type {Highcharts.SVGRenderer}
  30566. */
  30567. chart.renderer = new Renderer(container, chartWidth, chartHeight, void 0, optionsChart.forExport, options.exporting && options.exporting.allowHTML, chart.styledMode);
  30568. // Set the initial animation from the options
  30569. setAnimation(void 0, chart);
  30570. chart.setClassName(optionsChart.className);
  30571. if (!chart.styledMode) {
  30572. chart.renderer.setStyle(optionsChart.style);
  30573. }
  30574. else {
  30575. // Initialize definitions
  30576. for (var key in options.defs) { // eslint-disable-line guard-for-in
  30577. this.renderer.definition(options.defs[key]);
  30578. }
  30579. }
  30580. // Add a reference to the charts index
  30581. chart.renderer.chartIndex = chart.index;
  30582. fireEvent(this, 'afterGetContainer');
  30583. };
  30584. /**
  30585. * Calculate margins by rendering axis labels in a preliminary position.
  30586. * Title, subtitle and legend have already been rendered at this stage, but
  30587. * will be moved into their final positions.
  30588. *
  30589. * @private
  30590. * @function Highcharts.Chart#getMargins
  30591. * @fires Highcharts.Chart#event:getMargins
  30592. */
  30593. Chart.prototype.getMargins = function (skipAxes) {
  30594. var _a = this,
  30595. spacing = _a.spacing,
  30596. margin = _a.margin,
  30597. titleOffset = _a.titleOffset;
  30598. this.resetMargins();
  30599. // Adjust for title and subtitle
  30600. if (titleOffset[0] && !defined(margin[0])) {
  30601. this.plotTop = Math.max(this.plotTop, titleOffset[0] + spacing[0]);
  30602. }
  30603. if (titleOffset[2] && !defined(margin[2])) {
  30604. this.marginBottom = Math.max(this.marginBottom, titleOffset[2] + spacing[2]);
  30605. }
  30606. // Adjust for legend
  30607. if (this.legend && this.legend.display) {
  30608. this.legend.adjustMargins(margin, spacing);
  30609. }
  30610. fireEvent(this, 'getMargins');
  30611. if (!skipAxes) {
  30612. this.getAxisMargins();
  30613. }
  30614. };
  30615. /**
  30616. * @private
  30617. * @function Highcharts.Chart#getAxisMargins
  30618. */
  30619. Chart.prototype.getAxisMargins = function () {
  30620. var chart = this,
  30621. // [top, right, bottom, left]
  30622. axisOffset = chart.axisOffset = [0, 0, 0, 0],
  30623. colorAxis = chart.colorAxis,
  30624. margin = chart.margin,
  30625. getOffset = function (axes) {
  30626. axes.forEach(function (axis) {
  30627. if (axis.visible) {
  30628. axis.getOffset();
  30629. }
  30630. });
  30631. };
  30632. // pre-render axes to get labels offset width
  30633. if (chart.hasCartesianSeries) {
  30634. getOffset(chart.axes);
  30635. }
  30636. else if (colorAxis && colorAxis.length) {
  30637. getOffset(colorAxis);
  30638. }
  30639. // Add the axis offsets
  30640. marginNames.forEach(function (m, side) {
  30641. if (!defined(margin[side])) {
  30642. chart[m] += axisOffset[side];
  30643. }
  30644. });
  30645. chart.setChartSize();
  30646. };
  30647. /**
  30648. * Reflows the chart to its container. By default, the chart reflows
  30649. * automatically to its container following a `window.resize` event, as per
  30650. * the [chart.reflow](https://api.highcharts.com/highcharts/chart.reflow)
  30651. * option. However, there are no reliable events for div resize, so if the
  30652. * container is resized without a window resize event, this must be called
  30653. * explicitly.
  30654. *
  30655. * @sample highcharts/members/chart-reflow/
  30656. * Resize div and reflow
  30657. * @sample highcharts/chart/events-container/
  30658. * Pop up and reflow
  30659. *
  30660. * @function Highcharts.Chart#reflow
  30661. *
  30662. * @param {global.Event} [e]
  30663. * Event arguments. Used primarily when the function is called
  30664. * internally as a response to window resize.
  30665. */
  30666. Chart.prototype.reflow = function (e) {
  30667. var chart = this, optionsChart = chart.options.chart, renderTo = chart.renderTo, hasUserSize = (defined(optionsChart.width) &&
  30668. defined(optionsChart.height)), width = optionsChart.width || getStyle(renderTo, 'width'), height = optionsChart.height || getStyle(renderTo, 'height'), target = e ? e.target : win;
  30669. delete chart.pointer.chartPosition;
  30670. // Width and height checks for display:none. Target is doc in IE8 and
  30671. // Opera, win in Firefox, Chrome and IE9.
  30672. if (!hasUserSize &&
  30673. !chart.isPrinting &&
  30674. width &&
  30675. height &&
  30676. (target === win || target === doc)) {
  30677. if (width !== chart.containerWidth ||
  30678. height !== chart.containerHeight) {
  30679. U.clearTimeout(chart.reflowTimeout);
  30680. // When called from window.resize, e is set, else it's called
  30681. // directly (#2224)
  30682. chart.reflowTimeout = syncTimeout(function () {
  30683. // Set size, it may have been destroyed in the meantime
  30684. // (#1257)
  30685. if (chart.container) {
  30686. chart.setSize(void 0, void 0, false);
  30687. }
  30688. }, e ? 100 : 0);
  30689. }
  30690. chart.containerWidth = width;
  30691. chart.containerHeight = height;
  30692. }
  30693. };
  30694. /**
  30695. * Toggle the event handlers necessary for auto resizing, depending on the
  30696. * `chart.reflow` option.
  30697. *
  30698. * @private
  30699. * @function Highcharts.Chart#setReflow
  30700. */
  30701. Chart.prototype.setReflow = function (reflow) {
  30702. var chart = this;
  30703. if (reflow !== false && !this.unbindReflow) {
  30704. this.unbindReflow = addEvent(win, 'resize', function (e) {
  30705. // a removed event listener still runs in Edge and IE if the
  30706. // listener was removed while the event runs, so check if the
  30707. // chart is not destroyed (#11609)
  30708. if (chart.options) {
  30709. chart.reflow(e);
  30710. }
  30711. });
  30712. addEvent(this, 'destroy', this.unbindReflow);
  30713. }
  30714. else if (reflow === false && this.unbindReflow) {
  30715. // Unbind and unset
  30716. this.unbindReflow = this.unbindReflow();
  30717. }
  30718. // The following will add listeners to re-fit the chart before and after
  30719. // printing (#2284). However it only works in WebKit. Should have worked
  30720. // in Firefox, but not supported in IE.
  30721. /*
  30722. if (win.matchMedia) {
  30723. win.matchMedia('print').addListener(function reflow() {
  30724. chart.reflow();
  30725. });
  30726. }
  30727. //*/
  30728. };
  30729. /**
  30730. * Resize the chart to a given width and height. In order to set the width
  30731. * only, the height argument may be skipped. To set the height only, pass
  30732. * `undefined` for the width.
  30733. *
  30734. * @sample highcharts/members/chart-setsize-button/
  30735. * Test resizing from buttons
  30736. * @sample highcharts/members/chart-setsize-jquery-resizable/
  30737. * Add a jQuery UI resizable
  30738. * @sample stock/members/chart-setsize/
  30739. * Highcharts Stock with UI resizable
  30740. *
  30741. * @function Highcharts.Chart#setSize
  30742. *
  30743. * @param {number|null} [width]
  30744. * The new pixel width of the chart. Since v4.2.6, the argument can
  30745. * be `undefined` in order to preserve the current value (when
  30746. * setting height only), or `null` to adapt to the width of the
  30747. * containing element.
  30748. *
  30749. * @param {number|null} [height]
  30750. * The new pixel height of the chart. Since v4.2.6, the argument can
  30751. * be `undefined` in order to preserve the current value, or `null`
  30752. * in order to adapt to the height of the containing element.
  30753. *
  30754. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  30755. * Whether and how to apply animation.
  30756. *
  30757. * @return {void}
  30758. *
  30759. * @fires Highcharts.Chart#event:endResize
  30760. * @fires Highcharts.Chart#event:resize
  30761. */
  30762. Chart.prototype.setSize = function (width, height, animation) {
  30763. var chart = this,
  30764. renderer = chart.renderer;
  30765. // Handle the isResizing counter
  30766. chart.isResizing += 1;
  30767. // set the animation for the current process
  30768. setAnimation(animation, chart);
  30769. var globalAnimation = renderer.globalAnimation;
  30770. chart.oldChartHeight = chart.chartHeight;
  30771. chart.oldChartWidth = chart.chartWidth;
  30772. if (typeof width !== 'undefined') {
  30773. chart.options.chart.width = width;
  30774. }
  30775. if (typeof height !== 'undefined') {
  30776. chart.options.chart.height = height;
  30777. }
  30778. chart.getChartSize();
  30779. // Resize the container with the global animation applied if enabled
  30780. // (#2503)
  30781. if (!chart.styledMode) {
  30782. (globalAnimation ? animate : css)(chart.container, {
  30783. width: chart.chartWidth + 'px',
  30784. height: chart.chartHeight + 'px'
  30785. }, globalAnimation);
  30786. }
  30787. chart.setChartSize(true);
  30788. renderer.setSize(chart.chartWidth, chart.chartHeight, globalAnimation);
  30789. // handle axes
  30790. chart.axes.forEach(function (axis) {
  30791. axis.isDirty = true;
  30792. axis.setScale();
  30793. });
  30794. chart.isDirtyLegend = true; // force legend redraw
  30795. chart.isDirtyBox = true; // force redraw of plot and chart border
  30796. chart.layOutTitles(); // #2857
  30797. chart.getMargins();
  30798. chart.redraw(globalAnimation);
  30799. chart.oldChartHeight = null;
  30800. fireEvent(chart, 'resize');
  30801. // Fire endResize and set isResizing back. If animation is disabled,
  30802. // fire without delay
  30803. syncTimeout(function () {
  30804. if (chart) {
  30805. fireEvent(chart, 'endResize', null, function () {
  30806. chart.isResizing -= 1;
  30807. });
  30808. }
  30809. }, animObject(globalAnimation).duration);
  30810. };
  30811. /**
  30812. * Set the public chart properties. This is done before and after the
  30813. * pre-render to determine margin sizes.
  30814. *
  30815. * @private
  30816. * @function Highcharts.Chart#setChartSize
  30817. * @fires Highcharts.Chart#event:afterSetChartSize
  30818. */
  30819. Chart.prototype.setChartSize = function (skipAxes) {
  30820. var chart = this,
  30821. inverted = chart.inverted,
  30822. renderer = chart.renderer,
  30823. chartWidth = chart.chartWidth,
  30824. chartHeight = chart.chartHeight,
  30825. optionsChart = chart.options.chart,
  30826. spacing = chart.spacing,
  30827. clipOffset = chart.clipOffset;
  30828. var plotLeft,
  30829. plotTop,
  30830. plotWidth,
  30831. plotHeight;
  30832. /**
  30833. * The current left position of the plot area in pixels.
  30834. *
  30835. * @name Highcharts.Chart#plotLeft
  30836. * @type {number}
  30837. */
  30838. chart.plotLeft = plotLeft = Math.round(chart.plotLeft);
  30839. /**
  30840. * The current top position of the plot area in pixels.
  30841. *
  30842. * @name Highcharts.Chart#plotTop
  30843. * @type {number}
  30844. */
  30845. chart.plotTop = plotTop = Math.round(chart.plotTop);
  30846. /**
  30847. * The current width of the plot area in pixels.
  30848. *
  30849. * @name Highcharts.Chart#plotWidth
  30850. * @type {number}
  30851. */
  30852. chart.plotWidth = plotWidth = Math.max(0, Math.round(chartWidth - plotLeft - chart.marginRight));
  30853. /**
  30854. * The current height of the plot area in pixels.
  30855. *
  30856. * @name Highcharts.Chart#plotHeight
  30857. * @type {number}
  30858. */
  30859. chart.plotHeight = plotHeight = Math.max(0, Math.round(chartHeight - plotTop - chart.marginBottom));
  30860. chart.plotSizeX = inverted ? plotHeight : plotWidth;
  30861. chart.plotSizeY = inverted ? plotWidth : plotHeight;
  30862. chart.plotBorderWidth = optionsChart.plotBorderWidth || 0;
  30863. // Set boxes used for alignment
  30864. chart.spacingBox = renderer.spacingBox = {
  30865. x: spacing[3],
  30866. y: spacing[0],
  30867. width: chartWidth - spacing[3] - spacing[1],
  30868. height: chartHeight - spacing[0] - spacing[2]
  30869. };
  30870. chart.plotBox = renderer.plotBox = {
  30871. x: plotLeft,
  30872. y: plotTop,
  30873. width: plotWidth,
  30874. height: plotHeight
  30875. };
  30876. var plotBorderWidth = 2 * Math.floor(chart.plotBorderWidth / 2),
  30877. clipX = Math.ceil(Math.max(plotBorderWidth,
  30878. clipOffset[3]) / 2),
  30879. clipY = Math.ceil(Math.max(plotBorderWidth,
  30880. clipOffset[0]) / 2);
  30881. chart.clipBox = {
  30882. x: clipX,
  30883. y: clipY,
  30884. width: Math.floor(chart.plotSizeX -
  30885. Math.max(plotBorderWidth, clipOffset[1]) / 2 -
  30886. clipX),
  30887. height: Math.max(0, Math.floor(chart.plotSizeY -
  30888. Math.max(plotBorderWidth, clipOffset[2]) / 2 -
  30889. clipY))
  30890. };
  30891. if (!skipAxes) {
  30892. chart.axes.forEach(function (axis) {
  30893. axis.setAxisSize();
  30894. axis.setAxisTranslation();
  30895. });
  30896. renderer.alignElements();
  30897. }
  30898. fireEvent(chart, 'afterSetChartSize', { skipAxes: skipAxes });
  30899. };
  30900. /**
  30901. * Initial margins before auto size margins are applied.
  30902. *
  30903. * @private
  30904. * @function Highcharts.Chart#resetMargins
  30905. */
  30906. Chart.prototype.resetMargins = function () {
  30907. fireEvent(this, 'resetMargins');
  30908. var chart = this,
  30909. chartOptions = chart.options.chart;
  30910. // Create margin and spacing array
  30911. ['margin', 'spacing'].forEach(function splashArrays(target) {
  30912. var value = chartOptions[target],
  30913. values = isObject(value) ? value : [value,
  30914. value,
  30915. value,
  30916. value];
  30917. [
  30918. 'Top',
  30919. 'Right',
  30920. 'Bottom',
  30921. 'Left'
  30922. ].forEach(function (sideName, side) {
  30923. chart[target][side] = pick(chartOptions[target + sideName], values[side]);
  30924. });
  30925. });
  30926. // Set margin names like chart.plotTop, chart.plotLeft,
  30927. // chart.marginRight, chart.marginBottom.
  30928. marginNames.forEach(function (m, side) {
  30929. chart[m] = pick(chart.margin[side], chart.spacing[side]);
  30930. });
  30931. chart.axisOffset = [0, 0, 0, 0]; // top, right, bottom, left
  30932. chart.clipOffset = [0, 0, 0, 0];
  30933. };
  30934. /**
  30935. * Internal function to draw or redraw the borders and backgrounds for chart
  30936. * and plot area.
  30937. *
  30938. * @private
  30939. * @function Highcharts.Chart#drawChartBox
  30940. * @fires Highcharts.Chart#event:afterDrawChartBox
  30941. */
  30942. Chart.prototype.drawChartBox = function () {
  30943. var chart = this,
  30944. optionsChart = chart.options.chart,
  30945. renderer = chart.renderer,
  30946. chartWidth = chart.chartWidth,
  30947. chartHeight = chart.chartHeight,
  30948. styledMode = chart.styledMode,
  30949. plotBGImage = chart.plotBGImage,
  30950. chartBackgroundColor = optionsChart.backgroundColor,
  30951. plotBackgroundColor = optionsChart.plotBackgroundColor,
  30952. plotBackgroundImage = optionsChart.plotBackgroundImage,
  30953. plotLeft = chart.plotLeft,
  30954. plotTop = chart.plotTop,
  30955. plotWidth = chart.plotWidth,
  30956. plotHeight = chart.plotHeight,
  30957. plotBox = chart.plotBox,
  30958. clipRect = chart.clipRect,
  30959. clipBox = chart.clipBox;
  30960. var chartBackground = chart.chartBackground,
  30961. plotBackground = chart.plotBackground,
  30962. plotBorder = chart.plotBorder,
  30963. chartBorderWidth,
  30964. mgn,
  30965. bgAttr,
  30966. verb = 'animate';
  30967. // Chart area
  30968. if (!chartBackground) {
  30969. chart.chartBackground = chartBackground = renderer.rect()
  30970. .addClass('highcharts-background')
  30971. .add();
  30972. verb = 'attr';
  30973. }
  30974. if (!styledMode) {
  30975. // Presentational
  30976. chartBorderWidth = optionsChart.borderWidth || 0;
  30977. mgn = chartBorderWidth + (optionsChart.shadow ? 8 : 0);
  30978. bgAttr = {
  30979. fill: chartBackgroundColor || 'none'
  30980. };
  30981. if (chartBorderWidth || chartBackground['stroke-width']) { // #980
  30982. bgAttr.stroke = optionsChart.borderColor;
  30983. bgAttr['stroke-width'] = chartBorderWidth;
  30984. }
  30985. chartBackground
  30986. .attr(bgAttr)
  30987. .shadow(optionsChart.shadow);
  30988. }
  30989. else {
  30990. chartBorderWidth = mgn = chartBackground.strokeWidth();
  30991. }
  30992. chartBackground[verb]({
  30993. x: mgn / 2,
  30994. y: mgn / 2,
  30995. width: chartWidth - mgn - chartBorderWidth % 2,
  30996. height: chartHeight - mgn - chartBorderWidth % 2,
  30997. r: optionsChart.borderRadius
  30998. });
  30999. // Plot background
  31000. verb = 'animate';
  31001. if (!plotBackground) {
  31002. verb = 'attr';
  31003. chart.plotBackground = plotBackground = renderer.rect()
  31004. .addClass('highcharts-plot-background')
  31005. .add();
  31006. }
  31007. plotBackground[verb](plotBox);
  31008. if (!styledMode) {
  31009. // Presentational attributes for the background
  31010. plotBackground
  31011. .attr({
  31012. fill: plotBackgroundColor || 'none'
  31013. })
  31014. .shadow(optionsChart.plotShadow);
  31015. // Create the background image
  31016. if (plotBackgroundImage) {
  31017. if (!plotBGImage) {
  31018. chart.plotBGImage = renderer.image(plotBackgroundImage, plotLeft, plotTop, plotWidth, plotHeight).add();
  31019. }
  31020. else {
  31021. if (plotBackgroundImage !== plotBGImage.attr('href')) {
  31022. plotBGImage.attr('href', plotBackgroundImage);
  31023. }
  31024. plotBGImage.animate(plotBox);
  31025. }
  31026. }
  31027. }
  31028. // Plot clip
  31029. if (!clipRect) {
  31030. chart.clipRect = renderer.clipRect(clipBox);
  31031. }
  31032. else {
  31033. clipRect.animate({
  31034. width: clipBox.width,
  31035. height: clipBox.height
  31036. });
  31037. }
  31038. // Plot area border
  31039. verb = 'animate';
  31040. if (!plotBorder) {
  31041. verb = 'attr';
  31042. chart.plotBorder = plotBorder = renderer.rect()
  31043. .addClass('highcharts-plot-border')
  31044. .attr({
  31045. zIndex: 1 // Above the grid
  31046. })
  31047. .add();
  31048. }
  31049. if (!styledMode) {
  31050. // Presentational
  31051. plotBorder.attr({
  31052. stroke: optionsChart.plotBorderColor,
  31053. 'stroke-width': optionsChart.plotBorderWidth || 0,
  31054. fill: 'none'
  31055. });
  31056. }
  31057. plotBorder[verb](plotBorder.crisp({
  31058. x: plotLeft,
  31059. y: plotTop,
  31060. width: plotWidth,
  31061. height: plotHeight
  31062. }, -plotBorder.strokeWidth())); // #3282 plotBorder should be negative;
  31063. // reset
  31064. chart.isDirtyBox = false;
  31065. fireEvent(this, 'afterDrawChartBox');
  31066. };
  31067. /**
  31068. * Detect whether a certain chart property is needed based on inspecting its
  31069. * options and series. This mainly applies to the chart.inverted property,
  31070. * and in extensions to the chart.angular and chart.polar properties.
  31071. *
  31072. * @private
  31073. * @function Highcharts.Chart#propFromSeries
  31074. * @return {void}
  31075. */
  31076. Chart.prototype.propFromSeries = function () {
  31077. var chart = this,
  31078. optionsChart = chart.options.chart,
  31079. seriesOptions = chart.options.series;
  31080. var i,
  31081. klass,
  31082. value;
  31083. /**
  31084. * The flag is set to `true` if a series of the chart is inverted.
  31085. *
  31086. * @name Highcharts.Chart#inverted
  31087. * @type {boolean|undefined}
  31088. */
  31089. ['inverted', 'angular', 'polar'].forEach(function (key) {
  31090. // The default series type's class
  31091. klass = seriesTypes[(optionsChart.type || optionsChart.defaultSeriesType)];
  31092. // Get the value from available chart-wide properties
  31093. value =
  31094. // It is set in the options:
  31095. optionsChart[key] ||
  31096. // The default series class:
  31097. (klass && klass.prototype[key]);
  31098. // requires it
  31099. // 4. Check if any the chart's series require it
  31100. i = seriesOptions && seriesOptions.length;
  31101. while (!value && i--) {
  31102. klass = seriesTypes[seriesOptions[i].type];
  31103. if (klass && klass.prototype[key]) {
  31104. value = true;
  31105. }
  31106. }
  31107. // Set the chart property
  31108. chart[key] = value;
  31109. });
  31110. };
  31111. /**
  31112. * Internal function to link two or more series together, based on the
  31113. * `linkedTo` option. This is done from `Chart.render`, and after
  31114. * `Chart.addSeries` and `Series.remove`.
  31115. *
  31116. * @private
  31117. * @function Highcharts.Chart#linkSeries
  31118. * @fires Highcharts.Chart#event:afterLinkSeries
  31119. */
  31120. Chart.prototype.linkSeries = function () {
  31121. var chart = this,
  31122. chartSeries = chart.series;
  31123. // Reset links
  31124. chartSeries.forEach(function (series) {
  31125. series.linkedSeries.length = 0;
  31126. });
  31127. // Apply new links
  31128. chartSeries.forEach(function (series) {
  31129. var linkedTo = series.options.linkedTo;
  31130. if (isString(linkedTo)) {
  31131. if (linkedTo === ':previous') {
  31132. linkedTo = chart.series[series.index - 1];
  31133. }
  31134. else {
  31135. linkedTo = chart.get(linkedTo);
  31136. }
  31137. // #3341 avoid mutual linking
  31138. if (linkedTo && linkedTo.linkedParent !== series) {
  31139. linkedTo.linkedSeries.push(series);
  31140. series.linkedParent = linkedTo;
  31141. if (linkedTo.enabledDataSorting) {
  31142. series.setDataSortingOptions();
  31143. }
  31144. series.visible = pick(series.options.visible, linkedTo.options.visible, series.visible); // #3879
  31145. }
  31146. }
  31147. });
  31148. fireEvent(this, 'afterLinkSeries');
  31149. };
  31150. /**
  31151. * Render series for the chart.
  31152. *
  31153. * @private
  31154. * @function Highcharts.Chart#renderSeries
  31155. */
  31156. Chart.prototype.renderSeries = function () {
  31157. this.series.forEach(function (serie) {
  31158. serie.translate();
  31159. serie.render();
  31160. });
  31161. };
  31162. /**
  31163. * Render labels for the chart.
  31164. *
  31165. * @private
  31166. * @function Highcharts.Chart#renderLabels
  31167. */
  31168. Chart.prototype.renderLabels = function () {
  31169. var chart = this,
  31170. labels = chart.options.labels;
  31171. if (labels.items) {
  31172. labels.items.forEach(function (label) {
  31173. var style = extend(labels.style,
  31174. label.style),
  31175. x = pInt(style.left) + chart.plotLeft,
  31176. y = pInt(style.top) + chart.plotTop + 12;
  31177. // delete to prevent rewriting in IE
  31178. delete style.left;
  31179. delete style.top;
  31180. chart.renderer.text(label.html, x, y)
  31181. .attr({ zIndex: 2 })
  31182. .css(style)
  31183. .add();
  31184. });
  31185. }
  31186. };
  31187. /**
  31188. * Render all graphics for the chart. Runs internally on initialization.
  31189. *
  31190. * @private
  31191. * @function Highcharts.Chart#render
  31192. */
  31193. Chart.prototype.render = function () {
  31194. var chart = this,
  31195. axes = chart.axes,
  31196. colorAxis = chart.colorAxis,
  31197. renderer = chart.renderer,
  31198. options = chart.options,
  31199. renderAxes = function (axes) {
  31200. axes.forEach(function (axis) {
  31201. if (axis.visible) {
  31202. axis.render();
  31203. }
  31204. });
  31205. };
  31206. var correction = 0; // correction for X axis labels
  31207. // Title
  31208. chart.setTitle();
  31209. /**
  31210. * The overview of the chart's series.
  31211. *
  31212. * @name Highcharts.Chart#legend
  31213. * @type {Highcharts.Legend}
  31214. */
  31215. chart.legend = new Legend(chart, options.legend);
  31216. // Get stacks
  31217. if (chart.getStacks) {
  31218. chart.getStacks();
  31219. }
  31220. // Get chart margins
  31221. chart.getMargins(true);
  31222. chart.setChartSize();
  31223. // Record preliminary dimensions for later comparison
  31224. var tempWidth = chart.plotWidth;
  31225. axes.some(function (axis) {
  31226. if (axis.horiz &&
  31227. axis.visible &&
  31228. axis.options.labels.enabled &&
  31229. axis.series.length) {
  31230. // 21 is the most common correction for X axis labels
  31231. correction = 21;
  31232. return true;
  31233. }
  31234. });
  31235. // use Math.max to prevent negative plotHeight
  31236. chart.plotHeight = Math.max(chart.plotHeight - correction, 0);
  31237. var tempHeight = chart.plotHeight;
  31238. // Get margins by pre-rendering axes
  31239. axes.forEach(function (axis) {
  31240. axis.setScale();
  31241. });
  31242. chart.getAxisMargins();
  31243. // If the plot area size has changed significantly, calculate tick
  31244. // positions again
  31245. var redoHorizontal = tempWidth / chart.plotWidth > 1.1;
  31246. // Height is more sensitive, use lower threshold
  31247. var redoVertical = tempHeight / chart.plotHeight > 1.05;
  31248. if (redoHorizontal || redoVertical) {
  31249. axes.forEach(function (axis) {
  31250. if ((axis.horiz && redoHorizontal) ||
  31251. (!axis.horiz && redoVertical)) {
  31252. // update to reflect the new margins
  31253. axis.setTickInterval(true);
  31254. }
  31255. });
  31256. chart.getMargins(); // second pass to check for new labels
  31257. }
  31258. // Draw the borders and backgrounds
  31259. chart.drawChartBox();
  31260. // Axes
  31261. if (chart.hasCartesianSeries) {
  31262. renderAxes(axes);
  31263. }
  31264. else if (colorAxis && colorAxis.length) {
  31265. renderAxes(colorAxis);
  31266. }
  31267. // The series
  31268. if (!chart.seriesGroup) {
  31269. chart.seriesGroup = renderer.g('series-group')
  31270. .attr({ zIndex: 3 })
  31271. .add();
  31272. }
  31273. chart.renderSeries();
  31274. // Labels
  31275. chart.renderLabels();
  31276. // Credits
  31277. chart.addCredits();
  31278. // Handle responsiveness
  31279. if (chart.setResponsive) {
  31280. chart.setResponsive();
  31281. }
  31282. // Set flag
  31283. chart.hasRendered = true;
  31284. };
  31285. /**
  31286. * Set a new credits label for the chart.
  31287. *
  31288. * @sample highcharts/credits/credits-update/
  31289. * Add and update credits
  31290. *
  31291. * @function Highcharts.Chart#addCredits
  31292. *
  31293. * @param {Highcharts.CreditsOptions} [credits]
  31294. * A configuration object for the new credits.
  31295. */
  31296. Chart.prototype.addCredits = function (credits) {
  31297. var chart = this,
  31298. creds = merge(true,
  31299. this.options.credits,
  31300. credits);
  31301. if (creds.enabled && !this.credits) {
  31302. /**
  31303. * The chart's credits label. The label has an `update` method that
  31304. * allows setting new options as per the
  31305. * [credits options set](https://api.highcharts.com/highcharts/credits).
  31306. *
  31307. * @name Highcharts.Chart#credits
  31308. * @type {Highcharts.SVGElement}
  31309. */
  31310. this.credits = this.renderer.text(creds.text + (this.mapCredits || ''), 0, 0)
  31311. .addClass('highcharts-credits')
  31312. .on('click', function () {
  31313. if (creds.href) {
  31314. win.location.href = creds.href;
  31315. }
  31316. })
  31317. .attr({
  31318. align: creds.position.align,
  31319. zIndex: 8
  31320. });
  31321. if (!chart.styledMode) {
  31322. this.credits.css(creds.style);
  31323. }
  31324. this.credits
  31325. .add()
  31326. .align(creds.position);
  31327. // Dynamically update
  31328. this.credits.update = function (options) {
  31329. chart.credits = chart.credits.destroy();
  31330. chart.addCredits(options);
  31331. };
  31332. }
  31333. };
  31334. /**
  31335. * Remove the chart and purge memory. This method is called internally
  31336. * before adding a second chart into the same container, as well as on
  31337. * window unload to prevent leaks.
  31338. *
  31339. * @sample highcharts/members/chart-destroy/
  31340. * Destroy the chart from a button
  31341. * @sample stock/members/chart-destroy/
  31342. * Destroy with Highcharts Stock
  31343. *
  31344. * @function Highcharts.Chart#destroy
  31345. *
  31346. * @fires Highcharts.Chart#event:destroy
  31347. */
  31348. Chart.prototype.destroy = function () {
  31349. var chart = this,
  31350. axes = chart.axes,
  31351. series = chart.series,
  31352. container = chart.container,
  31353. parentNode = container && container.parentNode;
  31354. var i;
  31355. // fire the chart.destoy event
  31356. fireEvent(chart, 'destroy');
  31357. // Delete the chart from charts lookup array
  31358. if (chart.renderer.forExport) {
  31359. erase(charts, chart); // #6569
  31360. }
  31361. else {
  31362. charts[chart.index] = void 0;
  31363. }
  31364. H.chartCount--;
  31365. chart.renderTo.removeAttribute('data-highcharts-chart');
  31366. // remove events
  31367. removeEvent(chart);
  31368. // ==== Destroy collections:
  31369. // Destroy axes
  31370. i = axes.length;
  31371. while (i--) {
  31372. axes[i] = axes[i].destroy();
  31373. }
  31374. // Destroy scroller & scroller series before destroying base series
  31375. if (this.scroller && this.scroller.destroy) {
  31376. this.scroller.destroy();
  31377. }
  31378. // Destroy each series
  31379. i = series.length;
  31380. while (i--) {
  31381. series[i] = series[i].destroy();
  31382. }
  31383. // ==== Destroy chart properties:
  31384. [
  31385. 'title', 'subtitle', 'chartBackground', 'plotBackground',
  31386. 'plotBGImage', 'plotBorder', 'seriesGroup', 'clipRect', 'credits',
  31387. 'pointer', 'rangeSelector', 'legend', 'resetZoomButton', 'tooltip',
  31388. 'renderer'
  31389. ].forEach(function (name) {
  31390. var prop = chart[name];
  31391. if (prop && prop.destroy) {
  31392. chart[name] = prop.destroy();
  31393. }
  31394. });
  31395. // Remove container and all SVG, check container as it can break in IE
  31396. // when destroyed before finished loading
  31397. if (container) {
  31398. container.innerHTML = '';
  31399. removeEvent(container);
  31400. if (parentNode) {
  31401. discardElement(container);
  31402. }
  31403. }
  31404. // clean it all up
  31405. objectEach(chart, function (val, key) {
  31406. delete chart[key];
  31407. });
  31408. };
  31409. /**
  31410. * Prepare for first rendering after all data are loaded.
  31411. *
  31412. * @private
  31413. * @function Highcharts.Chart#firstRender
  31414. * @fires Highcharts.Chart#event:beforeRender
  31415. */
  31416. Chart.prototype.firstRender = function () {
  31417. var chart = this,
  31418. options = chart.options;
  31419. // Hook for oldIE to check whether the chart is ready to render
  31420. if (chart.isReadyToRender && !chart.isReadyToRender()) {
  31421. return;
  31422. }
  31423. // Create the container
  31424. chart.getContainer();
  31425. chart.resetMargins();
  31426. chart.setChartSize();
  31427. // Set the common chart properties (mainly invert) from the given series
  31428. chart.propFromSeries();
  31429. // get axes
  31430. chart.getAxes();
  31431. // Initialize the series
  31432. (isArray(options.series) ? options.series : []).forEach(
  31433. // #9680
  31434. function (serieOptions) {
  31435. chart.initSeries(serieOptions);
  31436. });
  31437. chart.linkSeries();
  31438. chart.setSeriesData();
  31439. // Run an event after axes and series are initialized, but before
  31440. // render. At this stage, the series data is indexed and cached in the
  31441. // xData and yData arrays, so we can access those before rendering. Used
  31442. // in Highcharts Stock.
  31443. fireEvent(chart, 'beforeRender');
  31444. // depends on inverted and on margins being set
  31445. if (Pointer) {
  31446. if (MSPointer.isRequired()) {
  31447. chart.pointer = new MSPointer(chart, options);
  31448. }
  31449. else {
  31450. /**
  31451. * The Pointer that keeps track of mouse and touch interaction.
  31452. *
  31453. * @memberof Highcharts.Chart
  31454. * @name pointer
  31455. * @type {Highcharts.Pointer}
  31456. * @instance
  31457. */
  31458. chart.pointer = new Pointer(chart, options);
  31459. }
  31460. }
  31461. chart.render();
  31462. chart.pointer.getChartPosition(); // #14973
  31463. // Fire the load event if there are no external images
  31464. if (!chart.renderer.imgCount && !chart.hasLoaded) {
  31465. chart.onload();
  31466. }
  31467. // If the chart was rendered outside the top container, put it back in
  31468. // (#3679)
  31469. chart.temporaryDisplay(true);
  31470. };
  31471. /**
  31472. * Internal function that runs on chart load, async if any images are loaded
  31473. * in the chart. Runs the callbacks and triggers the `load` and `render`
  31474. * events.
  31475. *
  31476. * @private
  31477. * @function Highcharts.Chart#onload
  31478. * @fires Highcharts.Chart#event:load
  31479. * @fires Highcharts.Chart#event:render
  31480. */
  31481. Chart.prototype.onload = function () {
  31482. // Run callbacks, first the ones registered by modules, then user's one
  31483. this.callbacks.concat([this.callback]).forEach(function (fn) {
  31484. // Chart destroyed in its own callback (#3600)
  31485. if (fn && typeof this.index !== 'undefined') {
  31486. fn.apply(this, [this]);
  31487. }
  31488. }, this);
  31489. fireEvent(this, 'load');
  31490. fireEvent(this, 'render');
  31491. // Set up auto resize, check for not destroyed (#6068)
  31492. if (defined(this.index)) {
  31493. this.setReflow(this.options.chart.reflow);
  31494. }
  31495. // Don't run again
  31496. this.hasLoaded = true;
  31497. };
  31498. /**
  31499. * Add a series to the chart after render time. Note that this method should
  31500. * never be used when adding data synchronously at chart render time, as it
  31501. * adds expense to the calculations and rendering. When adding data at the
  31502. * same time as the chart is initialized, add the series as a configuration
  31503. * option instead. With multiple axes, the `offset` is dynamically adjusted.
  31504. *
  31505. * @sample highcharts/members/chart-addseries/
  31506. * Add a series from a button
  31507. * @sample stock/members/chart-addseries/
  31508. * Add a series in Highcharts Stock
  31509. *
  31510. * @function Highcharts.Chart#addSeries
  31511. *
  31512. * @param {Highcharts.SeriesOptionsType} options
  31513. * The config options for the series.
  31514. *
  31515. * @param {boolean} [redraw=true]
  31516. * Whether to redraw the chart after adding.
  31517. *
  31518. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  31519. * Whether to apply animation, and optionally animation
  31520. * configuration.
  31521. *
  31522. * @return {Highcharts.Series}
  31523. * The newly created series object.
  31524. *
  31525. * @fires Highcharts.Chart#event:addSeries
  31526. * @fires Highcharts.Chart#event:afterAddSeries
  31527. */
  31528. Chart.prototype.addSeries = function (options, redraw, animation) {
  31529. var chart = this;
  31530. var series;
  31531. if (options) { // <- not necessary
  31532. redraw = pick(redraw, true); // defaults to true
  31533. fireEvent(chart, 'addSeries', { options: options }, function () {
  31534. series = chart.initSeries(options);
  31535. chart.isDirtyLegend = true;
  31536. chart.linkSeries();
  31537. if (series.enabledDataSorting) {
  31538. // We need to call `setData` after `linkSeries`
  31539. series.setData(options.data, false);
  31540. }
  31541. fireEvent(chart, 'afterAddSeries', { series: series });
  31542. if (redraw) {
  31543. chart.redraw(animation);
  31544. }
  31545. });
  31546. }
  31547. return series;
  31548. };
  31549. /**
  31550. * Add an axis to the chart after render time. Note that this method should
  31551. * never be used when adding data synchronously at chart render time, as it
  31552. * adds expense to the calculations and rendering. When adding data at the
  31553. * same time as the chart is initialized, add the axis as a configuration
  31554. * option instead.
  31555. *
  31556. * @sample highcharts/members/chart-addaxis/
  31557. * Add and remove axes
  31558. *
  31559. * @function Highcharts.Chart#addAxis
  31560. *
  31561. * @param {Highcharts.AxisOptions} options
  31562. * The axis options.
  31563. *
  31564. * @param {boolean} [isX=false]
  31565. * Whether it is an X axis or a value axis.
  31566. *
  31567. * @param {boolean} [redraw=true]
  31568. * Whether to redraw the chart after adding.
  31569. *
  31570. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  31571. * Whether and how to apply animation in the redraw.
  31572. *
  31573. * @return {Highcharts.Axis}
  31574. * The newly generated Axis object.
  31575. */
  31576. Chart.prototype.addAxis = function (options, isX, redraw, animation) {
  31577. return this.createAxis(isX ? 'xAxis' : 'yAxis', { axis: options, redraw: redraw, animation: animation });
  31578. };
  31579. /**
  31580. * Add a color axis to the chart after render time. Note that this method
  31581. * should never be used when adding data synchronously at chart render time,
  31582. * as it adds expense to the calculations and rendering. When adding data at
  31583. * the same time as the chart is initialized, add the axis as a
  31584. * configuration option instead.
  31585. *
  31586. * @sample highcharts/members/chart-addaxis/
  31587. * Add and remove axes
  31588. *
  31589. * @function Highcharts.Chart#addColorAxis
  31590. *
  31591. * @param {Highcharts.ColorAxisOptions} options
  31592. * The axis options.
  31593. *
  31594. * @param {boolean} [redraw=true]
  31595. * Whether to redraw the chart after adding.
  31596. *
  31597. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  31598. * Whether and how to apply animation in the redraw.
  31599. *
  31600. * @return {Highcharts.ColorAxis}
  31601. * The newly generated Axis object.
  31602. */
  31603. Chart.prototype.addColorAxis = function (options, redraw, animation) {
  31604. return this.createAxis('colorAxis', { axis: options, redraw: redraw, animation: animation });
  31605. };
  31606. /**
  31607. * Factory for creating different axis types.
  31608. *
  31609. * @private
  31610. * @function Highcharts.Chart#createAxis
  31611. *
  31612. * @param {string} type
  31613. * An axis type.
  31614. *
  31615. * @param {...Array<*>} arguments
  31616. * All arguments for the constructor.
  31617. *
  31618. * @return {Highcharts.Axis | Highcharts.ColorAxis}
  31619. * The newly generated Axis object.
  31620. */
  31621. Chart.prototype.createAxis = function (type, options) {
  31622. var isColorAxis = type === 'colorAxis',
  31623. axisOptions = options.axis,
  31624. redraw = options.redraw,
  31625. animation = options.animation,
  31626. userOptions = merge(axisOptions, {
  31627. index: this[type].length,
  31628. isX: type === 'xAxis'
  31629. });
  31630. var axis;
  31631. if (isColorAxis) {
  31632. axis = new H.ColorAxis(this, userOptions);
  31633. }
  31634. else {
  31635. axis = new Axis(this, userOptions);
  31636. }
  31637. if (isColorAxis) {
  31638. this.isDirtyLegend = true;
  31639. // Clear before 'bindAxes' (#11924)
  31640. this.axes.forEach(function (axis) {
  31641. axis.series = [];
  31642. });
  31643. this.series.forEach(function (series) {
  31644. series.bindAxes();
  31645. series.isDirtyData = true;
  31646. });
  31647. }
  31648. if (pick(redraw, true)) {
  31649. this.redraw(animation);
  31650. }
  31651. return axis;
  31652. };
  31653. /**
  31654. * Dim the chart and show a loading text or symbol. Options for the loading
  31655. * screen are defined in {@link
  31656. * https://api.highcharts.com/highcharts/loading|the loading options}.
  31657. *
  31658. * @sample highcharts/members/chart-hideloading/
  31659. * Show and hide loading from a button
  31660. * @sample highcharts/members/chart-showloading/
  31661. * Apply different text labels
  31662. * @sample stock/members/chart-show-hide-loading/
  31663. * Toggle loading in Highcharts Stock
  31664. *
  31665. * @function Highcharts.Chart#showLoading
  31666. *
  31667. * @param {string} [str]
  31668. * An optional text to show in the loading label instead of the
  31669. * default one. The default text is set in
  31670. * [lang.loading](https://api.highcharts.com/highcharts/lang.loading).
  31671. */
  31672. Chart.prototype.showLoading = function (str) {
  31673. var chart = this,
  31674. options = chart.options,
  31675. loadingOptions = options.loading,
  31676. setLoadingSize = function () {
  31677. if (loadingDiv) {
  31678. css(loadingDiv, {
  31679. left: chart.plotLeft + 'px',
  31680. top: chart.plotTop + 'px',
  31681. width: chart.plotWidth + 'px',
  31682. height: chart.plotHeight + 'px'
  31683. });
  31684. }
  31685. };
  31686. var loadingDiv = chart.loadingDiv,
  31687. loadingSpan = chart.loadingSpan;
  31688. // create the layer at the first call
  31689. if (!loadingDiv) {
  31690. chart.loadingDiv = loadingDiv = createElement('div', {
  31691. className: 'highcharts-loading highcharts-loading-hidden'
  31692. }, null, chart.container);
  31693. }
  31694. if (!loadingSpan) {
  31695. chart.loadingSpan = loadingSpan = createElement('span', { className: 'highcharts-loading-inner' }, null, loadingDiv);
  31696. addEvent(chart, 'redraw', setLoadingSize); // #1080
  31697. }
  31698. loadingDiv.className = 'highcharts-loading';
  31699. // Update text
  31700. AST.setElementHTML(loadingSpan, pick(str, options.lang.loading, ''));
  31701. if (!chart.styledMode) {
  31702. // Update visuals
  31703. css(loadingDiv, extend(loadingOptions.style, {
  31704. zIndex: 10
  31705. }));
  31706. css(loadingSpan, loadingOptions.labelStyle);
  31707. // Show it
  31708. if (!chart.loadingShown) {
  31709. css(loadingDiv, {
  31710. opacity: 0,
  31711. display: ''
  31712. });
  31713. animate(loadingDiv, {
  31714. opacity: loadingOptions.style.opacity || 0.5
  31715. }, {
  31716. duration: loadingOptions.showDuration || 0
  31717. });
  31718. }
  31719. }
  31720. chart.loadingShown = true;
  31721. setLoadingSize();
  31722. };
  31723. /**
  31724. * Hide the loading layer.
  31725. *
  31726. * @see Highcharts.Chart#showLoading
  31727. *
  31728. * @sample highcharts/members/chart-hideloading/
  31729. * Show and hide loading from a button
  31730. * @sample stock/members/chart-show-hide-loading/
  31731. * Toggle loading in Highcharts Stock
  31732. *
  31733. * @function Highcharts.Chart#hideLoading
  31734. */
  31735. Chart.prototype.hideLoading = function () {
  31736. var options = this.options,
  31737. loadingDiv = this.loadingDiv;
  31738. if (loadingDiv) {
  31739. loadingDiv.className =
  31740. 'highcharts-loading highcharts-loading-hidden';
  31741. if (!this.styledMode) {
  31742. animate(loadingDiv, {
  31743. opacity: 0
  31744. }, {
  31745. duration: options.loading.hideDuration || 100,
  31746. complete: function () {
  31747. css(loadingDiv, { display: 'none' });
  31748. }
  31749. });
  31750. }
  31751. }
  31752. this.loadingShown = false;
  31753. };
  31754. /**
  31755. * A generic function to update any element of the chart. Elements can be
  31756. * enabled and disabled, moved, re-styled, re-formatted etc.
  31757. *
  31758. * A special case is configuration objects that take arrays, for example
  31759. * [xAxis](https://api.highcharts.com/highcharts/xAxis),
  31760. * [yAxis](https://api.highcharts.com/highcharts/yAxis) or
  31761. * [series](https://api.highcharts.com/highcharts/series). For these
  31762. * collections, an `id` option is used to map the new option set to an
  31763. * existing object. If an existing object of the same id is not found, the
  31764. * corresponding item is updated. So for example, running `chart.update`
  31765. * with a series item without an id, will cause the existing chart's series
  31766. * with the same index in the series array to be updated. When the
  31767. * `oneToOne` parameter is true, `chart.update` will also take care of
  31768. * adding and removing items from the collection. Read more under the
  31769. * parameter description below.
  31770. *
  31771. * Note that when changing series data, `chart.update` may mutate the passed
  31772. * data options.
  31773. *
  31774. * See also the
  31775. * [responsive option set](https://api.highcharts.com/highcharts/responsive).
  31776. * Switching between `responsive.rules` basically runs `chart.update` under
  31777. * the hood.
  31778. *
  31779. * @sample highcharts/members/chart-update/
  31780. * Update chart geometry
  31781. *
  31782. * @function Highcharts.Chart#update
  31783. *
  31784. * @param {Highcharts.Options} options
  31785. * A configuration object for the new chart options.
  31786. *
  31787. * @param {boolean} [redraw=true]
  31788. * Whether to redraw the chart.
  31789. *
  31790. * @param {boolean} [oneToOne=false]
  31791. * When `true`, the `series`, `xAxis`, `yAxis` and `annotations`
  31792. * collections will be updated one to one, and items will be either
  31793. * added or removed to match the new updated options. For example,
  31794. * if the chart has two series and we call `chart.update` with a
  31795. * configuration containing three series, one will be added. If we
  31796. * call `chart.update` with one series, one will be removed. Setting
  31797. * an empty `series` array will remove all series, but leaving out
  31798. * the`series` property will leave all series untouched. If the
  31799. * series have id's, the new series options will be matched by id,
  31800. * and the remaining ones removed.
  31801. *
  31802. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation=true]
  31803. * Whether to apply animation, and optionally animation
  31804. * configuration.
  31805. *
  31806. * @fires Highcharts.Chart#event:update
  31807. * @fires Highcharts.Chart#event:afterUpdate
  31808. */
  31809. Chart.prototype.update = function (options, redraw, oneToOne, animation) {
  31810. var chart = this,
  31811. adders = {
  31812. credits: 'addCredits',
  31813. title: 'setTitle',
  31814. subtitle: 'setSubtitle',
  31815. caption: 'setCaption'
  31816. },
  31817. isResponsiveOptions = options.isResponsiveOptions,
  31818. itemsForRemoval = [];
  31819. var updateAllAxes,
  31820. updateAllSeries,
  31821. runSetSize;
  31822. fireEvent(chart, 'update', { options: options });
  31823. // If there are responsive rules in action, undo the responsive rules
  31824. // before we apply the updated options and replay the responsive rules
  31825. // on top from the chart.redraw function (#9617).
  31826. if (!isResponsiveOptions) {
  31827. chart.setResponsive(false, true);
  31828. }
  31829. options = cleanRecursively(options, chart.options);
  31830. chart.userOptions = merge(chart.userOptions, options);
  31831. // If the top-level chart option is present, some special updates are
  31832. // required
  31833. var optionsChart = options.chart;
  31834. if (optionsChart) {
  31835. merge(true, chart.options.chart, optionsChart);
  31836. // Setter function
  31837. if ('className' in optionsChart) {
  31838. chart.setClassName(optionsChart.className);
  31839. }
  31840. if ('reflow' in optionsChart) {
  31841. chart.setReflow(optionsChart.reflow);
  31842. }
  31843. if ('inverted' in optionsChart ||
  31844. 'polar' in optionsChart ||
  31845. 'type' in optionsChart) {
  31846. // Parse options.chart.inverted and options.chart.polar together
  31847. // with the available series.
  31848. chart.propFromSeries();
  31849. updateAllAxes = true;
  31850. }
  31851. if ('alignTicks' in optionsChart) { // #6452
  31852. updateAllAxes = true;
  31853. }
  31854. if ('events' in optionsChart) {
  31855. // Chart event handlers
  31856. registerEventOptions(this, optionsChart);
  31857. }
  31858. objectEach(optionsChart, function (val, key) {
  31859. if (chart.propsRequireUpdateSeries.indexOf('chart.' + key) !==
  31860. -1) {
  31861. updateAllSeries = true;
  31862. }
  31863. // Only dirty box
  31864. if (chart.propsRequireDirtyBox.indexOf(key) !== -1) {
  31865. chart.isDirtyBox = true;
  31866. }
  31867. // Chart setSize
  31868. if (chart.propsRequireReflow.indexOf(key) !== -1) {
  31869. if (isResponsiveOptions) {
  31870. chart.isDirtyBox = true;
  31871. }
  31872. else {
  31873. runSetSize = true;
  31874. }
  31875. }
  31876. });
  31877. if (!chart.styledMode && 'style' in optionsChart) {
  31878. chart.renderer.setStyle(optionsChart.style);
  31879. }
  31880. }
  31881. // Moved up, because tooltip needs updated plotOptions (#6218)
  31882. if (!chart.styledMode && options.colors) {
  31883. this.options.colors = options.colors;
  31884. }
  31885. if (options.time) {
  31886. // Maintaining legacy global time. If the chart is instanciated
  31887. // first with global time, then updated with time options, we need
  31888. // to create a new Time instance to avoid mutating the global time
  31889. // (#10536).
  31890. if (this.time === defaultTime) {
  31891. this.time = new Time(options.time);
  31892. }
  31893. // If we're updating, the time class is different from other chart
  31894. // classes (chart.legend, chart.tooltip etc) in that it doesn't know
  31895. // about the chart. The other chart[something].update functions also
  31896. // set the chart.options[something]. For the time class however we
  31897. // need to update the chart options separately. #14230.
  31898. merge(true, chart.options.time, options.time);
  31899. }
  31900. // Some option stuctures correspond one-to-one to chart objects that
  31901. // have update methods, for example
  31902. // options.credits => chart.credits
  31903. // options.legend => chart.legend
  31904. // options.title => chart.title
  31905. // options.tooltip => chart.tooltip
  31906. // options.subtitle => chart.subtitle
  31907. // options.mapNavigation => chart.mapNavigation
  31908. // options.navigator => chart.navigator
  31909. // options.scrollbar => chart.scrollbar
  31910. objectEach(options, function (val, key) {
  31911. if (chart[key] &&
  31912. typeof chart[key].update === 'function') {
  31913. chart[key].update(val, false);
  31914. // If a one-to-one object does not exist, look for an adder function
  31915. }
  31916. else if (typeof chart[adders[key]] === 'function') {
  31917. chart[adders[key]](val);
  31918. // Else, just merge the options. For nodes like loading, noData,
  31919. // plotOptions
  31920. }
  31921. else if (key !== 'colors' &&
  31922. chart.collectionsWithUpdate.indexOf(key) === -1) {
  31923. merge(true, chart.options[key], options[key]);
  31924. }
  31925. if (key !== 'chart' &&
  31926. chart.propsRequireUpdateSeries.indexOf(key) !== -1) {
  31927. updateAllSeries = true;
  31928. }
  31929. });
  31930. // Setters for collections. For axes and series, each item is referred
  31931. // by an id. If the id is not found, it defaults to the corresponding
  31932. // item in the collection, so setting one series without an id, will
  31933. // update the first series in the chart. Setting two series without
  31934. // an id will update the first and the second respectively (#6019)
  31935. // chart.update and responsive.
  31936. this.collectionsWithUpdate.forEach(function (coll) {
  31937. var indexMap;
  31938. if (options[coll]) {
  31939. // In stock charts, the navigator series are also part of the
  31940. // chart.series array, but those series should not be handled
  31941. // here (#8196) and neither should the navigator axis (#9671).
  31942. indexMap = [];
  31943. chart[coll].forEach(function (s, i) {
  31944. if (!s.options.isInternal) {
  31945. indexMap.push(pick(s.options.index, i));
  31946. }
  31947. });
  31948. splat(options[coll]).forEach(function (newOptions, i) {
  31949. var hasId = defined(newOptions.id);
  31950. var item;
  31951. // Match by id
  31952. if (hasId) {
  31953. item = chart.get(newOptions.id);
  31954. }
  31955. // No match by id found, match by index instead
  31956. if (!item && chart[coll]) {
  31957. item = chart[coll][indexMap ? indexMap[i] : i];
  31958. // Check if we grabbed an item with an exising but
  31959. // different id (#13541)
  31960. if (item && hasId && defined(item.options.id)) {
  31961. item = void 0;
  31962. }
  31963. }
  31964. if (item && item.coll === coll) {
  31965. item.update(newOptions, false);
  31966. if (oneToOne) {
  31967. item.touched = true;
  31968. }
  31969. }
  31970. // If oneToOne and no matching item is found, add one
  31971. if (!item && oneToOne && chart.collectionsWithInit[coll]) {
  31972. chart.collectionsWithInit[coll][0].apply(chart,
  31973. // [newOptions, ...extraArguments, redraw=false]
  31974. [
  31975. newOptions
  31976. ].concat(
  31977. // Not all initializers require extra args
  31978. chart.collectionsWithInit[coll][1] || []).concat([
  31979. false
  31980. ])).touched = true;
  31981. }
  31982. });
  31983. // Add items for removal
  31984. if (oneToOne) {
  31985. chart[coll].forEach(function (item) {
  31986. if (!item.touched && !item.options.isInternal) {
  31987. itemsForRemoval.push(item);
  31988. }
  31989. else {
  31990. delete item.touched;
  31991. }
  31992. });
  31993. }
  31994. }
  31995. });
  31996. itemsForRemoval.forEach(function (item) {
  31997. if (item.chart) { // #9097, avoid removing twice
  31998. item.remove(false);
  31999. }
  32000. });
  32001. if (updateAllAxes) {
  32002. chart.axes.forEach(function (axis) {
  32003. axis.update({}, false);
  32004. });
  32005. }
  32006. // Certain options require the whole series structure to be thrown away
  32007. // and rebuilt
  32008. if (updateAllSeries) {
  32009. chart.getSeriesOrderByLinks().forEach(function (series) {
  32010. // Avoid removed navigator series
  32011. if (series.chart) {
  32012. series.update({}, false);
  32013. }
  32014. }, this);
  32015. }
  32016. // Update size. Redraw is forced.
  32017. var newWidth = optionsChart && optionsChart.width;
  32018. var newHeight = optionsChart && (isString(optionsChart.height) ?
  32019. relativeLength(optionsChart.height,
  32020. newWidth || chart.chartWidth) :
  32021. optionsChart.height);
  32022. if (
  32023. // In this case, run chart.setSize with newWidth and newHeight which
  32024. // are undefined, only for reflowing chart elements because margin
  32025. // or spacing has been set (#8190)
  32026. runSetSize ||
  32027. // In this case, the size is actually set
  32028. (isNumber(newWidth) && newWidth !== chart.chartWidth) ||
  32029. (isNumber(newHeight) && newHeight !== chart.chartHeight)) {
  32030. chart.setSize(newWidth, newHeight, animation);
  32031. }
  32032. else if (pick(redraw, true)) {
  32033. chart.redraw(animation);
  32034. }
  32035. fireEvent(chart, 'afterUpdate', {
  32036. options: options,
  32037. redraw: redraw,
  32038. animation: animation
  32039. });
  32040. };
  32041. /**
  32042. * Shortcut to set the subtitle options. This can also be done from {@link
  32043. * Chart#update} or {@link Chart#setTitle}.
  32044. *
  32045. * @function Highcharts.Chart#setSubtitle
  32046. *
  32047. * @param {Highcharts.SubtitleOptions} options
  32048. * New subtitle options. The subtitle text itself is set by the
  32049. * `options.text` property.
  32050. */
  32051. Chart.prototype.setSubtitle = function (options, redraw) {
  32052. this.applyDescription('subtitle', options);
  32053. this.layOutTitles(redraw);
  32054. };
  32055. /**
  32056. * Set the caption options. This can also be done from {@link
  32057. * Chart#update}.
  32058. *
  32059. * @function Highcharts.Chart#setCaption
  32060. *
  32061. * @param {Highcharts.CaptionOptions} options
  32062. * New caption options. The caption text itself is set by the
  32063. * `options.text` property.
  32064. */
  32065. Chart.prototype.setCaption = function (options, redraw) {
  32066. this.applyDescription('caption', options);
  32067. this.layOutTitles(redraw);
  32068. };
  32069. /**
  32070. * Display the zoom button, so users can reset zoom to the default view
  32071. * settings.
  32072. *
  32073. * @function Highcharts.Chart#showResetZoom
  32074. *
  32075. * @fires Highcharts.Chart#event:afterShowResetZoom
  32076. * @fires Highcharts.Chart#event:beforeShowResetZoom
  32077. */
  32078. Chart.prototype.showResetZoom = function () {
  32079. var chart = this,
  32080. lang = defaultOptions.lang,
  32081. btnOptions = chart.options.chart.resetZoomButton,
  32082. theme = btnOptions.theme,
  32083. states = theme.states,
  32084. alignTo = (btnOptions.relativeTo === 'chart' ||
  32085. btnOptions.relativeTo === 'spacingBox' ?
  32086. null :
  32087. 'scrollablePlotBox');
  32088. /**
  32089. * @private
  32090. */
  32091. function zoomOut() {
  32092. chart.zoomOut();
  32093. }
  32094. fireEvent(this, 'beforeShowResetZoom', null, function () {
  32095. chart.resetZoomButton = chart.renderer
  32096. .button(lang.resetZoom, null, null, zoomOut, theme, states && states.hover)
  32097. .attr({
  32098. align: btnOptions.position.align,
  32099. title: lang.resetZoomTitle
  32100. })
  32101. .addClass('highcharts-reset-zoom')
  32102. .add()
  32103. .align(btnOptions.position, false, alignTo);
  32104. });
  32105. fireEvent(this, 'afterShowResetZoom');
  32106. };
  32107. /**
  32108. * Zoom the chart out after a user has zoomed in. See also
  32109. * [Axis.setExtremes](/class-reference/Highcharts.Axis#setExtremes).
  32110. *
  32111. * @function Highcharts.Chart#zoomOut
  32112. *
  32113. * @fires Highcharts.Chart#event:selection
  32114. */
  32115. Chart.prototype.zoomOut = function () {
  32116. fireEvent(this, 'selection', { resetSelection: true }, this.zoom);
  32117. };
  32118. /**
  32119. * Zoom into a given portion of the chart given by axis coordinates.
  32120. *
  32121. * @private
  32122. * @function Highcharts.Chart#zoom
  32123. * @param {Highcharts.SelectEventObject} event
  32124. */
  32125. Chart.prototype.zoom = function (event) {
  32126. var chart = this,
  32127. pointer = chart.pointer,
  32128. mouseDownPos = (chart.inverted ? pointer.mouseDownX : pointer.mouseDownY);
  32129. var displayButton = false,
  32130. hasZoomed;
  32131. // If zoom is called with no arguments, reset the axes
  32132. if (!event || event.resetSelection) {
  32133. chart.axes.forEach(function (axis) {
  32134. hasZoomed = axis.zoom();
  32135. });
  32136. pointer.initiated = false; // #6804
  32137. }
  32138. else { // else, zoom in on all axes
  32139. event.xAxis.concat(event.yAxis).forEach(function (axisData) {
  32140. var axis = axisData.axis,
  32141. axisStartPos = chart.inverted ? axis.left : axis.top,
  32142. axisEndPos = chart.inverted ?
  32143. axisStartPos + axis.width : axisStartPos + axis.height,
  32144. isXAxis = axis.isXAxis;
  32145. var isWithinPane = false;
  32146. // Check if zoomed area is within the pane (#1289).
  32147. // In case of multiple panes only one pane should be zoomed.
  32148. if ((!isXAxis &&
  32149. mouseDownPos >= axisStartPos &&
  32150. mouseDownPos <= axisEndPos) ||
  32151. isXAxis ||
  32152. !defined(mouseDownPos)) {
  32153. isWithinPane = true;
  32154. }
  32155. // don't zoom more than minRange
  32156. if (pointer[isXAxis ? 'zoomX' : 'zoomY'] && isWithinPane) {
  32157. hasZoomed = axis.zoom(axisData.min, axisData.max);
  32158. if (axis.displayBtn) {
  32159. displayButton = true;
  32160. }
  32161. }
  32162. });
  32163. }
  32164. // Show or hide the Reset zoom button
  32165. var resetZoomButton = chart.resetZoomButton;
  32166. if (displayButton && !resetZoomButton) {
  32167. chart.showResetZoom();
  32168. }
  32169. else if (!displayButton && isObject(resetZoomButton)) {
  32170. chart.resetZoomButton = resetZoomButton.destroy();
  32171. }
  32172. // Redraw
  32173. if (hasZoomed) {
  32174. chart.redraw(pick(chart.options.chart.animation, event && event.animation, chart.pointCount < 100));
  32175. }
  32176. };
  32177. /**
  32178. * Pan the chart by dragging the mouse across the pane. This function is
  32179. * called on mouse move, and the distance to pan is computed from chartX
  32180. * compared to the first chartX position in the dragging operation.
  32181. *
  32182. * @private
  32183. * @function Highcharts.Chart#pan
  32184. * @param {Highcharts.PointerEventObject} e
  32185. * @param {string} panning
  32186. */
  32187. Chart.prototype.pan = function (e, panning) {
  32188. var chart = this,
  32189. hoverPoints = chart.hoverPoints,
  32190. panningOptions = (typeof panning === 'object' ?
  32191. panning :
  32192. {
  32193. enabled: panning,
  32194. type: 'x'
  32195. }),
  32196. chartOptions = chart.options.chart,
  32197. hasMapNavigation = chart.options.mapNavigation &&
  32198. chart.options.mapNavigation.enabled;
  32199. if (chartOptions && chartOptions.panning) {
  32200. chartOptions.panning = panningOptions;
  32201. }
  32202. var type = panningOptions.type;
  32203. var doRedraw;
  32204. fireEvent(this, 'pan', { originalEvent: e }, function () {
  32205. // remove active points for shared tooltip
  32206. if (hoverPoints) {
  32207. hoverPoints.forEach(function (point) {
  32208. point.setState();
  32209. });
  32210. }
  32211. var axes = chart.xAxis;
  32212. if (type === 'xy') {
  32213. axes = axes.concat(chart.yAxis);
  32214. }
  32215. else if (type === 'y') {
  32216. axes = chart.yAxis;
  32217. }
  32218. var nextMousePos = {};
  32219. axes.forEach(function (axis) {
  32220. if (!axis.options.panningEnabled || axis.options.isInternal) {
  32221. return;
  32222. }
  32223. var horiz = axis.horiz, mousePos = e[horiz ? 'chartX' : 'chartY'], mouseDown = horiz ? 'mouseDownX' : 'mouseDownY', startPos = chart[mouseDown], halfPointRange = axis.minPointOffset || 0, pointRangeDirection = (axis.reversed && !chart.inverted) ||
  32224. (!axis.reversed && chart.inverted) ?
  32225. -1 :
  32226. 1, extremes = axis.getExtremes(), panMin = axis.toValue(startPos - mousePos, true) +
  32227. halfPointRange * pointRangeDirection, panMax = axis.toValue(startPos + axis.len - mousePos, true) -
  32228. ((halfPointRange * pointRangeDirection) ||
  32229. (axis.isXAxis && axis.pointRangePadding) ||
  32230. 0), flipped = panMax < panMin, hasVerticalPanning = axis.hasVerticalPanning();
  32231. var newMin = flipped ? panMax : panMin,
  32232. newMax = flipped ? panMin : panMax,
  32233. panningState = axis.panningState,
  32234. spill;
  32235. // General calculations of panning state.
  32236. // This is related to using vertical panning. (#11315).
  32237. if (hasVerticalPanning &&
  32238. !axis.isXAxis && (!panningState || panningState.isDirty)) {
  32239. axis.series.forEach(function (series) {
  32240. var processedData = series.getProcessedData(true),
  32241. dataExtremes = series.getExtremes(processedData.yData,
  32242. true);
  32243. if (!panningState) {
  32244. panningState = {
  32245. startMin: Number.MAX_VALUE,
  32246. startMax: -Number.MAX_VALUE
  32247. };
  32248. }
  32249. if (isNumber(dataExtremes.dataMin) &&
  32250. isNumber(dataExtremes.dataMax)) {
  32251. panningState.startMin = Math.min(pick(series.options.threshold, Infinity), dataExtremes.dataMin, panningState.startMin);
  32252. panningState.startMax = Math.max(pick(series.options.threshold, -Infinity), dataExtremes.dataMax, panningState.startMax);
  32253. }
  32254. });
  32255. }
  32256. var paddedMin = Math.min(pick(panningState && panningState.startMin,
  32257. extremes.dataMin),
  32258. halfPointRange ?
  32259. extremes.min :
  32260. axis.toValue(axis.toPixels(extremes.min) -
  32261. axis.minPixelPadding));
  32262. var paddedMax = Math.max(pick(panningState && panningState.startMax,
  32263. extremes.dataMax),
  32264. halfPointRange ?
  32265. extremes.max :
  32266. axis.toValue(axis.toPixels(extremes.max) +
  32267. axis.minPixelPadding));
  32268. axis.panningState = panningState;
  32269. // It is not necessary to calculate extremes on ordinal axis,
  32270. // because they are already calculated, so we don't want to
  32271. // override them.
  32272. if (!axis.isOrdinal) {
  32273. // If the new range spills over, either to the min or max,
  32274. // adjust the new range.
  32275. spill = paddedMin - newMin;
  32276. if (spill > 0) {
  32277. newMax += spill;
  32278. newMin = paddedMin;
  32279. }
  32280. spill = newMax - paddedMax;
  32281. if (spill > 0) {
  32282. newMax = paddedMax;
  32283. newMin -= spill;
  32284. }
  32285. // Set new extremes if they are actually new
  32286. if (axis.series.length &&
  32287. newMin !== extremes.min &&
  32288. newMax !== extremes.max &&
  32289. newMin >= paddedMin &&
  32290. newMax <= paddedMax) {
  32291. axis.setExtremes(newMin, newMax, false, false, { trigger: 'pan' });
  32292. if (!chart.resetZoomButton &&
  32293. !hasMapNavigation &&
  32294. // Show reset zoom button only when both newMin and
  32295. // newMax values are between padded axis range.
  32296. newMin !== paddedMin &&
  32297. newMax !== paddedMax &&
  32298. type.match('y')) {
  32299. chart.showResetZoom();
  32300. axis.displayBtn = false;
  32301. }
  32302. doRedraw = true;
  32303. }
  32304. // set new reference for next run:
  32305. nextMousePos[mouseDown] = mousePos;
  32306. }
  32307. });
  32308. objectEach(nextMousePos, function (pos, down) {
  32309. chart[down] = pos;
  32310. });
  32311. if (doRedraw) {
  32312. chart.redraw(false);
  32313. }
  32314. css(chart.container, { cursor: 'move' });
  32315. });
  32316. };
  32317. return Chart;
  32318. }());
  32319. extend(Chart.prototype, {
  32320. // Hook for adding callbacks in modules
  32321. callbacks: [],
  32322. /**
  32323. * These collections (arrays) implement `Chart.addSomethig` method used in
  32324. * chart.update() to create new object in the collection. Equivalent for
  32325. * deleting is resolved by simple `Somethig.remove()`.
  32326. *
  32327. * Note: We need to define these references after initializers are bound to
  32328. * chart's prototype.
  32329. */
  32330. collectionsWithInit: {
  32331. // collectionName: [ initializingMethod, [extraArguments] ]
  32332. xAxis: [Chart.prototype.addAxis, [true]],
  32333. yAxis: [Chart.prototype.addAxis, [false]],
  32334. series: [Chart.prototype.addSeries]
  32335. },
  32336. /**
  32337. * These collections (arrays) implement update() methods with support for
  32338. * one-to-one option.
  32339. */
  32340. collectionsWithUpdate: [
  32341. 'xAxis',
  32342. 'yAxis',
  32343. 'zAxis',
  32344. 'series'
  32345. ],
  32346. /**
  32347. * These properties cause isDirtyBox to be set to true when updating. Can be
  32348. * extended from plugins.
  32349. */
  32350. propsRequireDirtyBox: [
  32351. 'backgroundColor',
  32352. 'borderColor',
  32353. 'borderWidth',
  32354. 'borderRadius',
  32355. 'plotBackgroundColor',
  32356. 'plotBackgroundImage',
  32357. 'plotBorderColor',
  32358. 'plotBorderWidth',
  32359. 'plotShadow',
  32360. 'shadow'
  32361. ],
  32362. /**
  32363. * These properties require a full reflow of chart elements, best
  32364. * implemented through running `Chart.setSize` internally (#8190).
  32365. * @type {Array}
  32366. */
  32367. propsRequireReflow: [
  32368. 'margin',
  32369. 'marginTop',
  32370. 'marginRight',
  32371. 'marginBottom',
  32372. 'marginLeft',
  32373. 'spacing',
  32374. 'spacingTop',
  32375. 'spacingRight',
  32376. 'spacingBottom',
  32377. 'spacingLeft'
  32378. ],
  32379. /**
  32380. * These properties cause all series to be updated when updating. Can be
  32381. * extended from plugins.
  32382. */
  32383. propsRequireUpdateSeries: [
  32384. 'chart.inverted',
  32385. 'chart.polar',
  32386. 'chart.ignoreHiddenSeries',
  32387. 'chart.type',
  32388. 'colors',
  32389. 'plotOptions',
  32390. 'time',
  32391. 'tooltip'
  32392. ]
  32393. });
  32394. /* *
  32395. *
  32396. * Export
  32397. *
  32398. * */
  32399. /* *
  32400. *
  32401. * API Declarations
  32402. *
  32403. * */
  32404. /**
  32405. * Callback for chart constructors.
  32406. *
  32407. * @callback Highcharts.ChartCallbackFunction
  32408. *
  32409. * @param {Highcharts.Chart} chart
  32410. * Created chart.
  32411. */
  32412. /**
  32413. * Format a number and return a string based on input settings.
  32414. *
  32415. * @callback Highcharts.NumberFormatterCallbackFunction
  32416. *
  32417. * @param {number} number
  32418. * The input number to format.
  32419. *
  32420. * @param {number} decimals
  32421. * The amount of decimals. A value of -1 preserves the amount in the
  32422. * input number.
  32423. *
  32424. * @param {string} [decimalPoint]
  32425. * The decimal point, defaults to the one given in the lang options, or
  32426. * a dot.
  32427. *
  32428. * @param {string} [thousandsSep]
  32429. * The thousands separator, defaults to the one given in the lang
  32430. * options, or a space character.
  32431. *
  32432. * @return {string} The formatted number.
  32433. */
  32434. /**
  32435. * The chart title. The title has an `update` method that allows modifying the
  32436. * options directly or indirectly via `chart.update`.
  32437. *
  32438. * @interface Highcharts.TitleObject
  32439. * @extends Highcharts.SVGElement
  32440. */ /**
  32441. * Modify options for the title.
  32442. *
  32443. * @function Highcharts.TitleObject#update
  32444. *
  32445. * @param {Highcharts.TitleOptions} titleOptions
  32446. * Options to modify.
  32447. *
  32448. * @param {boolean} [redraw=true]
  32449. * Whether to redraw the chart after the title is altered. If doing more
  32450. * operations on the chart, it is a good idea to set redraw to false and
  32451. * call {@link Chart#redraw} after.
  32452. */
  32453. /**
  32454. * The chart subtitle. The subtitle has an `update` method that
  32455. * allows modifying the options directly or indirectly via
  32456. * `chart.update`.
  32457. *
  32458. * @interface Highcharts.SubtitleObject
  32459. * @extends Highcharts.SVGElement
  32460. */ /**
  32461. * Modify options for the subtitle.
  32462. *
  32463. * @function Highcharts.SubtitleObject#update
  32464. *
  32465. * @param {Highcharts.SubtitleOptions} subtitleOptions
  32466. * Options to modify.
  32467. *
  32468. * @param {boolean} [redraw=true]
  32469. * Whether to redraw the chart after the subtitle is altered. If doing
  32470. * more operations on the chart, it is a good idea to set redraw to false
  32471. * and call {@link Chart#redraw} after.
  32472. */
  32473. /**
  32474. * The chart caption. The caption has an `update` method that
  32475. * allows modifying the options directly or indirectly via
  32476. * `chart.update`.
  32477. *
  32478. * @interface Highcharts.CaptionObject
  32479. * @extends Highcharts.SVGElement
  32480. */ /**
  32481. * Modify options for the caption.
  32482. *
  32483. * @function Highcharts.CaptionObject#update
  32484. *
  32485. * @param {Highcharts.CaptionOptions} captionOptions
  32486. * Options to modify.
  32487. *
  32488. * @param {boolean} [redraw=true]
  32489. * Whether to redraw the chart after the caption is altered. If doing
  32490. * more operations on the chart, it is a good idea to set redraw to false
  32491. * and call {@link Chart#redraw} after.
  32492. */
  32493. /**
  32494. * @interface Highcharts.ChartIsInsideOptionsObject
  32495. */ /**
  32496. * @name Highcharts.ChartIsInsideOptionsObject#ignoreX
  32497. * @type {boolean|undefined}
  32498. */ /**
  32499. * @name Highcharts.ChartIsInsideOptionsObject#ignoreY
  32500. * @type {boolean|undefined}
  32501. */ /**
  32502. * @name Highcharts.ChartIsInsideOptionsObject#inverted
  32503. * @type {boolean|undefined}
  32504. */ /**
  32505. * @name Highcharts.ChartIsInsideOptionsObject#paneCoordinates
  32506. * @type {boolean|undefined}
  32507. */ /**
  32508. * @name Highcharts.ChartIsInsideOptionsObject#series
  32509. * @type {Highcharts.Series|undefined}
  32510. */ /**
  32511. * @name Highcharts.ChartIsInsideOptionsObject#visiblePlotOnly
  32512. * @type {boolean|undefined}
  32513. */
  32514. ''; // include doclets above in transpilat
  32515. return Chart;
  32516. });
  32517. _registerModule(_modules, 'Mixins/LegendSymbol.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  32518. /* *
  32519. *
  32520. * (c) 2010-2021 Torstein Honsi
  32521. *
  32522. * License: www.highcharts.com/license
  32523. *
  32524. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  32525. *
  32526. * */
  32527. var merge = U.merge,
  32528. pick = U.pick;
  32529. /* eslint-disable valid-jsdoc */
  32530. /**
  32531. * Legend symbol mixin.
  32532. *
  32533. * @private
  32534. * @mixin Highcharts.LegendSymbolMixin
  32535. */
  32536. var LegendSymbolMixin = H.LegendSymbolMixin = {
  32537. /**
  32538. * Get the series' symbol in the legend
  32539. *
  32540. * @private
  32541. * @function Highcharts.LegendSymbolMixin.drawRectangle
  32542. *
  32543. * @param {Highcharts.Legend} legend
  32544. * The legend object
  32545. *
  32546. * @param {Highcharts.Point|Highcharts.Series} item
  32547. * The series (this) or point
  32548. */
  32549. drawRectangle: function (legend,
  32550. item) {
  32551. var options = legend.options,
  32552. symbolHeight = legend.symbolHeight,
  32553. square = options.squareSymbol,
  32554. symbolWidth = square ? symbolHeight : legend.symbolWidth;
  32555. item.legendSymbol = this.chart.renderer.rect(square ? (legend.symbolWidth - symbolHeight) / 2 : 0, legend.baseline - symbolHeight + 1, // #3988
  32556. symbolWidth, symbolHeight, pick(legend.options.symbolRadius, symbolHeight / 2))
  32557. .addClass('highcharts-point')
  32558. .attr({
  32559. zIndex: 3
  32560. }).add(item.legendGroup);
  32561. },
  32562. /**
  32563. * Get the series' symbol in the legend. This method should be overridable
  32564. * to create custom symbols through
  32565. * Highcharts.seriesTypes[type].prototype.drawLegendSymbols.
  32566. *
  32567. * @private
  32568. * @function Highcharts.LegendSymbolMixin.drawLineMarker
  32569. *
  32570. * @param {Highcharts.Legend} legend
  32571. * The legend object.
  32572. */
  32573. drawLineMarker: function (legend) {
  32574. var options = this.options,
  32575. markerOptions = options.marker,
  32576. radius,
  32577. legendSymbol,
  32578. symbolWidth = legend.symbolWidth,
  32579. symbolHeight = legend.symbolHeight,
  32580. generalRadius = symbolHeight / 2,
  32581. renderer = this.chart.renderer,
  32582. legendItemGroup = this.legendGroup,
  32583. verticalCenter = legend.baseline -
  32584. Math.round(legend.fontMetrics.b * 0.3),
  32585. attr = {};
  32586. // Draw the line
  32587. if (!this.chart.styledMode) {
  32588. attr = {
  32589. 'stroke-width': options.lineWidth || 0
  32590. };
  32591. if (options.dashStyle) {
  32592. attr.dashstyle = options.dashStyle;
  32593. }
  32594. }
  32595. this.legendLine = renderer
  32596. .path([
  32597. ['M', 0, verticalCenter],
  32598. ['L', symbolWidth, verticalCenter]
  32599. ])
  32600. .addClass('highcharts-graph')
  32601. .attr(attr)
  32602. .add(legendItemGroup);
  32603. // Draw the marker
  32604. if (markerOptions && markerOptions.enabled !== false && symbolWidth) {
  32605. // Do not allow the marker to be larger than the symbolHeight
  32606. radius = Math.min(pick(markerOptions.radius, generalRadius), generalRadius);
  32607. // Restrict symbol markers size
  32608. if (this.symbol.indexOf('url') === 0) {
  32609. markerOptions = merge(markerOptions, {
  32610. width: symbolHeight,
  32611. height: symbolHeight
  32612. });
  32613. radius = 0;
  32614. }
  32615. this.legendSymbol = legendSymbol = renderer.symbol(this.symbol, (symbolWidth / 2) - radius, verticalCenter - radius, 2 * radius, 2 * radius, markerOptions)
  32616. .addClass('highcharts-point')
  32617. .add(legendItemGroup);
  32618. legendSymbol.isMarker = true;
  32619. }
  32620. }
  32621. };
  32622. return LegendSymbolMixin;
  32623. });
  32624. _registerModule(_modules, 'Core/Series/Series.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Foundation.js'], _modules['Core/Globals.js'], _modules['Mixins/LegendSymbol.js'], _modules['Core/DefaultOptions.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, F, H, LegendSymbolMixin, D, palette, Point, SeriesRegistry, SVGElement, U) {
  32625. /* *
  32626. *
  32627. * (c) 2010-2021 Torstein Honsi
  32628. *
  32629. * License: www.highcharts.com/license
  32630. *
  32631. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  32632. *
  32633. * */
  32634. var animObject = A.animObject,
  32635. setAnimation = A.setAnimation;
  32636. var registerEventOptions = F.registerEventOptions;
  32637. var hasTouch = H.hasTouch,
  32638. svg = H.svg,
  32639. win = H.win;
  32640. var defaultOptions = D.defaultOptions;
  32641. var seriesTypes = SeriesRegistry.seriesTypes;
  32642. var addEvent = U.addEvent,
  32643. arrayMax = U.arrayMax,
  32644. arrayMin = U.arrayMin,
  32645. clamp = U.clamp,
  32646. cleanRecursively = U.cleanRecursively,
  32647. correctFloat = U.correctFloat,
  32648. defined = U.defined,
  32649. erase = U.erase,
  32650. error = U.error,
  32651. extend = U.extend,
  32652. find = U.find,
  32653. fireEvent = U.fireEvent,
  32654. getNestedProperty = U.getNestedProperty,
  32655. isArray = U.isArray,
  32656. isNumber = U.isNumber,
  32657. isString = U.isString,
  32658. merge = U.merge,
  32659. objectEach = U.objectEach,
  32660. pick = U.pick,
  32661. removeEvent = U.removeEvent,
  32662. splat = U.splat,
  32663. syncTimeout = U.syncTimeout;
  32664. /* *
  32665. *
  32666. * Class
  32667. *
  32668. * */
  32669. /**
  32670. * This is the base series prototype that all other series types inherit from.
  32671. * A new series is initialized either through the
  32672. * [series](https://api.highcharts.com/highcharts/series)
  32673. * option structure, or after the chart is initialized, through
  32674. * {@link Highcharts.Chart#addSeries}.
  32675. *
  32676. * The object can be accessed in a number of ways. All series and point event
  32677. * handlers give a reference to the `series` object. The chart object has a
  32678. * {@link Highcharts.Chart#series|series} property that is a collection of all
  32679. * the chart's series. The point objects and axis objects also have the same
  32680. * reference.
  32681. *
  32682. * Another way to reference the series programmatically is by `id`. Add an id
  32683. * in the series configuration options, and get the series object by
  32684. * {@link Highcharts.Chart#get}.
  32685. *
  32686. * Configuration options for the series are given in three levels. Options for
  32687. * all series in a chart are given in the
  32688. * [plotOptions.series](https://api.highcharts.com/highcharts/plotOptions.series)
  32689. * object. Then options for all series of a specific type
  32690. * are given in the plotOptions of that type, for example `plotOptions.line`.
  32691. * Next, options for one single series are given in the series array, or as
  32692. * arguments to `chart.addSeries`.
  32693. *
  32694. * The data in the series is stored in various arrays.
  32695. *
  32696. * - First, `series.options.data` contains all the original config options for
  32697. * each point whether added by options or methods like `series.addPoint`.
  32698. *
  32699. * - Next, `series.data` contains those values converted to points, but in case
  32700. * the series data length exceeds the `cropThreshold`, or if the data is
  32701. * grouped, `series.data` doesn't contain all the points. It only contains the
  32702. * points that have been created on demand.
  32703. *
  32704. * - Then there's `series.points` that contains all currently visible point
  32705. * objects. In case of cropping, the cropped-away points are not part of this
  32706. * array. The `series.points` array starts at `series.cropStart` compared to
  32707. * `series.data` and `series.options.data`. If however the series data is
  32708. * grouped, these can't be correlated one to one.
  32709. *
  32710. * - `series.xData` and `series.processedXData` contain clean x values,
  32711. * equivalent to `series.data` and `series.points`.
  32712. *
  32713. * - `series.yData` and `series.processedYData` contain clean y values,
  32714. * equivalent to `series.data` and `series.points`.
  32715. *
  32716. * @class
  32717. * @name Highcharts.Series
  32718. *
  32719. * @param {Highcharts.Chart} chart
  32720. * The chart instance.
  32721. *
  32722. * @param {Highcharts.SeriesOptionsType|object} options
  32723. * The series options.
  32724. */
  32725. var Series = /** @class */ (function () {
  32726. function Series() {
  32727. /* *
  32728. *
  32729. * Static Functions
  32730. *
  32731. * */
  32732. this._i = void 0;
  32733. this.chart = void 0;
  32734. this.data = void 0;
  32735. this.eventOptions = void 0;
  32736. this.eventsToUnbind = void 0;
  32737. this.index = void 0;
  32738. this.linkedSeries = void 0;
  32739. this.options = void 0;
  32740. this.points = void 0;
  32741. this.processedXData = void 0;
  32742. this.processedYData = void 0;
  32743. this.tooltipOptions = void 0;
  32744. this.userOptions = void 0;
  32745. this.xAxis = void 0;
  32746. this.yAxis = void 0;
  32747. this.zones = void 0;
  32748. /** eslint-enable valid-jsdoc */
  32749. }
  32750. /* *
  32751. *
  32752. * Functions
  32753. *
  32754. * */
  32755. /* eslint-disable valid-jsdoc */
  32756. Series.prototype.init = function (chart, userOptions) {
  32757. fireEvent(this, 'init', { options: userOptions });
  32758. var series = this,
  32759. chartSeries = chart.series;
  32760. // The 'eventsToUnbind' property moved from prototype into the
  32761. // Series init to avoid reference to the same array between
  32762. // the different series and charts. #12959, #13937
  32763. this.eventsToUnbind = [];
  32764. /**
  32765. * Read only. The chart that the series belongs to.
  32766. *
  32767. * @name Highcharts.Series#chart
  32768. * @type {Highcharts.Chart}
  32769. */
  32770. series.chart = chart;
  32771. /**
  32772. * Read only. The series' type, like "line", "area", "column" etc.
  32773. * The type in the series options anc can be altered using
  32774. * {@link Series#update}.
  32775. *
  32776. * @name Highcharts.Series#type
  32777. * @type {string}
  32778. */
  32779. /**
  32780. * Read only. The series' current options. To update, use
  32781. * {@link Series#update}.
  32782. *
  32783. * @name Highcharts.Series#options
  32784. * @type {Highcharts.SeriesOptionsType}
  32785. */
  32786. series.options = series.setOptions(userOptions);
  32787. var options = series.options;
  32788. series.linkedSeries = [];
  32789. // bind the axes
  32790. series.bindAxes();
  32791. extend(series, {
  32792. /**
  32793. * The series name as given in the options. Defaults to
  32794. * "Series {n}".
  32795. *
  32796. * @name Highcharts.Series#name
  32797. * @type {string}
  32798. */
  32799. name: options.name,
  32800. state: '',
  32801. /**
  32802. * Read only. The series' visibility state as set by {@link
  32803. * Series#show}, {@link Series#hide}, or in the initial
  32804. * configuration.
  32805. *
  32806. * @name Highcharts.Series#visible
  32807. * @type {boolean}
  32808. */
  32809. visible: options.visible !== false,
  32810. /**
  32811. * Read only. The series' selected state as set by {@link
  32812. * Highcharts.Series#select}.
  32813. *
  32814. * @name Highcharts.Series#selected
  32815. * @type {boolean}
  32816. */
  32817. selected: options.selected === true // false by default
  32818. });
  32819. registerEventOptions(this, options);
  32820. var events = options.events;
  32821. if ((events && events.click) ||
  32822. (options.point &&
  32823. options.point.events &&
  32824. options.point.events.click) ||
  32825. options.allowPointSelect) {
  32826. chart.runTrackerClick = true;
  32827. }
  32828. series.getColor();
  32829. series.getSymbol();
  32830. // Initialize the parallel data arrays
  32831. series.parallelArrays.forEach(function (key) {
  32832. if (!series[key + 'Data']) {
  32833. series[key + 'Data'] = [];
  32834. }
  32835. });
  32836. // Mark cartesian
  32837. if (series.isCartesian) {
  32838. chart.hasCartesianSeries = true;
  32839. }
  32840. // Get the index and register the series in the chart. The index is
  32841. // one more than the current latest series index (#5960).
  32842. var lastSeries;
  32843. if (chartSeries.length) {
  32844. lastSeries = chartSeries[chartSeries.length - 1];
  32845. }
  32846. series._i = pick(lastSeries && lastSeries._i, -1) + 1;
  32847. series.opacity = series.options.opacity;
  32848. // Insert the series and re-order all series above the insertion
  32849. // point.
  32850. chart.orderSeries(this.insert(chartSeries));
  32851. // Set options for series with sorting and set data later.
  32852. if (options.dataSorting && options.dataSorting.enabled) {
  32853. series.setDataSortingOptions();
  32854. }
  32855. else if (!series.points && !series.data) {
  32856. series.setData(options.data, false);
  32857. }
  32858. fireEvent(this, 'afterInit');
  32859. };
  32860. /**
  32861. * Check whether the series item is itself or inherits from a certain
  32862. * series type.
  32863. *
  32864. * @function Highcharts.Series#is
  32865. * @param {string} type The type of series to check for, can be either
  32866. * featured or custom series types. For example `column`, `pie`,
  32867. * `ohlc` etc.
  32868. *
  32869. * @return {boolean}
  32870. * True if this item is or inherits from the given type.
  32871. */
  32872. Series.prototype.is = function (type) {
  32873. return seriesTypes[type] && this instanceof seriesTypes[type];
  32874. };
  32875. /**
  32876. * Insert the series in a collection with other series, either the chart
  32877. * series or yAxis series, in the correct order according to the index
  32878. * option. Used internally when adding series.
  32879. *
  32880. * @private
  32881. * @function Highcharts.Series#insert
  32882. * @param {Array<Highcharts.Series>} collection
  32883. * A collection of series, like `chart.series` or `xAxis.series`.
  32884. * @return {number}
  32885. * The index of the series in the collection.
  32886. */
  32887. Series.prototype.insert = function (collection) {
  32888. var indexOption = this.options.index,
  32889. i;
  32890. // Insert by index option
  32891. if (isNumber(indexOption)) {
  32892. i = collection.length;
  32893. while (i--) {
  32894. // Loop down until the interted element has higher index
  32895. if (indexOption >=
  32896. pick(collection[i].options.index, collection[i]._i)) {
  32897. collection.splice(i + 1, 0, this);
  32898. break;
  32899. }
  32900. }
  32901. if (i === -1) {
  32902. collection.unshift(this);
  32903. }
  32904. i = i + 1;
  32905. // Or just push it to the end
  32906. }
  32907. else {
  32908. collection.push(this);
  32909. }
  32910. return pick(i, collection.length - 1);
  32911. };
  32912. /**
  32913. * Set the xAxis and yAxis properties of cartesian series, and register
  32914. * the series in the `axis.series` array.
  32915. *
  32916. * @private
  32917. * @function Highcharts.Series#bindAxes
  32918. */
  32919. Series.prototype.bindAxes = function () {
  32920. var series = this,
  32921. seriesOptions = series.options,
  32922. chart = series.chart,
  32923. axisOptions;
  32924. fireEvent(this, 'bindAxes', null, function () {
  32925. // repeat for xAxis and yAxis
  32926. (series.axisTypes || []).forEach(function (AXIS) {
  32927. var index = 0;
  32928. // loop through the chart's axis objects
  32929. chart[AXIS].forEach(function (axis) {
  32930. axisOptions = axis.options;
  32931. // apply if the series xAxis or yAxis option mathches
  32932. // the number of the axis, or if undefined, use the
  32933. // first axis
  32934. if ((seriesOptions[AXIS] === index &&
  32935. !axisOptions.isInternal) ||
  32936. (typeof seriesOptions[AXIS] !==
  32937. 'undefined' &&
  32938. seriesOptions[AXIS] === axisOptions.id) ||
  32939. (typeof seriesOptions[AXIS] ===
  32940. 'undefined' &&
  32941. axisOptions.index === 0)) {
  32942. // register this series in the axis.series lookup
  32943. series.insert(axis.series);
  32944. // set this series.xAxis or series.yAxis reference
  32945. /**
  32946. * Read only. The unique xAxis object associated
  32947. * with the series.
  32948. *
  32949. * @name Highcharts.Series#xAxis
  32950. * @type {Highcharts.Axis}
  32951. */
  32952. /**
  32953. * Read only. The unique yAxis object associated
  32954. * with the series.
  32955. *
  32956. * @name Highcharts.Series#yAxis
  32957. * @type {Highcharts.Axis}
  32958. */
  32959. series[AXIS] = axis;
  32960. // mark dirty for redraw
  32961. axis.isDirty = true;
  32962. }
  32963. if (!axisOptions.isInternal) {
  32964. index++;
  32965. }
  32966. });
  32967. // The series needs an X and an Y axis
  32968. if (!series[AXIS] &&
  32969. series.optionalAxis !== AXIS) {
  32970. error(18, true, chart);
  32971. }
  32972. });
  32973. });
  32974. fireEvent(this, 'afterBindAxes');
  32975. };
  32976. /**
  32977. * For simple series types like line and column, the data values are
  32978. * held in arrays like xData and yData for quick lookup to find extremes
  32979. * and more. For multidimensional series like bubble and map, this can
  32980. * be extended with arrays like zData and valueData by adding to the
  32981. * `series.parallelArrays` array.
  32982. *
  32983. * @private
  32984. * @function Highcharts.Series#updateParallelArrays
  32985. */
  32986. Series.prototype.updateParallelArrays = function (point, i) {
  32987. var series = point.series,
  32988. args = arguments,
  32989. fn = isNumber(i) ?
  32990. // Insert the value in the given position
  32991. function (key) {
  32992. var val = key === 'y' && series.toYData ?
  32993. series.toYData(point) :
  32994. point[key];
  32995. series[key + 'Data'][i] = val;
  32996. } :
  32997. // Apply the method specified in i with the following
  32998. // arguments as arguments
  32999. function (key) {
  33000. Array.prototype[i].apply(series[key + 'Data'], Array.prototype.slice.call(args, 2));
  33001. };
  33002. series.parallelArrays.forEach(fn);
  33003. };
  33004. /**
  33005. * Define hasData functions for series. These return true if there
  33006. * are data points on this series within the plot area.
  33007. *
  33008. * @private
  33009. * @function Highcharts.Series#hasData
  33010. * @return {boolean}
  33011. */
  33012. Series.prototype.hasData = function () {
  33013. return ((this.visible &&
  33014. typeof this.dataMax !== 'undefined' &&
  33015. typeof this.dataMin !== 'undefined') || ( // #3703
  33016. this.visible &&
  33017. this.yData &&
  33018. this.yData.length > 0) // #9758
  33019. );
  33020. };
  33021. /**
  33022. * Return an auto incremented x value based on the pointStart and
  33023. * pointInterval options. This is only used if an x value is not given
  33024. * for the point that calls autoIncrement.
  33025. *
  33026. * @private
  33027. * @function Highcharts.Series#autoIncrement
  33028. * @return {number}
  33029. */
  33030. Series.prototype.autoIncrement = function () {
  33031. var options = this.options,
  33032. xIncrement = this.xIncrement,
  33033. date,
  33034. pointInterval,
  33035. pointIntervalUnit = options.pointIntervalUnit,
  33036. time = this.chart.time;
  33037. xIncrement = pick(xIncrement, options.pointStart, 0);
  33038. this.pointInterval = pointInterval = pick(this.pointInterval, options.pointInterval, 1);
  33039. // Added code for pointInterval strings
  33040. if (pointIntervalUnit) {
  33041. date = new time.Date(xIncrement);
  33042. if (pointIntervalUnit === 'day') {
  33043. time.set('Date', date, time.get('Date', date) + pointInterval);
  33044. }
  33045. else if (pointIntervalUnit === 'month') {
  33046. time.set('Month', date, time.get('Month', date) + pointInterval);
  33047. }
  33048. else if (pointIntervalUnit === 'year') {
  33049. time.set('FullYear', date, time.get('FullYear', date) + pointInterval);
  33050. }
  33051. pointInterval = date.getTime() - xIncrement;
  33052. }
  33053. this.xIncrement = xIncrement + pointInterval;
  33054. return xIncrement;
  33055. };
  33056. /**
  33057. * Internal function to set properties for series if data sorting is
  33058. * enabled.
  33059. *
  33060. * @private
  33061. * @function Highcharts.Series#setDataSortingOptions
  33062. */
  33063. Series.prototype.setDataSortingOptions = function () {
  33064. var options = this.options;
  33065. extend(this, {
  33066. requireSorting: false,
  33067. sorted: false,
  33068. enabledDataSorting: true,
  33069. allowDG: false
  33070. });
  33071. // To allow unsorted data for column series.
  33072. if (!defined(options.pointRange)) {
  33073. options.pointRange = 1;
  33074. }
  33075. };
  33076. /**
  33077. * Set the series options by merging from the options tree. Called
  33078. * internally on initializing and updating series. This function will
  33079. * not redraw the series. For API usage, use {@link Series#update}.
  33080. * @private
  33081. * @function Highcharts.Series#setOptions
  33082. *
  33083. * @param {Highcharts.SeriesOptionsType} itemOptions
  33084. * The series options.
  33085. *
  33086. * @return {Highcharts.SeriesOptionsType}
  33087. *
  33088. * @fires Highcharts.Series#event:afterSetOptions
  33089. */
  33090. Series.prototype.setOptions = function (itemOptions) {
  33091. var chart = this.chart,
  33092. chartOptions = chart.options,
  33093. plotOptions = chartOptions.plotOptions,
  33094. userOptions = chart.userOptions || {},
  33095. seriesUserOptions = merge(itemOptions),
  33096. options,
  33097. zones,
  33098. zone,
  33099. styledMode = chart.styledMode,
  33100. e = {
  33101. plotOptions: plotOptions,
  33102. userOptions: seriesUserOptions
  33103. };
  33104. fireEvent(this, 'setOptions', e);
  33105. // These may be modified by the event
  33106. var typeOptions = e.plotOptions[this.type],
  33107. userPlotOptions = (userOptions.plotOptions || {});
  33108. // use copy to prevent undetected changes (#9762)
  33109. /**
  33110. * Contains series options by the user without defaults.
  33111. * @name Highcharts.Series#userOptions
  33112. * @type {Highcharts.SeriesOptionsType}
  33113. */
  33114. this.userOptions = e.userOptions;
  33115. options = merge(typeOptions, plotOptions.series,
  33116. // #3881, chart instance plotOptions[type] should trump
  33117. // plotOptions.series
  33118. userOptions.plotOptions &&
  33119. userOptions.plotOptions[this.type], seriesUserOptions);
  33120. // The tooltip options are merged between global and series specific
  33121. // options. Importance order asscendingly:
  33122. // globals: (1)tooltip, (2)plotOptions.series,
  33123. // (3)plotOptions[this.type]
  33124. // init userOptions with possible later updates: 4-6 like 1-3 and
  33125. // (7)this series options
  33126. this.tooltipOptions = merge(defaultOptions.tooltip, // 1
  33127. defaultOptions.plotOptions.series &&
  33128. defaultOptions.plotOptions.series.tooltip, // 2
  33129. defaultOptions.plotOptions[this.type].tooltip, // 3
  33130. chartOptions.tooltip.userOptions, // 4
  33131. plotOptions.series &&
  33132. plotOptions.series.tooltip, // 5
  33133. plotOptions[this.type].tooltip, // 6
  33134. seriesUserOptions.tooltip // 7
  33135. );
  33136. // When shared tooltip, stickyTracking is true by default,
  33137. // unless user says otherwise.
  33138. this.stickyTracking = pick(seriesUserOptions.stickyTracking, userPlotOptions[this.type] &&
  33139. userPlotOptions[this.type].stickyTracking, userPlotOptions.series && userPlotOptions.series.stickyTracking, (this.tooltipOptions.shared && !this.noSharedTooltip ?
  33140. true :
  33141. options.stickyTracking));
  33142. // Delete marker object if not allowed (#1125)
  33143. if (typeOptions.marker === null) {
  33144. delete options.marker;
  33145. }
  33146. // Handle color zones
  33147. this.zoneAxis = options.zoneAxis;
  33148. zones = this.zones = (options.zones || []).slice();
  33149. if ((options.negativeColor || options.negativeFillColor) &&
  33150. !options.zones) {
  33151. zone = {
  33152. value: options[this.zoneAxis + 'Threshold'] ||
  33153. options.threshold ||
  33154. 0,
  33155. className: 'highcharts-negative'
  33156. };
  33157. if (!styledMode) {
  33158. zone.color = options.negativeColor;
  33159. zone.fillColor = options.negativeFillColor;
  33160. }
  33161. zones.push(zone);
  33162. }
  33163. if (zones.length) { // Push one extra zone for the rest
  33164. if (defined(zones[zones.length - 1].value)) {
  33165. zones.push(styledMode ? {} : {
  33166. color: this.color,
  33167. fillColor: this.fillColor
  33168. });
  33169. }
  33170. }
  33171. fireEvent(this, 'afterSetOptions', { options: options });
  33172. return options;
  33173. };
  33174. /**
  33175. * Return series name in "Series {Number}" format or the one defined by
  33176. * a user. This method can be simply overridden as series name format
  33177. * can vary (e.g. technical indicators).
  33178. *
  33179. * @function Highcharts.Series#getName
  33180. *
  33181. * @return {string}
  33182. * The series name.
  33183. */
  33184. Series.prototype.getName = function () {
  33185. // #4119
  33186. return pick(this.options.name, 'Series ' + (this.index + 1));
  33187. };
  33188. /**
  33189. * @private
  33190. * @function Highcharts.Series#getCyclic
  33191. */
  33192. Series.prototype.getCyclic = function (prop, value, defaults) {
  33193. 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;
  33194. if (!value) {
  33195. // Pick up either the colorIndex option, or the _colorIndex
  33196. // after Series.update()
  33197. setting = pick(userOptions[indexName], userOptions['_' + indexName]);
  33198. if (defined(setting)) { // after Series.update()
  33199. i = setting;
  33200. }
  33201. else {
  33202. // #6138
  33203. if (!chart.series.length) {
  33204. chart[counterName] = 0;
  33205. }
  33206. userOptions['_' + indexName] = i =
  33207. chart[counterName] % len;
  33208. chart[counterName] += 1;
  33209. }
  33210. if (defaults) {
  33211. value = defaults[i];
  33212. }
  33213. }
  33214. // Set the colorIndex
  33215. if (typeof i !== 'undefined') {
  33216. this[indexName] = i;
  33217. }
  33218. this[prop] = value;
  33219. };
  33220. /**
  33221. * Get the series' color based on either the options or pulled from
  33222. * global options.
  33223. *
  33224. * @private
  33225. * @function Highcharts.Series#getColor
  33226. */
  33227. Series.prototype.getColor = function () {
  33228. if (this.chart.styledMode) {
  33229. this.getCyclic('color');
  33230. }
  33231. else if (this.options.colorByPoint) {
  33232. this.color = palette.neutralColor20;
  33233. }
  33234. else {
  33235. this.getCyclic('color', this.options.color ||
  33236. defaultOptions.plotOptions[this.type].color, this.chart.options.colors);
  33237. }
  33238. };
  33239. /**
  33240. * Get all points' instances created for this series.
  33241. *
  33242. * @private
  33243. * @function Highcharts.Series#getPointsCollection
  33244. * @return {Array<Highcharts.Point>}
  33245. */
  33246. Series.prototype.getPointsCollection = function () {
  33247. return (this.hasGroupedData ? this.points : this.data) || [];
  33248. };
  33249. /**
  33250. * Get the series' symbol based on either the options or pulled from
  33251. * global options.
  33252. *
  33253. * @private
  33254. * @function Highcharts.Series#getSymbol
  33255. * @return {void}
  33256. */
  33257. Series.prototype.getSymbol = function () {
  33258. var seriesMarkerOption = this.options.marker;
  33259. this.getCyclic('symbol', seriesMarkerOption.symbol, this.chart.options.symbols);
  33260. };
  33261. /**
  33262. * Finds the index of an existing point that matches the given point
  33263. * options.
  33264. *
  33265. * @private
  33266. * @function Highcharts.Series#findPointIndex
  33267. * @param {Highcharts.PointOptionsObject} optionsObject
  33268. * The options of the point.
  33269. * @param {number} fromIndex
  33270. * The index to start searching from, used for optimizing
  33271. * series with required sorting.
  33272. * @returns {number|undefined}
  33273. * Returns the index of a matching point, or undefined if no
  33274. * match is found.
  33275. */
  33276. Series.prototype.findPointIndex = function (optionsObject, fromIndex) {
  33277. var id = optionsObject.id,
  33278. x = optionsObject.x,
  33279. oldData = this.points,
  33280. matchingPoint,
  33281. matchedById,
  33282. pointIndex,
  33283. matchKey,
  33284. dataSorting = this.options.dataSorting;
  33285. if (id) {
  33286. matchingPoint = this.chart.get(id);
  33287. }
  33288. else if (this.linkedParent || this.enabledDataSorting) {
  33289. matchKey = (dataSorting && dataSorting.matchByName) ?
  33290. 'name' : 'index';
  33291. matchingPoint = find(oldData, function (oldPoint) {
  33292. return !oldPoint.touched && oldPoint[matchKey] ===
  33293. optionsObject[matchKey];
  33294. });
  33295. // Add unmatched point as a new point
  33296. if (!matchingPoint) {
  33297. return void 0;
  33298. }
  33299. }
  33300. if (matchingPoint) {
  33301. pointIndex = matchingPoint && matchingPoint.index;
  33302. if (typeof pointIndex !== 'undefined') {
  33303. matchedById = true;
  33304. }
  33305. }
  33306. // Search for the same X in the existing data set
  33307. if (typeof pointIndex === 'undefined' && isNumber(x)) {
  33308. pointIndex = this.xData.indexOf(x, fromIndex);
  33309. }
  33310. // Reduce pointIndex if data is cropped
  33311. if (pointIndex !== -1 &&
  33312. typeof pointIndex !== 'undefined' &&
  33313. this.cropped) {
  33314. pointIndex = (pointIndex >= this.cropStart) ?
  33315. pointIndex - this.cropStart : pointIndex;
  33316. }
  33317. if (!matchedById &&
  33318. oldData[pointIndex] && oldData[pointIndex].touched) {
  33319. pointIndex = void 0;
  33320. }
  33321. return pointIndex;
  33322. };
  33323. /**
  33324. * Internal function called from setData. If the point count is the same
  33325. * as is was, or if there are overlapping X values, just run
  33326. * Point.update which is cheaper, allows animation, and keeps references
  33327. * to points. This also allows adding or removing points if the X-es
  33328. * don't match.
  33329. *
  33330. * @private
  33331. * @function Highcharts.Series#updateData
  33332. */
  33333. Series.prototype.updateData = function (data, animation) {
  33334. var options = this.options,
  33335. dataSorting = options.dataSorting,
  33336. oldData = this.points,
  33337. pointsToAdd = [],
  33338. hasUpdatedByKey,
  33339. i,
  33340. point,
  33341. lastIndex,
  33342. requireSorting = this.requireSorting,
  33343. equalLength = data.length === oldData.length,
  33344. succeeded = true;
  33345. this.xIncrement = null;
  33346. // Iterate the new data
  33347. data.forEach(function (pointOptions, i) {
  33348. var id,
  33349. x,
  33350. pointIndex,
  33351. optionsObject = (defined(pointOptions) &&
  33352. this.pointClass.prototype.optionsToObject.call({ series: this },
  33353. pointOptions)) || {};
  33354. // Get the x of the new data point
  33355. x = optionsObject.x;
  33356. id = optionsObject.id;
  33357. if (id || isNumber(x)) {
  33358. pointIndex = this.findPointIndex(optionsObject, lastIndex);
  33359. // Matching X not found
  33360. // or used already due to ununique x values (#8995),
  33361. // add point (but later)
  33362. if (pointIndex === -1 ||
  33363. typeof pointIndex === 'undefined') {
  33364. pointsToAdd.push(pointOptions);
  33365. // Matching X found, update
  33366. }
  33367. else if (oldData[pointIndex] &&
  33368. pointOptions !== options.data[pointIndex]) {
  33369. oldData[pointIndex].update(pointOptions, false, null, false);
  33370. // Mark it touched, below we will remove all points that
  33371. // are not touched.
  33372. oldData[pointIndex].touched = true;
  33373. // Speed optimize by only searching after last known
  33374. // index. Performs ~20% bettor on large data sets.
  33375. if (requireSorting) {
  33376. lastIndex = pointIndex + 1;
  33377. }
  33378. // Point exists, no changes, don't remove it
  33379. }
  33380. else if (oldData[pointIndex]) {
  33381. oldData[pointIndex].touched = true;
  33382. }
  33383. // If the length is equal and some of the nodes had a
  33384. // match in the same position, we don't want to remove
  33385. // non-matches.
  33386. if (!equalLength ||
  33387. i !== pointIndex ||
  33388. (dataSorting && dataSorting.enabled) ||
  33389. this.hasDerivedData) {
  33390. hasUpdatedByKey = true;
  33391. }
  33392. }
  33393. else {
  33394. // Gather all points that are not matched
  33395. pointsToAdd.push(pointOptions);
  33396. }
  33397. }, this);
  33398. // Remove points that don't exist in the updated data set
  33399. if (hasUpdatedByKey) {
  33400. i = oldData.length;
  33401. while (i--) {
  33402. point = oldData[i];
  33403. if (point && !point.touched && point.remove) {
  33404. point.remove(false, animation);
  33405. }
  33406. }
  33407. // If we did not find keys (ids or x-values), and the length is the
  33408. // same, update one-to-one
  33409. }
  33410. else if (equalLength && (!dataSorting || !dataSorting.enabled)) {
  33411. data.forEach(function (point, i) {
  33412. // .update doesn't exist on a linked, hidden series (#3709)
  33413. // (#10187)
  33414. if (point !== oldData[i].y && oldData[i].update) {
  33415. oldData[i].update(point, false, null, false);
  33416. }
  33417. });
  33418. // Don't add new points since those configs are used above
  33419. pointsToAdd.length = 0;
  33420. // Did not succeed in updating data
  33421. }
  33422. else {
  33423. succeeded = false;
  33424. }
  33425. oldData.forEach(function (point) {
  33426. if (point) {
  33427. point.touched = false;
  33428. }
  33429. });
  33430. if (!succeeded) {
  33431. return false;
  33432. }
  33433. // Add new points
  33434. pointsToAdd.forEach(function (point) {
  33435. this.addPoint(point, false, null, null, false);
  33436. }, this);
  33437. if (this.xIncrement === null &&
  33438. this.xData &&
  33439. this.xData.length) {
  33440. this.xIncrement = arrayMax(this.xData);
  33441. this.autoIncrement();
  33442. }
  33443. return true;
  33444. };
  33445. /**
  33446. * Apply a new set of data to the series and optionally redraw it. The
  33447. * new data array is passed by reference (except in case of
  33448. * `updatePoints`), and may later be mutated when updating the chart
  33449. * data.
  33450. *
  33451. * Note the difference in behaviour when setting the same amount of
  33452. * points, or a different amount of points, as handled by the
  33453. * `updatePoints` parameter.
  33454. *
  33455. * @sample highcharts/members/series-setdata/
  33456. * Set new data from a button
  33457. * @sample highcharts/members/series-setdata-pie/
  33458. * Set data in a pie
  33459. * @sample stock/members/series-setdata/
  33460. * Set new data in Highcharts Stock
  33461. * @sample maps/members/series-setdata/
  33462. * Set new data in Highmaps
  33463. *
  33464. * @function Highcharts.Series#setData
  33465. *
  33466. * @param {Array<Highcharts.PointOptionsType>} data
  33467. * Takes an array of data in the same format as described under
  33468. * `series.{type}.data` for the given series type, for example a
  33469. * line series would take data in the form described under
  33470. * [series.line.data](https://api.highcharts.com/highcharts/series.line.data).
  33471. *
  33472. * @param {boolean} [redraw=true]
  33473. * Whether to redraw the chart after the series is altered. If
  33474. * doing more operations on the chart, it is a good idea to set
  33475. * redraw to false and call {@link Chart#redraw} after.
  33476. *
  33477. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  33478. * When the updated data is the same length as the existing data,
  33479. * points will be updated by default, and animation visualizes
  33480. * how the points are changed. Set false to disable animation, or
  33481. * a configuration object to set duration or easing.
  33482. *
  33483. * @param {boolean} [updatePoints=true]
  33484. * When this is true, points will be updated instead of replaced
  33485. * whenever possible. This occurs a) when the updated data is the
  33486. * same length as the existing data, b) when points are matched
  33487. * by their id's, or c) when points can be matched by X values.
  33488. * This allows updating with animation and performs better. In
  33489. * this case, the original array is not passed by reference. Set
  33490. * `false` to prevent.
  33491. */
  33492. Series.prototype.setData = function (data, redraw, animation, updatePoints) {
  33493. var series = this,
  33494. oldData = series.points,
  33495. oldDataLength = (oldData && oldData.length) || 0,
  33496. dataLength,
  33497. options = series.options,
  33498. chart = series.chart,
  33499. dataSorting = options.dataSorting,
  33500. firstPoint = null,
  33501. xAxis = series.xAxis,
  33502. i,
  33503. turboThreshold = options.turboThreshold,
  33504. pt,
  33505. xData = this.xData,
  33506. yData = this.yData,
  33507. pointArrayMap = series.pointArrayMap,
  33508. valueCount = pointArrayMap && pointArrayMap.length,
  33509. keys = options.keys,
  33510. indexOfX = 0,
  33511. indexOfY = 1,
  33512. updatedData;
  33513. data = data || [];
  33514. dataLength = data.length;
  33515. redraw = pick(redraw, true);
  33516. if (dataSorting && dataSorting.enabled) {
  33517. data = this.sortData(data);
  33518. }
  33519. // First try to run Point.update which is cheaper, allows animation,
  33520. // and keeps references to points.
  33521. if (updatePoints !== false &&
  33522. dataLength &&
  33523. oldDataLength &&
  33524. !series.cropped &&
  33525. !series.hasGroupedData &&
  33526. series.visible &&
  33527. // Soft updating has no benefit in boost, and causes JS error
  33528. // (#8355)
  33529. !series.isSeriesBoosting) {
  33530. updatedData = this.updateData(data, animation);
  33531. }
  33532. if (!updatedData) {
  33533. // Reset properties
  33534. series.xIncrement = null;
  33535. series.colorCounter = 0; // for series with colorByPoint (#1547)
  33536. // Update parallel arrays
  33537. this.parallelArrays.forEach(function (key) {
  33538. series[key + 'Data'].length = 0;
  33539. });
  33540. // In turbo mode, only one- or twodimensional arrays of numbers
  33541. // are allowed. The first value is tested, and we assume that
  33542. // all the rest are defined the same way. Although the 'for'
  33543. // loops are similar, they are repeated inside each if-else
  33544. // conditional for max performance.
  33545. if (turboThreshold && dataLength > turboThreshold) {
  33546. firstPoint = series.getFirstValidPoint(data);
  33547. if (isNumber(firstPoint)) { // assume all points are numbers
  33548. for (i = 0; i < dataLength; i++) {
  33549. xData[i] = this.autoIncrement();
  33550. yData[i] = data[i];
  33551. }
  33552. // Assume all points are arrays when first point is
  33553. }
  33554. else if (isArray(firstPoint)) {
  33555. if (valueCount) { // [x, low, high] or [x, o, h, l, c]
  33556. for (i = 0; i < dataLength; i++) {
  33557. pt = data[i];
  33558. xData[i] = pt[0];
  33559. yData[i] =
  33560. pt.slice(1, valueCount + 1);
  33561. }
  33562. }
  33563. else { // [x, y]
  33564. if (keys) {
  33565. indexOfX = keys.indexOf('x');
  33566. indexOfY = keys.indexOf('y');
  33567. indexOfX = indexOfX >= 0 ? indexOfX : 0;
  33568. indexOfY = indexOfY >= 0 ? indexOfY : 1;
  33569. }
  33570. for (i = 0; i < dataLength; i++) {
  33571. pt = data[i];
  33572. xData[i] = pt[indexOfX];
  33573. yData[i] = pt[indexOfY];
  33574. }
  33575. }
  33576. }
  33577. else {
  33578. // Highcharts expects configs to be numbers or arrays in
  33579. // turbo mode
  33580. error(12, false, chart);
  33581. }
  33582. }
  33583. else {
  33584. for (i = 0; i < dataLength; i++) {
  33585. // stray commas in oldIE:
  33586. if (typeof data[i] !== 'undefined') {
  33587. pt = { series: series };
  33588. series.pointClass.prototype.applyOptions.apply(pt, [data[i]]);
  33589. series.updateParallelArrays(pt, i);
  33590. }
  33591. }
  33592. }
  33593. // Forgetting to cast strings to numbers is a common caveat when
  33594. // handling CSV or JSON
  33595. if (yData && isString(yData[0])) {
  33596. error(14, true, chart);
  33597. }
  33598. series.data = [];
  33599. series.options.data = series.userOptions.data = data;
  33600. // destroy old points
  33601. i = oldDataLength;
  33602. while (i--) {
  33603. if (oldData[i] && oldData[i].destroy) {
  33604. oldData[i].destroy();
  33605. }
  33606. }
  33607. // reset minRange (#878)
  33608. if (xAxis) {
  33609. xAxis.minRange = xAxis.userMinRange;
  33610. }
  33611. // redraw
  33612. series.isDirty = chart.isDirtyBox = true;
  33613. series.isDirtyData = !!oldData;
  33614. animation = false;
  33615. }
  33616. // Typically for pie series, points need to be processed and
  33617. // generated prior to rendering the legend
  33618. if (options.legendType === 'point') {
  33619. this.processData();
  33620. this.generatePoints();
  33621. }
  33622. if (redraw) {
  33623. chart.redraw(animation);
  33624. }
  33625. };
  33626. /**
  33627. * Internal function to sort series data
  33628. *
  33629. * @private
  33630. * @function Highcharts.Series#sortData
  33631. *
  33632. * @param {Array<Highcharts.PointOptionsType>} data
  33633. * Force data grouping.
  33634. *
  33635. * @return {Array<Highcharts.PointOptionsObject>}
  33636. */
  33637. Series.prototype.sortData = function (data) {
  33638. var series = this,
  33639. options = series.options,
  33640. dataSorting = options.dataSorting,
  33641. sortKey = dataSorting.sortKey || 'y',
  33642. sortedData,
  33643. getPointOptionsObject = function (series,
  33644. pointOptions) {
  33645. return (defined(pointOptions) &&
  33646. series.pointClass.prototype.optionsToObject.call({
  33647. series: series
  33648. },
  33649. pointOptions)) || {};
  33650. };
  33651. data.forEach(function (pointOptions, i) {
  33652. data[i] = getPointOptionsObject(series, pointOptions);
  33653. data[i].index = i;
  33654. }, this);
  33655. // Sorting
  33656. sortedData = data.concat().sort(function (a, b) {
  33657. var aValue = getNestedProperty(sortKey,
  33658. a);
  33659. var bValue = getNestedProperty(sortKey,
  33660. b);
  33661. return bValue < aValue ? -1 : bValue > aValue ? 1 : 0;
  33662. });
  33663. // Set x value depending on the position in the array
  33664. sortedData.forEach(function (point, i) {
  33665. point.x = i;
  33666. }, this);
  33667. // Set the same x for linked series points if they don't have their
  33668. // own sorting
  33669. if (series.linkedSeries) {
  33670. series.linkedSeries.forEach(function (linkedSeries) {
  33671. var options = linkedSeries.options,
  33672. seriesData = options.data;
  33673. if ((!options.dataSorting ||
  33674. !options.dataSorting.enabled) &&
  33675. seriesData) {
  33676. seriesData.forEach(function (pointOptions, i) {
  33677. seriesData[i] = getPointOptionsObject(linkedSeries, pointOptions);
  33678. if (data[i]) {
  33679. seriesData[i].x = data[i].x;
  33680. seriesData[i].index = i;
  33681. }
  33682. });
  33683. linkedSeries.setData(seriesData, false);
  33684. }
  33685. });
  33686. }
  33687. return data;
  33688. };
  33689. /**
  33690. * Internal function to process the data by cropping away unused data
  33691. * points if the series is longer than the crop threshold. This saves
  33692. * computing time for large series.
  33693. *
  33694. * @private
  33695. * @function Highcharts.Series#getProcessedData
  33696. * @param {boolean} [forceExtremesFromAll]
  33697. * Force getting extremes of a total series data range.
  33698. * @return {Highcharts.SeriesProcessedDataObject}
  33699. */
  33700. Series.prototype.getProcessedData = function (forceExtremesFromAll) {
  33701. var series = this,
  33702. // copied during slice operation:
  33703. processedXData = series.xData,
  33704. processedYData = series.yData,
  33705. dataLength = processedXData.length,
  33706. croppedData,
  33707. cropStart = 0,
  33708. cropped,
  33709. distance,
  33710. closestPointRange,
  33711. xAxis = series.xAxis,
  33712. i, // loop variable
  33713. options = series.options,
  33714. cropThreshold = options.cropThreshold,
  33715. getExtremesFromAll = forceExtremesFromAll ||
  33716. series.getExtremesFromAll ||
  33717. options.getExtremesFromAll, // #4599
  33718. isCartesian = series.isCartesian,
  33719. xExtremes,
  33720. val2lin = xAxis && xAxis.val2lin,
  33721. isLog = !!(xAxis && xAxis.logarithmic),
  33722. throwOnUnsorted = series.requireSorting,
  33723. min,
  33724. max;
  33725. if (xAxis) {
  33726. // corrected for log axis (#3053)
  33727. xExtremes = xAxis.getExtremes();
  33728. min = xExtremes.min;
  33729. max = xExtremes.max;
  33730. }
  33731. // optionally filter out points outside the plot area
  33732. if (isCartesian &&
  33733. series.sorted &&
  33734. !getExtremesFromAll &&
  33735. (!cropThreshold ||
  33736. dataLength > cropThreshold ||
  33737. series.forceCrop)) {
  33738. // it's outside current extremes
  33739. if (processedXData[dataLength - 1] < min ||
  33740. processedXData[0] > max) {
  33741. processedXData = [];
  33742. processedYData = [];
  33743. // only crop if it's actually spilling out
  33744. }
  33745. else if (series.yData && (processedXData[0] < min ||
  33746. processedXData[dataLength - 1] > max)) {
  33747. croppedData = this.cropData(series.xData, series.yData, min, max);
  33748. processedXData = croppedData.xData;
  33749. processedYData = croppedData.yData;
  33750. cropStart = croppedData.start;
  33751. cropped = true;
  33752. }
  33753. }
  33754. // Find the closest distance between processed points
  33755. i = processedXData.length || 1;
  33756. while (--i) {
  33757. distance = (isLog ?
  33758. (val2lin(processedXData[i]) -
  33759. val2lin(processedXData[i - 1])) :
  33760. (processedXData[i] -
  33761. processedXData[i - 1]));
  33762. if (distance > 0 &&
  33763. (typeof closestPointRange === 'undefined' ||
  33764. distance < closestPointRange)) {
  33765. closestPointRange = distance;
  33766. // Unsorted data is not supported by the line tooltip, as well
  33767. // as data grouping and navigation in Stock charts (#725) and
  33768. // width calculation of columns (#1900)
  33769. }
  33770. else if (distance < 0 && throwOnUnsorted) {
  33771. error(15, false, series.chart);
  33772. throwOnUnsorted = false; // Only once
  33773. }
  33774. }
  33775. return {
  33776. xData: processedXData,
  33777. yData: processedYData,
  33778. cropped: cropped,
  33779. cropStart: cropStart,
  33780. closestPointRange: closestPointRange
  33781. };
  33782. };
  33783. /**
  33784. * Internal function to apply processed data.
  33785. * In Highcharts Stock, this function is extended to provide data grouping.
  33786. *
  33787. * @private
  33788. * @function Highcharts.Series#processData
  33789. * @param {boolean} [force]
  33790. * Force data grouping.
  33791. * @return {boolean|undefined}
  33792. */
  33793. Series.prototype.processData = function (force) {
  33794. var series = this,
  33795. xAxis = series.xAxis,
  33796. processedData;
  33797. // If the series data or axes haven't changed, don't go through
  33798. // this. Return false to pass the message on to override methods
  33799. // like in data grouping.
  33800. if (series.isCartesian &&
  33801. !series.isDirty &&
  33802. !xAxis.isDirty &&
  33803. !series.yAxis.isDirty &&
  33804. !force) {
  33805. return false;
  33806. }
  33807. processedData = series.getProcessedData();
  33808. // Record the properties
  33809. series.cropped = processedData.cropped; // undefined or true
  33810. series.cropStart = processedData.cropStart;
  33811. series.processedXData = processedData.xData;
  33812. series.processedYData = processedData.yData;
  33813. series.closestPointRange = series.basePointRange = processedData.closestPointRange;
  33814. };
  33815. /**
  33816. * Iterate over xData and crop values between min and max. Returns
  33817. * object containing crop start/end cropped xData with corresponding
  33818. * part of yData, dataMin and dataMax within the cropped range.
  33819. *
  33820. * @private
  33821. * @function Highcharts.Series#cropData
  33822. * @param {Array<number>} xData
  33823. * @param {Array<number>} yData
  33824. * @param {number} min
  33825. * @param {number} max
  33826. * @param {number} [cropShoulder]
  33827. * @return {Highcharts.SeriesCropDataObject}
  33828. */
  33829. Series.prototype.cropData = function (xData, yData, min, max, cropShoulder) {
  33830. var dataLength = xData.length,
  33831. cropStart = 0,
  33832. cropEnd = dataLength,
  33833. i,
  33834. j;
  33835. // line-type series need one point outside
  33836. cropShoulder = pick(cropShoulder, this.cropShoulder);
  33837. // iterate up to find slice start
  33838. for (i = 0; i < dataLength; i++) {
  33839. if (xData[i] >= min) {
  33840. cropStart = Math.max(0, i - cropShoulder);
  33841. break;
  33842. }
  33843. }
  33844. // proceed to find slice end
  33845. for (j = i; j < dataLength; j++) {
  33846. if (xData[j] > max) {
  33847. cropEnd = j + cropShoulder;
  33848. break;
  33849. }
  33850. }
  33851. return {
  33852. xData: xData.slice(cropStart, cropEnd),
  33853. yData: yData.slice(cropStart, cropEnd),
  33854. start: cropStart,
  33855. end: cropEnd
  33856. };
  33857. };
  33858. /**
  33859. * Generate the data point after the data has been processed by cropping
  33860. * away unused points and optionally grouped in Highcharts Stock.
  33861. *
  33862. * @private
  33863. * @function Highcharts.Series#generatePoints
  33864. */
  33865. Series.prototype.generatePoints = function () {
  33866. var series = this,
  33867. options = series.options,
  33868. dataOptions = options.data,
  33869. data = series.data,
  33870. dataLength,
  33871. processedXData = series.processedXData,
  33872. processedYData = series.processedYData,
  33873. PointClass = series.pointClass,
  33874. processedDataLength = processedXData.length,
  33875. cropStart = series.cropStart || 0,
  33876. cursor,
  33877. hasGroupedData = series.hasGroupedData,
  33878. keys = options.keys,
  33879. point,
  33880. points = [],
  33881. i,
  33882. groupCropStartIndex = (options.dataGrouping &&
  33883. options.dataGrouping.groupAll ?
  33884. cropStart :
  33885. 0);
  33886. if (!data && !hasGroupedData) {
  33887. var arr = [];
  33888. arr.length = dataOptions.length;
  33889. data = series.data = arr;
  33890. }
  33891. if (keys && hasGroupedData) {
  33892. // grouped data has already applied keys (#6590)
  33893. series.options.keys = false;
  33894. }
  33895. for (i = 0; i < processedDataLength; i++) {
  33896. cursor = cropStart + i;
  33897. if (!hasGroupedData) {
  33898. point = data[cursor];
  33899. // #970:
  33900. if (!point &&
  33901. typeof dataOptions[cursor] !== 'undefined') {
  33902. data[cursor] = point = (new PointClass()).init(series, dataOptions[cursor], processedXData[i]);
  33903. }
  33904. }
  33905. else {
  33906. // splat the y data in case of ohlc data array
  33907. point = (new PointClass()).init(series, [processedXData[i]].concat(splat(processedYData[i])));
  33908. /**
  33909. * Highcharts Stock only. If a point object is created by data
  33910. * grouping, it doesn't reflect actual points in the raw
  33911. * data. In this case, the `dataGroup` property holds
  33912. * information that points back to the raw data.
  33913. *
  33914. * - `dataGroup.start` is the index of the first raw data
  33915. * point in the group.
  33916. *
  33917. * - `dataGroup.length` is the amount of points in the
  33918. * group.
  33919. *
  33920. * @product highstock
  33921. *
  33922. * @name Highcharts.Point#dataGroup
  33923. * @type {Highcharts.DataGroupingInfoObject|undefined}
  33924. */
  33925. point.dataGroup = series.groupMap[groupCropStartIndex + i];
  33926. if (point.dataGroup.options) {
  33927. point.options = point.dataGroup.options;
  33928. extend(point, point.dataGroup.options);
  33929. // Collision of props and options (#9770)
  33930. delete point.dataLabels;
  33931. }
  33932. }
  33933. if (point) { // #6279
  33934. /**
  33935. * Contains the point's index in the `Series.points` array.
  33936. *
  33937. * @name Highcharts.Point#index
  33938. * @type {number}
  33939. * @readonly
  33940. */
  33941. // For faster access in Point.update
  33942. point.index = hasGroupedData ? (groupCropStartIndex + i) : cursor;
  33943. points[i] = point;
  33944. }
  33945. }
  33946. // restore keys options (#6590)
  33947. series.options.keys = keys;
  33948. // Hide cropped-away points - this only runs when the number of
  33949. // points is above cropThreshold, or when swithching view from
  33950. // non-grouped data to grouped data (#637)
  33951. if (data &&
  33952. (processedDataLength !== (dataLength = data.length) ||
  33953. hasGroupedData)) {
  33954. for (i = 0; i < dataLength; i++) {
  33955. // when has grouped data, clear all points
  33956. if (i === cropStart && !hasGroupedData) {
  33957. i += processedDataLength;
  33958. }
  33959. if (data[i]) {
  33960. data[i].destroyElements();
  33961. data[i].plotX = void 0; // #1003
  33962. }
  33963. }
  33964. }
  33965. /**
  33966. * Read only. An array containing those values converted to points.
  33967. * In case the series data length exceeds the `cropThreshold`, or if
  33968. * the data is grouped, `series.data` doesn't contain all the
  33969. * points. Also, in case a series is hidden, the `data` array may be
  33970. * empty. To access raw values, `series.options.data` will always be
  33971. * up to date. `Series.data` only contains the points that have been
  33972. * created on demand. To modify the data, use
  33973. * {@link Highcharts.Series#setData} or
  33974. * {@link Highcharts.Point#update}.
  33975. *
  33976. * @see Series.points
  33977. *
  33978. * @name Highcharts.Series#data
  33979. * @type {Array<Highcharts.Point>}
  33980. */
  33981. series.data = data;
  33982. /**
  33983. * An array containing all currently visible point objects. In case
  33984. * of cropping, the cropped-away points are not part of this array.
  33985. * The `series.points` array starts at `series.cropStart` compared
  33986. * to `series.data` and `series.options.data`. If however the series
  33987. * data is grouped, these can't be correlated one to one. To modify
  33988. * the data, use {@link Highcharts.Series#setData} or
  33989. * {@link Highcharts.Point#update}.
  33990. *
  33991. * @name Highcharts.Series#points
  33992. * @type {Array<Highcharts.Point>}
  33993. */
  33994. series.points = points;
  33995. fireEvent(this, 'afterGeneratePoints');
  33996. };
  33997. /**
  33998. * Get current X extremes for the visible data.
  33999. *
  34000. * @private
  34001. * @function Highcharts.Series#getXExtremes
  34002. *
  34003. * @param {Array<number>} xData
  34004. * The data to inspect. Defaults to the current data within the visible
  34005. * range.
  34006. *
  34007. * @return {Highcharts.RangeObject}
  34008. */
  34009. Series.prototype.getXExtremes = function (xData) {
  34010. return {
  34011. min: arrayMin(xData),
  34012. max: arrayMax(xData)
  34013. };
  34014. };
  34015. /**
  34016. * Calculate Y extremes for the visible data. The result is returned
  34017. * as an object with `dataMin` and `dataMax` properties.
  34018. *
  34019. * @private
  34020. * @function Highcharts.Series#getExtremes
  34021. *
  34022. * @param {Array<number>} [yData]
  34023. * The data to inspect. Defaults to the current data within the visible
  34024. * range.
  34025. * @param {boolean} [forceExtremesFromAll]
  34026. * Force getting extremes of a total series data range.
  34027. *
  34028. * @return {Highcharts.DataExtremesObject}
  34029. */
  34030. Series.prototype.getExtremes = function (yData, forceExtremesFromAll) {
  34031. var xAxis = this.xAxis,
  34032. yAxis = this.yAxis,
  34033. xData = this.processedXData || this.xData,
  34034. yDataLength,
  34035. activeYData = [],
  34036. activeCounter = 0,
  34037. // #2117, need to compensate for log X axis
  34038. xExtremes,
  34039. xMin = 0,
  34040. xMax = 0,
  34041. validValue,
  34042. withinRange,
  34043. // Handle X outside the viewed area. This does not work with
  34044. // non-sorted data like scatter (#7639).
  34045. shoulder = this.requireSorting ? this.cropShoulder : 0,
  34046. positiveValuesOnly = yAxis ? yAxis.positiveValuesOnly : false,
  34047. x,
  34048. y,
  34049. i,
  34050. j;
  34051. yData = yData || this.stackedYData || this.processedYData || [];
  34052. yDataLength = yData.length;
  34053. if (xAxis) {
  34054. xExtremes = xAxis.getExtremes();
  34055. xMin = xExtremes.min;
  34056. xMax = xExtremes.max;
  34057. }
  34058. for (i = 0; i < yDataLength; i++) {
  34059. x = xData[i];
  34060. y = yData[i];
  34061. // For points within the visible range, including the first
  34062. // point outside the visible range (#7061), consider y extremes.
  34063. validValue = ((isNumber(y) || isArray(y)) &&
  34064. ((y.length || y > 0) || !positiveValuesOnly));
  34065. withinRange = (forceExtremesFromAll ||
  34066. this.getExtremesFromAll ||
  34067. this.options.getExtremesFromAll ||
  34068. this.cropped ||
  34069. !xAxis || // for colorAxis support
  34070. ((xData[i + shoulder] || x) >= xMin &&
  34071. (xData[i - shoulder] || x) <= xMax));
  34072. if (validValue && withinRange) {
  34073. j = y.length;
  34074. if (j) { // array, like ohlc or range data
  34075. while (j--) {
  34076. if (isNumber(y[j])) { // #7380, #11513
  34077. activeYData[activeCounter++] = y[j];
  34078. }
  34079. }
  34080. }
  34081. else {
  34082. activeYData[activeCounter++] = y;
  34083. }
  34084. }
  34085. }
  34086. var dataExtremes = {
  34087. dataMin: arrayMin(activeYData),
  34088. dataMax: arrayMax(activeYData)
  34089. };
  34090. fireEvent(this, 'afterGetExtremes', { dataExtremes: dataExtremes });
  34091. return dataExtremes;
  34092. };
  34093. /**
  34094. * Set the current data extremes as `dataMin` and `dataMax` on the
  34095. * Series item. Use this only when the series properties should be
  34096. * updated.
  34097. *
  34098. * @private
  34099. * @function Highcharts.Series#applyExtremes
  34100. */
  34101. Series.prototype.applyExtremes = function () {
  34102. var dataExtremes = this.getExtremes();
  34103. /**
  34104. * Contains the minimum value of the series' data point. Some series
  34105. * types like `networkgraph` do not support this property as they
  34106. * lack a `y`-value.
  34107. * @name Highcharts.Series#dataMin
  34108. * @type {number|undefined}
  34109. * @readonly
  34110. */
  34111. this.dataMin = dataExtremes.dataMin;
  34112. /**
  34113. * Contains the maximum value of the series' data point. Some series
  34114. * types like `networkgraph` do not support this property as they
  34115. * lack a `y`-value.
  34116. * @name Highcharts.Series#dataMax
  34117. * @type {number|undefined}
  34118. * @readonly
  34119. */
  34120. this.dataMax = dataExtremes.dataMax;
  34121. return dataExtremes;
  34122. };
  34123. /**
  34124. * Find and return the first non null point in the data
  34125. *
  34126. * @private
  34127. * @function Highcharts.Series.getFirstValidPoint
  34128. *
  34129. * @param {Array<Highcharts.PointOptionsType>} data
  34130. * Array of options for points
  34131. *
  34132. * @return {Highcharts.PointOptionsType}
  34133. */
  34134. Series.prototype.getFirstValidPoint = function (data) {
  34135. var firstPoint = null,
  34136. dataLength = data.length,
  34137. i = 0;
  34138. while (firstPoint === null && i < dataLength) {
  34139. firstPoint = data[i];
  34140. i++;
  34141. }
  34142. return firstPoint;
  34143. };
  34144. /**
  34145. * Translate data points from raw data values to chart specific
  34146. * positioning data needed later in the `drawPoints` and `drawGraph`
  34147. * functions. This function can be overridden in plugins and custom
  34148. * series type implementations.
  34149. *
  34150. * @function Highcharts.Series#translate
  34151. *
  34152. * @fires Highcharts.Series#events:translate
  34153. */
  34154. Series.prototype.translate = function () {
  34155. if (!this.processedXData) { // hidden series
  34156. this.processData();
  34157. }
  34158. this.generatePoints();
  34159. var series = this,
  34160. options = series.options,
  34161. stacking = options.stacking,
  34162. xAxis = series.xAxis,
  34163. categories = xAxis.categories,
  34164. enabledDataSorting = series.enabledDataSorting,
  34165. yAxis = series.yAxis,
  34166. points = series.points,
  34167. dataLength = points.length,
  34168. hasModifyValue = !!series.modifyValue,
  34169. i,
  34170. pointPlacement = series.pointPlacementToXValue(), // #7860
  34171. dynamicallyPlaced = Boolean(pointPlacement),
  34172. threshold = options.threshold,
  34173. stackThreshold = options.startFromThreshold ? threshold : 0,
  34174. plotX,
  34175. lastPlotX,
  34176. stackIndicator,
  34177. zoneAxis = this.zoneAxis || 'y',
  34178. closestPointRangePx = Number.MAX_VALUE;
  34179. /**
  34180. * Plotted coordinates need to be within a limited range. Drawing
  34181. * too far outside the viewport causes various rendering issues
  34182. * (#3201, #3923, #7555).
  34183. * @private
  34184. */
  34185. function limitedRange(val) {
  34186. return clamp(val, -1e5, 1e5);
  34187. }
  34188. // Translate each point
  34189. for (i = 0; i < dataLength; i++) {
  34190. var point = points[i],
  34191. xValue = point.x,
  34192. yValue = point.y,
  34193. yBottom = point.low,
  34194. stack = stacking && yAxis.stacking && yAxis.stacking.stacks[(series.negStacks &&
  34195. yValue <
  34196. (stackThreshold ? 0 : threshold) ?
  34197. '-' :
  34198. '') + series.stackKey],
  34199. pointStack = void 0,
  34200. stackValues = void 0;
  34201. if (yAxis.positiveValuesOnly && !yAxis.validatePositiveValue(yValue) ||
  34202. xAxis.positiveValuesOnly && !xAxis.validatePositiveValue(xValue)) {
  34203. point.isNull = true;
  34204. }
  34205. // Get the plotX translation
  34206. point.plotX = plotX = correctFloat(// #5236
  34207. limitedRange(xAxis.translate(// #3923
  34208. xValue, 0, 0, 0, 1, pointPlacement, this.type === 'flags')) // #3923
  34209. );
  34210. // Calculate the bottom y value for stacked series
  34211. if (stacking &&
  34212. series.visible &&
  34213. stack &&
  34214. stack[xValue]) {
  34215. stackIndicator = series.getStackIndicator(stackIndicator, xValue, series.index);
  34216. if (!point.isNull) {
  34217. pointStack = stack[xValue];
  34218. stackValues =
  34219. pointStack.points[stackIndicator.key];
  34220. }
  34221. }
  34222. if (isArray(stackValues)) {
  34223. yBottom = stackValues[0];
  34224. yValue = stackValues[1];
  34225. if (yBottom === stackThreshold &&
  34226. stackIndicator.key ===
  34227. stack[xValue].base) {
  34228. yBottom = pick((isNumber(threshold) && threshold), yAxis.min);
  34229. }
  34230. // #1200, #1232
  34231. if (yAxis.positiveValuesOnly && yBottom <= 0) {
  34232. yBottom = null;
  34233. }
  34234. point.total = point.stackTotal = pointStack.total;
  34235. point.percentage =
  34236. pointStack.total &&
  34237. (point.y / pointStack.total * 100);
  34238. point.stackY = yValue;
  34239. // Place the stack label
  34240. // in case of variwide series (where widths of points are
  34241. // different in most cases), stack labels are positioned
  34242. // wrongly, so the call of the setOffset is omited here and
  34243. // labels are correctly positioned later, at the end of the
  34244. // variwide's translate function (#10962)
  34245. if (!series.irregularWidths) {
  34246. pointStack.setOffset(series.pointXOffset || 0, series.barW || 0);
  34247. }
  34248. }
  34249. // Set translated yBottom or remove it
  34250. point.yBottom = defined(yBottom) ?
  34251. limitedRange(yAxis.translate(yBottom, 0, 1, 0, 1)) :
  34252. null;
  34253. // general hook, used for Highcharts Stock compare mode
  34254. if (hasModifyValue) {
  34255. yValue = series.modifyValue(yValue, point);
  34256. }
  34257. // Set the the plotY value, reset it for redraws
  34258. // #3201
  34259. point.plotY = void 0;
  34260. if (isNumber(yValue)) {
  34261. var translated = yAxis.translate(yValue,
  34262. false,
  34263. true,
  34264. false,
  34265. true);
  34266. if (typeof translated !== 'undefined') {
  34267. point.plotY = limitedRange(translated);
  34268. }
  34269. }
  34270. point.isInside = this.isPointInside(point);
  34271. // Set client related positions for mouse tracking
  34272. point.clientX = dynamicallyPlaced ?
  34273. correctFloat(xAxis.translate(xValue, 0, 0, 0, 1, pointPlacement)) :
  34274. plotX; // #1514, #5383, #5518
  34275. // Negative points. For bubble charts, this means negative z
  34276. // values (#9728)
  34277. point.negative = point[zoneAxis] < (options[zoneAxis + 'Threshold'] ||
  34278. threshold ||
  34279. 0);
  34280. // some API data
  34281. point.category = (categories &&
  34282. typeof categories[point.x] !== 'undefined' ?
  34283. categories[point.x] :
  34284. point.x);
  34285. // Determine auto enabling of markers (#3635, #5099)
  34286. if (!point.isNull && point.visible !== false) {
  34287. if (typeof lastPlotX !== 'undefined') {
  34288. closestPointRangePx = Math.min(closestPointRangePx, Math.abs(plotX - lastPlotX));
  34289. }
  34290. lastPlotX = plotX;
  34291. }
  34292. // Find point zone
  34293. point.zone = (this.zones.length && point.getZone());
  34294. // Animate new points with data sorting
  34295. if (!point.graphic && series.group && enabledDataSorting) {
  34296. point.isNew = true;
  34297. }
  34298. }
  34299. series.closestPointRangePx = closestPointRangePx;
  34300. fireEvent(this, 'afterTranslate');
  34301. };
  34302. /**
  34303. * Return the series points with null points filtered out.
  34304. *
  34305. * @function Highcharts.Series#getValidPoints
  34306. *
  34307. * @param {Array<Highcharts.Point>} [points]
  34308. * The points to inspect, defaults to {@link Series.points}.
  34309. *
  34310. * @param {boolean} [insideOnly=false]
  34311. * Whether to inspect only the points that are inside the visible view.
  34312. *
  34313. * @param {boolean} [allowNull=false]
  34314. * Whether to allow null points to pass as valid points.
  34315. *
  34316. * @return {Array<Highcharts.Point>}
  34317. * The valid points.
  34318. */
  34319. Series.prototype.getValidPoints = function (points, insideOnly, allowNull) {
  34320. var chart = this.chart;
  34321. // #3916, #5029, #5085
  34322. return (points || this.points || []).filter(function (point) {
  34323. if (insideOnly && !chart.isInsidePlot(point.plotX, point.plotY, { inverted: chart.inverted })) {
  34324. return false;
  34325. }
  34326. return point.visible !== false &&
  34327. (allowNull || !point.isNull);
  34328. });
  34329. };
  34330. /**
  34331. * Get the clipping for the series. Could be called for a series to
  34332. * initiate animating the clip or to set the final clip (only width
  34333. * and x).
  34334. *
  34335. * @private
  34336. * @function Highcharts.Series#getClip
  34337. *
  34338. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  34339. * Initialize the animation.
  34340. *
  34341. * @param {boolean} [finalBox]
  34342. * Final size for the clip - end state for the animation.
  34343. *
  34344. * @return {Highcharts.Dictionary<number>}
  34345. */
  34346. Series.prototype.getClipBox = function (animation, finalBox) {
  34347. var series = this,
  34348. options = series.options,
  34349. chart = series.chart,
  34350. inverted = chart.inverted,
  34351. xAxis = series.xAxis,
  34352. yAxis = xAxis && series.yAxis,
  34353. clipBox,
  34354. scrollablePlotAreaOptions = chart.options.chart.scrollablePlotArea || {};
  34355. if (animation && options.clip === false && yAxis) {
  34356. // support for not clipped series animation (#10450)
  34357. clipBox = inverted ? {
  34358. y: -chart.chartWidth + yAxis.len + yAxis.pos,
  34359. height: chart.chartWidth,
  34360. width: chart.chartHeight,
  34361. x: -chart.chartHeight + xAxis.len + xAxis.pos
  34362. } : {
  34363. y: -yAxis.pos,
  34364. height: chart.chartHeight,
  34365. width: chart.chartWidth,
  34366. x: -xAxis.pos
  34367. };
  34368. // x and width will be changed later when setting for animation
  34369. // initial state in Series.setClip
  34370. }
  34371. else {
  34372. clipBox = series.clipBox || chart.clipBox;
  34373. if (finalBox) {
  34374. clipBox.width = chart.plotSizeX;
  34375. clipBox.x = (chart.scrollablePixelsX || 0) *
  34376. (scrollablePlotAreaOptions.scrollPositionX || 0);
  34377. }
  34378. }
  34379. return !finalBox ? clipBox : {
  34380. width: clipBox.width,
  34381. x: clipBox.x
  34382. };
  34383. };
  34384. /**
  34385. * Get the shared clip key, creating it if it doesn't exist.
  34386. *
  34387. * @private
  34388. * @function Highcharts.Series#getSharedClipKey
  34389. */
  34390. Series.prototype.getSharedClipKey = function (animation) {
  34391. if (this.sharedClipKey) {
  34392. return this.sharedClipKey;
  34393. }
  34394. var sharedClipKey = [
  34395. animation && animation.duration,
  34396. animation && animation.easing,
  34397. animation && animation.defer,
  34398. this.getClipBox(animation).height,
  34399. this.options.xAxis,
  34400. this.options.yAxis
  34401. ].join(',');
  34402. if (this.options.clip !== false || animation) {
  34403. this.sharedClipKey = sharedClipKey;
  34404. }
  34405. return sharedClipKey;
  34406. };
  34407. /**
  34408. * Set the clipping for the series. For animated series it is called
  34409. * twice, first to initiate animating the clip then the second time
  34410. * without the animation to set the final clip.
  34411. *
  34412. * @private
  34413. * @function Highcharts.Series#setClip
  34414. */
  34415. Series.prototype.setClip = function (animation) {
  34416. var chart = this.chart,
  34417. options = this.options,
  34418. renderer = chart.renderer,
  34419. inverted = chart.inverted,
  34420. seriesClipBox = this.clipBox,
  34421. clipBox = this.getClipBox(animation),
  34422. sharedClipKey = this.getSharedClipKey(animation), // #4526
  34423. clipRect = chart.sharedClips[sharedClipKey],
  34424. markerClipRect = chart.sharedClips[sharedClipKey + 'm'];
  34425. if (animation) {
  34426. clipBox.width = 0;
  34427. if (inverted) {
  34428. clipBox.x = chart.plotHeight +
  34429. (options.clip !== false ? 0 : chart.plotTop);
  34430. }
  34431. }
  34432. // If a clipping rectangle with the same properties is currently
  34433. // present in the chart, use that.
  34434. if (!clipRect) {
  34435. // When animation is set, prepare the initial positions
  34436. if (animation) {
  34437. chart.sharedClips[sharedClipKey + 'm'] = markerClipRect =
  34438. renderer.clipRect(
  34439. // include the width of the first marker
  34440. inverted ? (chart.plotSizeX || 0) + 99 : -99, inverted ? -chart.plotLeft : -chart.plotTop, 99, inverted ? chart.chartWidth : chart.chartHeight);
  34441. }
  34442. chart.sharedClips[sharedClipKey] = clipRect = renderer.clipRect(clipBox);
  34443. // Create hashmap for series indexes
  34444. clipRect.count = { length: 0 };
  34445. // When the series is rendered again before starting animating, in
  34446. // compliance to a responsive rule
  34447. }
  34448. else if (!chart.hasLoaded) {
  34449. clipRect.attr(clipBox);
  34450. }
  34451. if (animation) {
  34452. if (!clipRect.count[this.index]) {
  34453. clipRect.count[this.index] = true;
  34454. clipRect.count.length += 1;
  34455. }
  34456. }
  34457. if (options.clip !== false || animation) {
  34458. this.group.clip(animation || seriesClipBox ? clipRect : chart.clipRect);
  34459. this.markerGroup.clip(markerClipRect);
  34460. }
  34461. // Remove the shared clipping rectangle when all series are shown
  34462. if (!animation) {
  34463. if (clipRect.count[this.index]) {
  34464. delete clipRect.count[this.index];
  34465. clipRect.count.length -= 1;
  34466. }
  34467. if (clipRect.count.length === 0) {
  34468. if (!seriesClipBox) {
  34469. chart.sharedClips[sharedClipKey] = clipRect.destroy();
  34470. }
  34471. if (markerClipRect) {
  34472. chart.sharedClips[sharedClipKey + 'm'] = markerClipRect.destroy();
  34473. }
  34474. }
  34475. }
  34476. };
  34477. /**
  34478. * Animate in the series. Called internally twice. First with the `init`
  34479. * parameter set to true, which sets up the initial state of the
  34480. * animation. Then when ready, it is called with the `init` parameter
  34481. * undefined, in order to perform the actual animation. After the
  34482. * second run, the function is removed.
  34483. *
  34484. * @function Highcharts.Series#animate
  34485. *
  34486. * @param {boolean} [init]
  34487. * Initialize the animation.
  34488. */
  34489. Series.prototype.animate = function (init) {
  34490. var series = this,
  34491. chart = series.chart,
  34492. animation = animObject(series.options.animation),
  34493. sharedClipKey = this.sharedClipKey;
  34494. // Initialize the animation. Set up the clipping rectangle.
  34495. if (init) {
  34496. series.setClip(animation);
  34497. // Run the animation
  34498. }
  34499. else if (sharedClipKey) {
  34500. var clipRect = chart.sharedClips[sharedClipKey];
  34501. var markerClipRect = chart.sharedClips[sharedClipKey + 'm'];
  34502. var finalBox = series.getClipBox(animation,
  34503. true);
  34504. if (clipRect) {
  34505. clipRect.animate(finalBox, animation);
  34506. }
  34507. if (markerClipRect) {
  34508. markerClipRect.animate({
  34509. width: finalBox.width + 99,
  34510. x: finalBox.x - (chart.inverted ? 0 : 99)
  34511. }, animation);
  34512. }
  34513. }
  34514. };
  34515. /**
  34516. * This runs after animation to land on the final plot clipping.
  34517. *
  34518. * @private
  34519. * @function Highcharts.Series#afterAnimate
  34520. *
  34521. * @fires Highcharts.Series#event:afterAnimate
  34522. */
  34523. Series.prototype.afterAnimate = function () {
  34524. this.setClip();
  34525. fireEvent(this, 'afterAnimate');
  34526. this.finishedAnimating = true;
  34527. };
  34528. /**
  34529. * Draw the markers for line-like series types, and columns or other
  34530. * graphical representation for {@link Point} objects for other series
  34531. * types. The resulting element is typically stored as
  34532. * {@link Point.graphic}, and is created on the first call and updated
  34533. * and moved on subsequent calls.
  34534. *
  34535. * @function Highcharts.Series#drawPoints
  34536. */
  34537. Series.prototype.drawPoints = function () {
  34538. var series = this,
  34539. points = series.points,
  34540. chart = series.chart,
  34541. i,
  34542. point,
  34543. graphic,
  34544. verb,
  34545. options = series.options,
  34546. seriesMarkerOptions = options.marker,
  34547. pointMarkerOptions,
  34548. hasPointMarker,
  34549. markerGroup = (series[series.specialGroup] ||
  34550. series.markerGroup),
  34551. xAxis = series.xAxis,
  34552. markerAttribs,
  34553. globallyEnabled = pick(seriesMarkerOptions.enabled, !xAxis || xAxis.isRadial ? true : null,
  34554. // Use larger or equal as radius is null in bubbles (#6321)
  34555. series.closestPointRangePx >= (seriesMarkerOptions.enabledThreshold *
  34556. seriesMarkerOptions.radius));
  34557. if (seriesMarkerOptions.enabled !== false ||
  34558. series._hasPointMarkers) {
  34559. for (i = 0; i < points.length; i++) {
  34560. point = points[i];
  34561. graphic = point.graphic;
  34562. verb = graphic ? 'animate' : 'attr';
  34563. pointMarkerOptions = point.marker || {};
  34564. hasPointMarker = !!point.marker;
  34565. var shouldDrawMarker = ((globallyEnabled &&
  34566. typeof pointMarkerOptions.enabled === 'undefined') || pointMarkerOptions.enabled) && !point.isNull && point.visible !== false;
  34567. // only draw the point if y is defined
  34568. if (shouldDrawMarker) {
  34569. // Shortcuts
  34570. var symbol = pick(pointMarkerOptions.symbol,
  34571. series.symbol, 'rect');
  34572. markerAttribs = series.markerAttribs(point, (point.selected && 'select'));
  34573. // Set starting position for point sliding animation.
  34574. if (series.enabledDataSorting) {
  34575. point.startXPos = xAxis.reversed ?
  34576. -(markerAttribs.width || 0) :
  34577. xAxis.width;
  34578. }
  34579. var isInside = point.isInside !== false;
  34580. if (graphic) { // update
  34581. // Since the marker group isn't clipped, each
  34582. // individual marker must be toggled
  34583. graphic[isInside ? 'show' : 'hide'](isInside)
  34584. .animate(markerAttribs);
  34585. }
  34586. else if (isInside &&
  34587. ((markerAttribs.width || 0) > 0 || point.hasImage)) {
  34588. /**
  34589. * The graphic representation of the point.
  34590. * Typically this is a simple shape, like a `rect`
  34591. * for column charts or `path` for line markers, but
  34592. * for some complex series types like boxplot or 3D
  34593. * charts, the graphic may be a `g` element
  34594. * containing other shapes. The graphic is generated
  34595. * the first time {@link Series#drawPoints} runs,
  34596. * and updated and moved on subsequent runs.
  34597. *
  34598. * @name Point#graphic
  34599. * @type {SVGElement}
  34600. */
  34601. point.graphic = graphic = chart.renderer
  34602. .symbol(symbol, markerAttribs.x, markerAttribs.y, markerAttribs.width, markerAttribs.height, hasPointMarker ?
  34603. pointMarkerOptions :
  34604. seriesMarkerOptions)
  34605. .add(markerGroup);
  34606. // Sliding animation for new points
  34607. if (series.enabledDataSorting &&
  34608. chart.hasRendered) {
  34609. graphic.attr({
  34610. x: point.startXPos
  34611. });
  34612. verb = 'animate';
  34613. }
  34614. }
  34615. if (graphic && verb === 'animate') { // update
  34616. // Since the marker group isn't clipped, each
  34617. // individual marker must be toggled
  34618. graphic[isInside ? 'show' : 'hide'](isInside)
  34619. .animate(markerAttribs);
  34620. }
  34621. // Presentational attributes
  34622. if (graphic && !chart.styledMode) {
  34623. graphic[verb](series.pointAttribs(point, (point.selected && 'select')));
  34624. }
  34625. if (graphic) {
  34626. graphic.addClass(point.getClassName(), true);
  34627. }
  34628. }
  34629. else if (graphic) {
  34630. point.graphic = graphic.destroy(); // #1269
  34631. }
  34632. }
  34633. }
  34634. };
  34635. /**
  34636. * Get non-presentational attributes for a point. Used internally for
  34637. * both styled mode and classic. Can be overridden for different series
  34638. * types.
  34639. *
  34640. * @see Series#pointAttribs
  34641. *
  34642. * @function Highcharts.Series#markerAttribs
  34643. *
  34644. * @param {Highcharts.Point} point
  34645. * The Point to inspect.
  34646. *
  34647. * @param {string} [state]
  34648. * The state, can be either `hover`, `select` or undefined.
  34649. *
  34650. * @return {Highcharts.SVGAttributes}
  34651. * A hash containing those attributes that are not settable from CSS.
  34652. */
  34653. Series.prototype.markerAttribs = function (point, state) {
  34654. var seriesOptions = this.options,
  34655. seriesMarkerOptions = seriesOptions.marker,
  34656. seriesStateOptions,
  34657. pointMarkerOptions = point.marker || {},
  34658. symbol = (pointMarkerOptions.symbol ||
  34659. seriesMarkerOptions.symbol),
  34660. pointStateOptions,
  34661. radius = pick(pointMarkerOptions.radius,
  34662. seriesMarkerOptions.radius),
  34663. attribs;
  34664. // Handle hover and select states
  34665. if (state) {
  34666. seriesStateOptions = seriesMarkerOptions.states[state];
  34667. pointStateOptions = pointMarkerOptions.states &&
  34668. pointMarkerOptions.states[state];
  34669. radius = pick(pointStateOptions && pointStateOptions.radius, seriesStateOptions && seriesStateOptions.radius, radius + (seriesStateOptions && seriesStateOptions.radiusPlus ||
  34670. 0));
  34671. }
  34672. point.hasImage = symbol && symbol.indexOf('url') === 0;
  34673. if (point.hasImage) {
  34674. radius = 0; // and subsequently width and height is not set
  34675. }
  34676. attribs = {
  34677. // Math.floor for #1843:
  34678. x: seriesOptions.crisp ?
  34679. Math.floor(point.plotX - radius) :
  34680. point.plotX - radius,
  34681. y: point.plotY - radius
  34682. };
  34683. if (radius) {
  34684. attribs.width = attribs.height = 2 * radius;
  34685. }
  34686. return attribs;
  34687. };
  34688. /**
  34689. * Internal function to get presentational attributes for each point.
  34690. * Unlike {@link Series#markerAttribs}, this function should return
  34691. * those attributes that can also be set in CSS. In styled mode,
  34692. * `pointAttribs` won't be called.
  34693. *
  34694. * @private
  34695. * @function Highcharts.Series#pointAttribs
  34696. *
  34697. * @param {Highcharts.Point} [point]
  34698. * The point instance to inspect.
  34699. *
  34700. * @param {string} [state]
  34701. * The point state, can be either `hover`, `select` or 'normal'. If
  34702. * undefined, normal state is assumed.
  34703. *
  34704. * @return {Highcharts.SVGAttributes}
  34705. * The presentational attributes to be set on the point.
  34706. */
  34707. Series.prototype.pointAttribs = function (point, state) {
  34708. var seriesMarkerOptions = this.options.marker,
  34709. seriesStateOptions,
  34710. pointOptions = point && point.options,
  34711. pointMarkerOptions = ((pointOptions && pointOptions.marker) || {}),
  34712. pointStateOptions,
  34713. color = this.color,
  34714. pointColorOption = pointOptions && pointOptions.color,
  34715. pointColor = point && point.color,
  34716. strokeWidth = pick(pointMarkerOptions.lineWidth,
  34717. seriesMarkerOptions.lineWidth),
  34718. zoneColor = point && point.zone && point.zone.color,
  34719. fill,
  34720. stroke,
  34721. opacity = 1;
  34722. color = (pointColorOption ||
  34723. zoneColor ||
  34724. pointColor ||
  34725. color);
  34726. fill = (pointMarkerOptions.fillColor ||
  34727. seriesMarkerOptions.fillColor ||
  34728. color);
  34729. stroke = (pointMarkerOptions.lineColor ||
  34730. seriesMarkerOptions.lineColor ||
  34731. color);
  34732. // Handle hover and select states
  34733. state = state || 'normal';
  34734. if (state) {
  34735. seriesStateOptions = seriesMarkerOptions.states[state];
  34736. pointStateOptions = (pointMarkerOptions.states &&
  34737. pointMarkerOptions.states[state]) || {};
  34738. strokeWidth = pick(pointStateOptions.lineWidth, seriesStateOptions.lineWidth, strokeWidth + pick(pointStateOptions.lineWidthPlus, seriesStateOptions.lineWidthPlus, 0));
  34739. fill = (pointStateOptions.fillColor ||
  34740. seriesStateOptions.fillColor ||
  34741. fill);
  34742. stroke = (pointStateOptions.lineColor ||
  34743. seriesStateOptions.lineColor ||
  34744. stroke);
  34745. opacity = pick(pointStateOptions.opacity, seriesStateOptions.opacity, opacity);
  34746. }
  34747. return {
  34748. 'stroke': stroke,
  34749. 'stroke-width': strokeWidth,
  34750. 'fill': fill,
  34751. 'opacity': opacity
  34752. };
  34753. };
  34754. /**
  34755. * Clear DOM objects and free up memory.
  34756. *
  34757. * @private
  34758. * @function Highcharts.Series#destroy
  34759. *
  34760. * @fires Highcharts.Series#event:destroy
  34761. */
  34762. Series.prototype.destroy = function (keepEventsForUpdate) {
  34763. var series = this,
  34764. chart = series.chart,
  34765. issue134 = /AppleWebKit\/533/.test(win.navigator.userAgent),
  34766. destroy,
  34767. i,
  34768. data = series.data || [],
  34769. point,
  34770. axis;
  34771. // add event hook
  34772. fireEvent(series, 'destroy');
  34773. // remove events
  34774. this.removeEvents(keepEventsForUpdate);
  34775. // erase from axes
  34776. (series.axisTypes || []).forEach(function (AXIS) {
  34777. axis = series[AXIS];
  34778. if (axis && axis.series) {
  34779. erase(axis.series, series);
  34780. axis.isDirty = axis.forceRedraw = true;
  34781. }
  34782. });
  34783. // remove legend items
  34784. if (series.legendItem) {
  34785. series.chart.legend.destroyItem(series);
  34786. }
  34787. // destroy all points with their elements
  34788. i = data.length;
  34789. while (i--) {
  34790. point = data[i];
  34791. if (point && point.destroy) {
  34792. point.destroy();
  34793. }
  34794. }
  34795. if (series.clips) {
  34796. series.clips.forEach(function (clip) { return clip.destroy(); });
  34797. }
  34798. // Clear the animation timeout if we are destroying the series
  34799. // during initial animation
  34800. U.clearTimeout(series.animationTimeout);
  34801. // Destroy all SVGElements associated to the series
  34802. objectEach(series, function (val, prop) {
  34803. // Survive provides a hook for not destroying
  34804. if (val instanceof SVGElement && !val.survive) {
  34805. // issue 134 workaround
  34806. destroy = issue134 && prop === 'group' ?
  34807. 'hide' :
  34808. 'destroy';
  34809. val[destroy]();
  34810. }
  34811. });
  34812. // remove from hoverSeries
  34813. if (chart.hoverSeries === series) {
  34814. chart.hoverSeries = void 0;
  34815. }
  34816. erase(chart.series, series);
  34817. chart.orderSeries();
  34818. // clear all members
  34819. objectEach(series, function (val, prop) {
  34820. if (!keepEventsForUpdate || prop !== 'hcEvents') {
  34821. delete series[prop];
  34822. }
  34823. });
  34824. };
  34825. /**
  34826. * Clip the graphs into zones for colors and styling.
  34827. *
  34828. * @private
  34829. * @function Highcharts.Series#applyZones
  34830. */
  34831. Series.prototype.applyZones = function () {
  34832. var series = this,
  34833. chart = this.chart,
  34834. renderer = chart.renderer,
  34835. zones = this.zones,
  34836. translatedFrom,
  34837. translatedTo,
  34838. clips = (this.clips || []),
  34839. clipAttr,
  34840. graph = this.graph,
  34841. area = this.area,
  34842. chartSizeMax = Math.max(chart.chartWidth,
  34843. chart.chartHeight),
  34844. axis = this[(this.zoneAxis || 'y') + 'Axis'],
  34845. extremes,
  34846. reversed,
  34847. inverted = chart.inverted,
  34848. horiz,
  34849. pxRange,
  34850. pxPosMin,
  34851. pxPosMax,
  34852. ignoreZones = false,
  34853. zoneArea,
  34854. zoneGraph;
  34855. if (zones.length &&
  34856. (graph || area) &&
  34857. axis &&
  34858. typeof axis.min !== 'undefined') {
  34859. reversed = axis.reversed;
  34860. horiz = axis.horiz;
  34861. // The use of the Color Threshold assumes there are no gaps
  34862. // so it is safe to hide the original graph and area
  34863. // unless it is not waterfall series, then use showLine property
  34864. // to set lines between columns to be visible (#7862)
  34865. if (graph && !this.showLine) {
  34866. graph.hide();
  34867. }
  34868. if (area) {
  34869. area.hide();
  34870. }
  34871. // Create the clips
  34872. extremes = axis.getExtremes();
  34873. zones.forEach(function (threshold, i) {
  34874. translatedFrom = reversed ?
  34875. (horiz ? chart.plotWidth : 0) :
  34876. (horiz ? 0 : (axis.toPixels(extremes.min) || 0));
  34877. translatedFrom = clamp(pick(translatedTo, translatedFrom), 0, chartSizeMax);
  34878. translatedTo = clamp(Math.round(axis.toPixels(pick(threshold.value, extremes.max), true) || 0), 0, chartSizeMax);
  34879. if (ignoreZones) {
  34880. translatedFrom = translatedTo =
  34881. axis.toPixels(extremes.max);
  34882. }
  34883. pxRange = Math.abs(translatedFrom - translatedTo);
  34884. pxPosMin = Math.min(translatedFrom, translatedTo);
  34885. pxPosMax = Math.max(translatedFrom, translatedTo);
  34886. if (axis.isXAxis) {
  34887. clipAttr = {
  34888. x: inverted ? pxPosMax : pxPosMin,
  34889. y: 0,
  34890. width: pxRange,
  34891. height: chartSizeMax
  34892. };
  34893. if (!horiz) {
  34894. clipAttr.x = chart.plotHeight - clipAttr.x;
  34895. }
  34896. }
  34897. else {
  34898. clipAttr = {
  34899. x: 0,
  34900. y: inverted ? pxPosMax : pxPosMin,
  34901. width: chartSizeMax,
  34902. height: pxRange
  34903. };
  34904. if (horiz) {
  34905. clipAttr.y = chart.plotWidth - clipAttr.y;
  34906. }
  34907. }
  34908. // VML SUPPPORT
  34909. if (inverted && renderer.isVML) {
  34910. if (axis.isXAxis) {
  34911. clipAttr = {
  34912. x: 0,
  34913. y: reversed ? pxPosMin : pxPosMax,
  34914. height: clipAttr.width,
  34915. width: chart.chartWidth
  34916. };
  34917. }
  34918. else {
  34919. clipAttr = {
  34920. x: (clipAttr.y -
  34921. chart.plotLeft -
  34922. chart.spacingBox.x),
  34923. y: 0,
  34924. width: clipAttr.height,
  34925. height: chart.chartHeight
  34926. };
  34927. }
  34928. }
  34929. // END OF VML SUPPORT
  34930. if (clips[i]) {
  34931. clips[i].animate(clipAttr);
  34932. }
  34933. else {
  34934. clips[i] = renderer.clipRect(clipAttr);
  34935. }
  34936. // when no data, graph zone is not applied and after setData
  34937. // clip was ignored. As a result, it should be applied each
  34938. // time.
  34939. zoneArea = series['zone-area-' + i];
  34940. zoneGraph = series['zone-graph-' + i];
  34941. if (graph && zoneGraph) {
  34942. zoneGraph.clip(clips[i]);
  34943. }
  34944. if (area && zoneArea) {
  34945. zoneArea.clip(clips[i]);
  34946. }
  34947. // if this zone extends out of the axis, ignore the others
  34948. ignoreZones = threshold.value > extremes.max;
  34949. // Clear translatedTo for indicators
  34950. if (series.resetZones && translatedTo === 0) {
  34951. translatedTo = void 0;
  34952. }
  34953. });
  34954. this.clips = clips;
  34955. }
  34956. else if (series.visible) {
  34957. // If zones were removed, restore graph and area
  34958. if (graph) {
  34959. graph.show(true);
  34960. }
  34961. if (area) {
  34962. area.show(true);
  34963. }
  34964. }
  34965. };
  34966. /**
  34967. * Initialize and perform group inversion on series.group and
  34968. * series.markerGroup.
  34969. *
  34970. * @private
  34971. * @function Highcharts.Series#invertGroups
  34972. */
  34973. Series.prototype.invertGroups = function (inverted) {
  34974. var series = this,
  34975. chart = series.chart;
  34976. /**
  34977. * @private
  34978. */
  34979. function setInvert() {
  34980. ['group', 'markerGroup'].forEach(function (groupName) {
  34981. if (series[groupName]) {
  34982. // VML/HTML needs explicit attributes for flipping
  34983. if (chart.renderer.isVML) {
  34984. series[groupName].attr({
  34985. width: series.yAxis.len,
  34986. height: series.xAxis.len
  34987. });
  34988. }
  34989. series[groupName].width = series.yAxis.len;
  34990. series[groupName].height = series.xAxis.len;
  34991. // If inverted polar, don't invert series group
  34992. series[groupName].invert(series.isRadialSeries ? false : inverted);
  34993. }
  34994. });
  34995. }
  34996. // Pie, go away (#1736)
  34997. if (!series.xAxis) {
  34998. return;
  34999. }
  35000. // A fixed size is needed for inversion to work
  35001. series.eventsToUnbind.push(addEvent(chart, 'resize', setInvert));
  35002. // Do it now
  35003. setInvert();
  35004. // On subsequent render and redraw, just do setInvert without
  35005. // setting up events again
  35006. series.invertGroups = setInvert;
  35007. };
  35008. /**
  35009. * General abstraction for creating plot groups like series.group,
  35010. * series.dataLabelsGroup and series.markerGroup. On subsequent calls,
  35011. * the group will only be adjusted to the updated plot size.
  35012. *
  35013. * @private
  35014. * @function Highcharts.Series#plotGroup
  35015. */
  35016. Series.prototype.plotGroup = function (prop, name, visibility, zIndex, parent) {
  35017. var group = this[prop];
  35018. var isNew = !group,
  35019. attrs = {
  35020. visibility: visibility,
  35021. zIndex: zIndex || 0.1 // IE8 and pointer logic use this
  35022. };
  35023. // Avoid setting undefined opacity, or in styled mode
  35024. if (typeof this.opacity !== 'undefined' &&
  35025. !this.chart.styledMode && this.state !== 'inactive' // #13719
  35026. ) {
  35027. attrs.opacity = this.opacity;
  35028. }
  35029. // Generate it on first call
  35030. if (isNew) {
  35031. this[prop] = group = this.chart.renderer
  35032. .g()
  35033. .add(parent);
  35034. }
  35035. // Add the class names, and replace existing ones as response to
  35036. // Series.update (#6660)
  35037. group.addClass(('highcharts-' + name +
  35038. ' highcharts-series-' + this.index +
  35039. ' highcharts-' + this.type + '-series ' +
  35040. (defined(this.colorIndex) ?
  35041. 'highcharts-color-' + this.colorIndex + ' ' :
  35042. '') +
  35043. (this.options.className || '') +
  35044. (group.hasClass('highcharts-tracker') ?
  35045. ' highcharts-tracker' :
  35046. '')), true);
  35047. // Place it on first and subsequent (redraw) calls
  35048. group.attr(attrs)[isNew ? 'attr' : 'animate'](this.getPlotBox());
  35049. return group;
  35050. };
  35051. /**
  35052. * Get the translation and scale for the plot area of this series.
  35053. *
  35054. * @function Highcharts.Series#getPlotBox
  35055. *
  35056. * @return {Highcharts.SeriesPlotBoxObject}
  35057. */
  35058. Series.prototype.getPlotBox = function () {
  35059. var chart = this.chart,
  35060. xAxis = this.xAxis,
  35061. yAxis = this.yAxis;
  35062. // Swap axes for inverted (#2339)
  35063. if (chart.inverted) {
  35064. xAxis = yAxis;
  35065. yAxis = this.xAxis;
  35066. }
  35067. return {
  35068. translateX: xAxis ? xAxis.left : chart.plotLeft,
  35069. translateY: yAxis ? yAxis.top : chart.plotTop,
  35070. scaleX: 1,
  35071. scaleY: 1
  35072. };
  35073. };
  35074. /**
  35075. * Removes the event handlers attached previously with addEvents.
  35076. * @private
  35077. * @function Highcharts.Series#removeEvents
  35078. */
  35079. Series.prototype.removeEvents = function (keepEventsForUpdate) {
  35080. var series = this;
  35081. if (!keepEventsForUpdate) {
  35082. // remove all events
  35083. removeEvent(series);
  35084. }
  35085. if (series.eventsToUnbind.length) {
  35086. // remove only internal events for proper update
  35087. // #12355 - solves problem with multiple destroy events
  35088. series.eventsToUnbind.forEach(function (unbind) {
  35089. unbind();
  35090. });
  35091. series.eventsToUnbind.length = 0;
  35092. }
  35093. };
  35094. /**
  35095. * Render the graph and markers. Called internally when first rendering
  35096. * and later when redrawing the chart. This function can be extended in
  35097. * plugins, but normally shouldn't be called directly.
  35098. *
  35099. * @function Highcharts.Series#render
  35100. *
  35101. * @fires Highcharts.Series#event:afterRender
  35102. */
  35103. Series.prototype.render = function () {
  35104. var series = this,
  35105. chart = series.chart,
  35106. group,
  35107. options = series.options,
  35108. animOptions = animObject(options.animation),
  35109. // Animation doesn't work in IE8 quirks when the group div is
  35110. // hidden, and looks bad in other oldIE
  35111. animDuration = (!series.finishedAnimating &&
  35112. chart.renderer.isSVG &&
  35113. animOptions.duration),
  35114. visibility = series.visible ?
  35115. 'inherit' : 'hidden', // #2597
  35116. zIndex = options.zIndex,
  35117. hasRendered = series.hasRendered,
  35118. chartSeriesGroup = chart.seriesGroup,
  35119. inverted = chart.inverted;
  35120. fireEvent(this, 'render');
  35121. // the group
  35122. group = series.plotGroup('group', 'series', visibility, zIndex, chartSeriesGroup);
  35123. series.markerGroup = series.plotGroup('markerGroup', 'markers', visibility, zIndex, chartSeriesGroup);
  35124. // initiate the animation
  35125. if (animDuration && series.animate) {
  35126. series.animate(true);
  35127. }
  35128. // SVGRenderer needs to know this before drawing elements (#1089,
  35129. // #1795)
  35130. group.inverted = pick(series.invertible, series.isCartesian) ?
  35131. inverted : false;
  35132. // Draw the graph if any
  35133. if (series.drawGraph) {
  35134. series.drawGraph();
  35135. series.applyZones();
  35136. }
  35137. // Draw the points
  35138. if (series.visible) {
  35139. series.drawPoints();
  35140. }
  35141. /* series.points.forEach(function (point) {
  35142. if (point.redraw) {
  35143. point.redraw();
  35144. }
  35145. }); */
  35146. // Draw the data labels
  35147. if (series.drawDataLabels) {
  35148. series.drawDataLabels();
  35149. }
  35150. // In pie charts, slices are added to the DOM, but actual rendering
  35151. // is postponed until labels reserved their space
  35152. if (series.redrawPoints) {
  35153. series.redrawPoints();
  35154. }
  35155. // draw the mouse tracking area
  35156. if (series.drawTracker &&
  35157. series.options.enableMouseTracking !== false) {
  35158. series.drawTracker();
  35159. }
  35160. // Handle inverted series and tracker groups
  35161. series.invertGroups(inverted);
  35162. // Initial clipping, must be defined after inverting groups for VML.
  35163. // Applies to columns etc. (#3839).
  35164. if (options.clip !== false &&
  35165. !series.sharedClipKey &&
  35166. !hasRendered) {
  35167. group.clip(chart.clipRect);
  35168. }
  35169. // Run the animation
  35170. if (animDuration && series.animate) {
  35171. series.animate();
  35172. }
  35173. // Call the afterAnimate function on animation complete (but don't
  35174. // overwrite the animation.complete option which should be available
  35175. // to the user).
  35176. if (!hasRendered) {
  35177. // Additional time if defer is defined before afterAnimate
  35178. // will be triggered
  35179. if (animDuration && animOptions.defer) {
  35180. animDuration += animOptions.defer;
  35181. }
  35182. series.animationTimeout = syncTimeout(function () {
  35183. series.afterAnimate();
  35184. }, animDuration || 0);
  35185. }
  35186. // Means data is in accordance with what you see
  35187. series.isDirty = false;
  35188. // (See #322) series.isDirty = series.isDirtyData = false; // means
  35189. // data is in accordance with what you see
  35190. series.hasRendered = true;
  35191. fireEvent(series, 'afterRender');
  35192. };
  35193. /**
  35194. * Redraw the series. This function is called internally from
  35195. * `chart.redraw` and normally shouldn't be called directly.
  35196. * @private
  35197. * @function Highcharts.Series#redraw
  35198. */
  35199. Series.prototype.redraw = function () {
  35200. var series = this,
  35201. chart = series.chart,
  35202. // cache it here as it is set to false in render, but used after
  35203. wasDirty = series.isDirty || series.isDirtyData,
  35204. group = series.group,
  35205. xAxis = series.xAxis,
  35206. yAxis = series.yAxis;
  35207. // reposition on resize
  35208. if (group) {
  35209. if (chart.inverted) {
  35210. group.attr({
  35211. width: chart.plotWidth,
  35212. height: chart.plotHeight
  35213. });
  35214. }
  35215. group.animate({
  35216. translateX: pick(xAxis && xAxis.left, chart.plotLeft),
  35217. translateY: pick(yAxis && yAxis.top, chart.plotTop)
  35218. });
  35219. }
  35220. series.translate();
  35221. series.render();
  35222. if (wasDirty) { // #3868, #3945
  35223. delete this.kdTree;
  35224. }
  35225. };
  35226. /**
  35227. * @private
  35228. * @function Highcharts.Series#searchPoint
  35229. */
  35230. Series.prototype.searchPoint = function (e, compareX) {
  35231. var series = this,
  35232. xAxis = series.xAxis,
  35233. yAxis = series.yAxis,
  35234. inverted = series.chart.inverted;
  35235. return this.searchKDTree({
  35236. clientX: inverted ?
  35237. xAxis.len - e.chartY + xAxis.pos :
  35238. e.chartX - xAxis.pos,
  35239. plotY: inverted ?
  35240. yAxis.len - e.chartX + yAxis.pos :
  35241. e.chartY - yAxis.pos
  35242. }, compareX, e);
  35243. };
  35244. /**
  35245. * Build the k-d-tree that is used by mouse and touch interaction to get
  35246. * the closest point. Line-like series typically have a one-dimensional
  35247. * tree where points are searched along the X axis, while scatter-like
  35248. * series typically search in two dimensions, X and Y.
  35249. *
  35250. * @private
  35251. * @function Highcharts.Series#buildKDTree
  35252. */
  35253. Series.prototype.buildKDTree = function (e) {
  35254. // Prevent multiple k-d-trees from being built simultaneously
  35255. // (#6235)
  35256. this.buildingKdTree = true;
  35257. var series = this,
  35258. dimensions = series.options.findNearestPointBy
  35259. .indexOf('y') > -1 ? 2 : 1;
  35260. /**
  35261. * Internal function
  35262. * @private
  35263. */
  35264. function _kdtree(points, depth, dimensions) {
  35265. var axis,
  35266. median,
  35267. length = points && points.length;
  35268. if (length) {
  35269. // alternate between the axis
  35270. axis = series.kdAxisArray[depth % dimensions];
  35271. // sort point array
  35272. points.sort(function (a, b) {
  35273. return a[axis] - b[axis];
  35274. });
  35275. median = Math.floor(length / 2);
  35276. // build and return nod
  35277. return {
  35278. point: points[median],
  35279. left: _kdtree(points.slice(0, median), depth + 1, dimensions),
  35280. right: _kdtree(points.slice(median + 1), depth + 1, dimensions)
  35281. };
  35282. }
  35283. }
  35284. /**
  35285. * Start the recursive build process with a clone of the points
  35286. * array and null points filtered out. (#3873)
  35287. * @private
  35288. */
  35289. function startRecursive() {
  35290. series.kdTree = _kdtree(series.getValidPoints(null,
  35291. // For line-type series restrict to plot area, but
  35292. // column-type series not (#3916, #4511)
  35293. !series.directTouch), dimensions, dimensions);
  35294. series.buildingKdTree = false;
  35295. }
  35296. delete series.kdTree;
  35297. // For testing tooltips, don't build async. Also if touchstart, we
  35298. // may be dealing with click events on mobile, so don't delay
  35299. // (#6817).
  35300. syncTimeout(startRecursive, series.options.kdNow || (e && e.type === 'touchstart') ? 0 : 1);
  35301. };
  35302. /**
  35303. * @private
  35304. * @function Highcharts.Series#searchKDTree
  35305. */
  35306. Series.prototype.searchKDTree = function (point, compareX, e) {
  35307. var series = this,
  35308. kdX = this.kdAxisArray[0],
  35309. kdY = this.kdAxisArray[1],
  35310. kdComparer = compareX ? 'distX' : 'dist',
  35311. kdDimensions = series.options.findNearestPointBy
  35312. .indexOf('y') > -1 ? 2 : 1;
  35313. /**
  35314. * Set the one and two dimensional distance on the point object.
  35315. * @private
  35316. */
  35317. function setDistance(p1, p2) {
  35318. var x = (defined(p1[kdX]) &&
  35319. defined(p2[kdX])) ?
  35320. Math.pow(p1[kdX] - p2[kdX], 2) :
  35321. null,
  35322. y = (defined(p1[kdY]) &&
  35323. defined(p2[kdY])) ?
  35324. Math.pow(p1[kdY] - p2[kdY], 2) :
  35325. null,
  35326. r = (x || 0) + (y || 0);
  35327. p2.dist = defined(r) ? Math.sqrt(r) : Number.MAX_VALUE;
  35328. p2.distX = defined(x) ? Math.sqrt(x) : Number.MAX_VALUE;
  35329. }
  35330. /**
  35331. * @private
  35332. */
  35333. function _search(search, tree, depth, dimensions) {
  35334. var point = tree.point,
  35335. axis = series.kdAxisArray[depth % dimensions],
  35336. tdist,
  35337. sideA,
  35338. sideB,
  35339. ret = point,
  35340. nPoint1,
  35341. nPoint2;
  35342. setDistance(search, point);
  35343. // Pick side based on distance to splitting point
  35344. tdist = search[axis] - point[axis];
  35345. sideA = tdist < 0 ? 'left' : 'right';
  35346. sideB = tdist < 0 ? 'right' : 'left';
  35347. // End of tree
  35348. if (tree[sideA]) {
  35349. nPoint1 = _search(search, tree[sideA], depth + 1, dimensions);
  35350. ret = (nPoint1[kdComparer] <
  35351. ret[kdComparer] ?
  35352. nPoint1 :
  35353. point);
  35354. }
  35355. if (tree[sideB]) {
  35356. // compare distance to current best to splitting point to
  35357. // decide wether to check side B or not
  35358. if (Math.sqrt(tdist * tdist) < ret[kdComparer]) {
  35359. nPoint2 = _search(search, tree[sideB], depth + 1, dimensions);
  35360. ret = (nPoint2[kdComparer] <
  35361. ret[kdComparer] ?
  35362. nPoint2 :
  35363. ret);
  35364. }
  35365. }
  35366. return ret;
  35367. }
  35368. if (!this.kdTree && !this.buildingKdTree) {
  35369. this.buildKDTree(e);
  35370. }
  35371. if (this.kdTree) {
  35372. return _search(point, this.kdTree, kdDimensions, kdDimensions);
  35373. }
  35374. };
  35375. /**
  35376. * @private
  35377. * @function Highcharts.Series#pointPlacementToXValue
  35378. */
  35379. Series.prototype.pointPlacementToXValue = function () {
  35380. var _a = this,
  35381. _b = _a.options,
  35382. pointPlacement = _b.pointPlacement,
  35383. pointRange = _b.pointRange,
  35384. axis = _a.xAxis;
  35385. var factor = pointPlacement;
  35386. // Point placement is relative to each series pointRange (#5889)
  35387. if (factor === 'between') {
  35388. factor = axis.reversed ? -0.5 : 0.5; // #11955
  35389. }
  35390. return isNumber(factor) ?
  35391. factor * (pointRange || axis.pointRange) :
  35392. 0;
  35393. };
  35394. /**
  35395. * @private
  35396. * @function Highcharts.Series#isPointInside
  35397. */
  35398. Series.prototype.isPointInside = function (point) {
  35399. var isInside = typeof point.plotY !== 'undefined' &&
  35400. typeof point.plotX !== 'undefined' &&
  35401. point.plotY >= 0 &&
  35402. point.plotY <= this.yAxis.len && // #3519
  35403. point.plotX >= 0 &&
  35404. point.plotX <= this.xAxis.len;
  35405. return isInside;
  35406. };
  35407. /**
  35408. * Draw the tracker object that sits above all data labels and markers to
  35409. * track mouse events on the graph or points. For the line type charts
  35410. * the tracker uses the same graphPath, but with a greater stroke width
  35411. * for better control.
  35412. * @private
  35413. */
  35414. Series.prototype.drawTracker = function () {
  35415. var series = this,
  35416. options = series.options,
  35417. trackByArea = options.trackByArea,
  35418. trackerPath = [].concat(trackByArea ?
  35419. series.areaPath :
  35420. series.graphPath),
  35421. // trackerPathLength = trackerPath.length,
  35422. chart = series.chart,
  35423. pointer = chart.pointer,
  35424. renderer = chart.renderer,
  35425. snap = chart.options.tooltip.snap,
  35426. tracker = series.tracker,
  35427. i,
  35428. onMouseOver = function (e) {
  35429. if (chart.hoverSeries !== series) {
  35430. series.onMouseOver();
  35431. }
  35432. },
  35433. /*
  35434. * Empirical lowest possible opacities for TRACKER_FILL for an
  35435. * element to stay invisible but clickable
  35436. * IE6: 0.002
  35437. * IE7: 0.002
  35438. * IE8: 0.002
  35439. * IE9: 0.00000000001 (unlimited)
  35440. * IE10: 0.0001 (exporting only)
  35441. * FF: 0.00000000001 (unlimited)
  35442. * Chrome: 0.000001
  35443. * Safari: 0.000001
  35444. * Opera: 0.00000000001 (unlimited)
  35445. */
  35446. TRACKER_FILL = 'rgba(192,192,192,' + (svg ? 0.0001 : 0.002) + ')';
  35447. // Draw the tracker
  35448. if (tracker) {
  35449. tracker.attr({ d: trackerPath });
  35450. }
  35451. else if (series.graph) { // create
  35452. series.tracker = renderer.path(trackerPath)
  35453. .attr({
  35454. visibility: series.visible ? 'visible' : 'hidden',
  35455. zIndex: 2
  35456. })
  35457. .addClass(trackByArea ?
  35458. 'highcharts-tracker-area' :
  35459. 'highcharts-tracker-line')
  35460. .add(series.group);
  35461. if (!chart.styledMode) {
  35462. series.tracker.attr({
  35463. 'stroke-linecap': 'round',
  35464. 'stroke-linejoin': 'round',
  35465. stroke: TRACKER_FILL,
  35466. fill: trackByArea ? TRACKER_FILL : 'none',
  35467. 'stroke-width': series.graph.strokeWidth() +
  35468. (trackByArea ? 0 : 2 * snap)
  35469. });
  35470. }
  35471. // The tracker is added to the series group, which is clipped, but
  35472. // is covered by the marker group. So the marker group also needs to
  35473. // capture events.
  35474. [
  35475. series.tracker,
  35476. series.markerGroup,
  35477. series.dataLabelsGroup
  35478. ].forEach(function (tracker) {
  35479. if (tracker) {
  35480. tracker.addClass('highcharts-tracker')
  35481. .on('mouseover', onMouseOver)
  35482. .on('mouseout', function (e) {
  35483. pointer.onTrackerMouseOut(e);
  35484. });
  35485. if (options.cursor && !chart.styledMode) {
  35486. tracker.css({ cursor: options.cursor });
  35487. }
  35488. if (hasTouch) {
  35489. tracker.on('touchstart', onMouseOver);
  35490. }
  35491. }
  35492. });
  35493. }
  35494. fireEvent(this, 'afterDrawTracker');
  35495. };
  35496. /**
  35497. * Add a point to the series after render time. The point can be added at
  35498. * the end, or by giving it an X value, to the start or in the middle of the
  35499. * series.
  35500. *
  35501. * @sample highcharts/members/series-addpoint-append/
  35502. * Append point
  35503. * @sample highcharts/members/series-addpoint-append-and-shift/
  35504. * Append and shift
  35505. * @sample highcharts/members/series-addpoint-x-and-y/
  35506. * Both X and Y values given
  35507. * @sample highcharts/members/series-addpoint-pie/
  35508. * Append pie slice
  35509. * @sample stock/members/series-addpoint/
  35510. * Append 100 points in Highcharts Stock
  35511. * @sample stock/members/series-addpoint-shift/
  35512. * Append and shift in Highcharts Stock
  35513. * @sample maps/members/series-addpoint/
  35514. * Add a point in Highmaps
  35515. *
  35516. * @function Highcharts.Series#addPoint
  35517. *
  35518. * @param {Highcharts.PointOptionsType} options
  35519. * The point options. If options is a single number, a point with
  35520. * that y value is appended to the series. If it is an array, it will
  35521. * be interpreted as x and y values respectively. If it is an
  35522. * object, advanced options as outlined under `series.data` are
  35523. * applied.
  35524. *
  35525. * @param {boolean} [redraw=true]
  35526. * Whether to redraw the chart after the point is added. When adding
  35527. * more than one point, it is highly recommended that the redraw
  35528. * option be set to false, and instead {@link Chart#redraw} is
  35529. * explicitly called after the adding of points is finished.
  35530. * Otherwise, the chart will redraw after adding each point.
  35531. *
  35532. * @param {boolean} [shift=false]
  35533. * If true, a point is shifted off the start of the series as one is
  35534. * appended to the end.
  35535. *
  35536. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  35537. * Whether to apply animation, and optionally animation
  35538. * configuration.
  35539. *
  35540. * @param {boolean} [withEvent=true]
  35541. * Used internally, whether to fire the series `addPoint` event.
  35542. *
  35543. * @fires Highcharts.Series#event:addPoint
  35544. */
  35545. Series.prototype.addPoint = function (options, redraw, shift, animation, withEvent) {
  35546. var series = this,
  35547. seriesOptions = series.options,
  35548. data = series.data,
  35549. chart = series.chart,
  35550. xAxis = series.xAxis,
  35551. names = xAxis && xAxis.hasNames && xAxis.names,
  35552. dataOptions = seriesOptions.data,
  35553. point,
  35554. xData = series.xData,
  35555. isInTheMiddle,
  35556. i,
  35557. x;
  35558. // Optional redraw, defaults to true
  35559. redraw = pick(redraw, true);
  35560. // Get options and push the point to xData, yData and series.options. In
  35561. // series.generatePoints the Point instance will be created on demand
  35562. // and pushed to the series.data array.
  35563. point = { series: series };
  35564. series.pointClass.prototype.applyOptions.apply(point, [options]);
  35565. x = point.x;
  35566. // Get the insertion point
  35567. i = xData.length;
  35568. if (series.requireSorting && x < xData[i - 1]) {
  35569. isInTheMiddle = true;
  35570. while (i && xData[i - 1] > x) {
  35571. i--;
  35572. }
  35573. }
  35574. // Insert undefined item
  35575. series.updateParallelArrays(point, 'splice', i, 0, 0);
  35576. // Update it
  35577. series.updateParallelArrays(point, i);
  35578. if (names && point.name) {
  35579. names[x] = point.name;
  35580. }
  35581. dataOptions.splice(i, 0, options);
  35582. if (isInTheMiddle) {
  35583. series.data.splice(i, 0, null);
  35584. series.processData();
  35585. }
  35586. // Generate points to be added to the legend (#1329)
  35587. if (seriesOptions.legendType === 'point') {
  35588. series.generatePoints();
  35589. }
  35590. // Shift the first point off the parallel arrays
  35591. if (shift) {
  35592. if (data[0] && data[0].remove) {
  35593. data[0].remove(false);
  35594. }
  35595. else {
  35596. data.shift();
  35597. series.updateParallelArrays(point, 'shift');
  35598. dataOptions.shift();
  35599. }
  35600. }
  35601. // Fire event
  35602. if (withEvent !== false) {
  35603. fireEvent(series, 'addPoint', { point: point });
  35604. }
  35605. // redraw
  35606. series.isDirty = true;
  35607. series.isDirtyData = true;
  35608. if (redraw) {
  35609. chart.redraw(animation); // Animation is set anyway on redraw, #5665
  35610. }
  35611. };
  35612. /**
  35613. * Remove a point from the series. Unlike the
  35614. * {@link Highcharts.Point#remove} method, this can also be done on a point
  35615. * that is not instanciated because it is outside the view or subject to
  35616. * Highcharts Stock data grouping.
  35617. *
  35618. * @sample highcharts/members/series-removepoint/
  35619. * Remove cropped point
  35620. *
  35621. * @function Highcharts.Series#removePoint
  35622. *
  35623. * @param {number} i
  35624. * The index of the point in the {@link Highcharts.Series.data|data}
  35625. * array.
  35626. *
  35627. * @param {boolean} [redraw=true]
  35628. * Whether to redraw the chart after the point is added. When
  35629. * removing more than one point, it is highly recommended that the
  35630. * `redraw` option be set to `false`, and instead {@link
  35631. * Highcharts.Chart#redraw} is explicitly called after the adding of
  35632. * points is finished.
  35633. *
  35634. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  35635. * Whether and optionally how the series should be animated.
  35636. *
  35637. * @fires Highcharts.Point#event:remove
  35638. */
  35639. Series.prototype.removePoint = function (i, redraw, animation) {
  35640. var series = this,
  35641. data = series.data,
  35642. point = data[i],
  35643. points = series.points,
  35644. chart = series.chart,
  35645. remove = function () {
  35646. if (points && points.length === data.length) { // #4935
  35647. points.splice(i, 1);
  35648. }
  35649. data.splice(i, 1);
  35650. series.options.data.splice(i, 1);
  35651. series.updateParallelArrays(point || { series: series }, 'splice', i, 1);
  35652. if (point) {
  35653. point.destroy();
  35654. }
  35655. // redraw
  35656. series.isDirty = true;
  35657. series.isDirtyData = true;
  35658. if (redraw) {
  35659. chart.redraw();
  35660. }
  35661. };
  35662. setAnimation(animation, chart);
  35663. redraw = pick(redraw, true);
  35664. // Fire the event with a default handler of removing the point
  35665. if (point) {
  35666. point.firePointEvent('remove', null, remove);
  35667. }
  35668. else {
  35669. remove();
  35670. }
  35671. };
  35672. /**
  35673. * Remove a series and optionally redraw the chart.
  35674. *
  35675. * @sample highcharts/members/series-remove/
  35676. * Remove first series from a button
  35677. *
  35678. * @function Highcharts.Series#remove
  35679. *
  35680. * @param {boolean} [redraw=true]
  35681. * Whether to redraw the chart or wait for an explicit call to
  35682. * {@link Highcharts.Chart#redraw}.
  35683. *
  35684. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>} [animation]
  35685. * Whether to apply animation, and optionally animation
  35686. * configuration.
  35687. *
  35688. * @param {boolean} [withEvent=true]
  35689. * Used internally, whether to fire the series `remove` event.
  35690. *
  35691. * @fires Highcharts.Series#event:remove
  35692. */
  35693. Series.prototype.remove = function (redraw, animation, withEvent, keepEvents) {
  35694. var series = this,
  35695. chart = series.chart;
  35696. /**
  35697. * @private
  35698. */
  35699. function remove() {
  35700. // Destroy elements
  35701. series.destroy(keepEvents);
  35702. // Redraw
  35703. chart.isDirtyLegend = chart.isDirtyBox = true;
  35704. chart.linkSeries();
  35705. if (pick(redraw, true)) {
  35706. chart.redraw(animation);
  35707. }
  35708. }
  35709. // Fire the event with a default handler of removing the point
  35710. if (withEvent !== false) {
  35711. fireEvent(series, 'remove', null, remove);
  35712. }
  35713. else {
  35714. remove();
  35715. }
  35716. };
  35717. /**
  35718. * Update the series with a new set of options. For a clean and precise
  35719. * handling of new options, all methods and elements from the series are
  35720. * removed, and it is initialized from scratch. Therefore, this method is
  35721. * more performance expensive than some other utility methods like {@link
  35722. * Series#setData} or {@link Series#setVisible}.
  35723. *
  35724. * Note that `Series.update` may mutate the passed `data` options.
  35725. *
  35726. * @sample highcharts/members/series-update/
  35727. * Updating series options
  35728. * @sample maps/members/series-update/
  35729. * Update series options in Highmaps
  35730. *
  35731. * @function Highcharts.Series#update
  35732. *
  35733. * @param {Highcharts.SeriesOptionsType} options
  35734. * New options that will be merged with the series' existing options.
  35735. *
  35736. * @param {boolean} [redraw=true]
  35737. * Whether to redraw the chart after the series is altered. If doing
  35738. * more operations on the chart, it is a good idea to set redraw to
  35739. * false and call {@link Chart#redraw} after.
  35740. *
  35741. * @fires Highcharts.Series#event:update
  35742. * @fires Highcharts.Series#event:afterUpdate
  35743. */
  35744. Series.prototype.update = function (options, redraw) {
  35745. options = cleanRecursively(options, this.userOptions);
  35746. fireEvent(this, 'update', { options: options });
  35747. var series = this,
  35748. chart = series.chart,
  35749. // must use user options when changing type because series.options
  35750. // is merged in with type specific plotOptions
  35751. oldOptions = series.userOptions,
  35752. seriesOptions,
  35753. initialType = series.initialType || series.type,
  35754. plotOptions = chart.options.plotOptions,
  35755. newType = (options.type ||
  35756. oldOptions.type ||
  35757. chart.options.chart.type),
  35758. keepPoints = !(
  35759. // Indicators, histograms etc recalculate the data. It should be
  35760. // possible to omit this.
  35761. this.hasDerivedData ||
  35762. // New type requires new point classes
  35763. (newType && newType !== this.type) ||
  35764. // New options affecting how the data points are built
  35765. typeof options.pointStart !== 'undefined' ||
  35766. typeof options.pointInterval !== 'undefined' ||
  35767. // Changes to data grouping requires new points in new group
  35768. series.hasOptionChanged('dataGrouping') ||
  35769. series.hasOptionChanged('pointStart') ||
  35770. series.hasOptionChanged('pointInterval') ||
  35771. series.hasOptionChanged('pointIntervalUnit') ||
  35772. series.hasOptionChanged('keys')),
  35773. initialSeriesProto = seriesTypes[initialType].prototype,
  35774. n,
  35775. groups = [
  35776. 'group',
  35777. 'markerGroup',
  35778. 'dataLabelsGroup',
  35779. 'transformGroup'
  35780. ],
  35781. preserve = [
  35782. 'eventOptions',
  35783. 'navigatorSeries',
  35784. 'baseSeries'
  35785. ],
  35786. // Animation must be enabled when calling update before the initial
  35787. // animation has first run. This happens when calling update
  35788. // directly after chart initialization, or when applying responsive
  35789. // rules (#6912).
  35790. animation = series.finishedAnimating && { animation: false },
  35791. kinds = {};
  35792. newType = newType || initialType;
  35793. if (keepPoints) {
  35794. preserve.push('data', 'isDirtyData', 'points', 'processedXData', 'processedYData', 'xIncrement', 'cropped', '_hasPointMarkers', '_hasPointLabels', 'clips', // #15420
  35795. // Networkgraph (#14397)
  35796. 'nodes', 'layout',
  35797. // Map specific, consider moving it to series-specific preserve-
  35798. // properties (#10617)
  35799. 'mapMap', 'mapData', 'minY', 'maxY', 'minX', 'maxX');
  35800. if (options.visible !== false) {
  35801. preserve.push('area', 'graph');
  35802. }
  35803. series.parallelArrays.forEach(function (key) {
  35804. preserve.push(key + 'Data');
  35805. });
  35806. if (options.data) {
  35807. // setData uses dataSorting options so we need to update them
  35808. // earlier
  35809. if (options.dataSorting) {
  35810. extend(series.options.dataSorting, options.dataSorting);
  35811. }
  35812. this.setData(options.data, false);
  35813. }
  35814. }
  35815. // Do the merge, with some forced options
  35816. options = merge(oldOptions, animation, {
  35817. // When oldOptions.index is null it should't be cleared.
  35818. // Otherwise navigator series will have wrong indexes (#10193).
  35819. index: typeof oldOptions.index === 'undefined' ?
  35820. series.index : oldOptions.index,
  35821. pointStart: pick(
  35822. // when updating from blank (#7933)
  35823. plotOptions && plotOptions.series && plotOptions.series.pointStart, oldOptions.pointStart,
  35824. // when updating after addPoint
  35825. series.xData[0])
  35826. }, (!keepPoints && { data: series.options.data }), options);
  35827. // Merge does not merge arrays, but replaces them. Since points were
  35828. // updated, `series.options.data` has correct merged options, use it:
  35829. if (keepPoints && options.data) {
  35830. options.data = series.options.data;
  35831. }
  35832. // Make sure preserved properties are not destroyed (#3094)
  35833. preserve = groups.concat(preserve);
  35834. preserve.forEach(function (prop) {
  35835. preserve[prop] = series[prop];
  35836. delete series[prop];
  35837. });
  35838. var casting = false;
  35839. if (seriesTypes[newType]) {
  35840. casting = newType !== series.type;
  35841. // Destroy the series and delete all properties, it will be
  35842. // reinserted within the `init` call below
  35843. series.remove(false, false, false, true);
  35844. if (casting) {
  35845. // Modern browsers including IE11
  35846. // @todo slow, consider alternatives mentioned:
  35847. // https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/setPrototypeOf
  35848. if (Object.setPrototypeOf) {
  35849. Object.setPrototypeOf(series, seriesTypes[newType].prototype);
  35850. // Legacy (IE < 11)
  35851. }
  35852. else {
  35853. var ownEvents = Object.hasOwnProperty.call(series, 'hcEvents') &&
  35854. series.hcEvents;
  35855. for (n in initialSeriesProto) { // eslint-disable-line guard-for-in
  35856. series[n] = void 0;
  35857. }
  35858. // Reinsert all methods and properties from the new type
  35859. // prototype (#2270, #3719).
  35860. extend(series, seriesTypes[newType].prototype);
  35861. // The events are tied to the prototype chain, don't copy if
  35862. // they're not the series' own
  35863. if (ownEvents) {
  35864. series.hcEvents = ownEvents;
  35865. }
  35866. else {
  35867. delete series.hcEvents;
  35868. }
  35869. }
  35870. }
  35871. }
  35872. else {
  35873. error(17, true, chart, { missingModuleFor: newType });
  35874. }
  35875. // Re-register groups (#3094) and other preserved properties
  35876. preserve.forEach(function (prop) {
  35877. series[prop] = preserve[prop];
  35878. });
  35879. series.init(chart, options);
  35880. // Remove particular elements of the points. Check `series.options`
  35881. // because we need to consider the options being set on plotOptions as
  35882. // well.
  35883. if (keepPoints && this.points) {
  35884. seriesOptions = series.options;
  35885. // What kind of elements to destroy
  35886. if (seriesOptions.visible === false) {
  35887. kinds.graphic = 1;
  35888. kinds.dataLabel = 1;
  35889. }
  35890. else if (!series._hasPointLabels) {
  35891. var marker = seriesOptions.marker,
  35892. dataLabels = seriesOptions.dataLabels;
  35893. if (marker && (marker.enabled === false ||
  35894. 'symbol' in marker // #10870
  35895. )) {
  35896. kinds.graphic = 1;
  35897. }
  35898. if (dataLabels &&
  35899. dataLabels.enabled === false) {
  35900. kinds.dataLabel = 1;
  35901. }
  35902. }
  35903. this.points.forEach(function (point) {
  35904. if (point && point.series) {
  35905. point.resolveColor();
  35906. // Destroy elements in order to recreate based on updated
  35907. // series options.
  35908. if (Object.keys(kinds).length) {
  35909. point.destroyElements(kinds);
  35910. }
  35911. if (seriesOptions.showInLegend === false &&
  35912. point.legendItem) {
  35913. chart.legend.destroyItem(point);
  35914. }
  35915. }
  35916. }, this);
  35917. }
  35918. series.initialType = initialType;
  35919. chart.linkSeries(); // Links are lost in series.remove (#3028)
  35920. // #15383: Fire updatedData if the type has changed to keep linked
  35921. // series such as indicators updated
  35922. if (casting && series.linkedSeries.length) {
  35923. series.isDirtyData = true;
  35924. }
  35925. fireEvent(this, 'afterUpdate');
  35926. if (pick(redraw, true)) {
  35927. chart.redraw(keepPoints ? void 0 : false);
  35928. }
  35929. };
  35930. /**
  35931. * Used from within series.update
  35932. * @private
  35933. */
  35934. Series.prototype.setName = function (name) {
  35935. this.name = this.options.name = this.userOptions.name = name;
  35936. this.chart.isDirtyLegend = true;
  35937. };
  35938. /**
  35939. * Check if the option has changed.
  35940. * @private
  35941. */
  35942. Series.prototype.hasOptionChanged = function (optionName) {
  35943. var chart = this.chart,
  35944. option = this.options[optionName],
  35945. plotOptions = chart.options.plotOptions,
  35946. oldOption = this.userOptions[optionName];
  35947. if (oldOption) {
  35948. return option !== oldOption;
  35949. }
  35950. return option !==
  35951. pick(plotOptions && plotOptions[this.type] && plotOptions[this.type][optionName], plotOptions && plotOptions.series && plotOptions.series[optionName], option);
  35952. };
  35953. /**
  35954. * Runs on mouse over the series graphical items.
  35955. *
  35956. * @function Highcharts.Series#onMouseOver
  35957. * @fires Highcharts.Series#event:mouseOver
  35958. */
  35959. Series.prototype.onMouseOver = function () {
  35960. var series = this,
  35961. chart = series.chart,
  35962. hoverSeries = chart.hoverSeries,
  35963. pointer = chart.pointer;
  35964. pointer.setHoverChartIndex();
  35965. // set normal state to previous series
  35966. if (hoverSeries && hoverSeries !== series) {
  35967. hoverSeries.onMouseOut();
  35968. }
  35969. // trigger the event, but to save processing time,
  35970. // only if defined
  35971. if (series.options.events.mouseOver) {
  35972. fireEvent(series, 'mouseOver');
  35973. }
  35974. // hover this
  35975. series.setState('hover');
  35976. /**
  35977. * Contains the original hovered series.
  35978. *
  35979. * @name Highcharts.Chart#hoverSeries
  35980. * @type {Highcharts.Series|null}
  35981. */
  35982. chart.hoverSeries = series;
  35983. };
  35984. /**
  35985. * Runs on mouse out of the series graphical items.
  35986. *
  35987. * @function Highcharts.Series#onMouseOut
  35988. *
  35989. * @fires Highcharts.Series#event:mouseOut
  35990. */
  35991. Series.prototype.onMouseOut = function () {
  35992. // trigger the event only if listeners exist
  35993. var series = this,
  35994. options = series.options,
  35995. chart = series.chart,
  35996. tooltip = chart.tooltip,
  35997. hoverPoint = chart.hoverPoint;
  35998. // #182, set to null before the mouseOut event fires
  35999. chart.hoverSeries = null;
  36000. // trigger mouse out on the point, which must be in this series
  36001. if (hoverPoint) {
  36002. hoverPoint.onMouseOut();
  36003. }
  36004. // fire the mouse out event
  36005. if (series && options.events.mouseOut) {
  36006. fireEvent(series, 'mouseOut');
  36007. }
  36008. // hide the tooltip
  36009. if (tooltip &&
  36010. !series.stickyTracking &&
  36011. (!tooltip.shared || series.noSharedTooltip)) {
  36012. tooltip.hide();
  36013. }
  36014. // Reset all inactive states
  36015. chart.series.forEach(function (s) {
  36016. s.setState('', true);
  36017. });
  36018. };
  36019. /**
  36020. * Set the state of the series. Called internally on mouse interaction
  36021. * operations, but it can also be called directly to visually
  36022. * highlight a series.
  36023. *
  36024. * @function Highcharts.Series#setState
  36025. *
  36026. * @param {Highcharts.SeriesStateValue|""} [state]
  36027. * The new state, can be either `'hover'`, `'inactive'`, `'select'`,
  36028. * or `''` (an empty string), `'normal'` or `undefined` to set to
  36029. * normal state.
  36030. * @param {boolean} [inherit]
  36031. * Determines if state should be inherited by points too.
  36032. */
  36033. Series.prototype.setState = function (state, inherit) {
  36034. var series = this,
  36035. options = series.options,
  36036. graph = series.graph,
  36037. inactiveOtherPoints = options.inactiveOtherPoints,
  36038. stateOptions = options.states,
  36039. lineWidth = options.lineWidth,
  36040. opacity = options.opacity,
  36041. // By default a quick animation to hover/inactive,
  36042. // slower to un-hover
  36043. stateAnimation = pick((stateOptions[state || 'normal'] &&
  36044. stateOptions[state || 'normal'].animation),
  36045. series.chart.options.chart.animation),
  36046. attribs,
  36047. i = 0;
  36048. state = state || '';
  36049. if (series.state !== state) {
  36050. // Toggle class names
  36051. [
  36052. series.group,
  36053. series.markerGroup,
  36054. series.dataLabelsGroup
  36055. ].forEach(function (group) {
  36056. if (group) {
  36057. // Old state
  36058. if (series.state) {
  36059. group.removeClass('highcharts-series-' + series.state);
  36060. }
  36061. // New state
  36062. if (state) {
  36063. group.addClass('highcharts-series-' + state);
  36064. }
  36065. }
  36066. });
  36067. series.state = state;
  36068. if (!series.chart.styledMode) {
  36069. if (stateOptions[state] &&
  36070. stateOptions[state].enabled === false) {
  36071. return;
  36072. }
  36073. if (state) {
  36074. lineWidth = (stateOptions[state].lineWidth ||
  36075. lineWidth + (stateOptions[state].lineWidthPlus || 0)); // #4035
  36076. opacity = pick(stateOptions[state].opacity, opacity);
  36077. }
  36078. if (graph && !graph.dashstyle) {
  36079. attribs = {
  36080. 'stroke-width': lineWidth
  36081. };
  36082. // Animate the graph stroke-width.
  36083. graph.animate(attribs, stateAnimation);
  36084. while (series['zone-graph-' + i]) {
  36085. series['zone-graph-' + i].animate(attribs, stateAnimation);
  36086. i = i + 1;
  36087. }
  36088. }
  36089. // For some types (pie, networkgraph, sankey) opacity is
  36090. // resolved on a point level
  36091. if (!inactiveOtherPoints) {
  36092. [
  36093. series.group,
  36094. series.markerGroup,
  36095. series.dataLabelsGroup,
  36096. series.labelBySeries
  36097. ].forEach(function (group) {
  36098. if (group) {
  36099. group.animate({
  36100. opacity: opacity
  36101. }, stateAnimation);
  36102. }
  36103. });
  36104. }
  36105. }
  36106. }
  36107. // Don't loop over points on a series that doesn't apply inactive state
  36108. // to siblings markers (e.g. line, column)
  36109. if (inherit && inactiveOtherPoints && series.points) {
  36110. series.setAllPointsToState(state || void 0);
  36111. }
  36112. };
  36113. /**
  36114. * Set the state for all points in the series.
  36115. *
  36116. * @function Highcharts.Series#setAllPointsToState
  36117. *
  36118. * @private
  36119. *
  36120. * @param {string} [state]
  36121. * Can be either `hover` or undefined to set to normal state.
  36122. */
  36123. Series.prototype.setAllPointsToState = function (state) {
  36124. this.points.forEach(function (point) {
  36125. if (point.setState) {
  36126. point.setState(state);
  36127. }
  36128. });
  36129. };
  36130. /**
  36131. * Show or hide the series.
  36132. *
  36133. * @function Highcharts.Series#setVisible
  36134. *
  36135. * @param {boolean} [visible]
  36136. * True to show the series, false to hide. If undefined, the visibility is
  36137. * toggled.
  36138. *
  36139. * @param {boolean} [redraw=true]
  36140. * Whether to redraw the chart after the series is altered. If doing more
  36141. * operations on the chart, it is a good idea to set redraw to false and
  36142. * call {@link Chart#redraw|chart.redraw()} after.
  36143. *
  36144. * @fires Highcharts.Series#event:hide
  36145. * @fires Highcharts.Series#event:show
  36146. */
  36147. Series.prototype.setVisible = function (vis, redraw) {
  36148. var series = this,
  36149. chart = series.chart,
  36150. legendItem = series.legendItem,
  36151. showOrHide,
  36152. ignoreHiddenSeries = chart.options.chart.ignoreHiddenSeries,
  36153. oldVisibility = series.visible;
  36154. // if called without an argument, toggle visibility
  36155. series.visible =
  36156. vis =
  36157. series.options.visible =
  36158. series.userOptions.visible =
  36159. typeof vis === 'undefined' ? !oldVisibility : vis; // #5618
  36160. showOrHide = vis ? 'show' : 'hide';
  36161. // show or hide elements
  36162. [
  36163. 'group',
  36164. 'dataLabelsGroup',
  36165. 'markerGroup',
  36166. 'tracker',
  36167. 'tt'
  36168. ].forEach(function (key) {
  36169. if (series[key]) {
  36170. series[key][showOrHide]();
  36171. }
  36172. });
  36173. // hide tooltip (#1361)
  36174. if (chart.hoverSeries === series ||
  36175. (chart.hoverPoint && chart.hoverPoint.series) === series) {
  36176. series.onMouseOut();
  36177. }
  36178. if (legendItem) {
  36179. chart.legend.colorizeItem(series, vis);
  36180. }
  36181. // rescale or adapt to resized chart
  36182. series.isDirty = true;
  36183. // in a stack, all other series are affected
  36184. if (series.options.stacking) {
  36185. chart.series.forEach(function (otherSeries) {
  36186. if (otherSeries.options.stacking && otherSeries.visible) {
  36187. otherSeries.isDirty = true;
  36188. }
  36189. });
  36190. }
  36191. // show or hide linked series
  36192. series.linkedSeries.forEach(function (otherSeries) {
  36193. otherSeries.setVisible(vis, false);
  36194. });
  36195. if (ignoreHiddenSeries) {
  36196. chart.isDirtyBox = true;
  36197. }
  36198. fireEvent(series, showOrHide);
  36199. if (redraw !== false) {
  36200. chart.redraw();
  36201. }
  36202. };
  36203. /**
  36204. * Show the series if hidden.
  36205. *
  36206. * @sample highcharts/members/series-hide/
  36207. * Toggle visibility from a button
  36208. *
  36209. * @function Highcharts.Series#show
  36210. * @fires Highcharts.Series#event:show
  36211. */
  36212. Series.prototype.show = function () {
  36213. this.setVisible(true);
  36214. };
  36215. /**
  36216. * Hide the series if visible. If the
  36217. * [chart.ignoreHiddenSeries](https://api.highcharts.com/highcharts/chart.ignoreHiddenSeries)
  36218. * option is true, the chart is redrawn without this series.
  36219. *
  36220. * @sample highcharts/members/series-hide/
  36221. * Toggle visibility from a button
  36222. *
  36223. * @function Highcharts.Series#hide
  36224. * @fires Highcharts.Series#event:hide
  36225. */
  36226. Series.prototype.hide = function () {
  36227. this.setVisible(false);
  36228. };
  36229. /**
  36230. * Select or unselect the series. This means its
  36231. * {@link Highcharts.Series.selected|selected}
  36232. * property is set, the checkbox in the legend is toggled and when selected,
  36233. * the series is returned by the {@link Highcharts.Chart#getSelectedSeries}
  36234. * function.
  36235. *
  36236. * @sample highcharts/members/series-select/
  36237. * Select a series from a button
  36238. *
  36239. * @function Highcharts.Series#select
  36240. *
  36241. * @param {boolean} [selected]
  36242. * True to select the series, false to unselect. If undefined, the selection
  36243. * state is toggled.
  36244. *
  36245. * @fires Highcharts.Series#event:select
  36246. * @fires Highcharts.Series#event:unselect
  36247. */
  36248. Series.prototype.select = function (selected) {
  36249. var series = this;
  36250. series.selected =
  36251. selected =
  36252. this.options.selected = (typeof selected === 'undefined' ?
  36253. !series.selected :
  36254. selected);
  36255. if (series.checkbox) {
  36256. series.checkbox.checked = selected;
  36257. }
  36258. fireEvent(series, selected ? 'select' : 'unselect');
  36259. };
  36260. /**
  36261. * Checks if a tooltip should be shown for a given point.
  36262. *
  36263. * @private
  36264. * @param {number} plotX
  36265. * @param {number} plotY
  36266. * @param {Highcharts.ChartIsInsideOptionsObject} [options]
  36267. * @return {boolean}
  36268. */
  36269. Series.prototype.shouldShowTooltip = function (plotX, plotY, options) {
  36270. if (options === void 0) { options = {}; }
  36271. options.series = this;
  36272. options.visiblePlotOnly = true;
  36273. return this.chart.isInsidePlot(plotX, plotY, options);
  36274. };
  36275. /**
  36276. * General options for all series types.
  36277. *
  36278. * @optionparent plotOptions.series
  36279. */
  36280. Series.defaultOptions = {
  36281. // base series options
  36282. /**
  36283. * The SVG value used for the `stroke-linecap` and `stroke-linejoin`
  36284. * of a line graph. Round means that lines are rounded in the ends and
  36285. * bends.
  36286. *
  36287. * @type {Highcharts.SeriesLinecapValue}
  36288. * @default round
  36289. * @since 3.0.7
  36290. * @apioption plotOptions.line.linecap
  36291. */
  36292. /**
  36293. * Pixel width of the graph line.
  36294. *
  36295. * @see In styled mode, the line stroke-width can be set with the
  36296. * `.highcharts-graph` class name.
  36297. *
  36298. * @sample {highcharts} highcharts/plotoptions/series-linewidth-general/
  36299. * On all series
  36300. * @sample {highcharts} highcharts/plotoptions/series-linewidth-specific/
  36301. * On one single series
  36302. *
  36303. * @product highcharts highstock
  36304. *
  36305. * @private
  36306. */
  36307. lineWidth: 2,
  36308. /**
  36309. * For some series, there is a limit that shuts down initial animation
  36310. * by default when the total number of points in the chart is too high.
  36311. * For example, for a column chart and its derivatives, animation does
  36312. * not run if there is more than 250 points totally. To disable this
  36313. * cap, set `animationLimit` to `Infinity`.
  36314. *
  36315. * @type {number}
  36316. * @apioption plotOptions.series.animationLimit
  36317. */
  36318. /**
  36319. * Allow this series' points to be selected by clicking on the graphic
  36320. * (columns, point markers, pie slices, map areas etc).
  36321. *
  36322. * The selected points can be handled by point select and unselect
  36323. * events, or collectively by the [getSelectedPoints
  36324. * ](/class-reference/Highcharts.Chart#getSelectedPoints) function.
  36325. *
  36326. * And alternative way of selecting points is through dragging.
  36327. *
  36328. * @sample {highcharts} highcharts/plotoptions/series-allowpointselect-line/
  36329. * Line
  36330. * @sample {highcharts} highcharts/plotoptions/series-allowpointselect-column/
  36331. * Column
  36332. * @sample {highcharts} highcharts/plotoptions/series-allowpointselect-pie/
  36333. * Pie
  36334. * @sample {highcharts} highcharts/chart/events-selection-points/
  36335. * Select a range of points through a drag selection
  36336. * @sample {highmaps} maps/plotoptions/series-allowpointselect/
  36337. * Map area
  36338. * @sample {highmaps} maps/plotoptions/mapbubble-allowpointselect/
  36339. * Map bubble
  36340. *
  36341. * @since 1.2.0
  36342. *
  36343. * @private
  36344. */
  36345. allowPointSelect: false,
  36346. /**
  36347. * When true, each point or column edge is rounded to its nearest pixel
  36348. * in order to render sharp on screen. In some cases, when there are a
  36349. * lot of densely packed columns, this leads to visible difference
  36350. * in column widths or distance between columns. In these cases,
  36351. * setting `crisp` to `false` may look better, even though each column
  36352. * is rendered blurry.
  36353. *
  36354. * @sample {highcharts} highcharts/plotoptions/column-crisp-false/
  36355. * Crisp is false
  36356. *
  36357. * @since 5.0.10
  36358. * @product highcharts highstock gantt
  36359. *
  36360. * @private
  36361. */
  36362. crisp: true,
  36363. /**
  36364. * If true, a checkbox is displayed next to the legend item to allow
  36365. * selecting the series. The state of the checkbox is determined by
  36366. * the `selected` option.
  36367. *
  36368. * @productdesc {highmaps}
  36369. * Note that if a `colorAxis` is defined, the color axis is represented
  36370. * in the legend, not the series.
  36371. *
  36372. * @sample {highcharts} highcharts/plotoptions/series-showcheckbox-true/
  36373. * Show select box
  36374. *
  36375. * @since 1.2.0
  36376. *
  36377. * @private
  36378. */
  36379. showCheckbox: false,
  36380. /**
  36381. * Enable or disable the initial animation when a series is displayed.
  36382. * The animation can also be set as a configuration object. Please
  36383. * note that this option only applies to the initial animation of the
  36384. * series itself. For other animations, see [chart.animation](
  36385. * #chart.animation) and the animation parameter under the API methods.
  36386. * The following properties are supported:
  36387. *
  36388. * - `defer`: The animation delay time in milliseconds.
  36389. *
  36390. * - `duration`: The duration of the animation in milliseconds.
  36391. *
  36392. * - `easing`: Can be a string reference to an easing function set on
  36393. * the `Math` object or a function. See the _Custom easing function_
  36394. * demo below.
  36395. *
  36396. * Due to poor performance, animation is disabled in old IE browsers
  36397. * for several chart types.
  36398. *
  36399. * @sample {highcharts} highcharts/plotoptions/series-animation-disabled/
  36400. * Animation disabled
  36401. * @sample {highcharts} highcharts/plotoptions/series-animation-slower/
  36402. * Slower animation
  36403. * @sample {highcharts} highcharts/plotoptions/series-animation-easing/
  36404. * Custom easing function
  36405. * @sample {highstock} stock/plotoptions/animation-slower/
  36406. * Slower animation
  36407. * @sample {highstock} stock/plotoptions/animation-easing/
  36408. * Custom easing function
  36409. * @sample {highmaps} maps/plotoptions/series-animation-true/
  36410. * Animation enabled on map series
  36411. * @sample {highmaps} maps/plotoptions/mapbubble-animation-false/
  36412. * Disabled on mapbubble series
  36413. *
  36414. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  36415. * @default {highcharts} true
  36416. * @default {highstock} true
  36417. * @default {highmaps} false
  36418. *
  36419. * @private
  36420. */
  36421. animation: {
  36422. /** @internal */
  36423. duration: 1000
  36424. },
  36425. /**
  36426. * @default 0
  36427. * @type {number}
  36428. * @since 8.2.0
  36429. * @apioption plotOptions.series.animation.defer
  36430. */
  36431. /**
  36432. * An additional class name to apply to the series' graphical elements.
  36433. * This option does not replace default class names of the graphical
  36434. * element.
  36435. *
  36436. * @type {string}
  36437. * @since 5.0.0
  36438. * @apioption plotOptions.series.className
  36439. */
  36440. /**
  36441. * Disable this option to allow series rendering in the whole plotting
  36442. * area.
  36443. *
  36444. * **Note:** Clipping should be always enabled when
  36445. * [chart.zoomType](#chart.zoomType) is set
  36446. *
  36447. * @sample {highcharts} highcharts/plotoptions/series-clip/
  36448. * Disabled clipping
  36449. *
  36450. * @default true
  36451. * @type {boolean}
  36452. * @since 3.0.0
  36453. * @apioption plotOptions.series.clip
  36454. */
  36455. /**
  36456. * The main color of the series. In line type series it applies to the
  36457. * line and the point markers unless otherwise specified. In bar type
  36458. * series it applies to the bars unless a color is specified per point.
  36459. * The default value is pulled from the `options.colors` array.
  36460. *
  36461. * In styled mode, the color can be defined by the
  36462. * [colorIndex](#plotOptions.series.colorIndex) option. Also, the series
  36463. * color can be set with the `.highcharts-series`,
  36464. * `.highcharts-color-{n}`, `.highcharts-{type}-series` or
  36465. * `.highcharts-series-{n}` class, or individual classes given by the
  36466. * `className` option.
  36467. *
  36468. * @productdesc {highmaps}
  36469. * In maps, the series color is rarely used, as most choropleth maps use
  36470. * the color to denote the value of each point. The series color can
  36471. * however be used in a map with multiple series holding categorized
  36472. * data.
  36473. *
  36474. * @sample {highcharts} highcharts/plotoptions/series-color-general/
  36475. * General plot option
  36476. * @sample {highcharts} highcharts/plotoptions/series-color-specific/
  36477. * One specific series
  36478. * @sample {highcharts} highcharts/plotoptions/series-color-area/
  36479. * Area color
  36480. * @sample {highcharts} highcharts/series/infographic/
  36481. * Pattern fill
  36482. * @sample {highmaps} maps/demo/category-map/
  36483. * Category map by multiple series
  36484. *
  36485. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  36486. * @apioption plotOptions.series.color
  36487. */
  36488. /**
  36489. * Styled mode only. A specific color index to use for the series, so
  36490. * its graphic representations are given the class name
  36491. * `highcharts-color-{n}`.
  36492. *
  36493. * @type {number}
  36494. * @since 5.0.0
  36495. * @apioption plotOptions.series.colorIndex
  36496. */
  36497. /**
  36498. * Whether to connect a graph line across null points, or render a gap
  36499. * between the two points on either side of the null.
  36500. *
  36501. * @sample {highcharts} highcharts/plotoptions/series-connectnulls-false/
  36502. * False by default
  36503. * @sample {highcharts} highcharts/plotoptions/series-connectnulls-true/
  36504. * True
  36505. *
  36506. * @type {boolean}
  36507. * @default false
  36508. * @product highcharts highstock
  36509. * @apioption plotOptions.series.connectNulls
  36510. */
  36511. /**
  36512. * You can set the cursor to "pointer" if you have click events attached
  36513. * to the series, to signal to the user that the points and lines can
  36514. * be clicked.
  36515. *
  36516. * In styled mode, the series cursor can be set with the same classes
  36517. * as listed under [series.color](#plotOptions.series.color).
  36518. *
  36519. * @sample {highcharts} highcharts/plotoptions/series-cursor-line/
  36520. * On line graph
  36521. * @sample {highcharts} highcharts/plotoptions/series-cursor-column/
  36522. * On columns
  36523. * @sample {highcharts} highcharts/plotoptions/series-cursor-scatter/
  36524. * On scatter markers
  36525. * @sample {highstock} stock/plotoptions/cursor/
  36526. * Pointer on a line graph
  36527. * @sample {highmaps} maps/plotoptions/series-allowpointselect/
  36528. * Map area
  36529. * @sample {highmaps} maps/plotoptions/mapbubble-allowpointselect/
  36530. * Map bubble
  36531. *
  36532. * @type {string|Highcharts.CursorValue}
  36533. * @apioption plotOptions.series.cursor
  36534. */
  36535. /**
  36536. * A reserved subspace to store options and values for customized
  36537. * functionality. Here you can add additional data for your own event
  36538. * callbacks and formatter callbacks.
  36539. *
  36540. * @sample {highcharts} highcharts/point/custom/
  36541. * Point and series with custom data
  36542. *
  36543. * @type {Highcharts.Dictionary<*>}
  36544. * @apioption plotOptions.series.custom
  36545. */
  36546. /**
  36547. * Name of the dash style to use for the graph, or for some series types
  36548. * the outline of each shape.
  36549. *
  36550. * In styled mode, the
  36551. * [stroke dash-array](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/css/series-dashstyle/)
  36552. * can be set with the same classes as listed under
  36553. * [series.color](#plotOptions.series.color).
  36554. *
  36555. * @sample {highcharts} highcharts/plotoptions/series-dashstyle-all/
  36556. * Possible values demonstrated
  36557. * @sample {highcharts} highcharts/plotoptions/series-dashstyle/
  36558. * Chart suitable for printing in black and white
  36559. * @sample {highstock} highcharts/plotoptions/series-dashstyle-all/
  36560. * Possible values demonstrated
  36561. * @sample {highmaps} highcharts/plotoptions/series-dashstyle-all/
  36562. * Possible values demonstrated
  36563. * @sample {highmaps} maps/plotoptions/series-dashstyle/
  36564. * Dotted borders on a map
  36565. *
  36566. * @type {Highcharts.DashStyleValue}
  36567. * @default Solid
  36568. * @since 2.1
  36569. * @apioption plotOptions.series.dashStyle
  36570. */
  36571. /**
  36572. * A description of the series to add to the screen reader information
  36573. * about the series.
  36574. *
  36575. * @type {string}
  36576. * @since 5.0.0
  36577. * @requires modules/accessibility
  36578. * @apioption plotOptions.series.description
  36579. */
  36580. /**
  36581. * Options for the series data sorting.
  36582. *
  36583. * @type {Highcharts.DataSortingOptionsObject}
  36584. * @since 8.0.0
  36585. * @product highcharts highstock
  36586. * @apioption plotOptions.series.dataSorting
  36587. */
  36588. /**
  36589. * Enable or disable data sorting for the series. Use [xAxis.reversed](
  36590. * #xAxis.reversed) to change the sorting order.
  36591. *
  36592. * @sample {highcharts} highcharts/datasorting/animation/
  36593. * Data sorting in scatter-3d
  36594. * @sample {highcharts} highcharts/datasorting/labels-animation/
  36595. * Axis labels animation
  36596. * @sample {highcharts} highcharts/datasorting/dependent-sorting/
  36597. * Dependent series sorting
  36598. * @sample {highcharts} highcharts/datasorting/independent-sorting/
  36599. * Independent series sorting
  36600. *
  36601. * @type {boolean}
  36602. * @since 8.0.0
  36603. * @apioption plotOptions.series.dataSorting.enabled
  36604. */
  36605. /**
  36606. * Whether to allow matching points by name in an update. If this option
  36607. * is disabled, points will be matched by order.
  36608. *
  36609. * @sample {highcharts} highcharts/datasorting/match-by-name/
  36610. * Enabled match by name
  36611. *
  36612. * @type {boolean}
  36613. * @since 8.0.0
  36614. * @apioption plotOptions.series.dataSorting.matchByName
  36615. */
  36616. /**
  36617. * Determines what data value should be used to sort by.
  36618. *
  36619. * @sample {highcharts} highcharts/datasorting/sort-key/
  36620. * Sort key as `z` value
  36621. *
  36622. * @type {string}
  36623. * @since 8.0.0
  36624. * @default y
  36625. * @apioption plotOptions.series.dataSorting.sortKey
  36626. */
  36627. /**
  36628. * Enable or disable the mouse tracking for a specific series. This
  36629. * includes point tooltips and click events on graphs and points. For
  36630. * large datasets it improves performance.
  36631. *
  36632. * @sample {highcharts} highcharts/plotoptions/series-enablemousetracking-false/
  36633. * No mouse tracking
  36634. * @sample {highmaps} maps/plotoptions/series-enablemousetracking-false/
  36635. * No mouse tracking
  36636. *
  36637. * @type {boolean}
  36638. * @default true
  36639. * @apioption plotOptions.series.enableMouseTracking
  36640. */
  36641. /**
  36642. * Whether to use the Y extremes of the total chart width or only the
  36643. * zoomed area when zooming in on parts of the X axis. By default, the
  36644. * Y axis adjusts to the min and max of the visible data. Cartesian
  36645. * series only.
  36646. *
  36647. * @type {boolean}
  36648. * @default false
  36649. * @since 4.1.6
  36650. * @product highcharts highstock gantt
  36651. * @apioption plotOptions.series.getExtremesFromAll
  36652. */
  36653. /**
  36654. * An array specifying which option maps to which key in the data point
  36655. * array. This makes it convenient to work with unstructured data arrays
  36656. * from different sources.
  36657. *
  36658. * @see [series.data](#series.line.data)
  36659. *
  36660. * @sample {highcharts|highstock} highcharts/series/data-keys/
  36661. * An extended data array with keys
  36662. * @sample {highcharts|highstock} highcharts/series/data-nested-keys/
  36663. * Nested keys used to access object properties
  36664. *
  36665. * @type {Array<string>}
  36666. * @since 4.1.6
  36667. * @apioption plotOptions.series.keys
  36668. */
  36669. /**
  36670. * The line cap used for line ends and line joins on the graph.
  36671. *
  36672. * @type {Highcharts.SeriesLinecapValue}
  36673. * @default round
  36674. * @product highcharts highstock
  36675. * @apioption plotOptions.series.linecap
  36676. */
  36677. /**
  36678. * The [id](#series.id) of another series to link to. Additionally,
  36679. * the value can be ":previous" to link to the previous series. When
  36680. * two series are linked, only the first one appears in the legend.
  36681. * Toggling the visibility of this also toggles the linked series.
  36682. *
  36683. * If master series uses data sorting and linked series does not have
  36684. * its own sorting definition, the linked series will be sorted in the
  36685. * same order as the master one.
  36686. *
  36687. * @sample {highcharts|highstock} highcharts/demo/arearange-line/
  36688. * Linked series
  36689. *
  36690. * @type {string}
  36691. * @since 3.0
  36692. * @product highcharts highstock gantt
  36693. * @apioption plotOptions.series.linkedTo
  36694. */
  36695. /**
  36696. * Options for the corresponding navigator series if `showInNavigator`
  36697. * is `true` for this series. Available options are the same as any
  36698. * series, documented at [plotOptions](#plotOptions.series) and
  36699. * [series](#series).
  36700. *
  36701. * These options are merged with options in [navigator.series](
  36702. * #navigator.series), and will take precedence if the same option is
  36703. * defined both places.
  36704. *
  36705. * @see [navigator.series](#navigator.series)
  36706. *
  36707. * @type {Highcharts.PlotSeriesOptions}
  36708. * @since 5.0.0
  36709. * @product highstock
  36710. * @apioption plotOptions.series.navigatorOptions
  36711. */
  36712. /**
  36713. * The color for the parts of the graph or points that are below the
  36714. * [threshold](#plotOptions.series.threshold). Note that `zones` takes
  36715. * precedence over the negative color. Using `negativeColor` is
  36716. * equivalent to applying a zone with value of 0.
  36717. *
  36718. * @see In styled mode, a negative color is applied by setting this option
  36719. * to `true` combined with the `.highcharts-negative` class name.
  36720. *
  36721. * @sample {highcharts} highcharts/plotoptions/series-negative-color/
  36722. * Spline, area and column
  36723. * @sample {highcharts} highcharts/plotoptions/arearange-negativecolor/
  36724. * Arearange
  36725. * @sample {highcharts} highcharts/css/series-negative-color/
  36726. * Styled mode
  36727. * @sample {highstock} highcharts/plotoptions/series-negative-color/
  36728. * Spline, area and column
  36729. * @sample {highstock} highcharts/plotoptions/arearange-negativecolor/
  36730. * Arearange
  36731. * @sample {highmaps} highcharts/plotoptions/series-negative-color/
  36732. * Spline, area and column
  36733. * @sample {highmaps} highcharts/plotoptions/arearange-negativecolor/
  36734. * Arearange
  36735. *
  36736. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  36737. * @since 3.0
  36738. * @apioption plotOptions.series.negativeColor
  36739. */
  36740. /**
  36741. * Same as
  36742. * [accessibility.series.descriptionFormatter](#accessibility.series.descriptionFormatter),
  36743. * but for an individual series. Overrides the chart wide configuration.
  36744. *
  36745. * @type {Function}
  36746. * @since 5.0.12
  36747. * @apioption plotOptions.series.pointDescriptionFormatter
  36748. */
  36749. /**
  36750. * If no x values are given for the points in a series, `pointInterval`
  36751. * defines the interval of the x values. For example, if a series
  36752. * contains one value every decade starting from year 0, set
  36753. * `pointInterval` to `10`. In true `datetime` axes, the `pointInterval`
  36754. * is set in milliseconds.
  36755. *
  36756. * It can be also be combined with `pointIntervalUnit` to draw irregular
  36757. * time intervals.
  36758. *
  36759. * Please note that this options applies to the _series data_, not the
  36760. * interval of the axis ticks, which is independent.
  36761. *
  36762. * @sample {highcharts} highcharts/plotoptions/series-pointstart-datetime/
  36763. * Datetime X axis
  36764. * @sample {highstock} stock/plotoptions/pointinterval-pointstart/
  36765. * Using pointStart and pointInterval
  36766. *
  36767. * @type {number}
  36768. * @default 1
  36769. * @product highcharts highstock gantt
  36770. * @apioption plotOptions.series.pointInterval
  36771. */
  36772. /**
  36773. * On datetime series, this allows for setting the
  36774. * [pointInterval](#plotOptions.series.pointInterval) to irregular time
  36775. * units, `day`, `month` and `year`. A day is usually the same as 24
  36776. * hours, but `pointIntervalUnit` also takes the DST crossover into
  36777. * consideration when dealing with local time. Combine this option with
  36778. * `pointInterval` to draw weeks, quarters, 6 months, 10 years etc.
  36779. *
  36780. * Please note that this options applies to the _series data_, not the
  36781. * interval of the axis ticks, which is independent.
  36782. *
  36783. * @sample {highcharts} highcharts/plotoptions/series-pointintervalunit/
  36784. * One point a month
  36785. * @sample {highstock} highcharts/plotoptions/series-pointintervalunit/
  36786. * One point a month
  36787. *
  36788. * @type {string}
  36789. * @since 4.1.0
  36790. * @product highcharts highstock gantt
  36791. * @validvalue ["day", "month", "year"]
  36792. * @apioption plotOptions.series.pointIntervalUnit
  36793. */
  36794. /**
  36795. * Possible values: `"on"`, `"between"`, `number`.
  36796. *
  36797. * In a column chart, when pointPlacement is `"on"`, the point will not
  36798. * create any padding of the X axis. In a polar column chart this means
  36799. * that the first column points directly north. If the pointPlacement is
  36800. * `"between"`, the columns will be laid out between ticks. This is
  36801. * useful for example for visualising an amount between two points in
  36802. * time or in a certain sector of a polar chart.
  36803. *
  36804. * Since Highcharts 3.0.2, the point placement can also be numeric,
  36805. * where 0 is on the axis value, -0.5 is between this value and the
  36806. * previous, and 0.5 is between this value and the next. Unlike the
  36807. * textual options, numeric point placement options won't affect axis
  36808. * padding.
  36809. *
  36810. * Note that pointPlacement needs a [pointRange](
  36811. * #plotOptions.series.pointRange) to work. For column series this is
  36812. * computed, but for line-type series it needs to be set.
  36813. *
  36814. * For the `xrange` series type and gantt charts, if the Y axis is a
  36815. * category axis, the `pointPlacement` applies to the Y axis rather than
  36816. * the (typically datetime) X axis.
  36817. *
  36818. * Defaults to `undefined` in cartesian charts, `"between"` in polar
  36819. * charts.
  36820. *
  36821. * @see [xAxis.tickmarkPlacement](#xAxis.tickmarkPlacement)
  36822. *
  36823. * @sample {highcharts|highstock} highcharts/plotoptions/series-pointplacement-between/
  36824. * Between in a column chart
  36825. * @sample {highcharts|highstock} highcharts/plotoptions/series-pointplacement-numeric/
  36826. * Numeric placement for custom layout
  36827. * @sample {highcharts|highstock} maps/plotoptions/heatmap-pointplacement/
  36828. * Placement in heatmap
  36829. *
  36830. * @type {string|number}
  36831. * @since 2.3.0
  36832. * @product highcharts highstock gantt
  36833. * @apioption plotOptions.series.pointPlacement
  36834. */
  36835. /**
  36836. * If no x values are given for the points in a series, pointStart
  36837. * defines on what value to start. For example, if a series contains one
  36838. * yearly value starting from 1945, set pointStart to 1945.
  36839. *
  36840. * @sample {highcharts} highcharts/plotoptions/series-pointstart-linear/
  36841. * Linear
  36842. * @sample {highcharts} highcharts/plotoptions/series-pointstart-datetime/
  36843. * Datetime
  36844. * @sample {highstock} stock/plotoptions/pointinterval-pointstart/
  36845. * Using pointStart and pointInterval
  36846. *
  36847. * @type {number}
  36848. * @default 0
  36849. * @product highcharts highstock gantt
  36850. * @apioption plotOptions.series.pointStart
  36851. */
  36852. /**
  36853. * Whether to select the series initially. If `showCheckbox` is true,
  36854. * the checkbox next to the series name in the legend will be checked
  36855. * for a selected series.
  36856. *
  36857. * @sample {highcharts} highcharts/plotoptions/series-selected/
  36858. * One out of two series selected
  36859. *
  36860. * @type {boolean}
  36861. * @default false
  36862. * @since 1.2.0
  36863. * @apioption plotOptions.series.selected
  36864. */
  36865. /**
  36866. * Whether to apply a drop shadow to the graph line. Since 2.3 the
  36867. * shadow can be an object configuration containing `color`, `offsetX`,
  36868. * `offsetY`, `opacity` and `width`.
  36869. *
  36870. * @sample {highcharts} highcharts/plotoptions/series-shadow/
  36871. * Shadow enabled
  36872. *
  36873. * @type {boolean|Highcharts.ShadowOptionsObject}
  36874. * @default false
  36875. * @apioption plotOptions.series.shadow
  36876. */
  36877. /**
  36878. * Whether to display this particular series or series type in the
  36879. * legend. Standalone series are shown in legend by default, and linked
  36880. * series are not. Since v7.2.0 it is possible to show series that use
  36881. * colorAxis by setting this option to `true`.
  36882. *
  36883. * @sample {highcharts} highcharts/plotoptions/series-showinlegend/
  36884. * One series in the legend, one hidden
  36885. *
  36886. * @type {boolean}
  36887. * @apioption plotOptions.series.showInLegend
  36888. */
  36889. /**
  36890. * Whether or not to show the series in the navigator. Takes precedence
  36891. * over [navigator.baseSeries](#navigator.baseSeries) if defined.
  36892. *
  36893. * @type {boolean}
  36894. * @since 5.0.0
  36895. * @product highstock
  36896. * @apioption plotOptions.series.showInNavigator
  36897. */
  36898. /**
  36899. * If set to `true`, the accessibility module will skip past the points
  36900. * in this series for keyboard navigation.
  36901. *
  36902. * @type {boolean}
  36903. * @since 5.0.12
  36904. * @apioption plotOptions.series.skipKeyboardNavigation
  36905. */
  36906. /**
  36907. * Whether to stack the values of each series on top of each other.
  36908. * Possible values are `undefined` to disable, `"normal"` to stack by
  36909. * value or `"percent"`.
  36910. *
  36911. * When stacking is enabled, data must be sorted
  36912. * in ascending X order.
  36913. *
  36914. * Some stacking options are related to specific series types. In the
  36915. * streamgraph series type, the stacking option is set to `"stream"`.
  36916. * The second one is `"overlap"`, which only applies to waterfall
  36917. * series.
  36918. *
  36919. * @see [yAxis.reversedStacks](#yAxis.reversedStacks)
  36920. *
  36921. * @sample {highcharts} highcharts/plotoptions/series-stacking-line/
  36922. * Line
  36923. * @sample {highcharts} highcharts/plotoptions/series-stacking-column/
  36924. * Column
  36925. * @sample {highcharts} highcharts/plotoptions/series-stacking-bar/
  36926. * Bar
  36927. * @sample {highcharts} highcharts/plotoptions/series-stacking-area/
  36928. * Area
  36929. * @sample {highcharts} highcharts/plotoptions/series-stacking-percent-line/
  36930. * Line
  36931. * @sample {highcharts} highcharts/plotoptions/series-stacking-percent-column/
  36932. * Column
  36933. * @sample {highcharts} highcharts/plotoptions/series-stacking-percent-bar/
  36934. * Bar
  36935. * @sample {highcharts} highcharts/plotoptions/series-stacking-percent-area/
  36936. * Area
  36937. * @sample {highcharts} highcharts/plotoptions/series-waterfall-with-normal-stacking
  36938. * Waterfall with normal stacking
  36939. * @sample {highcharts} highcharts/plotoptions/series-waterfall-with-overlap-stacking
  36940. * Waterfall with overlap stacking
  36941. * @sample {highstock} stock/plotoptions/stacking/
  36942. * Area
  36943. *
  36944. * @type {string}
  36945. * @product highcharts highstock
  36946. * @validvalue ["normal", "overlap", "percent", "stream"]
  36947. * @apioption plotOptions.series.stacking
  36948. */
  36949. /**
  36950. * Whether to apply steps to the line. Possible values are `left`,
  36951. * `center` and `right`.
  36952. *
  36953. * @sample {highcharts} highcharts/plotoptions/line-step/
  36954. * Different step line options
  36955. * @sample {highcharts} highcharts/plotoptions/area-step/
  36956. * Stepped, stacked area
  36957. * @sample {highstock} stock/plotoptions/line-step/
  36958. * Step line
  36959. *
  36960. * @type {string}
  36961. * @since 1.2.5
  36962. * @product highcharts highstock
  36963. * @validvalue ["left", "center", "right"]
  36964. * @apioption plotOptions.series.step
  36965. */
  36966. /**
  36967. * The threshold, also called zero level or base level. For line type
  36968. * series this is only used in conjunction with
  36969. * [negativeColor](#plotOptions.series.negativeColor).
  36970. *
  36971. * @see [softThreshold](#plotOptions.series.softThreshold).
  36972. *
  36973. * @type {number|null}
  36974. * @default 0
  36975. * @since 3.0
  36976. * @product highcharts highstock
  36977. * @apioption plotOptions.series.threshold
  36978. */
  36979. /**
  36980. * Set the initial visibility of the series.
  36981. *
  36982. * @sample {highcharts} highcharts/plotoptions/series-visible/
  36983. * Two series, one hidden and one visible
  36984. * @sample {highstock} stock/plotoptions/series-visibility/
  36985. * Hidden series
  36986. *
  36987. * @type {boolean}
  36988. * @default true
  36989. * @apioption plotOptions.series.visible
  36990. */
  36991. /**
  36992. * Defines the Axis on which the zones are applied.
  36993. *
  36994. * @see [zones](#plotOptions.series.zones)
  36995. *
  36996. * @sample {highcharts} highcharts/series/color-zones-zoneaxis-x/
  36997. * Zones on the X-Axis
  36998. * @sample {highstock} highcharts/series/color-zones-zoneaxis-x/
  36999. * Zones on the X-Axis
  37000. *
  37001. * @type {string}
  37002. * @default y
  37003. * @since 4.1.0
  37004. * @product highcharts highstock
  37005. * @apioption plotOptions.series.zoneAxis
  37006. */
  37007. /**
  37008. * General event handlers for the series items. These event hooks can
  37009. * also be attached to the series at run time using the
  37010. * `Highcharts.addEvent` function.
  37011. *
  37012. * @declare Highcharts.SeriesEventsOptionsObject
  37013. *
  37014. * @private
  37015. */
  37016. events: {},
  37017. /**
  37018. * Fires after the series has finished its initial animation, or in case
  37019. * animation is disabled, immediately as the series is displayed.
  37020. *
  37021. * @sample {highcharts} highcharts/plotoptions/series-events-afteranimate/
  37022. * Show label after animate
  37023. * @sample {highstock} highcharts/plotoptions/series-events-afteranimate/
  37024. * Show label after animate
  37025. *
  37026. * @type {Highcharts.SeriesAfterAnimateCallbackFunction}
  37027. * @since 4.0
  37028. * @product highcharts highstock gantt
  37029. * @context Highcharts.Series
  37030. * @apioption plotOptions.series.events.afterAnimate
  37031. */
  37032. /**
  37033. * Fires when the checkbox next to the series' name in the legend is
  37034. * clicked. One parameter, `event`, is passed to the function. The state
  37035. * of the checkbox is found by `event.checked`. The checked item is
  37036. * found by `event.item`. Return `false` to prevent the default action
  37037. * which is to toggle the select state of the series.
  37038. *
  37039. * @sample {highcharts} highcharts/plotoptions/series-events-checkboxclick/
  37040. * Alert checkbox status
  37041. *
  37042. * @type {Highcharts.SeriesCheckboxClickCallbackFunction}
  37043. * @since 1.2.0
  37044. * @context Highcharts.Series
  37045. * @apioption plotOptions.series.events.checkboxClick
  37046. */
  37047. /**
  37048. * Fires when the series is clicked. One parameter, `event`, is passed
  37049. * to the function, containing common event information. Additionally,
  37050. * `event.point` holds a pointer to the nearest point on the graph.
  37051. *
  37052. * @sample {highcharts} highcharts/plotoptions/series-events-click/
  37053. * Alert click info
  37054. * @sample {highstock} stock/plotoptions/series-events-click/
  37055. * Alert click info
  37056. * @sample {highmaps} maps/plotoptions/series-events-click/
  37057. * Display click info in subtitle
  37058. *
  37059. * @type {Highcharts.SeriesClickCallbackFunction}
  37060. * @context Highcharts.Series
  37061. * @apioption plotOptions.series.events.click
  37062. */
  37063. /**
  37064. * Fires when the series is hidden after chart generation time, either
  37065. * by clicking the legend item or by calling `.hide()`.
  37066. *
  37067. * @sample {highcharts} highcharts/plotoptions/series-events-hide/
  37068. * Alert when the series is hidden by clicking the legend item
  37069. *
  37070. * @type {Highcharts.SeriesHideCallbackFunction}
  37071. * @since 1.2.0
  37072. * @context Highcharts.Series
  37073. * @apioption plotOptions.series.events.hide
  37074. */
  37075. /**
  37076. * Fires when the legend item belonging to the series is clicked. One
  37077. * parameter, `event`, is passed to the function. The default action
  37078. * is to toggle the visibility of the series. This can be prevented
  37079. * by returning `false` or calling `event.preventDefault()`.
  37080. *
  37081. * @sample {highcharts} highcharts/plotoptions/series-events-legenditemclick/
  37082. * Confirm hiding and showing
  37083. *
  37084. * @type {Highcharts.SeriesLegendItemClickCallbackFunction}
  37085. * @context Highcharts.Series
  37086. * @apioption plotOptions.series.events.legendItemClick
  37087. */
  37088. /**
  37089. * Fires when the mouse leaves the graph. One parameter, `event`, is
  37090. * passed to the function, containing common event information. If the
  37091. * [stickyTracking](#plotOptions.series) option is true, `mouseOut`
  37092. * doesn't happen before the mouse enters another graph or leaves the
  37093. * plot area.
  37094. *
  37095. * @sample {highcharts} highcharts/plotoptions/series-events-mouseover-sticky/
  37096. * With sticky tracking by default
  37097. * @sample {highcharts} highcharts/plotoptions/series-events-mouseover-no-sticky/
  37098. * Without sticky tracking
  37099. *
  37100. * @type {Highcharts.SeriesMouseOutCallbackFunction}
  37101. * @context Highcharts.Series
  37102. * @apioption plotOptions.series.events.mouseOut
  37103. */
  37104. /**
  37105. * Fires when the mouse enters the graph. One parameter, `event`, is
  37106. * passed to the function, containing common event information.
  37107. *
  37108. * @sample {highcharts} highcharts/plotoptions/series-events-mouseover-sticky/
  37109. * With sticky tracking by default
  37110. * @sample {highcharts} highcharts/plotoptions/series-events-mouseover-no-sticky/
  37111. * Without sticky tracking
  37112. *
  37113. * @type {Highcharts.SeriesMouseOverCallbackFunction}
  37114. * @context Highcharts.Series
  37115. * @apioption plotOptions.series.events.mouseOver
  37116. */
  37117. /**
  37118. * Fires when the series is shown after chart generation time, either
  37119. * by clicking the legend item or by calling `.show()`.
  37120. *
  37121. * @sample {highcharts} highcharts/plotoptions/series-events-show/
  37122. * Alert when the series is shown by clicking the legend item.
  37123. *
  37124. * @type {Highcharts.SeriesShowCallbackFunction}
  37125. * @since 1.2.0
  37126. * @context Highcharts.Series
  37127. * @apioption plotOptions.series.events.show
  37128. */
  37129. /**
  37130. * Options for the point markers of line-like series. Properties like
  37131. * `fillColor`, `lineColor` and `lineWidth` define the visual appearance
  37132. * of the markers. Other series types, like column series, don't have
  37133. * markers, but have visual options on the series level instead.
  37134. *
  37135. * In styled mode, the markers can be styled with the
  37136. * `.highcharts-point`, `.highcharts-point-hover` and
  37137. * `.highcharts-point-select` class names.
  37138. *
  37139. * @declare Highcharts.PointMarkerOptionsObject
  37140. *
  37141. * @private
  37142. */
  37143. marker: {
  37144. /**
  37145. * Enable or disable the point marker. If `undefined`, the markers
  37146. * are hidden when the data is dense, and shown for more widespread
  37147. * data points.
  37148. *
  37149. * @sample {highcharts} highcharts/plotoptions/series-marker-enabled/
  37150. * Disabled markers
  37151. * @sample {highcharts} highcharts/plotoptions/series-marker-enabled-false/
  37152. * Disabled in normal state but enabled on hover
  37153. * @sample {highstock} stock/plotoptions/series-marker/
  37154. * Enabled markers
  37155. *
  37156. * @type {boolean}
  37157. * @default {highcharts} undefined
  37158. * @default {highstock} false
  37159. * @apioption plotOptions.series.marker.enabled
  37160. */
  37161. /**
  37162. * The threshold for how dense the point markers should be before
  37163. * they are hidden, given that `enabled` is not defined. The number
  37164. * indicates the horizontal distance between the two closest points
  37165. * in the series, as multiples of the `marker.radius`. In other
  37166. * words, the default value of 2 means points are hidden if
  37167. * overlapping horizontally.
  37168. *
  37169. * @sample highcharts/plotoptions/series-marker-enabledthreshold
  37170. * A higher threshold
  37171. *
  37172. * @since 6.0.5
  37173. */
  37174. enabledThreshold: 2,
  37175. /**
  37176. * The fill color of the point marker. When `undefined`, the series'
  37177. * or point's color is used.
  37178. *
  37179. * @sample {highcharts} highcharts/plotoptions/series-marker-fillcolor/
  37180. * White fill
  37181. *
  37182. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  37183. * @apioption plotOptions.series.marker.fillColor
  37184. */
  37185. /**
  37186. * Image markers only. Set the image width explicitly. When using
  37187. * this option, a `width` must also be set.
  37188. *
  37189. * @sample {highcharts} highcharts/plotoptions/series-marker-width-height/
  37190. * Fixed width and height
  37191. * @sample {highstock} highcharts/plotoptions/series-marker-width-height/
  37192. * Fixed width and height
  37193. *
  37194. * @type {number}
  37195. * @since 4.0.4
  37196. * @apioption plotOptions.series.marker.height
  37197. */
  37198. /**
  37199. * The color of the point marker's outline. When `undefined`, the
  37200. * series' or point's color is used.
  37201. *
  37202. * @sample {highcharts} highcharts/plotoptions/series-marker-fillcolor/
  37203. * Inherit from series color (undefined)
  37204. *
  37205. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  37206. */
  37207. lineColor: palette.backgroundColor,
  37208. /**
  37209. * The width of the point marker's outline.
  37210. *
  37211. * @sample {highcharts} highcharts/plotoptions/series-marker-fillcolor/
  37212. * 2px blue marker
  37213. */
  37214. lineWidth: 0,
  37215. /**
  37216. * The radius of the point marker.
  37217. *
  37218. * @sample {highcharts} highcharts/plotoptions/series-marker-radius/
  37219. * Bigger markers
  37220. *
  37221. * @default {highstock} 2
  37222. * @default {highcharts} 4
  37223. *
  37224. */
  37225. radius: 4,
  37226. /**
  37227. * A predefined shape or symbol for the marker. When undefined, the
  37228. * symbol is pulled from options.symbols. Other possible values are
  37229. * `'circle'`, `'square'`,`'diamond'`, `'triangle'` and
  37230. * `'triangle-down'`.
  37231. *
  37232. * Additionally, the URL to a graphic can be given on this form:
  37233. * `'url(graphic.png)'`. Note that for the image to be applied to
  37234. * exported charts, its URL needs to be accessible by the export
  37235. * server.
  37236. *
  37237. * Custom callbacks for symbol path generation can also be added to
  37238. * `Highcharts.SVGRenderer.prototype.symbols`. The callback is then
  37239. * used by its method name, as shown in the demo.
  37240. *
  37241. * @sample {highcharts} highcharts/plotoptions/series-marker-symbol/
  37242. * Predefined, graphic and custom markers
  37243. * @sample {highstock} highcharts/plotoptions/series-marker-symbol/
  37244. * Predefined, graphic and custom markers
  37245. *
  37246. * @type {string}
  37247. * @apioption plotOptions.series.marker.symbol
  37248. */
  37249. /**
  37250. * Image markers only. Set the image width explicitly. When using
  37251. * this option, a `height` must also be set.
  37252. *
  37253. * @sample {highcharts} highcharts/plotoptions/series-marker-width-height/
  37254. * Fixed width and height
  37255. * @sample {highstock} highcharts/plotoptions/series-marker-width-height/
  37256. * Fixed width and height
  37257. *
  37258. * @type {number}
  37259. * @since 4.0.4
  37260. * @apioption plotOptions.series.marker.width
  37261. */
  37262. /**
  37263. * States for a single point marker.
  37264. *
  37265. * @declare Highcharts.PointStatesOptionsObject
  37266. */
  37267. states: {
  37268. /**
  37269. * The normal state of a single point marker. Currently only
  37270. * used for setting animation when returning to normal state
  37271. * from hover.
  37272. *
  37273. * @declare Highcharts.PointStatesNormalOptionsObject
  37274. */
  37275. normal: {
  37276. /**
  37277. * Animation when returning to normal state after hovering.
  37278. *
  37279. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  37280. */
  37281. animation: true
  37282. },
  37283. /**
  37284. * The hover state for a single point marker.
  37285. *
  37286. * @declare Highcharts.PointStatesHoverOptionsObject
  37287. */
  37288. hover: {
  37289. /**
  37290. * Animation when hovering over the marker.
  37291. *
  37292. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  37293. */
  37294. animation: {
  37295. /** @internal */
  37296. duration: 50
  37297. },
  37298. /**
  37299. * Enable or disable the point marker.
  37300. *
  37301. * @sample {highcharts} highcharts/plotoptions/series-marker-states-hover-enabled/
  37302. * Disabled hover state
  37303. */
  37304. enabled: true,
  37305. /**
  37306. * The fill color of the marker in hover state. When
  37307. * `undefined`, the series' or point's fillColor for normal
  37308. * state is used.
  37309. *
  37310. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  37311. * @apioption plotOptions.series.marker.states.hover.fillColor
  37312. */
  37313. /**
  37314. * The color of the point marker's outline. When
  37315. * `undefined`, the series' or point's lineColor for normal
  37316. * state is used.
  37317. *
  37318. * @sample {highcharts} highcharts/plotoptions/series-marker-states-hover-linecolor/
  37319. * White fill color, black line color
  37320. *
  37321. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  37322. * @apioption plotOptions.series.marker.states.hover.lineColor
  37323. */
  37324. /**
  37325. * The width of the point marker's outline. When
  37326. * `undefined`, the series' or point's lineWidth for normal
  37327. * state is used.
  37328. *
  37329. * @sample {highcharts} highcharts/plotoptions/series-marker-states-hover-linewidth/
  37330. * 3px line width
  37331. *
  37332. * @type {number}
  37333. * @apioption plotOptions.series.marker.states.hover.lineWidth
  37334. */
  37335. /**
  37336. * The radius of the point marker. In hover state, it
  37337. * defaults to the normal state's radius + 2 as per the
  37338. * [radiusPlus](#plotOptions.series.marker.states.hover.radiusPlus)
  37339. * option.
  37340. *
  37341. * @sample {highcharts} highcharts/plotoptions/series-marker-states-hover-radius/
  37342. * 10px radius
  37343. *
  37344. * @type {number}
  37345. * @apioption plotOptions.series.marker.states.hover.radius
  37346. */
  37347. /**
  37348. * The number of pixels to increase the radius of the
  37349. * hovered point.
  37350. *
  37351. * @sample {highcharts} highcharts/plotoptions/series-states-hover-linewidthplus/
  37352. * 5 pixels greater radius on hover
  37353. * @sample {highstock} highcharts/plotoptions/series-states-hover-linewidthplus/
  37354. * 5 pixels greater radius on hover
  37355. *
  37356. * @since 4.0.3
  37357. */
  37358. radiusPlus: 2,
  37359. /**
  37360. * The additional line width for a hovered point.
  37361. *
  37362. * @sample {highcharts} highcharts/plotoptions/series-states-hover-linewidthplus/
  37363. * 2 pixels wider on hover
  37364. * @sample {highstock} highcharts/plotoptions/series-states-hover-linewidthplus/
  37365. * 2 pixels wider on hover
  37366. *
  37367. * @since 4.0.3
  37368. */
  37369. lineWidthPlus: 1
  37370. },
  37371. /**
  37372. * The appearance of the point marker when selected. In order to
  37373. * allow a point to be selected, set the
  37374. * `series.allowPointSelect` option to true.
  37375. *
  37376. * @declare Highcharts.PointStatesSelectOptionsObject
  37377. */
  37378. select: {
  37379. /**
  37380. * Enable or disable visible feedback for selection.
  37381. *
  37382. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-enabled/
  37383. * Disabled select state
  37384. *
  37385. * @type {boolean}
  37386. * @default true
  37387. * @apioption plotOptions.series.marker.states.select.enabled
  37388. */
  37389. /**
  37390. * The radius of the point marker. In hover state, it
  37391. * defaults to the normal state's radius + 2.
  37392. *
  37393. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-radius/
  37394. * 10px radius for selected points
  37395. *
  37396. * @type {number}
  37397. * @apioption plotOptions.series.marker.states.select.radius
  37398. */
  37399. /**
  37400. * The fill color of the point marker.
  37401. *
  37402. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-fillcolor/
  37403. * Solid red discs for selected points
  37404. *
  37405. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  37406. */
  37407. fillColor: palette.neutralColor20,
  37408. /**
  37409. * The color of the point marker's outline. When
  37410. * `undefined`, the series' or point's color is used.
  37411. *
  37412. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-linecolor/
  37413. * Red line color for selected points
  37414. *
  37415. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  37416. */
  37417. lineColor: palette.neutralColor100,
  37418. /**
  37419. * The width of the point marker's outline.
  37420. *
  37421. * @sample {highcharts} highcharts/plotoptions/series-marker-states-select-linewidth/
  37422. * 3px line width for selected points
  37423. */
  37424. lineWidth: 2
  37425. }
  37426. }
  37427. },
  37428. /**
  37429. * Properties for each single point.
  37430. *
  37431. * @declare Highcharts.PlotSeriesPointOptions
  37432. *
  37433. * @private
  37434. */
  37435. point: {
  37436. /**
  37437. * Fires when a point is clicked. One parameter, `event`, is passed
  37438. * to the function, containing common event information.
  37439. *
  37440. * If the `series.allowPointSelect` option is true, the default
  37441. * action for the point's click event is to toggle the point's
  37442. * select state. Returning `false` cancels this action.
  37443. *
  37444. * @sample {highcharts} highcharts/plotoptions/series-point-events-click/
  37445. * Click marker to alert values
  37446. * @sample {highcharts} highcharts/plotoptions/series-point-events-click-column/
  37447. * Click column
  37448. * @sample {highcharts} highcharts/plotoptions/series-point-events-click-url/
  37449. * Go to URL
  37450. * @sample {highmaps} maps/plotoptions/series-point-events-click/
  37451. * Click marker to display values
  37452. * @sample {highmaps} maps/plotoptions/series-point-events-click-url/
  37453. * Go to URL
  37454. *
  37455. * @type {Highcharts.PointClickCallbackFunction}
  37456. * @context Highcharts.Point
  37457. * @apioption plotOptions.series.point.events.click
  37458. */
  37459. /**
  37460. * Fires when the mouse leaves the area close to the point. One
  37461. * parameter, `event`, is passed to the function, containing common
  37462. * event information.
  37463. *
  37464. * @sample {highcharts} highcharts/plotoptions/series-point-events-mouseover/
  37465. * Show values in the chart's corner on mouse over
  37466. *
  37467. * @type {Highcharts.PointMouseOutCallbackFunction}
  37468. * @context Highcharts.Point
  37469. * @apioption plotOptions.series.point.events.mouseOut
  37470. */
  37471. /**
  37472. * Fires when the mouse enters the area close to the point. One
  37473. * parameter, `event`, is passed to the function, containing common
  37474. * event information.
  37475. *
  37476. * @sample {highcharts} highcharts/plotoptions/series-point-events-mouseover/
  37477. * Show values in the chart's corner on mouse over
  37478. *
  37479. * @type {Highcharts.PointMouseOverCallbackFunction}
  37480. * @context Highcharts.Point
  37481. * @apioption plotOptions.series.point.events.mouseOver
  37482. */
  37483. /**
  37484. * Fires when the point is removed using the `.remove()` method. One
  37485. * parameter, `event`, is passed to the function. Returning `false`
  37486. * cancels the operation.
  37487. *
  37488. * @sample {highcharts} highcharts/plotoptions/series-point-events-remove/
  37489. * Remove point and confirm
  37490. *
  37491. * @type {Highcharts.PointRemoveCallbackFunction}
  37492. * @since 1.2.0
  37493. * @context Highcharts.Point
  37494. * @apioption plotOptions.series.point.events.remove
  37495. */
  37496. /**
  37497. * Fires when the point is selected either programmatically or
  37498. * following a click on the point. One parameter, `event`, is passed
  37499. * to the function. Returning `false` cancels the operation.
  37500. *
  37501. * @sample {highcharts} highcharts/plotoptions/series-point-events-select/
  37502. * Report the last selected point
  37503. * @sample {highmaps} maps/plotoptions/series-allowpointselect/
  37504. * Report select and unselect
  37505. *
  37506. * @type {Highcharts.PointSelectCallbackFunction}
  37507. * @since 1.2.0
  37508. * @context Highcharts.Point
  37509. * @apioption plotOptions.series.point.events.select
  37510. */
  37511. /**
  37512. * Fires when the point is unselected either programmatically or
  37513. * following a click on the point. One parameter, `event`, is passed
  37514. * to the function.
  37515. * Returning `false` cancels the operation.
  37516. *
  37517. * @sample {highcharts} highcharts/plotoptions/series-point-events-unselect/
  37518. * Report the last unselected point
  37519. * @sample {highmaps} maps/plotoptions/series-allowpointselect/
  37520. * Report select and unselect
  37521. *
  37522. * @type {Highcharts.PointUnselectCallbackFunction}
  37523. * @since 1.2.0
  37524. * @context Highcharts.Point
  37525. * @apioption plotOptions.series.point.events.unselect
  37526. */
  37527. /**
  37528. * Fires when the point is updated programmatically through the
  37529. * `.update()` method. One parameter, `event`, is passed to the
  37530. * function. The new point options can be accessed through
  37531. * `event.options`. Returning `false` cancels the operation.
  37532. *
  37533. * @sample {highcharts} highcharts/plotoptions/series-point-events-update/
  37534. * Confirm point updating
  37535. *
  37536. * @type {Highcharts.PointUpdateCallbackFunction}
  37537. * @since 1.2.0
  37538. * @context Highcharts.Point
  37539. * @apioption plotOptions.series.point.events.update
  37540. */
  37541. /**
  37542. * Events for each single point.
  37543. *
  37544. * @declare Highcharts.PointEventsOptionsObject
  37545. */
  37546. events: {}
  37547. },
  37548. /**
  37549. * Options for the series data labels, appearing next to each data
  37550. * point.
  37551. *
  37552. * Since v6.2.0, multiple data labels can be applied to each single
  37553. * point by defining them as an array of configs.
  37554. *
  37555. * In styled mode, the data labels can be styled with the
  37556. * `.highcharts-data-label-box` and `.highcharts-data-label` class names
  37557. * ([see example](https://www.highcharts.com/samples/highcharts/css/series-datalabels)).
  37558. *
  37559. * @sample {highcharts} highcharts/plotoptions/series-datalabels-enabled
  37560. * Data labels enabled
  37561. * @sample {highcharts} highcharts/plotoptions/series-datalabels-multiple
  37562. * Multiple data labels on a bar series
  37563. * @sample {highcharts} highcharts/css/series-datalabels
  37564. * Style mode example
  37565. *
  37566. * @type {*|Array<*>}
  37567. * @product highcharts highstock highmaps gantt
  37568. *
  37569. * @private
  37570. */
  37571. dataLabels: {
  37572. /**
  37573. * Enable or disable the initial animation when a series is
  37574. * displayed for the `dataLabels`. The animation can also be set as
  37575. * a configuration object. Please note that this option only
  37576. * applies to the initial animation.
  37577. * For other animations, see [chart.animation](#chart.animation)
  37578. * and the animation parameter under the API methods.
  37579. * The following properties are supported:
  37580. *
  37581. * - `defer`: The animation delay time in milliseconds.
  37582. *
  37583. * @sample {highcharts} highcharts/plotoptions/animation-defer/
  37584. * Animation defer settings
  37585. *
  37586. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  37587. * @since 8.2.0
  37588. * @apioption plotOptions.series.dataLabels.animation
  37589. */
  37590. animation: {},
  37591. /**
  37592. * The animation delay time in milliseconds.
  37593. * Set to `0` renders dataLabel immediately.
  37594. * As `undefined` inherits defer time from the [series.animation.defer](#plotOptions.series.animation.defer).
  37595. *
  37596. * @type {number}
  37597. * @since 8.2.0
  37598. * @apioption plotOptions.series.dataLabels.animation.defer
  37599. */
  37600. /**
  37601. * The alignment of the data label compared to the point. If
  37602. * `right`, the right side of the label should be touching the
  37603. * point. For points with an extent, like columns, the alignments
  37604. * also dictates how to align it inside the box, as given with the
  37605. * [inside](#plotOptions.column.dataLabels.inside)
  37606. * option. Can be one of `left`, `center` or `right`.
  37607. *
  37608. * @sample {highcharts} highcharts/plotoptions/series-datalabels-align-left/
  37609. * Left aligned
  37610. * @sample {highcharts} highcharts/plotoptions/bar-datalabels-align-inside-bar/
  37611. * Data labels inside the bar
  37612. *
  37613. * @type {Highcharts.AlignValue|null}
  37614. */
  37615. align: 'center',
  37616. /**
  37617. * Whether to allow data labels to overlap. To make the labels less
  37618. * sensitive for overlapping, the
  37619. * [dataLabels.padding](#plotOptions.series.dataLabels.padding)
  37620. * can be set to 0.
  37621. *
  37622. * @sample {highcharts} highcharts/plotoptions/series-datalabels-allowoverlap-false/
  37623. * Don't allow overlap
  37624. *
  37625. * @type {boolean}
  37626. * @default false
  37627. * @since 4.1.0
  37628. * @apioption plotOptions.series.dataLabels.allowOverlap
  37629. */
  37630. /**
  37631. * The background color or gradient for the data label.
  37632. *
  37633. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  37634. * Data labels box options
  37635. * @sample {highmaps} maps/plotoptions/series-datalabels-box/
  37636. * Data labels box options
  37637. *
  37638. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  37639. * @since 2.2.1
  37640. * @apioption plotOptions.series.dataLabels.backgroundColor
  37641. */
  37642. /**
  37643. * The border color for the data label. Defaults to `undefined`.
  37644. *
  37645. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  37646. * Data labels box options
  37647. *
  37648. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  37649. * @since 2.2.1
  37650. * @apioption plotOptions.series.dataLabels.borderColor
  37651. */
  37652. /**
  37653. * The border radius in pixels for the data label.
  37654. *
  37655. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  37656. * Data labels box options
  37657. * @sample {highmaps} maps/plotoptions/series-datalabels-box/
  37658. * Data labels box options
  37659. *
  37660. * @type {number}
  37661. * @default 0
  37662. * @since 2.2.1
  37663. * @apioption plotOptions.series.dataLabels.borderRadius
  37664. */
  37665. /**
  37666. * The border width in pixels for the data label.
  37667. *
  37668. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  37669. * Data labels box options
  37670. *
  37671. * @type {number}
  37672. * @default 0
  37673. * @since 2.2.1
  37674. * @apioption plotOptions.series.dataLabels.borderWidth
  37675. */
  37676. /**
  37677. * A class name for the data label. Particularly in styled mode,
  37678. * this can be used to give each series' or point's data label
  37679. * unique styling. In addition to this option, a default color class
  37680. * name is added so that we can give the labels a contrast text
  37681. * shadow.
  37682. *
  37683. * @sample {highcharts} highcharts/css/data-label-contrast/
  37684. * Contrast text shadow
  37685. * @sample {highcharts} highcharts/css/series-datalabels/
  37686. * Styling by CSS
  37687. *
  37688. * @type {string}
  37689. * @since 5.0.0
  37690. * @apioption plotOptions.series.dataLabels.className
  37691. */
  37692. /**
  37693. * The text color for the data labels. Defaults to `undefined`. For
  37694. * certain series types, like column or map, the data labels can be
  37695. * drawn inside the points. In this case the data label will be
  37696. * drawn with maximum contrast by default. Additionally, it will be
  37697. * given a `text-outline` style with the opposite color, to further
  37698. * increase the contrast. This can be overridden by setting the
  37699. * `text-outline` style to `none` in the `dataLabels.style` option.
  37700. *
  37701. * @sample {highcharts} highcharts/plotoptions/series-datalabels-color/
  37702. * Red data labels
  37703. * @sample {highmaps} maps/demo/color-axis/
  37704. * White data labels
  37705. *
  37706. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  37707. * @apioption plotOptions.series.dataLabels.color
  37708. */
  37709. /**
  37710. * Whether to hide data labels that are outside the plot area. By
  37711. * default, the data label is moved inside the plot area according
  37712. * to the
  37713. * [overflow](#plotOptions.series.dataLabels.overflow)
  37714. * option.
  37715. *
  37716. * @type {boolean}
  37717. * @default true
  37718. * @since 2.3.3
  37719. * @apioption plotOptions.series.dataLabels.crop
  37720. */
  37721. /**
  37722. * Whether to defer displaying the data labels until the initial
  37723. * series animation has finished. Setting to `false` renders the
  37724. * data label immediately. If set to `true` inherits the defer
  37725. * time set in [plotOptions.series.animation](#plotOptions.series.animation).
  37726. * If set to a number, a defer time is specified in milliseconds.
  37727. *
  37728. * @sample highcharts/plotoptions/animation-defer
  37729. * Set defer time
  37730. *
  37731. * @since 4.0.0
  37732. * @type {boolean|number}
  37733. * @product highcharts highstock gantt
  37734. */
  37735. defer: true,
  37736. /**
  37737. * Enable or disable the data labels.
  37738. *
  37739. * @sample {highcharts} highcharts/plotoptions/series-datalabels-enabled/
  37740. * Data labels enabled
  37741. * @sample {highmaps} maps/demo/color-axis/
  37742. * Data labels enabled
  37743. *
  37744. * @type {boolean}
  37745. * @default false
  37746. * @apioption plotOptions.series.dataLabels.enabled
  37747. */
  37748. /**
  37749. * A declarative filter to control of which data labels to display.
  37750. * The declarative filter is designed for use when callback
  37751. * functions are not available, like when the chart options require
  37752. * a pure JSON structure or for use with graphical editors. For
  37753. * programmatic control, use the `formatter` instead, and return
  37754. * `undefined` to disable a single data label.
  37755. *
  37756. * @example
  37757. * filter: {
  37758. * property: 'percentage',
  37759. * operator: '>',
  37760. * value: 4
  37761. * }
  37762. *
  37763. * @sample {highcharts} highcharts/demo/pie-monochrome
  37764. * Data labels filtered by percentage
  37765. *
  37766. * @declare Highcharts.DataLabelsFilterOptionsObject
  37767. * @since 6.0.3
  37768. * @apioption plotOptions.series.dataLabels.filter
  37769. */
  37770. /**
  37771. * The operator to compare by. Can be one of `>`, `<`, `>=`, `<=`,
  37772. * `==`, and `===`.
  37773. *
  37774. * @type {string}
  37775. * @validvalue [">", "<", ">=", "<=", "==", "==="]
  37776. * @apioption plotOptions.series.dataLabels.filter.operator
  37777. */
  37778. /**
  37779. * The point property to filter by. Point options are passed
  37780. * directly to properties, additionally there are `y` value,
  37781. * `percentage` and others listed under {@link Highcharts.Point}
  37782. * members.
  37783. *
  37784. * @type {string}
  37785. * @apioption plotOptions.series.dataLabels.filter.property
  37786. */
  37787. /**
  37788. * The value to compare against.
  37789. *
  37790. * @type {number}
  37791. * @apioption plotOptions.series.dataLabels.filter.value
  37792. */
  37793. /**
  37794. * A
  37795. * [format string](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting)
  37796. * for the data label. Available variables are the same as for
  37797. * `formatter`.
  37798. *
  37799. * @sample {highcharts} highcharts/plotoptions/series-datalabels-format/
  37800. * Add a unit
  37801. * @sample {highmaps} maps/plotoptions/series-datalabels-format/
  37802. * Formatted value in the data label
  37803. *
  37804. * @type {string}
  37805. * @default y
  37806. * @default point.value
  37807. * @since 3.0
  37808. * @apioption plotOptions.series.dataLabels.format
  37809. */
  37810. // eslint-disable-next-line valid-jsdoc
  37811. /**
  37812. * Callback JavaScript function to format the data label. Note that
  37813. * if a `format` is defined, the format takes precedence and the
  37814. * formatter is ignored.
  37815. *
  37816. * @sample {highmaps} maps/plotoptions/series-datalabels-format/
  37817. * Formatted value
  37818. *
  37819. * @type {Highcharts.DataLabelsFormatterCallbackFunction}
  37820. */
  37821. formatter: function () {
  37822. var numberFormatter = this.series.chart.numberFormatter;
  37823. return typeof this.y !== 'number' ? '' : numberFormatter(this.y, -1);
  37824. },
  37825. /**
  37826. * For points with an extent, like columns or map areas, whether to
  37827. * align the data label inside the box or to the actual value point.
  37828. * Defaults to `false` in most cases, `true` in stacked columns.
  37829. *
  37830. * @type {boolean}
  37831. * @since 3.0
  37832. * @apioption plotOptions.series.dataLabels.inside
  37833. */
  37834. /**
  37835. * Format for points with the value of null. Works analogously to
  37836. * [format](#plotOptions.series.dataLabels.format). `nullFormat` can
  37837. * be applied only to series which support displaying null points.
  37838. *
  37839. * @sample {highcharts} highcharts/plotoptions/series-datalabels-format/
  37840. * Format data label and tooltip for null point.
  37841. *
  37842. * @type {boolean|string}
  37843. * @since 7.1.0
  37844. * @apioption plotOptions.series.dataLabels.nullFormat
  37845. */
  37846. /**
  37847. * Callback JavaScript function that defines formatting for points
  37848. * with the value of null. Works analogously to
  37849. * [formatter](#plotOptions.series.dataLabels.formatter).
  37850. * `nullPointFormatter` can be applied only to series which support
  37851. * displaying null points.
  37852. *
  37853. * @sample {highcharts} highcharts/plotoptions/series-datalabels-format/
  37854. * Format data label and tooltip for null point.
  37855. *
  37856. * @type {Highcharts.DataLabelsFormatterCallbackFunction}
  37857. * @since 7.1.0
  37858. * @apioption plotOptions.series.dataLabels.nullFormatter
  37859. */
  37860. /**
  37861. * How to handle data labels that flow outside the plot area. The
  37862. * default is `"justify"`, which aligns them inside the plot area.
  37863. * For columns and bars, this means it will be moved inside the bar.
  37864. * To display data labels outside the plot area, set `crop` to
  37865. * `false` and `overflow` to `"allow"`.
  37866. *
  37867. * @type {Highcharts.DataLabelsOverflowValue}
  37868. * @default justify
  37869. * @since 3.0.6
  37870. * @apioption plotOptions.series.dataLabels.overflow
  37871. */
  37872. /**
  37873. * When either the `borderWidth` or the `backgroundColor` is set,
  37874. * this is the padding within the box.
  37875. *
  37876. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  37877. * Data labels box options
  37878. * @sample {highmaps} maps/plotoptions/series-datalabels-box/
  37879. * Data labels box options
  37880. *
  37881. * @since 2.2.1
  37882. */
  37883. padding: 5,
  37884. /**
  37885. * Aligns data labels relative to points. If `center` alignment is
  37886. * not possible, it defaults to `right`.
  37887. *
  37888. * @type {Highcharts.AlignValue}
  37889. * @default center
  37890. * @apioption plotOptions.series.dataLabels.position
  37891. */
  37892. /**
  37893. * Text rotation in degrees. Note that due to a more complex
  37894. * structure, backgrounds, borders and padding will be lost on a
  37895. * rotated data label.
  37896. *
  37897. * @sample {highcharts} highcharts/plotoptions/series-datalabels-rotation/
  37898. * Vertical labels
  37899. *
  37900. * @type {number}
  37901. * @default 0
  37902. * @apioption plotOptions.series.dataLabels.rotation
  37903. */
  37904. /**
  37905. * The shadow of the box. Works best with `borderWidth` or
  37906. * `backgroundColor`. Since 2.3 the shadow can be an object
  37907. * configuration containing `color`, `offsetX`, `offsetY`, `opacity`
  37908. * and `width`.
  37909. *
  37910. * @sample {highcharts} highcharts/plotoptions/series-datalabels-box/
  37911. * Data labels box options
  37912. *
  37913. * @type {boolean|Highcharts.ShadowOptionsObject}
  37914. * @default false
  37915. * @since 2.2.1
  37916. * @apioption plotOptions.series.dataLabels.shadow
  37917. */
  37918. /**
  37919. * The name of a symbol to use for the border around the label.
  37920. * Symbols are predefined functions on the Renderer object.
  37921. *
  37922. * @sample {highcharts} highcharts/plotoptions/series-datalabels-shape/
  37923. * A callout for annotations
  37924. *
  37925. * @type {string}
  37926. * @default square
  37927. * @since 4.1.2
  37928. * @apioption plotOptions.series.dataLabels.shape
  37929. */
  37930. /**
  37931. * Styles for the label. The default `color` setting is
  37932. * `"contrast"`, which is a pseudo color that Highcharts picks up
  37933. * and applies the maximum contrast to the underlying point item,
  37934. * for example the bar in a bar chart.
  37935. *
  37936. * The `textOutline` is a pseudo property that applies an outline of
  37937. * the given width with the given color, which by default is the
  37938. * maximum contrast to the text. So a bright text color will result
  37939. * in a black text outline for maximum readability on a mixed
  37940. * background. In some cases, especially with grayscale text, the
  37941. * text outline doesn't work well, in which cases it can be disabled
  37942. * by setting it to `"none"`. When `useHTML` is true, the
  37943. * `textOutline` will not be picked up. In this, case, the same
  37944. * effect can be acheived through the `text-shadow` CSS property.
  37945. *
  37946. * For some series types, where each point has an extent, like for
  37947. * example tree maps, the data label may overflow the point. There
  37948. * are two strategies for handling overflow. By default, the text
  37949. * will wrap to multiple lines. The other strategy is to set
  37950. * `style.textOverflow` to `ellipsis`, which will keep the text on
  37951. * one line plus it will break inside long words.
  37952. *
  37953. * @sample {highcharts} highcharts/plotoptions/series-datalabels-style/
  37954. * Bold labels
  37955. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-overflow/
  37956. * Long labels truncated with an ellipsis in a pie
  37957. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-overflow-wrap/
  37958. * Long labels are wrapped in a pie
  37959. * @sample {highmaps} maps/demo/color-axis/
  37960. * Bold labels
  37961. *
  37962. * @type {Highcharts.CSSObject}
  37963. * @since 4.1.0
  37964. * @apioption plotOptions.series.dataLabels.style
  37965. */
  37966. style: {
  37967. /** @internal */
  37968. fontSize: '11px',
  37969. /** @internal */
  37970. fontWeight: 'bold',
  37971. /** @internal */
  37972. color: 'contrast',
  37973. /** @internal */
  37974. textOutline: '1px contrast'
  37975. },
  37976. /**
  37977. * Options for a label text which should follow marker's shape.
  37978. * Border and background are disabled for a label that follows a
  37979. * path.
  37980. *
  37981. * **Note:** Only SVG-based renderer supports this option. Setting
  37982. * `useHTML` to true will disable this option.
  37983. *
  37984. * @declare Highcharts.DataLabelsTextPathOptionsObject
  37985. * @since 7.1.0
  37986. * @apioption plotOptions.series.dataLabels.textPath
  37987. */
  37988. /**
  37989. * Presentation attributes for the text path.
  37990. *
  37991. * @type {Highcharts.SVGAttributes}
  37992. * @since 7.1.0
  37993. * @apioption plotOptions.series.dataLabels.textPath.attributes
  37994. */
  37995. /**
  37996. * Enable or disable `textPath` option for link's or marker's data
  37997. * labels.
  37998. *
  37999. * @type {boolean}
  38000. * @since 7.1.0
  38001. * @apioption plotOptions.series.dataLabels.textPath.enabled
  38002. */
  38003. /**
  38004. * Whether to
  38005. * [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  38006. * to render the labels.
  38007. *
  38008. * @type {boolean}
  38009. * @default false
  38010. * @apioption plotOptions.series.dataLabels.useHTML
  38011. */
  38012. /**
  38013. * The vertical alignment of a data label. Can be one of `top`,
  38014. * `middle` or `bottom`. The default value depends on the data, for
  38015. * instance in a column chart, the label is above positive values
  38016. * and below negative values.
  38017. *
  38018. * @type {Highcharts.VerticalAlignValue|null}
  38019. * @since 2.3.3
  38020. */
  38021. verticalAlign: 'bottom',
  38022. /**
  38023. * The x position offset of the label relative to the point in
  38024. * pixels.
  38025. *
  38026. * @sample {highcharts} highcharts/plotoptions/series-datalabels-rotation/
  38027. * Vertical and positioned
  38028. * @sample {highcharts} highcharts/plotoptions/bar-datalabels-align-inside-bar/
  38029. * Data labels inside the bar
  38030. */
  38031. x: 0,
  38032. /**
  38033. * The Z index of the data labels. The default Z index puts it above
  38034. * the series. Use a Z index of 2 to display it behind the series.
  38035. *
  38036. * @type {number}
  38037. * @default 6
  38038. * @since 2.3.5
  38039. * @apioption plotOptions.series.dataLabels.z
  38040. */
  38041. /**
  38042. * The y position offset of the label relative to the point in
  38043. * pixels.
  38044. *
  38045. * @sample {highcharts} highcharts/plotoptions/series-datalabels-rotation/
  38046. * Vertical and positioned
  38047. */
  38048. y: 0
  38049. },
  38050. /**
  38051. * When the series contains less points than the crop threshold, all
  38052. * points are drawn, even if the points fall outside the visible plot
  38053. * area at the current zoom. The advantage of drawing all points
  38054. * (including markers and columns), is that animation is performed on
  38055. * updates. On the other hand, when the series contains more points than
  38056. * the crop threshold, the series data is cropped to only contain points
  38057. * that fall within the plot area. The advantage of cropping away
  38058. * invisible points is to increase performance on large series.
  38059. *
  38060. * @since 2.2
  38061. * @product highcharts highstock
  38062. *
  38063. * @private
  38064. */
  38065. cropThreshold: 300,
  38066. /**
  38067. * Opacity of a series parts: line, fill (e.g. area) and dataLabels.
  38068. *
  38069. * @see [states.inactive.opacity](#plotOptions.series.states.inactive.opacity)
  38070. *
  38071. * @since 7.1.0
  38072. *
  38073. * @private
  38074. */
  38075. opacity: 1,
  38076. /**
  38077. * The width of each point on the x axis. For example in a column chart
  38078. * with one value each day, the pointRange would be 1 day (= 24 * 3600
  38079. * * 1000 milliseconds). This is normally computed automatically, but
  38080. * this option can be used to override the automatic value.
  38081. *
  38082. * @product highstock
  38083. *
  38084. * @private
  38085. */
  38086. pointRange: 0,
  38087. /**
  38088. * When this is true, the series will not cause the Y axis to cross
  38089. * the zero plane (or [threshold](#plotOptions.series.threshold) option)
  38090. * unless the data actually crosses the plane.
  38091. *
  38092. * For example, if `softThreshold` is `false`, a series of 0, 1, 2,
  38093. * 3 will make the Y axis show negative values according to the
  38094. * `minPadding` option. If `softThreshold` is `true`, the Y axis starts
  38095. * at 0.
  38096. *
  38097. * @since 4.1.9
  38098. * @product highcharts highstock
  38099. *
  38100. * @private
  38101. */
  38102. softThreshold: true,
  38103. /**
  38104. * @declare Highcharts.SeriesStatesOptionsObject
  38105. *
  38106. * @private
  38107. */
  38108. states: {
  38109. /**
  38110. * The normal state of a series, or for point items in column, pie
  38111. * and similar series. Currently only used for setting animation
  38112. * when returning to normal state from hover.
  38113. *
  38114. * @declare Highcharts.SeriesStatesNormalOptionsObject
  38115. */
  38116. normal: {
  38117. /**
  38118. * Animation when returning to normal state after hovering.
  38119. *
  38120. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  38121. */
  38122. animation: true
  38123. },
  38124. /**
  38125. * Options for the hovered series. These settings override the
  38126. * normal state options when a series is moused over or touched.
  38127. *
  38128. * @declare Highcharts.SeriesStatesHoverOptionsObject
  38129. */
  38130. hover: {
  38131. /**
  38132. * Enable separate styles for the hovered series to visualize
  38133. * that the user hovers either the series itself or the legend.
  38134. *
  38135. * @sample {highcharts} highcharts/plotoptions/series-states-hover-enabled/
  38136. * Line
  38137. * @sample {highcharts} highcharts/plotoptions/series-states-hover-enabled-column/
  38138. * Column
  38139. * @sample {highcharts} highcharts/plotoptions/series-states-hover-enabled-pie/
  38140. * Pie
  38141. *
  38142. * @type {boolean}
  38143. * @default true
  38144. * @since 1.2
  38145. * @apioption plotOptions.series.states.hover.enabled
  38146. */
  38147. /**
  38148. * Animation setting for hovering the graph in line-type series.
  38149. *
  38150. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  38151. * @since 5.0.8
  38152. * @product highcharts highstock
  38153. */
  38154. animation: {
  38155. /**
  38156. * The duration of the hover animation in milliseconds. By
  38157. * default the hover state animates quickly in, and slowly
  38158. * back to normal.
  38159. *
  38160. * @internal
  38161. */
  38162. duration: 50
  38163. },
  38164. /**
  38165. * Pixel width of the graph line. By default this property is
  38166. * undefined, and the `lineWidthPlus` property dictates how much
  38167. * to increase the linewidth from normal state.
  38168. *
  38169. * @sample {highcharts} highcharts/plotoptions/series-states-hover-linewidth/
  38170. * 5px line on hover
  38171. *
  38172. * @type {number}
  38173. * @product highcharts highstock
  38174. * @apioption plotOptions.series.states.hover.lineWidth
  38175. */
  38176. /**
  38177. * The additional line width for the graph of a hovered series.
  38178. *
  38179. * @sample {highcharts} highcharts/plotoptions/series-states-hover-linewidthplus/
  38180. * 5 pixels wider
  38181. * @sample {highstock} highcharts/plotoptions/series-states-hover-linewidthplus/
  38182. * 5 pixels wider
  38183. *
  38184. * @since 4.0.3
  38185. * @product highcharts highstock
  38186. */
  38187. lineWidthPlus: 1,
  38188. /**
  38189. * In Highcharts 1.0, the appearance of all markers belonging
  38190. * to the hovered series. For settings on the hover state of the
  38191. * individual point, see
  38192. * [marker.states.hover](#plotOptions.series.marker.states.hover).
  38193. *
  38194. * @deprecated
  38195. *
  38196. * @extends plotOptions.series.marker
  38197. * @excluding states
  38198. * @product highcharts highstock
  38199. */
  38200. marker: {
  38201. // lineWidth: base + 1,
  38202. // radius: base + 1
  38203. },
  38204. /**
  38205. * Options for the halo appearing around the hovered point in
  38206. * line-type series as well as outside the hovered slice in pie
  38207. * charts. By default the halo is filled by the current point or
  38208. * series color with an opacity of 0.25\. The halo can be
  38209. * disabled by setting the `halo` option to `null`.
  38210. *
  38211. * In styled mode, the halo is styled with the
  38212. * `.highcharts-halo` class, with colors inherited from
  38213. * `.highcharts-color-{n}`.
  38214. *
  38215. * @sample {highcharts} highcharts/plotoptions/halo/
  38216. * Halo options
  38217. * @sample {highstock} highcharts/plotoptions/halo/
  38218. * Halo options
  38219. *
  38220. * @declare Highcharts.SeriesStatesHoverHaloOptionsObject
  38221. * @type {null|*}
  38222. * @since 4.0
  38223. * @product highcharts highstock
  38224. */
  38225. halo: {
  38226. /**
  38227. * A collection of SVG attributes to override the appearance
  38228. * of the halo, for example `fill`, `stroke` and
  38229. * `stroke-width`.
  38230. *
  38231. * @type {Highcharts.SVGAttributes}
  38232. * @since 4.0
  38233. * @product highcharts highstock
  38234. * @apioption plotOptions.series.states.hover.halo.attributes
  38235. */
  38236. /**
  38237. * The pixel size of the halo. For point markers this is the
  38238. * radius of the halo. For pie slices it is the width of the
  38239. * halo outside the slice. For bubbles it defaults to 5 and
  38240. * is the width of the halo outside the bubble.
  38241. *
  38242. * @since 4.0
  38243. * @product highcharts highstock
  38244. */
  38245. size: 10,
  38246. /**
  38247. * Opacity for the halo unless a specific fill is overridden
  38248. * using the `attributes` setting. Note that Highcharts is
  38249. * only able to apply opacity to colors of hex or rgb(a)
  38250. * formats.
  38251. *
  38252. * @since 4.0
  38253. * @product highcharts highstock
  38254. */
  38255. opacity: 0.25
  38256. }
  38257. },
  38258. /**
  38259. * Specific options for point in selected states, after being
  38260. * selected by
  38261. * [allowPointSelect](#plotOptions.series.allowPointSelect)
  38262. * or programmatically.
  38263. *
  38264. * @sample maps/plotoptions/series-allowpointselect/
  38265. * Allow point select demo
  38266. *
  38267. * @declare Highcharts.SeriesStatesSelectOptionsObject
  38268. * @extends plotOptions.series.states.hover
  38269. * @excluding brightness
  38270. */
  38271. select: {
  38272. animation: {
  38273. /** @internal */
  38274. duration: 0
  38275. }
  38276. },
  38277. /**
  38278. * The opposite state of a hover for series.
  38279. *
  38280. * @sample highcharts/plotoptions/series-states-inactive-disabled
  38281. * Disabled inactive state
  38282. *
  38283. * @declare Highcharts.SeriesStatesInactiveOptionsObject
  38284. */
  38285. inactive: {
  38286. /**
  38287. * Enable or disable the inactive state for a series
  38288. *
  38289. * @sample highcharts/plotoptions/series-states-inactive-disabled
  38290. * Disabled inactive state
  38291. *
  38292. * @type {boolean}
  38293. * @default true
  38294. * @apioption plotOptions.series.states.inactive.enabled
  38295. */
  38296. /**
  38297. * The animation for entering the inactive state.
  38298. *
  38299. * @type {boolean|Partial<Highcharts.AnimationOptionsObject>}
  38300. */
  38301. animation: {
  38302. /** @internal */
  38303. duration: 50
  38304. },
  38305. /**
  38306. * Opacity of series elements (dataLabels, line, area).
  38307. *
  38308. * @type {number}
  38309. */
  38310. opacity: 0.2
  38311. }
  38312. },
  38313. /**
  38314. * Sticky tracking of mouse events. When true, the `mouseOut` event on a
  38315. * series isn't triggered until the mouse moves over another series, or
  38316. * out of the plot area. When false, the `mouseOut` event on a series is
  38317. * triggered when the mouse leaves the area around the series' graph or
  38318. * markers. This also implies the tooltip when not shared. When
  38319. * `stickyTracking` is false and `tooltip.shared` is false, the tooltip
  38320. * will be hidden when moving the mouse between series. Defaults to true
  38321. * for line and area type series, but to false for columns, pies etc.
  38322. *
  38323. * **Note:** The boost module will force this option because of
  38324. * technical limitations.
  38325. *
  38326. * @sample {highcharts} highcharts/plotoptions/series-stickytracking-true/
  38327. * True by default
  38328. * @sample {highcharts} highcharts/plotoptions/series-stickytracking-false/
  38329. * False
  38330. *
  38331. * @default {highcharts} true
  38332. * @default {highstock} true
  38333. * @default {highmaps} false
  38334. * @since 2.0
  38335. *
  38336. * @private
  38337. */
  38338. stickyTracking: true,
  38339. /**
  38340. * A configuration object for the tooltip rendering of each single
  38341. * series. Properties are inherited from [tooltip](#tooltip), but only
  38342. * the following properties can be defined on a series level.
  38343. *
  38344. * @declare Highcharts.SeriesTooltipOptionsObject
  38345. * @since 2.3
  38346. * @extends tooltip
  38347. * @excluding animation, backgroundColor, borderColor, borderRadius,
  38348. * borderWidth, className, crosshairs, enabled, formatter,
  38349. * headerShape, hideDelay, outside, padding, positioner,
  38350. * shadow, shape, shared, snap, split, stickOnContact,
  38351. * style, useHTML
  38352. * @apioption plotOptions.series.tooltip
  38353. */
  38354. /**
  38355. * When a series contains a data array that is longer than this, only
  38356. * one dimensional arrays of numbers, or two dimensional arrays with
  38357. * x and y values are allowed. Also, only the first point is tested,
  38358. * and the rest are assumed to be the same format. This saves expensive
  38359. * data checking and indexing in long series. Set it to `0` disable.
  38360. *
  38361. * Note:
  38362. * In boost mode turbo threshold is forced. Only array of numbers or
  38363. * two dimensional arrays are allowed.
  38364. *
  38365. * @since 2.2
  38366. * @product highcharts highstock gantt
  38367. *
  38368. * @private
  38369. */
  38370. turboThreshold: 1000,
  38371. /**
  38372. * An array defining zones within a series. Zones can be applied to the
  38373. * X axis, Y axis or Z axis for bubbles, according to the `zoneAxis`
  38374. * option. The zone definitions have to be in ascending order regarding
  38375. * to the value.
  38376. *
  38377. * In styled mode, the color zones are styled with the
  38378. * `.highcharts-zone-{n}` class, or custom classed from the `className`
  38379. * option
  38380. * ([view live demo](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/css/color-zones/)).
  38381. *
  38382. * @see [zoneAxis](#plotOptions.series.zoneAxis)
  38383. *
  38384. * @sample {highcharts} highcharts/series/color-zones-simple/
  38385. * Color zones
  38386. * @sample {highstock} highcharts/series/color-zones-simple/
  38387. * Color zones
  38388. *
  38389. * @declare Highcharts.SeriesZonesOptionsObject
  38390. * @type {Array<*>}
  38391. * @since 4.1.0
  38392. * @product highcharts highstock
  38393. * @apioption plotOptions.series.zones
  38394. */
  38395. /**
  38396. * Styled mode only. A custom class name for the zone.
  38397. *
  38398. * @sample highcharts/css/color-zones/
  38399. * Zones styled by class name
  38400. *
  38401. * @type {string}
  38402. * @since 5.0.0
  38403. * @apioption plotOptions.series.zones.className
  38404. */
  38405. /**
  38406. * Defines the color of the series.
  38407. *
  38408. * @see [series color](#plotOptions.series.color)
  38409. *
  38410. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  38411. * @since 4.1.0
  38412. * @product highcharts highstock
  38413. * @apioption plotOptions.series.zones.color
  38414. */
  38415. /**
  38416. * A name for the dash style to use for the graph.
  38417. *
  38418. * @see [plotOptions.series.dashStyle](#plotOptions.series.dashStyle)
  38419. *
  38420. * @sample {highcharts|highstock} highcharts/series/color-zones-dashstyle-dot/
  38421. * Dashed line indicates prognosis
  38422. *
  38423. * @type {Highcharts.DashStyleValue}
  38424. * @since 4.1.0
  38425. * @product highcharts highstock
  38426. * @apioption plotOptions.series.zones.dashStyle
  38427. */
  38428. /**
  38429. * Defines the fill color for the series (in area type series)
  38430. *
  38431. * @see [fillColor](#plotOptions.area.fillColor)
  38432. *
  38433. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  38434. * @since 4.1.0
  38435. * @product highcharts highstock
  38436. * @apioption plotOptions.series.zones.fillColor
  38437. */
  38438. /**
  38439. * The value up to where the zone extends, if undefined the zones
  38440. * stretches to the last value in the series.
  38441. *
  38442. * @type {number}
  38443. * @since 4.1.0
  38444. * @product highcharts highstock
  38445. * @apioption plotOptions.series.zones.value
  38446. */
  38447. /**
  38448. * When using dual or multiple color axes, this number defines which
  38449. * colorAxis the particular series is connected to. It refers to
  38450. * either the
  38451. * {@link #colorAxis.id|axis id}
  38452. * or the index of the axis in the colorAxis array, with 0 being the
  38453. * first. Set this option to false to prevent a series from connecting
  38454. * to the default color axis.
  38455. *
  38456. * Since v7.2.0 the option can also be an axis id or an axis index
  38457. * instead of a boolean flag.
  38458. *
  38459. * @sample highcharts/coloraxis/coloraxis-with-pie/
  38460. * Color axis with pie series
  38461. * @sample highcharts/coloraxis/multiple-coloraxis/
  38462. * Multiple color axis
  38463. *
  38464. * @type {number|string|boolean}
  38465. * @default 0
  38466. * @product highcharts highstock highmaps
  38467. * @apioption plotOptions.series.colorAxis
  38468. */
  38469. /**
  38470. * Determines what data value should be used to calculate point color
  38471. * if `colorAxis` is used. Requires to set `min` and `max` if some
  38472. * custom point property is used or if approximation for data grouping
  38473. * is set to `'sum'`.
  38474. *
  38475. * @sample highcharts/coloraxis/custom-color-key/
  38476. * Custom color key
  38477. * @sample highcharts/coloraxis/changed-default-color-key/
  38478. * Changed default color key
  38479. *
  38480. * @type {string}
  38481. * @default y
  38482. * @since 7.2.0
  38483. * @product highcharts highstock highmaps
  38484. * @apioption plotOptions.series.colorKey
  38485. */
  38486. /**
  38487. * Determines whether the series should look for the nearest point
  38488. * in both dimensions or just the x-dimension when hovering the series.
  38489. * Defaults to `'xy'` for scatter series and `'x'` for most other
  38490. * series. If the data has duplicate x-values, it is recommended to
  38491. * set this to `'xy'` to allow hovering over all points.
  38492. *
  38493. * Applies only to series types using nearest neighbor search (not
  38494. * direct hover) for tooltip.
  38495. *
  38496. * @sample {highcharts} highcharts/series/findnearestpointby/
  38497. * Different hover behaviors
  38498. * @sample {highstock} highcharts/series/findnearestpointby/
  38499. * Different hover behaviors
  38500. * @sample {highmaps} highcharts/series/findnearestpointby/
  38501. * Different hover behaviors
  38502. *
  38503. * @since 5.0.10
  38504. * @validvalue ["x", "xy"]
  38505. *
  38506. * @private
  38507. */
  38508. findNearestPointBy: 'x'
  38509. };
  38510. return Series;
  38511. }());
  38512. extend(Series.prototype, {
  38513. axisTypes: ['xAxis', 'yAxis'],
  38514. coll: 'series',
  38515. colorCounter: 0,
  38516. cropShoulder: 1,
  38517. directTouch: false,
  38518. drawLegendSymbol: LegendSymbolMixin.drawLineMarker,
  38519. isCartesian: true,
  38520. kdAxisArray: ['clientX', 'plotY'],
  38521. // each point's x and y values are stored in this.xData and this.yData:
  38522. parallelArrays: ['x', 'y'],
  38523. pointClass: Point,
  38524. requireSorting: true,
  38525. // requires the data to be sorted:
  38526. sorted: true
  38527. });
  38528. /* *
  38529. *
  38530. * Registry
  38531. *
  38532. * */
  38533. SeriesRegistry.series = Series;
  38534. /* *
  38535. *
  38536. * Default Export
  38537. *
  38538. * */
  38539. /* *
  38540. *
  38541. * API Declarations
  38542. *
  38543. * */
  38544. /**
  38545. * This is a placeholder type of the possible series options for
  38546. * [Highcharts](../highcharts/series), [Highcharts Stock](../highstock/series),
  38547. * [Highmaps](../highmaps/series), and [Gantt](../gantt/series).
  38548. *
  38549. * In TypeScript is this dynamically generated to reference all possible types
  38550. * of series options.
  38551. *
  38552. * @ignore-declaration
  38553. * @typedef {Highcharts.SeriesOptions|Highcharts.Dictionary<*>} Highcharts.SeriesOptionsType
  38554. */
  38555. /**
  38556. * Options for `dataSorting`.
  38557. *
  38558. * @interface Highcharts.DataSortingOptionsObject
  38559. * @since 8.0.0
  38560. */ /**
  38561. * Enable or disable data sorting for the series.
  38562. * @name Highcharts.DataSortingOptionsObject#enabled
  38563. * @type {boolean|undefined}
  38564. */ /**
  38565. * Whether to allow matching points by name in an update.
  38566. * @name Highcharts.DataSortingOptionsObject#matchByName
  38567. * @type {boolean|undefined}
  38568. */ /**
  38569. * Determines what data value should be used to sort by.
  38570. * @name Highcharts.DataSortingOptionsObject#sortKey
  38571. * @type {string|undefined}
  38572. */
  38573. /**
  38574. * Function callback when a series has been animated.
  38575. *
  38576. * @callback Highcharts.SeriesAfterAnimateCallbackFunction
  38577. *
  38578. * @param {Highcharts.Series} this
  38579. * The series where the event occured.
  38580. *
  38581. * @param {Highcharts.SeriesAfterAnimateEventObject} event
  38582. * Event arguments.
  38583. */
  38584. /**
  38585. * Event information regarding completed animation of a series.
  38586. *
  38587. * @interface Highcharts.SeriesAfterAnimateEventObject
  38588. */ /**
  38589. * Animated series.
  38590. * @name Highcharts.SeriesAfterAnimateEventObject#target
  38591. * @type {Highcharts.Series}
  38592. */ /**
  38593. * Event type.
  38594. * @name Highcharts.SeriesAfterAnimateEventObject#type
  38595. * @type {"afterAnimate"}
  38596. */
  38597. /**
  38598. * Function callback when the checkbox next to the series' name in the legend is
  38599. * clicked.
  38600. *
  38601. * @callback Highcharts.SeriesCheckboxClickCallbackFunction
  38602. *
  38603. * @param {Highcharts.Series} this
  38604. * The series where the event occured.
  38605. *
  38606. * @param {Highcharts.SeriesCheckboxClickEventObject} event
  38607. * Event arguments.
  38608. */
  38609. /**
  38610. * Event information regarding check of a series box.
  38611. *
  38612. * @interface Highcharts.SeriesCheckboxClickEventObject
  38613. */ /**
  38614. * Whether the box has been checked.
  38615. * @name Highcharts.SeriesCheckboxClickEventObject#checked
  38616. * @type {boolean}
  38617. */ /**
  38618. * Related series.
  38619. * @name Highcharts.SeriesCheckboxClickEventObject#item
  38620. * @type {Highcharts.Series}
  38621. */ /**
  38622. * Related series.
  38623. * @name Highcharts.SeriesCheckboxClickEventObject#target
  38624. * @type {Highcharts.Series}
  38625. */ /**
  38626. * Event type.
  38627. * @name Highcharts.SeriesCheckboxClickEventObject#type
  38628. * @type {"checkboxClick"}
  38629. */
  38630. /**
  38631. * Function callback when a series is clicked. Return false to cancel toogle
  38632. * actions.
  38633. *
  38634. * @callback Highcharts.SeriesClickCallbackFunction
  38635. *
  38636. * @param {Highcharts.Series} this
  38637. * The series where the event occured.
  38638. *
  38639. * @param {Highcharts.SeriesClickEventObject} event
  38640. * Event arguments.
  38641. */
  38642. /**
  38643. * Common information for a click event on a series.
  38644. *
  38645. * @interface Highcharts.SeriesClickEventObject
  38646. * @extends global.Event
  38647. */ /**
  38648. * Nearest point on the graph.
  38649. * @name Highcharts.SeriesClickEventObject#point
  38650. * @type {Highcharts.Point}
  38651. */
  38652. /**
  38653. * Gets fired when the series is hidden after chart generation time, either by
  38654. * clicking the legend item or by calling `.hide()`.
  38655. *
  38656. * @callback Highcharts.SeriesHideCallbackFunction
  38657. *
  38658. * @param {Highcharts.Series} this
  38659. * The series where the event occured.
  38660. *
  38661. * @param {global.Event} event
  38662. * The event that occured.
  38663. */
  38664. /**
  38665. * The SVG value used for the `stroke-linecap` and `stroke-linejoin` of a line
  38666. * graph.
  38667. *
  38668. * @typedef {"butt"|"round"|"square"|string} Highcharts.SeriesLinecapValue
  38669. */
  38670. /**
  38671. * Gets fired when the legend item belonging to the series is clicked. The
  38672. * default action is to toggle the visibility of the series. This can be
  38673. * prevented by returning `false` or calling `event.preventDefault()`.
  38674. *
  38675. * @callback Highcharts.SeriesLegendItemClickCallbackFunction
  38676. *
  38677. * @param {Highcharts.Series} this
  38678. * The series where the event occured.
  38679. *
  38680. * @param {Highcharts.SeriesLegendItemClickEventObject} event
  38681. * The event that occured.
  38682. */
  38683. /**
  38684. * Information about the event.
  38685. *
  38686. * @interface Highcharts.SeriesLegendItemClickEventObject
  38687. */ /**
  38688. * Related browser event.
  38689. * @name Highcharts.SeriesLegendItemClickEventObject#browserEvent
  38690. * @type {global.PointerEvent}
  38691. */ /**
  38692. * Prevent the default action of toggle the visibility of the series.
  38693. * @name Highcharts.SeriesLegendItemClickEventObject#preventDefault
  38694. * @type {Function}
  38695. */ /**
  38696. * Related series.
  38697. * @name Highcharts.SeriesCheckboxClickEventObject#target
  38698. * @type {Highcharts.Series}
  38699. */ /**
  38700. * Event type.
  38701. * @name Highcharts.SeriesCheckboxClickEventObject#type
  38702. * @type {"checkboxClick"}
  38703. */
  38704. /**
  38705. * Gets fired when the mouse leaves the graph.
  38706. *
  38707. * @callback Highcharts.SeriesMouseOutCallbackFunction
  38708. *
  38709. * @param {Highcharts.Series} this
  38710. * Series where the event occured.
  38711. *
  38712. * @param {global.PointerEvent} event
  38713. * Event that occured.
  38714. */
  38715. /**
  38716. * Gets fired when the mouse enters the graph.
  38717. *
  38718. * @callback Highcharts.SeriesMouseOverCallbackFunction
  38719. *
  38720. * @param {Highcharts.Series} this
  38721. * Series where the event occured.
  38722. *
  38723. * @param {global.PointerEvent} event
  38724. * Event that occured.
  38725. */
  38726. /**
  38727. * Translation and scale for the plot area of a series.
  38728. *
  38729. * @interface Highcharts.SeriesPlotBoxObject
  38730. */ /**
  38731. * @name Highcharts.SeriesPlotBoxObject#scaleX
  38732. * @type {number}
  38733. */ /**
  38734. * @name Highcharts.SeriesPlotBoxObject#scaleY
  38735. * @type {number}
  38736. */ /**
  38737. * @name Highcharts.SeriesPlotBoxObject#translateX
  38738. * @type {number}
  38739. */ /**
  38740. * @name Highcharts.SeriesPlotBoxObject#translateY
  38741. * @type {number}
  38742. */
  38743. /**
  38744. * Gets fired when the series is shown after chart generation time, either by
  38745. * clicking the legend item or by calling `.show()`.
  38746. *
  38747. * @callback Highcharts.SeriesShowCallbackFunction
  38748. *
  38749. * @param {Highcharts.Series} this
  38750. * Series where the event occured.
  38751. *
  38752. * @param {global.Event} event
  38753. * Event that occured.
  38754. */
  38755. /**
  38756. * Possible key values for the series state options.
  38757. *
  38758. * @typedef {"hover"|"inactive"|"normal"|"select"} Highcharts.SeriesStateValue
  38759. */
  38760. ''; // detach doclets above
  38761. /* *
  38762. *
  38763. * API Options
  38764. *
  38765. * */
  38766. /**
  38767. * Series options for specific data and the data itself. In TypeScript you
  38768. * have to cast the series options to specific series types, to get all
  38769. * possible options for a series.
  38770. *
  38771. * @example
  38772. * // TypeScript example
  38773. * Highcharts.chart('container', {
  38774. * series: [{
  38775. * color: '#06C',
  38776. * data: [[0, 1], [2, 3]]
  38777. * } as Highcharts.SeriesLineOptions ]
  38778. * });
  38779. *
  38780. * @type {Array<*>}
  38781. * @apioption series
  38782. */
  38783. /**
  38784. * An id for the series. This can be used after render time to get a pointer
  38785. * to the series object through `chart.get()`.
  38786. *
  38787. * @sample {highcharts} highcharts/plotoptions/series-id/
  38788. * Get series by id
  38789. *
  38790. * @type {string}
  38791. * @since 1.2.0
  38792. * @apioption series.id
  38793. */
  38794. /**
  38795. * The index of the series in the chart, affecting the internal index in the
  38796. * `chart.series` array, the visible Z index as well as the order in the
  38797. * legend.
  38798. *
  38799. * @type {number}
  38800. * @since 2.3.0
  38801. * @apioption series.index
  38802. */
  38803. /**
  38804. * The sequential index of the series in the legend.
  38805. *
  38806. * @see [legend.reversed](#legend.reversed),
  38807. * [yAxis.reversedStacks](#yAxis.reversedStacks)
  38808. *
  38809. * @sample {highcharts|highstock} highcharts/series/legendindex/
  38810. * Legend in opposite order
  38811. *
  38812. * @type {number}
  38813. * @apioption series.legendIndex
  38814. */
  38815. /**
  38816. * The name of the series as shown in the legend, tooltip etc.
  38817. *
  38818. * @sample {highcharts} highcharts/series/name/
  38819. * Series name
  38820. * @sample {highmaps} maps/demo/category-map/
  38821. * Series name
  38822. *
  38823. * @type {string}
  38824. * @apioption series.name
  38825. */
  38826. /**
  38827. * This option allows grouping series in a stacked chart. The stack option
  38828. * can be a string or anything else, as long as the grouped series' stack
  38829. * options match each other after conversion into a string.
  38830. *
  38831. * @sample {highcharts} highcharts/series/stack/
  38832. * Stacked and grouped columns
  38833. *
  38834. * @type {number|string}
  38835. * @since 2.1
  38836. * @product highcharts highstock
  38837. * @apioption series.stack
  38838. */
  38839. /**
  38840. * The type of series, for example `line` or `column`. By default, the
  38841. * series type is inherited from [chart.type](#chart.type), so unless the
  38842. * chart is a combination of series types, there is no need to set it on the
  38843. * series level.
  38844. *
  38845. * @sample {highcharts} highcharts/series/type/
  38846. * Line and column in the same chart
  38847. * @sample highcharts/series/type-dynamic/
  38848. * Dynamic types with button selector
  38849. * @sample {highmaps} maps/demo/mapline-mappoint/
  38850. * Multiple types in the same map
  38851. *
  38852. * @type {string}
  38853. * @apioption series.type
  38854. */
  38855. /**
  38856. * When using dual or multiple x axes, this number defines which xAxis the
  38857. * particular series is connected to. It refers to either the
  38858. * {@link #xAxis.id|axis id}
  38859. * or the index of the axis in the xAxis array, with 0 being the first.
  38860. *
  38861. * @type {number|string}
  38862. * @default 0
  38863. * @product highcharts highstock
  38864. * @apioption series.xAxis
  38865. */
  38866. /**
  38867. * When using dual or multiple y axes, this number defines which yAxis the
  38868. * particular series is connected to. It refers to either the
  38869. * {@link #yAxis.id|axis id}
  38870. * or the index of the axis in the yAxis array, with 0 being the first.
  38871. *
  38872. * @sample {highcharts} highcharts/series/yaxis/
  38873. * Apply the column series to the secondary Y axis
  38874. *
  38875. * @type {number|string}
  38876. * @default 0
  38877. * @product highcharts highstock
  38878. * @apioption series.yAxis
  38879. */
  38880. /**
  38881. * Define the visual z index of the series.
  38882. *
  38883. * @sample {highcharts} highcharts/plotoptions/series-zindex-default/
  38884. * With no z index, the series defined last are on top
  38885. * @sample {highcharts} highcharts/plotoptions/series-zindex/
  38886. * With a z index, the series with the highest z index is on top
  38887. * @sample {highstock} highcharts/plotoptions/series-zindex-default/
  38888. * With no z index, the series defined last are on top
  38889. * @sample {highstock} highcharts/plotoptions/series-zindex/
  38890. * With a z index, the series with the highest z index is on top
  38891. *
  38892. * @type {number}
  38893. * @product highcharts highstock
  38894. * @apioption series.zIndex
  38895. */
  38896. ''; // include precedent doclets in transpilat
  38897. return Series;
  38898. });
  38899. _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/Renderer/RendererRegistry.js'], _modules['Core/Utilities.js']], function (A, Axis, Chart, Series, RendererRegistry, U) {
  38900. /* *
  38901. *
  38902. * (c) 2010-2021 Torstein Honsi
  38903. *
  38904. * License: www.highcharts.com/license
  38905. *
  38906. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  38907. *
  38908. * Highcharts feature to make the Y axis stay fixed when scrolling the chart
  38909. * horizontally on mobile devices. Supports left and right side axes.
  38910. */
  38911. /*
  38912. WIP on vertical scrollable plot area (#9378). To do:
  38913. - Bottom axis positioning
  38914. - Test with Gantt
  38915. - Look for size optimizing the code
  38916. - API and demos
  38917. */
  38918. var stop = A.stop;
  38919. var addEvent = U.addEvent,
  38920. createElement = U.createElement,
  38921. merge = U.merge,
  38922. pick = U.pick;
  38923. /* eslint-disable no-invalid-this, valid-jsdoc */
  38924. addEvent(Chart, 'afterSetChartSize', function (e) {
  38925. var scrollablePlotArea = this.options.chart.scrollablePlotArea,
  38926. scrollableMinWidth = scrollablePlotArea && scrollablePlotArea.minWidth,
  38927. scrollableMinHeight = scrollablePlotArea && scrollablePlotArea.minHeight,
  38928. scrollablePixelsX,
  38929. scrollablePixelsY,
  38930. corrections;
  38931. if (!this.renderer.forExport) {
  38932. // The amount of pixels to scroll, the difference between chart
  38933. // width and scrollable width
  38934. if (scrollableMinWidth) {
  38935. this.scrollablePixelsX = scrollablePixelsX = Math.max(0, scrollableMinWidth - this.chartWidth);
  38936. if (scrollablePixelsX) {
  38937. this.scrollablePlotBox = this.renderer.scrollablePlotBox = merge(this.plotBox);
  38938. this.plotBox.width = this.plotWidth += scrollablePixelsX;
  38939. if (this.inverted) {
  38940. this.clipBox.height += scrollablePixelsX;
  38941. }
  38942. else {
  38943. this.clipBox.width += scrollablePixelsX;
  38944. }
  38945. corrections = {
  38946. // Corrections for right side
  38947. 1: { name: 'right', value: scrollablePixelsX }
  38948. };
  38949. }
  38950. // Currently we can only do either X or Y
  38951. }
  38952. else if (scrollableMinHeight) {
  38953. this.scrollablePixelsY = scrollablePixelsY = Math.max(0, scrollableMinHeight - this.chartHeight);
  38954. if (scrollablePixelsY) {
  38955. this.scrollablePlotBox = this.renderer.scrollablePlotBox = merge(this.plotBox);
  38956. this.plotBox.height = this.plotHeight += scrollablePixelsY;
  38957. if (this.inverted) {
  38958. this.clipBox.width += scrollablePixelsY;
  38959. }
  38960. else {
  38961. this.clipBox.height += scrollablePixelsY;
  38962. }
  38963. corrections = {
  38964. 2: { name: 'bottom', value: scrollablePixelsY }
  38965. };
  38966. }
  38967. }
  38968. if (corrections && !e.skipAxes) {
  38969. this.axes.forEach(function (axis) {
  38970. // For right and bottom axes, only fix the plot line length
  38971. if (corrections[axis.side]) {
  38972. // Get the plot lines right in getPlotLinePath,
  38973. // temporarily set it to the adjusted plot width.
  38974. axis.getPlotLinePath = function () {
  38975. var marginName = corrections[axis.side].name,
  38976. correctionValue = corrections[axis.side].value,
  38977. // axis.right or axis.bottom
  38978. margin = this[marginName],
  38979. path;
  38980. // Temporarily adjust
  38981. this[marginName] = margin - correctionValue;
  38982. path = Axis.prototype.getPlotLinePath.apply(this, arguments);
  38983. // Reset
  38984. this[marginName] = margin;
  38985. return path;
  38986. };
  38987. }
  38988. else {
  38989. // Apply the corrected plotWidth
  38990. axis.setAxisSize();
  38991. axis.setAxisTranslation();
  38992. }
  38993. });
  38994. }
  38995. }
  38996. });
  38997. addEvent(Chart, 'render', function () {
  38998. if (this.scrollablePixelsX || this.scrollablePixelsY) {
  38999. if (this.setUpScrolling) {
  39000. this.setUpScrolling();
  39001. }
  39002. this.applyFixed();
  39003. }
  39004. else if (this.fixedDiv) { // Has been in scrollable mode
  39005. this.applyFixed();
  39006. }
  39007. });
  39008. /**
  39009. * @private
  39010. * @function Highcharts.Chart#setUpScrolling
  39011. * @return {void}
  39012. */
  39013. Chart.prototype.setUpScrolling = function () {
  39014. var _this = this;
  39015. var css = {
  39016. WebkitOverflowScrolling: 'touch',
  39017. overflowX: 'hidden',
  39018. overflowY: 'hidden'
  39019. };
  39020. if (this.scrollablePixelsX) {
  39021. css.overflowX = 'auto';
  39022. }
  39023. if (this.scrollablePixelsY) {
  39024. css.overflowY = 'auto';
  39025. }
  39026. // Insert a container with position relative
  39027. // that scrolling and fixed container renders to (#10555)
  39028. this.scrollingParent = createElement('div', {
  39029. className: 'highcharts-scrolling-parent'
  39030. }, {
  39031. position: 'relative'
  39032. }, this.renderTo);
  39033. // Add the necessary divs to provide scrolling
  39034. this.scrollingContainer = createElement('div', {
  39035. 'className': 'highcharts-scrolling'
  39036. }, css, this.scrollingParent);
  39037. // On scroll, reset the chart position because it applies to the scrolled
  39038. // container
  39039. addEvent(this.scrollingContainer, 'scroll', function () {
  39040. if (_this.pointer) {
  39041. delete _this.pointer.chartPosition;
  39042. }
  39043. });
  39044. this.innerContainer = createElement('div', {
  39045. 'className': 'highcharts-inner-container'
  39046. }, null, this.scrollingContainer);
  39047. // Now move the container inside
  39048. this.innerContainer.appendChild(this.container);
  39049. // Don't run again
  39050. this.setUpScrolling = null;
  39051. };
  39052. /**
  39053. * These elements are moved over to the fixed renderer and stay fixed when the
  39054. * user scrolls the chart
  39055. * @private
  39056. */
  39057. Chart.prototype.moveFixedElements = function () {
  39058. var container = this.container,
  39059. fixedRenderer = this.fixedRenderer,
  39060. fixedSelectors = [
  39061. '.highcharts-contextbutton',
  39062. '.highcharts-credits',
  39063. '.highcharts-legend',
  39064. '.highcharts-legend-checkbox',
  39065. '.highcharts-navigator-series',
  39066. '.highcharts-navigator-xaxis',
  39067. '.highcharts-navigator-yaxis',
  39068. '.highcharts-navigator',
  39069. '.highcharts-reset-zoom',
  39070. '.highcharts-drillup-button',
  39071. '.highcharts-scrollbar',
  39072. '.highcharts-subtitle',
  39073. '.highcharts-title'
  39074. ],
  39075. axisClass;
  39076. if (this.scrollablePixelsX && !this.inverted) {
  39077. axisClass = '.highcharts-yaxis';
  39078. }
  39079. else if (this.scrollablePixelsX && this.inverted) {
  39080. axisClass = '.highcharts-xaxis';
  39081. }
  39082. else if (this.scrollablePixelsY && !this.inverted) {
  39083. axisClass = '.highcharts-xaxis';
  39084. }
  39085. else if (this.scrollablePixelsY && this.inverted) {
  39086. axisClass = '.highcharts-yaxis';
  39087. }
  39088. if (axisClass) {
  39089. fixedSelectors.push(axisClass + ":not(.highcharts-radial-axis)", axisClass + "-labels:not(.highcharts-radial-axis-labels)");
  39090. }
  39091. fixedSelectors.forEach(function (className) {
  39092. [].forEach.call(container.querySelectorAll(className), function (elem) {
  39093. (elem.namespaceURI === fixedRenderer.SVG_NS ?
  39094. fixedRenderer.box :
  39095. fixedRenderer.box.parentNode).appendChild(elem);
  39096. elem.style.pointerEvents = 'auto';
  39097. });
  39098. });
  39099. };
  39100. /**
  39101. * @private
  39102. * @function Highcharts.Chart#applyFixed
  39103. * @return {void}
  39104. */
  39105. Chart.prototype.applyFixed = function () {
  39106. var firstTime = !this.fixedDiv,
  39107. chartOptions = this.options.chart,
  39108. scrollableOptions = chartOptions.scrollablePlotArea,
  39109. Renderer = RendererRegistry.getRendererType();
  39110. var fixedRenderer,
  39111. scrollableWidth,
  39112. scrollableHeight;
  39113. // First render
  39114. if (firstTime) {
  39115. this.fixedDiv = createElement('div', {
  39116. className: 'highcharts-fixed'
  39117. }, {
  39118. position: 'absolute',
  39119. overflow: 'hidden',
  39120. pointerEvents: 'none',
  39121. zIndex: (chartOptions.style && chartOptions.style.zIndex || 0) + 2,
  39122. top: 0
  39123. }, null, true);
  39124. if (this.scrollingContainer) {
  39125. this.scrollingContainer.parentNode.insertBefore(this.fixedDiv, this.scrollingContainer);
  39126. }
  39127. this.renderTo.style.overflow = 'visible';
  39128. this.fixedRenderer = fixedRenderer = new Renderer(this.fixedDiv, this.chartWidth, this.chartHeight, this.options.chart.style);
  39129. // Mask
  39130. this.scrollableMask = fixedRenderer
  39131. .path()
  39132. .attr({
  39133. fill: this.options.chart.backgroundColor || '#fff',
  39134. 'fill-opacity': pick(scrollableOptions.opacity, 0.85),
  39135. zIndex: -1
  39136. })
  39137. .addClass('highcharts-scrollable-mask')
  39138. .add();
  39139. addEvent(this, 'afterShowResetZoom', this.moveFixedElements);
  39140. addEvent(this, 'afterDrilldown', this.moveFixedElements);
  39141. addEvent(this, 'afterLayOutTitles', this.moveFixedElements);
  39142. }
  39143. else {
  39144. // Set the size of the fixed renderer to the visible width
  39145. this.fixedRenderer.setSize(this.chartWidth, this.chartHeight);
  39146. }
  39147. if (this.scrollableDirty || firstTime) {
  39148. this.scrollableDirty = false;
  39149. this.moveFixedElements();
  39150. }
  39151. // Increase the size of the scrollable renderer and background
  39152. scrollableWidth = this.chartWidth + (this.scrollablePixelsX || 0);
  39153. scrollableHeight = this.chartHeight + (this.scrollablePixelsY || 0);
  39154. stop(this.container);
  39155. this.container.style.width = scrollableWidth + 'px';
  39156. this.container.style.height = scrollableHeight + 'px';
  39157. this.renderer.boxWrapper.attr({
  39158. width: scrollableWidth,
  39159. height: scrollableHeight,
  39160. viewBox: [0, 0, scrollableWidth, scrollableHeight].join(' ')
  39161. });
  39162. this.chartBackground.attr({
  39163. width: scrollableWidth,
  39164. height: scrollableHeight
  39165. });
  39166. this.scrollingContainer.style.height = this.chartHeight + 'px';
  39167. // Set scroll position
  39168. if (firstTime) {
  39169. if (scrollableOptions.scrollPositionX) {
  39170. this.scrollingContainer.scrollLeft =
  39171. this.scrollablePixelsX *
  39172. scrollableOptions.scrollPositionX;
  39173. }
  39174. if (scrollableOptions.scrollPositionY) {
  39175. this.scrollingContainer.scrollTop =
  39176. this.scrollablePixelsY *
  39177. scrollableOptions.scrollPositionY;
  39178. }
  39179. }
  39180. // Mask behind the left and right side
  39181. var axisOffset = this.axisOffset,
  39182. maskTop = this.plotTop - axisOffset[0] - 1,
  39183. maskLeft = this.plotLeft - axisOffset[3] - 1,
  39184. maskBottom = this.plotTop + this.plotHeight + axisOffset[2] + 1,
  39185. maskRight = this.plotLeft + this.plotWidth + axisOffset[1] + 1,
  39186. maskPlotRight = this.plotLeft + this.plotWidth -
  39187. (this.scrollablePixelsX || 0),
  39188. maskPlotBottom = this.plotTop + this.plotHeight -
  39189. (this.scrollablePixelsY || 0),
  39190. d;
  39191. if (this.scrollablePixelsX) {
  39192. d = [
  39193. // Left side
  39194. ['M', 0, maskTop],
  39195. ['L', this.plotLeft - 1, maskTop],
  39196. ['L', this.plotLeft - 1, maskBottom],
  39197. ['L', 0, maskBottom],
  39198. ['Z'],
  39199. // Right side
  39200. ['M', maskPlotRight, maskTop],
  39201. ['L', this.chartWidth, maskTop],
  39202. ['L', this.chartWidth, maskBottom],
  39203. ['L', maskPlotRight, maskBottom],
  39204. ['Z']
  39205. ];
  39206. }
  39207. else if (this.scrollablePixelsY) {
  39208. d = [
  39209. // Top side
  39210. ['M', maskLeft, 0],
  39211. ['L', maskLeft, this.plotTop - 1],
  39212. ['L', maskRight, this.plotTop - 1],
  39213. ['L', maskRight, 0],
  39214. ['Z'],
  39215. // Bottom side
  39216. ['M', maskLeft, maskPlotBottom],
  39217. ['L', maskLeft, this.chartHeight],
  39218. ['L', maskRight, this.chartHeight],
  39219. ['L', maskRight, maskPlotBottom],
  39220. ['Z']
  39221. ];
  39222. }
  39223. else {
  39224. d = [['M', 0, 0]];
  39225. }
  39226. if (this.redrawTrigger !== 'adjustHeight') {
  39227. this.scrollableMask.attr({ d: d });
  39228. }
  39229. };
  39230. addEvent(Axis, 'afterInit', function () {
  39231. this.chart.scrollableDirty = true;
  39232. });
  39233. addEvent(Series, 'show', function () {
  39234. this.chart.scrollableDirty = true;
  39235. });
  39236. /* *
  39237. *
  39238. * API Declarations
  39239. *
  39240. * */
  39241. /**
  39242. * Options for a scrollable plot area. This feature provides a minimum size for
  39243. * the plot area of the chart. If the size gets smaller than this, typically
  39244. * on mobile devices, a native browser scrollbar is presented. This scrollbar
  39245. * provides smooth scrolling for the contents of the plot area, whereas the
  39246. * title, legend and unaffected axes are fixed.
  39247. *
  39248. * Since v7.1.2, a scrollable plot area can be defined for either horizontal or
  39249. * vertical scrolling, depending on whether the `minWidth` or `minHeight`
  39250. * option is set.
  39251. *
  39252. * @sample highcharts/chart/scrollable-plotarea
  39253. * Scrollable plot area
  39254. * @sample highcharts/chart/scrollable-plotarea-vertical
  39255. * Vertically scrollable plot area
  39256. * @sample {gantt} highcharts/chart/scrollable-plotarea-vertical
  39257. * Gantt chart with vertically scrollable plot area
  39258. *
  39259. * @since 6.1.0
  39260. * @product highcharts gantt
  39261. * @apioption chart.scrollablePlotArea
  39262. */
  39263. /**
  39264. * The minimum height for the plot area. If it gets smaller than this, the plot
  39265. * area will become scrollable.
  39266. *
  39267. * @type {number}
  39268. * @apioption chart.scrollablePlotArea.minHeight
  39269. */
  39270. /**
  39271. * The minimum width for the plot area. If it gets smaller than this, the plot
  39272. * area will become scrollable.
  39273. *
  39274. * @type {number}
  39275. * @apioption chart.scrollablePlotArea.minWidth
  39276. */
  39277. /**
  39278. * The initial scrolling position of the scrollable plot area. Ranges from 0 to
  39279. * 1, where 0 aligns the plot area to the left and 1 aligns it to the right.
  39280. * Typically we would use 1 if the chart has right aligned Y axes.
  39281. *
  39282. * @type {number}
  39283. * @apioption chart.scrollablePlotArea.scrollPositionX
  39284. */
  39285. /**
  39286. * The initial scrolling position of the scrollable plot area. Ranges from 0 to
  39287. * 1, where 0 aligns the plot area to the top and 1 aligns it to the bottom.
  39288. *
  39289. * @type {number}
  39290. * @apioption chart.scrollablePlotArea.scrollPositionY
  39291. */
  39292. /**
  39293. * The opacity of mask applied on one of the sides of the plot
  39294. * area.
  39295. *
  39296. * @sample {highcharts} highcharts/chart/scrollable-plotarea-opacity
  39297. * Disabled opacity for the mask
  39298. *
  39299. * @type {number}
  39300. * @default 0.85
  39301. * @since 7.1.1
  39302. * @apioption chart.scrollablePlotArea.opacity
  39303. */
  39304. (''); // keep doclets above in transpiled file
  39305. });
  39306. _registerModule(_modules, 'Core/Axis/StackingAxis.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Utilities.js']], function (A, U) {
  39307. /* *
  39308. *
  39309. * (c) 2010-2021 Torstein Honsi
  39310. *
  39311. * License: www.highcharts.com/license
  39312. *
  39313. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  39314. *
  39315. * */
  39316. var getDeferredAnimation = A.getDeferredAnimation;
  39317. var addEvent = U.addEvent,
  39318. destroyObjectProperties = U.destroyObjectProperties,
  39319. fireEvent = U.fireEvent,
  39320. isNumber = U.isNumber,
  39321. objectEach = U.objectEach,
  39322. pick = U.pick;
  39323. /* eslint-disable valid-jsdoc */
  39324. /**
  39325. * Adds stacking support to axes.
  39326. * @private
  39327. * @class
  39328. */
  39329. var StackingAxisAdditions = /** @class */ (function () {
  39330. /* *
  39331. *
  39332. * Constructors
  39333. *
  39334. * */
  39335. function StackingAxisAdditions(axis) {
  39336. this.oldStacks = {};
  39337. this.stacks = {};
  39338. this.stacksTouched = 0;
  39339. this.axis = axis;
  39340. }
  39341. /* *
  39342. *
  39343. * Functions
  39344. *
  39345. * */
  39346. /**
  39347. * Build the stacks from top down
  39348. * @private
  39349. */
  39350. StackingAxisAdditions.prototype.buildStacks = function () {
  39351. var stacking = this;
  39352. var axis = stacking.axis;
  39353. var axisSeries = axis.series;
  39354. var reversedStacks = axis.options.reversedStacks;
  39355. var len = axisSeries.length;
  39356. var actualSeries,
  39357. i;
  39358. if (!axis.isXAxis) {
  39359. stacking.usePercentage = false;
  39360. i = len;
  39361. while (i--) {
  39362. actualSeries = axisSeries[reversedStacks ? i : len - i - 1];
  39363. actualSeries.setStackedPoints();
  39364. actualSeries.setGroupedPoints();
  39365. }
  39366. // Loop up again to compute percent and stream stack
  39367. for (i = 0; i < len; i++) {
  39368. axisSeries[i].modifyStacks();
  39369. }
  39370. fireEvent(axis, 'afterBuildStacks');
  39371. }
  39372. };
  39373. /**
  39374. * @private
  39375. */
  39376. StackingAxisAdditions.prototype.cleanStacks = function () {
  39377. var stacking = this;
  39378. var axis = stacking.axis;
  39379. var stacks;
  39380. if (!axis.isXAxis) {
  39381. if (stacking.oldStacks) {
  39382. stacks = stacking.stacks = stacking.oldStacks;
  39383. }
  39384. // reset stacks
  39385. objectEach(stacks, function (type) {
  39386. objectEach(type, function (stack) {
  39387. stack.cumulative = stack.total;
  39388. });
  39389. });
  39390. }
  39391. };
  39392. /**
  39393. * Set all the stacks to initial states and destroy unused ones.
  39394. * @private
  39395. */
  39396. StackingAxisAdditions.prototype.resetStacks = function () {
  39397. var _this = this;
  39398. var _a = this,
  39399. axis = _a.axis,
  39400. stacks = _a.stacks;
  39401. if (!axis.isXAxis) {
  39402. objectEach(stacks, function (type) {
  39403. objectEach(type, function (stack, x) {
  39404. // Clean up memory after point deletion (#1044, #4320)
  39405. if (isNumber(stack.touched) &&
  39406. stack.touched < _this.stacksTouched) {
  39407. stack.destroy();
  39408. delete type[x];
  39409. // Reset stacks
  39410. }
  39411. else {
  39412. stack.total = null;
  39413. stack.cumulative = null;
  39414. }
  39415. });
  39416. });
  39417. }
  39418. };
  39419. /**
  39420. * @private
  39421. */
  39422. StackingAxisAdditions.prototype.renderStackTotals = function () {
  39423. var stacking = this;
  39424. var axis = stacking.axis;
  39425. var chart = axis.chart;
  39426. var renderer = chart.renderer;
  39427. var stacks = stacking.stacks;
  39428. var stackLabelsAnim = axis.options.stackLabels && axis.options.stackLabels.animation;
  39429. var animationConfig = getDeferredAnimation(chart,
  39430. stackLabelsAnim || false);
  39431. var stackTotalGroup = stacking.stackTotalGroup = (stacking.stackTotalGroup ||
  39432. renderer
  39433. .g('stack-labels')
  39434. .attr({
  39435. visibility: 'visible',
  39436. zIndex: 6,
  39437. opacity: 0
  39438. })
  39439. .add());
  39440. // plotLeft/Top will change when y axis gets wider so we need to
  39441. // translate the stackTotalGroup at every render call. See bug #506
  39442. // and #516
  39443. stackTotalGroup.translate(chart.plotLeft, chart.plotTop);
  39444. // Render each stack total
  39445. objectEach(stacks, function (type) {
  39446. objectEach(type, function (stack) {
  39447. stack.render(stackTotalGroup);
  39448. });
  39449. });
  39450. stackTotalGroup.animate({
  39451. opacity: 1
  39452. }, animationConfig);
  39453. };
  39454. return StackingAxisAdditions;
  39455. }());
  39456. /**
  39457. * Axis with stacking support.
  39458. * @private
  39459. * @class
  39460. */
  39461. var StackingAxis = /** @class */ (function () {
  39462. function StackingAxis() {
  39463. }
  39464. /* *
  39465. *
  39466. * Static Functions
  39467. *
  39468. * */
  39469. /**
  39470. * Extends axis with stacking support.
  39471. * @private
  39472. */
  39473. StackingAxis.compose = function (AxisClass) {
  39474. var axisProto = AxisClass.prototype;
  39475. addEvent(AxisClass, 'init', StackingAxis.onInit);
  39476. addEvent(AxisClass, 'destroy', StackingAxis.onDestroy);
  39477. };
  39478. /**
  39479. * @private
  39480. */
  39481. StackingAxis.onDestroy = function () {
  39482. var stacking = this.stacking;
  39483. if (!stacking) {
  39484. return;
  39485. }
  39486. var stacks = stacking.stacks;
  39487. // Destroy each stack total
  39488. objectEach(stacks, function (stack, stackKey) {
  39489. destroyObjectProperties(stack);
  39490. stacks[stackKey] = null;
  39491. });
  39492. if (stacking &&
  39493. stacking.stackTotalGroup) {
  39494. stacking.stackTotalGroup.destroy();
  39495. }
  39496. };
  39497. /**
  39498. * @private
  39499. */
  39500. StackingAxis.onInit = function () {
  39501. var axis = this;
  39502. if (!axis.stacking) {
  39503. axis.stacking = new StackingAxisAdditions(axis);
  39504. }
  39505. };
  39506. return StackingAxis;
  39507. }());
  39508. return StackingAxis;
  39509. });
  39510. _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) {
  39511. /* *
  39512. *
  39513. * (c) 2010-2021 Torstein Honsi
  39514. *
  39515. * License: www.highcharts.com/license
  39516. *
  39517. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  39518. *
  39519. * */
  39520. var format = F.format;
  39521. var correctFloat = U.correctFloat,
  39522. defined = U.defined,
  39523. destroyObjectProperties = U.destroyObjectProperties,
  39524. isArray = U.isArray,
  39525. isNumber = U.isNumber,
  39526. objectEach = U.objectEach,
  39527. pick = U.pick;
  39528. /* *
  39529. *
  39530. * Class
  39531. *
  39532. * */
  39533. /* eslint-disable no-invalid-this, valid-jsdoc */
  39534. /**
  39535. * The class for stacks. Each stack, on a specific X value and either negative
  39536. * or positive, has its own stack item.
  39537. *
  39538. * @private
  39539. * @class
  39540. * @name Highcharts.StackItem
  39541. * @param {Highcharts.Axis} axis
  39542. * @param {Highcharts.YAxisStackLabelsOptions} options
  39543. * @param {boolean} isNegative
  39544. * @param {number} x
  39545. * @param {Highcharts.OptionsStackingValue} [stackOption]
  39546. */
  39547. var StackItem = /** @class */ (function () {
  39548. function StackItem(axis, options, isNegative, x, stackOption) {
  39549. var inverted = axis.chart.inverted;
  39550. this.axis = axis;
  39551. // Tells if the stack is negative
  39552. this.isNegative = isNegative;
  39553. // Save the options to be able to style the label
  39554. this.options = options = options || {};
  39555. // Save the x value to be able to position the label later
  39556. this.x = x;
  39557. // Initialize total value
  39558. this.total = null;
  39559. // This will keep each points' extremes stored by series.index and point
  39560. // index
  39561. this.points = {};
  39562. this.hasValidPoints = false;
  39563. // Save the stack option on the series configuration object,
  39564. // and whether to treat it as percent
  39565. this.stack = stackOption;
  39566. this.leftCliff = 0;
  39567. this.rightCliff = 0;
  39568. // The align options and text align varies on whether the stack is
  39569. // negative and if the chart is inverted or not.
  39570. // First test the user supplied value, then use the dynamic.
  39571. this.alignOptions = {
  39572. align: options.align ||
  39573. (inverted ? (isNegative ? 'left' : 'right') : 'center'),
  39574. verticalAlign: options.verticalAlign ||
  39575. (inverted ? 'middle' : (isNegative ? 'bottom' : 'top')),
  39576. y: options.y,
  39577. x: options.x
  39578. };
  39579. this.textAlign = options.textAlign ||
  39580. (inverted ? (isNegative ? 'right' : 'left') : 'center');
  39581. }
  39582. /**
  39583. * @private
  39584. * @function Highcharts.StackItem#destroy
  39585. */
  39586. StackItem.prototype.destroy = function () {
  39587. destroyObjectProperties(this, this.axis);
  39588. };
  39589. /**
  39590. * Renders the stack total label and adds it to the stack label group.
  39591. *
  39592. * @private
  39593. * @function Highcharts.StackItem#render
  39594. * @param {Highcharts.SVGElement} group
  39595. */
  39596. StackItem.prototype.render = function (group) {
  39597. var chart = this.axis.chart,
  39598. options = this.options,
  39599. formatOption = options.format,
  39600. attr = {},
  39601. str = formatOption ? // format the text in the label
  39602. format(formatOption,
  39603. this,
  39604. chart) :
  39605. options.formatter.call(this);
  39606. // Change the text to reflect the new total and set visibility to hidden
  39607. // in case the serie is hidden
  39608. if (this.label) {
  39609. this.label.attr({ text: str, visibility: 'hidden' });
  39610. }
  39611. else {
  39612. // Create new label
  39613. this.label = chart.renderer
  39614. .label(str, null, null, options.shape, null, null, options.useHTML, false, 'stack-labels');
  39615. attr = {
  39616. r: options.borderRadius || 0,
  39617. text: str,
  39618. rotation: options.rotation,
  39619. padding: pick(options.padding, 5),
  39620. visibility: 'hidden' // hidden until setOffset is called
  39621. };
  39622. if (!chart.styledMode) {
  39623. attr.fill = options.backgroundColor;
  39624. attr.stroke = options.borderColor;
  39625. attr['stroke-width'] = options.borderWidth;
  39626. this.label.css(options.style);
  39627. }
  39628. this.label.attr(attr);
  39629. if (!this.label.added) {
  39630. this.label.add(group); // add to the labels-group
  39631. }
  39632. }
  39633. // Rank it higher than data labels (#8742)
  39634. this.label.labelrank = chart.plotSizeY;
  39635. };
  39636. /**
  39637. * Sets the offset that the stack has from the x value and repositions the
  39638. * label.
  39639. *
  39640. * @private
  39641. * @function Highcarts.StackItem#setOffset
  39642. * @param {number} xOffset
  39643. * @param {number} xWidth
  39644. * @param {number} [boxBottom]
  39645. * @param {number} [boxTop]
  39646. * @param {number} [defaultX]
  39647. */
  39648. StackItem.prototype.setOffset = function (xOffset, xWidth, boxBottom, boxTop, defaultX) {
  39649. var stackItem = this,
  39650. axis = stackItem.axis,
  39651. chart = axis.chart,
  39652. // stack value translated mapped to chart coordinates
  39653. y = axis.translate(axis.stacking.usePercentage ?
  39654. 100 :
  39655. (boxTop ?
  39656. boxTop :
  39657. stackItem.total), 0, 0, 0, 1),
  39658. yZero = axis.translate(boxBottom ? boxBottom : 0), // stack origin
  39659. // stack height:
  39660. h = defined(y) && Math.abs(y - yZero),
  39661. // x position:
  39662. x = pick(defaultX,
  39663. chart.xAxis[0].translate(stackItem.x)) +
  39664. xOffset,
  39665. stackBox = defined(y) && stackItem.getStackBox(chart,
  39666. stackItem,
  39667. x,
  39668. y,
  39669. xWidth,
  39670. h,
  39671. axis),
  39672. label = stackItem.label,
  39673. isNegative = stackItem.isNegative,
  39674. isJustify = pick(stackItem.options.overflow, 'justify') === 'justify',
  39675. textAlign = stackItem.textAlign,
  39676. visible;
  39677. if (label && stackBox) {
  39678. var bBox = label.getBBox(),
  39679. padding = label.padding,
  39680. boxOffsetX = void 0,
  39681. boxOffsetY = void 0;
  39682. if (textAlign === 'left') {
  39683. boxOffsetX = chart.inverted ? -padding : padding;
  39684. }
  39685. else if (textAlign === 'right') {
  39686. boxOffsetX = bBox.width;
  39687. }
  39688. else {
  39689. if (chart.inverted && textAlign === 'center') {
  39690. boxOffsetX = bBox.width / 2;
  39691. }
  39692. else {
  39693. boxOffsetX = chart.inverted ?
  39694. (isNegative ? bBox.width + padding : -padding) : bBox.width / 2;
  39695. }
  39696. }
  39697. boxOffsetY = chart.inverted ?
  39698. bBox.height / 2 : (isNegative ? -padding : bBox.height);
  39699. // Reset alignOptions property after justify #12337
  39700. stackItem.alignOptions.x = pick(stackItem.options.x, 0);
  39701. stackItem.alignOptions.y = pick(stackItem.options.y, 0);
  39702. // Set the stackBox position
  39703. stackBox.x -= boxOffsetX;
  39704. stackBox.y -= boxOffsetY;
  39705. // Align the label to the box
  39706. label.align(stackItem.alignOptions, null, stackBox);
  39707. // Check if label is inside the plotArea #12294
  39708. if (chart.isInsidePlot(label.alignAttr.x + boxOffsetX - stackItem.alignOptions.x, label.alignAttr.y + boxOffsetY - stackItem.alignOptions.y)) {
  39709. label.show();
  39710. }
  39711. else {
  39712. // Move label away to avoid the overlapping issues
  39713. label.alignAttr.y = -9999;
  39714. isJustify = false;
  39715. }
  39716. if (isJustify) {
  39717. // Justify stackLabel into the stackBox
  39718. Series.prototype.justifyDataLabel.call(this.axis, label, stackItem.alignOptions, label.alignAttr, bBox, stackBox);
  39719. }
  39720. label.attr({
  39721. x: label.alignAttr.x,
  39722. y: label.alignAttr.y
  39723. });
  39724. if (pick(!isJustify && stackItem.options.crop, true)) {
  39725. visible =
  39726. isNumber(label.x) &&
  39727. isNumber(label.y) &&
  39728. chart.isInsidePlot(label.x - padding + label.width, label.y) &&
  39729. chart.isInsidePlot(label.x + padding, label.y);
  39730. if (!visible) {
  39731. label.hide();
  39732. }
  39733. }
  39734. }
  39735. };
  39736. /**
  39737. * @private
  39738. * @function Highcharts.StackItem#getStackBox
  39739. *
  39740. * @param {Highcharts.Chart} chart
  39741. *
  39742. * @param {Highcharts.StackItem} stackItem
  39743. *
  39744. * @param {number} x
  39745. *
  39746. * @param {number} y
  39747. *
  39748. * @param {number} xWidth
  39749. *
  39750. * @param {number} h
  39751. *
  39752. * @param {Highcharts.Axis} axis
  39753. *
  39754. * @return {Highcharts.BBoxObject}
  39755. */
  39756. StackItem.prototype.getStackBox = function (chart, stackItem, x, y, xWidth, h, axis) {
  39757. var reversed = stackItem.axis.reversed,
  39758. inverted = chart.inverted,
  39759. axisPos = axis.height + axis.pos -
  39760. (inverted ? chart.plotLeft : chart.plotTop),
  39761. neg = (stackItem.isNegative && !reversed) ||
  39762. (!stackItem.isNegative && reversed); // #4056
  39763. return {
  39764. x: inverted ? (neg ? y - axis.right : y - h + axis.pos - chart.plotLeft) :
  39765. x + chart.xAxis[0].transB - chart.plotLeft,
  39766. y: inverted ?
  39767. axis.height - x - xWidth :
  39768. (neg ?
  39769. (axisPos - y - h) :
  39770. axisPos - y),
  39771. width: inverted ? h : xWidth,
  39772. height: inverted ? xWidth : h
  39773. };
  39774. };
  39775. return StackItem;
  39776. }());
  39777. /**
  39778. * Generate stacks for each series and calculate stacks total values
  39779. *
  39780. * @private
  39781. * @function Highcharts.Chart#getStacks
  39782. */
  39783. Chart.prototype.getStacks = function () {
  39784. var chart = this,
  39785. inverted = chart.inverted;
  39786. // reset stacks for each yAxis
  39787. chart.yAxis.forEach(function (axis) {
  39788. if (axis.stacking && axis.stacking.stacks && axis.hasVisibleSeries) {
  39789. axis.stacking.oldStacks = axis.stacking.stacks;
  39790. }
  39791. });
  39792. chart.series.forEach(function (series) {
  39793. var xAxisOptions = series.xAxis && series.xAxis.options || {};
  39794. if (series.options.stacking &&
  39795. (series.visible === true ||
  39796. chart.options.chart.ignoreHiddenSeries === false)) {
  39797. series.stackKey = [
  39798. series.type,
  39799. pick(series.options.stack, ''),
  39800. inverted ? xAxisOptions.top : xAxisOptions.left,
  39801. inverted ? xAxisOptions.height : xAxisOptions.width
  39802. ].join(',');
  39803. }
  39804. });
  39805. };
  39806. // Stacking methods defined on the Axis prototype
  39807. StackingAxis.compose(Axis);
  39808. // Stacking methods defined for Series prototype
  39809. /**
  39810. * Set grouped points in a stack-like object. When `centerInCategory` is true,
  39811. * and `stacking` is not enabled, we need a pseudo (horizontal) stack in order
  39812. * to handle grouping of points within the same category.
  39813. *
  39814. * @private
  39815. * @function Highcharts.Series#setStackedPoints
  39816. * @return {void}
  39817. */
  39818. Series.prototype.setGroupedPoints = function () {
  39819. var stacking = this.yAxis.stacking;
  39820. if (this.options.centerInCategory &&
  39821. (this.is('column') || this.is('columnrange')) &&
  39822. // With stacking enabled, we already have stacks that we can compute
  39823. // from
  39824. !this.options.stacking &&
  39825. // With only one series, we don't need to consider centerInCategory
  39826. this.chart.series.length > 1) {
  39827. Series.prototype.setStackedPoints.call(this, 'group');
  39828. // After updating, if we now have proper stacks, we must delete the group
  39829. // pseudo stacks (#14986)
  39830. }
  39831. else if (stacking) {
  39832. objectEach(stacking.stacks, function (type, key) {
  39833. if (key.slice(-5) === 'group') {
  39834. objectEach(type, function (stack) { return stack.destroy(); });
  39835. delete stacking.stacks[key];
  39836. }
  39837. });
  39838. }
  39839. };
  39840. /**
  39841. * Adds series' points value to corresponding stack
  39842. *
  39843. * @private
  39844. * @function Highcharts.Series#setStackedPoints
  39845. */
  39846. Series.prototype.setStackedPoints = function (stackingParam) {
  39847. var stacking = stackingParam || this.options.stacking;
  39848. if (!stacking || (this.visible !== true &&
  39849. this.chart.options.chart.ignoreHiddenSeries !== false)) {
  39850. return;
  39851. }
  39852. 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;
  39853. yAxis.stacking.stacksTouched += 1;
  39854. // loop over the non-null y values and read them into a local array
  39855. for (i = 0; i < yDataLength; i++) {
  39856. x = xData[i];
  39857. y = yData[i];
  39858. stackIndicator = series.getStackIndicator(stackIndicator, x, series.index);
  39859. pointKey = stackIndicator.key;
  39860. // Read stacked values into a stack based on the x value,
  39861. // the sign of y and the stack key. Stacking is also handled for null
  39862. // values (#739)
  39863. isNegative = negStacks && y < (stackThreshold ? 0 : threshold);
  39864. key = isNegative ? negKey : stackKey;
  39865. // Create empty object for this stack if it doesn't exist yet
  39866. if (!stacks[key]) {
  39867. stacks[key] = {};
  39868. }
  39869. // Initialize StackItem for this x
  39870. if (!stacks[key][x]) {
  39871. if (oldStacks[key] &&
  39872. oldStacks[key][x]) {
  39873. stacks[key][x] = oldStacks[key][x];
  39874. stacks[key][x].total = null;
  39875. }
  39876. else {
  39877. stacks[key][x] = new StackItem(yAxis, yAxis.options.stackLabels, isNegative, x, stackOption);
  39878. }
  39879. }
  39880. // If the StackItem doesn't exist, create it first
  39881. stack = stacks[key][x];
  39882. if (y !== null) {
  39883. stack.points[pointKey] = stack.points[series.index] =
  39884. [pick(stack.cumulative, stackThreshold)];
  39885. // Record the base of the stack
  39886. if (!defined(stack.cumulative)) {
  39887. stack.base = pointKey;
  39888. }
  39889. stack.touched = yAxis.stacking.stacksTouched;
  39890. // In area charts, if there are multiple points on the same X value,
  39891. // let the area fill the full span of those points
  39892. if (stackIndicator.index > 0 && series.singleStacks === false) {
  39893. stack.points[pointKey][0] =
  39894. stack.points[series.index + ',' + x + ',0'][0];
  39895. }
  39896. // When updating to null, reset the point stack (#7493)
  39897. }
  39898. else {
  39899. stack.points[pointKey] = stack.points[series.index] =
  39900. null;
  39901. }
  39902. // Add value to the stack total
  39903. if (stacking === 'percent') {
  39904. // Percent stacked column, totals are the same for the positive and
  39905. // negative stacks
  39906. other = isNegative ? stackKey : negKey;
  39907. if (negStacks && stacks[other] && stacks[other][x]) {
  39908. other = stacks[other][x];
  39909. stack.total = other.total =
  39910. Math.max(other.total, stack.total) +
  39911. Math.abs(y) ||
  39912. 0;
  39913. // Percent stacked areas
  39914. }
  39915. else {
  39916. stack.total =
  39917. correctFloat(stack.total + (Math.abs(y) || 0));
  39918. }
  39919. }
  39920. else if (stacking === 'group') {
  39921. if (isArray(y)) {
  39922. y = y[0];
  39923. }
  39924. // In this stack, the total is the number of valid points
  39925. if (y !== null) {
  39926. stack.total = (stack.total || 0) + 1;
  39927. }
  39928. }
  39929. else {
  39930. stack.total = correctFloat(stack.total + (y || 0));
  39931. }
  39932. if (stacking === 'group') {
  39933. // This point's index within the stack, pushed to stack.points[1]
  39934. stack.cumulative = (stack.total || 1) - 1;
  39935. }
  39936. else {
  39937. stack.cumulative =
  39938. pick(stack.cumulative, stackThreshold) + (y || 0);
  39939. }
  39940. if (y !== null) {
  39941. stack.points[pointKey].push(stack.cumulative);
  39942. stackedYData[i] = stack.cumulative;
  39943. stack.hasValidPoints = true;
  39944. }
  39945. }
  39946. if (stacking === 'percent') {
  39947. yAxis.stacking.usePercentage = true;
  39948. }
  39949. if (stacking !== 'group') {
  39950. this.stackedYData = stackedYData; // To be used in getExtremes
  39951. }
  39952. // Reset old stacks
  39953. yAxis.stacking.oldStacks = {};
  39954. };
  39955. /**
  39956. * Iterate over all stacks and compute the absolute values to percent
  39957. *
  39958. * @private
  39959. * @function Highcharts.Series#modifyStacks
  39960. */
  39961. Series.prototype.modifyStacks = function () {
  39962. var series = this,
  39963. yAxis = series.yAxis,
  39964. stackKey = series.stackKey,
  39965. stacks = yAxis.stacking.stacks,
  39966. processedXData = series.processedXData,
  39967. stackIndicator,
  39968. stacking = series.options.stacking;
  39969. if (series[stacking + 'Stacker']) { // Modifier function exists
  39970. [stackKey, '-' + stackKey].forEach(function (key) {
  39971. var i = processedXData.length,
  39972. x,
  39973. stack,
  39974. pointExtremes;
  39975. while (i--) {
  39976. x = processedXData[i];
  39977. stackIndicator = series.getStackIndicator(stackIndicator, x, series.index, key);
  39978. stack = stacks[key] && stacks[key][x];
  39979. pointExtremes =
  39980. stack && stack.points[stackIndicator.key];
  39981. if (pointExtremes) {
  39982. series[stacking + 'Stacker'](pointExtremes, stack, i);
  39983. }
  39984. }
  39985. });
  39986. }
  39987. };
  39988. /**
  39989. * Modifier function for percent stacks. Blows up the stack to 100%.
  39990. *
  39991. * @private
  39992. * @function Highcharts.Series#percentStacker
  39993. */
  39994. Series.prototype.percentStacker = function (pointExtremes, stack, i) {
  39995. var totalFactor = stack.total ? 100 / stack.total : 0;
  39996. // Y bottom value
  39997. pointExtremes[0] = correctFloat(pointExtremes[0] * totalFactor);
  39998. // Y value
  39999. pointExtremes[1] = correctFloat(pointExtremes[1] * totalFactor);
  40000. this.stackedYData[i] = pointExtremes[1];
  40001. };
  40002. /**
  40003. * Get stack indicator, according to it's x-value, to determine points with the
  40004. * same x-value
  40005. *
  40006. * @private
  40007. * @function Highcharts.Series#getStackIndicator
  40008. * @param {Highcharts.StackItemIndicatorObject|undefined} stackIndicator
  40009. * @param {number} x
  40010. * @param {number} index
  40011. * @param {string} [key]
  40012. * @return {Highcharts.StackItemIndicatorObject}
  40013. */
  40014. Series.prototype.getStackIndicator = function (stackIndicator, x, index, key) {
  40015. // Update stack indicator, when:
  40016. // first point in a stack || x changed || stack type (negative vs positive)
  40017. // changed:
  40018. if (!defined(stackIndicator) ||
  40019. stackIndicator.x !== x ||
  40020. (key && stackIndicator.key !== key)) {
  40021. stackIndicator = {
  40022. x: x,
  40023. index: 0,
  40024. key: key
  40025. };
  40026. }
  40027. else {
  40028. (stackIndicator).index++;
  40029. }
  40030. stackIndicator.key =
  40031. [index, x, stackIndicator.index].join(',');
  40032. return stackIndicator;
  40033. };
  40034. H.StackItem = StackItem; // @todo -> master
  40035. /* *
  40036. *
  40037. * Default Export
  40038. *
  40039. * */
  40040. /**
  40041. * Stack of data points
  40042. *
  40043. * @product highcharts
  40044. *
  40045. * @interface Highcharts.StackItemObject
  40046. */ /**
  40047. * Alignment settings
  40048. * @name Highcharts.StackItemObject#alignOptions
  40049. * @type {Highcharts.AlignObject}
  40050. */ /**
  40051. * Related axis
  40052. * @name Highcharts.StackItemObject#axis
  40053. * @type {Highcharts.Axis}
  40054. */ /**
  40055. * Cumulative value of the stacked data points
  40056. * @name Highcharts.StackItemObject#cumulative
  40057. * @type {number}
  40058. */ /**
  40059. * True if on the negative side
  40060. * @name Highcharts.StackItemObject#isNegative
  40061. * @type {boolean}
  40062. */ /**
  40063. * Related SVG element
  40064. * @name Highcharts.StackItemObject#label
  40065. * @type {Highcharts.SVGElement}
  40066. */ /**
  40067. * Related stack options
  40068. * @name Highcharts.StackItemObject#options
  40069. * @type {Highcharts.YAxisStackLabelsOptions}
  40070. */ /**
  40071. * Total value of the stacked data points
  40072. * @name Highcharts.StackItemObject#total
  40073. * @type {number}
  40074. */ /**
  40075. * Shared x value of the stack
  40076. * @name Highcharts.StackItemObject#x
  40077. * @type {number}
  40078. */
  40079. ''; // keeps doclets above in JS file
  40080. return H.StackItem;
  40081. });
  40082. _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) {
  40083. /* *
  40084. *
  40085. * (c) 2010-2021 Torstein Honsi
  40086. *
  40087. * License: www.highcharts.com/license
  40088. *
  40089. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  40090. *
  40091. * */
  40092. var __extends = (this && this.__extends) || (function () {
  40093. var extendStatics = function (d,
  40094. b) {
  40095. extendStatics = Object.setPrototypeOf ||
  40096. ({ __proto__: [] } instanceof Array && function (d,
  40097. b) { d.__proto__ = b; }) ||
  40098. function (d,
  40099. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40100. return extendStatics(d, b);
  40101. };
  40102. return function (d, b) {
  40103. extendStatics(d, b);
  40104. function __() { this.constructor = d; }
  40105. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40106. };
  40107. })();
  40108. var defined = U.defined,
  40109. merge = U.merge;
  40110. /* *
  40111. *
  40112. * Class
  40113. *
  40114. * */
  40115. /**
  40116. * The line series is the base type and is therefor the series base prototype.
  40117. *
  40118. * @private
  40119. */
  40120. var LineSeries = /** @class */ (function (_super) {
  40121. __extends(LineSeries, _super);
  40122. function LineSeries() {
  40123. /* *
  40124. *
  40125. * Static Functions
  40126. *
  40127. * */
  40128. var _this = _super !== null && _super.apply(this,
  40129. arguments) || this;
  40130. /* *
  40131. *
  40132. * Properties
  40133. *
  40134. * */
  40135. _this.data = void 0;
  40136. _this.options = void 0;
  40137. _this.points = void 0;
  40138. return _this;
  40139. }
  40140. /* *
  40141. *
  40142. * Functions
  40143. *
  40144. * */
  40145. /**
  40146. * Draw the graph. Called internally when rendering line-like series
  40147. * types. The first time it generates the `series.graph` item and
  40148. * optionally other series-wide items like `series.area` for area
  40149. * charts. On subsequent calls these items are updated with new
  40150. * positions and attributes.
  40151. *
  40152. * @function Highcharts.Series#drawGraph
  40153. */
  40154. LineSeries.prototype.drawGraph = function () {
  40155. var series = this,
  40156. options = this.options,
  40157. graphPath = (this.gappedPath || this.getGraphPath).call(this),
  40158. styledMode = this.chart.styledMode,
  40159. props = [[
  40160. 'graph',
  40161. 'highcharts-graph'
  40162. ]];
  40163. // Presentational properties
  40164. if (!styledMode) {
  40165. props[0].push((options.lineColor ||
  40166. this.color ||
  40167. palette.neutralColor20 // when colorByPoint = true
  40168. ), options.dashStyle);
  40169. }
  40170. props = series.getZonesGraphs(props);
  40171. // Draw the graph
  40172. props.forEach(function (prop, i) {
  40173. var graphKey = prop[0],
  40174. graph = series[graphKey],
  40175. verb = graph ? 'animate' : 'attr',
  40176. attribs;
  40177. if (graph) {
  40178. graph.endX = series.preventGraphAnimation ?
  40179. null :
  40180. graphPath.xMap;
  40181. graph.animate({ d: graphPath });
  40182. }
  40183. else if (graphPath.length) { // #1487
  40184. /**
  40185. * SVG element of area-based charts. Can be used for styling
  40186. * purposes. If zones are configured, this element will be
  40187. * hidden and replaced by multiple zone areas, accessible
  40188. * via `series['zone-area-x']` (where x is a number,
  40189. * starting with 0).
  40190. *
  40191. * @name Highcharts.Series#area
  40192. * @type {Highcharts.SVGElement|undefined}
  40193. */
  40194. /**
  40195. * SVG element of line-based charts. Can be used for styling
  40196. * purposes. If zones are configured, this element will be
  40197. * hidden and replaced by multiple zone lines, accessible
  40198. * via `series['zone-graph-x']` (where x is a number,
  40199. * starting with 0).
  40200. *
  40201. * @name Highcharts.Series#graph
  40202. * @type {Highcharts.SVGElement|undefined}
  40203. */
  40204. series[graphKey] = graph = series.chart.renderer
  40205. .path(graphPath)
  40206. .addClass(prop[1])
  40207. .attr({ zIndex: 1 }) // #1069
  40208. .add(series.group);
  40209. }
  40210. if (graph && !styledMode) {
  40211. attribs = {
  40212. 'stroke': prop[2],
  40213. 'stroke-width': options.lineWidth,
  40214. // Polygon series use filled graph
  40215. 'fill': (series.fillGraph && series.color) || 'none'
  40216. };
  40217. if (prop[3]) {
  40218. attribs.dashstyle = prop[3];
  40219. }
  40220. else if (options.linecap !== 'square') {
  40221. attribs['stroke-linecap'] =
  40222. attribs['stroke-linejoin'] = 'round';
  40223. }
  40224. graph[verb](attribs)
  40225. // Add shadow to normal series (0) or to first
  40226. // zone (1) #3932
  40227. .shadow((i < 2) && options.shadow);
  40228. }
  40229. // Helpers for animation
  40230. if (graph) {
  40231. graph.startX = graphPath.xMap;
  40232. graph.isArea = graphPath.isArea; // For arearange animation
  40233. }
  40234. });
  40235. };
  40236. // eslint-disable-next-line valid-jsdoc
  40237. /**
  40238. * Get the graph path.
  40239. *
  40240. * @private
  40241. */
  40242. LineSeries.prototype.getGraphPath = function (points, nullsAsZeroes, connectCliffs) {
  40243. var series = this,
  40244. options = series.options,
  40245. step = options.step,
  40246. reversed,
  40247. graphPath = [],
  40248. xMap = [],
  40249. gap;
  40250. points = points || series.points;
  40251. // Bottom of a stack is reversed
  40252. reversed = points.reversed;
  40253. if (reversed) {
  40254. points.reverse();
  40255. }
  40256. // Reverse the steps (#5004)
  40257. step = {
  40258. right: 1,
  40259. center: 2
  40260. }[step] || (step && 3);
  40261. if (step && reversed) {
  40262. step = 4 - step;
  40263. }
  40264. // Remove invalid points, especially in spline (#5015)
  40265. points = this.getValidPoints(points, false, !(options.connectNulls && !nullsAsZeroes && !connectCliffs));
  40266. // Build the line
  40267. points.forEach(function (point, i) {
  40268. var plotX = point.plotX,
  40269. plotY = point.plotY,
  40270. lastPoint = points[i - 1],
  40271. // the path to this point from the previous
  40272. pathToPoint;
  40273. if ((point.leftCliff || (lastPoint && lastPoint.rightCliff)) &&
  40274. !connectCliffs) {
  40275. gap = true; // ... and continue
  40276. }
  40277. // Line series, nullsAsZeroes is not handled
  40278. if (point.isNull && !defined(nullsAsZeroes) && i > 0) {
  40279. gap = !options.connectNulls;
  40280. // Area series, nullsAsZeroes is set
  40281. }
  40282. else if (point.isNull && !nullsAsZeroes) {
  40283. gap = true;
  40284. }
  40285. else {
  40286. if (i === 0 || gap) {
  40287. pathToPoint = [[
  40288. 'M',
  40289. point.plotX,
  40290. point.plotY
  40291. ]];
  40292. // Generate the spline as defined in the SplineSeries object
  40293. }
  40294. else if (series.getPointSpline) {
  40295. pathToPoint = [series.getPointSpline(points, point, i)];
  40296. }
  40297. else if (step) {
  40298. if (step === 1) { // right
  40299. pathToPoint = [[
  40300. 'L',
  40301. lastPoint.plotX,
  40302. plotY
  40303. ]];
  40304. }
  40305. else if (step === 2) { // center
  40306. pathToPoint = [[
  40307. 'L',
  40308. (lastPoint.plotX + plotX) / 2,
  40309. lastPoint.plotY
  40310. ], [
  40311. 'L',
  40312. (lastPoint.plotX + plotX) / 2,
  40313. plotY
  40314. ]];
  40315. }
  40316. else {
  40317. pathToPoint = [[
  40318. 'L',
  40319. plotX,
  40320. lastPoint.plotY
  40321. ]];
  40322. }
  40323. pathToPoint.push([
  40324. 'L',
  40325. plotX,
  40326. plotY
  40327. ]);
  40328. }
  40329. else {
  40330. // normal line to next point
  40331. pathToPoint = [[
  40332. 'L',
  40333. plotX,
  40334. plotY
  40335. ]];
  40336. }
  40337. // Prepare for animation. When step is enabled, there are
  40338. // two path nodes for each x value.
  40339. xMap.push(point.x);
  40340. if (step) {
  40341. xMap.push(point.x);
  40342. if (step === 2) { // step = center (#8073)
  40343. xMap.push(point.x);
  40344. }
  40345. }
  40346. graphPath.push.apply(graphPath, pathToPoint);
  40347. gap = false;
  40348. }
  40349. });
  40350. graphPath.xMap = xMap;
  40351. series.graphPath = graphPath;
  40352. return graphPath;
  40353. };
  40354. // eslint-disable-next-line valid-jsdoc
  40355. /**
  40356. * Get zones properties for building graphs. Extendable by series with
  40357. * multiple lines within one series.
  40358. *
  40359. * @private
  40360. */
  40361. LineSeries.prototype.getZonesGraphs = function (props) {
  40362. // Add the zone properties if any
  40363. this.zones.forEach(function (zone, i) {
  40364. var propset = [
  40365. 'zone-graph-' + i,
  40366. 'highcharts-graph highcharts-zone-graph-' + i + ' ' +
  40367. (zone.className || '')
  40368. ];
  40369. if (!this.chart.styledMode) {
  40370. propset.push((zone.color || this.color), (zone.dashStyle || this.options.dashStyle));
  40371. }
  40372. props.push(propset);
  40373. }, this);
  40374. return props;
  40375. };
  40376. /**
  40377. * General options for all series types.
  40378. *
  40379. * @optionparent plotOptions.series
  40380. */
  40381. LineSeries.defaultOptions = merge(Series.defaultOptions, {
  40382. // nothing here yet
  40383. });
  40384. return LineSeries;
  40385. }(Series));
  40386. SeriesRegistry.registerSeriesType('line', LineSeries);
  40387. /* *
  40388. *
  40389. * Default Export
  40390. *
  40391. * */
  40392. /* *
  40393. *
  40394. * API Options
  40395. *
  40396. * */
  40397. /**
  40398. * A line series displays information as a series of data points connected by
  40399. * straight line segments.
  40400. *
  40401. * @sample {highcharts} highcharts/demo/line-basic/
  40402. * Line chart
  40403. * @sample {highstock} stock/demo/basic-line/
  40404. * Line chart
  40405. *
  40406. * @extends plotOptions.series
  40407. * @product highcharts highstock
  40408. * @apioption plotOptions.line
  40409. */
  40410. /**
  40411. * The SVG value used for the `stroke-linecap` and `stroke-linejoin`
  40412. * of a line graph. Round means that lines are rounded in the ends and
  40413. * bends.
  40414. *
  40415. * @type {Highcharts.SeriesLinecapValue}
  40416. * @default round
  40417. * @since 3.0.7
  40418. * @apioption plotOptions.line.linecap
  40419. */
  40420. /**
  40421. * A `line` series. If the [type](#series.line.type) option is not
  40422. * specified, it is inherited from [chart.type](#chart.type).
  40423. *
  40424. * @extends series,plotOptions.line
  40425. * @excluding dataParser,dataURL
  40426. * @product highcharts highstock
  40427. * @apioption series.line
  40428. */
  40429. /**
  40430. * An array of data points for the series. For the `line` series type,
  40431. * points can be given in the following ways:
  40432. *
  40433. * 1. An array of numerical values. In this case, the numerical values will be
  40434. * interpreted as `y` options. The `x` values will be automatically
  40435. * calculated, either starting at 0 and incremented by 1, or from
  40436. * `pointStart` and `pointInterval` given in the series options. If the axis
  40437. * has categories, these will be used. Example:
  40438. * ```js
  40439. * data: [0, 5, 3, 5]
  40440. * ```
  40441. *
  40442. * 2. An array of arrays with 2 values. In this case, the values correspond to
  40443. * `x,y`. If the first value is a string, it is applied as the name of the
  40444. * point, and the `x` value is inferred.
  40445. * ```js
  40446. * data: [
  40447. * [0, 1],
  40448. * [1, 2],
  40449. * [2, 8]
  40450. * ]
  40451. * ```
  40452. *
  40453. * 3. An array of objects with named values. The following snippet shows only a
  40454. * few settings, see the complete options set below. If the total number of
  40455. * data points exceeds the series'
  40456. * [turboThreshold](#series.line.turboThreshold),
  40457. * this option is not available.
  40458. * ```js
  40459. * data: [{
  40460. * x: 1,
  40461. * y: 9,
  40462. * name: "Point2",
  40463. * color: "#00FF00"
  40464. * }, {
  40465. * x: 1,
  40466. * y: 6,
  40467. * name: "Point1",
  40468. * color: "#FF00FF"
  40469. * }]
  40470. * ```
  40471. *
  40472. * **Note:** In TypeScript you have to extend `PointOptionsObject` with an
  40473. * additional declaration to allow custom data types:
  40474. * ```ts
  40475. * declare module `highcharts` {
  40476. * interface PointOptionsObject {
  40477. * custom: Record<string, (boolean|number|string)>;
  40478. * }
  40479. * }
  40480. * ```
  40481. *
  40482. * @sample {highcharts} highcharts/chart/reflow-true/
  40483. * Numerical values
  40484. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  40485. * Arrays of numeric x and y
  40486. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  40487. * Arrays of datetime x and y
  40488. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  40489. * Arrays of point.name and y
  40490. * @sample {highcharts} highcharts/series/data-array-of-objects/
  40491. * Config objects
  40492. *
  40493. * @declare Highcharts.PointOptionsObject
  40494. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  40495. * @apioption series.line.data
  40496. */
  40497. /**
  40498. * An additional, individual class name for the data point's graphic
  40499. * representation.
  40500. *
  40501. * @type {string}
  40502. * @since 5.0.0
  40503. * @product highcharts gantt
  40504. * @apioption series.line.data.className
  40505. */
  40506. /**
  40507. * Individual color for the point. By default the color is pulled from
  40508. * the global `colors` array.
  40509. *
  40510. * In styled mode, the `color` option doesn't take effect. Instead, use
  40511. * `colorIndex`.
  40512. *
  40513. * @sample {highcharts} highcharts/point/color/
  40514. * Mark the highest point
  40515. *
  40516. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  40517. * @product highcharts highstock gantt
  40518. * @apioption series.line.data.color
  40519. */
  40520. /**
  40521. * A specific color index to use for the point, so its graphic representations
  40522. * are given the class name `highcharts-color-{n}`. In styled mode this will
  40523. * change the color of the graphic. In non-styled mode, the color by is set by
  40524. * the `fill` attribute, so the change in class name won't have a visual effect
  40525. * by default.
  40526. *
  40527. * @type {number}
  40528. * @since 5.0.0
  40529. * @product highcharts gantt
  40530. * @apioption series.line.data.colorIndex
  40531. */
  40532. /**
  40533. * A reserved subspace to store options and values for customized functionality.
  40534. * Here you can add additional data for your own event callbacks and formatter
  40535. * callbacks.
  40536. *
  40537. * @sample {highcharts} highcharts/point/custom/
  40538. * Point and series with custom data
  40539. *
  40540. * @type {Highcharts.Dictionary<*>}
  40541. * @apioption series.line.data.custom
  40542. */
  40543. /**
  40544. * Individual data label for each point. The options are the same as
  40545. * the ones for [plotOptions.series.dataLabels](
  40546. * #plotOptions.series.dataLabels).
  40547. *
  40548. * @sample highcharts/point/datalabels/
  40549. * Show a label for the last value
  40550. *
  40551. * @declare Highcharts.DataLabelsOptions
  40552. * @extends plotOptions.line.dataLabels
  40553. * @product highcharts highstock gantt
  40554. * @apioption series.line.data.dataLabels
  40555. */
  40556. /**
  40557. * A description of the point to add to the screen reader information
  40558. * about the point.
  40559. *
  40560. * @type {string}
  40561. * @since 5.0.0
  40562. * @requires modules/accessibility
  40563. * @apioption series.line.data.description
  40564. */
  40565. /**
  40566. * An id for the point. This can be used after render time to get a
  40567. * pointer to the point object through `chart.get()`.
  40568. *
  40569. * @sample {highcharts} highcharts/point/id/
  40570. * Remove an id'd point
  40571. *
  40572. * @type {string}
  40573. * @since 1.2.0
  40574. * @product highcharts highstock gantt
  40575. * @apioption series.line.data.id
  40576. */
  40577. /**
  40578. * The rank for this point's data label in case of collision. If two
  40579. * data labels are about to overlap, only the one with the highest `labelrank`
  40580. * will be drawn.
  40581. *
  40582. * @type {number}
  40583. * @apioption series.line.data.labelrank
  40584. */
  40585. /**
  40586. * The name of the point as shown in the legend, tooltip, dataLabels, etc.
  40587. *
  40588. * @see [xAxis.uniqueNames](#xAxis.uniqueNames)
  40589. *
  40590. * @sample {highcharts} highcharts/series/data-array-of-objects/
  40591. * Point names
  40592. *
  40593. * @type {string}
  40594. * @apioption series.line.data.name
  40595. */
  40596. /**
  40597. * Whether the data point is selected initially.
  40598. *
  40599. * @type {boolean}
  40600. * @default false
  40601. * @product highcharts highstock gantt
  40602. * @apioption series.line.data.selected
  40603. */
  40604. /**
  40605. * The x value of the point. For datetime axes, the X value is the timestamp
  40606. * in milliseconds since 1970.
  40607. *
  40608. * @type {number}
  40609. * @product highcharts highstock
  40610. * @apioption series.line.data.x
  40611. */
  40612. /**
  40613. * The y value of the point.
  40614. *
  40615. * @type {number|null}
  40616. * @product highcharts highstock
  40617. * @apioption series.line.data.y
  40618. */
  40619. /**
  40620. * The individual point events.
  40621. *
  40622. * @extends plotOptions.series.point.events
  40623. * @product highcharts highstock gantt
  40624. * @apioption series.line.data.events
  40625. */
  40626. /**
  40627. * Options for the point markers of line-like series.
  40628. *
  40629. * @declare Highcharts.PointMarkerOptionsObject
  40630. * @extends plotOptions.series.marker
  40631. * @product highcharts highstock
  40632. * @apioption series.line.data.marker
  40633. */
  40634. ''; // include precedent doclets in transpilat
  40635. return LineSeries;
  40636. });
  40637. _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) {
  40638. /* *
  40639. *
  40640. * (c) 2010-2021 Torstein Honsi
  40641. *
  40642. * License: www.highcharts.com/license
  40643. *
  40644. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  40645. *
  40646. * */
  40647. var __extends = (this && this.__extends) || (function () {
  40648. var extendStatics = function (d,
  40649. b) {
  40650. extendStatics = Object.setPrototypeOf ||
  40651. ({ __proto__: [] } instanceof Array && function (d,
  40652. b) { d.__proto__ = b; }) ||
  40653. function (d,
  40654. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  40655. return extendStatics(d, b);
  40656. };
  40657. return function (d, b) {
  40658. extendStatics(d, b);
  40659. function __() { this.constructor = d; }
  40660. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  40661. };
  40662. })();
  40663. var color = Color.parse;
  40664. var LineSeries = SeriesRegistry.seriesTypes.line;
  40665. var extend = U.extend,
  40666. merge = U.merge,
  40667. objectEach = U.objectEach,
  40668. pick = U.pick;
  40669. /* *
  40670. *
  40671. * Class
  40672. *
  40673. * */
  40674. /**
  40675. * Area series type.
  40676. *
  40677. * @private
  40678. * @class
  40679. * @name AreaSeries
  40680. *
  40681. * @augments LineSeries
  40682. */
  40683. var AreaSeries = /** @class */ (function (_super) {
  40684. __extends(AreaSeries, _super);
  40685. function AreaSeries() {
  40686. /* *
  40687. *
  40688. * Static Properties
  40689. *
  40690. * */
  40691. var _this = _super !== null && _super.apply(this,
  40692. arguments) || this;
  40693. _this.data = void 0;
  40694. _this.options = void 0;
  40695. _this.points = void 0;
  40696. return _this;
  40697. /* eslint-enable valid-jsdoc */
  40698. }
  40699. /* *
  40700. *
  40701. * Functions
  40702. *
  40703. * */
  40704. /* eslint-disable valid-jsdoc */
  40705. /**
  40706. * Draw the graph and the underlying area. This method calls the Series
  40707. * base function and adds the area. The areaPath is calculated in the
  40708. * getSegmentPath method called from Series.prototype.drawGraph.
  40709. * @private
  40710. */
  40711. AreaSeries.prototype.drawGraph = function () {
  40712. // Define or reset areaPath
  40713. this.areaPath = [];
  40714. // Call the base method
  40715. _super.prototype.drawGraph.apply(this);
  40716. // Define local variables
  40717. var series = this,
  40718. areaPath = this.areaPath,
  40719. options = this.options,
  40720. zones = this.zones,
  40721. props = [[
  40722. 'area',
  40723. 'highcharts-area',
  40724. this.color,
  40725. options.fillColor
  40726. ]]; // area name, main color, fill color
  40727. zones.forEach(function (zone,
  40728. i) {
  40729. props.push([
  40730. 'zone-area-' + i,
  40731. 'highcharts-area highcharts-zone-area-' + i + ' ' +
  40732. zone.className,
  40733. zone.color || series.color,
  40734. zone.fillColor || options.fillColor
  40735. ]);
  40736. });
  40737. props.forEach(function (prop) {
  40738. var areaKey = prop[0],
  40739. area = series[areaKey],
  40740. verb = area ? 'animate' : 'attr',
  40741. attribs = {};
  40742. // Create or update the area
  40743. if (area) { // update
  40744. area.endX = series.preventGraphAnimation ?
  40745. null :
  40746. areaPath.xMap;
  40747. area.animate({ d: areaPath });
  40748. }
  40749. else { // create
  40750. attribs.zIndex = 0; // #1069
  40751. area = series[areaKey] = series.chart.renderer
  40752. .path(areaPath)
  40753. .addClass(prop[1])
  40754. .add(series.group);
  40755. area.isArea = true;
  40756. }
  40757. if (!series.chart.styledMode) {
  40758. attribs.fill = pick(prop[3], color(prop[2])
  40759. .setOpacity(pick(options.fillOpacity, 0.75))
  40760. .get());
  40761. }
  40762. area[verb](attribs);
  40763. area.startX = areaPath.xMap;
  40764. area.shiftUnit = options.step ? 2 : 1;
  40765. });
  40766. };
  40767. /**
  40768. * @private
  40769. */
  40770. AreaSeries.prototype.getGraphPath = function (points) {
  40771. 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
  40772. yAxis.getThreshold(options.threshold)), isNull, yBottom, connectNulls = pick(// #10574
  40773. options.connectNulls, stacking === 'percent'),
  40774. // To display null points in underlying stacked series, this
  40775. // series graph must be broken, and the area also fall down to
  40776. // fill the gap left by the null point. #2069
  40777. addDummyPoints = function (i, otherI, side) {
  40778. var point = points[i], stackedValues = stacking &&
  40779. stacks[point.x].points[seriesIndex], nullVal = point[side + 'Null'] || 0, cliffVal = point[side + 'Cliff'] || 0, top, bottom, isNull = true;
  40780. if (cliffVal || nullVal) {
  40781. top = (nullVal ?
  40782. stackedValues[0] :
  40783. stackedValues[1]) + cliffVal;
  40784. bottom = stackedValues[0] + cliffVal;
  40785. isNull = !!nullVal;
  40786. }
  40787. else if (!stacking &&
  40788. points[otherI] &&
  40789. points[otherI].isNull) {
  40790. top = bottom = threshold;
  40791. }
  40792. // Add to the top and bottom line of the area
  40793. if (typeof top !== 'undefined') {
  40794. graphPoints.push({
  40795. plotX: plotX,
  40796. plotY: top === null ?
  40797. translatedThreshold :
  40798. yAxis.getThreshold(top),
  40799. isNull: isNull,
  40800. isCliff: true
  40801. });
  40802. bottomPoints.push({
  40803. plotX: plotX,
  40804. plotY: bottom === null ?
  40805. translatedThreshold :
  40806. yAxis.getThreshold(bottom),
  40807. doCurve: false // #1041, gaps in areaspline areas
  40808. });
  40809. }
  40810. };
  40811. // Find what points to use
  40812. points = points || this.points;
  40813. // Fill in missing points
  40814. if (stacking) {
  40815. points = this.getStackPoints(points);
  40816. }
  40817. for (i = 0; i < points.length; i++) {
  40818. // Reset after series.update of stacking property (#12033)
  40819. if (!stacking) {
  40820. points[i].leftCliff = points[i].rightCliff =
  40821. points[i].leftNull = points[i].rightNull = void 0;
  40822. }
  40823. isNull = points[i].isNull;
  40824. plotX = pick(points[i].rectPlotX, points[i].plotX);
  40825. yBottom = stacking ? pick(points[i].yBottom, translatedThreshold) : translatedThreshold;
  40826. if (!isNull || connectNulls) {
  40827. if (!connectNulls) {
  40828. addDummyPoints(i, i - 1, 'left');
  40829. }
  40830. // Skip null point when stacking is false and connectNulls
  40831. // true
  40832. if (!(isNull && !stacking && connectNulls)) {
  40833. graphPoints.push(points[i]);
  40834. bottomPoints.push({
  40835. x: i,
  40836. plotX: plotX,
  40837. plotY: yBottom
  40838. });
  40839. }
  40840. if (!connectNulls) {
  40841. addDummyPoints(i, i + 1, 'right');
  40842. }
  40843. }
  40844. }
  40845. topPath = getGraphPath.call(this, graphPoints, true, true);
  40846. bottomPoints.reversed = true;
  40847. bottomPath = getGraphPath.call(this, bottomPoints, true, true);
  40848. var firstBottomPoint = bottomPath[0];
  40849. if (firstBottomPoint && firstBottomPoint[0] === 'M') {
  40850. bottomPath[0] = ['L', firstBottomPoint[1], firstBottomPoint[2]];
  40851. }
  40852. areaPath = topPath.concat(bottomPath);
  40853. if (areaPath.length) {
  40854. areaPath.push(['Z']);
  40855. }
  40856. // TODO: don't set leftCliff and rightCliff when connectNulls?
  40857. graphPath = getGraphPath
  40858. .call(this, graphPoints, false, connectNulls);
  40859. areaPath.xMap = topPath.xMap;
  40860. this.areaPath = areaPath;
  40861. return graphPath;
  40862. };
  40863. /**
  40864. * Return an array of stacked points, where null and missing points are
  40865. * replaced by dummy points in order for gaps to be drawn correctly in
  40866. * stacks.
  40867. * @private
  40868. */
  40869. AreaSeries.prototype.getStackPoints = function (points) {
  40870. var series = this,
  40871. segment = [],
  40872. keys = [],
  40873. xAxis = this.xAxis,
  40874. yAxis = this.yAxis,
  40875. stack = yAxis.stacking.stacks[this.stackKey],
  40876. pointMap = {},
  40877. yAxisSeries = yAxis.series,
  40878. seriesLength = yAxisSeries.length,
  40879. upOrDown = yAxis.options.reversedStacks ? 1 : -1,
  40880. seriesIndex = yAxisSeries.indexOf(series);
  40881. points = points || this.points;
  40882. if (this.options.stacking) {
  40883. for (var i = 0; i < points.length; i++) {
  40884. // Reset after point update (#7326)
  40885. points[i].leftNull = points[i].rightNull = void 0;
  40886. // Create a map where we can quickly look up the points by
  40887. // their X values.
  40888. pointMap[points[i].x] = points[i];
  40889. }
  40890. // Sort the keys (#1651)
  40891. objectEach(stack, function (stackX, x) {
  40892. // nulled after switching between
  40893. // grouping and not (#1651, #2336)
  40894. if (stackX.total !== null) {
  40895. keys.push(x);
  40896. }
  40897. });
  40898. keys.sort(function (a, b) {
  40899. return a - b;
  40900. });
  40901. var visibleSeries_1 = yAxisSeries.map(function (s) { return s.visible; });
  40902. keys.forEach(function (x, idx) {
  40903. var y = 0,
  40904. stackPoint,
  40905. stackedValues;
  40906. if (pointMap[x] && !pointMap[x].isNull) {
  40907. segment.push(pointMap[x]);
  40908. // Find left and right cliff. -1 goes left, 1 goes
  40909. // right.
  40910. [-1, 1].forEach(function (direction) {
  40911. var nullName = direction === 1 ?
  40912. 'rightNull' :
  40913. 'leftNull',
  40914. cliffName = direction === 1 ?
  40915. 'rightCliff' :
  40916. 'leftCliff',
  40917. cliff = 0,
  40918. otherStack = stack[keys[idx + direction]];
  40919. // If there is a stack next to this one,
  40920. // to the left or to the right...
  40921. if (otherStack) {
  40922. var i = seriesIndex;
  40923. // Can go either up or down,
  40924. // depending on reversedStacks
  40925. while (i >= 0 && i < seriesLength) {
  40926. var si = yAxisSeries[i].index;
  40927. stackPoint = otherStack.points[si];
  40928. if (!stackPoint) {
  40929. // If the next point in this series
  40930. // is missing, mark the point
  40931. // with point.leftNull or
  40932. // point.rightNull = true.
  40933. if (si === series.index) {
  40934. pointMap[x][nullName] = true;
  40935. // If there are missing points in
  40936. // the next stack in any of the
  40937. // series below this one, we need
  40938. // to substract the missing values
  40939. // and add a hiatus to the left or
  40940. // right.
  40941. }
  40942. else if (visibleSeries_1[i]) {
  40943. stackedValues =
  40944. stack[x].points[si];
  40945. if (stackedValues) {
  40946. cliff -= stackedValues[1] - stackedValues[0];
  40947. }
  40948. }
  40949. }
  40950. // When reversedStacks is true, loop up,
  40951. // else loop down
  40952. i += upOrDown;
  40953. }
  40954. }
  40955. pointMap[x][cliffName] = cliff;
  40956. });
  40957. // There is no point for this X value in this series, so we
  40958. // insert a dummy point in order for the areas to be drawn
  40959. // correctly.
  40960. }
  40961. else {
  40962. // Loop down the stack to find the series below this
  40963. // one that has a value (#1991)
  40964. var i = seriesIndex;
  40965. while (i >= 0 && i < seriesLength) {
  40966. var si = yAxisSeries[i].index;
  40967. stackPoint = stack[x].points[si];
  40968. if (stackPoint) {
  40969. y = stackPoint[1];
  40970. break;
  40971. }
  40972. // When reversedStacks is true, loop up, else loop
  40973. // down
  40974. i += upOrDown;
  40975. }
  40976. y = pick(y, 0);
  40977. y = yAxis.translate(// #6272
  40978. y, 0, 1, 0, 1);
  40979. segment.push({
  40980. isNull: true,
  40981. plotX: xAxis.translate(// #6272
  40982. x, 0, 0, 0, 1),
  40983. x: x,
  40984. plotY: y,
  40985. yBottom: y
  40986. });
  40987. }
  40988. });
  40989. }
  40990. return segment;
  40991. };
  40992. /**
  40993. * The area series type.
  40994. *
  40995. * @sample {highcharts} highcharts/demo/area-basic/
  40996. * Area chart
  40997. * @sample {highstock} stock/demo/area/
  40998. * Area chart
  40999. *
  41000. * @extends plotOptions.line
  41001. * @excluding useOhlcData
  41002. * @product highcharts highstock
  41003. * @optionparent plotOptions.area
  41004. */
  41005. AreaSeries.defaultOptions = merge(LineSeries.defaultOptions, {
  41006. /**
  41007. * @see [fillColor](#plotOptions.area.fillColor)
  41008. * @see [fillOpacity](#plotOptions.area.fillOpacity)
  41009. *
  41010. * @apioption plotOptions.area.color
  41011. */
  41012. /**
  41013. * Fill color or gradient for the area. When `null`, the series' `color`
  41014. * is used with the series' `fillOpacity`.
  41015. *
  41016. * In styled mode, the fill color can be set with the `.highcharts-area`
  41017. * class name.
  41018. *
  41019. * @see [color](#plotOptions.area.color)
  41020. * @see [fillOpacity](#plotOptions.area.fillOpacity)
  41021. *
  41022. * @sample {highcharts} highcharts/plotoptions/area-fillcolor-default/
  41023. * Null by default
  41024. * @sample {highcharts} highcharts/plotoptions/area-fillcolor-gradient/
  41025. * Gradient
  41026. *
  41027. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  41028. * @product highcharts highstock
  41029. * @apioption plotOptions.area.fillColor
  41030. */
  41031. /**
  41032. * Fill opacity for the area. When you set an explicit `fillColor`,
  41033. * the `fillOpacity` is not applied. Instead, you should define the
  41034. * opacity in the `fillColor` with an rgba color definition. The
  41035. * `fillOpacity` setting, also the default setting, overrides the alpha
  41036. * component of the `color` setting.
  41037. *
  41038. * In styled mode, the fill opacity can be set with the
  41039. * `.highcharts-area` class name.
  41040. *
  41041. * @see [color](#plotOptions.area.color)
  41042. * @see [fillColor](#plotOptions.area.fillColor)
  41043. *
  41044. * @sample {highcharts} highcharts/plotoptions/area-fillopacity/
  41045. * Automatic fill color and fill opacity of 0.1
  41046. *
  41047. * @type {number}
  41048. * @default {highcharts} 0.75
  41049. * @default {highstock} 0.75
  41050. * @product highcharts highstock
  41051. * @apioption plotOptions.area.fillOpacity
  41052. */
  41053. /**
  41054. * A separate color for the graph line. By default the line takes the
  41055. * `color` of the series, but the lineColor setting allows setting a
  41056. * separate color for the line without altering the `fillColor`.
  41057. *
  41058. * In styled mode, the line stroke can be set with the
  41059. * `.highcharts-graph` class name.
  41060. *
  41061. * @sample {highcharts} highcharts/plotoptions/area-linecolor/
  41062. * Dark gray line
  41063. *
  41064. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  41065. * @product highcharts highstock
  41066. * @apioption plotOptions.area.lineColor
  41067. */
  41068. /**
  41069. * A separate color for the negative part of the area.
  41070. *
  41071. * In styled mode, a negative color is set with the
  41072. * `.highcharts-negative` class name.
  41073. *
  41074. * @see [negativeColor](#plotOptions.area.negativeColor)
  41075. *
  41076. * @sample {highcharts} highcharts/css/series-negative-color/
  41077. * Negative color in styled mode
  41078. *
  41079. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  41080. * @since 3.0
  41081. * @product highcharts
  41082. * @apioption plotOptions.area.negativeFillColor
  41083. */
  41084. /**
  41085. * Whether the whole area or just the line should respond to mouseover
  41086. * tooltips and other mouse or touch events.
  41087. *
  41088. * @sample {highcharts|highstock} highcharts/plotoptions/area-trackbyarea/
  41089. * Display the tooltip when the area is hovered
  41090. *
  41091. * @type {boolean}
  41092. * @default false
  41093. * @since 1.1.6
  41094. * @product highcharts highstock
  41095. * @apioption plotOptions.area.trackByArea
  41096. */
  41097. /**
  41098. * The Y axis value to serve as the base for the area, for
  41099. * distinguishing between values above and below a threshold. The area
  41100. * between the graph and the threshold is filled.
  41101. *
  41102. * * If a number is given, the Y axis will scale to the threshold.
  41103. * * If `null`, the scaling behaves like a line series with fill between
  41104. * the graph and the Y axis minimum.
  41105. * * If `Infinity` or `-Infinity`, the area between the graph and the
  41106. * corresponding Y axis extreme is filled (since v6.1.0).
  41107. *
  41108. * @sample {highcharts} highcharts/plotoptions/area-threshold/
  41109. * A threshold of 100
  41110. * @sample {highcharts} highcharts/plotoptions/area-threshold-infinity/
  41111. * A threshold of Infinity
  41112. *
  41113. * @type {number|null}
  41114. * @since 2.0
  41115. * @product highcharts highstock
  41116. */
  41117. threshold: 0
  41118. });
  41119. return AreaSeries;
  41120. }(LineSeries));
  41121. extend(AreaSeries.prototype, {
  41122. singleStacks: false,
  41123. drawLegendSymbol: LegendSymbolMixin.drawRectangle
  41124. });
  41125. SeriesRegistry.registerSeriesType('area', AreaSeries);
  41126. /* *
  41127. *
  41128. * Default Export
  41129. *
  41130. * */
  41131. /* *
  41132. *
  41133. * API Options
  41134. *
  41135. * */
  41136. /**
  41137. * A `area` series. If the [type](#series.area.type) option is not
  41138. * specified, it is inherited from [chart.type](#chart.type).
  41139. *
  41140. * @extends series,plotOptions.area
  41141. * @excluding dataParser, dataURL, useOhlcData
  41142. * @product highcharts highstock
  41143. * @apioption series.area
  41144. */
  41145. /**
  41146. * @see [fillColor](#series.area.fillColor)
  41147. * @see [fillOpacity](#series.area.fillOpacity)
  41148. *
  41149. * @apioption series.area.color
  41150. */
  41151. /**
  41152. * An array of data points for the series. For the `area` series type,
  41153. * points can be given in the following ways:
  41154. *
  41155. * 1. An array of numerical values. In this case, the numerical values will be
  41156. * interpreted as `y` options. The `x` values will be automatically
  41157. * calculated, either starting at 0 and incremented by 1, or from
  41158. * `pointStart` * and `pointInterval` given in the series options. If the
  41159. * axis has categories, these will be used. Example:
  41160. * ```js
  41161. * data: [0, 5, 3, 5]
  41162. * ```
  41163. *
  41164. * 2. An array of arrays with 2 values. In this case, the values correspond to
  41165. * `x,y`. If the first value is a string, it is applied as the name of the
  41166. * point, and the `x` value is inferred.
  41167. * ```js
  41168. * data: [
  41169. * [0, 9],
  41170. * [1, 7],
  41171. * [2, 6]
  41172. * ]
  41173. * ```
  41174. *
  41175. * 3. An array of objects with named values. The following snippet shows only a
  41176. * few settings, see the complete options set below. If the total number of
  41177. * data points exceeds the series'
  41178. * [turboThreshold](#series.area.turboThreshold), this option is not
  41179. * available.
  41180. * ```js
  41181. * data: [{
  41182. * x: 1,
  41183. * y: 9,
  41184. * name: "Point2",
  41185. * color: "#00FF00"
  41186. * }, {
  41187. * x: 1,
  41188. * y: 6,
  41189. * name: "Point1",
  41190. * color: "#FF00FF"
  41191. * }]
  41192. * ```
  41193. *
  41194. * @sample {highcharts} highcharts/chart/reflow-true/
  41195. * Numerical values
  41196. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  41197. * Arrays of numeric x and y
  41198. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  41199. * Arrays of datetime x and y
  41200. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  41201. * Arrays of point.name and y
  41202. * @sample {highcharts} highcharts/series/data-array-of-objects/
  41203. * Config objects
  41204. *
  41205. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  41206. * @extends series.line.data
  41207. * @product highcharts highstock
  41208. * @apioption series.area.data
  41209. */
  41210. /**
  41211. * @see [color](#series.area.color)
  41212. * @see [fillOpacity](#series.area.fillOpacity)
  41213. *
  41214. * @apioption series.area.fillColor
  41215. */
  41216. /**
  41217. * @see [color](#series.area.color)
  41218. * @see [fillColor](#series.area.fillColor)
  41219. *
  41220. * @default {highcharts} 0.75
  41221. * @default {highstock} 0.75
  41222. * @apioption series.area.fillOpacity
  41223. */
  41224. ''; // adds doclets above to transpilat
  41225. return AreaSeries;
  41226. });
  41227. _registerModule(_modules, 'Series/Spline/SplineSeries.js', [_modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (SeriesRegistry, U) {
  41228. /* *
  41229. *
  41230. * (c) 2010-2021 Torstein Honsi
  41231. *
  41232. * License: www.highcharts.com/license
  41233. *
  41234. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  41235. *
  41236. * */
  41237. var __extends = (this && this.__extends) || (function () {
  41238. var extendStatics = function (d,
  41239. b) {
  41240. extendStatics = Object.setPrototypeOf ||
  41241. ({ __proto__: [] } instanceof Array && function (d,
  41242. b) { d.__proto__ = b; }) ||
  41243. function (d,
  41244. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  41245. return extendStatics(d, b);
  41246. };
  41247. return function (d, b) {
  41248. extendStatics(d, b);
  41249. function __() { this.constructor = d; }
  41250. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  41251. };
  41252. })();
  41253. var LineSeries = SeriesRegistry.seriesTypes.line;
  41254. var merge = U.merge,
  41255. pick = U.pick;
  41256. /**
  41257. * Spline series type.
  41258. *
  41259. * @private
  41260. */
  41261. var SplineSeries = /** @class */ (function (_super) {
  41262. __extends(SplineSeries, _super);
  41263. function SplineSeries() {
  41264. /* *
  41265. *
  41266. * Static Properties
  41267. *
  41268. * */
  41269. var _this = _super !== null && _super.apply(this,
  41270. arguments) || this;
  41271. /* *
  41272. *
  41273. * Properties
  41274. *
  41275. * */
  41276. _this.data = void 0;
  41277. _this.options = void 0;
  41278. _this.points = void 0;
  41279. return _this;
  41280. /* eslint-enable valid-jsdoc */
  41281. }
  41282. /* *
  41283. *
  41284. * Functions
  41285. *
  41286. * */
  41287. /* eslint-disable valid-jsdoc */
  41288. /**
  41289. * Get the spline segment from a given point's previous neighbour to the
  41290. * given point.
  41291. *
  41292. * @private
  41293. * @function Highcharts.seriesTypes.spline#getPointSpline
  41294. *
  41295. * @param {Array<Highcharts.Point>}
  41296. *
  41297. * @param {Highcharts.Point} point
  41298. *
  41299. * @param {number} i
  41300. *
  41301. * @return {Highcharts.SVGPathArray}
  41302. */
  41303. SplineSeries.prototype.getPointSpline = function (points, point, i) {
  41304. var
  41305. // 1 means control points midway between points, 2 means 1/3
  41306. // from the point, 3 is 1/4 etc
  41307. smoothing = 1.5,
  41308. denom = smoothing + 1,
  41309. plotX = point.plotX || 0,
  41310. plotY = point.plotY || 0,
  41311. lastPoint = points[i - 1],
  41312. nextPoint = points[i + 1],
  41313. leftContX,
  41314. leftContY,
  41315. rightContX,
  41316. rightContY,
  41317. ret;
  41318. /**
  41319. * @private
  41320. */
  41321. function doCurve(otherPoint) {
  41322. return otherPoint &&
  41323. !otherPoint.isNull &&
  41324. otherPoint.doCurve !== false &&
  41325. // #6387, area splines next to null:
  41326. !point.isCliff;
  41327. }
  41328. // Find control points
  41329. if (doCurve(lastPoint) && doCurve(nextPoint)) {
  41330. var lastX = lastPoint.plotX || 0,
  41331. lastY = lastPoint.plotY || 0,
  41332. nextX = nextPoint.plotX || 0,
  41333. nextY = nextPoint.plotY || 0,
  41334. correction = 0;
  41335. leftContX = (smoothing * plotX + lastX) / denom;
  41336. leftContY = (smoothing * plotY + lastY) / denom;
  41337. rightContX = (smoothing * plotX + nextX) / denom;
  41338. rightContY = (smoothing * plotY + nextY) / denom;
  41339. // Have the two control points make a straight line through main
  41340. // point
  41341. if (rightContX !== leftContX) { // #5016, division by zero
  41342. correction = (((rightContY - leftContY) *
  41343. (rightContX - plotX)) /
  41344. (rightContX - leftContX) + plotY - rightContY);
  41345. }
  41346. leftContY += correction;
  41347. rightContY += correction;
  41348. // to prevent false extremes, check that control points are
  41349. // between neighbouring points' y values
  41350. if (leftContY > lastY && leftContY > plotY) {
  41351. leftContY = Math.max(lastY, plotY);
  41352. // mirror of left control point
  41353. rightContY = 2 * plotY - leftContY;
  41354. }
  41355. else if (leftContY < lastY && leftContY < plotY) {
  41356. leftContY = Math.min(lastY, plotY);
  41357. rightContY = 2 * plotY - leftContY;
  41358. }
  41359. if (rightContY > nextY && rightContY > plotY) {
  41360. rightContY = Math.max(nextY, plotY);
  41361. leftContY = 2 * plotY - rightContY;
  41362. }
  41363. else if (rightContY < nextY && rightContY < plotY) {
  41364. rightContY = Math.min(nextY, plotY);
  41365. leftContY = 2 * plotY - rightContY;
  41366. }
  41367. // record for drawing in next point
  41368. point.rightContX = rightContX;
  41369. point.rightContY = rightContY;
  41370. }
  41371. // Visualize control points for debugging
  41372. /*
  41373. if (leftContX) {
  41374. this.chart.renderer.circle(
  41375. leftContX + this.chart.plotLeft,
  41376. leftContY + this.chart.plotTop,
  41377. 2
  41378. )
  41379. .attr({
  41380. stroke: 'red',
  41381. 'stroke-width': 2,
  41382. fill: 'none',
  41383. zIndex: 9
  41384. })
  41385. .add();
  41386. this.chart.renderer.path(['M', leftContX + this.chart.plotLeft,
  41387. leftContY + this.chart.plotTop,
  41388. 'L', plotX + this.chart.plotLeft, plotY + this.chart.plotTop])
  41389. .attr({
  41390. stroke: 'red',
  41391. 'stroke-width': 2,
  41392. zIndex: 9
  41393. })
  41394. .add();
  41395. }
  41396. if (rightContX) {
  41397. this.chart.renderer.circle(
  41398. rightContX + this.chart.plotLeft,
  41399. rightContY + this.chart.plotTop,
  41400. 2
  41401. )
  41402. .attr({
  41403. stroke: 'green',
  41404. 'stroke-width': 2,
  41405. fill: 'none',
  41406. zIndex: 9
  41407. })
  41408. .add();
  41409. this.chart.renderer.path(['M', rightContX + this.chart.plotLeft,
  41410. rightContY + this.chart.plotTop,
  41411. 'L', plotX + this.chart.plotLeft, plotY + this.chart.plotTop])
  41412. .attr({
  41413. stroke: 'green',
  41414. 'stroke-width': 2,
  41415. zIndex: 9
  41416. })
  41417. .add();
  41418. }
  41419. // */
  41420. ret = [
  41421. 'C',
  41422. pick(lastPoint.rightContX, lastPoint.plotX, 0),
  41423. pick(lastPoint.rightContY, lastPoint.plotY, 0),
  41424. pick(leftContX, plotX, 0),
  41425. pick(leftContY, plotY, 0),
  41426. plotX,
  41427. plotY
  41428. ];
  41429. // reset for updating series later
  41430. lastPoint.rightContX = lastPoint.rightContY = void 0;
  41431. return ret;
  41432. };
  41433. /**
  41434. * A spline series is a special type of line series, where the segments
  41435. * between the data points are smoothed.
  41436. *
  41437. * @sample {highcharts} highcharts/demo/spline-irregular-time/
  41438. * Spline chart
  41439. * @sample {highstock} stock/demo/spline/
  41440. * Spline chart
  41441. *
  41442. * @extends plotOptions.series
  41443. * @excluding step, boostThreshold, boostBlending
  41444. * @product highcharts highstock
  41445. * @optionparent plotOptions.spline
  41446. */
  41447. SplineSeries.defaultOptions = merge(LineSeries.defaultOptions);
  41448. return SplineSeries;
  41449. }(LineSeries));
  41450. SeriesRegistry.registerSeriesType('spline', SplineSeries);
  41451. /* *
  41452. *
  41453. * Default Export
  41454. *
  41455. * */
  41456. /* *
  41457. *
  41458. * API Options
  41459. *
  41460. * */
  41461. /**
  41462. * A `spline` series. If the [type](#series.spline.type) option is
  41463. * not specified, it is inherited from [chart.type](#chart.type).
  41464. *
  41465. * @extends series,plotOptions.spline
  41466. * @excluding dataParser, dataURL, step, boostThreshold, boostBlending
  41467. * @product highcharts highstock
  41468. * @apioption series.spline
  41469. */
  41470. /**
  41471. * An array of data points for the series. For the `spline` series type,
  41472. * points can be given in the following ways:
  41473. *
  41474. * 1. An array of numerical values. In this case, the numerical values will be
  41475. * interpreted as `y` options. The `x` values will be automatically
  41476. * calculated, either starting at 0 and incremented by 1, or from
  41477. * `pointStart` and `pointInterval` given in the series options. If the axis
  41478. * has categories, these will be used. Example:
  41479. * ```js
  41480. * data: [0, 5, 3, 5]
  41481. * ```
  41482. *
  41483. * 2. An array of arrays with 2 values. In this case, the values correspond to
  41484. * `x,y`. If the first value is a string, it is applied as the name of the
  41485. * point, and the `x` value is inferred.
  41486. * ```js
  41487. * data: [
  41488. * [0, 9],
  41489. * [1, 2],
  41490. * [2, 8]
  41491. * ]
  41492. * ```
  41493. *
  41494. * 3. An array of objects with named values. The following snippet shows only a
  41495. * few settings, see the complete options set below. If the total number of
  41496. * data points exceeds the series'
  41497. * [turboThreshold](#series.spline.turboThreshold),
  41498. * this option is not available.
  41499. * ```js
  41500. * data: [{
  41501. * x: 1,
  41502. * y: 9,
  41503. * name: "Point2",
  41504. * color: "#00FF00"
  41505. * }, {
  41506. * x: 1,
  41507. * y: 0,
  41508. * name: "Point1",
  41509. * color: "#FF00FF"
  41510. * }]
  41511. * ```
  41512. *
  41513. * @sample {highcharts} highcharts/chart/reflow-true/
  41514. * Numerical values
  41515. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  41516. * Arrays of numeric x and y
  41517. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  41518. * Arrays of datetime x and y
  41519. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  41520. * Arrays of point.name and y
  41521. * @sample {highcharts} highcharts/series/data-array-of-objects/
  41522. * Config objects
  41523. *
  41524. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  41525. * @extends series.line.data
  41526. * @product highcharts highstock
  41527. * @apioption series.spline.data
  41528. */
  41529. ''; // adds doclets above intro transpilat
  41530. return SplineSeries;
  41531. });
  41532. _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) {
  41533. /* *
  41534. *
  41535. * (c) 2010-2021 Torstein Honsi
  41536. *
  41537. * License: www.highcharts.com/license
  41538. *
  41539. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  41540. *
  41541. * */
  41542. var __extends = (this && this.__extends) || (function () {
  41543. var extendStatics = function (d,
  41544. b) {
  41545. extendStatics = Object.setPrototypeOf ||
  41546. ({ __proto__: [] } instanceof Array && function (d,
  41547. b) { d.__proto__ = b; }) ||
  41548. function (d,
  41549. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  41550. return extendStatics(d, b);
  41551. };
  41552. return function (d, b) {
  41553. extendStatics(d, b);
  41554. function __() { this.constructor = d; }
  41555. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  41556. };
  41557. })();
  41558. var areaProto = AreaSeries.prototype;
  41559. var extend = U.extend,
  41560. merge = U.merge;
  41561. /* *
  41562. *
  41563. * Class
  41564. *
  41565. * */
  41566. /**
  41567. * AreaSpline series type.
  41568. *
  41569. * @private
  41570. * @class
  41571. * @name Highcharts.seriesTypes.areaspline
  41572. *
  41573. * @augments Highcharts.Series
  41574. */
  41575. var AreaSplineSeries = /** @class */ (function (_super) {
  41576. __extends(AreaSplineSeries, _super);
  41577. function AreaSplineSeries() {
  41578. /* *
  41579. *
  41580. * Static properties
  41581. *
  41582. * */
  41583. var _this = _super !== null && _super.apply(this,
  41584. arguments) || this;
  41585. /* *
  41586. *
  41587. * Properties
  41588. *
  41589. * */
  41590. _this.data = void 0;
  41591. _this.points = void 0;
  41592. _this.options = void 0;
  41593. return _this;
  41594. }
  41595. /**
  41596. * The area spline series is an area series where the graph between the
  41597. * points is smoothed into a spline.
  41598. *
  41599. * @sample {highcharts} highcharts/demo/areaspline/
  41600. * Area spline chart
  41601. * @sample {highstock} stock/demo/areaspline/
  41602. * Area spline chart
  41603. *
  41604. * @extends plotOptions.area
  41605. * @excluding step, boostThreshold, boostBlending
  41606. * @product highcharts highstock
  41607. * @apioption plotOptions.areaspline
  41608. */
  41609. /**
  41610. * @see [fillColor](#plotOptions.areaspline.fillColor)
  41611. * @see [fillOpacity](#plotOptions.areaspline.fillOpacity)
  41612. *
  41613. * @apioption plotOptions.areaspline.color
  41614. */
  41615. /**
  41616. * @see [color](#plotOptions.areaspline.color)
  41617. * @see [fillOpacity](#plotOptions.areaspline.fillOpacity)
  41618. *
  41619. * @apioption plotOptions.areaspline.fillColor
  41620. */
  41621. /**
  41622. * @see [color](#plotOptions.areaspline.color)
  41623. * @see [fillColor](#plotOptions.areaspline.fillColor)
  41624. *
  41625. * @default {highcharts} 0.75
  41626. * @default {highstock} 0.75
  41627. * @apioption plotOptions.areaspline.fillOpacity
  41628. */
  41629. AreaSplineSeries.defaultOptions = merge(SplineSeries.defaultOptions, AreaSeries.defaultOptions);
  41630. return AreaSplineSeries;
  41631. }(SplineSeries));
  41632. extend(AreaSplineSeries.prototype, {
  41633. getGraphPath: areaProto.getGraphPath,
  41634. getStackPoints: areaProto.getStackPoints,
  41635. drawGraph: areaProto.drawGraph,
  41636. drawLegendSymbol: LegendSymbolMixin.drawRectangle
  41637. });
  41638. SeriesRegistry.registerSeriesType('areaspline', AreaSplineSeries);
  41639. /* *
  41640. *
  41641. * Default export
  41642. *
  41643. * */
  41644. /**
  41645. * A `areaspline` series. If the [type](#series.areaspline.type) option
  41646. * is not specified, it is inherited from [chart.type](#chart.type).
  41647. *
  41648. *
  41649. * @extends series,plotOptions.areaspline
  41650. * @excluding dataParser, dataURL, step, boostThreshold, boostBlending
  41651. * @product highcharts highstock
  41652. * @apioption series.areaspline
  41653. */
  41654. /**
  41655. * @see [fillColor](#series.areaspline.fillColor)
  41656. * @see [fillOpacity](#series.areaspline.fillOpacity)
  41657. *
  41658. * @apioption series.areaspline.color
  41659. */
  41660. /**
  41661. * An array of data points for the series. For the `areaspline` series
  41662. * type, points can be given in the following ways:
  41663. *
  41664. * 1. An array of numerical values. In this case, the numerical values will be
  41665. * interpreted as `y` options. The `x` values will be automatically
  41666. * calculated, either starting at 0 and incremented by 1, or from
  41667. * `pointStart` and `pointInterval` given in the series options. If the axis
  41668. * has categories, these will be used. Example:
  41669. * ```js
  41670. * data: [0, 5, 3, 5]
  41671. * ```
  41672. *
  41673. * 2. An array of arrays with 2 values. In this case, the values correspond to
  41674. * `x,y`. If the first value is a string, it is applied as the name of the
  41675. * point, and the `x` value is inferred.
  41676. * ```js
  41677. * data: [
  41678. * [0, 10],
  41679. * [1, 9],
  41680. * [2, 3]
  41681. * ]
  41682. * ```
  41683. *
  41684. * 3. An array of objects with named values. The following snippet shows only a
  41685. * few settings, see the complete options set below. If the total number of
  41686. * data points exceeds the series'
  41687. * [turboThreshold](#series.areaspline.turboThreshold), this option is not
  41688. * available.
  41689. * ```js
  41690. * data: [{
  41691. * x: 1,
  41692. * y: 4,
  41693. * name: "Point2",
  41694. * color: "#00FF00"
  41695. * }, {
  41696. * x: 1,
  41697. * y: 4,
  41698. * name: "Point1",
  41699. * color: "#FF00FF"
  41700. * }]
  41701. * ```
  41702. *
  41703. * @sample {highcharts} highcharts/chart/reflow-true/
  41704. * Numerical values
  41705. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  41706. * Arrays of numeric x and y
  41707. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  41708. * Arrays of datetime x and y
  41709. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  41710. * Arrays of point.name and y
  41711. * @sample {highcharts} highcharts/series/data-array-of-objects/
  41712. * Config objects
  41713. *
  41714. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  41715. * @extends series.line.data
  41716. * @product highcharts highstock
  41717. * @apioption series.areaspline.data
  41718. */
  41719. /**
  41720. * @see [color](#series.areaspline.color)
  41721. * @see [fillOpacity](#series.areaspline.fillOpacity)
  41722. *
  41723. * @apioption series.areaspline.fillColor
  41724. */
  41725. /**
  41726. * @see [color](#series.areaspline.color)
  41727. * @see [fillColor](#series.areaspline.fillColor)
  41728. *
  41729. * @default {highcharts} 0.75
  41730. * @default {highstock} 0.75
  41731. * @apioption series.areaspline.fillOpacity
  41732. */
  41733. ''; // adds doclets above into transpilat
  41734. return AreaSplineSeries;
  41735. });
  41736. _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) {
  41737. /* *
  41738. *
  41739. * (c) 2010-2021 Torstein Honsi
  41740. *
  41741. * License: www.highcharts.com/license
  41742. *
  41743. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  41744. *
  41745. * */
  41746. var __extends = (this && this.__extends) || (function () {
  41747. var extendStatics = function (d,
  41748. b) {
  41749. extendStatics = Object.setPrototypeOf ||
  41750. ({ __proto__: [] } instanceof Array && function (d,
  41751. b) { d.__proto__ = b; }) ||
  41752. function (d,
  41753. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  41754. return extendStatics(d, b);
  41755. };
  41756. return function (d, b) {
  41757. extendStatics(d, b);
  41758. function __() { this.constructor = d; }
  41759. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  41760. };
  41761. })();
  41762. var animObject = A.animObject;
  41763. var color = Color.parse;
  41764. var hasTouch = H.hasTouch,
  41765. noop = H.noop;
  41766. var clamp = U.clamp,
  41767. css = U.css,
  41768. defined = U.defined,
  41769. extend = U.extend,
  41770. fireEvent = U.fireEvent,
  41771. isArray = U.isArray,
  41772. isNumber = U.isNumber,
  41773. merge = U.merge,
  41774. pick = U.pick,
  41775. objectEach = U.objectEach;
  41776. /**
  41777. * The column series type.
  41778. *
  41779. * @private
  41780. * @class
  41781. * @name Highcharts.seriesTypes.column
  41782. *
  41783. * @augments Highcharts.Series
  41784. */
  41785. var ColumnSeries = /** @class */ (function (_super) {
  41786. __extends(ColumnSeries, _super);
  41787. function ColumnSeries() {
  41788. /* *
  41789. *
  41790. * Static Properties
  41791. *
  41792. * */
  41793. var _this = _super !== null && _super.apply(this,
  41794. arguments) || this;
  41795. /* *
  41796. *
  41797. * Properties
  41798. *
  41799. * */
  41800. _this.borderWidth = void 0;
  41801. _this.data = void 0;
  41802. _this.group = void 0;
  41803. _this.options = void 0;
  41804. _this.points = void 0;
  41805. return _this;
  41806. /* eslint-enable valid-jsdoc */
  41807. }
  41808. /* *
  41809. *
  41810. * Functions
  41811. *
  41812. * */
  41813. /* eslint-disable valid-jsdoc */
  41814. /**
  41815. * Animate the column heights one by one from zero.
  41816. *
  41817. * @private
  41818. * @function Highcharts.seriesTypes.column#animate
  41819. *
  41820. * @param {boolean} init
  41821. * Whether to initialize the animation or run it
  41822. */
  41823. ColumnSeries.prototype.animate = function (init) {
  41824. var series = this,
  41825. yAxis = this.yAxis,
  41826. options = series.options,
  41827. inverted = this.chart.inverted,
  41828. attr = {},
  41829. translateProp = inverted ? 'translateX' : 'translateY',
  41830. translateStart,
  41831. translatedThreshold;
  41832. if (init) {
  41833. attr.scaleY = 0.001;
  41834. translatedThreshold = clamp(yAxis.toPixels(options.threshold), yAxis.pos, yAxis.pos + yAxis.len);
  41835. if (inverted) {
  41836. attr.translateX = translatedThreshold - yAxis.len;
  41837. }
  41838. else {
  41839. attr.translateY = translatedThreshold;
  41840. }
  41841. // apply finnal clipping (used in Highcharts Stock) (#7083)
  41842. // animation is done by scaleY, so cliping is for panes
  41843. if (series.clipBox) {
  41844. series.setClip();
  41845. }
  41846. series.group.attr(attr);
  41847. }
  41848. else { // run the animation
  41849. translateStart = Number(series.group.attr(translateProp));
  41850. series.group.animate({ scaleY: 1 }, extend(animObject(series.options.animation), {
  41851. // Do the scale synchronously to ensure smooth
  41852. // updating (#5030, #7228)
  41853. step: function (val, fx) {
  41854. if (series.group) {
  41855. attr[translateProp] = translateStart +
  41856. fx.pos * (yAxis.pos - translateStart);
  41857. series.group.attr(attr);
  41858. }
  41859. }
  41860. }));
  41861. }
  41862. };
  41863. /**
  41864. * Initialize the series. Extends the basic Series.init method by
  41865. * marking other series of the same type as dirty.
  41866. *
  41867. * @private
  41868. * @function Highcharts.seriesTypes.column#init
  41869. */
  41870. ColumnSeries.prototype.init = function (chart, options) {
  41871. _super.prototype.init.apply(this, arguments);
  41872. var series = this;
  41873. chart = series.chart;
  41874. // if the series is added dynamically, force redraw of other
  41875. // series affected by a new column
  41876. if (chart.hasRendered) {
  41877. chart.series.forEach(function (otherSeries) {
  41878. if (otherSeries.type === series.type) {
  41879. otherSeries.isDirty = true;
  41880. }
  41881. });
  41882. }
  41883. };
  41884. /**
  41885. * Return the width and x offset of the columns adjusted for grouping,
  41886. * groupPadding, pointPadding, pointWidth etc.
  41887. *
  41888. * @private
  41889. * @function Highcharts.seriesTypes.column#getColumnMetrics
  41890. * @return {Highcharts.ColumnMetricsObject}
  41891. */
  41892. ColumnSeries.prototype.getColumnMetrics = function () {
  41893. var series = this,
  41894. options = series.options,
  41895. xAxis = series.xAxis,
  41896. yAxis = series.yAxis,
  41897. reversedStacks = xAxis.options.reversedStacks,
  41898. // Keep backward compatibility: reversed xAxis had reversed
  41899. // stacks
  41900. reverseStacks = (xAxis.reversed && !reversedStacks) ||
  41901. (!xAxis.reversed && reversedStacks),
  41902. stackKey,
  41903. stackGroups = {},
  41904. columnCount = 0;
  41905. // Get the total number of column type series. This is called on
  41906. // every series. Consider moving this logic to a chart.orderStacks()
  41907. // function and call it on init, addSeries and removeSeries
  41908. if (options.grouping === false) {
  41909. columnCount = 1;
  41910. }
  41911. else {
  41912. series.chart.series.forEach(function (otherSeries) {
  41913. var otherYAxis = otherSeries.yAxis,
  41914. otherOptions = otherSeries.options,
  41915. columnIndex;
  41916. if (otherSeries.type === series.type &&
  41917. (otherSeries.visible ||
  41918. !series.chart.options.chart.ignoreHiddenSeries) &&
  41919. yAxis.len === otherYAxis.len &&
  41920. yAxis.pos === otherYAxis.pos) { // #642, #2086
  41921. if (otherOptions.stacking && otherOptions.stacking !== 'group') {
  41922. stackKey = otherSeries.stackKey;
  41923. if (typeof stackGroups[stackKey] ===
  41924. 'undefined') {
  41925. stackGroups[stackKey] = columnCount++;
  41926. }
  41927. columnIndex = stackGroups[stackKey];
  41928. }
  41929. else if (otherOptions.grouping !== false) { // #1162
  41930. columnIndex = columnCount++;
  41931. }
  41932. otherSeries.columnIndex = columnIndex;
  41933. }
  41934. });
  41935. }
  41936. var categoryWidth = Math.min(Math.abs(xAxis.transA) * ((xAxis.ordinal && xAxis.ordinal.slope) ||
  41937. options.pointRange ||
  41938. xAxis.closestPointRange ||
  41939. xAxis.tickInterval ||
  41940. 1), // #2610
  41941. xAxis.len // #1535
  41942. ),
  41943. groupPadding = categoryWidth * options.groupPadding,
  41944. groupWidth = categoryWidth - 2 * groupPadding,
  41945. pointOffsetWidth = groupWidth / (columnCount || 1),
  41946. pointWidth = Math.min(options.maxPointWidth || xAxis.len,
  41947. pick(options.pointWidth,
  41948. pointOffsetWidth * (1 - 2 * options.pointPadding))),
  41949. pointPadding = (pointOffsetWidth - pointWidth) / 2,
  41950. // #1251, #3737
  41951. colIndex = (series.columnIndex || 0) + (reverseStacks ? 1 : 0),
  41952. pointXOffset = pointPadding +
  41953. (groupPadding +
  41954. colIndex * pointOffsetWidth -
  41955. (categoryWidth / 2)) * (reverseStacks ? -1 : 1);
  41956. // Save it for reading in linked series (Error bars particularly)
  41957. series.columnMetrics = {
  41958. width: pointWidth,
  41959. offset: pointXOffset,
  41960. paddedWidth: pointOffsetWidth,
  41961. columnCount: columnCount
  41962. };
  41963. return series.columnMetrics;
  41964. };
  41965. /**
  41966. * Make the columns crisp. The edges are rounded to the nearest full
  41967. * pixel.
  41968. *
  41969. * @private
  41970. * @function Highcharts.seriesTypes.column#crispCol
  41971. */
  41972. ColumnSeries.prototype.crispCol = function (x, y, w, h) {
  41973. var chart = this.chart,
  41974. borderWidth = this.borderWidth,
  41975. xCrisp = -(borderWidth % 2 ? 0.5 : 0),
  41976. yCrisp = borderWidth % 2 ? 0.5 : 1,
  41977. right,
  41978. bottom,
  41979. fromTop;
  41980. if (chart.inverted && chart.renderer.isVML) {
  41981. yCrisp += 1;
  41982. }
  41983. // Horizontal. We need to first compute the exact right edge, then
  41984. // round it and compute the width from there.
  41985. if (this.options.crisp) {
  41986. right = Math.round(x + w) + xCrisp;
  41987. x = Math.round(x) + xCrisp;
  41988. w = right - x;
  41989. }
  41990. // Vertical
  41991. bottom = Math.round(y + h) + yCrisp;
  41992. fromTop = Math.abs(y) <= 0.5 && bottom > 0.5; // #4504, #4656
  41993. y = Math.round(y) + yCrisp;
  41994. h = bottom - y;
  41995. // Top edges are exceptions
  41996. if (fromTop && h) { // #5146
  41997. y -= 1;
  41998. h += 1;
  41999. }
  42000. return {
  42001. x: x,
  42002. y: y,
  42003. width: w,
  42004. height: h
  42005. };
  42006. };
  42007. /**
  42008. * Adjust for missing columns, according to the `centerInCategory`
  42009. * option. Missing columns are either single points or stacks where the
  42010. * point or points are either missing or null.
  42011. *
  42012. * @private
  42013. * @function Highcharts.seriesTypes.column#adjustForMissingColumns
  42014. * @param {number} x
  42015. * The x coordinate of the column, left side
  42016. *
  42017. * @param {number} pointWidth
  42018. * The pointWidth, already computed upstream
  42019. *
  42020. * @param {Highcharts.ColumnPoint} point
  42021. * The point instance
  42022. *
  42023. * @param {Highcharts.ColumnMetricsObject} metrics
  42024. * The series-wide column metrics
  42025. *
  42026. * @return {number}
  42027. * The adjusted x position, or the original if not adjusted
  42028. */
  42029. ColumnSeries.prototype.adjustForMissingColumns = function (x, pointWidth, point, metrics) {
  42030. var _this = this;
  42031. var stacking = this.options.stacking;
  42032. if (!point.isNull && metrics.columnCount > 1) {
  42033. var indexInCategory_1 = 0;
  42034. var totalInCategory_1 = 0;
  42035. // Loop over all the stacks on the Y axis. When stacking is
  42036. // enabled, these are real point stacks. When stacking is not
  42037. // enabled, but `centerInCategory` is true, there is one stack
  42038. // handling the grouping of points in each category. This is
  42039. // done in the `setGroupedPoints` function.
  42040. objectEach(this.yAxis.stacking && this.yAxis.stacking.stacks, function (stack) {
  42041. if (typeof point.x === 'number') {
  42042. var stackItem = stack[point.x.toString()];
  42043. if (stackItem) {
  42044. var pointValues = stackItem.points[_this.index],
  42045. total = stackItem.total;
  42046. // If true `stacking` is enabled, count the
  42047. // total number of non-null stacks in the
  42048. // category, and note which index this point is
  42049. // within those stacks.
  42050. if (stacking) {
  42051. if (pointValues) {
  42052. indexInCategory_1 = totalInCategory_1;
  42053. }
  42054. if (stackItem.hasValidPoints) {
  42055. totalInCategory_1++;
  42056. }
  42057. // If `stacking` is not enabled, look for the
  42058. // index and total of the `group` stack.
  42059. }
  42060. else if (isArray(pointValues)) {
  42061. indexInCategory_1 = pointValues[1];
  42062. totalInCategory_1 = total || 0;
  42063. }
  42064. }
  42065. }
  42066. });
  42067. // Compute the adjusted x position
  42068. var boxWidth = (totalInCategory_1 - 1) * metrics.paddedWidth +
  42069. pointWidth;
  42070. x = (point.plotX || 0) + boxWidth / 2 - pointWidth -
  42071. indexInCategory_1 * metrics.paddedWidth;
  42072. }
  42073. return x;
  42074. };
  42075. /**
  42076. * Translate each point to the plot area coordinate system and find
  42077. * shape positions
  42078. *
  42079. * @private
  42080. * @function Highcharts.seriesTypes.column#translate
  42081. */
  42082. ColumnSeries.prototype.translate = function () {
  42083. var series = this,
  42084. chart = series.chart,
  42085. options = series.options,
  42086. dense = series.dense =
  42087. series.closestPointRange * series.xAxis.transA < 2,
  42088. borderWidth = series.borderWidth = pick(options.borderWidth,
  42089. dense ? 0 : 1 // #3635
  42090. ),
  42091. xAxis = series.xAxis,
  42092. yAxis = series.yAxis,
  42093. threshold = options.threshold,
  42094. translatedThreshold = series.translatedThreshold =
  42095. yAxis.getThreshold(threshold),
  42096. minPointLength = pick(options.minPointLength, 5),
  42097. metrics = series.getColumnMetrics(),
  42098. seriesPointWidth = metrics.width,
  42099. // postprocessed for border width
  42100. seriesBarW = series.barW =
  42101. Math.max(seriesPointWidth, 1 + 2 * borderWidth),
  42102. seriesXOffset = series.pointXOffset = metrics.offset,
  42103. dataMin = series.dataMin,
  42104. dataMax = series.dataMax;
  42105. if (chart.inverted) {
  42106. translatedThreshold -= 0.5; // #3355
  42107. }
  42108. // When the pointPadding is 0, we want the columns to be packed
  42109. // tightly, so we allow individual columns to have individual sizes.
  42110. // When pointPadding is greater, we strive for equal-width columns
  42111. // (#2694).
  42112. if (options.pointPadding) {
  42113. seriesBarW = Math.ceil(seriesBarW);
  42114. }
  42115. Series.prototype.translate.apply(series);
  42116. // Record the new values
  42117. series.points.forEach(function (point) {
  42118. var yBottom = pick(point.yBottom,
  42119. translatedThreshold),
  42120. safeDistance = 999 + Math.abs(yBottom),
  42121. pointWidth = seriesPointWidth,
  42122. plotX = point.plotX || 0,
  42123. // Don't draw too far outside plot area (#1303, #2241,
  42124. // #4264)
  42125. plotY = clamp(point.plotY, -safeDistance,
  42126. yAxis.len + safeDistance),
  42127. barX = plotX + seriesXOffset,
  42128. barW = seriesBarW,
  42129. barY = Math.min(plotY,
  42130. yBottom),
  42131. up,
  42132. barH = Math.max(plotY,
  42133. yBottom) - barY;
  42134. // Handle options.minPointLength
  42135. if (minPointLength && Math.abs(barH) < minPointLength) {
  42136. barH = minPointLength;
  42137. up = (!yAxis.reversed && !point.negative) ||
  42138. (yAxis.reversed && point.negative);
  42139. // Reverse zeros if there's no positive value in the series
  42140. // in visible range (#7046)
  42141. if (isNumber(threshold) &&
  42142. isNumber(dataMax) &&
  42143. point.y === threshold &&
  42144. dataMax <= threshold &&
  42145. // and if there's room for it (#7311)
  42146. (yAxis.min || 0) < threshold &&
  42147. // if all points are the same value (i.e zero) not draw
  42148. // as negative points (#10646), but only if there's room
  42149. // for it (#14876)
  42150. (dataMin !== dataMax || (yAxis.max || 0) <= threshold)) {
  42151. up = !up;
  42152. }
  42153. // If stacked...
  42154. barY = (Math.abs(barY - translatedThreshold) > minPointLength ?
  42155. // ...keep position
  42156. yBottom - minPointLength :
  42157. // #1485, #4051
  42158. translatedThreshold -
  42159. (up ? minPointLength : 0));
  42160. }
  42161. // Handle point.options.pointWidth
  42162. // @todo Handle grouping/stacking too. Calculate offset properly
  42163. if (defined(point.options.pointWidth)) {
  42164. pointWidth = barW =
  42165. Math.ceil(point.options.pointWidth);
  42166. barX -= Math.round((pointWidth - seriesPointWidth) / 2);
  42167. }
  42168. // Adjust for null or missing points
  42169. if (options.centerInCategory) {
  42170. barX = series.adjustForMissingColumns(barX, pointWidth, point, metrics);
  42171. }
  42172. // Cache for access in polar
  42173. point.barX = barX;
  42174. point.pointWidth = pointWidth;
  42175. // Fix the tooltip on center of grouped columns (#1216, #424,
  42176. // #3648)
  42177. point.tooltipPos = chart.inverted ?
  42178. [
  42179. clamp(yAxis.len + yAxis.pos - chart.plotLeft - plotY, yAxis.pos - chart.plotLeft, yAxis.len + yAxis.pos - chart.plotLeft),
  42180. xAxis.len + xAxis.pos - chart.plotTop - barX - barW / 2,
  42181. barH
  42182. ] :
  42183. [
  42184. xAxis.left - chart.plotLeft + barX + barW / 2,
  42185. clamp(plotY + yAxis.pos -
  42186. chart.plotTop, yAxis.pos - chart.plotTop, yAxis.len + yAxis.pos - chart.plotTop),
  42187. barH
  42188. ];
  42189. // Register shape type and arguments to be used in drawPoints
  42190. // Allow shapeType defined on pointClass level
  42191. point.shapeType = series.pointClass.prototype.shapeType || 'rect';
  42192. point.shapeArgs = series.crispCol.apply(series, point.isNull ?
  42193. // #3169, drilldown from null must have a position to work
  42194. // from #6585, dataLabel should be placed on xAxis, not
  42195. // floating in the middle of the chart
  42196. [barX, translatedThreshold, barW, 0] :
  42197. [barX, barY, barW, barH]);
  42198. });
  42199. };
  42200. /**
  42201. * Columns have no graph
  42202. *
  42203. * @private
  42204. * @function Highcharts.seriesTypes.column#drawGraph
  42205. */
  42206. ColumnSeries.prototype.drawGraph = function () {
  42207. this.group[this.dense ? 'addClass' : 'removeClass']('highcharts-dense-data');
  42208. };
  42209. /**
  42210. * Get presentational attributes
  42211. *
  42212. * @private
  42213. * @function Highcharts.seriesTypes.column#pointAttribs
  42214. */
  42215. ColumnSeries.prototype.pointAttribs = function (point, state) {
  42216. var options = this.options, stateOptions, ret, p2o = this.pointAttrToOptions || {}, strokeOption = p2o.stroke || 'borderColor', strokeWidthOption = p2o['stroke-width'] || 'borderWidth', fill = (point && point.color) || this.color,
  42217. // set to fill when borderColor null:
  42218. stroke = ((point && point[strokeOption]) ||
  42219. options[strokeOption] ||
  42220. fill), strokeWidth = (point && point[strokeWidthOption]) ||
  42221. options[strokeWidthOption] ||
  42222. this[strokeWidthOption] || 0, dashstyle = (point && point.options.dashStyle) || options.dashStyle, opacity = pick(point && point.opacity, options.opacity, 1), zone, brightness;
  42223. // Handle zone colors
  42224. if (point && this.zones.length) {
  42225. zone = point.getZone();
  42226. // When zones are present, don't use point.color (#4267).
  42227. // Changed order (#6527), added support for colorAxis (#10670)
  42228. fill = (point.options.color ||
  42229. (zone && (zone.color || point.nonZonedColor)) ||
  42230. this.color);
  42231. if (zone) {
  42232. stroke = zone.borderColor || stroke;
  42233. dashstyle = zone.dashStyle || dashstyle;
  42234. strokeWidth = zone.borderWidth || strokeWidth;
  42235. }
  42236. }
  42237. // Select or hover states
  42238. if (state && point) {
  42239. stateOptions = merge(options.states[state],
  42240. // #6401
  42241. point.options.states &&
  42242. point.options.states[state] ||
  42243. {});
  42244. brightness = stateOptions.brightness;
  42245. fill =
  42246. stateOptions.color || (typeof brightness !== 'undefined' &&
  42247. color(fill)
  42248. .brighten(stateOptions.brightness)
  42249. .get()) || fill;
  42250. stroke = stateOptions[strokeOption] || stroke;
  42251. strokeWidth =
  42252. stateOptions[strokeWidthOption] || strokeWidth;
  42253. dashstyle = stateOptions.dashStyle || dashstyle;
  42254. opacity = pick(stateOptions.opacity, opacity);
  42255. }
  42256. ret = {
  42257. fill: fill,
  42258. stroke: stroke,
  42259. 'stroke-width': strokeWidth,
  42260. opacity: opacity
  42261. };
  42262. if (dashstyle) {
  42263. ret.dashstyle = dashstyle;
  42264. }
  42265. return ret;
  42266. };
  42267. /**
  42268. * Draw the columns. For bars, the series.group is rotated, so the same
  42269. * coordinates apply for columns and bars. This method is inherited by
  42270. * scatter series.
  42271. *
  42272. * @private
  42273. * @function Highcharts.seriesTypes.column#drawPoints
  42274. */
  42275. ColumnSeries.prototype.drawPoints = function () {
  42276. var series = this,
  42277. chart = this.chart,
  42278. options = series.options,
  42279. renderer = chart.renderer,
  42280. animationLimit = options.animationLimit || 250,
  42281. shapeArgs;
  42282. // draw the columns
  42283. series.points.forEach(function (point) {
  42284. var plotY = point.plotY,
  42285. graphic = point.graphic,
  42286. hasGraphic = !!graphic,
  42287. verb = graphic && chart.pointCount < animationLimit ?
  42288. 'animate' : 'attr';
  42289. if (isNumber(plotY) && point.y !== null) {
  42290. shapeArgs = point.shapeArgs;
  42291. // When updating a series between 2d and 3d or cartesian and
  42292. // polar, the shape type changes.
  42293. if (graphic && point.hasNewShapeType()) {
  42294. graphic = graphic.destroy();
  42295. }
  42296. // Set starting position for point sliding animation.
  42297. if (series.enabledDataSorting) {
  42298. point.startXPos = series.xAxis.reversed ?
  42299. -(shapeArgs ? (shapeArgs.width || 0) : 0) :
  42300. series.xAxis.width;
  42301. }
  42302. if (!graphic) {
  42303. point.graphic = graphic =
  42304. renderer[point.shapeType](shapeArgs)
  42305. .add(point.group || series.group);
  42306. if (graphic &&
  42307. series.enabledDataSorting &&
  42308. chart.hasRendered &&
  42309. chart.pointCount < animationLimit) {
  42310. graphic.attr({
  42311. x: point.startXPos
  42312. });
  42313. hasGraphic = true;
  42314. verb = 'animate';
  42315. }
  42316. }
  42317. if (graphic && hasGraphic) { // update
  42318. graphic[verb](merge(shapeArgs));
  42319. }
  42320. // Border radius is not stylable (#6900)
  42321. if (options.borderRadius) {
  42322. graphic[verb]({
  42323. r: options.borderRadius
  42324. });
  42325. }
  42326. // Presentational
  42327. if (!chart.styledMode) {
  42328. graphic[verb](series.pointAttribs(point, (point.selected && 'select')))
  42329. .shadow(point.allowShadow !== false && options.shadow, null, options.stacking && !options.borderRadius);
  42330. }
  42331. if (graphic) {
  42332. graphic.addClass(point.getClassName(), true);
  42333. graphic.attr({
  42334. visibility: point.visible ? 'inherit' : 'hidden'
  42335. });
  42336. }
  42337. }
  42338. else if (graphic) {
  42339. point.graphic = graphic.destroy(); // #1269
  42340. }
  42341. });
  42342. };
  42343. /**
  42344. * Draw the tracker for a point.
  42345. * @private
  42346. */
  42347. ColumnSeries.prototype.drawTracker = function () {
  42348. var series = this,
  42349. chart = series.chart,
  42350. pointer = chart.pointer,
  42351. onMouseOver = function (e) {
  42352. var point = pointer.getPointFromEvent(e);
  42353. // undefined on graph in scatterchart
  42354. if (typeof point !== 'undefined') {
  42355. pointer.isDirectTouch = true;
  42356. point.onMouseOver(e);
  42357. }
  42358. }, dataLabels;
  42359. // Add reference to the point
  42360. series.points.forEach(function (point) {
  42361. dataLabels = (isArray(point.dataLabels) ?
  42362. point.dataLabels :
  42363. (point.dataLabel ? [point.dataLabel] : []));
  42364. if (point.graphic) {
  42365. point.graphic.element.point = point;
  42366. }
  42367. dataLabels.forEach(function (dataLabel) {
  42368. if (dataLabel.div) {
  42369. dataLabel.div.point = point;
  42370. }
  42371. else {
  42372. dataLabel.element.point = point;
  42373. }
  42374. });
  42375. });
  42376. // Add the event listeners, we need to do this only once
  42377. if (!series._hasTracking) {
  42378. series.trackerGroups.forEach(function (key) {
  42379. if (series[key]) {
  42380. // we don't always have dataLabelsGroup
  42381. series[key]
  42382. .addClass('highcharts-tracker')
  42383. .on('mouseover', onMouseOver)
  42384. .on('mouseout', function (e) {
  42385. pointer.onTrackerMouseOut(e);
  42386. });
  42387. if (hasTouch) {
  42388. series[key].on('touchstart', onMouseOver);
  42389. }
  42390. if (!chart.styledMode && series.options.cursor) {
  42391. series[key]
  42392. .css(css)
  42393. .css({ cursor: series.options.cursor });
  42394. }
  42395. }
  42396. });
  42397. series._hasTracking = true;
  42398. }
  42399. fireEvent(this, 'afterDrawTracker');
  42400. };
  42401. /**
  42402. * Remove this series from the chart
  42403. *
  42404. * @private
  42405. * @function Highcharts.seriesTypes.column#remove
  42406. */
  42407. ColumnSeries.prototype.remove = function () {
  42408. var series = this,
  42409. chart = series.chart;
  42410. // column and bar series affects other series of the same type
  42411. // as they are either stacked or grouped
  42412. if (chart.hasRendered) {
  42413. chart.series.forEach(function (otherSeries) {
  42414. if (otherSeries.type === series.type) {
  42415. otherSeries.isDirty = true;
  42416. }
  42417. });
  42418. }
  42419. Series.prototype.remove.apply(series, arguments);
  42420. };
  42421. /**
  42422. * Column series display one column per value along an X axis.
  42423. *
  42424. * @sample {highcharts} highcharts/demo/column-basic/
  42425. * Column chart
  42426. * @sample {highstock} stock/demo/column/
  42427. * Column chart
  42428. *
  42429. * @extends plotOptions.line
  42430. * @excluding connectEnds, connectNulls, gapSize, gapUnit, linecap,
  42431. * lineWidth, marker, step, useOhlcData
  42432. * @product highcharts highstock
  42433. * @optionparent plotOptions.column
  42434. */
  42435. ColumnSeries.defaultOptions = merge(Series.defaultOptions, {
  42436. /**
  42437. * The corner radius of the border surrounding each column or bar.
  42438. *
  42439. * @sample {highcharts} highcharts/plotoptions/column-borderradius/
  42440. * Rounded columns
  42441. *
  42442. * @product highcharts highstock gantt
  42443. *
  42444. * @private
  42445. */
  42446. borderRadius: 0,
  42447. /**
  42448. * When using automatic point colors pulled from the global
  42449. * [colors](colors) or series-specific
  42450. * [plotOptions.column.colors](series.colors) collections, this option
  42451. * determines whether the chart should receive one color per series or
  42452. * one color per point.
  42453. *
  42454. * In styled mode, the `colors` or `series.colors` arrays are not
  42455. * supported, and instead this option gives the points individual color
  42456. * class names on the form `highcharts-color-{n}`.
  42457. *
  42458. * @see [series colors](#plotOptions.column.colors)
  42459. *
  42460. * @sample {highcharts} highcharts/plotoptions/column-colorbypoint-false/
  42461. * False by default
  42462. * @sample {highcharts} highcharts/plotoptions/column-colorbypoint-true/
  42463. * True
  42464. *
  42465. * @type {boolean}
  42466. * @default false
  42467. * @since 2.0
  42468. * @product highcharts highstock gantt
  42469. * @apioption plotOptions.column.colorByPoint
  42470. */
  42471. /**
  42472. * A series specific or series type specific color set to apply instead
  42473. * of the global [colors](#colors) when [colorByPoint](
  42474. * #plotOptions.column.colorByPoint) is true.
  42475. *
  42476. * @type {Array<Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject>}
  42477. * @since 3.0
  42478. * @product highcharts highstock gantt
  42479. * @apioption plotOptions.column.colors
  42480. */
  42481. /**
  42482. * When `true`, the columns will center in the category, ignoring null
  42483. * or missing points. When `false`, space will be reserved for null or
  42484. * missing points.
  42485. *
  42486. * @sample {highcharts} highcharts/series-column/centerincategory/
  42487. * Center in category
  42488. *
  42489. * @since 8.0.1
  42490. * @product highcharts highstock gantt
  42491. *
  42492. * @private
  42493. */
  42494. centerInCategory: false,
  42495. /**
  42496. * Padding between each value groups, in x axis units.
  42497. *
  42498. * @sample {highcharts} highcharts/plotoptions/column-grouppadding-default/
  42499. * 0.2 by default
  42500. * @sample {highcharts} highcharts/plotoptions/column-grouppadding-none/
  42501. * No group padding - all columns are evenly spaced
  42502. *
  42503. * @product highcharts highstock gantt
  42504. *
  42505. * @private
  42506. */
  42507. groupPadding: 0.2,
  42508. /**
  42509. * Whether to group non-stacked columns or to let them render
  42510. * independent of each other. Non-grouped columns will be laid out
  42511. * individually and overlap each other.
  42512. *
  42513. * @sample {highcharts} highcharts/plotoptions/column-grouping-false/
  42514. * Grouping disabled
  42515. * @sample {highstock} highcharts/plotoptions/column-grouping-false/
  42516. * Grouping disabled
  42517. *
  42518. * @type {boolean}
  42519. * @default true
  42520. * @since 2.3.0
  42521. * @product highcharts highstock gantt
  42522. * @apioption plotOptions.column.grouping
  42523. */
  42524. /**
  42525. * @ignore-option
  42526. * @private
  42527. */
  42528. marker: null,
  42529. /**
  42530. * The maximum allowed pixel width for a column, translated to the
  42531. * height of a bar in a bar chart. This prevents the columns from
  42532. * becoming too wide when there is a small number of points in the
  42533. * chart.
  42534. *
  42535. * @see [pointWidth](#plotOptions.column.pointWidth)
  42536. *
  42537. * @sample {highcharts} highcharts/plotoptions/column-maxpointwidth-20/
  42538. * Limited to 50
  42539. * @sample {highstock} highcharts/plotoptions/column-maxpointwidth-20/
  42540. * Limited to 50
  42541. *
  42542. * @type {number}
  42543. * @since 4.1.8
  42544. * @product highcharts highstock gantt
  42545. * @apioption plotOptions.column.maxPointWidth
  42546. */
  42547. /**
  42548. * Padding between each column or bar, in x axis units.
  42549. *
  42550. * @sample {highcharts} highcharts/plotoptions/column-pointpadding-default/
  42551. * 0.1 by default
  42552. * @sample {highcharts} highcharts/plotoptions/column-pointpadding-025/
  42553. * 0.25
  42554. * @sample {highcharts} highcharts/plotoptions/column-pointpadding-none/
  42555. * 0 for tightly packed columns
  42556. *
  42557. * @product highcharts highstock gantt
  42558. *
  42559. * @private
  42560. */
  42561. pointPadding: 0.1,
  42562. /**
  42563. * A pixel value specifying a fixed width for each column or bar point.
  42564. * When set to `undefined`, the width is calculated from the
  42565. * `pointPadding` and `groupPadding`. The width effects the dimension
  42566. * that is not based on the point value. For column series it is the
  42567. * hoizontal length and for bar series it is the vertical length.
  42568. *
  42569. * @see [maxPointWidth](#plotOptions.column.maxPointWidth)
  42570. *
  42571. * @sample {highcharts} highcharts/plotoptions/column-pointwidth-20/
  42572. * 20px wide columns regardless of chart width or the amount of
  42573. * data points
  42574. *
  42575. * @type {number}
  42576. * @since 1.2.5
  42577. * @product highcharts highstock gantt
  42578. * @apioption plotOptions.column.pointWidth
  42579. */
  42580. /**
  42581. * A pixel value specifying a fixed width for the column or bar.
  42582. * Overrides pointWidth on the series.
  42583. *
  42584. * @see [series.pointWidth](#plotOptions.column.pointWidth)
  42585. *
  42586. * @type {number}
  42587. * @default undefined
  42588. * @since 7.0.0
  42589. * @product highcharts highstock gantt
  42590. * @apioption series.column.data.pointWidth
  42591. */
  42592. /**
  42593. * The minimal height for a column or width for a bar. By default,
  42594. * 0 values are not shown. To visualize a 0 (or close to zero) point,
  42595. * set the minimal point length to a pixel value like 3\. In stacked
  42596. * column charts, minPointLength might not be respected for tightly
  42597. * packed values.
  42598. *
  42599. * @sample {highcharts} highcharts/plotoptions/column-minpointlength/
  42600. * Zero base value
  42601. * @sample {highcharts} highcharts/plotoptions/column-minpointlength-pos-and-neg/
  42602. * Positive and negative close to zero values
  42603. *
  42604. * @product highcharts highstock gantt
  42605. *
  42606. * @private
  42607. */
  42608. minPointLength: 0,
  42609. /**
  42610. * When the series contains less points than the crop threshold, all
  42611. * points are drawn, event if the points fall outside the visible plot
  42612. * area at the current zoom. The advantage of drawing all points
  42613. * (including markers and columns), is that animation is performed on
  42614. * updates. On the other hand, when the series contains more points than
  42615. * the crop threshold, the series data is cropped to only contain points
  42616. * that fall within the plot area. The advantage of cropping away
  42617. * invisible points is to increase performance on large series.
  42618. *
  42619. * @product highcharts highstock gantt
  42620. *
  42621. * @private
  42622. */
  42623. cropThreshold: 50,
  42624. /**
  42625. * The X axis range that each point is valid for. This determines the
  42626. * width of the column. On a categorized axis, the range will be 1
  42627. * by default (one category unit). On linear and datetime axes, the
  42628. * range will be computed as the distance between the two closest data
  42629. * points.
  42630. *
  42631. * The default `null` means it is computed automatically, but this
  42632. * option can be used to override the automatic value.
  42633. *
  42634. * This option is set by default to 1 if data sorting is enabled.
  42635. *
  42636. * @sample {highcharts} highcharts/plotoptions/column-pointrange/
  42637. * Set the point range to one day on a data set with one week
  42638. * between the points
  42639. *
  42640. * @type {number|null}
  42641. * @since 2.3
  42642. * @product highcharts highstock gantt
  42643. *
  42644. * @private
  42645. */
  42646. pointRange: null,
  42647. states: {
  42648. /**
  42649. * Options for the hovered point. These settings override the normal
  42650. * state options when a point is moused over or touched.
  42651. *
  42652. * @extends plotOptions.series.states.hover
  42653. * @excluding halo, lineWidth, lineWidthPlus, marker
  42654. * @product highcharts highstock gantt
  42655. */
  42656. hover: {
  42657. /** @ignore-option */
  42658. halo: false,
  42659. /**
  42660. * A specific border color for the hovered point. Defaults to
  42661. * inherit the normal state border color.
  42662. *
  42663. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  42664. * @product highcharts gantt
  42665. * @apioption plotOptions.column.states.hover.borderColor
  42666. */
  42667. /**
  42668. * A specific color for the hovered point.
  42669. *
  42670. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  42671. * @product highcharts gantt
  42672. * @apioption plotOptions.column.states.hover.color
  42673. */
  42674. /**
  42675. * How much to brighten the point on interaction. Requires the
  42676. * main color to be defined in hex or rgb(a) format.
  42677. *
  42678. * In styled mode, the hover brightening is by default replaced
  42679. * with a fill-opacity set in the `.highcharts-point:hover`
  42680. * rule.
  42681. *
  42682. * @sample {highcharts} highcharts/plotoptions/column-states-hover-brightness/
  42683. * Brighten by 0.5
  42684. *
  42685. * @product highcharts highstock gantt
  42686. */
  42687. brightness: 0.1
  42688. },
  42689. /**
  42690. * Options for the selected point. These settings override the
  42691. * normal state options when a point is selected.
  42692. *
  42693. * @extends plotOptions.series.states.select
  42694. * @excluding halo, lineWidth, lineWidthPlus, marker
  42695. * @product highcharts highstock gantt
  42696. */
  42697. select: {
  42698. /**
  42699. * A specific color for the selected point.
  42700. *
  42701. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  42702. * @default #cccccc
  42703. * @product highcharts highstock gantt
  42704. */
  42705. color: palette.neutralColor20,
  42706. /**
  42707. * A specific border color for the selected point.
  42708. *
  42709. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  42710. * @default #000000
  42711. * @product highcharts highstock gantt
  42712. */
  42713. borderColor: palette.neutralColor100
  42714. }
  42715. },
  42716. dataLabels: {
  42717. align: void 0,
  42718. verticalAlign: void 0,
  42719. /**
  42720. * The y position offset of the label relative to the point in
  42721. * pixels.
  42722. *
  42723. * @type {number}
  42724. */
  42725. y: void 0
  42726. },
  42727. // false doesn't work well: https://jsfiddle.net/highcharts/hz8fopan/14/
  42728. /**
  42729. * @ignore-option
  42730. * @private
  42731. */
  42732. startFromThreshold: true,
  42733. stickyTracking: false,
  42734. tooltip: {
  42735. distance: 6
  42736. },
  42737. /**
  42738. * The Y axis value to serve as the base for the columns, for
  42739. * distinguishing between values above and below a threshold. If `null`,
  42740. * the columns extend from the padding Y axis minimum.
  42741. *
  42742. * @type {number|null}
  42743. * @since 2.0
  42744. * @product highcharts
  42745. *
  42746. * @private
  42747. */
  42748. threshold: 0,
  42749. /**
  42750. * The width of the border surrounding each column or bar. Defaults to
  42751. * `1` when there is room for a border, but to `0` when the columns are
  42752. * so dense that a border would cover the next column.
  42753. *
  42754. * In styled mode, the stroke width can be set with the
  42755. * `.highcharts-point` rule.
  42756. *
  42757. * @sample {highcharts} highcharts/plotoptions/column-borderwidth/
  42758. * 2px black border
  42759. *
  42760. * @type {number}
  42761. * @default undefined
  42762. * @product highcharts highstock gantt
  42763. * @apioption plotOptions.column.borderWidth
  42764. */
  42765. /**
  42766. * The color of the border surrounding each column or bar.
  42767. *
  42768. * In styled mode, the border stroke can be set with the
  42769. * `.highcharts-point` rule.
  42770. *
  42771. * @sample {highcharts} highcharts/plotoptions/column-bordercolor/
  42772. * Dark gray border
  42773. *
  42774. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  42775. * @default #ffffff
  42776. * @product highcharts highstock gantt
  42777. *
  42778. * @private
  42779. */
  42780. borderColor: palette.backgroundColor
  42781. });
  42782. return ColumnSeries;
  42783. }(Series));
  42784. extend(ColumnSeries.prototype, {
  42785. cropShoulder: 0,
  42786. // When tooltip is not shared, this series (and derivatives) requires
  42787. // direct touch/hover. KD-tree does not apply.
  42788. directTouch: true,
  42789. /**
  42790. * Use a solid rectangle like the area series types
  42791. *
  42792. * @private
  42793. * @function Highcharts.seriesTypes.column#drawLegendSymbol
  42794. *
  42795. * @param {Highcharts.Legend} legend
  42796. * The legend object
  42797. *
  42798. * @param {Highcharts.Series|Highcharts.Point} item
  42799. * The series (this) or point
  42800. */
  42801. drawLegendSymbol: LegendSymbolMixin.drawRectangle,
  42802. getSymbol: noop,
  42803. // use separate negative stacks, unlike area stacks where a negative
  42804. // point is substracted from previous (#1910)
  42805. negStacks: true,
  42806. trackerGroups: ['group', 'dataLabelsGroup']
  42807. });
  42808. SeriesRegistry.registerSeriesType('column', ColumnSeries);
  42809. /* *
  42810. *
  42811. * Export
  42812. *
  42813. * */
  42814. /* *
  42815. *
  42816. * API Declarations
  42817. *
  42818. * */
  42819. /**
  42820. * Adjusted width and x offset of the columns for grouping.
  42821. *
  42822. * @private
  42823. * @interface Highcharts.ColumnMetricsObject
  42824. */ /**
  42825. * Width of the columns.
  42826. * @name Highcharts.ColumnMetricsObject#width
  42827. * @type {number}
  42828. */ /**
  42829. * Offset of the columns.
  42830. * @name Highcharts.ColumnMetricsObject#offset
  42831. * @type {number}
  42832. */
  42833. ''; // detach doclets above
  42834. /* *
  42835. *
  42836. * API Options
  42837. *
  42838. * */
  42839. /**
  42840. * A `column` series. If the [type](#series.column.type) option is
  42841. * not specified, it is inherited from [chart.type](#chart.type).
  42842. *
  42843. * @extends series,plotOptions.column
  42844. * @excluding connectNulls, dataParser, dataURL, gapSize, gapUnit, linecap,
  42845. * lineWidth, marker, connectEnds, step
  42846. * @product highcharts highstock
  42847. * @apioption series.column
  42848. */
  42849. /**
  42850. * An array of data points for the series. For the `column` series type,
  42851. * points can be given in the following ways:
  42852. *
  42853. * 1. An array of numerical values. In this case, the numerical values will be
  42854. * interpreted as `y` options. The `x` values will be automatically
  42855. * calculated, either starting at 0 and incremented by 1, or from
  42856. * `pointStart` and `pointInterval` given in the series options. If the axis
  42857. * has categories, these will be used. Example:
  42858. * ```js
  42859. * data: [0, 5, 3, 5]
  42860. * ```
  42861. *
  42862. * 2. An array of arrays with 2 values. In this case, the values correspond to
  42863. * `x,y`. If the first value is a string, it is applied as the name of the
  42864. * point, and the `x` value is inferred.
  42865. * ```js
  42866. * data: [
  42867. * [0, 6],
  42868. * [1, 2],
  42869. * [2, 6]
  42870. * ]
  42871. * ```
  42872. *
  42873. * 3. An array of objects with named values. The following snippet shows only a
  42874. * few settings, see the complete options set below. If the total number of
  42875. * data points exceeds the series'
  42876. * [turboThreshold](#series.column.turboThreshold), this option is not
  42877. * available.
  42878. * ```js
  42879. * data: [{
  42880. * x: 1,
  42881. * y: 9,
  42882. * name: "Point2",
  42883. * color: "#00FF00"
  42884. * }, {
  42885. * x: 1,
  42886. * y: 6,
  42887. * name: "Point1",
  42888. * color: "#FF00FF"
  42889. * }]
  42890. * ```
  42891. *
  42892. * @sample {highcharts} highcharts/chart/reflow-true/
  42893. * Numerical values
  42894. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  42895. * Arrays of numeric x and y
  42896. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  42897. * Arrays of datetime x and y
  42898. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  42899. * Arrays of point.name and y
  42900. * @sample {highcharts} highcharts/series/data-array-of-objects/
  42901. * Config objects
  42902. *
  42903. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  42904. * @extends series.line.data
  42905. * @excluding marker
  42906. * @product highcharts highstock
  42907. * @apioption series.column.data
  42908. */
  42909. /**
  42910. * The color of the border surrounding the column or bar.
  42911. *
  42912. * In styled mode, the border stroke can be set with the `.highcharts-point`
  42913. * rule.
  42914. *
  42915. * @sample {highcharts} highcharts/plotoptions/column-bordercolor/
  42916. * Dark gray border
  42917. *
  42918. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  42919. * @product highcharts highstock
  42920. * @apioption series.column.data.borderColor
  42921. */
  42922. /**
  42923. * The width of the border surrounding the column or bar.
  42924. *
  42925. * In styled mode, the stroke width can be set with the `.highcharts-point`
  42926. * rule.
  42927. *
  42928. * @sample {highcharts} highcharts/plotoptions/column-borderwidth/
  42929. * 2px black border
  42930. *
  42931. * @type {number}
  42932. * @product highcharts highstock
  42933. * @apioption series.column.data.borderWidth
  42934. */
  42935. /**
  42936. * A name for the dash style to use for the column or bar. Overrides
  42937. * dashStyle on the series.
  42938. *
  42939. * In styled mode, the stroke dash-array can be set with the same classes as
  42940. * listed under [data.color](#series.column.data.color).
  42941. *
  42942. * @see [series.pointWidth](#plotOptions.column.dashStyle)
  42943. *
  42944. * @type {Highcharts.DashStyleValue}
  42945. * @apioption series.column.data.dashStyle
  42946. */
  42947. /**
  42948. * A pixel value specifying a fixed width for the column or bar. Overrides
  42949. * pointWidth on the series. The width effects the dimension that is not based
  42950. * on the point value.
  42951. *
  42952. * @see [series.pointWidth](#plotOptions.column.pointWidth)
  42953. *
  42954. * @type {number}
  42955. * @apioption series.column.data.pointWidth
  42956. */
  42957. /**
  42958. * @excluding halo, lineWidth, lineWidthPlus, marker
  42959. * @product highcharts highstock
  42960. * @apioption series.column.states.hover
  42961. */
  42962. /**
  42963. * @excluding halo, lineWidth, lineWidthPlus, marker
  42964. * @product highcharts highstock
  42965. * @apioption series.column.states.select
  42966. */
  42967. ''; // includes above doclets in transpilat
  42968. return ColumnSeries;
  42969. });
  42970. _registerModule(_modules, 'Series/Bar/BarSeries.js', [_modules['Series/Column/ColumnSeries.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (ColumnSeries, SeriesRegistry, U) {
  42971. /* *
  42972. *
  42973. * (c) 2010-2021 Torstein Honsi
  42974. *
  42975. * License: www.highcharts.com/license
  42976. *
  42977. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  42978. *
  42979. * */
  42980. var __extends = (this && this.__extends) || (function () {
  42981. var extendStatics = function (d,
  42982. b) {
  42983. extendStatics = Object.setPrototypeOf ||
  42984. ({ __proto__: [] } instanceof Array && function (d,
  42985. b) { d.__proto__ = b; }) ||
  42986. function (d,
  42987. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  42988. return extendStatics(d, b);
  42989. };
  42990. return function (d, b) {
  42991. extendStatics(d, b);
  42992. function __() { this.constructor = d; }
  42993. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  42994. };
  42995. })();
  42996. var extend = U.extend,
  42997. merge = U.merge;
  42998. /* *
  42999. *
  43000. * Class
  43001. *
  43002. * */
  43003. /**
  43004. * Bar series type.
  43005. *
  43006. * @private
  43007. * @class
  43008. * @name Highcharts.seriesTypes.bar
  43009. *
  43010. * @augments Highcharts.Series
  43011. */
  43012. var BarSeries = /** @class */ (function (_super) {
  43013. __extends(BarSeries, _super);
  43014. function BarSeries() {
  43015. /* *
  43016. *
  43017. * Static Properties
  43018. *
  43019. * */
  43020. var _this = _super !== null && _super.apply(this,
  43021. arguments) || this;
  43022. /* *
  43023. *
  43024. * Properties
  43025. *
  43026. * */
  43027. _this.data = void 0;
  43028. _this.options = void 0;
  43029. _this.points = void 0;
  43030. return _this;
  43031. }
  43032. /**
  43033. * A bar series is a special type of column series where the columns are
  43034. * horizontal.
  43035. *
  43036. * @sample highcharts/demo/bar-basic/
  43037. * Bar chart
  43038. *
  43039. * @extends plotOptions.column
  43040. * @product highcharts
  43041. * @optionparent plotOptions.bar
  43042. */
  43043. BarSeries.defaultOptions = merge(ColumnSeries.defaultOptions, {
  43044. // nothing here yet
  43045. });
  43046. return BarSeries;
  43047. }(ColumnSeries));
  43048. extend(BarSeries.prototype, {
  43049. inverted: true
  43050. });
  43051. SeriesRegistry.registerSeriesType('bar', BarSeries);
  43052. /* *
  43053. *
  43054. * Default Export
  43055. *
  43056. * */
  43057. /* *
  43058. *
  43059. * API Options
  43060. *
  43061. * */
  43062. /**
  43063. * A `bar` series. If the [type](#series.bar.type) option is not specified,
  43064. * it is inherited from [chart.type](#chart.type).
  43065. *
  43066. * @extends series,plotOptions.bar
  43067. * @excluding connectNulls, dashStyle, dataParser, dataURL, gapSize, gapUnit,
  43068. * linecap, lineWidth, marker, connectEnds, step
  43069. * @product highcharts
  43070. * @apioption series.bar
  43071. */
  43072. /**
  43073. * An array of data points for the series. For the `bar` series type,
  43074. * points can be given in the following ways:
  43075. *
  43076. * 1. An array of numerical values. In this case, the numerical values will be
  43077. * interpreted as `y` options. The `x` values will be automatically
  43078. * calculated, either starting at 0 and incremented by 1, or from
  43079. * `pointStart` and `pointInterval` given in the series options. If the axis
  43080. * has categories, these will be used. Example:
  43081. * ```js
  43082. * data: [0, 5, 3, 5]
  43083. * ```
  43084. *
  43085. * 2. An array of arrays with 2 values. In this case, the values correspond to
  43086. * `x,y`. If the first value is a string, it is applied as the name of the
  43087. * point, and the `x` value is inferred.
  43088. * ```js
  43089. * data: [
  43090. * [0, 5],
  43091. * [1, 10],
  43092. * [2, 3]
  43093. * ]
  43094. * ```
  43095. *
  43096. * 3. An array of objects with named values. The following snippet shows only a
  43097. * few settings, see the complete options set below. If the total number of
  43098. * data points exceeds the series'
  43099. * [turboThreshold](#series.bar.turboThreshold), this option is not
  43100. * available.
  43101. * ```js
  43102. * data: [{
  43103. * x: 1,
  43104. * y: 1,
  43105. * name: "Point2",
  43106. * color: "#00FF00"
  43107. * }, {
  43108. * x: 1,
  43109. * y: 10,
  43110. * name: "Point1",
  43111. * color: "#FF00FF"
  43112. * }]
  43113. * ```
  43114. *
  43115. * @sample {highcharts} highcharts/chart/reflow-true/
  43116. * Numerical values
  43117. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  43118. * Arrays of numeric x and y
  43119. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  43120. * Arrays of datetime x and y
  43121. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  43122. * Arrays of point.name and y
  43123. * @sample {highcharts} highcharts/series/data-array-of-objects/
  43124. * Config objects
  43125. *
  43126. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  43127. * @extends series.column.data
  43128. * @product highcharts
  43129. * @apioption series.bar.data
  43130. */
  43131. /**
  43132. * @excluding halo,lineWidth,lineWidthPlus,marker
  43133. * @product highcharts highstock
  43134. * @apioption series.bar.states.hover
  43135. */
  43136. /**
  43137. * @excluding halo,lineWidth,lineWidthPlus,marker
  43138. * @product highcharts highstock
  43139. * @apioption series.bar.states.select
  43140. */
  43141. ''; // gets doclets above into transpilat
  43142. return BarSeries;
  43143. });
  43144. _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) {
  43145. /* *
  43146. *
  43147. * (c) 2010-2021 Torstein Honsi
  43148. *
  43149. * License: www.highcharts.com/license
  43150. *
  43151. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  43152. *
  43153. * */
  43154. var __extends = (this && this.__extends) || (function () {
  43155. var extendStatics = function (d,
  43156. b) {
  43157. extendStatics = Object.setPrototypeOf ||
  43158. ({ __proto__: [] } instanceof Array && function (d,
  43159. b) { d.__proto__ = b; }) ||
  43160. function (d,
  43161. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  43162. return extendStatics(d, b);
  43163. };
  43164. return function (d, b) {
  43165. extendStatics(d, b);
  43166. function __() { this.constructor = d; }
  43167. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  43168. };
  43169. })();
  43170. var addEvent = U.addEvent,
  43171. extend = U.extend,
  43172. merge = U.merge;
  43173. /* *
  43174. *
  43175. * Class
  43176. *
  43177. * */
  43178. /**
  43179. * Scatter series type.
  43180. *
  43181. * @private
  43182. */
  43183. var ScatterSeries = /** @class */ (function (_super) {
  43184. __extends(ScatterSeries, _super);
  43185. function ScatterSeries() {
  43186. var _this = _super !== null && _super.apply(this,
  43187. arguments) || this;
  43188. /* *
  43189. *
  43190. * Properties
  43191. *
  43192. * */
  43193. _this.data = void 0;
  43194. _this.options = void 0;
  43195. _this.points = void 0;
  43196. return _this;
  43197. /* eslint-enable valid-jsdoc */
  43198. }
  43199. /* *
  43200. *
  43201. * Functions
  43202. *
  43203. * */
  43204. /* eslint-disable valid-jsdoc */
  43205. /**
  43206. * Optionally add the jitter effect.
  43207. * @private
  43208. */
  43209. ScatterSeries.prototype.applyJitter = function () {
  43210. var series = this,
  43211. jitter = this.options.jitter,
  43212. len = this.points.length;
  43213. /**
  43214. * Return a repeatable, pseudo-random number based on an integer
  43215. * seed.
  43216. * @private
  43217. */
  43218. function unrandom(seed) {
  43219. var rand = Math.sin(seed) * 10000;
  43220. return rand - Math.floor(rand);
  43221. }
  43222. if (jitter) {
  43223. this.points.forEach(function (point, i) {
  43224. ['x', 'y'].forEach(function (dim, j) {
  43225. var axis,
  43226. plotProp = 'plot' + dim.toUpperCase(),
  43227. min,
  43228. max,
  43229. translatedJitter;
  43230. if (jitter[dim] && !point.isNull) {
  43231. axis = series[dim + 'Axis'];
  43232. translatedJitter =
  43233. jitter[dim] * axis.transA;
  43234. if (axis && !axis.isLog) {
  43235. // Identify the outer bounds of the jitter range
  43236. min = Math.max(0, point[plotProp] - translatedJitter);
  43237. max = Math.min(axis.len, point[plotProp] + translatedJitter);
  43238. // Find a random position within this range
  43239. point[plotProp] = min +
  43240. (max - min) * unrandom(i + j * len);
  43241. // Update clientX for the tooltip k-d-tree
  43242. if (dim === 'x') {
  43243. point.clientX = point.plotX;
  43244. }
  43245. }
  43246. }
  43247. });
  43248. });
  43249. }
  43250. };
  43251. /**
  43252. * @private
  43253. * @function Highcharts.seriesTypes.scatter#drawGraph
  43254. */
  43255. ScatterSeries.prototype.drawGraph = function () {
  43256. if (this.options.lineWidth) {
  43257. _super.prototype.drawGraph.call(this);
  43258. }
  43259. else if (this.graph) {
  43260. this.graph = this.graph.destroy();
  43261. }
  43262. };
  43263. /**
  43264. * A scatter plot uses cartesian coordinates to display values for two
  43265. * variables for a set of data.
  43266. *
  43267. * @sample {highcharts} highcharts/demo/scatter/
  43268. * Scatter plot
  43269. *
  43270. * @extends plotOptions.line
  43271. * @excluding cropThreshold, pointPlacement, shadow, useOhlcData
  43272. * @product highcharts highstock
  43273. * @optionparent plotOptions.scatter
  43274. */
  43275. ScatterSeries.defaultOptions = merge(LineSeries.defaultOptions, {
  43276. /**
  43277. * The width of the line connecting the data points.
  43278. *
  43279. * @sample {highcharts} highcharts/plotoptions/scatter-linewidth-none/
  43280. * 0 by default
  43281. * @sample {highcharts} highcharts/plotoptions/scatter-linewidth-1/
  43282. * 1px
  43283. *
  43284. * @product highcharts highstock
  43285. */
  43286. lineWidth: 0,
  43287. findNearestPointBy: 'xy',
  43288. /**
  43289. * Apply a jitter effect for the rendered markers. When plotting
  43290. * discrete values, a little random noise may help telling the points
  43291. * apart. The jitter setting applies a random displacement of up to `n`
  43292. * axis units in either direction. So for example on a horizontal X
  43293. * axis, setting the `jitter.x` to 0.24 will render the point in a
  43294. * random position between 0.24 units to the left and 0.24 units to the
  43295. * right of the true axis position. On a category axis, setting it to
  43296. * 0.5 will fill up the bin and make the data appear continuous.
  43297. *
  43298. * When rendered on top of a box plot or a column series, a jitter value
  43299. * of 0.24 will correspond to the underlying series' default
  43300. * [groupPadding](
  43301. * https://api.highcharts.com/highcharts/plotOptions.column.groupPadding)
  43302. * and [pointPadding](
  43303. * https://api.highcharts.com/highcharts/plotOptions.column.pointPadding)
  43304. * settings.
  43305. *
  43306. * @sample {highcharts} highcharts/series-scatter/jitter
  43307. * Jitter on a scatter plot
  43308. *
  43309. * @sample {highcharts} highcharts/series-scatter/jitter-boxplot
  43310. * Jittered scatter plot on top of a box plot
  43311. *
  43312. * @product highcharts highstock
  43313. * @since 7.0.2
  43314. */
  43315. jitter: {
  43316. /**
  43317. * The maximal X offset for the random jitter effect.
  43318. */
  43319. x: 0,
  43320. /**
  43321. * The maximal Y offset for the random jitter effect.
  43322. */
  43323. y: 0
  43324. },
  43325. marker: {
  43326. enabled: true // Overrides auto-enabling in line series (#3647)
  43327. },
  43328. /**
  43329. * Sticky tracking of mouse events. When true, the `mouseOut` event
  43330. * on a series isn't triggered until the mouse moves over another
  43331. * series, or out of the plot area. When false, the `mouseOut` event on
  43332. * a series is triggered when the mouse leaves the area around the
  43333. * series' graph or markers. This also implies the tooltip. When
  43334. * `stickyTracking` is false and `tooltip.shared` is false, the tooltip
  43335. * will be hidden when moving the mouse between series.
  43336. *
  43337. * @type {boolean}
  43338. * @default false
  43339. * @product highcharts highstock
  43340. * @apioption plotOptions.scatter.stickyTracking
  43341. */
  43342. /**
  43343. * A configuration object for the tooltip rendering of each single
  43344. * series. Properties are inherited from [tooltip](#tooltip).
  43345. * Overridable properties are `headerFormat`, `pointFormat`,
  43346. * `yDecimals`, `xDateFormat`, `yPrefix` and `ySuffix`. Unlike other
  43347. * series, in a scatter plot the series.name by default shows in the
  43348. * headerFormat and point.x and point.y in the pointFormat.
  43349. *
  43350. * @product highcharts highstock
  43351. */
  43352. tooltip: {
  43353. headerFormat: '<span style="color:{point.color}">\u25CF</span> ' +
  43354. '<span style="font-size: 10px"> {series.name}</span><br/>',
  43355. pointFormat: 'x: <b>{point.x}</b><br/>y: <b>{point.y}</b><br/>'
  43356. }
  43357. });
  43358. return ScatterSeries;
  43359. }(LineSeries));
  43360. extend(ScatterSeries.prototype, {
  43361. drawTracker: ColumnSeries.prototype.drawTracker,
  43362. sorted: false,
  43363. requireSorting: false,
  43364. noSharedTooltip: true,
  43365. trackerGroups: ['group', 'markerGroup', 'dataLabelsGroup'],
  43366. takeOrdinalPosition: false // #2342
  43367. });
  43368. /* *
  43369. *
  43370. * Events
  43371. *
  43372. * */
  43373. /* eslint-disable no-invalid-this */
  43374. addEvent(ScatterSeries, 'afterTranslate', function () {
  43375. this.applyJitter();
  43376. });
  43377. SeriesRegistry.registerSeriesType('scatter', ScatterSeries);
  43378. /* *
  43379. *
  43380. * Default Export
  43381. *
  43382. * */
  43383. /* *
  43384. *
  43385. * API Options
  43386. *
  43387. * */
  43388. /**
  43389. * A `scatter` series. If the [type](#series.scatter.type) option is
  43390. * not specified, it is inherited from [chart.type](#chart.type).
  43391. *
  43392. * @extends series,plotOptions.scatter
  43393. * @excluding cropThreshold, dataParser, dataURL, useOhlcData
  43394. * @product highcharts highstock
  43395. * @apioption series.scatter
  43396. */
  43397. /**
  43398. * An array of data points for the series. For the `scatter` series
  43399. * type, points can be given in the following ways:
  43400. *
  43401. * 1. An array of numerical values. In this case, the numerical values will be
  43402. * interpreted as `y` options. The `x` values will be automatically
  43403. * calculated, either starting at 0 and incremented by 1, or from
  43404. * `pointStart` and `pointInterval` given in the series options. If the axis
  43405. * has categories, these will be used. Example:
  43406. * ```js
  43407. * data: [0, 5, 3, 5]
  43408. * ```
  43409. *
  43410. * 2. An array of arrays with 2 values. In this case, the values correspond to
  43411. * `x,y`. If the first value is a string, it is applied as the name of the
  43412. * point, and the `x` value is inferred.
  43413. * ```js
  43414. * data: [
  43415. * [0, 0],
  43416. * [1, 8],
  43417. * [2, 9]
  43418. * ]
  43419. * ```
  43420. *
  43421. * 3. An array of objects with named values. The following snippet shows only a
  43422. * few settings, see the complete options set below. If the total number of
  43423. * data points exceeds the series'
  43424. * [turboThreshold](#series.scatter.turboThreshold), this option is not
  43425. * available.
  43426. * ```js
  43427. * data: [{
  43428. * x: 1,
  43429. * y: 2,
  43430. * name: "Point2",
  43431. * color: "#00FF00"
  43432. * }, {
  43433. * x: 1,
  43434. * y: 4,
  43435. * name: "Point1",
  43436. * color: "#FF00FF"
  43437. * }]
  43438. * ```
  43439. *
  43440. * @sample {highcharts} highcharts/chart/reflow-true/
  43441. * Numerical values
  43442. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  43443. * Arrays of numeric x and y
  43444. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  43445. * Arrays of datetime x and y
  43446. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  43447. * Arrays of point.name and y
  43448. * @sample {highcharts} highcharts/series/data-array-of-objects/
  43449. * Config objects
  43450. *
  43451. * @type {Array<number|Array<(number|string),(number|null)>|null|*>}
  43452. * @extends series.line.data
  43453. * @product highcharts highstock
  43454. * @apioption series.scatter.data
  43455. */
  43456. ''; // adds doclets above to transpilat
  43457. return ScatterSeries;
  43458. });
  43459. _registerModule(_modules, 'Mixins/CenteredSeries.js', [_modules['Core/Globals.js'], _modules['Core/Series/Series.js'], _modules['Core/Utilities.js']], function (H, Series, U) {
  43460. /* *
  43461. *
  43462. * (c) 2010-2021 Torstein Honsi
  43463. *
  43464. * License: www.highcharts.com/license
  43465. *
  43466. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  43467. *
  43468. * */
  43469. /**
  43470. * @private
  43471. * @interface Highcharts.RadianAngles
  43472. */ /**
  43473. * @name Highcharts.RadianAngles#end
  43474. * @type {number}
  43475. */ /**
  43476. * @name Highcharts.RadianAngles#start
  43477. * @type {number}
  43478. */
  43479. var isNumber = U.isNumber,
  43480. pick = U.pick,
  43481. relativeLength = U.relativeLength;
  43482. var deg2rad = H.deg2rad;
  43483. /* eslint-disable valid-jsdoc */
  43484. /**
  43485. * @private
  43486. * @mixin Highcharts.CenteredSeriesMixin
  43487. */
  43488. var centeredSeriesMixin = H.CenteredSeriesMixin = {
  43489. /**
  43490. * Get the center of the pie based on the size and center options relative
  43491. * to the plot area. Borrowed by the polar and gauge series types.
  43492. *
  43493. * @private
  43494. * @function Highcharts.CenteredSeriesMixin.getCenter
  43495. *
  43496. * @return {Array<number>}
  43497. */
  43498. getCenter: function () {
  43499. var options = this.options,
  43500. chart = this.chart,
  43501. slicingRoom = 2 * (options.slicedOffset || 0),
  43502. handleSlicingRoom,
  43503. plotWidth = chart.plotWidth - 2 * slicingRoom,
  43504. plotHeight = chart.plotHeight - 2 * slicingRoom,
  43505. centerOption = options.center,
  43506. smallestSize = Math.min(plotWidth,
  43507. plotHeight),
  43508. size = options.size,
  43509. innerSize = options.innerSize || 0,
  43510. positions,
  43511. i,
  43512. value;
  43513. if (typeof size === 'string') {
  43514. size = parseFloat(size);
  43515. }
  43516. if (typeof innerSize === 'string') {
  43517. innerSize = parseFloat(innerSize);
  43518. }
  43519. positions = [
  43520. pick(centerOption[0], '50%'),
  43521. pick(centerOption[1], '50%'),
  43522. // Prevent from negative values
  43523. pick(size && size < 0 ? void 0 : options.size, '100%'),
  43524. pick(innerSize && innerSize < 0 ? void 0 : options.innerSize || 0, '0%')
  43525. ];
  43526. // No need for inner size in angular (gauges) series but still required
  43527. // for pie series
  43528. if (chart.angular && !(this instanceof Series)) {
  43529. positions[3] = 0;
  43530. }
  43531. for (i = 0; i < 4; ++i) {
  43532. value = positions[i];
  43533. handleSlicingRoom = i < 2 || (i === 2 && /%$/.test(value));
  43534. // i == 0: centerX, relative to width
  43535. // i == 1: centerY, relative to height
  43536. // i == 2: size, relative to smallestSize
  43537. // i == 3: innerSize, relative to size
  43538. positions[i] = relativeLength(value, [plotWidth, plotHeight, smallestSize, positions[2]][i]) + (handleSlicingRoom ? slicingRoom : 0);
  43539. }
  43540. // innerSize cannot be larger than size (#3632)
  43541. if (positions[3] > positions[2]) {
  43542. positions[3] = positions[2];
  43543. }
  43544. return positions;
  43545. },
  43546. /**
  43547. * getStartAndEndRadians - Calculates start and end angles in radians.
  43548. * Used in series types such as pie and sunburst.
  43549. *
  43550. * @private
  43551. * @function Highcharts.CenteredSeriesMixin.getStartAndEndRadians
  43552. *
  43553. * @param {number} [start]
  43554. * Start angle in degrees.
  43555. *
  43556. * @param {number} [end]
  43557. * Start angle in degrees.
  43558. *
  43559. * @return {Highcharts.RadianAngles}
  43560. * Returns an object containing start and end angles as radians.
  43561. */
  43562. getStartAndEndRadians: function (start, end) {
  43563. var startAngle = isNumber(start) ? start : 0, // must be a number
  43564. endAngle = ((isNumber(end) && // must be a number
  43565. end > startAngle && // must be larger than the start angle
  43566. // difference must be less than 360 degrees
  43567. (end - startAngle) < 360) ?
  43568. end :
  43569. startAngle + 360),
  43570. correction = -90;
  43571. return {
  43572. start: deg2rad * (startAngle + correction),
  43573. end: deg2rad * (endAngle + correction)
  43574. };
  43575. }
  43576. };
  43577. return centeredSeriesMixin;
  43578. });
  43579. _registerModule(_modules, 'Series/Pie/PiePoint.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Series/Point.js'], _modules['Core/Utilities.js']], function (A, Point, U) {
  43580. /* *
  43581. *
  43582. * (c) 2010-2021 Torstein Honsi
  43583. *
  43584. * License: www.highcharts.com/license
  43585. *
  43586. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  43587. *
  43588. * */
  43589. var __extends = (this && this.__extends) || (function () {
  43590. var extendStatics = function (d,
  43591. b) {
  43592. extendStatics = Object.setPrototypeOf ||
  43593. ({ __proto__: [] } instanceof Array && function (d,
  43594. b) { d.__proto__ = b; }) ||
  43595. function (d,
  43596. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  43597. return extendStatics(d, b);
  43598. };
  43599. return function (d, b) {
  43600. extendStatics(d, b);
  43601. function __() { this.constructor = d; }
  43602. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  43603. };
  43604. })();
  43605. var setAnimation = A.setAnimation;
  43606. var addEvent = U.addEvent,
  43607. defined = U.defined,
  43608. extend = U.extend,
  43609. isNumber = U.isNumber,
  43610. pick = U.pick,
  43611. relativeLength = U.relativeLength;
  43612. /* *
  43613. *
  43614. * Class
  43615. *
  43616. * */
  43617. var PiePoint = /** @class */ (function (_super) {
  43618. __extends(PiePoint, _super);
  43619. function PiePoint() {
  43620. /* *
  43621. *
  43622. * Properties
  43623. *
  43624. * */
  43625. var _this = _super !== null && _super.apply(this,
  43626. arguments) || this;
  43627. _this.labelDistance = void 0;
  43628. _this.options = void 0;
  43629. _this.series = void 0;
  43630. return _this;
  43631. }
  43632. /* *
  43633. *
  43634. * Functions
  43635. *
  43636. * */
  43637. /* eslint-disable valid-jsdoc */
  43638. /**
  43639. * Extendable method for getting the path of the connector between the
  43640. * data label and the pie slice.
  43641. * @private
  43642. */
  43643. PiePoint.prototype.getConnectorPath = function () {
  43644. var labelPosition = this.labelPosition,
  43645. options = this.series.options.dataLabels,
  43646. connectorShape = options.connectorShape,
  43647. predefinedShapes = this.connectorShapes;
  43648. // find out whether to use the predefined shape
  43649. if (predefinedShapes[connectorShape]) {
  43650. connectorShape = predefinedShapes[connectorShape];
  43651. }
  43652. return connectorShape.call(this, {
  43653. // pass simplified label position object for user's convenience
  43654. x: labelPosition.final.x,
  43655. y: labelPosition.final.y,
  43656. alignment: labelPosition.alignment
  43657. }, labelPosition.connectorPosition, options);
  43658. };
  43659. /**
  43660. * @private
  43661. */
  43662. PiePoint.prototype.getTranslate = function () {
  43663. return this.sliced ? this.slicedTranslation : {
  43664. translateX: 0,
  43665. translateY: 0
  43666. };
  43667. };
  43668. /**
  43669. * @private
  43670. */
  43671. PiePoint.prototype.haloPath = function (size) {
  43672. var shapeArgs = this.shapeArgs;
  43673. return this.sliced || !this.visible ?
  43674. [] :
  43675. this.series.chart.renderer.symbols.arc(shapeArgs.x, shapeArgs.y, shapeArgs.r + size, shapeArgs.r + size, {
  43676. // Substract 1px to ensure the background is not bleeding
  43677. // through between the halo and the slice (#7495).
  43678. innerR: shapeArgs.r - 1,
  43679. start: shapeArgs.start,
  43680. end: shapeArgs.end
  43681. });
  43682. };
  43683. /**
  43684. * Initialize the pie slice.
  43685. * @private
  43686. */
  43687. PiePoint.prototype.init = function () {
  43688. Point.prototype.init.apply(this, arguments);
  43689. var point = this,
  43690. toggleSlice;
  43691. point.name = pick(point.name, 'Slice');
  43692. // add event listener for select
  43693. toggleSlice = function (e) {
  43694. point.slice(e.type === 'select');
  43695. };
  43696. addEvent(point, 'select', toggleSlice);
  43697. addEvent(point, 'unselect', toggleSlice);
  43698. return point;
  43699. };
  43700. /**
  43701. * Negative points are not valid (#1530, #3623, #5322)
  43702. * @private
  43703. */
  43704. PiePoint.prototype.isValid = function () {
  43705. return isNumber(this.y) && this.y >= 0;
  43706. };
  43707. /**
  43708. * Toggle the visibility of the pie slice.
  43709. * @private
  43710. *
  43711. * @param {boolean} vis
  43712. * Whether to show the slice or not. If undefined, the visibility is
  43713. * toggled.
  43714. */
  43715. PiePoint.prototype.setVisible = function (vis, redraw) {
  43716. var point = this,
  43717. series = point.series,
  43718. chart = series.chart,
  43719. ignoreHiddenPoint = series.options.ignoreHiddenPoint;
  43720. redraw = pick(redraw, ignoreHiddenPoint);
  43721. if (vis !== point.visible) {
  43722. // If called without an argument, toggle visibility
  43723. point.visible = point.options.visible = vis =
  43724. typeof vis === 'undefined' ? !point.visible : vis;
  43725. // update userOptions.data
  43726. series.options.data[series.data.indexOf(point)] =
  43727. point.options;
  43728. // Show and hide associated elements. This is performed
  43729. // regardless of redraw or not, because chart.redraw only
  43730. // handles full series.
  43731. ['graphic', 'dataLabel', 'connector', 'shadowGroup'].forEach(function (key) {
  43732. if (point[key]) {
  43733. point[key][vis ? 'show' : 'hide'](vis);
  43734. }
  43735. });
  43736. if (point.legendItem) {
  43737. chart.legend.colorizeItem(point, vis);
  43738. }
  43739. // #4170, hide halo after hiding point
  43740. if (!vis && point.state === 'hover') {
  43741. point.setState('');
  43742. }
  43743. // Handle ignore hidden slices
  43744. if (ignoreHiddenPoint) {
  43745. series.isDirty = true;
  43746. }
  43747. if (redraw) {
  43748. chart.redraw();
  43749. }
  43750. }
  43751. };
  43752. /**
  43753. * Set or toggle whether the slice is cut out from the pie.
  43754. * @private
  43755. *
  43756. * @param {boolean} sliced
  43757. * When undefined, the slice state is toggled.
  43758. *
  43759. * @param {boolean} redraw
  43760. * Whether to redraw the chart. True by default.
  43761. *
  43762. * @param {boolean|Partial<Highcharts.AnimationOptionsObject>}
  43763. * Animation options.
  43764. */
  43765. PiePoint.prototype.slice = function (sliced, redraw, animation) {
  43766. var point = this,
  43767. series = point.series,
  43768. chart = series.chart;
  43769. setAnimation(animation, chart);
  43770. // redraw is true by default
  43771. redraw = pick(redraw, true);
  43772. /**
  43773. * Pie series only. Whether to display a slice offset from the
  43774. * center.
  43775. * @name Highcharts.Point#sliced
  43776. * @type {boolean|undefined}
  43777. */
  43778. // if called without an argument, toggle
  43779. point.sliced = point.options.sliced = sliced =
  43780. defined(sliced) ? sliced : !point.sliced;
  43781. // update userOptions.data
  43782. series.options.data[series.data.indexOf(point)] =
  43783. point.options;
  43784. if (point.graphic) {
  43785. point.graphic.animate(this.getTranslate());
  43786. }
  43787. if (point.shadowGroup) {
  43788. point.shadowGroup.animate(this.getTranslate());
  43789. }
  43790. };
  43791. return PiePoint;
  43792. }(Point));
  43793. extend(PiePoint.prototype, {
  43794. connectorShapes: {
  43795. // only one available before v7.0.0
  43796. fixedOffset: function (labelPosition, connectorPosition, options) {
  43797. var breakAt = connectorPosition.breakAt,
  43798. touchingSliceAt = connectorPosition.touchingSliceAt,
  43799. lineSegment = options.softConnector ? [
  43800. 'C',
  43801. // 1st control point (of the curve)
  43802. labelPosition.x +
  43803. // 5 gives the connector a little horizontal bend
  43804. (labelPosition.alignment === 'left' ? -5 : 5),
  43805. labelPosition.y,
  43806. 2 * breakAt.x - touchingSliceAt.x,
  43807. 2 * breakAt.y - touchingSliceAt.y,
  43808. breakAt.x,
  43809. breakAt.y //
  43810. ] : [
  43811. 'L',
  43812. breakAt.x,
  43813. breakAt.y
  43814. ];
  43815. // assemble the path
  43816. return ([
  43817. ['M', labelPosition.x, labelPosition.y],
  43818. lineSegment,
  43819. ['L', touchingSliceAt.x, touchingSliceAt.y]
  43820. ]);
  43821. },
  43822. straight: function (labelPosition, connectorPosition) {
  43823. var touchingSliceAt = connectorPosition.touchingSliceAt;
  43824. // direct line to the slice
  43825. return [
  43826. ['M', labelPosition.x, labelPosition.y],
  43827. ['L', touchingSliceAt.x, touchingSliceAt.y]
  43828. ];
  43829. },
  43830. crookedLine: function (labelPosition, connectorPosition, options) {
  43831. var touchingSliceAt = connectorPosition.touchingSliceAt,
  43832. series = this.series,
  43833. pieCenterX = series.center[0],
  43834. plotWidth = series.chart.plotWidth,
  43835. plotLeft = series.chart.plotLeft,
  43836. alignment = labelPosition.alignment,
  43837. radius = this.shapeArgs.r,
  43838. crookDistance = relativeLength(// % to fraction
  43839. options.crookDistance, 1),
  43840. crookX = alignment === 'left' ?
  43841. pieCenterX + radius + (plotWidth + plotLeft -
  43842. pieCenterX - radius) * (1 - crookDistance) :
  43843. plotLeft + (pieCenterX - radius) * crookDistance,
  43844. segmentWithCrook = [
  43845. 'L',
  43846. crookX,
  43847. labelPosition.y
  43848. ],
  43849. useCrook = true;
  43850. // crookedLine formula doesn't make sense if the path overlaps
  43851. // the label - use straight line instead in that case
  43852. if (alignment === 'left' ?
  43853. (crookX > labelPosition.x || crookX < touchingSliceAt.x) :
  43854. (crookX < labelPosition.x || crookX > touchingSliceAt.x)) {
  43855. useCrook = false;
  43856. }
  43857. // assemble the path
  43858. var path = [
  43859. ['M',
  43860. labelPosition.x,
  43861. labelPosition.y]
  43862. ];
  43863. if (useCrook) {
  43864. path.push(segmentWithCrook);
  43865. }
  43866. path.push(['L', touchingSliceAt.x, touchingSliceAt.y]);
  43867. return path;
  43868. }
  43869. }
  43870. });
  43871. /* *
  43872. *
  43873. * Default Export
  43874. *
  43875. * */
  43876. return PiePoint;
  43877. });
  43878. _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/Symbols.js'], _modules['Core/Utilities.js']], function (CenteredSeriesMixin, ColumnSeries, H, LegendSymbolMixin, palette, PiePoint, Series, SeriesRegistry, Symbols, U) {
  43879. /* *
  43880. *
  43881. * (c) 2010-2021 Torstein Honsi
  43882. *
  43883. * License: www.highcharts.com/license
  43884. *
  43885. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  43886. *
  43887. * */
  43888. var __extends = (this && this.__extends) || (function () {
  43889. var extendStatics = function (d,
  43890. b) {
  43891. extendStatics = Object.setPrototypeOf ||
  43892. ({ __proto__: [] } instanceof Array && function (d,
  43893. b) { d.__proto__ = b; }) ||
  43894. function (d,
  43895. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  43896. return extendStatics(d, b);
  43897. };
  43898. return function (d, b) {
  43899. extendStatics(d, b);
  43900. function __() { this.constructor = d; }
  43901. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  43902. };
  43903. })();
  43904. var getStartAndEndRadians = CenteredSeriesMixin.getStartAndEndRadians;
  43905. var noop = H.noop;
  43906. var clamp = U.clamp,
  43907. extend = U.extend,
  43908. fireEvent = U.fireEvent,
  43909. merge = U.merge,
  43910. pick = U.pick,
  43911. relativeLength = U.relativeLength;
  43912. /* *
  43913. *
  43914. * Class
  43915. *
  43916. * */
  43917. /**
  43918. * Pie series type.
  43919. *
  43920. * @private
  43921. * @class
  43922. * @name Highcharts.seriesTypes.pie
  43923. *
  43924. * @augments Highcharts.Series
  43925. */
  43926. var PieSeries = /** @class */ (function (_super) {
  43927. __extends(PieSeries, _super);
  43928. function PieSeries() {
  43929. /* *
  43930. *
  43931. * Static Properties
  43932. *
  43933. * */
  43934. var _this = _super !== null && _super.apply(this,
  43935. arguments) || this;
  43936. /* *
  43937. *
  43938. * Properties
  43939. *
  43940. * */
  43941. _this.center = void 0;
  43942. _this.data = void 0;
  43943. _this.maxLabelDistance = void 0;
  43944. _this.options = void 0;
  43945. _this.points = void 0;
  43946. return _this;
  43947. /* eslint-enable valid-jsdoc */
  43948. }
  43949. /* *
  43950. *
  43951. * Functions
  43952. *
  43953. * */
  43954. /* eslint-disable valid-jsdoc */
  43955. /**
  43956. * Animates the pies in.
  43957. * @private
  43958. */
  43959. PieSeries.prototype.animate = function (init) {
  43960. var series = this,
  43961. points = series.points,
  43962. startAngleRad = series.startAngleRad;
  43963. if (!init) {
  43964. points.forEach(function (point) {
  43965. var graphic = point.graphic,
  43966. args = point.shapeArgs;
  43967. if (graphic && args) {
  43968. // start values
  43969. graphic.attr({
  43970. // animate from inner radius (#779)
  43971. r: pick(point.startR, (series.center && series.center[3] / 2)),
  43972. start: startAngleRad,
  43973. end: startAngleRad
  43974. });
  43975. // animate
  43976. graphic.animate({
  43977. r: args.r,
  43978. start: args.start,
  43979. end: args.end
  43980. }, series.options.animation);
  43981. }
  43982. });
  43983. }
  43984. };
  43985. /**
  43986. * Called internally to draw auxiliary graph in pie-like series in
  43987. * situtation when the default graph is not sufficient enough to present
  43988. * the data well. Auxiliary graph is saved in the same object as
  43989. * regular graph.
  43990. * @private
  43991. */
  43992. PieSeries.prototype.drawEmpty = function () {
  43993. var centerX,
  43994. centerY,
  43995. start = this.startAngleRad,
  43996. end = this.endAngleRad,
  43997. options = this.options;
  43998. // Draw auxiliary graph if there're no visible points.
  43999. if (this.total === 0 && this.center) {
  44000. centerX = this.center[0];
  44001. centerY = this.center[1];
  44002. if (!this.graph) {
  44003. this.graph = this.chart.renderer
  44004. .arc(centerX, centerY, this.center[1] / 2, 0, start, end)
  44005. .addClass('highcharts-empty-series')
  44006. .add(this.group);
  44007. }
  44008. this.graph.attr({
  44009. d: Symbols.arc(centerX, centerY, this.center[2] / 2, 0, {
  44010. start: start,
  44011. end: end,
  44012. innerR: this.center[3] / 2
  44013. })
  44014. });
  44015. if (!this.chart.styledMode) {
  44016. this.graph.attr({
  44017. 'stroke-width': options.borderWidth,
  44018. fill: options.fillColor || 'none',
  44019. stroke: options.color || palette.neutralColor20
  44020. });
  44021. }
  44022. }
  44023. else if (this.graph) { // Destroy the graph object.
  44024. this.graph = this.graph.destroy();
  44025. }
  44026. };
  44027. /**
  44028. * Slices in pie chart are initialized in DOM, but it's shapes and
  44029. * animations are normally run in `drawPoints()`.
  44030. * @private
  44031. */
  44032. PieSeries.prototype.drawPoints = function () {
  44033. var renderer = this.chart.renderer;
  44034. this.points.forEach(function (point) {
  44035. // When updating a series between 2d and 3d or cartesian and
  44036. // polar, the shape type changes.
  44037. if (point.graphic && point.hasNewShapeType()) {
  44038. point.graphic = point.graphic.destroy();
  44039. }
  44040. if (!point.graphic) {
  44041. point.graphic = renderer[point.shapeType](point.shapeArgs)
  44042. .add(point.series.group);
  44043. point.delayedRendering = true;
  44044. }
  44045. });
  44046. };
  44047. /**
  44048. * Extend the generatePoints method by adding total and percentage
  44049. * properties to each point
  44050. * @private
  44051. */
  44052. PieSeries.prototype.generatePoints = function () {
  44053. _super.prototype.generatePoints.call(this);
  44054. this.updateTotals();
  44055. };
  44056. /**
  44057. * Utility for getting the x value from a given y, used for
  44058. * anticollision logic in data labels. Added point for using specific
  44059. * points' label distance.
  44060. * @private
  44061. */
  44062. PieSeries.prototype.getX = function (y, left, point) {
  44063. var center = this.center,
  44064. // Variable pie has individual radius
  44065. radius = this.radii ?
  44066. this.radii[point.index] || 0 :
  44067. center[2] / 2,
  44068. angle,
  44069. x;
  44070. angle = Math.asin(clamp((y - center[1]) / (radius + point.labelDistance), -1, 1));
  44071. x = center[0] +
  44072. (left ? -1 : 1) *
  44073. (Math.cos(angle) * (radius + point.labelDistance)) +
  44074. (point.labelDistance > 0 ?
  44075. (left ? -1 : 1) * this.options.dataLabels.padding :
  44076. 0);
  44077. return x;
  44078. };
  44079. /**
  44080. * Define hasData function for non-cartesian series. Returns true if the
  44081. * series has points at all.
  44082. * @private
  44083. */
  44084. PieSeries.prototype.hasData = function () {
  44085. return !!this.processedXData.length; // != 0
  44086. };
  44087. /**
  44088. * Draw the data points
  44089. * @private
  44090. */
  44091. PieSeries.prototype.redrawPoints = function () {
  44092. var series = this,
  44093. chart = series.chart,
  44094. renderer = chart.renderer,
  44095. groupTranslation,
  44096. graphic,
  44097. pointAttr,
  44098. shapeArgs,
  44099. shadow = series.options.shadow;
  44100. this.drawEmpty();
  44101. if (shadow && !series.shadowGroup && !chart.styledMode) {
  44102. series.shadowGroup = renderer
  44103. .g('shadow')
  44104. .attr({ zIndex: -1 })
  44105. .add(series.group);
  44106. }
  44107. // draw the slices
  44108. series.points.forEach(function (point) {
  44109. var animateTo = {};
  44110. graphic = point.graphic;
  44111. if (!point.isNull && graphic) {
  44112. var shadowGroup = void 0;
  44113. shapeArgs = point.shapeArgs;
  44114. // If the point is sliced, use special translation, else use
  44115. // plot area translation
  44116. groupTranslation = point.getTranslate();
  44117. if (!chart.styledMode) {
  44118. // Put the shadow behind all points
  44119. shadowGroup = point.shadowGroup;
  44120. if (shadow && !shadowGroup) {
  44121. shadowGroup = point.shadowGroup = renderer
  44122. .g('shadow')
  44123. .add(series.shadowGroup);
  44124. }
  44125. if (shadowGroup) {
  44126. shadowGroup.attr(groupTranslation);
  44127. }
  44128. pointAttr = series.pointAttribs(point, (point.selected && 'select'));
  44129. }
  44130. // Draw the slice
  44131. if (!point.delayedRendering) {
  44132. graphic
  44133. .setRadialReference(series.center);
  44134. if (!chart.styledMode) {
  44135. merge(true, animateTo, pointAttr);
  44136. }
  44137. merge(true, animateTo, shapeArgs, groupTranslation);
  44138. graphic.animate(animateTo);
  44139. }
  44140. else {
  44141. graphic
  44142. .setRadialReference(series.center)
  44143. .attr(shapeArgs)
  44144. .attr(groupTranslation);
  44145. if (!chart.styledMode) {
  44146. graphic
  44147. .attr(pointAttr)
  44148. .attr({ 'stroke-linejoin': 'round' })
  44149. .shadow(shadow, shadowGroup);
  44150. }
  44151. point.delayedRendering = false;
  44152. }
  44153. graphic.attr({
  44154. visibility: point.visible ? 'inherit' : 'hidden'
  44155. });
  44156. graphic.addClass(point.getClassName(), true);
  44157. }
  44158. else if (graphic) {
  44159. point.graphic = graphic.destroy();
  44160. }
  44161. });
  44162. };
  44163. /**
  44164. * Utility for sorting data labels.
  44165. * @private
  44166. */
  44167. PieSeries.prototype.sortByAngle = function (points, sign) {
  44168. points.sort(function (a, b) {
  44169. return ((typeof a.angle !== 'undefined') &&
  44170. (b.angle - a.angle) * sign);
  44171. });
  44172. };
  44173. /**
  44174. * Do translation for pie slices
  44175. * @private
  44176. */
  44177. PieSeries.prototype.translate = function (positions) {
  44178. this.generatePoints();
  44179. var series = this,
  44180. cumulative = 0,
  44181. precision = 1000, // issue #172
  44182. options = series.options,
  44183. slicedOffset = options.slicedOffset,
  44184. connectorOffset = slicedOffset + (options.borderWidth || 0),
  44185. finalConnectorOffset,
  44186. start,
  44187. end,
  44188. angle,
  44189. radians = getStartAndEndRadians(options.startAngle,
  44190. options.endAngle),
  44191. startAngleRad = series.startAngleRad = radians.start,
  44192. endAngleRad = series.endAngleRad = radians.end,
  44193. circ = endAngleRad - startAngleRad, // 2 * Math.PI,
  44194. points = series.points,
  44195. // the x component of the radius vector for a given point
  44196. radiusX,
  44197. radiusY,
  44198. labelDistance = options.dataLabels.distance,
  44199. ignoreHiddenPoint = options.ignoreHiddenPoint,
  44200. i,
  44201. len = points.length,
  44202. point;
  44203. // Get positions - either an integer or a percentage string must be
  44204. // given. If positions are passed as a parameter, we're in a
  44205. // recursive loop for adjusting space for data labels.
  44206. if (!positions) {
  44207. series.center = positions = series.getCenter();
  44208. }
  44209. // Calculate the geometry for each point
  44210. for (i = 0; i < len; i++) {
  44211. point = points[i];
  44212. // set start and end angle
  44213. start = startAngleRad + (cumulative * circ);
  44214. if (point.isValid() &&
  44215. (!ignoreHiddenPoint || point.visible)) {
  44216. cumulative += point.percentage / 100;
  44217. }
  44218. end = startAngleRad + (cumulative * circ);
  44219. // set the shape
  44220. var shapeArgs = {
  44221. x: positions[0],
  44222. y: positions[1],
  44223. r: positions[2] / 2,
  44224. innerR: positions[3] / 2,
  44225. start: Math.round(start * precision) / precision,
  44226. end: Math.round(end * precision) / precision
  44227. };
  44228. point.shapeType = 'arc';
  44229. point.shapeArgs = shapeArgs;
  44230. // Used for distance calculation for specific point.
  44231. point.labelDistance = pick((point.options.dataLabels &&
  44232. point.options.dataLabels.distance), labelDistance);
  44233. // Compute point.labelDistance if it's defined as percentage
  44234. // of slice radius (#8854)
  44235. point.labelDistance = relativeLength(point.labelDistance, shapeArgs.r);
  44236. // Saved for later dataLabels distance calculation.
  44237. series.maxLabelDistance = Math.max(series.maxLabelDistance || 0, point.labelDistance);
  44238. // The angle must stay within -90 and 270 (#2645)
  44239. angle = (end + start) / 2;
  44240. if (angle > 1.5 * Math.PI) {
  44241. angle -= 2 * Math.PI;
  44242. }
  44243. else if (angle < -Math.PI / 2) {
  44244. angle += 2 * Math.PI;
  44245. }
  44246. // Center for the sliced out slice
  44247. point.slicedTranslation = {
  44248. translateX: Math.round(Math.cos(angle) * slicedOffset),
  44249. translateY: Math.round(Math.sin(angle) * slicedOffset)
  44250. };
  44251. // set the anchor point for tooltips
  44252. radiusX = Math.cos(angle) * positions[2] / 2;
  44253. radiusY = Math.sin(angle) * positions[2] / 2;
  44254. point.tooltipPos = [
  44255. positions[0] + radiusX * 0.7,
  44256. positions[1] + radiusY * 0.7
  44257. ];
  44258. point.half = angle < -Math.PI / 2 || angle > Math.PI / 2 ?
  44259. 1 :
  44260. 0;
  44261. point.angle = angle;
  44262. // Set the anchor point for data labels. Use point.labelDistance
  44263. // instead of labelDistance // #1174
  44264. // finalConnectorOffset - not override connectorOffset value.
  44265. finalConnectorOffset = Math.min(connectorOffset, point.labelDistance / 5); // #1678
  44266. point.labelPosition = {
  44267. natural: {
  44268. // initial position of the data label - it's utilized for
  44269. // finding the final position for the label
  44270. x: positions[0] + radiusX + Math.cos(angle) *
  44271. point.labelDistance,
  44272. y: positions[1] + radiusY + Math.sin(angle) *
  44273. point.labelDistance
  44274. },
  44275. 'final': {
  44276. // used for generating connector path -
  44277. // initialized later in drawDataLabels function
  44278. // x: undefined,
  44279. // y: undefined
  44280. },
  44281. // left - pie on the left side of the data label
  44282. // right - pie on the right side of the data label
  44283. // center - data label overlaps the pie
  44284. alignment: point.labelDistance < 0 ?
  44285. 'center' : point.half ? 'right' : 'left',
  44286. connectorPosition: {
  44287. breakAt: {
  44288. x: positions[0] + radiusX + Math.cos(angle) *
  44289. finalConnectorOffset,
  44290. y: positions[1] + radiusY + Math.sin(angle) *
  44291. finalConnectorOffset
  44292. },
  44293. touchingSliceAt: {
  44294. x: positions[0] + radiusX,
  44295. y: positions[1] + radiusY
  44296. }
  44297. }
  44298. };
  44299. }
  44300. fireEvent(series, 'afterTranslate');
  44301. };
  44302. /**
  44303. * Recompute total chart sum and update percentages of points.
  44304. * @private
  44305. */
  44306. PieSeries.prototype.updateTotals = function () {
  44307. var i,
  44308. total = 0,
  44309. points = this.points,
  44310. len = points.length,
  44311. point,
  44312. ignoreHiddenPoint = this.options.ignoreHiddenPoint;
  44313. // Get the total sum
  44314. for (i = 0; i < len; i++) {
  44315. point = points[i];
  44316. if (point.isValid() &&
  44317. (!ignoreHiddenPoint || point.visible)) {
  44318. total += point.y;
  44319. }
  44320. }
  44321. this.total = total;
  44322. // Set each point's properties
  44323. for (i = 0; i < len; i++) {
  44324. point = points[i];
  44325. point.percentage =
  44326. (total > 0 && (point.visible || !ignoreHiddenPoint)) ?
  44327. point.y / total * 100 :
  44328. 0;
  44329. point.total = total;
  44330. }
  44331. };
  44332. /**
  44333. * A pie chart is a circular graphic which is divided into slices to
  44334. * illustrate numerical proportion.
  44335. *
  44336. * @sample highcharts/demo/pie-basic/
  44337. * Pie chart
  44338. *
  44339. * @extends plotOptions.line
  44340. * @excluding animationLimit, boostThreshold, connectEnds, connectNulls,
  44341. * cropThreshold, dashStyle, dataSorting, dragDrop,
  44342. * findNearestPointBy, getExtremesFromAll, label, lineWidth,
  44343. * marker, negativeColor, pointInterval, pointIntervalUnit,
  44344. * pointPlacement, pointStart, softThreshold, stacking, step,
  44345. * threshold, turboThreshold, zoneAxis, zones, dataSorting,
  44346. * boostBlending
  44347. * @product highcharts
  44348. * @optionparent plotOptions.pie
  44349. */
  44350. PieSeries.defaultOptions = merge(Series.defaultOptions, {
  44351. /**
  44352. * @excluding legendItemClick
  44353. * @apioption plotOptions.pie.events
  44354. */
  44355. /**
  44356. * Fires when the checkbox next to the point name in the legend is
  44357. * clicked. One parameter, event, is passed to the function. The state
  44358. * of the checkbox is found by event.checked. The checked item is found
  44359. * by event.item. Return false to prevent the default action which is to
  44360. * toggle the select state of the series.
  44361. *
  44362. * @sample {highcharts} highcharts/plotoptions/series-events-checkboxclick/
  44363. * Alert checkbox status
  44364. *
  44365. * @type {Function}
  44366. * @since 1.2.0
  44367. * @product highcharts
  44368. * @context Highcharts.Point
  44369. * @apioption plotOptions.pie.events.checkboxClick
  44370. */
  44371. /**
  44372. * Fires when the legend item belonging to the pie point (slice) is
  44373. * clicked. The `this` keyword refers to the point itself. One
  44374. * parameter, `event`, is passed to the function, containing common
  44375. * event information. The default action is to toggle the visibility of
  44376. * the point. This can be prevented by calling `event.preventDefault()`.
  44377. *
  44378. * @sample {highcharts} highcharts/plotoptions/pie-point-events-legenditemclick/
  44379. * Confirm toggle visibility
  44380. *
  44381. * @type {Highcharts.PointLegendItemClickCallbackFunction}
  44382. * @since 1.2.0
  44383. * @product highcharts
  44384. * @apioption plotOptions.pie.point.events.legendItemClick
  44385. */
  44386. /**
  44387. * The center of the pie chart relative to the plot area. Can be
  44388. * percentages or pixel values. The default behaviour (as of 3.0) is to
  44389. * center the pie so that all slices and data labels are within the plot
  44390. * area. As a consequence, the pie may actually jump around in a chart
  44391. * with dynamic values, as the data labels move. In that case, the
  44392. * center should be explicitly set, for example to `["50%", "50%"]`.
  44393. *
  44394. * @sample {highcharts} highcharts/plotoptions/pie-center/
  44395. * Centered at 100, 100
  44396. *
  44397. * @type {Array<(number|string|null),(number|string|null)>}
  44398. * @default [null, null]
  44399. * @product highcharts
  44400. *
  44401. * @private
  44402. */
  44403. center: [null, null],
  44404. /**
  44405. * The color of the pie series. A pie series is represented as an empty
  44406. * circle if the total sum of its values is 0. Use this property to
  44407. * define the color of its border.
  44408. *
  44409. * In styled mode, the color can be defined by the
  44410. * [colorIndex](#plotOptions.series.colorIndex) option. Also, the series
  44411. * color can be set with the `.highcharts-series`,
  44412. * `.highcharts-color-{n}`, `.highcharts-{type}-series` or
  44413. * `.highcharts-series-{n}` class, or individual classes given by the
  44414. * `className` option.
  44415. *
  44416. * @sample {highcharts} highcharts/plotoptions/pie-emptyseries/
  44417. * Empty pie series
  44418. *
  44419. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  44420. * @default ${palette.neutralColor20}
  44421. * @apioption plotOptions.pie.color
  44422. */
  44423. /**
  44424. * @product highcharts
  44425. *
  44426. * @private
  44427. */
  44428. clip: false,
  44429. /**
  44430. * @ignore-option
  44431. *
  44432. * @private
  44433. */
  44434. colorByPoint: true,
  44435. /**
  44436. * A series specific or series type specific color set to use instead
  44437. * of the global [colors](#colors).
  44438. *
  44439. * @sample {highcharts} highcharts/demo/pie-monochrome/
  44440. * Set default colors for all pies
  44441. *
  44442. * @type {Array<Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject>}
  44443. * @since 3.0
  44444. * @product highcharts
  44445. * @apioption plotOptions.pie.colors
  44446. */
  44447. /**
  44448. * @declare Highcharts.SeriesPieDataLabelsOptionsObject
  44449. * @extends plotOptions.series.dataLabels
  44450. * @excluding align, allowOverlap, inside, staggerLines, step
  44451. * @private
  44452. */
  44453. dataLabels: {
  44454. /**
  44455. * Alignment method for data labels. Possible values are:
  44456. *
  44457. * - `toPlotEdges`: Each label touches the nearest vertical edge of
  44458. * the plot area.
  44459. *
  44460. * - `connectors`: Connectors have the same x position and the
  44461. * widest label of each half (left & right) touches the nearest
  44462. * vertical edge of the plot area.
  44463. *
  44464. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-alignto-connectors/
  44465. * alignTo: connectors
  44466. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-alignto-plotedges/
  44467. * alignTo: plotEdges
  44468. *
  44469. * @type {string}
  44470. * @since 7.0.0
  44471. * @product highcharts
  44472. * @apioption plotOptions.pie.dataLabels.alignTo
  44473. */
  44474. allowOverlap: true,
  44475. /**
  44476. * The color of the line connecting the data label to the pie slice.
  44477. * The default color is the same as the point's color.
  44478. *
  44479. * In styled mode, the connector stroke is given in the
  44480. * `.highcharts-data-label-connector` class.
  44481. *
  44482. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorcolor/
  44483. * Blue connectors
  44484. * @sample {highcharts} highcharts/css/pie-point/
  44485. * Styled connectors
  44486. *
  44487. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  44488. * @since 2.1
  44489. * @product highcharts
  44490. * @apioption plotOptions.pie.dataLabels.connectorColor
  44491. */
  44492. /**
  44493. * The distance from the data label to the connector. Note that
  44494. * data labels also have a default `padding`, so in order for the
  44495. * connector to touch the text, the `padding` must also be 0.
  44496. *
  44497. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorpadding/
  44498. * No padding
  44499. *
  44500. * @since 2.1
  44501. * @product highcharts
  44502. */
  44503. connectorPadding: 5,
  44504. /**
  44505. * Specifies the method that is used to generate the connector path.
  44506. * Highcharts provides 3 built-in connector shapes: `'fixedOffset'`
  44507. * (default), `'straight'` and `'crookedLine'`. Using
  44508. * `'crookedLine'` has the most sense (in most of the cases) when
  44509. * `'alignTo'` is set.
  44510. *
  44511. * Users can provide their own method by passing a function instead
  44512. * of a String. 3 arguments are passed to the callback:
  44513. *
  44514. * - Object that holds the information about the coordinates of the
  44515. * label (`x` & `y` properties) and how the label is located in
  44516. * relation to the pie (`alignment` property). `alignment` can by
  44517. * one of the following:
  44518. * `'left'` (pie on the left side of the data label),
  44519. * `'right'` (pie on the right side of the data label) or
  44520. * `'center'` (data label overlaps the pie).
  44521. *
  44522. * - Object that holds the information about the position of the
  44523. * connector. Its `touchingSliceAt` porperty tells the position
  44524. * of the place where the connector touches the slice.
  44525. *
  44526. * - Data label options
  44527. *
  44528. * The function has to return an SVG path definition in array form
  44529. * (see the example).
  44530. *
  44531. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorshape-string/
  44532. * connectorShape is a String
  44533. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorshape-function/
  44534. * connectorShape is a function
  44535. *
  44536. * @type {string|Function}
  44537. * @since 7.0.0
  44538. * @product highcharts
  44539. */
  44540. connectorShape: 'fixedOffset',
  44541. /**
  44542. * The width of the line connecting the data label to the pie slice.
  44543. *
  44544. * In styled mode, the connector stroke width is given in the
  44545. * `.highcharts-data-label-connector` class.
  44546. *
  44547. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-connectorwidth-disabled/
  44548. * Disable the connector
  44549. * @sample {highcharts} highcharts/css/pie-point/
  44550. * Styled connectors
  44551. *
  44552. * @type {number}
  44553. * @default 1
  44554. * @since 2.1
  44555. * @product highcharts
  44556. * @apioption plotOptions.pie.dataLabels.connectorWidth
  44557. */
  44558. /**
  44559. * Works only if `connectorShape` is `'crookedLine'`. It defines how
  44560. * far from the vertical plot edge the coonnector path should be
  44561. * crooked.
  44562. *
  44563. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-crookdistance/
  44564. * crookDistance set to 90%
  44565. *
  44566. * @since 7.0.0
  44567. * @product highcharts
  44568. */
  44569. crookDistance: '70%',
  44570. /**
  44571. * The distance of the data label from the pie's edge. Negative
  44572. * numbers put the data label on top of the pie slices. Can also be
  44573. * defined as a percentage of pie's radius. Connectors are only
  44574. * shown for data labels outside the pie.
  44575. *
  44576. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-distance/
  44577. * Data labels on top of the pie
  44578. *
  44579. * @type {number|string}
  44580. * @since 2.1
  44581. * @product highcharts
  44582. */
  44583. distance: 30,
  44584. enabled: true,
  44585. /**
  44586. * A
  44587. * [format string](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting)
  44588. * for the data label. Available variables are the same as for
  44589. * `formatter`.
  44590. *
  44591. * @sample {highcharts} highcharts/plotoptions/series-datalabels-format/
  44592. * Add a unit
  44593. *
  44594. * @type {string}
  44595. * @default undefined
  44596. * @since 3.0
  44597. * @apioption plotOptions.pie.dataLabels.format
  44598. */
  44599. // eslint-disable-next-line valid-jsdoc
  44600. /**
  44601. * Callback JavaScript function to format the data label. Note that
  44602. * if a `format` is defined, the format takes precedence and the
  44603. * formatter is ignored.
  44604. *
  44605. * @type {Highcharts.DataLabelsFormatterCallbackFunction}
  44606. * @default function () { return this.point.isNull ? void 0 : this.point.name; }
  44607. */
  44608. formatter: function () {
  44609. return this.point.isNull ? void 0 : this.point.name;
  44610. },
  44611. /**
  44612. * Whether to render the connector as a soft arc or a line with
  44613. * sharp break. Works only if `connectorShape` equals to
  44614. * `fixedOffset`.
  44615. *
  44616. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-softconnector-true/
  44617. * Soft
  44618. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-softconnector-false/
  44619. * Non soft
  44620. *
  44621. * @since 2.1.7
  44622. * @product highcharts
  44623. */
  44624. softConnector: true,
  44625. /**
  44626. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-overflow
  44627. * Long labels truncated with an ellipsis
  44628. * @sample {highcharts} highcharts/plotoptions/pie-datalabels-overflow-wrap
  44629. * Long labels are wrapped
  44630. *
  44631. * @type {Highcharts.CSSObject}
  44632. * @apioption plotOptions.pie.dataLabels.style
  44633. */
  44634. x: 0
  44635. },
  44636. /**
  44637. * If the total sum of the pie's values is 0, the series is represented
  44638. * as an empty circle . The `fillColor` option defines the color of that
  44639. * circle. Use [pie.borderWidth](#plotOptions.pie.borderWidth) to set
  44640. * the border thickness.
  44641. *
  44642. * @sample {highcharts} highcharts/plotoptions/pie-emptyseries/
  44643. * Empty pie series
  44644. *
  44645. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  44646. * @private
  44647. */
  44648. fillColor: void 0,
  44649. /**
  44650. * The end angle of the pie in degrees where 0 is top and 90 is right.
  44651. * Defaults to `startAngle` plus 360.
  44652. *
  44653. * @sample {highcharts} highcharts/demo/pie-semi-circle/
  44654. * Semi-circle donut
  44655. *
  44656. * @type {number}
  44657. * @since 1.3.6
  44658. * @product highcharts
  44659. * @apioption plotOptions.pie.endAngle
  44660. */
  44661. /**
  44662. * Equivalent to [chart.ignoreHiddenSeries](#chart.ignoreHiddenSeries),
  44663. * this option tells whether the series shall be redrawn as if the
  44664. * hidden point were `null`.
  44665. *
  44666. * The default value changed from `false` to `true` with Highcharts
  44667. * 3.0.
  44668. *
  44669. * @sample {highcharts} highcharts/plotoptions/pie-ignorehiddenpoint/
  44670. * True, the hiddden point is ignored
  44671. *
  44672. * @since 2.3.0
  44673. * @product highcharts
  44674. *
  44675. * @private
  44676. */
  44677. ignoreHiddenPoint: true,
  44678. /**
  44679. * @ignore-option
  44680. *
  44681. * @private
  44682. */
  44683. inactiveOtherPoints: true,
  44684. /**
  44685. * The size of the inner diameter for the pie. A size greater than 0
  44686. * renders a donut chart. Can be a percentage or pixel value.
  44687. * Percentages are relative to the pie size. Pixel values are given as
  44688. * integers.
  44689. *
  44690. *
  44691. * Note: in Highcharts < 4.1.2, the percentage was relative to the plot
  44692. * area, not the pie size.
  44693. *
  44694. * @sample {highcharts} highcharts/plotoptions/pie-innersize-80px/
  44695. * 80px inner size
  44696. * @sample {highcharts} highcharts/plotoptions/pie-innersize-50percent/
  44697. * 50% of the plot area
  44698. * @sample {highcharts} highcharts/demo/3d-pie-donut/
  44699. * 3D donut
  44700. *
  44701. * @type {number|string}
  44702. * @default 0
  44703. * @since 2.0
  44704. * @product highcharts
  44705. * @apioption plotOptions.pie.innerSize
  44706. */
  44707. /**
  44708. * @ignore-option
  44709. *
  44710. * @private
  44711. */
  44712. legendType: 'point',
  44713. /**
  44714. * @ignore-option
  44715. *
  44716. * @private
  44717. */
  44718. marker: null,
  44719. /**
  44720. * The minimum size for a pie in response to auto margins. The pie will
  44721. * try to shrink to make room for data labels in side the plot area,
  44722. * but only to this size.
  44723. *
  44724. * @type {number|string}
  44725. * @default 80
  44726. * @since 3.0
  44727. * @product highcharts
  44728. * @apioption plotOptions.pie.minSize
  44729. */
  44730. /**
  44731. * The diameter of the pie relative to the plot area. Can be a
  44732. * percentage or pixel value. Pixel values are given as integers. The
  44733. * default behaviour (as of 3.0) is to scale to the plot area and give
  44734. * room for data labels within the plot area.
  44735. * [slicedOffset](#plotOptions.pie.slicedOffset) is also included in the
  44736. * default size calculation. As a consequence, the size of the pie may
  44737. * vary when points are updated and data labels more around. In that
  44738. * case it is best to set a fixed value, for example `"75%"`.
  44739. *
  44740. * @sample {highcharts} highcharts/plotoptions/pie-size/
  44741. * Smaller pie
  44742. *
  44743. * @type {number|string|null}
  44744. * @product highcharts
  44745. *
  44746. * @private
  44747. */
  44748. size: null,
  44749. /**
  44750. * Whether to display this particular series or series type in the
  44751. * legend. Since 2.1, pies are not shown in the legend by default.
  44752. *
  44753. * @sample {highcharts} highcharts/plotoptions/series-showinlegend/
  44754. * One series in the legend, one hidden
  44755. *
  44756. * @product highcharts
  44757. *
  44758. * @private
  44759. */
  44760. showInLegend: false,
  44761. /**
  44762. * If a point is sliced, moved out from the center, how many pixels
  44763. * should it be moved?.
  44764. *
  44765. * @sample {highcharts} highcharts/plotoptions/pie-slicedoffset-20/
  44766. * 20px offset
  44767. *
  44768. * @product highcharts
  44769. *
  44770. * @private
  44771. */
  44772. slicedOffset: 10,
  44773. /**
  44774. * The start angle of the pie slices in degrees where 0 is top and 90
  44775. * right.
  44776. *
  44777. * @sample {highcharts} highcharts/plotoptions/pie-startangle-90/
  44778. * Start from right
  44779. *
  44780. * @type {number}
  44781. * @default 0
  44782. * @since 2.3.4
  44783. * @product highcharts
  44784. * @apioption plotOptions.pie.startAngle
  44785. */
  44786. /**
  44787. * Sticky tracking of mouse events. When true, the `mouseOut` event
  44788. * on a series isn't triggered until the mouse moves over another
  44789. * series, or out of the plot area. When false, the `mouseOut` event on
  44790. * a series is triggered when the mouse leaves the area around the
  44791. * series' graph or markers. This also implies the tooltip. When
  44792. * `stickyTracking` is false and `tooltip.shared` is false, the tooltip
  44793. * will be hidden when moving the mouse between series.
  44794. *
  44795. * @product highcharts
  44796. *
  44797. * @private
  44798. */
  44799. stickyTracking: false,
  44800. tooltip: {
  44801. followPointer: true
  44802. },
  44803. /**
  44804. * The color of the border surrounding each slice. When `null`, the
  44805. * border takes the same color as the slice fill. This can be used
  44806. * together with a `borderWidth` to fill drawing gaps created by
  44807. * antialiazing artefacts in borderless pies.
  44808. *
  44809. * In styled mode, the border stroke is given in the `.highcharts-point`
  44810. * class.
  44811. *
  44812. * @sample {highcharts} highcharts/plotoptions/pie-bordercolor-black/
  44813. * Black border
  44814. *
  44815. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  44816. * @default #ffffff
  44817. * @product highcharts
  44818. *
  44819. * @private
  44820. */
  44821. borderColor: palette.backgroundColor,
  44822. /**
  44823. * The width of the border surrounding each slice.
  44824. *
  44825. * When setting the border width to 0, there may be small gaps between
  44826. * the slices due to SVG antialiasing artefacts. To work around this,
  44827. * keep the border width at 0.5 or 1, but set the `borderColor` to
  44828. * `null` instead.
  44829. *
  44830. * In styled mode, the border stroke width is given in the
  44831. * `.highcharts-point` class.
  44832. *
  44833. * @sample {highcharts} highcharts/plotoptions/pie-borderwidth/
  44834. * 3px border
  44835. *
  44836. * @product highcharts
  44837. *
  44838. * @private
  44839. */
  44840. borderWidth: 1,
  44841. /**
  44842. * @ignore-options
  44843. * @private
  44844. */
  44845. lineWidth: void 0,
  44846. states: {
  44847. /**
  44848. * @extends plotOptions.series.states.hover
  44849. * @excluding marker, lineWidth, lineWidthPlus
  44850. * @product highcharts
  44851. */
  44852. hover: {
  44853. /**
  44854. * How much to brighten the point on interaction. Requires the
  44855. * main color to be defined in hex or rgb(a) format.
  44856. *
  44857. * In styled mode, the hover brightness is by default replaced
  44858. * by a fill-opacity given in the `.highcharts-point-hover`
  44859. * class.
  44860. *
  44861. * @sample {highcharts} highcharts/plotoptions/pie-states-hover-brightness/
  44862. * Brightened by 0.5
  44863. *
  44864. * @product highcharts
  44865. */
  44866. brightness: 0.1
  44867. }
  44868. }
  44869. });
  44870. return PieSeries;
  44871. }(Series));
  44872. extend(PieSeries.prototype, {
  44873. axisTypes: [],
  44874. directTouch: true,
  44875. drawGraph: void 0,
  44876. drawLegendSymbol: LegendSymbolMixin.drawRectangle,
  44877. drawTracker: ColumnSeries.prototype.drawTracker,
  44878. getCenter: CenteredSeriesMixin.getCenter,
  44879. getSymbol: noop,
  44880. isCartesian: false,
  44881. noSharedTooltip: true,
  44882. pointAttribs: ColumnSeries.prototype.pointAttribs,
  44883. pointClass: PiePoint,
  44884. requireSorting: false,
  44885. searchPoint: noop,
  44886. trackerGroups: ['group', 'dataLabelsGroup']
  44887. });
  44888. SeriesRegistry.registerSeriesType('pie', PieSeries);
  44889. /* *
  44890. *
  44891. * Default Export
  44892. *
  44893. * */
  44894. /* *
  44895. *
  44896. * API Options
  44897. *
  44898. * */
  44899. /**
  44900. * A `pie` series. If the [type](#series.pie.type) option is not specified,
  44901. * it is inherited from [chart.type](#chart.type).
  44902. *
  44903. * @extends series,plotOptions.pie
  44904. * @excluding cropThreshold, dataParser, dataURL, stack, xAxis, yAxis,
  44905. * dataSorting, step, boostThreshold, boostBlending
  44906. * @product highcharts
  44907. * @apioption series.pie
  44908. */
  44909. /**
  44910. * An array of data points for the series. For the `pie` series type,
  44911. * points can be given in the following ways:
  44912. *
  44913. * 1. An array of numerical values. In this case, the numerical values will be
  44914. * interpreted as `y` options. Example:
  44915. * ```js
  44916. * data: [0, 5, 3, 5]
  44917. * ```
  44918. *
  44919. * 2. An array of objects with named values. The following snippet shows only a
  44920. * few settings, see the complete options set below. If the total number of
  44921. * data points exceeds the series'
  44922. * [turboThreshold](#series.pie.turboThreshold),
  44923. * this option is not available.
  44924. * ```js
  44925. * data: [{
  44926. * y: 1,
  44927. * name: "Point2",
  44928. * color: "#00FF00"
  44929. * }, {
  44930. * y: 7,
  44931. * name: "Point1",
  44932. * color: "#FF00FF"
  44933. * }]
  44934. * ```
  44935. *
  44936. * @sample {highcharts} highcharts/chart/reflow-true/
  44937. * Numerical values
  44938. * @sample {highcharts} highcharts/series/data-array-of-arrays/
  44939. * Arrays of numeric x and y
  44940. * @sample {highcharts} highcharts/series/data-array-of-arrays-datetime/
  44941. * Arrays of datetime x and y
  44942. * @sample {highcharts} highcharts/series/data-array-of-name-value/
  44943. * Arrays of point.name and y
  44944. * @sample {highcharts} highcharts/series/data-array-of-objects/
  44945. * Config objects
  44946. *
  44947. * @type {Array<number|Array<string,(number|null)>|null|*>}
  44948. * @extends series.line.data
  44949. * @excluding marker, x
  44950. * @product highcharts
  44951. * @apioption series.pie.data
  44952. */
  44953. /**
  44954. * @type {Highcharts.SeriesPieDataLabelsOptionsObject}
  44955. * @product highcharts
  44956. * @apioption series.pie.data.dataLabels
  44957. */
  44958. /**
  44959. * The sequential index of the data point in the legend.
  44960. *
  44961. * @type {number}
  44962. * @product highcharts
  44963. * @apioption series.pie.data.legendIndex
  44964. */
  44965. /**
  44966. * Whether to display a slice offset from the center.
  44967. *
  44968. * @sample {highcharts} highcharts/point/sliced/
  44969. * One sliced point
  44970. *
  44971. * @type {boolean}
  44972. * @product highcharts
  44973. * @apioption series.pie.data.sliced
  44974. */
  44975. /**
  44976. * @extends plotOptions.pie.dataLabels
  44977. * @excluding align, allowOverlap, inside, staggerLines, step
  44978. * @product highcharts
  44979. * @apioption series.pie.dataLabels
  44980. */
  44981. /**
  44982. * @excluding legendItemClick
  44983. * @product highcharts
  44984. * @apioption series.pie.events
  44985. */
  44986. ''; // placeholder for transpiled doclets above
  44987. return PieSeries;
  44988. });
  44989. _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) {
  44990. /* *
  44991. *
  44992. * (c) 2010-2021 Torstein Honsi
  44993. *
  44994. * License: www.highcharts.com/license
  44995. *
  44996. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  44997. *
  44998. * */
  44999. var getDeferredAnimation = A.getDeferredAnimation;
  45000. var format = F.format;
  45001. var noop = H.noop;
  45002. var seriesTypes = SeriesRegistry.seriesTypes;
  45003. var arrayMax = U.arrayMax,
  45004. clamp = U.clamp,
  45005. defined = U.defined,
  45006. extend = U.extend,
  45007. fireEvent = U.fireEvent,
  45008. isArray = U.isArray,
  45009. merge = U.merge,
  45010. objectEach = U.objectEach,
  45011. pick = U.pick,
  45012. relativeLength = U.relativeLength,
  45013. splat = U.splat,
  45014. stableSort = U.stableSort;
  45015. /**
  45016. * Callback JavaScript function to format the data label as a string. Note that
  45017. * if a `format` is defined, the format takes precedence and the formatter is
  45018. * ignored.
  45019. *
  45020. * @callback Highcharts.DataLabelsFormatterCallbackFunction
  45021. *
  45022. * @param {Highcharts.PointLabelObject} this
  45023. * Data label context to format
  45024. *
  45025. * @param {Highcharts.DataLabelsOptions} options
  45026. * [API options](/highcharts/plotOptions.series.dataLabels) of the data label
  45027. *
  45028. * @return {number|string|null|undefined}
  45029. * Formatted data label text
  45030. */
  45031. /**
  45032. * Values for handling data labels that flow outside the plot area.
  45033. *
  45034. * @typedef {"allow"|"justify"} Highcharts.DataLabelsOverflowValue
  45035. */
  45036. ''; // detach doclets above
  45037. /* eslint-disable valid-jsdoc */
  45038. /**
  45039. * General distribution algorithm for distributing labels of differing size
  45040. * along a confined length in two dimensions. The algorithm takes an array of
  45041. * objects containing a size, a target and a rank. It will place the labels as
  45042. * close as possible to their targets, skipping the lowest ranked labels if
  45043. * necessary.
  45044. *
  45045. * @private
  45046. * @function Highcharts.distribute
  45047. * @param {Highcharts.DataLabelsBoxArray} boxes
  45048. * @param {number} len
  45049. * @param {number} [maxDistance]
  45050. * @return {void}
  45051. */
  45052. H.distribute = function (boxes, len, maxDistance) {
  45053. var i,
  45054. overlapping = true,
  45055. origBoxes = boxes, // Original array will be altered with added .pos
  45056. restBoxes = [], // The outranked overshoot
  45057. box,
  45058. target,
  45059. total = 0,
  45060. reducedLen = origBoxes.reducedLen || len;
  45061. /**
  45062. * @private
  45063. */
  45064. function sortByTarget(a, b) {
  45065. return a.target - b.target;
  45066. }
  45067. // If the total size exceeds the len, remove those boxes with the lowest
  45068. // rank
  45069. i = boxes.length;
  45070. while (i--) {
  45071. total += boxes[i].size;
  45072. }
  45073. // Sort by rank, then slice away overshoot
  45074. if (total > reducedLen) {
  45075. stableSort(boxes, function (a, b) {
  45076. return (b.rank || 0) - (a.rank || 0);
  45077. });
  45078. i = 0;
  45079. total = 0;
  45080. while (total <= reducedLen) {
  45081. total += boxes[i].size;
  45082. i++;
  45083. }
  45084. restBoxes = boxes.splice(i - 1, boxes.length);
  45085. }
  45086. // Order by target
  45087. stableSort(boxes, sortByTarget);
  45088. // So far we have been mutating the original array. Now
  45089. // create a copy with target arrays
  45090. boxes = boxes.map(function (box) {
  45091. return {
  45092. size: box.size,
  45093. targets: [box.target],
  45094. align: pick(box.align, 0.5)
  45095. };
  45096. });
  45097. while (overlapping) {
  45098. // Initial positions: target centered in box
  45099. i = boxes.length;
  45100. while (i--) {
  45101. box = boxes[i];
  45102. // Composite box, average of targets
  45103. target = (Math.min.apply(0, box.targets) +
  45104. Math.max.apply(0, box.targets)) / 2;
  45105. box.pos = clamp(target - box.size * box.align, 0, len - box.size);
  45106. }
  45107. // Detect overlap and join boxes
  45108. i = boxes.length;
  45109. overlapping = false;
  45110. while (i--) {
  45111. // Overlap
  45112. if (i > 0 &&
  45113. boxes[i - 1].pos + boxes[i - 1].size >
  45114. boxes[i].pos) {
  45115. // Add this size to the previous box
  45116. boxes[i - 1].size += boxes[i].size;
  45117. boxes[i - 1].targets = boxes[i - 1]
  45118. .targets
  45119. .concat(boxes[i].targets);
  45120. boxes[i - 1].align = 0.5;
  45121. // Overlapping right, push left
  45122. if (boxes[i - 1].pos + boxes[i - 1].size > len) {
  45123. boxes[i - 1].pos = len - boxes[i - 1].size;
  45124. }
  45125. boxes.splice(i, 1); // Remove this item
  45126. overlapping = true;
  45127. }
  45128. }
  45129. }
  45130. // Add the rest (hidden boxes)
  45131. origBoxes.push.apply(origBoxes, restBoxes);
  45132. // Now the composite boxes are placed, we need to put the original boxes
  45133. // within them
  45134. i = 0;
  45135. boxes.some(function (box) {
  45136. var posInCompositeBox = 0;
  45137. if (box.targets.some(function () {
  45138. origBoxes[i].pos = box.pos + posInCompositeBox;
  45139. // If the distance between the position and the target exceeds
  45140. // maxDistance, abort the loop and decrease the length in increments
  45141. // of 10% to recursively reduce the number of visible boxes by
  45142. // rank. Once all boxes are within the maxDistance, we're good.
  45143. if (typeof maxDistance !== 'undefined' &&
  45144. Math.abs(origBoxes[i].pos - origBoxes[i].target) > maxDistance) {
  45145. // Reset the positions that are already set
  45146. origBoxes.slice(0, i + 1).forEach(function (box) {
  45147. delete box.pos;
  45148. });
  45149. // Try with a smaller length
  45150. origBoxes.reducedLen =
  45151. (origBoxes.reducedLen || len) - (len * 0.1);
  45152. // Recurse
  45153. if (origBoxes.reducedLen > len * 0.1) {
  45154. H.distribute(origBoxes, len, maxDistance);
  45155. }
  45156. // Exceeded maxDistance => abort
  45157. return true;
  45158. }
  45159. posInCompositeBox += origBoxes[i].size;
  45160. i++;
  45161. })) {
  45162. // Exceeded maxDistance => abort
  45163. return true;
  45164. }
  45165. });
  45166. // Add the rest (hidden) boxes and sort by target
  45167. stableSort(origBoxes, sortByTarget);
  45168. };
  45169. /**
  45170. * Draw the data labels
  45171. *
  45172. * @private
  45173. * @function Highcharts.Series#drawDataLabels
  45174. * @return {void}
  45175. * @fires Highcharts.Series#event:afterDrawDataLabels
  45176. */
  45177. Series.prototype.drawDataLabels = function () {
  45178. var series = this,
  45179. chart = series.chart,
  45180. seriesOptions = series.options,
  45181. seriesDlOptions = seriesOptions.dataLabels,
  45182. points = series.points,
  45183. pointOptions,
  45184. hasRendered = series.hasRendered || 0,
  45185. dataLabelsGroup,
  45186. dataLabelAnim = seriesDlOptions.animation,
  45187. animationConfig = seriesDlOptions.defer ?
  45188. getDeferredAnimation(chart,
  45189. dataLabelAnim,
  45190. series) :
  45191. { defer: 0,
  45192. duration: 0 },
  45193. renderer = chart.renderer;
  45194. /**
  45195. * Handle the dataLabels.filter option.
  45196. * @private
  45197. */
  45198. function applyFilter(point, options) {
  45199. var filter = options.filter,
  45200. op,
  45201. prop,
  45202. val;
  45203. if (filter) {
  45204. op = filter.operator;
  45205. prop = point[filter.property];
  45206. val = filter.value;
  45207. if ((op === '>' && prop > val) ||
  45208. (op === '<' && prop < val) ||
  45209. (op === '>=' && prop >= val) ||
  45210. (op === '<=' && prop <= val) ||
  45211. (op === '==' && prop == val) || // eslint-disable-line eqeqeq
  45212. (op === '===' && prop === val)) {
  45213. return true;
  45214. }
  45215. return false;
  45216. }
  45217. return true;
  45218. }
  45219. /**
  45220. * Merge two objects that can be arrays. If one of them is an array, the
  45221. * other is merged into each element. If both are arrays, each element is
  45222. * merged by index. If neither are arrays, we use normal merge.
  45223. * @private
  45224. */
  45225. function mergeArrays(one, two) {
  45226. var res = [],
  45227. i;
  45228. if (isArray(one) && !isArray(two)) {
  45229. res = one.map(function (el) {
  45230. return merge(el, two);
  45231. });
  45232. }
  45233. else if (isArray(two) && !isArray(one)) {
  45234. res = two.map(function (el) {
  45235. return merge(one, el);
  45236. });
  45237. }
  45238. else if (!isArray(one) && !isArray(two)) {
  45239. res = merge(one, two);
  45240. }
  45241. else {
  45242. i = Math.max(one.length, two.length);
  45243. while (i--) {
  45244. res[i] = merge(one[i], two[i]);
  45245. }
  45246. }
  45247. return res;
  45248. }
  45249. // Merge in plotOptions.dataLabels for series
  45250. seriesDlOptions = mergeArrays(mergeArrays(chart.options.plotOptions &&
  45251. chart.options.plotOptions.series &&
  45252. chart.options.plotOptions.series.dataLabels, chart.options.plotOptions &&
  45253. chart.options.plotOptions[series.type] &&
  45254. chart.options.plotOptions[series.type].dataLabels), seriesDlOptions);
  45255. fireEvent(this, 'drawDataLabels');
  45256. if (isArray(seriesDlOptions) ||
  45257. seriesDlOptions.enabled ||
  45258. series._hasPointLabels) {
  45259. // Create a separate group for the data labels to avoid rotation
  45260. dataLabelsGroup = series.plotGroup('dataLabelsGroup', 'data-labels', !hasRendered ? 'hidden' : 'inherit', // #5133, #10220
  45261. seriesDlOptions.zIndex || 6);
  45262. dataLabelsGroup.attr({ opacity: +hasRendered }); // #3300
  45263. if (!hasRendered) {
  45264. var group = series.dataLabelsGroup;
  45265. if (group) {
  45266. if (series.visible) { // #2597, #3023, #3024
  45267. dataLabelsGroup.show(true);
  45268. }
  45269. group[seriesOptions.animation ? 'animate' : 'attr']({ opacity: 1 }, animationConfig);
  45270. }
  45271. }
  45272. // Make the labels for each point
  45273. points.forEach(function (point) {
  45274. // Merge in series options for the point.
  45275. // @note dataLabelAttribs (like pointAttribs) would eradicate
  45276. // the need for dlOptions, and simplify the section below.
  45277. pointOptions = splat(mergeArrays(seriesDlOptions, point.dlOptions || // dlOptions is used in treemaps
  45278. (point.options && point.options.dataLabels)));
  45279. // Handle each individual data label for this point
  45280. pointOptions.forEach(function (labelOptions, i) {
  45281. // Options for one datalabel
  45282. var labelEnabled = (labelOptions.enabled &&
  45283. // #2282, #4641, #7112, #10049
  45284. (!point.isNull || point.dataLabelOnNull) &&
  45285. applyFilter(point,
  45286. labelOptions)),
  45287. labelConfig,
  45288. formatString,
  45289. labelText,
  45290. style,
  45291. rotation,
  45292. attr,
  45293. dataLabel = point.dataLabels ? point.dataLabels[i] :
  45294. point.dataLabel,
  45295. connector = point.connectors ? point.connectors[i] :
  45296. point.connector,
  45297. labelDistance = pick(labelOptions.distance,
  45298. point.labelDistance),
  45299. isNew = !dataLabel;
  45300. if (labelEnabled) {
  45301. // Create individual options structure that can be extended
  45302. // without affecting others
  45303. labelConfig = point.getLabelConfig();
  45304. formatString = pick(labelOptions[point.formatPrefix + 'Format'], labelOptions.format);
  45305. labelText = defined(formatString) ?
  45306. format(formatString, labelConfig, chart) :
  45307. (labelOptions[point.formatPrefix + 'Formatter'] ||
  45308. labelOptions.formatter).call(labelConfig, labelOptions);
  45309. style = labelOptions.style;
  45310. rotation = labelOptions.rotation;
  45311. if (!chart.styledMode) {
  45312. // Determine the color
  45313. style.color = pick(labelOptions.color, style.color, series.color, palette.neutralColor100);
  45314. // Get automated contrast color
  45315. if (style.color === 'contrast') {
  45316. point.contrastColor = renderer.getContrast((point.color || series.color));
  45317. style.color = (!defined(labelDistance) &&
  45318. labelOptions.inside) ||
  45319. labelDistance < 0 ||
  45320. !!seriesOptions.stacking ?
  45321. point.contrastColor :
  45322. palette.neutralColor100;
  45323. }
  45324. else {
  45325. delete point.contrastColor;
  45326. }
  45327. if (seriesOptions.cursor) {
  45328. style.cursor = seriesOptions.cursor;
  45329. }
  45330. }
  45331. attr = {
  45332. r: labelOptions.borderRadius || 0,
  45333. rotation: rotation,
  45334. padding: labelOptions.padding,
  45335. zIndex: 1
  45336. };
  45337. if (!chart.styledMode) {
  45338. attr.fill = labelOptions.backgroundColor;
  45339. attr.stroke = labelOptions.borderColor;
  45340. attr['stroke-width'] = labelOptions.borderWidth;
  45341. }
  45342. // Remove unused attributes (#947)
  45343. objectEach(attr, function (val, name) {
  45344. if (typeof val === 'undefined') {
  45345. delete attr[name];
  45346. }
  45347. });
  45348. }
  45349. // If the point is outside the plot area, destroy it. #678, #820
  45350. if (dataLabel && (!labelEnabled || !defined(labelText))) {
  45351. point.dataLabel =
  45352. point.dataLabel && point.dataLabel.destroy();
  45353. if (point.dataLabels) {
  45354. // Remove point.dataLabels if this was the last one
  45355. if (point.dataLabels.length === 1) {
  45356. delete point.dataLabels;
  45357. }
  45358. else {
  45359. delete point.dataLabels[i];
  45360. }
  45361. }
  45362. if (!i) {
  45363. delete point.dataLabel;
  45364. }
  45365. if (connector) {
  45366. point.connector = point.connector.destroy();
  45367. if (point.connectors) {
  45368. // Remove point.connectors if this was the last one
  45369. if (point.connectors.length === 1) {
  45370. delete point.connectors;
  45371. }
  45372. else {
  45373. delete point.connectors[i];
  45374. }
  45375. }
  45376. }
  45377. // Individual labels are disabled if the are explicitly disabled
  45378. // in the point options, or if they fall outside the plot area.
  45379. }
  45380. else if (labelEnabled && defined(labelText)) {
  45381. if (!dataLabel) {
  45382. // Create new label element
  45383. point.dataLabels = point.dataLabels || [];
  45384. dataLabel = point.dataLabels[i] = rotation ?
  45385. // Labels don't rotate, use text element
  45386. renderer.text(labelText, 0, -9999, labelOptions.useHTML)
  45387. .addClass('highcharts-data-label') :
  45388. // We can use label
  45389. renderer.label(labelText, 0, -9999, labelOptions.shape, null, null, labelOptions.useHTML, null, 'data-label');
  45390. // Store for backwards compatibility
  45391. if (!i) {
  45392. point.dataLabel = dataLabel;
  45393. }
  45394. dataLabel.addClass(' highcharts-data-label-color-' + point.colorIndex +
  45395. ' ' + (labelOptions.className || '') +
  45396. ( // #3398
  45397. labelOptions.useHTML ?
  45398. ' highcharts-tracker' :
  45399. ''));
  45400. }
  45401. else {
  45402. // Use old element and just update text
  45403. attr.text = labelText;
  45404. }
  45405. // Store data label options for later access
  45406. dataLabel.options = labelOptions;
  45407. dataLabel.attr(attr);
  45408. if (!chart.styledMode) {
  45409. // Styles must be applied before add in order to read
  45410. // text bounding box
  45411. dataLabel.css(style).shadow(labelOptions.shadow);
  45412. }
  45413. if (!dataLabel.added) {
  45414. dataLabel.add(dataLabelsGroup);
  45415. }
  45416. if (labelOptions.textPath && !labelOptions.useHTML) {
  45417. dataLabel.setTextPath((point.getDataLabelPath &&
  45418. point.getDataLabelPath(dataLabel)) || point.graphic, labelOptions.textPath);
  45419. if (point.dataLabelPath &&
  45420. !labelOptions.textPath.enabled) {
  45421. // clean the DOM
  45422. point.dataLabelPath = point.dataLabelPath.destroy();
  45423. }
  45424. }
  45425. // Now the data label is created and placed at 0,0, so we
  45426. // need to align it
  45427. series.alignDataLabel(point, dataLabel, labelOptions, null, isNew);
  45428. }
  45429. });
  45430. });
  45431. }
  45432. fireEvent(this, 'afterDrawDataLabels');
  45433. };
  45434. /**
  45435. * Align each individual data label.
  45436. *
  45437. * @private
  45438. * @function Highcharts.Series#alignDataLabel
  45439. * @param {Highcharts.Point} point
  45440. * @param {Highcharts.SVGElement} dataLabel
  45441. * @param {Highcharts.DataLabelsOptions} options
  45442. * @param {Highcharts.BBoxObject} alignTo
  45443. * @param {boolean} [isNew]
  45444. * @return {void}
  45445. */
  45446. Series.prototype.alignDataLabel = function (point, dataLabel, options, alignTo, isNew) {
  45447. var series = this,
  45448. chart = this.chart,
  45449. inverted = this.isCartesian && chart.inverted,
  45450. enabledDataSorting = this.enabledDataSorting,
  45451. plotX = pick(point.dlBox && point.dlBox.centerX,
  45452. point.plotX, -9999),
  45453. plotY = pick(point.plotY, -9999),
  45454. bBox = dataLabel.getBBox(),
  45455. baseline,
  45456. rotation = options.rotation,
  45457. normRotation,
  45458. negRotation,
  45459. align = options.align,
  45460. rotCorr, // rotation correction
  45461. isInsidePlot = chart.isInsidePlot(plotX,
  45462. Math.round(plotY), {
  45463. inverted: inverted,
  45464. paneCoordinates: true,
  45465. series: series
  45466. }),
  45467. // Math.round for rounding errors (#2683), alignTo to allow column
  45468. // labels (#2700)
  45469. alignAttr, // the final position;
  45470. justify = pick(options.overflow, (enabledDataSorting ? 'none' : 'justify')) === 'justify', visible = this.visible &&
  45471. point.visible !== false &&
  45472. (point.series.forceDL ||
  45473. (enabledDataSorting && !justify) ||
  45474. isInsidePlot ||
  45475. (
  45476. // If the data label is inside the align box, it is enough
  45477. // that parts of the align box is inside the plot area
  45478. // (#12370). When stacking, it is always inside regardless
  45479. // of the option (#15148).
  45480. pick(options.inside, !!this.options.stacking) &&
  45481. alignTo &&
  45482. chart.isInsidePlot(plotX, inverted ?
  45483. alignTo.x + 1 :
  45484. alignTo.y + alignTo.height - 1, {
  45485. inverted: inverted,
  45486. paneCoordinates: true,
  45487. series: series
  45488. }))), setStartPos = function (alignOptions) {
  45489. if (enabledDataSorting && series.xAxis && !justify) {
  45490. series.setDataLabelStartPos(point, dataLabel, isNew, isInsidePlot, alignOptions);
  45491. }
  45492. };
  45493. if (visible) {
  45494. baseline = chart.renderer.fontMetrics(chart.styledMode ? void 0 : options.style.fontSize, dataLabel).b;
  45495. // The alignment box is a singular point
  45496. alignTo = extend({
  45497. x: inverted ? this.yAxis.len - plotY : plotX,
  45498. y: Math.round(inverted ? this.xAxis.len - plotX : plotY),
  45499. width: 0,
  45500. height: 0
  45501. }, alignTo);
  45502. // Add the text size for alignment calculation
  45503. extend(options, {
  45504. width: bBox.width,
  45505. height: bBox.height
  45506. });
  45507. // Allow a hook for changing alignment in the last moment, then do the
  45508. // alignment
  45509. if (rotation) {
  45510. justify = false; // Not supported for rotated text
  45511. rotCorr = chart.renderer.rotCorr(baseline, rotation); // #3723
  45512. alignAttr = {
  45513. x: (alignTo.x +
  45514. (options.x || 0) +
  45515. alignTo.width / 2 +
  45516. rotCorr.x),
  45517. y: (alignTo.y +
  45518. (options.y || 0) +
  45519. { top: 0, middle: 0.5, bottom: 1 }[options.verticalAlign] *
  45520. alignTo.height)
  45521. };
  45522. setStartPos(alignAttr); // data sorting
  45523. dataLabel[isNew ? 'attr' : 'animate'](alignAttr)
  45524. .attr({
  45525. align: align
  45526. });
  45527. // Compensate for the rotated label sticking out on the sides
  45528. normRotation = (rotation + 720) % 360;
  45529. negRotation = normRotation > 180 && normRotation < 360;
  45530. if (align === 'left') {
  45531. alignAttr.y -= negRotation ? bBox.height : 0;
  45532. }
  45533. else if (align === 'center') {
  45534. alignAttr.x -= bBox.width / 2;
  45535. alignAttr.y -= bBox.height / 2;
  45536. }
  45537. else if (align === 'right') {
  45538. alignAttr.x -= bBox.width;
  45539. alignAttr.y -= negRotation ? 0 : bBox.height;
  45540. }
  45541. dataLabel.placed = true;
  45542. dataLabel.alignAttr = alignAttr;
  45543. }
  45544. else {
  45545. setStartPos(alignTo); // data sorting
  45546. dataLabel.align(options, void 0, alignTo);
  45547. alignAttr = dataLabel.alignAttr;
  45548. }
  45549. // Handle justify or crop
  45550. if (justify && alignTo.height >= 0) { // #8830
  45551. this.justifyDataLabel(dataLabel, options, alignAttr, bBox, alignTo, isNew);
  45552. // Now check that the data label is within the plot area
  45553. }
  45554. else if (pick(options.crop, true)) {
  45555. visible =
  45556. chart.isInsidePlot(alignAttr.x, alignAttr.y, {
  45557. paneCoordinates: true,
  45558. series: series
  45559. }) &&
  45560. chart.isInsidePlot(alignAttr.x + bBox.width, alignAttr.y + bBox.height, {
  45561. paneCoordinates: true,
  45562. series: series
  45563. });
  45564. }
  45565. // When we're using a shape, make it possible with a connector or an
  45566. // arrow pointing to thie point
  45567. if (options.shape && !rotation) {
  45568. dataLabel[isNew ? 'attr' : 'animate']({
  45569. anchorX: inverted ?
  45570. chart.plotWidth - point.plotY :
  45571. point.plotX,
  45572. anchorY: inverted ?
  45573. chart.plotHeight - point.plotX :
  45574. point.plotY
  45575. });
  45576. }
  45577. }
  45578. // To use alignAttr property in hideOverlappingLabels
  45579. if (isNew && enabledDataSorting) {
  45580. dataLabel.placed = false;
  45581. }
  45582. // Show or hide based on the final aligned position
  45583. if (!visible && (!enabledDataSorting || justify)) {
  45584. dataLabel.hide(true);
  45585. dataLabel.placed = false; // don't animate back in
  45586. }
  45587. };
  45588. /**
  45589. * Set starting position for data label sorting animation.
  45590. *
  45591. * @private
  45592. * @function Highcharts.Series#setDataLabelStartPos
  45593. * @param {Highcharts.SVGElement} dataLabel
  45594. * @param {Highcharts.ColumnPoint} point
  45595. * @param {boolean | undefined} [isNew]
  45596. * @param {boolean} [isInside]
  45597. * @param {Highcharts.AlignObject} [alignOptions]
  45598. *
  45599. * @return {void}
  45600. */
  45601. Series.prototype.setDataLabelStartPos = function (point, dataLabel, isNew, isInside, alignOptions) {
  45602. var chart = this.chart,
  45603. inverted = chart.inverted,
  45604. xAxis = this.xAxis,
  45605. reversed = xAxis.reversed,
  45606. labelCenter = inverted ? dataLabel.height / 2 : dataLabel.width / 2,
  45607. pointWidth = point.pointWidth,
  45608. halfWidth = pointWidth ? pointWidth / 2 : 0,
  45609. startXPos,
  45610. startYPos;
  45611. startXPos = inverted ?
  45612. alignOptions.x :
  45613. (reversed ?
  45614. -labelCenter - halfWidth :
  45615. xAxis.width - labelCenter + halfWidth);
  45616. startYPos = inverted ?
  45617. (reversed ?
  45618. this.yAxis.height - labelCenter + halfWidth :
  45619. -labelCenter - halfWidth) : alignOptions.y;
  45620. dataLabel.startXPos = startXPos;
  45621. dataLabel.startYPos = startYPos;
  45622. // We need to handle visibility in case of sorting point outside plot area
  45623. if (!isInside) {
  45624. dataLabel
  45625. .attr({ opacity: 1 })
  45626. .animate({ opacity: 0 }, void 0, dataLabel.hide);
  45627. }
  45628. else if (dataLabel.visibility === 'hidden') {
  45629. dataLabel.show();
  45630. dataLabel
  45631. .attr({ opacity: 0 })
  45632. .animate({ opacity: 1 });
  45633. }
  45634. // Save start position on first render, but do not change position
  45635. if (!chart.hasRendered) {
  45636. return;
  45637. }
  45638. // Set start position
  45639. if (isNew) {
  45640. dataLabel.attr({ x: dataLabel.startXPos, y: dataLabel.startYPos });
  45641. }
  45642. dataLabel.placed = true;
  45643. };
  45644. /**
  45645. * If data labels fall partly outside the plot area, align them back in, in a
  45646. * way that doesn't hide the point.
  45647. *
  45648. * @private
  45649. * @function Highcharts.Series#justifyDataLabel
  45650. * @param {Highcharts.SVGElement} dataLabel
  45651. * @param {Highcharts.DataLabelsOptions} options
  45652. * @param {Highcharts.SVGAttributes} alignAttr
  45653. * @param {Highcharts.BBoxObject} bBox
  45654. * @param {Highcharts.BBoxObject} [alignTo]
  45655. * @param {boolean} [isNew]
  45656. * @return {boolean|undefined}
  45657. */
  45658. Series.prototype.justifyDataLabel = function (dataLabel, options, alignAttr, bBox, alignTo, isNew) {
  45659. var chart = this.chart,
  45660. align = options.align,
  45661. verticalAlign = options.verticalAlign,
  45662. off,
  45663. justified,
  45664. padding = dataLabel.box ? 0 : (dataLabel.padding || 0);
  45665. var _a = options.x,
  45666. x = _a === void 0 ? 0 : _a,
  45667. _b = options.y,
  45668. y = _b === void 0 ? 0 : _b;
  45669. // Off left
  45670. off = (alignAttr.x || 0) + padding;
  45671. if (off < 0) {
  45672. if (align === 'right' && x >= 0) {
  45673. options.align = 'left';
  45674. options.inside = true;
  45675. }
  45676. else {
  45677. x -= off;
  45678. }
  45679. justified = true;
  45680. }
  45681. // Off right
  45682. off = (alignAttr.x || 0) + bBox.width - padding;
  45683. if (off > chart.plotWidth) {
  45684. if (align === 'left' && x <= 0) {
  45685. options.align = 'right';
  45686. options.inside = true;
  45687. }
  45688. else {
  45689. x += chart.plotWidth - off;
  45690. }
  45691. justified = true;
  45692. }
  45693. // Off top
  45694. off = alignAttr.y + padding;
  45695. if (off < 0) {
  45696. if (verticalAlign === 'bottom' && y >= 0) {
  45697. options.verticalAlign = 'top';
  45698. options.inside = true;
  45699. }
  45700. else {
  45701. y -= off;
  45702. }
  45703. justified = true;
  45704. }
  45705. // Off bottom
  45706. off = (alignAttr.y || 0) + bBox.height - padding;
  45707. if (off > chart.plotHeight) {
  45708. if (verticalAlign === 'top' && y <= 0) {
  45709. options.verticalAlign = 'bottom';
  45710. options.inside = true;
  45711. }
  45712. else {
  45713. y += chart.plotHeight - off;
  45714. }
  45715. justified = true;
  45716. }
  45717. if (justified) {
  45718. options.x = x;
  45719. options.y = y;
  45720. dataLabel.placed = !isNew;
  45721. dataLabel.align(options, void 0, alignTo);
  45722. }
  45723. return justified;
  45724. };
  45725. if (seriesTypes.pie) {
  45726. seriesTypes.pie.prototype.dataLabelPositioners = {
  45727. // Based on the value computed in Highcharts' distribute algorithm.
  45728. radialDistributionY: function (point) {
  45729. return point.top + point.distributeBox.pos;
  45730. },
  45731. // get the x - use the natural x position for labels near the
  45732. // top and bottom, to prevent the top and botton slice
  45733. // connectors from touching each other on either side
  45734. // Based on the value computed in Highcharts' distribute algorithm.
  45735. radialDistributionX: function (series, point, y, naturalY) {
  45736. return series.getX(y < point.top + 2 || y > point.bottom - 2 ?
  45737. naturalY :
  45738. y, point.half, point);
  45739. },
  45740. // dataLabels.distance determines the x position of the label
  45741. justify: function (point, radius, seriesCenter) {
  45742. return seriesCenter[0] + (point.half ? -1 : 1) *
  45743. (radius + point.labelDistance);
  45744. },
  45745. // Left edges of the left-half labels touch the left edge of the plot
  45746. // area. Right edges of the right-half labels touch the right edge of
  45747. // the plot area.
  45748. alignToPlotEdges: function (dataLabel, half, plotWidth, plotLeft) {
  45749. var dataLabelWidth = dataLabel.getBBox().width;
  45750. return half ? dataLabelWidth + plotLeft :
  45751. plotWidth - dataLabelWidth - plotLeft;
  45752. },
  45753. // Connectors of each side end in the same x position. Labels are
  45754. // aligned to them. Left edge of the widest left-half label touches the
  45755. // left edge of the plot area. Right edge of the widest right-half label
  45756. // touches the right edge of the plot area.
  45757. alignToConnectors: function (points, half, plotWidth, plotLeft) {
  45758. var maxDataLabelWidth = 0,
  45759. dataLabelWidth;
  45760. // find widest data label
  45761. points.forEach(function (point) {
  45762. dataLabelWidth = point.dataLabel.getBBox().width;
  45763. if (dataLabelWidth > maxDataLabelWidth) {
  45764. maxDataLabelWidth = dataLabelWidth;
  45765. }
  45766. });
  45767. return half ? maxDataLabelWidth + plotLeft :
  45768. plotWidth - maxDataLabelWidth - plotLeft;
  45769. }
  45770. };
  45771. /**
  45772. * Override the base drawDataLabels method by pie specific functionality
  45773. *
  45774. * @private
  45775. * @function Highcharts.seriesTypes.pie#drawDataLabels
  45776. * @return {void}
  45777. */
  45778. seriesTypes.pie.prototype.drawDataLabels = function () {
  45779. var series = this,
  45780. data = series.data,
  45781. point,
  45782. chart = series.chart,
  45783. options = series.options.dataLabels || {},
  45784. connectorPadding = options.connectorPadding,
  45785. connectorWidth,
  45786. plotWidth = chart.plotWidth,
  45787. plotHeight = chart.plotHeight,
  45788. plotLeft = chart.plotLeft,
  45789. maxWidth = Math.round(chart.chartWidth / 3),
  45790. connector,
  45791. seriesCenter = series.center,
  45792. radius = seriesCenter[2] / 2,
  45793. centerY = seriesCenter[1],
  45794. dataLabel,
  45795. dataLabelWidth,
  45796. // labelPos,
  45797. labelPosition,
  45798. labelHeight,
  45799. // divide the points into right and left halves for anti collision
  45800. halves = [
  45801. [],
  45802. [] // left
  45803. ],
  45804. x,
  45805. y,
  45806. visibility,
  45807. j,
  45808. overflow = [0, 0, 0, 0], // top, right, bottom, left
  45809. dataLabelPositioners = series.dataLabelPositioners,
  45810. pointDataLabelsOptions;
  45811. // get out if not enabled
  45812. if (!series.visible ||
  45813. (!options.enabled &&
  45814. !series._hasPointLabels)) {
  45815. return;
  45816. }
  45817. // Reset all labels that have been shortened
  45818. data.forEach(function (point) {
  45819. if (point.dataLabel && point.visible && point.dataLabel.shortened) {
  45820. point.dataLabel
  45821. .attr({
  45822. width: 'auto'
  45823. }).css({
  45824. width: 'auto',
  45825. textOverflow: 'clip'
  45826. });
  45827. point.dataLabel.shortened = false;
  45828. }
  45829. });
  45830. // run parent method
  45831. Series.prototype.drawDataLabels.apply(series);
  45832. data.forEach(function (point) {
  45833. if (point.dataLabel) {
  45834. if (point.visible) { // #407, #2510
  45835. // Arrange points for detection collision
  45836. halves[point.half].push(point);
  45837. // Reset positions (#4905)
  45838. point.dataLabel._pos = null;
  45839. // Avoid long labels squeezing the pie size too far down
  45840. if (!defined(options.style.width) &&
  45841. !defined(point.options.dataLabels &&
  45842. point.options.dataLabels.style &&
  45843. point.options.dataLabels.style.width)) {
  45844. if (point.dataLabel.getBBox().width > maxWidth) {
  45845. point.dataLabel.css({
  45846. // Use a fraction of the maxWidth to avoid
  45847. // wrapping close to the end of the string.
  45848. width: Math.round(maxWidth * 0.7) + 'px'
  45849. });
  45850. point.dataLabel.shortened = true;
  45851. }
  45852. }
  45853. }
  45854. else {
  45855. point.dataLabel = point.dataLabel.destroy();
  45856. // Workaround to make pies destroy multiple datalabels
  45857. // correctly. This logic needs rewriting to support multiple
  45858. // datalabels fully.
  45859. if (point.dataLabels && point.dataLabels.length === 1) {
  45860. delete point.dataLabels;
  45861. }
  45862. }
  45863. }
  45864. });
  45865. /* Loop over the points in each half, starting from the top and bottom
  45866. * of the pie to detect overlapping labels.
  45867. */
  45868. halves.forEach(function (points, i) {
  45869. var top,
  45870. bottom,
  45871. length = points.length,
  45872. positions = [],
  45873. naturalY,
  45874. sideOverflow,
  45875. size,
  45876. distributionLength;
  45877. if (!length) {
  45878. return;
  45879. }
  45880. // Sort by angle
  45881. series.sortByAngle(points, i - 0.5);
  45882. // Only do anti-collision when we have dataLabels outside the pie
  45883. // and have connectors. (#856)
  45884. if (series.maxLabelDistance > 0) {
  45885. top = Math.max(0, centerY - radius - series.maxLabelDistance);
  45886. bottom = Math.min(centerY + radius + series.maxLabelDistance, chart.plotHeight);
  45887. points.forEach(function (point) {
  45888. // check if specific points' label is outside the pie
  45889. if (point.labelDistance > 0 && point.dataLabel) {
  45890. // point.top depends on point.labelDistance value
  45891. // Used for calculation of y value in getX method
  45892. point.top = Math.max(0, centerY - radius - point.labelDistance);
  45893. point.bottom = Math.min(centerY + radius + point.labelDistance, chart.plotHeight);
  45894. size = point.dataLabel.getBBox().height || 21;
  45895. // point.positionsIndex is needed for getting index of
  45896. // parameter related to specific point inside positions
  45897. // array - not every point is in positions array.
  45898. point.distributeBox = {
  45899. target: point.labelPosition.natural.y -
  45900. point.top + size / 2,
  45901. size: size,
  45902. rank: point.y
  45903. };
  45904. positions.push(point.distributeBox);
  45905. }
  45906. });
  45907. distributionLength = bottom + size - top;
  45908. H.distribute(positions, distributionLength, distributionLength / 5);
  45909. }
  45910. // Now the used slots are sorted, fill them up sequentially
  45911. for (j = 0; j < length; j++) {
  45912. point = points[j];
  45913. // labelPos = point.labelPos;
  45914. labelPosition = point.labelPosition;
  45915. dataLabel = point.dataLabel;
  45916. visibility = point.visible === false ? 'hidden' : 'inherit';
  45917. naturalY = labelPosition.natural.y;
  45918. y = naturalY;
  45919. if (positions && defined(point.distributeBox)) {
  45920. if (typeof point.distributeBox.pos === 'undefined') {
  45921. visibility = 'hidden';
  45922. }
  45923. else {
  45924. labelHeight = point.distributeBox.size;
  45925. // Find label's y position
  45926. y = dataLabelPositioners
  45927. .radialDistributionY(point);
  45928. }
  45929. }
  45930. // It is needed to delete point.positionIndex for
  45931. // dynamically added points etc.
  45932. delete point.positionIndex; // @todo unused
  45933. // Find label's x position
  45934. // justify is undocumented in the API - preserve support for it
  45935. if (options.justify) {
  45936. x = dataLabelPositioners.justify(point, radius, seriesCenter);
  45937. }
  45938. else {
  45939. switch (options.alignTo) {
  45940. case 'connectors':
  45941. x = dataLabelPositioners.alignToConnectors(points, i, plotWidth, plotLeft);
  45942. break;
  45943. case 'plotEdges':
  45944. x = dataLabelPositioners.alignToPlotEdges(dataLabel, i, plotWidth, plotLeft);
  45945. break;
  45946. default:
  45947. x = dataLabelPositioners.radialDistributionX(series, point, y, naturalY);
  45948. }
  45949. }
  45950. // Record the placement and visibility
  45951. dataLabel._attr = {
  45952. visibility: visibility,
  45953. align: labelPosition.alignment
  45954. };
  45955. pointDataLabelsOptions = point.options.dataLabels || {};
  45956. dataLabel._pos = {
  45957. x: (x +
  45958. pick(pointDataLabelsOptions.x, options.x) + // (#12985)
  45959. ({
  45960. left: connectorPadding,
  45961. right: -connectorPadding
  45962. }[labelPosition.alignment] || 0)),
  45963. // 10 is for the baseline (label vs text)
  45964. y: (y +
  45965. pick(pointDataLabelsOptions.y, options.y) - // (#12985)
  45966. 10)
  45967. };
  45968. // labelPos.x = x;
  45969. // labelPos.y = y;
  45970. labelPosition.final.x = x;
  45971. labelPosition.final.y = y;
  45972. // Detect overflowing data labels
  45973. if (pick(options.crop, true)) {
  45974. dataLabelWidth = dataLabel.getBBox().width;
  45975. sideOverflow = null;
  45976. // Overflow left
  45977. if (x - dataLabelWidth < connectorPadding &&
  45978. i === 1 // left half
  45979. ) {
  45980. sideOverflow = Math.round(dataLabelWidth - x + connectorPadding);
  45981. overflow[3] = Math.max(sideOverflow, overflow[3]);
  45982. // Overflow right
  45983. }
  45984. else if (x + dataLabelWidth > plotWidth - connectorPadding &&
  45985. i === 0 // right half
  45986. ) {
  45987. sideOverflow = Math.round(x + dataLabelWidth - plotWidth + connectorPadding);
  45988. overflow[1] = Math.max(sideOverflow, overflow[1]);
  45989. }
  45990. // Overflow top
  45991. if (y - labelHeight / 2 < 0) {
  45992. overflow[0] = Math.max(Math.round(-y + labelHeight / 2), overflow[0]);
  45993. // Overflow left
  45994. }
  45995. else if (y + labelHeight / 2 > plotHeight) {
  45996. overflow[2] = Math.max(Math.round(y + labelHeight / 2 - plotHeight), overflow[2]);
  45997. }
  45998. dataLabel.sideOverflow = sideOverflow;
  45999. }
  46000. } // for each point
  46001. }); // for each half
  46002. // Do not apply the final placement and draw the connectors until we
  46003. // have verified that labels are not spilling over.
  46004. if (arrayMax(overflow) === 0 ||
  46005. this.verifyDataLabelOverflow(overflow)) {
  46006. // Place the labels in the final position
  46007. this.placeDataLabels();
  46008. this.points.forEach(function (point) {
  46009. // #8864: every connector can have individual options
  46010. pointDataLabelsOptions =
  46011. merge(options, point.options.dataLabels);
  46012. connectorWidth =
  46013. pick(pointDataLabelsOptions.connectorWidth, 1);
  46014. // Draw the connector
  46015. if (connectorWidth) {
  46016. var isNew = void 0;
  46017. connector = point.connector;
  46018. dataLabel = point.dataLabel;
  46019. if (dataLabel &&
  46020. dataLabel._pos &&
  46021. point.visible &&
  46022. point.labelDistance > 0) {
  46023. visibility = dataLabel._attr.visibility;
  46024. isNew = !connector;
  46025. if (isNew) {
  46026. point.connector = connector = chart.renderer
  46027. .path()
  46028. .addClass('highcharts-data-label-connector ' +
  46029. ' highcharts-color-' + point.colorIndex +
  46030. (point.className ?
  46031. ' ' + point.className :
  46032. ''))
  46033. .add(series.dataLabelsGroup);
  46034. if (!chart.styledMode) {
  46035. connector.attr({
  46036. 'stroke-width': connectorWidth,
  46037. 'stroke': (pointDataLabelsOptions.connectorColor ||
  46038. point.color ||
  46039. palette.neutralColor60)
  46040. });
  46041. }
  46042. }
  46043. connector[isNew ? 'attr' : 'animate']({
  46044. d: point.getConnectorPath()
  46045. });
  46046. connector.attr('visibility', visibility);
  46047. }
  46048. else if (connector) {
  46049. point.connector = connector.destroy();
  46050. }
  46051. }
  46052. });
  46053. }
  46054. };
  46055. /**
  46056. * Extendable method for getting the path of the connector between the data
  46057. * label and the pie slice.
  46058. *
  46059. * @private
  46060. * @function Highcharts.seriesTypes.pie#connectorPath
  46061. *
  46062. * @param {*} labelPos
  46063. *
  46064. * @return {Highcharts.SVGPathArray}
  46065. */
  46066. // TODO: depracated - remove it
  46067. /*
  46068. seriesTypes.pie.prototype.connectorPath = function (labelPos) {
  46069. let x = labelPos.x,
  46070. y = labelPos.y;
  46071. return pick(this.options.dataLabels.softConnector, true) ? [
  46072. 'M',
  46073. // end of the string at the label
  46074. x + (labelPos[6] === 'left' ? 5 : -5), y,
  46075. 'C',
  46076. x, y, // first break, next to the label
  46077. 2 * labelPos[2] - labelPos[4], 2 * labelPos[3] - labelPos[5],
  46078. labelPos[2], labelPos[3], // second break
  46079. 'L',
  46080. labelPos[4], labelPos[5] // base
  46081. ] : [
  46082. 'M',
  46083. // end of the string at the label
  46084. x + (labelPos[6] === 'left' ? 5 : -5), y,
  46085. 'L',
  46086. labelPos[2], labelPos[3], // second break
  46087. 'L',
  46088. labelPos[4], labelPos[5] // base
  46089. ];
  46090. };
  46091. */
  46092. /**
  46093. * Perform the final placement of the data labels after we have verified
  46094. * that they fall within the plot area.
  46095. *
  46096. * @private
  46097. * @function Highcharts.seriesTypes.pie#placeDataLabels
  46098. * @return {void}
  46099. */
  46100. seriesTypes.pie.prototype.placeDataLabels = function () {
  46101. this.points.forEach(function (point) {
  46102. var dataLabel = point.dataLabel,
  46103. _pos;
  46104. if (dataLabel && point.visible) {
  46105. _pos = dataLabel._pos;
  46106. if (_pos) {
  46107. // Shorten data labels with ellipsis if they still overflow
  46108. // after the pie has reached minSize (#223).
  46109. if (dataLabel.sideOverflow) {
  46110. dataLabel._attr.width =
  46111. Math.max(dataLabel.getBBox().width -
  46112. dataLabel.sideOverflow, 0);
  46113. dataLabel.css({
  46114. width: dataLabel._attr.width + 'px',
  46115. textOverflow: ((this.options.dataLabels.style || {})
  46116. .textOverflow ||
  46117. 'ellipsis')
  46118. });
  46119. dataLabel.shortened = true;
  46120. }
  46121. dataLabel.attr(dataLabel._attr);
  46122. dataLabel[dataLabel.moved ? 'animate' : 'attr'](_pos);
  46123. dataLabel.moved = true;
  46124. }
  46125. else if (dataLabel) {
  46126. dataLabel.attr({ y: -9999 });
  46127. }
  46128. }
  46129. // Clear for update
  46130. delete point.distributeBox;
  46131. }, this);
  46132. };
  46133. seriesTypes.pie.prototype.alignDataLabel = noop;
  46134. /**
  46135. * Verify whether the data labels are allowed to draw, or we should run more
  46136. * translation and data label positioning to keep them inside the plot area.
  46137. * Returns true when data labels are ready to draw.
  46138. *
  46139. * @private
  46140. * @function Highcharts.seriesTypes.pie#verifyDataLabelOverflow
  46141. * @param {Array<number>} overflow
  46142. * @return {boolean}
  46143. */
  46144. seriesTypes.pie.prototype.verifyDataLabelOverflow = function (overflow) {
  46145. var center = this.center,
  46146. options = this.options,
  46147. centerOption = options.center,
  46148. minSize = options.minSize || 80,
  46149. newSize = minSize,
  46150. // If a size is set, return true and don't try to shrink the pie
  46151. // to fit the labels.
  46152. ret = options.size !== null;
  46153. if (!ret) {
  46154. // Handle horizontal size and center
  46155. if (centerOption[0] !== null) { // Fixed center
  46156. newSize = Math.max(center[2] -
  46157. Math.max(overflow[1], overflow[3]), minSize);
  46158. }
  46159. else { // Auto center
  46160. newSize = Math.max(
  46161. // horizontal overflow
  46162. center[2] - overflow[1] - overflow[3], minSize);
  46163. // horizontal center
  46164. center[0] += (overflow[3] - overflow[1]) / 2;
  46165. }
  46166. // Handle vertical size and center
  46167. if (centerOption[1] !== null) { // Fixed center
  46168. newSize = clamp(newSize, minSize, center[2] - Math.max(overflow[0], overflow[2]));
  46169. }
  46170. else { // Auto center
  46171. newSize = clamp(newSize, minSize,
  46172. // vertical overflow
  46173. center[2] - overflow[0] - overflow[2]);
  46174. // vertical center
  46175. center[1] += (overflow[0] - overflow[2]) / 2;
  46176. }
  46177. // If the size must be decreased, we need to run translate and
  46178. // drawDataLabels again
  46179. if (newSize < center[2]) {
  46180. center[2] = newSize;
  46181. center[3] = Math.min(// #3632
  46182. relativeLength(options.innerSize || 0, newSize), newSize);
  46183. this.translate(center);
  46184. if (this.drawDataLabels) {
  46185. this.drawDataLabels();
  46186. }
  46187. // Else, return true to indicate that the pie and its labels is
  46188. // within the plot area
  46189. }
  46190. else {
  46191. ret = true;
  46192. }
  46193. }
  46194. return ret;
  46195. };
  46196. }
  46197. if (seriesTypes.column) {
  46198. /**
  46199. * Override the basic data label alignment by adjusting for the position of
  46200. * the column.
  46201. *
  46202. * @private
  46203. * @function Highcharts.seriesTypes.column#alignDataLabel
  46204. * @param {Highcharts.Point} point
  46205. * @param {Highcharts.SVGElement} dataLabel
  46206. * @param {Highcharts.DataLabelsOptions} options
  46207. * @param {Highcharts.BBoxObject} alignTo
  46208. * @param {boolean} [isNew]
  46209. * @return {void}
  46210. */
  46211. seriesTypes.column.prototype.alignDataLabel = function (point, dataLabel, options, alignTo, isNew) {
  46212. var inverted = this.chart.inverted,
  46213. series = point.series,
  46214. // data label box for alignment
  46215. dlBox = point.dlBox || point.shapeArgs,
  46216. below = pick(point.below, // range series
  46217. point.plotY >
  46218. pick(this.translatedThreshold,
  46219. series.yAxis.len)),
  46220. // draw it inside the box?
  46221. inside = pick(options.inside, !!this.options.stacking),
  46222. overshoot;
  46223. // Align to the column itself, or the top of it
  46224. if (dlBox) { // Area range uses this method but not alignTo
  46225. alignTo = merge(dlBox);
  46226. if (alignTo.y < 0) {
  46227. alignTo.height += alignTo.y;
  46228. alignTo.y = 0;
  46229. }
  46230. // If parts of the box overshoots outside the plot area, modify the
  46231. // box to center the label inside
  46232. overshoot = alignTo.y + alignTo.height - series.yAxis.len;
  46233. if (overshoot > 0 && overshoot < alignTo.height) {
  46234. alignTo.height -= overshoot;
  46235. }
  46236. if (inverted) {
  46237. alignTo = {
  46238. x: series.yAxis.len - alignTo.y - alignTo.height,
  46239. y: series.xAxis.len - alignTo.x - alignTo.width,
  46240. width: alignTo.height,
  46241. height: alignTo.width
  46242. };
  46243. }
  46244. // Compute the alignment box
  46245. if (!inside) {
  46246. if (inverted) {
  46247. alignTo.x += below ? 0 : alignTo.width;
  46248. alignTo.width = 0;
  46249. }
  46250. else {
  46251. alignTo.y += below ? alignTo.height : 0;
  46252. alignTo.height = 0;
  46253. }
  46254. }
  46255. }
  46256. // When alignment is undefined (typically columns and bars), display the
  46257. // individual point below or above the point depending on the threshold
  46258. options.align = pick(options.align, !inverted || inside ? 'center' : below ? 'right' : 'left');
  46259. options.verticalAlign = pick(options.verticalAlign, inverted || inside ? 'middle' : below ? 'top' : 'bottom');
  46260. // Call the parent method
  46261. Series.prototype.alignDataLabel.call(this, point, dataLabel, options, alignTo, isNew);
  46262. // If label was justified and we have contrast, set it:
  46263. if (options.inside && point.contrastColor) {
  46264. dataLabel.css({
  46265. color: point.contrastColor
  46266. });
  46267. }
  46268. };
  46269. }
  46270. });
  46271. _registerModule(_modules, 'Extensions/OverlappingDataLabels.js', [_modules['Core/Chart/Chart.js'], _modules['Core/Utilities.js']], function (Chart, U) {
  46272. /* *
  46273. *
  46274. * Highcharts module to hide overlapping data labels.
  46275. * This module is included in Highcharts.
  46276. *
  46277. * (c) 2009-2021 Torstein Honsi
  46278. *
  46279. * License: www.highcharts.com/license
  46280. *
  46281. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  46282. *
  46283. * */
  46284. var addEvent = U.addEvent,
  46285. fireEvent = U.fireEvent,
  46286. isArray = U.isArray,
  46287. isNumber = U.isNumber,
  46288. objectEach = U.objectEach,
  46289. pick = U.pick;
  46290. /**
  46291. * Internal type
  46292. * @private
  46293. */
  46294. /* eslint-disable no-invalid-this */
  46295. // Collect potensial overlapping data labels. Stack labels probably don't need
  46296. // to be considered because they are usually accompanied by data labels that lie
  46297. // inside the columns.
  46298. addEvent(Chart, 'render', function collectAndHide() {
  46299. var chart = this,
  46300. labels = [];
  46301. // Consider external label collectors
  46302. (this.labelCollectors || []).forEach(function (collector) {
  46303. labels = labels.concat(collector());
  46304. });
  46305. (this.yAxis || []).forEach(function (yAxis) {
  46306. if (yAxis.stacking &&
  46307. yAxis.options.stackLabels &&
  46308. !yAxis.options.stackLabels.allowOverlap) {
  46309. objectEach(yAxis.stacking.stacks, function (stack) {
  46310. objectEach(stack, function (stackItem) {
  46311. if (stackItem.label &&
  46312. stackItem.label.visibility !== 'hidden' // #15607
  46313. ) {
  46314. labels.push(stackItem.label);
  46315. }
  46316. });
  46317. });
  46318. }
  46319. });
  46320. (this.series || []).forEach(function (series) {
  46321. var dlOptions = series.options.dataLabels;
  46322. if (series.visible &&
  46323. !(dlOptions.enabled === false && !series._hasPointLabels)) { // #3866
  46324. var push = function (points) {
  46325. return points.forEach(function (point) {
  46326. if (point.visible) {
  46327. var dataLabels = (isArray(point.dataLabels) ?
  46328. point.dataLabels :
  46329. (point.dataLabel ? [point.dataLabel] : []));
  46330. dataLabels.forEach(function (label) {
  46331. var options = label.options;
  46332. label.labelrank = pick(options.labelrank, point.labelrank, point.shapeArgs && point.shapeArgs.height); // #4118
  46333. if (!options.allowOverlap) {
  46334. labels.push(label);
  46335. }
  46336. else { // #13449
  46337. label.oldOpacity = label.opacity;
  46338. label.newOpacity = 1;
  46339. hideOrShow(label, chart);
  46340. }
  46341. });
  46342. }
  46343. });
  46344. };
  46345. push(series.nodes || []);
  46346. push(series.points);
  46347. }
  46348. });
  46349. this.hideOverlappingLabels(labels);
  46350. });
  46351. /**
  46352. * Hide overlapping labels. Labels are moved and faded in and out on zoom to
  46353. * provide a smooth visual imression.
  46354. *
  46355. * @private
  46356. * @function Highcharts.Chart#hideOverlappingLabels
  46357. * @param {Array<Highcharts.SVGElement>} labels
  46358. * Rendered data labels
  46359. * @requires modules/overlapping-datalabels
  46360. */
  46361. Chart.prototype.hideOverlappingLabels = function (labels) {
  46362. var chart = this,
  46363. len = labels.length,
  46364. ren = chart.renderer,
  46365. label,
  46366. i,
  46367. j,
  46368. label1,
  46369. label2,
  46370. box1,
  46371. box2,
  46372. isLabelAffected = false,
  46373. isIntersectRect = function (box1,
  46374. box2) {
  46375. return !(box2.x >= box1.x + box1.width ||
  46376. box2.x + box2.width <= box1.x ||
  46377. box2.y >= box1.y + box1.height ||
  46378. box2.y + box2.height <= box1.y);
  46379. },
  46380. // Get the box with its position inside the chart, as opposed to getBBox
  46381. // that only reports the position relative to the parent.
  46382. getAbsoluteBox = function (label) {
  46383. var pos,
  46384. parent,
  46385. bBox,
  46386. // Substract the padding if no background or border (#4333)
  46387. padding = label.box ? 0 : (label.padding || 0),
  46388. lineHeightCorrection = 0,
  46389. xOffset = 0,
  46390. boxWidth,
  46391. alignValue;
  46392. if (label &&
  46393. (!label.alignAttr || label.placed)) {
  46394. pos = label.alignAttr || {
  46395. x: label.attr('x'),
  46396. y: label.attr('y')
  46397. };
  46398. parent = label.parentGroup;
  46399. // Get width and height if pure text nodes (stack labels)
  46400. if (!label.width) {
  46401. bBox = label.getBBox();
  46402. label.width = bBox.width;
  46403. label.height = bBox.height;
  46404. // Labels positions are computed from top left corner, so
  46405. // we need to substract the text height from text nodes too.
  46406. lineHeightCorrection = ren
  46407. .fontMetrics(null, label.element).h;
  46408. }
  46409. boxWidth = label.width - 2 * padding;
  46410. alignValue = {
  46411. left: '0',
  46412. center: '0.5',
  46413. right: '1'
  46414. }[label.alignValue];
  46415. if (alignValue) {
  46416. xOffset = +alignValue * boxWidth;
  46417. }
  46418. else if (isNumber(label.x) && Math.round(label.x) !== label.translateX) {
  46419. xOffset = label.x - label.translateX;
  46420. }
  46421. return {
  46422. x: pos.x + (parent.translateX || 0) + padding -
  46423. (xOffset || 0),
  46424. y: pos.y + (parent.translateY || 0) + padding -
  46425. lineHeightCorrection,
  46426. width: label.width - 2 * padding,
  46427. height: label.height - 2 * padding
  46428. };
  46429. }
  46430. };
  46431. for (i = 0; i < len; i++) {
  46432. label = labels[i];
  46433. if (label) {
  46434. // Mark with initial opacity
  46435. label.oldOpacity = label.opacity;
  46436. label.newOpacity = 1;
  46437. label.absoluteBox = getAbsoluteBox(label);
  46438. }
  46439. }
  46440. // Prevent a situation in a gradually rising slope, that each label will
  46441. // hide the previous one because the previous one always has lower rank.
  46442. labels.sort(function (a, b) {
  46443. return (b.labelrank || 0) - (a.labelrank || 0);
  46444. });
  46445. // Detect overlapping labels
  46446. for (i = 0; i < len; i++) {
  46447. label1 = labels[i];
  46448. box1 = label1 && label1.absoluteBox;
  46449. for (j = i + 1; j < len; ++j) {
  46450. label2 = labels[j];
  46451. box2 = label2 && label2.absoluteBox;
  46452. if (box1 &&
  46453. box2 &&
  46454. label1 !== label2 && // #6465, polar chart with connectEnds
  46455. label1.newOpacity !== 0 &&
  46456. label2.newOpacity !== 0) {
  46457. if (isIntersectRect(box1, box2)) {
  46458. (label1.labelrank < label2.labelrank ? label1 : label2)
  46459. .newOpacity = 0;
  46460. }
  46461. }
  46462. }
  46463. }
  46464. // Hide or show
  46465. labels.forEach(function (label) {
  46466. if (hideOrShow(label, chart)) {
  46467. isLabelAffected = true;
  46468. }
  46469. });
  46470. if (isLabelAffected) {
  46471. fireEvent(chart, 'afterHideAllOverlappingLabels');
  46472. }
  46473. };
  46474. /**
  46475. * Hide or show labels based on opacity.
  46476. *
  46477. * @private
  46478. * @function hideOrShow
  46479. * @param {Highcharts.SVGElement} label
  46480. * The label.
  46481. * @param {Highcharts.Chart} chart
  46482. * The chart that contains the label.
  46483. * @return {boolean}
  46484. */
  46485. function hideOrShow(label, chart) {
  46486. var complete,
  46487. newOpacity,
  46488. isLabelAffected = false;
  46489. if (label) {
  46490. newOpacity = label.newOpacity;
  46491. if (label.oldOpacity !== newOpacity) {
  46492. // Make sure the label is completely hidden to avoid catching
  46493. // clicks (#4362)
  46494. if (label.alignAttr && label.placed) { // data labels
  46495. label[newOpacity ? 'removeClass' : 'addClass']('highcharts-data-label-hidden');
  46496. complete = function () {
  46497. if (!chart.styledMode) {
  46498. label.css({ pointerEvents: newOpacity ? 'auto' : 'none' });
  46499. }
  46500. };
  46501. isLabelAffected = true;
  46502. // Animate or set the opacity
  46503. label.alignAttr.opacity = newOpacity;
  46504. label[label.isOld ? 'animate' : 'attr'](label.alignAttr, null, complete);
  46505. fireEvent(chart, 'afterHideOverlappingLabel');
  46506. }
  46507. else { // other labels, tick labels
  46508. label.attr({
  46509. opacity: newOpacity
  46510. });
  46511. }
  46512. }
  46513. label.isOld = true;
  46514. }
  46515. return isLabelAffected;
  46516. }
  46517. });
  46518. _registerModule(_modules, 'Core/Responsive.js', [_modules['Core/Utilities.js']], function (U) {
  46519. /* *
  46520. *
  46521. * (c) 2010-2021 Torstein Honsi
  46522. *
  46523. * License: www.highcharts.com/license
  46524. *
  46525. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  46526. *
  46527. * */
  46528. var extend = U.extend,
  46529. find = U.find,
  46530. isArray = U.isArray,
  46531. isObject = U.isObject,
  46532. merge = U.merge,
  46533. objectEach = U.objectEach,
  46534. pick = U.pick,
  46535. splat = U.splat,
  46536. uniqueKey = U.uniqueKey;
  46537. /* *
  46538. *
  46539. * Class
  46540. *
  46541. * */
  46542. /* eslint-disable no-invalid-this, valid-jsdoc */
  46543. var ResponsiveChart = /** @class */ (function () {
  46544. function ResponsiveChart() {
  46545. }
  46546. /* *
  46547. *
  46548. * Functions
  46549. *
  46550. * */
  46551. /**
  46552. * Get the current values for a given set of options. Used before we update
  46553. * the chart with a new responsiveness rule.
  46554. *
  46555. * @todo Restore axis options (by id?). The matching of items in collections
  46556. * bears resemblance to the oneToOne matching in Chart.update. Probably we
  46557. * can refactor out that matching and reuse it in both functions.
  46558. *
  46559. * @private
  46560. * @function Highcharts.Chart#currentOptions
  46561. */
  46562. ResponsiveChart.prototype.currentOptions = function (options) {
  46563. var chart = this, ret = {};
  46564. /**
  46565. * Recurse over a set of options and its current values,
  46566. * and store the current values in the ret object.
  46567. */
  46568. function getCurrent(options, curr, ret, depth) {
  46569. var i;
  46570. objectEach(options, function (val, key) {
  46571. if (!depth &&
  46572. chart.collectionsWithUpdate.indexOf(key) > -1 &&
  46573. curr[key]) {
  46574. val = splat(val);
  46575. ret[key] = [];
  46576. // Iterate over collections like series, xAxis or yAxis and
  46577. // map the items by index.
  46578. for (i = 0; i < Math.max(val.length, curr[key].length); i++) {
  46579. // Item exists in current data (#6347)
  46580. if (curr[key][i]) {
  46581. // If the item is missing from the new data, we need
  46582. // to save the whole config structure. Like when
  46583. // responsively updating from a dual axis layout to
  46584. // a single axis and back (#13544).
  46585. if (val[i] === void 0) {
  46586. ret[key][i] = curr[key][i];
  46587. // Otherwise, proceed
  46588. }
  46589. else {
  46590. ret[key][i] = {};
  46591. getCurrent(val[i], curr[key][i], ret[key][i], depth + 1);
  46592. }
  46593. }
  46594. }
  46595. }
  46596. else if (isObject(val)) {
  46597. ret[key] = isArray(val) ? [] : {};
  46598. getCurrent(val, curr[key] || {}, ret[key], depth + 1);
  46599. }
  46600. else if (typeof curr[key] === 'undefined') { // #10286
  46601. ret[key] = null;
  46602. }
  46603. else {
  46604. ret[key] = curr[key];
  46605. }
  46606. });
  46607. }
  46608. getCurrent(options, this.options, ret, 0);
  46609. return ret;
  46610. };
  46611. /**
  46612. * Handle a single responsiveness rule.
  46613. *
  46614. * @private
  46615. * @function Highcharts.Chart#matchResponsiveRule
  46616. * @param {Highcharts.ResponsiveRulesOptions} rule
  46617. * @param {Array<string>} matches
  46618. */
  46619. ResponsiveChart.prototype.matchResponsiveRule = function (rule, matches) {
  46620. var condition = rule.condition,
  46621. fn = condition.callback || function () {
  46622. return (this.chartWidth <= pick(condition.maxWidth,
  46623. Number.MAX_VALUE) &&
  46624. this.chartHeight <=
  46625. pick(condition.maxHeight,
  46626. Number.MAX_VALUE) &&
  46627. this.chartWidth >= pick(condition.minWidth, 0) &&
  46628. this.chartHeight >= pick(condition.minHeight, 0));
  46629. };
  46630. if (fn.call(this)) {
  46631. matches.push(rule._id);
  46632. }
  46633. };
  46634. /**
  46635. * Update the chart based on the current chart/document size and options for
  46636. * responsiveness.
  46637. *
  46638. * @private
  46639. * @function Highcharts.Chart#setResponsive
  46640. * @param {boolean} [redraw=true]
  46641. * @param {boolean} [reset=false]
  46642. * Reset by un-applying all rules. Chart.update resets all rules before
  46643. * applying updated options.
  46644. */
  46645. ResponsiveChart.prototype.setResponsive = function (redraw, reset) {
  46646. var options = this.options.responsive,
  46647. currentResponsive = this.currentResponsive;
  46648. var ruleIds = [],
  46649. undoOptions;
  46650. if (!reset && options && options.rules) {
  46651. options.rules.forEach(function (rule) {
  46652. if (typeof rule._id === 'undefined') {
  46653. rule._id = uniqueKey();
  46654. }
  46655. this.matchResponsiveRule(rule, ruleIds /* , redraw */);
  46656. }, this);
  46657. }
  46658. // Merge matching rules
  46659. var mergedOptions = merge.apply(void 0,
  46660. ruleIds
  46661. .map(function (ruleId) { return find((options || {}).rules || [],
  46662. function (rule) { return (rule._id === ruleId); }); })
  46663. .map(function (rule) { return (rule && rule.chartOptions); }));
  46664. mergedOptions.isResponsiveOptions = true;
  46665. // Stringified key for the rules that currently apply.
  46666. ruleIds = (ruleIds.toString() || void 0);
  46667. var currentRuleIds = currentResponsive && currentResponsive.ruleIds;
  46668. // Changes in what rules apply
  46669. if (ruleIds !== currentRuleIds) {
  46670. // Undo previous rules. Before we apply a new set of rules, we need
  46671. // to roll back completely to base options (#6291).
  46672. if (currentResponsive) {
  46673. this.update(currentResponsive.undoOptions, redraw, true);
  46674. }
  46675. if (ruleIds) {
  46676. // Get undo-options for matching rules
  46677. undoOptions = this.currentOptions(mergedOptions);
  46678. undoOptions.isResponsiveOptions = true;
  46679. this.currentResponsive = {
  46680. ruleIds: ruleIds,
  46681. mergedOptions: mergedOptions,
  46682. undoOptions: undoOptions
  46683. };
  46684. this.update(mergedOptions, redraw, true);
  46685. }
  46686. else {
  46687. this.currentResponsive = void 0;
  46688. }
  46689. }
  46690. };
  46691. return ResponsiveChart;
  46692. }());
  46693. /* *
  46694. *
  46695. * Composition
  46696. *
  46697. * */
  46698. var ResponsiveComposition = /** @class */ (function () {
  46699. function ResponsiveComposition() {
  46700. }
  46701. /* *
  46702. *
  46703. * Static Functions
  46704. *
  46705. * */
  46706. ResponsiveComposition.compose = function (ChartClass) {
  46707. extend(ChartClass.prototype, ResponsiveChart.prototype);
  46708. return ChartClass;
  46709. };
  46710. return ResponsiveComposition;
  46711. }());
  46712. /* *
  46713. *
  46714. * Default Export
  46715. *
  46716. * */
  46717. /* *
  46718. *
  46719. * API Declarations
  46720. *
  46721. * */
  46722. /**
  46723. * A callback function to gain complete control on when the responsive rule
  46724. * applies.
  46725. *
  46726. * @callback Highcharts.ResponsiveCallbackFunction
  46727. *
  46728. * @param {Highcharts.Chart} this
  46729. * Chart context.
  46730. *
  46731. * @return {boolean}
  46732. * Return `true` if it applies.
  46733. */
  46734. (''); // detached doclets above
  46735. /* *
  46736. *
  46737. * API Options
  46738. *
  46739. * */
  46740. /**
  46741. * Allows setting a set of rules to apply for different screen or chart
  46742. * sizes. Each rule specifies additional chart options.
  46743. *
  46744. * @sample {highstock} stock/demo/responsive/
  46745. * Stock chart
  46746. * @sample highcharts/responsive/axis/
  46747. * Axis
  46748. * @sample highcharts/responsive/legend/
  46749. * Legend
  46750. * @sample highcharts/responsive/classname/
  46751. * Class name
  46752. *
  46753. * @since 5.0.0
  46754. * @apioption responsive
  46755. */
  46756. /**
  46757. * A set of rules for responsive settings. The rules are executed from
  46758. * the top down.
  46759. *
  46760. * @sample {highcharts} highcharts/responsive/axis/
  46761. * Axis changes
  46762. * @sample {highstock} highcharts/responsive/axis/
  46763. * Axis changes
  46764. * @sample {highmaps} highcharts/responsive/axis/
  46765. * Axis changes
  46766. *
  46767. * @type {Array<*>}
  46768. * @since 5.0.0
  46769. * @apioption responsive.rules
  46770. */
  46771. /**
  46772. * A full set of chart options to apply as overrides to the general
  46773. * chart options. The chart options are applied when the given rule
  46774. * is active.
  46775. *
  46776. * A special case is configuration objects that take arrays, for example
  46777. * [xAxis](#xAxis), [yAxis](#yAxis) or [series](#series). For these
  46778. * collections, an `id` option is used to map the new option set to
  46779. * an existing object. If an existing object of the same id is not found,
  46780. * the item of the same indexupdated. So for example, setting `chartOptions`
  46781. * with two series items without an `id`, will cause the existing chart's
  46782. * two series to be updated with respective options.
  46783. *
  46784. * @sample {highstock} stock/demo/responsive/
  46785. * Stock chart
  46786. * @sample highcharts/responsive/axis/
  46787. * Axis
  46788. * @sample highcharts/responsive/legend/
  46789. * Legend
  46790. * @sample highcharts/responsive/classname/
  46791. * Class name
  46792. *
  46793. * @type {Highcharts.Options}
  46794. * @since 5.0.0
  46795. * @apioption responsive.rules.chartOptions
  46796. */
  46797. /**
  46798. * Under which conditions the rule applies.
  46799. *
  46800. * @since 5.0.0
  46801. * @apioption responsive.rules.condition
  46802. */
  46803. /**
  46804. * A callback function to gain complete control on when the responsive
  46805. * rule applies. Return `true` if it applies. This opens for checking
  46806. * against other metrics than the chart size, for example the document
  46807. * size or other elements.
  46808. *
  46809. * @type {Highcharts.ResponsiveCallbackFunction}
  46810. * @since 5.0.0
  46811. * @context Highcharts.Chart
  46812. * @apioption responsive.rules.condition.callback
  46813. */
  46814. /**
  46815. * The responsive rule applies if the chart height is less than this.
  46816. *
  46817. * @type {number}
  46818. * @since 5.0.0
  46819. * @apioption responsive.rules.condition.maxHeight
  46820. */
  46821. /**
  46822. * The responsive rule applies if the chart width is less than this.
  46823. *
  46824. * @sample highcharts/responsive/axis/
  46825. * Max width is 500
  46826. *
  46827. * @type {number}
  46828. * @since 5.0.0
  46829. * @apioption responsive.rules.condition.maxWidth
  46830. */
  46831. /**
  46832. * The responsive rule applies if the chart height is greater than this.
  46833. *
  46834. * @type {number}
  46835. * @default 0
  46836. * @since 5.0.0
  46837. * @apioption responsive.rules.condition.minHeight
  46838. */
  46839. /**
  46840. * The responsive rule applies if the chart width is greater than this.
  46841. *
  46842. * @type {number}
  46843. * @default 0
  46844. * @since 5.0.0
  46845. * @apioption responsive.rules.condition.minWidth
  46846. */
  46847. (''); // keeps doclets above in JS file
  46848. return ResponsiveComposition;
  46849. });
  46850. _registerModule(_modules, 'masters/highcharts.src.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js'], _modules['Core/DefaultOptions.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/Renderer/SVG/SVGRenderer.js'], _modules['Core/Renderer/HTML/HTMLElement.js'], _modules['Core/Renderer/HTML/HTMLRenderer.js'], _modules['Core/Axis/Axis.js'], _modules['Core/Axis/PlotLineOrBand.js'], _modules['Core/Axis/Tick.js'], _modules['Core/Pointer.js'], _modules['Core/MSPointer.js'], _modules['Core/Chart/Chart.js'], _modules['Core/Series/Series.js'], _modules['Core/Responsive.js'], _modules['Core/Color/Color.js'], _modules['Core/Time.js']], function (Highcharts, Utilities, DefaultOptions, Fx, Animation, AST, FormatUtilities, SVGElement, SVGRenderer, HTMLElement, HTMLRenderer, Axis, PlotLineOrBand, Tick, Pointer, MSPointer, Chart, Series, Responsive, Color, Time) {
  46851. var G = Highcharts;
  46852. // Animation
  46853. G.animate = Animation.animate;
  46854. G.animObject = Animation.animObject;
  46855. G.getDeferredAnimation = Animation.getDeferredAnimation;
  46856. G.setAnimation = Animation.setAnimation;
  46857. G.stop = Animation.stop;
  46858. G.timers = Fx.timers;
  46859. // Classes
  46860. G.AST = AST;
  46861. G.Axis = Axis;
  46862. G.Chart = Chart;
  46863. G.chart = Chart.chart;
  46864. G.Fx = Fx;
  46865. G.PlotLineOrBand = PlotLineOrBand;
  46866. G.Pointer = (MSPointer.isRequired() ? MSPointer : Pointer);
  46867. G.Series = Series;
  46868. G.SVGElement = SVGElement;
  46869. G.SVGRenderer = SVGRenderer;
  46870. G.Tick = Tick;
  46871. G.Time = Time;
  46872. // Color
  46873. G.Color = Color;
  46874. G.color = Color.parse;
  46875. // Compositions
  46876. HTMLRenderer.compose(SVGRenderer);
  46877. HTMLElement.compose(SVGElement);
  46878. // DefaultOptions
  46879. G.defaultOptions = DefaultOptions.defaultOptions;
  46880. G.getOptions = DefaultOptions.getOptions;
  46881. G.time = DefaultOptions.defaultTime;
  46882. G.setOptions = DefaultOptions.setOptions;
  46883. // Format Utilities
  46884. G.dateFormat = FormatUtilities.dateFormat;
  46885. G.format = FormatUtilities.format;
  46886. G.numberFormat = FormatUtilities.numberFormat;
  46887. // Utilities
  46888. G.addEvent = Utilities.addEvent;
  46889. G.arrayMax = Utilities.arrayMax;
  46890. G.arrayMin = Utilities.arrayMin;
  46891. G.attr = Utilities.attr;
  46892. G.clearTimeout = Utilities.clearTimeout;
  46893. G.correctFloat = Utilities.correctFloat;
  46894. G.createElement = Utilities.createElement;
  46895. G.css = Utilities.css;
  46896. G.defined = Utilities.defined;
  46897. G.destroyObjectProperties = Utilities.destroyObjectProperties;
  46898. G.discardElement = Utilities.discardElement;
  46899. G.erase = Utilities.erase;
  46900. G.error = Utilities.error;
  46901. G.extend = Utilities.extend;
  46902. G.extendClass = Utilities.extendClass;
  46903. G.find = Utilities.find;
  46904. G.fireEvent = Utilities.fireEvent;
  46905. G.getMagnitude = Utilities.getMagnitude;
  46906. G.getStyle = Utilities.getStyle;
  46907. G.inArray = Utilities.inArray;
  46908. G.isArray = Utilities.isArray;
  46909. G.isClass = Utilities.isClass;
  46910. G.isDOMElement = Utilities.isDOMElement;
  46911. G.isFunction = Utilities.isFunction;
  46912. G.isNumber = Utilities.isNumber;
  46913. G.isObject = Utilities.isObject;
  46914. G.isString = Utilities.isString;
  46915. G.keys = Utilities.keys;
  46916. G.merge = Utilities.merge;
  46917. G.normalizeTickInterval = Utilities.normalizeTickInterval;
  46918. G.objectEach = Utilities.objectEach;
  46919. G.offset = Utilities.offset;
  46920. G.pad = Utilities.pad;
  46921. G.pick = Utilities.pick;
  46922. G.pInt = Utilities.pInt;
  46923. G.relativeLength = Utilities.relativeLength;
  46924. G.removeEvent = Utilities.removeEvent;
  46925. G.splat = Utilities.splat;
  46926. G.stableSort = Utilities.stableSort;
  46927. G.syncTimeout = Utilities.syncTimeout;
  46928. G.timeUnits = Utilities.timeUnits;
  46929. G.uniqueKey = Utilities.uniqueKey;
  46930. G.useSerialIds = Utilities.useSerialIds;
  46931. G.wrap = Utilities.wrap;
  46932. // Compositions
  46933. Responsive.compose(Chart);
  46934. // Default Export
  46935. return G;
  46936. });
  46937. _registerModule(_modules, 'Core/Axis/NavigatorAxis.js', [_modules['Core/Globals.js'], _modules['Core/Utilities.js']], function (H, U) {
  46938. /* *
  46939. *
  46940. * (c) 2010-2021 Torstein Honsi
  46941. *
  46942. * License: www.highcharts.com/license
  46943. *
  46944. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  46945. *
  46946. * */
  46947. var isTouchDevice = H.isTouchDevice;
  46948. var addEvent = U.addEvent,
  46949. correctFloat = U.correctFloat,
  46950. defined = U.defined,
  46951. isNumber = U.isNumber,
  46952. pick = U.pick;
  46953. /* eslint-disable valid-jsdoc */
  46954. /**
  46955. * @private
  46956. * @class
  46957. */
  46958. var NavigatorAxisAdditions = /** @class */ (function () {
  46959. /* *
  46960. *
  46961. * Constructors
  46962. *
  46963. * */
  46964. function NavigatorAxisAdditions(axis) {
  46965. this.axis = axis;
  46966. }
  46967. /* *
  46968. *
  46969. * Functions
  46970. *
  46971. * */
  46972. /**
  46973. * @private
  46974. */
  46975. NavigatorAxisAdditions.prototype.destroy = function () {
  46976. this.axis = void 0;
  46977. };
  46978. /**
  46979. * Add logic to normalize the zoomed range in order to preserve the pressed
  46980. * state of range selector buttons
  46981. *
  46982. * @private
  46983. * @function Highcharts.Axis#toFixedRange
  46984. * @param {number} [pxMin]
  46985. * @param {number} [pxMax]
  46986. * @param {number} [fixedMin]
  46987. * @param {number} [fixedMax]
  46988. * @return {*}
  46989. */
  46990. NavigatorAxisAdditions.prototype.toFixedRange = function (pxMin, pxMax, fixedMin, fixedMax) {
  46991. var navigator = this;
  46992. var axis = navigator.axis;
  46993. var chart = axis.chart;
  46994. var fixedRange = chart && chart.fixedRange,
  46995. halfPointRange = (axis.pointRange || 0) / 2,
  46996. newMin = pick(fixedMin,
  46997. axis.translate(pxMin,
  46998. true, !axis.horiz)),
  46999. newMax = pick(fixedMax,
  47000. axis.translate(pxMax,
  47001. true, !axis.horiz)),
  47002. changeRatio = fixedRange && (newMax - newMin) / fixedRange;
  47003. // Add/remove half point range to/from the extremes (#1172)
  47004. if (!defined(fixedMin)) {
  47005. newMin = correctFloat(newMin + halfPointRange);
  47006. }
  47007. if (!defined(fixedMax)) {
  47008. newMax = correctFloat(newMax - halfPointRange);
  47009. }
  47010. // If the difference between the fixed range and the actual requested
  47011. // range is too great, the user is dragging across an ordinal gap, and
  47012. // we need to release the range selector button.
  47013. if (changeRatio > 0.7 && changeRatio < 1.3) {
  47014. if (fixedMax) {
  47015. newMin = newMax - fixedRange;
  47016. }
  47017. else {
  47018. newMax = newMin + fixedRange;
  47019. }
  47020. }
  47021. if (!isNumber(newMin) || !isNumber(newMax)) { // #1195, #7411
  47022. newMin = newMax = void 0;
  47023. }
  47024. return {
  47025. min: newMin,
  47026. max: newMax
  47027. };
  47028. };
  47029. return NavigatorAxisAdditions;
  47030. }());
  47031. /**
  47032. * @private
  47033. * @class
  47034. */
  47035. var NavigatorAxis = /** @class */ (function () {
  47036. function NavigatorAxis() {
  47037. }
  47038. /* *
  47039. *
  47040. * Static Functions
  47041. *
  47042. * */
  47043. /**
  47044. * @private
  47045. */
  47046. NavigatorAxis.compose = function (AxisClass) {
  47047. AxisClass.keepProps.push('navigatorAxis');
  47048. /* eslint-disable no-invalid-this */
  47049. addEvent(AxisClass, 'init', function () {
  47050. var axis = this;
  47051. if (!axis.navigatorAxis) {
  47052. axis.navigatorAxis = new NavigatorAxisAdditions(axis);
  47053. }
  47054. });
  47055. // For Stock charts, override selection zooming with some special
  47056. // features because X axis zooming is already allowed by the Navigator
  47057. // and Range selector.
  47058. addEvent(AxisClass, 'zoom', function (e) {
  47059. var axis = this;
  47060. var chart = axis.chart;
  47061. var chartOptions = chart.options;
  47062. var navigator = chartOptions.navigator;
  47063. var navigatorAxis = axis.navigatorAxis;
  47064. var pinchType = chartOptions.chart.pinchType;
  47065. var rangeSelector = chartOptions.rangeSelector;
  47066. var zoomType = chartOptions.chart.zoomType;
  47067. var previousZoom;
  47068. if (axis.isXAxis && ((navigator && navigator.enabled) ||
  47069. (rangeSelector && rangeSelector.enabled))) {
  47070. // For y only zooming, ignore the X axis completely
  47071. if (zoomType === 'y') {
  47072. e.zoomed = false;
  47073. // For xy zooming, record the state of the zoom before zoom
  47074. // selection, then when the reset button is pressed, revert to
  47075. // this state. This should apply only if the chart is
  47076. // initialized with a range (#6612), otherwise zoom all the way
  47077. // out.
  47078. }
  47079. else if (((!isTouchDevice && zoomType === 'xy') ||
  47080. (isTouchDevice && pinchType === 'xy')) &&
  47081. axis.options.range) {
  47082. previousZoom = navigatorAxis.previousZoom;
  47083. if (defined(e.newMin)) {
  47084. navigatorAxis.previousZoom = [axis.min, axis.max];
  47085. }
  47086. else if (previousZoom) {
  47087. e.newMin = previousZoom[0];
  47088. e.newMax = previousZoom[1];
  47089. navigatorAxis.previousZoom = void 0;
  47090. }
  47091. }
  47092. }
  47093. if (typeof e.zoomed !== 'undefined') {
  47094. e.preventDefault();
  47095. }
  47096. });
  47097. /* eslint-enable no-invalid-this */
  47098. };
  47099. /* *
  47100. *
  47101. * Static Properties
  47102. *
  47103. * */
  47104. /**
  47105. * @private
  47106. */
  47107. NavigatorAxis.AdditionsClass = NavigatorAxisAdditions;
  47108. return NavigatorAxis;
  47109. }());
  47110. return NavigatorAxis;
  47111. });
  47112. _registerModule(_modules, 'Core/Axis/ScrollbarAxis.js', [_modules['Core/Utilities.js']], function (U) {
  47113. /* *
  47114. *
  47115. * (c) 2010-2021 Torstein Honsi
  47116. *
  47117. * License: www.highcharts.com/license
  47118. *
  47119. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  47120. *
  47121. * */
  47122. var addEvent = U.addEvent,
  47123. defined = U.defined,
  47124. pick = U.pick;
  47125. /* *
  47126. *
  47127. * Composition
  47128. *
  47129. * */
  47130. /* eslint-disable no-invalid-this, valid-jsdoc */
  47131. /**
  47132. * Creates scrollbars if enabled.
  47133. * @private
  47134. */
  47135. var ScrollbarAxis = /** @class */ (function () {
  47136. function ScrollbarAxis() {
  47137. }
  47138. /**
  47139. * Attaches to axis events to create scrollbars if enabled.
  47140. *
  47141. * @private
  47142. *
  47143. * @param AxisClass
  47144. * Axis class to extend.
  47145. *
  47146. * @param ScrollbarClass
  47147. * Scrollbar class to use.
  47148. */
  47149. ScrollbarAxis.compose = function (AxisClass, ScrollbarClass) {
  47150. var getExtremes = function (axis) {
  47151. var axisMin = pick(axis.options && axis.options.min, axis.min);
  47152. var axisMax = pick(axis.options && axis.options.max,
  47153. axis.max);
  47154. return {
  47155. axisMin: axisMin,
  47156. axisMax: axisMax,
  47157. scrollMin: defined(axis.dataMin) ?
  47158. Math.min(axisMin, axis.min, axis.dataMin, pick(axis.threshold, Infinity)) : axisMin,
  47159. scrollMax: defined(axis.dataMax) ?
  47160. Math.max(axisMax, axis.max, axis.dataMax, pick(axis.threshold, -Infinity)) : axisMax
  47161. };
  47162. };
  47163. // Wrap axis initialization and create scrollbar if enabled:
  47164. addEvent(AxisClass, 'afterInit', function () {
  47165. var axis = this;
  47166. if (axis.options &&
  47167. axis.options.scrollbar &&
  47168. axis.options.scrollbar.enabled) {
  47169. // Predefined options:
  47170. axis.options.scrollbar.vertical = !axis.horiz;
  47171. axis.options.startOnTick = axis.options.endOnTick = false;
  47172. axis.scrollbar = new ScrollbarClass(axis.chart.renderer, axis.options.scrollbar, axis.chart);
  47173. addEvent(axis.scrollbar, 'changed', function (e) {
  47174. var _a = getExtremes(axis),
  47175. axisMin = _a.axisMin,
  47176. axisMax = _a.axisMax,
  47177. unitedMin = _a.scrollMin,
  47178. unitedMax = _a.scrollMax,
  47179. range = unitedMax - unitedMin,
  47180. to,
  47181. from;
  47182. // #12834, scroll when show/hide series, wrong extremes
  47183. if (!defined(axisMin) || !defined(axisMax)) {
  47184. return;
  47185. }
  47186. if ((axis.horiz && !axis.reversed) ||
  47187. (!axis.horiz && axis.reversed)) {
  47188. to = unitedMin + range * this.to;
  47189. from = unitedMin + range * this.from;
  47190. }
  47191. else {
  47192. // y-values in browser are reversed, but this also
  47193. // applies for reversed horizontal axis:
  47194. to = unitedMin + range * (1 - this.from);
  47195. from = unitedMin + range * (1 - this.to);
  47196. }
  47197. if (this.shouldUpdateExtremes(e.DOMType)) {
  47198. axis.setExtremes(from, to, true, e.DOMType !== 'mousemove' && e.DOMType !== 'touchmove', e);
  47199. }
  47200. else {
  47201. // When live redraw is disabled, don't change extremes
  47202. // Only change the position of the scollbar thumb
  47203. this.setRange(this.from, this.to);
  47204. }
  47205. });
  47206. }
  47207. });
  47208. // Wrap rendering axis, and update scrollbar if one is created:
  47209. addEvent(AxisClass, 'afterRender', function () {
  47210. var axis = this,
  47211. _a = getExtremes(axis),
  47212. scrollMin = _a.scrollMin,
  47213. scrollMax = _a.scrollMax,
  47214. scrollbar = axis.scrollbar,
  47215. offset = axis.axisTitleMargin + (axis.titleOffset || 0),
  47216. scrollbarsOffsets = axis.chart.scrollbarsOffsets,
  47217. axisMargin = axis.options.margin || 0,
  47218. offsetsIndex,
  47219. from,
  47220. to;
  47221. if (scrollbar) {
  47222. if (axis.horiz) {
  47223. // Reserve space for labels/title
  47224. if (!axis.opposite) {
  47225. scrollbarsOffsets[1] += offset;
  47226. }
  47227. scrollbar.position(axis.left, axis.top + axis.height + 2 + scrollbarsOffsets[1] -
  47228. (axis.opposite ? axisMargin : 0), axis.width, axis.height);
  47229. // Next scrollbar should reserve space for margin (if set)
  47230. if (!axis.opposite) {
  47231. scrollbarsOffsets[1] += axisMargin;
  47232. }
  47233. offsetsIndex = 1;
  47234. }
  47235. else {
  47236. // Reserve space for labels/title
  47237. if (axis.opposite) {
  47238. scrollbarsOffsets[0] += offset;
  47239. }
  47240. scrollbar.position(axis.left + axis.width + 2 + scrollbarsOffsets[0] -
  47241. (axis.opposite ? 0 : axisMargin), axis.top, axis.width, axis.height);
  47242. // Next scrollbar should reserve space for margin (if set)
  47243. if (axis.opposite) {
  47244. scrollbarsOffsets[0] += axisMargin;
  47245. }
  47246. offsetsIndex = 0;
  47247. }
  47248. scrollbarsOffsets[offsetsIndex] += scrollbar.size +
  47249. scrollbar.options.margin;
  47250. if (isNaN(scrollMin) ||
  47251. isNaN(scrollMax) ||
  47252. !defined(axis.min) ||
  47253. !defined(axis.max) ||
  47254. axis.min === axis.max // #10733
  47255. ) {
  47256. // default action: when extremes are the same or there is
  47257. // not extremes on the axis, but scrollbar exists, make it
  47258. // full size
  47259. scrollbar.setRange(0, 1);
  47260. }
  47261. else {
  47262. from =
  47263. (axis.min - scrollMin) / (scrollMax - scrollMin);
  47264. to =
  47265. (axis.max - scrollMin) / (scrollMax - scrollMin);
  47266. if ((axis.horiz && !axis.reversed) ||
  47267. (!axis.horiz && axis.reversed)) {
  47268. scrollbar.setRange(from, to);
  47269. }
  47270. else {
  47271. // inverse vertical axis
  47272. scrollbar.setRange(1 - to, 1 - from);
  47273. }
  47274. }
  47275. }
  47276. });
  47277. // Make space for a scrollbar:
  47278. addEvent(AxisClass, 'afterGetOffset', function () {
  47279. var axis = this,
  47280. index = axis.horiz ? 2 : 1,
  47281. scrollbar = axis.scrollbar;
  47282. if (scrollbar) {
  47283. axis.chart.scrollbarsOffsets = [0, 0]; // reset scrollbars offsets
  47284. axis.chart.axisOffset[index] +=
  47285. scrollbar.size + scrollbar.options.margin;
  47286. }
  47287. });
  47288. return AxisClass;
  47289. };
  47290. return ScrollbarAxis;
  47291. }());
  47292. return ScrollbarAxis;
  47293. });
  47294. _registerModule(_modules, 'Core/ScrollbarDefaults.js', [_modules['Core/Globals.js'], _modules['Core/Color/Palette.js']], function (H, Palette) {
  47295. /* *
  47296. *
  47297. * (c) 2010-2021 Torstein Honsi
  47298. *
  47299. * License: www.highcharts.com/license
  47300. *
  47301. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  47302. *
  47303. * */
  47304. var isTouchDevice = H.isTouchDevice;
  47305. /* *
  47306. *
  47307. * Constant
  47308. *
  47309. * */
  47310. /**
  47311. *
  47312. * The scrollbar is a means of panning over the X axis of a stock chart.
  47313. * Scrollbars can also be applied to other types of axes.
  47314. *
  47315. * Another approach to scrollable charts is the [chart.scrollablePlotArea](
  47316. * https://api.highcharts.com/highcharts/chart.scrollablePlotArea) option that
  47317. * is especially suitable for simpler cartesian charts on mobile.
  47318. *
  47319. * In styled mode, all the presentational options for the
  47320. * scrollbar are replaced by the classes `.highcharts-scrollbar-thumb`,
  47321. * `.highcharts-scrollbar-arrow`, `.highcharts-scrollbar-button`,
  47322. * `.highcharts-scrollbar-rifles` and `.highcharts-scrollbar-track`.
  47323. *
  47324. * @sample stock/yaxis/inverted-bar-scrollbar/
  47325. * A scrollbar on a simple bar chart
  47326. *
  47327. * @product highstock gantt
  47328. * @optionparent scrollbar
  47329. *
  47330. * @private
  47331. */
  47332. var ScrollbarDefaults = {
  47333. /**
  47334. * The height of the scrollbar. The height also applies to the width
  47335. * of the scroll arrows so that they are always squares. Defaults to
  47336. * 20 for touch devices and 14 for mouse devices.
  47337. *
  47338. * @sample stock/scrollbar/height/
  47339. * A 30px scrollbar
  47340. *
  47341. * @type {number}
  47342. * @default 20/14
  47343. */
  47344. height: isTouchDevice ? 20 : 14,
  47345. /**
  47346. * The border rounding radius of the bar.
  47347. *
  47348. * @sample stock/scrollbar/style/
  47349. * Scrollbar styling
  47350. */
  47351. barBorderRadius: 0,
  47352. /**
  47353. * The corner radius of the scrollbar buttons.
  47354. *
  47355. * @sample stock/scrollbar/style/
  47356. * Scrollbar styling
  47357. */
  47358. buttonBorderRadius: 0,
  47359. /**
  47360. * Enable or disable the scrollbar.
  47361. *
  47362. * @sample stock/scrollbar/enabled/
  47363. * Disable the scrollbar,
  47364. only use navigator
  47365. *
  47366. * @type {boolean}
  47367. * @default true
  47368. * @apioption scrollbar.enabled
  47369. */
  47370. /**
  47371. * Whether to redraw the main chart as the scrollbar or the navigator
  47372. * zoomed window is moved. Defaults to `true` for modern browsers and
  47373. * `false` for legacy IE browsers as well as mobile devices.
  47374. *
  47375. * @sample stock/scrollbar/liveredraw
  47376. * Setting live redraw to false
  47377. *
  47378. * @type {boolean}
  47379. * @since 1.3
  47380. */
  47381. liveRedraw: void 0,
  47382. /**
  47383. * The margin between the scrollbar and its axis when the scrollbar is
  47384. * applied directly to an axis.
  47385. */
  47386. margin: 10,
  47387. /**
  47388. * The minimum width of the scrollbar.
  47389. *
  47390. * @since 1.2.5
  47391. */
  47392. minWidth: 6,
  47393. /**
  47394. * Whether to show or hide the scrollbar when the scrolled content is
  47395. * zoomed out to it full extent.
  47396. *
  47397. * @type {boolean}
  47398. * @default true
  47399. * @apioption scrollbar.showFull
  47400. */
  47401. step: 0.2,
  47402. /**
  47403. * The z index of the scrollbar group.
  47404. */
  47405. zIndex: 3,
  47406. /**
  47407. * The background color of the scrollbar itself.
  47408. *
  47409. * @sample stock/scrollbar/style/
  47410. * Scrollbar styling
  47411. *
  47412. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  47413. */
  47414. barBackgroundColor: Palette.neutralColor20,
  47415. /**
  47416. * The width of the bar's border.
  47417. *
  47418. * @sample stock/scrollbar/style/
  47419. * Scrollbar styling
  47420. */
  47421. barBorderWidth: 1,
  47422. /**
  47423. * The color of the scrollbar's border.
  47424. *
  47425. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  47426. */
  47427. barBorderColor: Palette.neutralColor20,
  47428. /**
  47429. * The color of the small arrow inside the scrollbar buttons.
  47430. *
  47431. * @sample stock/scrollbar/style/
  47432. * Scrollbar styling
  47433. *
  47434. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  47435. */
  47436. buttonArrowColor: Palette.neutralColor80,
  47437. /**
  47438. * The color of scrollbar buttons.
  47439. *
  47440. * @sample stock/scrollbar/style/
  47441. * Scrollbar styling
  47442. *
  47443. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  47444. */
  47445. buttonBackgroundColor: Palette.neutralColor10,
  47446. /**
  47447. * The color of the border of the scrollbar buttons.
  47448. *
  47449. * @sample stock/scrollbar/style/
  47450. * Scrollbar styling
  47451. *
  47452. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  47453. */
  47454. buttonBorderColor: Palette.neutralColor20,
  47455. /**
  47456. * The border width of the scrollbar buttons.
  47457. *
  47458. * @sample stock/scrollbar/style/
  47459. * Scrollbar styling
  47460. */
  47461. buttonBorderWidth: 1,
  47462. /**
  47463. * The color of the small rifles in the middle of the scrollbar.
  47464. *
  47465. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  47466. */
  47467. rifleColor: Palette.neutralColor80,
  47468. /**
  47469. * The color of the track background.
  47470. *
  47471. * @sample stock/scrollbar/style/
  47472. * Scrollbar styling
  47473. *
  47474. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  47475. */
  47476. trackBackgroundColor: Palette.neutralColor5,
  47477. /**
  47478. * The color of the border of the scrollbar track.
  47479. *
  47480. * @sample stock/scrollbar/style/
  47481. * Scrollbar styling
  47482. *
  47483. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  47484. */
  47485. trackBorderColor: Palette.neutralColor5,
  47486. /**
  47487. * The corner radius of the border of the scrollbar track.
  47488. *
  47489. * @sample stock/scrollbar/style/
  47490. * Scrollbar styling
  47491. *
  47492. * @type {number}
  47493. * @default 0
  47494. * @apioption scrollbar.trackBorderRadius
  47495. */
  47496. /**
  47497. * The width of the border of the scrollbar track.
  47498. *
  47499. * @sample stock/scrollbar/style/
  47500. * Scrollbar styling
  47501. */
  47502. trackBorderWidth: 1
  47503. };
  47504. /* *
  47505. *
  47506. * Default Export
  47507. *
  47508. * */
  47509. return ScrollbarDefaults;
  47510. });
  47511. _registerModule(_modules, 'Core/Scrollbar.js', [_modules['Core/DefaultOptions.js'], _modules['Core/Globals.js'], _modules['Core/Axis/ScrollbarAxis.js'], _modules['Core/ScrollbarDefaults.js'], _modules['Core/Utilities.js']], function (D, H, ScrollbarAxis, ScrollbarDefaults, U) {
  47512. /* *
  47513. *
  47514. * (c) 2010-2021 Torstein Honsi
  47515. *
  47516. * License: www.highcharts.com/license
  47517. *
  47518. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  47519. *
  47520. * */
  47521. var defaultOptions = D.defaultOptions;
  47522. var addEvent = U.addEvent,
  47523. correctFloat = U.correctFloat,
  47524. defined = U.defined,
  47525. destroyObjectProperties = U.destroyObjectProperties,
  47526. fireEvent = U.fireEvent,
  47527. merge = U.merge,
  47528. pick = U.pick,
  47529. removeEvent = U.removeEvent;
  47530. /* *
  47531. *
  47532. * Constants
  47533. *
  47534. * */
  47535. /* eslint-disable no-invalid-this, valid-jsdoc */
  47536. /**
  47537. * A reusable scrollbar, internally used in Highcharts Stock's
  47538. * navigator and optionally on individual axes.
  47539. *
  47540. * @private
  47541. * @class
  47542. * @name Highcharts.Scrollbar
  47543. * @param {Highcharts.SVGRenderer} renderer
  47544. * @param {Highcharts.ScrollbarOptions} options
  47545. * @param {Highcharts.Chart} chart
  47546. */
  47547. var Scrollbar = /** @class */ (function () {
  47548. /* *
  47549. *
  47550. * Constructors
  47551. *
  47552. * */
  47553. function Scrollbar(renderer, options, chart) {
  47554. /* *
  47555. *
  47556. * Properties
  47557. *
  47558. * */
  47559. this._events = [];
  47560. this.chart = void 0;
  47561. this.chartX = 0;
  47562. this.chartY = 0;
  47563. this.from = 0;
  47564. this.group = void 0;
  47565. this.options = void 0;
  47566. this.renderer = void 0;
  47567. this.scrollbar = void 0;
  47568. this.scrollbarButtons = [];
  47569. this.scrollbarGroup = void 0;
  47570. this.scrollbarLeft = 0;
  47571. this.scrollbarRifles = void 0;
  47572. this.scrollbarStrokeWidth = 1;
  47573. this.scrollbarTop = 0;
  47574. this.size = 0;
  47575. this.to = 0;
  47576. this.track = void 0;
  47577. this.trackBorderWidth = 1;
  47578. this.userOptions = void 0;
  47579. this.x = 0;
  47580. this.y = 0;
  47581. this.init(renderer, options, chart);
  47582. }
  47583. /* *
  47584. *
  47585. * Static Functions
  47586. *
  47587. * */
  47588. Scrollbar.compose = function (AxisClass) {
  47589. ScrollbarAxis.compose(AxisClass, Scrollbar);
  47590. };
  47591. /**
  47592. * When we have vertical scrollbar, rifles and arrow in buttons should be
  47593. * rotated. The same method is used in Navigator's handles, to rotate them.
  47594. *
  47595. * @function Highcharts.swapXY
  47596. *
  47597. * @param {Highcharts.SVGPathArray} path
  47598. * Path to be rotated.
  47599. *
  47600. * @param {boolean} [vertical]
  47601. * If vertical scrollbar, swap x-y values.
  47602. *
  47603. * @return {Highcharts.SVGPathArray}
  47604. * Rotated path.
  47605. *
  47606. * @requires modules/stock
  47607. */
  47608. Scrollbar.swapXY = function (path, vertical) {
  47609. if (vertical) {
  47610. path.forEach(function (seg) {
  47611. var len = seg.length;
  47612. var temp;
  47613. for (var i = 0; i < len; i += 2) {
  47614. temp = seg[i + 1];
  47615. if (typeof temp === 'number') {
  47616. seg[i + 1] = seg[i + 2];
  47617. seg[i + 2] = temp;
  47618. }
  47619. }
  47620. });
  47621. }
  47622. return path;
  47623. };
  47624. /* *
  47625. *
  47626. * Functions
  47627. *
  47628. * */
  47629. /**
  47630. * Set up the mouse and touch events for the Scrollbar
  47631. *
  47632. * @private
  47633. * @function Highcharts.Scrollbar#addEvents
  47634. */
  47635. Scrollbar.prototype.addEvents = function () {
  47636. var buttonsOrder = this.options.inverted ? [1, 0] : [0, 1],
  47637. buttons = this.scrollbarButtons,
  47638. bar = this.scrollbarGroup.element,
  47639. track = this.track.element,
  47640. mouseDownHandler = this.mouseDownHandler.bind(this),
  47641. mouseMoveHandler = this.mouseMoveHandler.bind(this),
  47642. mouseUpHandler = this.mouseUpHandler.bind(this);
  47643. // Mouse events
  47644. var _events = [
  47645. [buttons[buttonsOrder[0]].element, 'click',
  47646. this.buttonToMinClick.bind(this)],
  47647. [buttons[buttonsOrder[1]].element, 'click',
  47648. this.buttonToMaxClick.bind(this)],
  47649. [track, 'click',
  47650. this.trackClick.bind(this)],
  47651. [bar, 'mousedown',
  47652. mouseDownHandler],
  47653. [bar.ownerDocument, 'mousemove',
  47654. mouseMoveHandler],
  47655. [bar.ownerDocument, 'mouseup',
  47656. mouseUpHandler]
  47657. ];
  47658. // Touch events
  47659. if (H.hasTouch) {
  47660. _events.push([bar, 'touchstart', mouseDownHandler], [bar.ownerDocument, 'touchmove', mouseMoveHandler], [bar.ownerDocument, 'touchend', mouseUpHandler]);
  47661. }
  47662. // Add them all
  47663. _events.forEach(function (args) {
  47664. addEvent.apply(null, args);
  47665. });
  47666. this._events = _events;
  47667. };
  47668. Scrollbar.prototype.buttonToMaxClick = function (e) {
  47669. var scroller = this;
  47670. var range = (scroller.to - scroller.from) * pick(scroller.options.step, 0.2);
  47671. scroller.updatePosition(scroller.from + range, scroller.to + range);
  47672. fireEvent(scroller, 'changed', {
  47673. from: scroller.from,
  47674. to: scroller.to,
  47675. trigger: 'scrollbar',
  47676. DOMEvent: e
  47677. });
  47678. };
  47679. Scrollbar.prototype.buttonToMinClick = function (e) {
  47680. var scroller = this;
  47681. var range = correctFloat(scroller.to - scroller.from) *
  47682. pick(scroller.options.step, 0.2);
  47683. scroller.updatePosition(correctFloat(scroller.from - range), correctFloat(scroller.to - range));
  47684. fireEvent(scroller, 'changed', {
  47685. from: scroller.from,
  47686. to: scroller.to,
  47687. trigger: 'scrollbar',
  47688. DOMEvent: e
  47689. });
  47690. };
  47691. /**
  47692. * Get normalized (0-1) cursor position over the scrollbar
  47693. *
  47694. * @private
  47695. * @function Highcharts.Scrollbar#cursorToScrollbarPosition
  47696. *
  47697. * @param {*} normalizedEvent
  47698. * normalized event, with chartX and chartY values
  47699. *
  47700. * @return {Highcharts.Dictionary<number>}
  47701. * Local position {chartX, chartY}
  47702. */
  47703. Scrollbar.prototype.cursorToScrollbarPosition = function (normalizedEvent) {
  47704. var scroller = this,
  47705. options = scroller.options,
  47706. minWidthDifference = options.minWidth > scroller.calculatedWidth ?
  47707. options.minWidth :
  47708. 0; // minWidth distorts translation
  47709. return {
  47710. chartX: (normalizedEvent.chartX - scroller.x -
  47711. scroller.xOffset) /
  47712. (scroller.barWidth - minWidthDifference),
  47713. chartY: (normalizedEvent.chartY - scroller.y -
  47714. scroller.yOffset) /
  47715. (scroller.barWidth - minWidthDifference)
  47716. };
  47717. };
  47718. /**
  47719. * Destroys allocated elements.
  47720. *
  47721. * @private
  47722. * @function Highcharts.Scrollbar#destroy
  47723. * @return {void}
  47724. */
  47725. Scrollbar.prototype.destroy = function () {
  47726. var scroller = this,
  47727. navigator = scroller.chart.scroller;
  47728. // Disconnect events added in addEvents
  47729. scroller.removeEvents();
  47730. // Destroy properties
  47731. [
  47732. 'track',
  47733. 'scrollbarRifles',
  47734. 'scrollbar',
  47735. 'scrollbarGroup',
  47736. 'group'
  47737. ].forEach(function (prop) {
  47738. if (scroller[prop] && scroller[prop].destroy) {
  47739. scroller[prop] = scroller[prop].destroy();
  47740. }
  47741. });
  47742. // #6421, chart may have more scrollbars
  47743. if (navigator && scroller === navigator.scrollbar) {
  47744. navigator.scrollbar = null;
  47745. // Destroy elements in collection
  47746. destroyObjectProperties(navigator.scrollbarButtons);
  47747. }
  47748. };
  47749. /**
  47750. * Draw the scrollbar buttons with arrows
  47751. *
  47752. * @private
  47753. * @function Highcharts.Scrollbar#drawScrollbarButton
  47754. * @param {number} index
  47755. * 0 is left, 1 is right
  47756. * @return {void}
  47757. */
  47758. Scrollbar.prototype.drawScrollbarButton = function (index) {
  47759. var scroller = this,
  47760. renderer = scroller.renderer,
  47761. scrollbarButtons = scroller.scrollbarButtons,
  47762. options = scroller.options,
  47763. size = scroller.size,
  47764. group = renderer.g().add(scroller.group);
  47765. var tempElem;
  47766. scrollbarButtons.push(group);
  47767. // Create a rectangle for the scrollbar button
  47768. tempElem = renderer.rect()
  47769. .addClass('highcharts-scrollbar-button')
  47770. .add(group);
  47771. // Presentational attributes
  47772. if (!scroller.chart.styledMode) {
  47773. tempElem.attr({
  47774. stroke: options.buttonBorderColor,
  47775. 'stroke-width': options.buttonBorderWidth,
  47776. fill: options.buttonBackgroundColor
  47777. });
  47778. }
  47779. // Place the rectangle based on the rendered stroke width
  47780. tempElem.attr(tempElem.crisp({
  47781. x: -0.5,
  47782. y: -0.5,
  47783. width: size + 1,
  47784. height: size + 1,
  47785. r: options.buttonBorderRadius
  47786. }, tempElem.strokeWidth()));
  47787. // Button arrow
  47788. tempElem = renderer
  47789. .path(Scrollbar.swapXY([[
  47790. 'M',
  47791. size / 2 + (index ? -1 : 1),
  47792. size / 2 - 3
  47793. ], [
  47794. 'L',
  47795. size / 2 + (index ? -1 : 1),
  47796. size / 2 + 3
  47797. ], [
  47798. 'L',
  47799. size / 2 + (index ? 2 : -2),
  47800. size / 2
  47801. ]], options.vertical))
  47802. .addClass('highcharts-scrollbar-arrow')
  47803. .add(scrollbarButtons[index]);
  47804. if (!scroller.chart.styledMode) {
  47805. tempElem.attr({
  47806. fill: options.buttonArrowColor
  47807. });
  47808. }
  47809. };
  47810. /**
  47811. * @private
  47812. * @function Highcharts.Scrollbar#init
  47813. * @param {Highcharts.SVGRenderer} renderer
  47814. * @param {Highcharts.ScrollbarOptions} options
  47815. * @param {Highcharts.Chart} chart
  47816. */
  47817. Scrollbar.prototype.init = function (renderer, options, chart) {
  47818. var scroller = this;
  47819. scroller.scrollbarButtons = [];
  47820. scroller.renderer = renderer;
  47821. scroller.userOptions = options;
  47822. scroller.options = merge(ScrollbarDefaults, defaultOptions.scrollbar, options);
  47823. scroller.chart = chart;
  47824. // backward compatibility
  47825. scroller.size = pick(scroller.options.size, scroller.options.height);
  47826. // Init
  47827. if (options.enabled) {
  47828. scroller.render();
  47829. scroller.addEvents();
  47830. }
  47831. };
  47832. Scrollbar.prototype.mouseDownHandler = function (e) {
  47833. var scroller = this,
  47834. normalizedEvent = scroller.chart.pointer.normalize(e),
  47835. mousePosition = scroller.cursorToScrollbarPosition(normalizedEvent);
  47836. scroller.chartX = mousePosition.chartX;
  47837. scroller.chartY = mousePosition.chartY;
  47838. scroller.initPositions = [scroller.from, scroller.to];
  47839. scroller.grabbedCenter = true;
  47840. };
  47841. /**
  47842. * Event handler for the mouse move event.
  47843. * @private
  47844. */
  47845. Scrollbar.prototype.mouseMoveHandler = function (e) {
  47846. var scroller = this,
  47847. normalizedEvent = scroller.chart.pointer.normalize(e),
  47848. options = scroller.options,
  47849. direction = options.vertical ? 'chartY' : 'chartX',
  47850. initPositions = scroller.initPositions || [];
  47851. var scrollPosition,
  47852. chartPosition,
  47853. change;
  47854. // In iOS, a mousemove event with e.pageX === 0 is fired when
  47855. // holding the finger down in the center of the scrollbar. This
  47856. // should be ignored.
  47857. if (scroller.grabbedCenter &&
  47858. // #4696, scrollbar failed on Android
  47859. (!e.touches || e.touches[0][direction] !== 0)) {
  47860. chartPosition = scroller.cursorToScrollbarPosition(normalizedEvent)[direction];
  47861. scrollPosition = scroller[direction];
  47862. change = chartPosition - scrollPosition;
  47863. scroller.hasDragged = true;
  47864. scroller.updatePosition(initPositions[0] + change, initPositions[1] + change);
  47865. if (scroller.hasDragged) {
  47866. fireEvent(scroller, 'changed', {
  47867. from: scroller.from,
  47868. to: scroller.to,
  47869. trigger: 'scrollbar',
  47870. DOMType: e.type,
  47871. DOMEvent: e
  47872. });
  47873. }
  47874. }
  47875. };
  47876. /**
  47877. * Event handler for the mouse up event.
  47878. * @private
  47879. */
  47880. Scrollbar.prototype.mouseUpHandler = function (e) {
  47881. var scroller = this;
  47882. if (scroller.hasDragged) {
  47883. fireEvent(scroller, 'changed', {
  47884. from: scroller.from,
  47885. to: scroller.to,
  47886. trigger: 'scrollbar',
  47887. DOMType: e.type,
  47888. DOMEvent: e
  47889. });
  47890. }
  47891. scroller.grabbedCenter =
  47892. scroller.hasDragged =
  47893. scroller.chartX =
  47894. scroller.chartY = null;
  47895. };
  47896. /**
  47897. * Position the scrollbar, method called from a parent with defined
  47898. * dimensions.
  47899. *
  47900. * @private
  47901. * @function Highcharts.Scrollbar#position
  47902. * @param {number} x
  47903. * x-position on the chart
  47904. * @param {number} y
  47905. * y-position on the chart
  47906. * @param {number} width
  47907. * width of the scrollbar
  47908. * @param {number} height
  47909. * height of the scorllbar
  47910. * @return {void}
  47911. */
  47912. Scrollbar.prototype.position = function (x, y, width, height) {
  47913. var scroller = this,
  47914. options = scroller.options,
  47915. vertical = options.vertical,
  47916. method = scroller.rendered ? 'animate' : 'attr';
  47917. var xOffset = height,
  47918. yOffset = 0;
  47919. scroller.x = x;
  47920. scroller.y = y + this.trackBorderWidth;
  47921. scroller.width = width; // width with buttons
  47922. scroller.height = height;
  47923. scroller.xOffset = xOffset;
  47924. scroller.yOffset = yOffset;
  47925. // If Scrollbar is a vertical type, swap options:
  47926. if (vertical) {
  47927. scroller.width = scroller.yOffset = width = yOffset = scroller.size;
  47928. scroller.xOffset = xOffset = 0;
  47929. scroller.barWidth = height - width * 2; // width without buttons
  47930. scroller.x = x = x + scroller.options.margin;
  47931. }
  47932. else {
  47933. scroller.height = scroller.xOffset = height = xOffset =
  47934. scroller.size;
  47935. scroller.barWidth = width - height * 2; // width without buttons
  47936. scroller.y = scroller.y + scroller.options.margin;
  47937. }
  47938. // Set general position for a group:
  47939. scroller.group[method]({
  47940. translateX: x,
  47941. translateY: scroller.y
  47942. });
  47943. // Resize background/track:
  47944. scroller.track[method]({
  47945. width: width,
  47946. height: height
  47947. });
  47948. // Move right/bottom button ot it's place:
  47949. scroller.scrollbarButtons[1][method]({
  47950. translateX: vertical ? 0 : width - xOffset,
  47951. translateY: vertical ? height - yOffset : 0
  47952. });
  47953. };
  47954. /**
  47955. * Removes the event handlers attached previously with addEvents.
  47956. *
  47957. * @private
  47958. * @function Highcharts.Scrollbar#removeEvents
  47959. * @return {void}
  47960. */
  47961. Scrollbar.prototype.removeEvents = function () {
  47962. this._events.forEach(function (args) {
  47963. removeEvent.apply(null, args);
  47964. });
  47965. this._events.length = 0;
  47966. };
  47967. /**
  47968. * Render scrollbar with all required items.
  47969. *
  47970. * @private
  47971. * @function Highcharts.Scrollbar#render
  47972. */
  47973. Scrollbar.prototype.render = function () {
  47974. var scroller = this,
  47975. renderer = scroller.renderer,
  47976. options = scroller.options,
  47977. size = scroller.size,
  47978. styledMode = scroller.chart.styledMode,
  47979. group = renderer.g('scrollbar').attr({
  47980. zIndex: options.zIndex,
  47981. translateY: -99999
  47982. }).add();
  47983. // Draw the scrollbar group
  47984. scroller.group = group;
  47985. // Draw the scrollbar track:
  47986. scroller.track = renderer.rect()
  47987. .addClass('highcharts-scrollbar-track')
  47988. .attr({
  47989. x: 0,
  47990. r: options.trackBorderRadius || 0,
  47991. height: size,
  47992. width: size
  47993. }).add(group);
  47994. if (!styledMode) {
  47995. scroller.track.attr({
  47996. fill: options.trackBackgroundColor,
  47997. stroke: options.trackBorderColor,
  47998. 'stroke-width': options.trackBorderWidth
  47999. });
  48000. }
  48001. scroller.trackBorderWidth = scroller.track.strokeWidth();
  48002. scroller.track.attr({
  48003. y: -this.trackBorderWidth % 2 / 2
  48004. });
  48005. // Draw the scrollbar itself
  48006. scroller.scrollbarGroup = renderer.g().add(group);
  48007. scroller.scrollbar = renderer.rect()
  48008. .addClass('highcharts-scrollbar-thumb')
  48009. .attr({
  48010. height: size,
  48011. width: size,
  48012. r: options.barBorderRadius || 0
  48013. }).add(scroller.scrollbarGroup);
  48014. scroller.scrollbarRifles = renderer
  48015. .path(Scrollbar.swapXY([
  48016. ['M', -3, size / 4],
  48017. ['L', -3, 2 * size / 3],
  48018. ['M', 0, size / 4],
  48019. ['L', 0, 2 * size / 3],
  48020. ['M', 3, size / 4],
  48021. ['L', 3, 2 * size / 3]
  48022. ], options.vertical))
  48023. .addClass('highcharts-scrollbar-rifles')
  48024. .add(scroller.scrollbarGroup);
  48025. if (!styledMode) {
  48026. scroller.scrollbar.attr({
  48027. fill: options.barBackgroundColor,
  48028. stroke: options.barBorderColor,
  48029. 'stroke-width': options.barBorderWidth
  48030. });
  48031. scroller.scrollbarRifles.attr({
  48032. stroke: options.rifleColor,
  48033. 'stroke-width': 1
  48034. });
  48035. }
  48036. scroller.scrollbarStrokeWidth = scroller.scrollbar.strokeWidth();
  48037. scroller.scrollbarGroup.translate(-scroller.scrollbarStrokeWidth % 2 / 2, -scroller.scrollbarStrokeWidth % 2 / 2);
  48038. // Draw the buttons:
  48039. scroller.drawScrollbarButton(0);
  48040. scroller.drawScrollbarButton(1);
  48041. };
  48042. /**
  48043. * Set scrollbar size, with a given scale.
  48044. *
  48045. * @private
  48046. * @function Highcharts.Scrollbar#setRange
  48047. * @param {number} from
  48048. * scale (0-1) where bar should start
  48049. * @param {number} to
  48050. * scale (0-1) where bar should end
  48051. * @return {void}
  48052. */
  48053. Scrollbar.prototype.setRange = function (from, to) {
  48054. var scroller = this,
  48055. options = scroller.options,
  48056. vertical = options.vertical,
  48057. minWidth = options.minWidth,
  48058. fullWidth = scroller.barWidth,
  48059. method = (this.rendered &&
  48060. !this.hasDragged &&
  48061. !(this.chart.navigator && this.chart.navigator.hasDragged)) ? 'animate' : 'attr';
  48062. if (!defined(fullWidth)) {
  48063. return;
  48064. }
  48065. var toPX = fullWidth * Math.min(to, 1);
  48066. var fromPX,
  48067. newSize;
  48068. from = Math.max(from, 0);
  48069. fromPX = Math.ceil(fullWidth * from);
  48070. scroller.calculatedWidth = newSize = correctFloat(toPX - fromPX);
  48071. // We need to recalculate position, if minWidth is used
  48072. if (newSize < minWidth) {
  48073. fromPX = (fullWidth - minWidth + newSize) * from;
  48074. newSize = minWidth;
  48075. }
  48076. var newPos = Math.floor(fromPX + scroller.xOffset + scroller.yOffset);
  48077. var newRiflesPos = newSize / 2 - 0.5; // -0.5 -> rifle line width / 2
  48078. // Store current position:
  48079. scroller.from = from;
  48080. scroller.to = to;
  48081. if (!vertical) {
  48082. scroller.scrollbarGroup[method]({
  48083. translateX: newPos
  48084. });
  48085. scroller.scrollbar[method]({
  48086. width: newSize
  48087. });
  48088. scroller.scrollbarRifles[method]({
  48089. translateX: newRiflesPos
  48090. });
  48091. scroller.scrollbarLeft = newPos;
  48092. scroller.scrollbarTop = 0;
  48093. }
  48094. else {
  48095. scroller.scrollbarGroup[method]({
  48096. translateY: newPos
  48097. });
  48098. scroller.scrollbar[method]({
  48099. height: newSize
  48100. });
  48101. scroller.scrollbarRifles[method]({
  48102. translateY: newRiflesPos
  48103. });
  48104. scroller.scrollbarTop = newPos;
  48105. scroller.scrollbarLeft = 0;
  48106. }
  48107. if (newSize <= 12) {
  48108. scroller.scrollbarRifles.hide();
  48109. }
  48110. else {
  48111. scroller.scrollbarRifles.show(true);
  48112. }
  48113. // Show or hide the scrollbar based on the showFull setting
  48114. if (options.showFull === false) {
  48115. if (from <= 0 && to >= 1) {
  48116. scroller.group.hide();
  48117. }
  48118. else {
  48119. scroller.group.show();
  48120. }
  48121. }
  48122. scroller.rendered = true;
  48123. };
  48124. /**
  48125. * Checks if the extremes should be updated in response to a scrollbar
  48126. * change event.
  48127. *
  48128. * @private
  48129. * @function Highcharts.Scrollbar#shouldUpdateExtremes
  48130. * @param {string} [eventType]
  48131. * @return {boolean}
  48132. */
  48133. Scrollbar.prototype.shouldUpdateExtremes = function (eventType) {
  48134. return (pick(this.options.liveRedraw, H.svg && !H.isTouchDevice && !this.chart.isBoosting) ||
  48135. // Mouseup always should change extremes
  48136. eventType === 'mouseup' ||
  48137. eventType === 'touchend' ||
  48138. // Internal events
  48139. !defined(eventType));
  48140. };
  48141. Scrollbar.prototype.trackClick = function (e) {
  48142. var scroller = this;
  48143. var normalizedEvent = scroller.chart.pointer.normalize(e),
  48144. range = scroller.to - scroller.from,
  48145. top = scroller.y + scroller.scrollbarTop,
  48146. left = scroller.x + scroller.scrollbarLeft;
  48147. if ((scroller.options.vertical && normalizedEvent.chartY > top) ||
  48148. (!scroller.options.vertical && normalizedEvent.chartX > left)) {
  48149. // On the top or on the left side of the track:
  48150. scroller.updatePosition(scroller.from + range, scroller.to + range);
  48151. }
  48152. else {
  48153. // On the bottom or the right side of the track:
  48154. scroller.updatePosition(scroller.from - range, scroller.to - range);
  48155. }
  48156. fireEvent(scroller, 'changed', {
  48157. from: scroller.from,
  48158. to: scroller.to,
  48159. trigger: 'scrollbar',
  48160. DOMEvent: e
  48161. });
  48162. };
  48163. /**
  48164. * Update the scrollbar with new options
  48165. *
  48166. * @private
  48167. * @function Highcharts.Scrollbar#update
  48168. * @param {Highcharts.ScrollbarOptions} options
  48169. */
  48170. Scrollbar.prototype.update = function (options) {
  48171. this.destroy();
  48172. this.init(this.chart.renderer, merge(true, this.options, options), this.chart);
  48173. };
  48174. /**
  48175. * Update position option in the Scrollbar, with normalized 0-1 scale
  48176. *
  48177. * @private
  48178. * @function Highcharts.Scrollbar#updatePosition
  48179. * @param {number} from
  48180. * @param {number} to
  48181. * @return {void}
  48182. */
  48183. Scrollbar.prototype.updatePosition = function (from, to) {
  48184. if (to > 1) {
  48185. from = correctFloat(1 - correctFloat(to - from));
  48186. to = 1;
  48187. }
  48188. if (from < 0) {
  48189. to = correctFloat(to - from);
  48190. from = 0;
  48191. }
  48192. this.from = from;
  48193. this.to = to;
  48194. };
  48195. /* *
  48196. *
  48197. * Static Properties
  48198. *
  48199. * */
  48200. Scrollbar.defaultOptions = ScrollbarDefaults;
  48201. return Scrollbar;
  48202. }());
  48203. /* *
  48204. *
  48205. * Registry
  48206. *
  48207. * */
  48208. defaultOptions.scrollbar = merge(true, Scrollbar.defaultOptions, defaultOptions.scrollbar);
  48209. /* *
  48210. *
  48211. * Default Export
  48212. *
  48213. * */
  48214. return Scrollbar;
  48215. });
  48216. _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/DefaultOptions.js'], _modules['Core/Color/Palette.js'], _modules['Core/Renderer/RendererRegistry.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, D, Palette, RendererRegistry, Scrollbar, Series, SeriesRegistry, U) {
  48217. /* *
  48218. *
  48219. * (c) 2010-2021 Torstein Honsi
  48220. *
  48221. * License: www.highcharts.com/license
  48222. *
  48223. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  48224. *
  48225. * */
  48226. var color = Color.parse;
  48227. var hasTouch = H.hasTouch,
  48228. isTouchDevice = H.isTouchDevice;
  48229. var defaultOptions = D.defaultOptions;
  48230. var seriesTypes = SeriesRegistry.seriesTypes;
  48231. var addEvent = U.addEvent,
  48232. clamp = U.clamp,
  48233. correctFloat = U.correctFloat,
  48234. defined = U.defined,
  48235. destroyObjectProperties = U.destroyObjectProperties,
  48236. erase = U.erase,
  48237. extend = U.extend,
  48238. find = U.find,
  48239. isArray = U.isArray,
  48240. isNumber = U.isNumber,
  48241. merge = U.merge,
  48242. pick = U.pick,
  48243. removeEvent = U.removeEvent,
  48244. splat = U.splat;
  48245. var defaultSeriesType,
  48246. // Finding the min or max of a set of variables where we don't know if they
  48247. // are defined, is a pattern that is repeated several places in Highcharts.
  48248. // Consider making this a global utility method.
  48249. numExt = function (extreme) {
  48250. var args = [];
  48251. for (var _i = 1; _i < arguments.length; _i++) {
  48252. args[_i - 1] = arguments[_i];
  48253. }
  48254. var numbers = [].filter.call(args,
  48255. isNumber);
  48256. if (numbers.length) {
  48257. return Math[extreme].apply(0, numbers);
  48258. }
  48259. };
  48260. defaultSeriesType = typeof seriesTypes.areaspline === 'undefined' ?
  48261. 'line' :
  48262. 'areaspline';
  48263. extend(defaultOptions, {
  48264. /**
  48265. * Maximum range which can be set using the navigator's handles.
  48266. * Opposite of [xAxis.minRange](#xAxis.minRange).
  48267. *
  48268. * @sample {highstock} stock/navigator/maxrange/
  48269. * Defined max and min range
  48270. *
  48271. * @type {number}
  48272. * @since 6.0.0
  48273. * @product highstock gantt
  48274. * @apioption xAxis.maxRange
  48275. */
  48276. /**
  48277. * The navigator is a small series below the main series, displaying
  48278. * a view of the entire data set. It provides tools to zoom in and
  48279. * out on parts of the data as well as panning across the dataset.
  48280. *
  48281. * @product highstock gantt
  48282. * @optionparent navigator
  48283. */
  48284. navigator: {
  48285. /**
  48286. * Whether the navigator and scrollbar should adapt to updated data
  48287. * in the base X axis. When loading data async, as in the demo below,
  48288. * this should be `false`. Otherwise new data will trigger navigator
  48289. * redraw, which will cause unwanted looping. In the demo below, the
  48290. * data in the navigator is set only once. On navigating, only the main
  48291. * chart content is updated.
  48292. *
  48293. * @sample {highstock} stock/demo/lazy-loading/
  48294. * Set to false with async data loading
  48295. *
  48296. * @type {boolean}
  48297. * @default true
  48298. * @apioption navigator.adaptToUpdatedData
  48299. */
  48300. /**
  48301. * An integer identifying the index to use for the base series, or a
  48302. * string representing the id of the series.
  48303. *
  48304. * **Note**: As of Highcharts 5.0, this is now a deprecated option.
  48305. * Prefer [series.showInNavigator](#plotOptions.series.showInNavigator).
  48306. *
  48307. * @see [series.showInNavigator](#plotOptions.series.showInNavigator)
  48308. *
  48309. * @deprecated
  48310. * @type {number|string}
  48311. * @default 0
  48312. * @apioption navigator.baseSeries
  48313. */
  48314. /**
  48315. * Enable or disable the navigator.
  48316. *
  48317. * @sample {highstock} stock/navigator/enabled/
  48318. * Disable the navigator
  48319. *
  48320. * @type {boolean}
  48321. * @default true
  48322. * @apioption navigator.enabled
  48323. */
  48324. /**
  48325. * When the chart is inverted, whether to draw the navigator on the
  48326. * opposite side.
  48327. *
  48328. * @type {boolean}
  48329. * @default false
  48330. * @since 5.0.8
  48331. * @apioption navigator.opposite
  48332. */
  48333. /**
  48334. * The height of the navigator.
  48335. *
  48336. * @sample {highstock} stock/navigator/height/
  48337. * A higher navigator
  48338. */
  48339. height: 40,
  48340. /**
  48341. * The distance from the nearest element, the X axis or X axis labels.
  48342. *
  48343. * @sample {highstock} stock/navigator/margin/
  48344. * A margin of 2 draws the navigator closer to the X axis labels
  48345. */
  48346. margin: 25,
  48347. /**
  48348. * Whether the mask should be inside the range marking the zoomed
  48349. * range, or outside. In Highcharts Stock 1.x it was always `false`.
  48350. *
  48351. * @sample {highstock} stock/navigator/maskinside-false/
  48352. * False, mask outside
  48353. *
  48354. * @since 2.0
  48355. */
  48356. maskInside: true,
  48357. /**
  48358. * Options for the handles for dragging the zoomed area.
  48359. *
  48360. * @sample {highstock} stock/navigator/handles/
  48361. * Colored handles
  48362. */
  48363. handles: {
  48364. /**
  48365. * Width for handles.
  48366. *
  48367. * @sample {highstock} stock/navigator/styled-handles/
  48368. * Styled handles
  48369. *
  48370. * @since 6.0.0
  48371. */
  48372. width: 7,
  48373. /**
  48374. * Height for handles.
  48375. *
  48376. * @sample {highstock} stock/navigator/styled-handles/
  48377. * Styled handles
  48378. *
  48379. * @since 6.0.0
  48380. */
  48381. height: 15,
  48382. /**
  48383. * Array to define shapes of handles. 0-index for left, 1-index for
  48384. * right.
  48385. *
  48386. * Additionally, the URL to a graphic can be given on this form:
  48387. * `url(graphic.png)`. Note that for the image to be applied to
  48388. * exported charts, its URL needs to be accessible by the export
  48389. * server.
  48390. *
  48391. * Custom callbacks for symbol path generation can also be added to
  48392. * `Highcharts.SVGRenderer.prototype.symbols`. The callback is then
  48393. * used by its method name, as shown in the demo.
  48394. *
  48395. * @sample {highstock} stock/navigator/styled-handles/
  48396. * Styled handles
  48397. *
  48398. * @type {Array<string>}
  48399. * @default ["navigator-handle", "navigator-handle"]
  48400. * @since 6.0.0
  48401. */
  48402. symbols: ['navigator-handle', 'navigator-handle'],
  48403. /**
  48404. * Allows to enable/disable handles.
  48405. *
  48406. * @since 6.0.0
  48407. */
  48408. enabled: true,
  48409. /**
  48410. * The width for the handle border and the stripes inside.
  48411. *
  48412. * @sample {highstock} stock/navigator/styled-handles/
  48413. * Styled handles
  48414. *
  48415. * @since 6.0.0
  48416. * @apioption navigator.handles.lineWidth
  48417. */
  48418. lineWidth: 1,
  48419. /**
  48420. * The fill for the handle.
  48421. *
  48422. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  48423. */
  48424. backgroundColor: Palette.neutralColor5,
  48425. /**
  48426. * The stroke for the handle border and the stripes inside.
  48427. *
  48428. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  48429. */
  48430. borderColor: Palette.neutralColor40
  48431. },
  48432. /**
  48433. * The color of the mask covering the areas of the navigator series
  48434. * that are currently not visible in the main series. The default
  48435. * color is bluish with an opacity of 0.3 to see the series below.
  48436. *
  48437. * @see In styled mode, the mask is styled with the
  48438. * `.highcharts-navigator-mask` and
  48439. * `.highcharts-navigator-mask-inside` classes.
  48440. *
  48441. * @sample {highstock} stock/navigator/maskfill/
  48442. * Blue, semi transparent mask
  48443. *
  48444. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  48445. * @default rgba(102,133,194,0.3)
  48446. */
  48447. maskFill: color(Palette.highlightColor60).setOpacity(0.3).get(),
  48448. /**
  48449. * The color of the line marking the currently zoomed area in the
  48450. * navigator.
  48451. *
  48452. * @sample {highstock} stock/navigator/outline/
  48453. * 2px blue outline
  48454. *
  48455. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  48456. * @default #cccccc
  48457. */
  48458. outlineColor: Palette.neutralColor20,
  48459. /**
  48460. * The width of the line marking the currently zoomed area in the
  48461. * navigator.
  48462. *
  48463. * @see In styled mode, the outline stroke width is set with the
  48464. * `.highcharts-navigator-outline` class.
  48465. *
  48466. * @sample {highstock} stock/navigator/outline/
  48467. * 2px blue outline
  48468. *
  48469. * @type {number}
  48470. */
  48471. outlineWidth: 1,
  48472. /**
  48473. * Options for the navigator series. Available options are the same
  48474. * as any series, documented at [plotOptions](#plotOptions.series)
  48475. * and [series](#series).
  48476. *
  48477. * Unless data is explicitly defined on navigator.series, the data
  48478. * is borrowed from the first series in the chart.
  48479. *
  48480. * Default series options for the navigator series are:
  48481. * ```js
  48482. * series: {
  48483. * type: 'areaspline',
  48484. * fillOpacity: 0.05,
  48485. * dataGrouping: {
  48486. * smoothed: true
  48487. * },
  48488. * lineWidth: 1,
  48489. * marker: {
  48490. * enabled: false
  48491. * }
  48492. * }
  48493. * ```
  48494. *
  48495. * @see In styled mode, the navigator series is styled with the
  48496. * `.highcharts-navigator-series` class.
  48497. *
  48498. * @sample {highstock} stock/navigator/series-data/
  48499. * Using a separate data set for the navigator
  48500. * @sample {highstock} stock/navigator/series/
  48501. * A green navigator series
  48502. *
  48503. * @type {*|Array<*>|Highcharts.SeriesOptionsType|Array<Highcharts.SeriesOptionsType>}
  48504. */
  48505. series: {
  48506. /**
  48507. * The type of the navigator series.
  48508. *
  48509. * Heads up:
  48510. * In column-type navigator, zooming is limited to at least one
  48511. * point with its `pointRange`.
  48512. *
  48513. * @sample {highstock} stock/navigator/column/
  48514. * Column type navigator
  48515. *
  48516. * @type {string}
  48517. * @default {highstock} `areaspline` if defined, otherwise `line`
  48518. * @default {gantt} gantt
  48519. */
  48520. type: defaultSeriesType,
  48521. /**
  48522. * The fill opacity of the navigator series.
  48523. */
  48524. fillOpacity: 0.05,
  48525. /**
  48526. * The pixel line width of the navigator series.
  48527. */
  48528. lineWidth: 1,
  48529. /**
  48530. * @ignore-option
  48531. */
  48532. compare: null,
  48533. /**
  48534. * Unless data is explicitly defined, the data is borrowed from the
  48535. * first series in the chart.
  48536. *
  48537. * @type {Array<number|Array<number|string|null>|object|null>}
  48538. * @product highstock
  48539. * @apioption navigator.series.data
  48540. */
  48541. /**
  48542. * Data grouping options for the navigator series.
  48543. *
  48544. * @extends plotOptions.series.dataGrouping
  48545. */
  48546. dataGrouping: {
  48547. approximation: 'average',
  48548. enabled: true,
  48549. groupPixelWidth: 2,
  48550. // Replace smoothed property by anchors, #12455.
  48551. firstAnchor: 'firstPoint',
  48552. anchor: 'middle',
  48553. lastAnchor: 'lastPoint',
  48554. // Day and week differs from plotOptions.series.dataGrouping
  48555. units: [
  48556. ['millisecond', [1, 2, 5, 10, 20, 25, 50, 100, 200, 500]],
  48557. ['second', [1, 2, 5, 10, 15, 30]],
  48558. ['minute', [1, 2, 5, 10, 15, 30]],
  48559. ['hour', [1, 2, 3, 4, 6, 8, 12]],
  48560. ['day', [1, 2, 3, 4]],
  48561. ['week', [1, 2, 3]],
  48562. ['month', [1, 3, 6]],
  48563. ['year', null]
  48564. ]
  48565. },
  48566. /**
  48567. * Data label options for the navigator series. Data labels are
  48568. * disabled by default on the navigator series.
  48569. *
  48570. * @extends plotOptions.series.dataLabels
  48571. */
  48572. dataLabels: {
  48573. enabled: false,
  48574. zIndex: 2 // #1839
  48575. },
  48576. id: 'highcharts-navigator-series',
  48577. className: 'highcharts-navigator-series',
  48578. /**
  48579. * Sets the fill color of the navigator series.
  48580. *
  48581. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  48582. * @apioption navigator.series.color
  48583. */
  48584. /**
  48585. * Line color for the navigator series. Allows setting the color
  48586. * while disallowing the default candlestick setting.
  48587. *
  48588. * @type {Highcharts.ColorString|null}
  48589. */
  48590. lineColor: null,
  48591. marker: {
  48592. enabled: false
  48593. },
  48594. /**
  48595. * Since Highcharts Stock v8, default value is the same as default
  48596. * `pointRange` defined for a specific type (e.g. `null` for
  48597. * column type).
  48598. *
  48599. * In Highcharts Stock version < 8, defaults to 0.
  48600. *
  48601. * @extends plotOptions.series.pointRange
  48602. * @type {number|null}
  48603. * @apioption navigator.series.pointRange
  48604. */
  48605. /**
  48606. * The threshold option. Setting it to 0 will make the default
  48607. * navigator area series draw its area from the 0 value and up.
  48608. *
  48609. * @type {number|null}
  48610. */
  48611. threshold: null
  48612. },
  48613. /**
  48614. * Options for the navigator X axis. Default series options for the
  48615. * navigator xAxis are:
  48616. * ```js
  48617. * xAxis: {
  48618. * tickWidth: 0,
  48619. * lineWidth: 0,
  48620. * gridLineWidth: 1,
  48621. * tickPixelInterval: 200,
  48622. * labels: {
  48623. * align: 'left',
  48624. * style: {
  48625. * color: '#888'
  48626. * },
  48627. * x: 3,
  48628. * y: -4
  48629. * }
  48630. * }
  48631. * ```
  48632. *
  48633. * @extends xAxis
  48634. * @excluding linkedTo, maxZoom, minRange, opposite, range, scrollbar,
  48635. * showEmpty, maxRange
  48636. */
  48637. xAxis: {
  48638. /**
  48639. * Additional range on the right side of the xAxis. Works similar to
  48640. * xAxis.maxPadding, but value is set in milliseconds.
  48641. * Can be set for both, main xAxis and navigator's xAxis.
  48642. *
  48643. * @since 6.0.0
  48644. */
  48645. overscroll: 0,
  48646. className: 'highcharts-navigator-xaxis',
  48647. tickLength: 0,
  48648. lineWidth: 0,
  48649. gridLineColor: Palette.neutralColor10,
  48650. gridLineWidth: 1,
  48651. tickPixelInterval: 200,
  48652. labels: {
  48653. align: 'left',
  48654. /**
  48655. * @type {Highcharts.CSSObject}
  48656. */
  48657. style: {
  48658. /** @ignore */
  48659. color: Palette.neutralColor40
  48660. },
  48661. x: 3,
  48662. y: -4
  48663. },
  48664. crosshair: false
  48665. },
  48666. /**
  48667. * Options for the navigator Y axis. Default series options for the
  48668. * navigator yAxis are:
  48669. * ```js
  48670. * yAxis: {
  48671. * gridLineWidth: 0,
  48672. * startOnTick: false,
  48673. * endOnTick: false,
  48674. * minPadding: 0.1,
  48675. * maxPadding: 0.1,
  48676. * labels: {
  48677. * enabled: false
  48678. * },
  48679. * title: {
  48680. * text: null
  48681. * },
  48682. * tickWidth: 0
  48683. * }
  48684. * ```
  48685. *
  48686. * @extends yAxis
  48687. * @excluding height, linkedTo, maxZoom, minRange, ordinal, range,
  48688. * showEmpty, scrollbar, top, units, maxRange, minLength,
  48689. * maxLength, resize
  48690. */
  48691. yAxis: {
  48692. className: 'highcharts-navigator-yaxis',
  48693. gridLineWidth: 0,
  48694. startOnTick: false,
  48695. endOnTick: false,
  48696. minPadding: 0.1,
  48697. maxPadding: 0.1,
  48698. labels: {
  48699. enabled: false
  48700. },
  48701. crosshair: false,
  48702. title: {
  48703. text: null
  48704. },
  48705. tickLength: 0,
  48706. tickWidth: 0
  48707. }
  48708. }
  48709. });
  48710. /* eslint-disable no-invalid-this, valid-jsdoc */
  48711. /**
  48712. * Draw one of the handles on the side of the zoomed range in the navigator
  48713. *
  48714. * @private
  48715. * @function Highcharts.Renderer#symbols.navigator-handle
  48716. * @param {number} x
  48717. * @param {number} y
  48718. * @param {number} w
  48719. * @param {number} h
  48720. * @param {Highcharts.NavigatorHandlesOptions} options
  48721. * @return {Highcharts.SVGPathArray}
  48722. * Path to be used in a handle
  48723. */
  48724. RendererRegistry.getRendererType().prototype.symbols['navigator-handle'] = function (_x, _y, _w, _h, options) {
  48725. var halfWidth = (options && options.width || 0) / 2,
  48726. markerPosition = Math.round(halfWidth / 3) + 0.5,
  48727. height = options && options.height || 0;
  48728. return [
  48729. ['M', -halfWidth - 1, 0.5],
  48730. ['L', halfWidth, 0.5],
  48731. ['L', halfWidth, height + 0.5],
  48732. ['L', -halfWidth - 1, height + 0.5],
  48733. ['L', -halfWidth - 1, 0.5],
  48734. ['M', -markerPosition, 4],
  48735. ['L', -markerPosition, height - 3],
  48736. ['M', markerPosition - 1, 4],
  48737. ['L', markerPosition - 1, height - 3]
  48738. ];
  48739. };
  48740. /**
  48741. * The Navigator class
  48742. *
  48743. * @private
  48744. * @class
  48745. * @name Highcharts.Navigator
  48746. *
  48747. * @param {Highcharts.Chart} chart
  48748. * Chart object
  48749. */
  48750. var Navigator = /** @class */ (function () {
  48751. function Navigator(chart) {
  48752. this.baseSeries = void 0;
  48753. this.chart = void 0;
  48754. this.handles = void 0;
  48755. this.height = void 0;
  48756. this.left = void 0;
  48757. this.navigatorEnabled = void 0;
  48758. this.navigatorGroup = void 0;
  48759. this.navigatorOptions = void 0;
  48760. this.navigatorSeries = void 0;
  48761. this.navigatorSize = void 0;
  48762. this.opposite = void 0;
  48763. this.outline = void 0;
  48764. this.outlineHeight = void 0;
  48765. this.range = void 0;
  48766. this.rendered = void 0;
  48767. this.shades = void 0;
  48768. this.size = void 0;
  48769. this.top = void 0;
  48770. this.xAxis = void 0;
  48771. this.yAxis = void 0;
  48772. this.zoomedMax = void 0;
  48773. this.zoomedMin = void 0;
  48774. this.init(chart);
  48775. }
  48776. /**
  48777. * Draw one of the handles on the side of the zoomed range in the navigator
  48778. *
  48779. * @private
  48780. * @function Highcharts.Navigator#drawHandle
  48781. *
  48782. * @param {number} x
  48783. * The x center for the handle
  48784. *
  48785. * @param {number} index
  48786. * 0 for left and 1 for right
  48787. *
  48788. * @param {boolean|undefined} inverted
  48789. * flag for chart.inverted
  48790. *
  48791. * @param {string} verb
  48792. * use 'animate' or 'attr'
  48793. */
  48794. Navigator.prototype.drawHandle = function (x, index, inverted, verb) {
  48795. var navigator = this,
  48796. height = navigator.navigatorOptions.handles.height;
  48797. // Place it
  48798. navigator.handles[index][verb](inverted ? {
  48799. translateX: Math.round(navigator.left + navigator.height / 2),
  48800. translateY: Math.round(navigator.top + parseInt(x, 10) + 0.5 - height)
  48801. } : {
  48802. translateX: Math.round(navigator.left + parseInt(x, 10)),
  48803. translateY: Math.round(navigator.top + navigator.height / 2 - height / 2 - 1)
  48804. });
  48805. };
  48806. /**
  48807. * Render outline around the zoomed range
  48808. *
  48809. * @private
  48810. * @function Highcharts.Navigator#drawOutline
  48811. *
  48812. * @param {number} zoomedMin
  48813. * in pixels position where zoomed range starts
  48814. *
  48815. * @param {number} zoomedMax
  48816. * in pixels position where zoomed range ends
  48817. *
  48818. * @param {boolean|undefined} inverted
  48819. * flag if chart is inverted
  48820. *
  48821. * @param {string} verb
  48822. * use 'animate' or 'attr'
  48823. */
  48824. Navigator.prototype.drawOutline = function (zoomedMin, zoomedMax, inverted, verb) {
  48825. var navigator = this,
  48826. maskInside = navigator.navigatorOptions.maskInside,
  48827. outlineWidth = navigator.outline.strokeWidth(),
  48828. halfOutline = outlineWidth / 2,
  48829. outlineCorrection = (outlineWidth % 2) / 2, // #5800
  48830. outlineHeight = navigator.outlineHeight,
  48831. scrollbarHeight = navigator.scrollbarHeight || 0,
  48832. navigatorSize = navigator.size,
  48833. left = navigator.left - scrollbarHeight,
  48834. navigatorTop = navigator.top,
  48835. verticalMin,
  48836. path;
  48837. if (inverted) {
  48838. left -= halfOutline;
  48839. verticalMin = navigatorTop + zoomedMax + outlineCorrection;
  48840. zoomedMax = navigatorTop + zoomedMin + outlineCorrection;
  48841. path = [
  48842. ['M', left + outlineHeight, navigatorTop - scrollbarHeight - outlineCorrection],
  48843. ['L', left + outlineHeight, verticalMin],
  48844. ['L', left, verticalMin],
  48845. ['L', left, zoomedMax],
  48846. ['L', left + outlineHeight, zoomedMax],
  48847. ['L', left + outlineHeight, navigatorTop + navigatorSize + scrollbarHeight]
  48848. ];
  48849. if (maskInside) {
  48850. path.push(['M', left + outlineHeight, verticalMin - halfOutline], // upper left of zoomed range
  48851. ['L', left + outlineHeight, zoomedMax + halfOutline] // upper right of z.r.
  48852. );
  48853. }
  48854. }
  48855. else {
  48856. zoomedMin += left + scrollbarHeight - outlineCorrection;
  48857. zoomedMax += left + scrollbarHeight - outlineCorrection;
  48858. navigatorTop += halfOutline;
  48859. path = [
  48860. ['M', left, navigatorTop],
  48861. ['L', zoomedMin, navigatorTop],
  48862. ['L', zoomedMin, navigatorTop + outlineHeight],
  48863. ['L', zoomedMax, navigatorTop + outlineHeight],
  48864. ['L', zoomedMax, navigatorTop],
  48865. ['L', left + navigatorSize + scrollbarHeight * 2, navigatorTop] // right
  48866. ];
  48867. if (maskInside) {
  48868. path.push(['M', zoomedMin - halfOutline, navigatorTop], // upper left of zoomed range
  48869. ['L', zoomedMax + halfOutline, navigatorTop] // upper right of z.r.
  48870. );
  48871. }
  48872. }
  48873. navigator.outline[verb]({
  48874. d: path
  48875. });
  48876. };
  48877. /**
  48878. * Render outline around the zoomed range
  48879. *
  48880. * @private
  48881. * @function Highcharts.Navigator#drawMasks
  48882. *
  48883. * @param {number} zoomedMin
  48884. * in pixels position where zoomed range starts
  48885. *
  48886. * @param {number} zoomedMax
  48887. * in pixels position where zoomed range ends
  48888. *
  48889. * @param {boolean|undefined} inverted
  48890. * flag if chart is inverted
  48891. *
  48892. * @param {string} verb
  48893. * use 'animate' or 'attr'
  48894. */
  48895. Navigator.prototype.drawMasks = function (zoomedMin, zoomedMax, inverted, verb) {
  48896. var navigator = this,
  48897. left = navigator.left,
  48898. top = navigator.top,
  48899. navigatorHeight = navigator.height,
  48900. height,
  48901. width,
  48902. x,
  48903. y;
  48904. // Determine rectangle position & size
  48905. // According to (non)inverted position:
  48906. if (inverted) {
  48907. x = [left, left, left];
  48908. y = [top, top + zoomedMin, top + zoomedMax];
  48909. width = [navigatorHeight, navigatorHeight, navigatorHeight];
  48910. height = [
  48911. zoomedMin,
  48912. zoomedMax - zoomedMin,
  48913. navigator.size - zoomedMax
  48914. ];
  48915. }
  48916. else {
  48917. x = [left, left + zoomedMin, left + zoomedMax];
  48918. y = [top, top, top];
  48919. width = [
  48920. zoomedMin,
  48921. zoomedMax - zoomedMin,
  48922. navigator.size - zoomedMax
  48923. ];
  48924. height = [navigatorHeight, navigatorHeight, navigatorHeight];
  48925. }
  48926. navigator.shades.forEach(function (shade, i) {
  48927. shade[verb]({
  48928. x: x[i],
  48929. y: y[i],
  48930. width: width[i],
  48931. height: height[i]
  48932. });
  48933. });
  48934. };
  48935. /**
  48936. * Generate DOM elements for a navigator:
  48937. *
  48938. * - main navigator group
  48939. *
  48940. * - all shades
  48941. *
  48942. * - outline
  48943. *
  48944. * - handles
  48945. *
  48946. * @private
  48947. * @function Highcharts.Navigator#renderElements
  48948. */
  48949. Navigator.prototype.renderElements = function () {
  48950. var navigator = this,
  48951. navigatorOptions = navigator.navigatorOptions,
  48952. maskInside = navigatorOptions.maskInside,
  48953. chart = navigator.chart,
  48954. inverted = chart.inverted,
  48955. renderer = chart.renderer,
  48956. navigatorGroup,
  48957. mouseCursor = {
  48958. cursor: inverted ? 'ns-resize' : 'ew-resize'
  48959. };
  48960. // Create the main navigator group
  48961. navigator.navigatorGroup = navigatorGroup = renderer.g('navigator')
  48962. .attr({
  48963. zIndex: 8,
  48964. visibility: 'hidden'
  48965. })
  48966. .add();
  48967. // Create masks, each mask will get events and fill:
  48968. [
  48969. !maskInside,
  48970. maskInside,
  48971. !maskInside
  48972. ].forEach(function (hasMask, index) {
  48973. navigator.shades[index] = renderer.rect()
  48974. .addClass('highcharts-navigator-mask' +
  48975. (index === 1 ? '-inside' : '-outside'))
  48976. .add(navigatorGroup);
  48977. if (!chart.styledMode) {
  48978. navigator.shades[index]
  48979. .attr({
  48980. fill: hasMask ?
  48981. navigatorOptions.maskFill :
  48982. 'rgba(0,0,0,0)'
  48983. })
  48984. .css((index === 1) && mouseCursor);
  48985. }
  48986. });
  48987. // Create the outline:
  48988. navigator.outline = renderer.path()
  48989. .addClass('highcharts-navigator-outline')
  48990. .add(navigatorGroup);
  48991. if (!chart.styledMode) {
  48992. navigator.outline.attr({
  48993. 'stroke-width': navigatorOptions.outlineWidth,
  48994. stroke: navigatorOptions.outlineColor
  48995. });
  48996. }
  48997. // Create the handlers:
  48998. if (navigatorOptions.handles.enabled) {
  48999. [0, 1].forEach(function (index) {
  49000. navigatorOptions.handles.inverted = chart.inverted;
  49001. navigator.handles[index] = renderer.symbol(navigatorOptions.handles.symbols[index], -navigatorOptions.handles.width / 2 - 1, 0, navigatorOptions.handles.width, navigatorOptions.handles.height, navigatorOptions.handles);
  49002. // zIndex = 6 for right handle, 7 for left.
  49003. // Can't be 10, because of the tooltip in inverted chart #2908
  49004. navigator.handles[index].attr({ zIndex: 7 - index })
  49005. .addClass('highcharts-navigator-handle ' +
  49006. 'highcharts-navigator-handle-' +
  49007. ['left', 'right'][index]).add(navigatorGroup);
  49008. if (!chart.styledMode) {
  49009. var handlesOptions = navigatorOptions.handles;
  49010. navigator.handles[index]
  49011. .attr({
  49012. fill: handlesOptions.backgroundColor,
  49013. stroke: handlesOptions.borderColor,
  49014. 'stroke-width': handlesOptions.lineWidth
  49015. })
  49016. .css(mouseCursor);
  49017. }
  49018. });
  49019. }
  49020. };
  49021. /**
  49022. * Update navigator
  49023. *
  49024. * @private
  49025. * @function Highcharts.Navigator#update
  49026. *
  49027. * @param {Highcharts.NavigatorOptions} options
  49028. * Options to merge in when updating navigator
  49029. */
  49030. Navigator.prototype.update = function (options) {
  49031. // Remove references to old navigator series in base series
  49032. (this.series || []).forEach(function (series) {
  49033. if (series.baseSeries) {
  49034. delete series.baseSeries.navigatorSeries;
  49035. }
  49036. });
  49037. // Destroy and rebuild navigator
  49038. this.destroy();
  49039. var chartOptions = this.chart.options;
  49040. merge(true, chartOptions.navigator, this.options, options);
  49041. this.init(this.chart);
  49042. };
  49043. /**
  49044. * Render the navigator
  49045. *
  49046. * @private
  49047. * @function Highcharts.Navigator#render
  49048. * @param {number} min
  49049. * X axis value minimum
  49050. * @param {number} max
  49051. * X axis value maximum
  49052. * @param {number} [pxMin]
  49053. * Pixel value minimum
  49054. * @param {number} [pxMax]
  49055. * Pixel value maximum
  49056. * @return {void}
  49057. */
  49058. Navigator.prototype.render = function (min, max, pxMin, pxMax) {
  49059. var navigator = this,
  49060. chart = navigator.chart,
  49061. navigatorWidth,
  49062. scrollbarLeft,
  49063. scrollbarTop,
  49064. scrollbarHeight = navigator.scrollbarHeight,
  49065. navigatorSize,
  49066. xAxis = navigator.xAxis,
  49067. pointRange = xAxis.pointRange || 0,
  49068. scrollbarXAxis = xAxis.navigatorAxis.fake ? chart.xAxis[0] : xAxis,
  49069. navigatorEnabled = navigator.navigatorEnabled,
  49070. zoomedMin,
  49071. zoomedMax,
  49072. rendered = navigator.rendered,
  49073. inverted = chart.inverted,
  49074. verb,
  49075. newMin,
  49076. newMax,
  49077. currentRange,
  49078. minRange = chart.xAxis[0].minRange,
  49079. maxRange = chart.xAxis[0].options.maxRange;
  49080. // Don't redraw while moving the handles (#4703).
  49081. if (this.hasDragged && !defined(pxMin)) {
  49082. return;
  49083. }
  49084. min = correctFloat(min - pointRange / 2);
  49085. max = correctFloat(max + pointRange / 2);
  49086. // Don't render the navigator until we have data (#486, #4202, #5172).
  49087. if (!isNumber(min) || !isNumber(max)) {
  49088. // However, if navigator was already rendered, we may need to resize
  49089. // it. For example hidden series, but visible navigator (#6022).
  49090. if (rendered) {
  49091. pxMin = 0;
  49092. pxMax = pick(xAxis.width, scrollbarXAxis.width);
  49093. }
  49094. else {
  49095. return;
  49096. }
  49097. }
  49098. navigator.left = pick(xAxis.left,
  49099. // in case of scrollbar only, without navigator
  49100. chart.plotLeft + scrollbarHeight +
  49101. (inverted ? chart.plotWidth : 0));
  49102. navigator.size = zoomedMax = navigatorSize = pick(xAxis.len, (inverted ? chart.plotHeight : chart.plotWidth) -
  49103. 2 * scrollbarHeight);
  49104. if (inverted) {
  49105. navigatorWidth = scrollbarHeight;
  49106. }
  49107. else {
  49108. navigatorWidth = navigatorSize + 2 * scrollbarHeight;
  49109. }
  49110. // Get the pixel position of the handles
  49111. pxMin = pick(pxMin, xAxis.toPixels(min, true));
  49112. pxMax = pick(pxMax, xAxis.toPixels(max, true));
  49113. // Verify (#1851, #2238)
  49114. if (!isNumber(pxMin) || Math.abs(pxMin) === Infinity) {
  49115. pxMin = 0;
  49116. pxMax = navigatorWidth;
  49117. }
  49118. // Are we below the minRange? (#2618, #6191)
  49119. newMin = xAxis.toValue(pxMin, true);
  49120. newMax = xAxis.toValue(pxMax, true);
  49121. currentRange = Math.abs(correctFloat(newMax - newMin));
  49122. if (currentRange < minRange) {
  49123. if (this.grabbedLeft) {
  49124. pxMin = xAxis.toPixels(newMax - minRange - pointRange, true);
  49125. }
  49126. else if (this.grabbedRight) {
  49127. pxMax = xAxis.toPixels(newMin + minRange + pointRange, true);
  49128. }
  49129. }
  49130. else if (defined(maxRange) &&
  49131. correctFloat(currentRange - pointRange) > maxRange) {
  49132. if (this.grabbedLeft) {
  49133. pxMin = xAxis.toPixels(newMax - maxRange - pointRange, true);
  49134. }
  49135. else if (this.grabbedRight) {
  49136. pxMax = xAxis.toPixels(newMin + maxRange + pointRange, true);
  49137. }
  49138. }
  49139. // Handles are allowed to cross, but never exceed the plot area
  49140. navigator.zoomedMax = clamp(Math.max(pxMin, pxMax), 0, zoomedMax);
  49141. navigator.zoomedMin = clamp(navigator.fixedWidth ?
  49142. navigator.zoomedMax - navigator.fixedWidth :
  49143. Math.min(pxMin, pxMax), 0, zoomedMax);
  49144. navigator.range = navigator.zoomedMax - navigator.zoomedMin;
  49145. zoomedMax = Math.round(navigator.zoomedMax);
  49146. zoomedMin = Math.round(navigator.zoomedMin);
  49147. if (navigatorEnabled) {
  49148. navigator.navigatorGroup.attr({
  49149. visibility: 'visible'
  49150. });
  49151. // Place elements
  49152. verb = rendered && !navigator.hasDragged ? 'animate' : 'attr';
  49153. navigator.drawMasks(zoomedMin, zoomedMax, inverted, verb);
  49154. navigator.drawOutline(zoomedMin, zoomedMax, inverted, verb);
  49155. if (navigator.navigatorOptions.handles.enabled) {
  49156. navigator.drawHandle(zoomedMin, 0, inverted, verb);
  49157. navigator.drawHandle(zoomedMax, 1, inverted, verb);
  49158. }
  49159. }
  49160. if (navigator.scrollbar) {
  49161. if (inverted) {
  49162. scrollbarTop = navigator.top - scrollbarHeight;
  49163. scrollbarLeft = navigator.left - scrollbarHeight +
  49164. (navigatorEnabled || !scrollbarXAxis.opposite ? 0 :
  49165. // Multiple axes has offsets:
  49166. (scrollbarXAxis.titleOffset || 0) +
  49167. // Self margin from the axis.title
  49168. scrollbarXAxis.axisTitleMargin);
  49169. scrollbarHeight = navigatorSize + 2 * scrollbarHeight;
  49170. }
  49171. else {
  49172. scrollbarTop = navigator.top + (navigatorEnabled ?
  49173. navigator.height :
  49174. -scrollbarHeight);
  49175. scrollbarLeft = navigator.left - scrollbarHeight;
  49176. }
  49177. // Reposition scrollbar
  49178. navigator.scrollbar.position(scrollbarLeft, scrollbarTop, navigatorWidth, scrollbarHeight);
  49179. // Keep scale 0-1
  49180. navigator.scrollbar.setRange(
  49181. // Use real value, not rounded because range can be very small
  49182. // (#1716)
  49183. navigator.zoomedMin / (navigatorSize || 1), navigator.zoomedMax / (navigatorSize || 1));
  49184. }
  49185. navigator.rendered = true;
  49186. };
  49187. /**
  49188. * Set up the mouse and touch events for the navigator
  49189. *
  49190. * @private
  49191. * @function Highcharts.Navigator#addMouseEvents
  49192. */
  49193. Navigator.prototype.addMouseEvents = function () {
  49194. var navigator = this,
  49195. chart = navigator.chart,
  49196. container = chart.container,
  49197. eventsToUnbind = [],
  49198. mouseMoveHandler,
  49199. mouseUpHandler;
  49200. /**
  49201. * Create mouse events' handlers.
  49202. * Make them as separate functions to enable wrapping them:
  49203. */
  49204. navigator.mouseMoveHandler = mouseMoveHandler = function (e) {
  49205. navigator.onMouseMove(e);
  49206. };
  49207. navigator.mouseUpHandler = mouseUpHandler = function (e) {
  49208. navigator.onMouseUp(e);
  49209. };
  49210. // Add shades and handles mousedown events
  49211. eventsToUnbind = navigator.getPartsEvents('mousedown');
  49212. // Add mouse move and mouseup events. These are bind to doc/container,
  49213. // because Navigator.grabbedSomething flags are stored in mousedown
  49214. // events
  49215. eventsToUnbind.push(addEvent(chart.renderTo, 'mousemove', mouseMoveHandler), addEvent(container.ownerDocument, 'mouseup', mouseUpHandler));
  49216. // Touch events
  49217. if (hasTouch) {
  49218. eventsToUnbind.push(addEvent(chart.renderTo, 'touchmove', mouseMoveHandler), addEvent(container.ownerDocument, 'touchend', mouseUpHandler));
  49219. eventsToUnbind.concat(navigator.getPartsEvents('touchstart'));
  49220. }
  49221. navigator.eventsToUnbind = eventsToUnbind;
  49222. // Data events
  49223. if (navigator.series && navigator.series[0]) {
  49224. eventsToUnbind.push(addEvent(navigator.series[0].xAxis, 'foundExtremes', function () {
  49225. chart.navigator.modifyNavigatorAxisExtremes();
  49226. }));
  49227. }
  49228. };
  49229. /**
  49230. * Generate events for handles and masks
  49231. *
  49232. * @private
  49233. * @function Highcharts.Navigator#getPartsEvents
  49234. *
  49235. * @param {string} eventName
  49236. * Event name handler, 'mousedown' or 'touchstart'
  49237. *
  49238. * @return {Array<Function>}
  49239. * An array of functions to remove navigator functions from the
  49240. * events again.
  49241. */
  49242. Navigator.prototype.getPartsEvents = function (eventName) {
  49243. var navigator = this,
  49244. events = [];
  49245. ['shades', 'handles'].forEach(function (name) {
  49246. navigator[name].forEach(function (navigatorItem, index) {
  49247. events.push(addEvent(navigatorItem.element, eventName, function (e) {
  49248. navigator[name + 'Mousedown'](e, index);
  49249. }));
  49250. });
  49251. });
  49252. return events;
  49253. };
  49254. /**
  49255. * Mousedown on a shaded mask, either:
  49256. *
  49257. * - will be stored for future drag&drop
  49258. *
  49259. * - will directly shift to a new range
  49260. *
  49261. * @private
  49262. * @function Highcharts.Navigator#shadesMousedown
  49263. *
  49264. * @param {Highcharts.PointerEventObject} e
  49265. * Mouse event
  49266. *
  49267. * @param {number} index
  49268. * Index of a mask in Navigator.shades array
  49269. */
  49270. Navigator.prototype.shadesMousedown = function (e, index) {
  49271. e = this.chart.pointer.normalize(e);
  49272. var navigator = this,
  49273. chart = navigator.chart,
  49274. xAxis = navigator.xAxis,
  49275. zoomedMin = navigator.zoomedMin,
  49276. navigatorPosition = navigator.left,
  49277. navigatorSize = navigator.size,
  49278. range = navigator.range,
  49279. chartX = e.chartX,
  49280. fixedMax,
  49281. fixedMin,
  49282. ext,
  49283. left;
  49284. // For inverted chart, swap some options:
  49285. if (chart.inverted) {
  49286. chartX = e.chartY;
  49287. navigatorPosition = navigator.top;
  49288. }
  49289. if (index === 1) {
  49290. // Store information for drag&drop
  49291. navigator.grabbedCenter = chartX;
  49292. navigator.fixedWidth = range;
  49293. navigator.dragOffset = chartX - zoomedMin;
  49294. }
  49295. else {
  49296. // Shift the range by clicking on shaded areas
  49297. left = chartX - navigatorPosition - range / 2;
  49298. if (index === 0) {
  49299. left = Math.max(0, left);
  49300. }
  49301. else if (index === 2 && left + range >= navigatorSize) {
  49302. left = navigatorSize - range;
  49303. if (navigator.reversedExtremes) {
  49304. // #7713
  49305. left -= range;
  49306. fixedMin = navigator.getUnionExtremes().dataMin;
  49307. }
  49308. else {
  49309. // #2293, #3543
  49310. fixedMax = navigator.getUnionExtremes().dataMax;
  49311. }
  49312. }
  49313. if (left !== zoomedMin) { // it has actually moved
  49314. navigator.fixedWidth = range; // #1370
  49315. ext = xAxis.navigatorAxis.toFixedRange(left, left + range, fixedMin, fixedMax);
  49316. if (defined(ext.min)) { // #7411
  49317. chart.xAxis[0].setExtremes(Math.min(ext.min, ext.max), Math.max(ext.min, ext.max), true, null, // auto animation
  49318. { trigger: 'navigator' });
  49319. }
  49320. }
  49321. }
  49322. };
  49323. /**
  49324. * Mousedown on a handle mask.
  49325. * Will store necessary information for drag&drop.
  49326. *
  49327. * @private
  49328. * @function Highcharts.Navigator#handlesMousedown
  49329. * @param {Highcharts.PointerEventObject} e
  49330. * Mouse event
  49331. * @param {number} index
  49332. * Index of a handle in Navigator.handles array
  49333. * @return {void}
  49334. */
  49335. Navigator.prototype.handlesMousedown = function (e, index) {
  49336. e = this.chart.pointer.normalize(e);
  49337. var navigator = this,
  49338. chart = navigator.chart,
  49339. baseXAxis = chart.xAxis[0],
  49340. // For reversed axes, min and max are changed,
  49341. // so the other extreme should be stored
  49342. reverse = navigator.reversedExtremes;
  49343. if (index === 0) {
  49344. // Grab the left handle
  49345. navigator.grabbedLeft = true;
  49346. navigator.otherHandlePos = navigator.zoomedMax;
  49347. navigator.fixedExtreme = reverse ? baseXAxis.min : baseXAxis.max;
  49348. }
  49349. else {
  49350. // Grab the right handle
  49351. navigator.grabbedRight = true;
  49352. navigator.otherHandlePos = navigator.zoomedMin;
  49353. navigator.fixedExtreme = reverse ? baseXAxis.max : baseXAxis.min;
  49354. }
  49355. chart.fixedRange = null;
  49356. };
  49357. /**
  49358. * Mouse move event based on x/y mouse position.
  49359. *
  49360. * @private
  49361. * @function Highcharts.Navigator#onMouseMove
  49362. *
  49363. * @param {Highcharts.PointerEventObject} e
  49364. * Mouse event
  49365. */
  49366. Navigator.prototype.onMouseMove = function (e) {
  49367. var navigator = this,
  49368. chart = navigator.chart,
  49369. left = navigator.left,
  49370. navigatorSize = navigator.navigatorSize,
  49371. range = navigator.range,
  49372. dragOffset = navigator.dragOffset,
  49373. inverted = chart.inverted,
  49374. chartX;
  49375. // In iOS, a mousemove event with e.pageX === 0 is fired when holding
  49376. // the finger down in the center of the scrollbar. This should be
  49377. // ignored.
  49378. if (!e.touches || e.touches[0].pageX !== 0) { // #4696
  49379. e = chart.pointer.normalize(e);
  49380. chartX = e.chartX;
  49381. // Swap some options for inverted chart
  49382. if (inverted) {
  49383. left = navigator.top;
  49384. chartX = e.chartY;
  49385. }
  49386. // Drag left handle or top handle
  49387. if (navigator.grabbedLeft) {
  49388. navigator.hasDragged = true;
  49389. navigator.render(0, 0, chartX - left, navigator.otherHandlePos);
  49390. // Drag right handle or bottom handle
  49391. }
  49392. else if (navigator.grabbedRight) {
  49393. navigator.hasDragged = true;
  49394. navigator.render(0, 0, navigator.otherHandlePos, chartX - left);
  49395. // Drag scrollbar or open area in navigator
  49396. }
  49397. else if (navigator.grabbedCenter) {
  49398. navigator.hasDragged = true;
  49399. if (chartX < dragOffset) { // outside left
  49400. chartX = dragOffset;
  49401. // outside right
  49402. }
  49403. else if (chartX >
  49404. navigatorSize + dragOffset - range) {
  49405. chartX = navigatorSize + dragOffset - range;
  49406. }
  49407. navigator.render(0, 0, chartX - dragOffset, chartX - dragOffset + range);
  49408. }
  49409. if (navigator.hasDragged &&
  49410. navigator.scrollbar &&
  49411. pick(navigator.scrollbar.options.liveRedraw,
  49412. // By default, don't run live redraw on VML, on touch
  49413. // devices or if the chart is in boost.
  49414. H.svg && !isTouchDevice && !this.chart.isBoosting)) {
  49415. e.DOMType = e.type; // DOMType is for IE8
  49416. setTimeout(function () {
  49417. navigator.onMouseUp(e);
  49418. }, 0);
  49419. }
  49420. }
  49421. };
  49422. /**
  49423. * Mouse up event based on x/y mouse position.
  49424. *
  49425. * @private
  49426. * @function Highcharts.Navigator#onMouseUp
  49427. * @param {Highcharts.PointerEventObject} e
  49428. * Mouse event
  49429. * @return {void}
  49430. */
  49431. Navigator.prototype.onMouseUp = function (e) {
  49432. var navigator = this,
  49433. chart = navigator.chart,
  49434. xAxis = navigator.xAxis,
  49435. scrollbar = navigator.scrollbar,
  49436. DOMEvent = e.DOMEvent || e,
  49437. inverted = chart.inverted,
  49438. verb = navigator.rendered && !navigator.hasDragged ?
  49439. 'animate' : 'attr',
  49440. zoomedMax,
  49441. zoomedMin,
  49442. unionExtremes,
  49443. fixedMin,
  49444. fixedMax,
  49445. ext;
  49446. if (
  49447. // MouseUp is called for both, navigator and scrollbar (that order),
  49448. // which causes calling afterSetExtremes twice. Prevent first call
  49449. // by checking if scrollbar is going to set new extremes (#6334)
  49450. (navigator.hasDragged && (!scrollbar || !scrollbar.hasDragged)) ||
  49451. e.trigger === 'scrollbar') {
  49452. unionExtremes = navigator.getUnionExtremes();
  49453. // When dragging one handle, make sure the other one doesn't change
  49454. if (navigator.zoomedMin === navigator.otherHandlePos) {
  49455. fixedMin = navigator.fixedExtreme;
  49456. }
  49457. else if (navigator.zoomedMax === navigator.otherHandlePos) {
  49458. fixedMax = navigator.fixedExtreme;
  49459. }
  49460. // Snap to right edge (#4076)
  49461. if (navigator.zoomedMax === navigator.size) {
  49462. fixedMax = navigator.reversedExtremes ?
  49463. unionExtremes.dataMin :
  49464. unionExtremes.dataMax;
  49465. }
  49466. // Snap to left edge (#7576)
  49467. if (navigator.zoomedMin === 0) {
  49468. fixedMin = navigator.reversedExtremes ?
  49469. unionExtremes.dataMax :
  49470. unionExtremes.dataMin;
  49471. }
  49472. ext = xAxis.navigatorAxis.toFixedRange(navigator.zoomedMin, navigator.zoomedMax, fixedMin, fixedMax);
  49473. if (defined(ext.min)) {
  49474. chart.xAxis[0].setExtremes(Math.min(ext.min, ext.max), Math.max(ext.min, ext.max), true,
  49475. // Run animation when clicking buttons, scrollbar track etc,
  49476. // but not when dragging handles or scrollbar
  49477. navigator.hasDragged ? false : null, {
  49478. trigger: 'navigator',
  49479. triggerOp: 'navigator-drag',
  49480. DOMEvent: DOMEvent // #1838
  49481. });
  49482. }
  49483. }
  49484. if (e.DOMType !== 'mousemove' &&
  49485. e.DOMType !== 'touchmove') {
  49486. navigator.grabbedLeft = navigator.grabbedRight =
  49487. navigator.grabbedCenter = navigator.fixedWidth =
  49488. navigator.fixedExtreme = navigator.otherHandlePos =
  49489. navigator.hasDragged = navigator.dragOffset = null;
  49490. }
  49491. // Update position of navigator shades, outline and handles (#12573)
  49492. if (navigator.navigatorEnabled &&
  49493. isNumber(navigator.zoomedMin) &&
  49494. isNumber(navigator.zoomedMax)) {
  49495. zoomedMin = Math.round(navigator.zoomedMin);
  49496. zoomedMax = Math.round(navigator.zoomedMax);
  49497. if (navigator.shades) {
  49498. navigator.drawMasks(zoomedMin, zoomedMax, inverted, verb);
  49499. }
  49500. if (navigator.outline) {
  49501. navigator.drawOutline(zoomedMin, zoomedMax, inverted, verb);
  49502. }
  49503. if (navigator.navigatorOptions.handles.enabled &&
  49504. Object.keys(navigator.handles).length ===
  49505. navigator.handles.length) {
  49506. navigator.drawHandle(zoomedMin, 0, inverted, verb);
  49507. navigator.drawHandle(zoomedMax, 1, inverted, verb);
  49508. }
  49509. }
  49510. };
  49511. /**
  49512. * Removes the event handlers attached previously with addEvents.
  49513. *
  49514. * @private
  49515. * @function Highcharts.Navigator#removeEvents
  49516. * @return {void}
  49517. */
  49518. Navigator.prototype.removeEvents = function () {
  49519. if (this.eventsToUnbind) {
  49520. this.eventsToUnbind.forEach(function (unbind) {
  49521. unbind();
  49522. });
  49523. this.eventsToUnbind = void 0;
  49524. }
  49525. this.removeBaseSeriesEvents();
  49526. };
  49527. /**
  49528. * Remove data events.
  49529. *
  49530. * @private
  49531. * @function Highcharts.Navigator#removeBaseSeriesEvents
  49532. * @return {void}
  49533. */
  49534. Navigator.prototype.removeBaseSeriesEvents = function () {
  49535. var baseSeries = this.baseSeries || [];
  49536. if (this.navigatorEnabled && baseSeries[0]) {
  49537. if (this.navigatorOptions.adaptToUpdatedData !== false) {
  49538. baseSeries.forEach(function (series) {
  49539. removeEvent(series, 'updatedData', this.updatedDataHandler);
  49540. }, this);
  49541. }
  49542. // We only listen for extremes-events on the first baseSeries
  49543. if (baseSeries[0].xAxis) {
  49544. removeEvent(baseSeries[0].xAxis, 'foundExtremes', this.modifyBaseAxisExtremes);
  49545. }
  49546. }
  49547. };
  49548. /**
  49549. * Initialize the Navigator object
  49550. *
  49551. * @private
  49552. * @function Highcharts.Navigator#init
  49553. *
  49554. * @param {Highcharts.Chart} chart
  49555. */
  49556. Navigator.prototype.init = function (chart) {
  49557. var chartOptions = chart.options,
  49558. navigatorOptions = chartOptions.navigator,
  49559. navigatorEnabled = navigatorOptions.enabled,
  49560. scrollbarOptions = chartOptions.scrollbar,
  49561. scrollbarEnabled = scrollbarOptions.enabled,
  49562. height = navigatorEnabled ? navigatorOptions.height : 0,
  49563. scrollbarHeight = scrollbarEnabled ?
  49564. scrollbarOptions.height :
  49565. 0;
  49566. this.handles = [];
  49567. this.shades = [];
  49568. this.chart = chart;
  49569. this.setBaseSeries();
  49570. this.height = height;
  49571. this.scrollbarHeight = scrollbarHeight;
  49572. this.scrollbarEnabled = scrollbarEnabled;
  49573. this.navigatorEnabled = navigatorEnabled;
  49574. this.navigatorOptions = navigatorOptions;
  49575. this.scrollbarOptions = scrollbarOptions;
  49576. this.outlineHeight = height + scrollbarHeight;
  49577. this.opposite = pick(navigatorOptions.opposite, Boolean(!navigatorEnabled && chart.inverted)); // #6262
  49578. var navigator = this,
  49579. baseSeries = navigator.baseSeries,
  49580. xAxisIndex = chart.xAxis.length,
  49581. yAxisIndex = chart.yAxis.length,
  49582. baseXaxis = baseSeries && baseSeries[0] && baseSeries[0].xAxis ||
  49583. chart.xAxis[0] || { options: {} };
  49584. chart.isDirtyBox = true;
  49585. if (navigator.navigatorEnabled) {
  49586. // an x axis is required for scrollbar also
  49587. navigator.xAxis = new Axis(chart, merge({
  49588. // inherit base xAxis' break and ordinal options
  49589. breaks: baseXaxis.options.breaks,
  49590. ordinal: baseXaxis.options.ordinal
  49591. }, navigatorOptions.xAxis, {
  49592. id: 'navigator-x-axis',
  49593. yAxis: 'navigator-y-axis',
  49594. isX: true,
  49595. type: 'datetime',
  49596. index: xAxisIndex,
  49597. isInternal: true,
  49598. offset: 0,
  49599. keepOrdinalPadding: true,
  49600. startOnTick: false,
  49601. endOnTick: false,
  49602. minPadding: 0,
  49603. maxPadding: 0,
  49604. zoomEnabled: false
  49605. }, chart.inverted ? {
  49606. offsets: [scrollbarHeight, 0, -scrollbarHeight, 0],
  49607. width: height
  49608. } : {
  49609. offsets: [0, -scrollbarHeight, 0, scrollbarHeight],
  49610. height: height
  49611. }));
  49612. navigator.yAxis = new Axis(chart, merge(navigatorOptions.yAxis, {
  49613. id: 'navigator-y-axis',
  49614. alignTicks: false,
  49615. offset: 0,
  49616. index: yAxisIndex,
  49617. isInternal: true,
  49618. reversed: pick((navigatorOptions.yAxis && navigatorOptions.yAxis.reversed), (chart.yAxis[0] && chart.yAxis[0].reversed), false),
  49619. zoomEnabled: false
  49620. }, chart.inverted ? {
  49621. width: height
  49622. } : {
  49623. height: height
  49624. }));
  49625. // If we have a base series, initialize the navigator series
  49626. if (baseSeries || navigatorOptions.series.data) {
  49627. navigator.updateNavigatorSeries(false);
  49628. // If not, set up an event to listen for added series
  49629. }
  49630. else if (chart.series.length === 0) {
  49631. navigator.unbindRedraw = addEvent(chart, 'beforeRedraw', function () {
  49632. // We've got one, now add it as base
  49633. if (chart.series.length > 0 && !navigator.series) {
  49634. navigator.setBaseSeries();
  49635. navigator.unbindRedraw(); // reset
  49636. }
  49637. });
  49638. }
  49639. navigator.reversedExtremes = (chart.inverted && !navigator.xAxis.reversed) || (!chart.inverted && navigator.xAxis.reversed);
  49640. // Render items, so we can bind events to them:
  49641. navigator.renderElements();
  49642. // Add mouse events
  49643. navigator.addMouseEvents();
  49644. // in case of scrollbar only, fake an x axis to get translation
  49645. }
  49646. else {
  49647. navigator.xAxis = {
  49648. chart: chart,
  49649. navigatorAxis: {
  49650. fake: true
  49651. },
  49652. translate: function (value, reverse) {
  49653. 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;
  49654. return reverse ?
  49655. // from pixel to value
  49656. (value * valueRange / scrollTrackWidth) + min :
  49657. // from value to pixel
  49658. scrollTrackWidth * (value - min) / valueRange;
  49659. },
  49660. toPixels: function (value) {
  49661. return this.translate(value);
  49662. },
  49663. toValue: function (value) {
  49664. return this.translate(value, true);
  49665. }
  49666. };
  49667. navigator.xAxis.navigatorAxis.axis = navigator.xAxis;
  49668. navigator.xAxis.navigatorAxis.toFixedRange = (NavigatorAxis.AdditionsClass.prototype.toFixedRange.bind(navigator.xAxis.navigatorAxis));
  49669. }
  49670. // Initialize the scrollbar
  49671. if (chart.options.scrollbar.enabled) {
  49672. chart.scrollbar = navigator.scrollbar = new Scrollbar(chart.renderer, merge(chart.options.scrollbar, {
  49673. margin: navigator.navigatorEnabled ? 0 : 10,
  49674. vertical: chart.inverted
  49675. }), chart);
  49676. addEvent(navigator.scrollbar, 'changed', function (e) {
  49677. var range = navigator.size,
  49678. to = range * this.to,
  49679. from = range * this.from;
  49680. navigator.hasDragged = navigator.scrollbar.hasDragged;
  49681. navigator.render(0, 0, from, to);
  49682. if (this.shouldUpdateExtremes(e.DOMType)) {
  49683. setTimeout(function () {
  49684. navigator.onMouseUp(e);
  49685. });
  49686. }
  49687. });
  49688. }
  49689. // Add data events
  49690. navigator.addBaseSeriesEvents();
  49691. // Add redraw events
  49692. navigator.addChartEvents();
  49693. };
  49694. /**
  49695. * Get the union data extremes of the chart - the outer data extremes of the
  49696. * base X axis and the navigator axis.
  49697. *
  49698. * @private
  49699. * @function Highcharts.Navigator#getUnionExtremes
  49700. * @param {boolean} [returnFalseOnNoBaseSeries]
  49701. * as the param says.
  49702. * @return {Highcharts.Dictionary<(number|undefined)>|undefined}
  49703. */
  49704. Navigator.prototype.getUnionExtremes = function (returnFalseOnNoBaseSeries) {
  49705. var baseAxis = this.chart.xAxis[0],
  49706. navAxis = this.xAxis,
  49707. navAxisOptions = navAxis.options,
  49708. baseAxisOptions = baseAxis.options,
  49709. ret;
  49710. if (!returnFalseOnNoBaseSeries || baseAxis.dataMin !== null) {
  49711. ret = {
  49712. dataMin: pick(// #4053
  49713. navAxisOptions && navAxisOptions.min, numExt('min', baseAxisOptions.min, baseAxis.dataMin, navAxis.dataMin, navAxis.min)),
  49714. dataMax: pick(navAxisOptions && navAxisOptions.max, numExt('max', baseAxisOptions.max, baseAxis.dataMax, navAxis.dataMax, navAxis.max))
  49715. };
  49716. }
  49717. return ret;
  49718. };
  49719. /**
  49720. * Set the base series and update the navigator series from this. With a bit
  49721. * of modification we should be able to make this an API method to be called
  49722. * from the outside
  49723. *
  49724. * @private
  49725. * @function Highcharts.Navigator#setBaseSeries
  49726. * @param {Highcharts.SeriesOptionsType} [baseSeriesOptions]
  49727. * Additional series options for a navigator
  49728. * @param {boolean} [redraw]
  49729. * Whether to redraw after update.
  49730. * @return {void}
  49731. */
  49732. Navigator.prototype.setBaseSeries = function (baseSeriesOptions, redraw) {
  49733. var chart = this.chart,
  49734. baseSeries = this.baseSeries = [];
  49735. baseSeriesOptions = (baseSeriesOptions ||
  49736. chart.options && chart.options.navigator.baseSeries ||
  49737. (chart.series.length ?
  49738. // Find the first non-navigator series (#8430)
  49739. find(chart.series, function (s) {
  49740. return !s.options.isInternal;
  49741. }).index :
  49742. 0));
  49743. // Iterate through series and add the ones that should be shown in
  49744. // navigator.
  49745. (chart.series || []).forEach(function (series, i) {
  49746. if (
  49747. // Don't include existing nav series
  49748. !series.options.isInternal &&
  49749. (series.options.showInNavigator ||
  49750. (i === baseSeriesOptions ||
  49751. series.options.id === baseSeriesOptions) &&
  49752. series.options.showInNavigator !== false)) {
  49753. baseSeries.push(series);
  49754. }
  49755. });
  49756. // When run after render, this.xAxis already exists
  49757. if (this.xAxis && !this.xAxis.navigatorAxis.fake) {
  49758. this.updateNavigatorSeries(true, redraw);
  49759. }
  49760. };
  49761. /**
  49762. * Update series in the navigator from baseSeries, adding new if does not
  49763. * exist.
  49764. *
  49765. * @private
  49766. * @function Highcharts.Navigator.updateNavigatorSeries
  49767. * @param {boolean} addEvents
  49768. * @param {boolean} [redraw]
  49769. * @return {void}
  49770. */
  49771. Navigator.prototype.updateNavigatorSeries = function (addEvents, redraw) {
  49772. var navigator = this,
  49773. chart = navigator.chart,
  49774. baseSeries = navigator.baseSeries,
  49775. baseOptions,
  49776. mergedNavSeriesOptions,
  49777. chartNavigatorSeriesOptions = navigator.navigatorOptions.series,
  49778. baseNavigatorOptions,
  49779. navSeriesMixin = {
  49780. enableMouseTracking: false,
  49781. index: null,
  49782. linkedTo: null,
  49783. group: 'nav',
  49784. padXAxis: false,
  49785. xAxis: 'navigator-x-axis',
  49786. yAxis: 'navigator-y-axis',
  49787. showInLegend: false,
  49788. stacking: void 0,
  49789. isInternal: true,
  49790. states: {
  49791. inactive: {
  49792. opacity: 1
  49793. }
  49794. }
  49795. },
  49796. // Remove navigator series that are no longer in the baseSeries
  49797. navigatorSeries = navigator.series =
  49798. (navigator.series || []).filter(function (navSeries) {
  49799. var base = navSeries.baseSeries;
  49800. if (baseSeries.indexOf(base) < 0) { // Not in array
  49801. // If there is still a base series connected to this
  49802. // series, remove event handler and reference.
  49803. if (base) {
  49804. removeEvent(base, 'updatedData', navigator.updatedDataHandler);
  49805. delete base.navigatorSeries;
  49806. }
  49807. // Kill the nav series. It may already have been
  49808. // destroyed (#8715).
  49809. if (navSeries.chart) {
  49810. navSeries.destroy();
  49811. }
  49812. return false;
  49813. }
  49814. return true;
  49815. });
  49816. // Go through each base series and merge the options to create new
  49817. // series
  49818. if (baseSeries && baseSeries.length) {
  49819. baseSeries.forEach(function eachBaseSeries(base) {
  49820. var linkedNavSeries = base.navigatorSeries,
  49821. userNavOptions = extend(
  49822. // Grab color and visibility from base as default
  49823. {
  49824. color: base.color,
  49825. visible: base.visible
  49826. }, !isArray(chartNavigatorSeriesOptions) ?
  49827. chartNavigatorSeriesOptions :
  49828. defaultOptions.navigator.series);
  49829. // Don't update if the series exists in nav and we have disabled
  49830. // adaptToUpdatedData.
  49831. if (linkedNavSeries &&
  49832. navigator.navigatorOptions.adaptToUpdatedData === false) {
  49833. return;
  49834. }
  49835. navSeriesMixin.name = 'Navigator ' + baseSeries.length;
  49836. baseOptions = base.options || {};
  49837. baseNavigatorOptions = baseOptions.navigatorOptions || {};
  49838. // The dataLabels options are not merged correctly
  49839. // if the settings are an array, #13847.
  49840. userNavOptions.dataLabels = splat(userNavOptions.dataLabels);
  49841. mergedNavSeriesOptions = merge(baseOptions, navSeriesMixin, userNavOptions, baseNavigatorOptions);
  49842. // Once nav series type is resolved, pick correct pointRange
  49843. mergedNavSeriesOptions.pointRange = pick(
  49844. // Stricte set pointRange in options
  49845. userNavOptions.pointRange, baseNavigatorOptions.pointRange,
  49846. // Fallback to default values, e.g. `null` for column
  49847. defaultOptions.plotOptions[mergedNavSeriesOptions.type || 'line'].pointRange);
  49848. // Merge data separately. Do a slice to avoid mutating the
  49849. // navigator options from base series (#4923).
  49850. var navigatorSeriesData = baseNavigatorOptions.data || userNavOptions.data;
  49851. navigator.hasNavigatorData =
  49852. navigator.hasNavigatorData || !!navigatorSeriesData;
  49853. mergedNavSeriesOptions.data =
  49854. navigatorSeriesData ||
  49855. baseOptions.data && baseOptions.data.slice(0);
  49856. // Update or add the series
  49857. if (linkedNavSeries && linkedNavSeries.options) {
  49858. linkedNavSeries.update(mergedNavSeriesOptions, redraw);
  49859. }
  49860. else {
  49861. base.navigatorSeries = chart.initSeries(mergedNavSeriesOptions);
  49862. base.navigatorSeries.baseSeries = base; // Store ref
  49863. navigatorSeries.push(base.navigatorSeries);
  49864. }
  49865. });
  49866. }
  49867. // If user has defined data (and no base series) or explicitly defined
  49868. // navigator.series as an array, we create these series on top of any
  49869. // base series.
  49870. if (chartNavigatorSeriesOptions.data &&
  49871. !(baseSeries && baseSeries.length) ||
  49872. isArray(chartNavigatorSeriesOptions)) {
  49873. navigator.hasNavigatorData = false;
  49874. // Allow navigator.series to be an array
  49875. chartNavigatorSeriesOptions =
  49876. splat(chartNavigatorSeriesOptions);
  49877. chartNavigatorSeriesOptions.forEach(function (userSeriesOptions, i) {
  49878. navSeriesMixin.name =
  49879. 'Navigator ' + (navigatorSeries.length + 1);
  49880. mergedNavSeriesOptions = merge(defaultOptions.navigator.series, {
  49881. // Since we don't have a base series to pull color from,
  49882. // try to fake it by using color from series with same
  49883. // index. Otherwise pull from the colors array. We need
  49884. // an explicit color as otherwise updates will increment
  49885. // color counter and we'll get a new color for each
  49886. // update of the nav series.
  49887. color: chart.series[i] &&
  49888. !chart.series[i].options.isInternal &&
  49889. chart.series[i].color ||
  49890. chart.options.colors[i] ||
  49891. chart.options.colors[0]
  49892. }, navSeriesMixin, userSeriesOptions);
  49893. mergedNavSeriesOptions.data = userSeriesOptions.data;
  49894. if (mergedNavSeriesOptions.data) {
  49895. navigator.hasNavigatorData = true;
  49896. navigatorSeries.push(chart.initSeries(mergedNavSeriesOptions));
  49897. }
  49898. });
  49899. }
  49900. if (addEvents) {
  49901. this.addBaseSeriesEvents();
  49902. }
  49903. };
  49904. /**
  49905. * Add data events.
  49906. * For example when main series is updated we need to recalculate extremes
  49907. *
  49908. * @private
  49909. * @function Highcharts.Navigator#addBaseSeriesEvent
  49910. * @return {void}
  49911. */
  49912. Navigator.prototype.addBaseSeriesEvents = function () {
  49913. var navigator = this,
  49914. baseSeries = navigator.baseSeries || [];
  49915. // Bind modified extremes event to first base's xAxis only.
  49916. // In event of > 1 base-xAxes, the navigator will ignore those.
  49917. // Adding this multiple times to the same axis is no problem, as
  49918. // duplicates should be discarded by the browser.
  49919. if (baseSeries[0] && baseSeries[0].xAxis) {
  49920. baseSeries[0].eventsToUnbind.push(addEvent(baseSeries[0].xAxis, 'foundExtremes', this.modifyBaseAxisExtremes));
  49921. }
  49922. baseSeries.forEach(function (base) {
  49923. // Link base series show/hide to navigator series visibility
  49924. base.eventsToUnbind.push(addEvent(base, 'show', function () {
  49925. if (this.navigatorSeries) {
  49926. this.navigatorSeries.setVisible(true, false);
  49927. }
  49928. }));
  49929. base.eventsToUnbind.push(addEvent(base, 'hide', function () {
  49930. if (this.navigatorSeries) {
  49931. this.navigatorSeries.setVisible(false, false);
  49932. }
  49933. }));
  49934. // Respond to updated data in the base series, unless explicitily
  49935. // not adapting to data changes.
  49936. if (this.navigatorOptions.adaptToUpdatedData !== false) {
  49937. if (base.xAxis) {
  49938. base.eventsToUnbind.push(addEvent(base, 'updatedData', this.updatedDataHandler));
  49939. }
  49940. }
  49941. // Handle series removal
  49942. base.eventsToUnbind.push(addEvent(base, 'remove', function () {
  49943. if (this.navigatorSeries) {
  49944. erase(navigator.series, this.navigatorSeries);
  49945. if (defined(this.navigatorSeries.options)) {
  49946. this.navigatorSeries.remove(false);
  49947. }
  49948. delete this.navigatorSeries;
  49949. }
  49950. }));
  49951. }, this);
  49952. };
  49953. /**
  49954. * Get minimum from all base series connected to the navigator
  49955. * @private
  49956. * @param {number} currentSeriesMin
  49957. * Minium from the current series
  49958. * @return {number} Minimum from all series
  49959. */
  49960. Navigator.prototype.getBaseSeriesMin = function (currentSeriesMin) {
  49961. return this.baseSeries.reduce(function (min, series) {
  49962. // (#10193)
  49963. return Math.min(min, series.xData ? series.xData[0] : min);
  49964. }, currentSeriesMin);
  49965. };
  49966. /**
  49967. * Set the navigator x axis extremes to reflect the total. The navigator
  49968. * extremes should always be the extremes of the union of all series in the
  49969. * chart as well as the navigator series.
  49970. *
  49971. * @private
  49972. * @function Highcharts.Navigator#modifyNavigatorAxisExtremes
  49973. */
  49974. Navigator.prototype.modifyNavigatorAxisExtremes = function () {
  49975. var xAxis = this.xAxis,
  49976. unionExtremes;
  49977. if (typeof xAxis.getExtremes !== 'undefined') {
  49978. unionExtremes = this.getUnionExtremes(true);
  49979. if (unionExtremes &&
  49980. (unionExtremes.dataMin !== xAxis.min ||
  49981. unionExtremes.dataMax !== xAxis.max)) {
  49982. xAxis.min = unionExtremes.dataMin;
  49983. xAxis.max = unionExtremes.dataMax;
  49984. }
  49985. }
  49986. };
  49987. /**
  49988. * Hook to modify the base axis extremes with information from the Navigator
  49989. *
  49990. * @private
  49991. * @function Highcharts.Navigator#modifyBaseAxisExtremes
  49992. */
  49993. Navigator.prototype.modifyBaseAxisExtremes = function () {
  49994. var baseXAxis = this,
  49995. navigator = baseXAxis.chart.navigator,
  49996. baseExtremes = baseXAxis.getExtremes(),
  49997. baseMin = baseExtremes.min,
  49998. baseMax = baseExtremes.max,
  49999. baseDataMin = baseExtremes.dataMin,
  50000. baseDataMax = baseExtremes.dataMax,
  50001. range = baseMax - baseMin,
  50002. stickToMin = navigator.stickToMin,
  50003. stickToMax = navigator.stickToMax,
  50004. overscroll = pick(baseXAxis.options.overscroll, 0),
  50005. newMax,
  50006. newMin,
  50007. navigatorSeries = navigator.series && navigator.series[0],
  50008. hasSetExtremes = !!baseXAxis.setExtremes,
  50009. // When the extremes have been set by range selector button, don't
  50010. // stick to min or max. The range selector buttons will handle the
  50011. // extremes. (#5489)
  50012. unmutable = baseXAxis.eventArgs &&
  50013. baseXAxis.eventArgs.trigger === 'rangeSelectorButton';
  50014. if (!unmutable) {
  50015. // If the zoomed range is already at the min, move it to the right
  50016. // as new data comes in
  50017. if (stickToMin) {
  50018. newMin = baseDataMin;
  50019. newMax = newMin + range;
  50020. }
  50021. // If the zoomed range is already at the max, move it to the right
  50022. // as new data comes in
  50023. if (stickToMax) {
  50024. newMax = baseDataMax + overscroll;
  50025. // If stickToMin is true, the new min value is set above
  50026. if (!stickToMin) {
  50027. newMin = Math.max(baseDataMin, // don't go below data extremes (#13184)
  50028. newMax - range, navigator.getBaseSeriesMin(navigatorSeries && navigatorSeries.xData ?
  50029. navigatorSeries.xData[0] :
  50030. -Number.MAX_VALUE));
  50031. }
  50032. }
  50033. // Update the extremes
  50034. if (hasSetExtremes && (stickToMin || stickToMax)) {
  50035. if (isNumber(newMin)) {
  50036. baseXAxis.min = baseXAxis.userMin = newMin;
  50037. baseXAxis.max = baseXAxis.userMax = newMax;
  50038. }
  50039. }
  50040. }
  50041. // Reset
  50042. navigator.stickToMin =
  50043. navigator.stickToMax = null;
  50044. };
  50045. /**
  50046. * Handler for updated data on the base series. When data is modified, the
  50047. * navigator series must reflect it. This is called from the Chart.redraw
  50048. * function before axis and series extremes are computed.
  50049. *
  50050. * @private
  50051. * @function Highcharts.Navigator#updateDataHandler
  50052. */
  50053. Navigator.prototype.updatedDataHandler = function () {
  50054. var navigator = this.chart.navigator,
  50055. baseSeries = this,
  50056. navigatorSeries = this.navigatorSeries;
  50057. // If the scrollbar is scrolled all the way to the right, keep right as
  50058. // new data comes in.
  50059. navigator.stickToMax = navigator.reversedExtremes ?
  50060. Math.round(navigator.zoomedMin) === 0 :
  50061. Math.round(navigator.zoomedMax) >= Math.round(navigator.size);
  50062. navigator.stickToMin = navigator.shouldStickToMin(baseSeries, navigator);
  50063. // Set the navigator series data to the new data of the base series
  50064. if (navigatorSeries && !navigator.hasNavigatorData) {
  50065. navigatorSeries.options.pointStart = baseSeries.xData[0];
  50066. navigatorSeries.setData(baseSeries.options.data, false, null, false); // #5414
  50067. }
  50068. };
  50069. /**
  50070. * Detect if the zoomed area should stick to the minimum, #14742.
  50071. *
  50072. * @private
  50073. * @function Highcharts.Navigator#shouldStickToMin
  50074. */
  50075. Navigator.prototype.shouldStickToMin = function (baseSeries, navigator) {
  50076. var xDataMin = navigator.getBaseSeriesMin(baseSeries.xData[0]),
  50077. xAxis = baseSeries.xAxis,
  50078. max = xAxis.max,
  50079. min = xAxis.min,
  50080. range = xAxis.options.range;
  50081. var stickToMin = true;
  50082. if (isNumber(max) && isNumber(min)) {
  50083. // If range declared, stick to the minimum only if the range
  50084. // is smaller than the data set range.
  50085. if (range && max - xDataMin > 0) {
  50086. stickToMin = max - xDataMin < range && (!this.chart.fixedRange);
  50087. }
  50088. else {
  50089. // If the current axis minimum falls outside the new
  50090. // updated dataset, we must adjust.
  50091. stickToMin = min <= xDataMin;
  50092. }
  50093. }
  50094. return stickToMin;
  50095. };
  50096. /**
  50097. * Add chart events, like redrawing navigator, when chart requires that.
  50098. *
  50099. * @private
  50100. * @function Highcharts.Navigator#addChartEvents
  50101. * @return {void}
  50102. */
  50103. Navigator.prototype.addChartEvents = function () {
  50104. if (!this.eventsToUnbind) {
  50105. this.eventsToUnbind = [];
  50106. }
  50107. this.eventsToUnbind.push(
  50108. // Move the scrollbar after redraw, like after data updata even if
  50109. // axes don't redraw
  50110. addEvent(this.chart, 'redraw', function () {
  50111. var navigator = this.navigator,
  50112. xAxis = navigator && (navigator.baseSeries &&
  50113. navigator.baseSeries[0] &&
  50114. navigator.baseSeries[0].xAxis ||
  50115. this.xAxis[0]); // #5709, #13114
  50116. if (xAxis) {
  50117. navigator.render(xAxis.min,
  50118. xAxis.max);
  50119. }
  50120. }),
  50121. // Make room for the navigator, can be placed around the chart:
  50122. addEvent(this.chart, 'getMargins', function () {
  50123. var chart = this,
  50124. navigator = chart.navigator,
  50125. marginName = navigator.opposite ?
  50126. 'plotTop' : 'marginBottom';
  50127. if (chart.inverted) {
  50128. marginName = navigator.opposite ?
  50129. 'marginRight' : 'plotLeft';
  50130. }
  50131. chart[marginName] =
  50132. (chart[marginName] || 0) + (navigator.navigatorEnabled || !chart.inverted ?
  50133. navigator.outlineHeight :
  50134. 0) + navigator.navigatorOptions.margin;
  50135. }));
  50136. };
  50137. /**
  50138. * Destroys allocated elements.
  50139. *
  50140. * @private
  50141. * @function Highcharts.Navigator#destroy
  50142. */
  50143. Navigator.prototype.destroy = function () {
  50144. // Disconnect events added in addEvents
  50145. this.removeEvents();
  50146. if (this.xAxis) {
  50147. erase(this.chart.xAxis, this.xAxis);
  50148. erase(this.chart.axes, this.xAxis);
  50149. }
  50150. if (this.yAxis) {
  50151. erase(this.chart.yAxis, this.yAxis);
  50152. erase(this.chart.axes, this.yAxis);
  50153. }
  50154. // Destroy series
  50155. (this.series || []).forEach(function (s) {
  50156. if (s.destroy) {
  50157. s.destroy();
  50158. }
  50159. });
  50160. // Destroy properties
  50161. [
  50162. 'series', 'xAxis', 'yAxis', 'shades', 'outline', 'scrollbarTrack',
  50163. 'scrollbarRifles', 'scrollbarGroup', 'scrollbar', 'navigatorGroup',
  50164. 'rendered'
  50165. ].forEach(function (prop) {
  50166. if (this[prop] && this[prop].destroy) {
  50167. this[prop].destroy();
  50168. }
  50169. this[prop] = null;
  50170. }, this);
  50171. // Destroy elements in collection
  50172. [this.handles].forEach(function (coll) {
  50173. destroyObjectProperties(coll);
  50174. }, this);
  50175. };
  50176. return Navigator;
  50177. }());
  50178. // End of prototype
  50179. if (!H.Navigator) {
  50180. H.Navigator = Navigator;
  50181. NavigatorAxis.compose(Axis);
  50182. // For Stock charts. For x only zooming, do not to create the zoom button
  50183. // because X axis zooming is already allowed by the Navigator and Range
  50184. // selector. (#9285)
  50185. addEvent(Chart, 'beforeShowResetZoom', function () {
  50186. var chartOptions = this.options,
  50187. navigator = chartOptions.navigator,
  50188. rangeSelector = chartOptions.rangeSelector;
  50189. if (((navigator && navigator.enabled) ||
  50190. (rangeSelector && rangeSelector.enabled)) &&
  50191. ((!isTouchDevice && chartOptions.chart.zoomType === 'x') ||
  50192. (isTouchDevice && chartOptions.chart.pinchType === 'x'))) {
  50193. return false;
  50194. }
  50195. });
  50196. // Initialize navigator for stock charts
  50197. addEvent(Chart, 'beforeRender', function () {
  50198. var options = this.options;
  50199. if (options.navigator.enabled ||
  50200. options.scrollbar.enabled) {
  50201. this.scroller = this.navigator = new Navigator(this);
  50202. }
  50203. });
  50204. // For stock charts, extend the Chart.setChartSize method so that we can set
  50205. // the final top position of the navigator once the height of the chart,
  50206. // including the legend, is determined. #367. We can't use Chart.getMargins,
  50207. // because labels offsets are not calculated yet.
  50208. addEvent(Chart, 'afterSetChartSize', function () {
  50209. var legend = this.legend,
  50210. navigator = this.navigator,
  50211. scrollbarHeight,
  50212. legendOptions,
  50213. xAxis,
  50214. yAxis;
  50215. if (navigator) {
  50216. legendOptions = legend && legend.options;
  50217. xAxis = navigator.xAxis;
  50218. yAxis = navigator.yAxis;
  50219. scrollbarHeight = navigator.scrollbarHeight;
  50220. // Compute the top position
  50221. if (this.inverted) {
  50222. navigator.left = navigator.opposite ?
  50223. this.chartWidth - scrollbarHeight -
  50224. navigator.height :
  50225. this.spacing[3] + scrollbarHeight;
  50226. navigator.top = this.plotTop + scrollbarHeight;
  50227. }
  50228. else {
  50229. navigator.left = pick(xAxis.left, this.plotLeft + scrollbarHeight);
  50230. navigator.top = navigator.navigatorOptions.top ||
  50231. this.chartHeight -
  50232. navigator.height -
  50233. scrollbarHeight -
  50234. this.spacing[2] -
  50235. (this.rangeSelector && this.extraBottomMargin ?
  50236. this.rangeSelector.getHeight() :
  50237. 0) -
  50238. ((legendOptions &&
  50239. legendOptions.verticalAlign === 'bottom' &&
  50240. legendOptions.layout !== 'proximate' && // #13392
  50241. legendOptions.enabled &&
  50242. !legendOptions.floating) ?
  50243. legend.legendHeight +
  50244. pick(legendOptions.margin, 10) :
  50245. 0) -
  50246. (this.titleOffset ? this.titleOffset[2] : 0);
  50247. }
  50248. if (xAxis && yAxis) { // false if navigator is disabled (#904)
  50249. if (this.inverted) {
  50250. xAxis.options.left = yAxis.options.left = navigator.left;
  50251. }
  50252. else {
  50253. xAxis.options.top = yAxis.options.top = navigator.top;
  50254. }
  50255. xAxis.setAxisSize();
  50256. yAxis.setAxisSize();
  50257. }
  50258. }
  50259. });
  50260. // Merge options, if no scrolling exists yet
  50261. addEvent(Chart, 'update', function (e) {
  50262. var navigatorOptions = (e.options.navigator || {}),
  50263. scrollbarOptions = (e.options.scrollbar || {});
  50264. if (!this.navigator && !this.scroller &&
  50265. (navigatorOptions.enabled || scrollbarOptions.enabled)) {
  50266. merge(true, this.options.navigator, navigatorOptions);
  50267. merge(true, this.options.scrollbar, scrollbarOptions);
  50268. delete e.options.navigator;
  50269. delete e.options.scrollbar;
  50270. }
  50271. });
  50272. // Initialize navigator, if no scrolling exists yet
  50273. addEvent(Chart, 'afterUpdate', function (event) {
  50274. if (!this.navigator && !this.scroller &&
  50275. (this.options.navigator.enabled ||
  50276. this.options.scrollbar.enabled)) {
  50277. this.scroller = this.navigator = new Navigator(this);
  50278. if (pick(event.redraw, true)) {
  50279. this.redraw(event.animation); // #7067
  50280. }
  50281. }
  50282. });
  50283. // Handle adding new series
  50284. addEvent(Chart, 'afterAddSeries', function () {
  50285. if (this.navigator) {
  50286. // Recompute which series should be shown in navigator, and add them
  50287. this.navigator.setBaseSeries(null, false);
  50288. }
  50289. });
  50290. // Handle updating series
  50291. addEvent(Series, 'afterUpdate', function () {
  50292. if (this.chart.navigator && !this.options.isInternal) {
  50293. this.chart.navigator.setBaseSeries(null, false);
  50294. }
  50295. });
  50296. Chart.prototype.callbacks.push(function (chart) {
  50297. var extremes,
  50298. navigator = chart.navigator;
  50299. // Initialize the navigator
  50300. if (navigator && chart.xAxis[0]) {
  50301. extremes = chart.xAxis[0].getExtremes();
  50302. navigator.render(extremes.min, extremes.max);
  50303. }
  50304. });
  50305. }
  50306. H.Navigator = Navigator;
  50307. return H.Navigator;
  50308. });
  50309. _registerModule(_modules, 'Core/Axis/OrdinalAxis.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Chart/Chart.js'], _modules['Core/Globals.js'], _modules['Core/Series/Series.js'], _modules['Core/Utilities.js']], function (Axis, Chart, H, Series, U) {
  50310. /* *
  50311. *
  50312. * (c) 2010-2021 Torstein Honsi
  50313. *
  50314. * License: www.highcharts.com/license
  50315. *
  50316. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  50317. *
  50318. * */
  50319. var addEvent = U.addEvent,
  50320. css = U.css,
  50321. defined = U.defined,
  50322. error = U.error,
  50323. pick = U.pick,
  50324. timeUnits = U.timeUnits;
  50325. // Has a dependency on Navigator due to the use of Axis.toFixedRange
  50326. /**
  50327. * Extends the axis with ordinal support.
  50328. * @private
  50329. */
  50330. var OrdinalAxis;
  50331. (function (OrdinalAxis) {
  50332. /* *
  50333. *
  50334. * Classes
  50335. *
  50336. * */
  50337. /**
  50338. * @private
  50339. */
  50340. var Composition = /** @class */ (function () {
  50341. /* *
  50342. *
  50343. * Constructors
  50344. *
  50345. * */
  50346. /**
  50347. * @private
  50348. */
  50349. function Composition(axis) {
  50350. this.index = {};
  50351. this.axis = axis;
  50352. }
  50353. /* *
  50354. *
  50355. * Functions
  50356. *
  50357. * */
  50358. /**
  50359. * Calculate the ordinal positions before tick positions are calculated.
  50360. *
  50361. * @private
  50362. */
  50363. Composition.prototype.beforeSetTickPositions = function () {
  50364. var axis = this.axis,
  50365. ordinal = axis.ordinal,
  50366. len,
  50367. ordinalPositions = [],
  50368. uniqueOrdinalPositions,
  50369. useOrdinal = false,
  50370. dist,
  50371. extremes = axis.getExtremes(),
  50372. min = extremes.min,
  50373. max = extremes.max,
  50374. minIndex,
  50375. maxIndex,
  50376. slope,
  50377. hasBreaks = axis.isXAxis && !!axis.options.breaks,
  50378. isOrdinal = axis.options.ordinal,
  50379. overscrollPointsRange = Number.MAX_VALUE,
  50380. ignoreHiddenSeries = axis.chart.options.chart.ignoreHiddenSeries,
  50381. i,
  50382. hasBoostedSeries;
  50383. // Apply the ordinal logic
  50384. if (isOrdinal || hasBreaks) { // #4167 YAxis is never ordinal ?
  50385. axis.series.forEach(function (series, i) {
  50386. uniqueOrdinalPositions = [];
  50387. if ((!ignoreHiddenSeries || series.visible !== false) &&
  50388. (series.takeOrdinalPosition !== false || hasBreaks)) {
  50389. // concatenate the processed X data into the existing
  50390. // positions, or the empty array
  50391. ordinalPositions = ordinalPositions.concat(series.processedXData);
  50392. len = ordinalPositions.length;
  50393. // remove duplicates (#1588)
  50394. ordinalPositions.sort(function (a, b) {
  50395. // without a custom function it is sorted as strings
  50396. return a - b;
  50397. });
  50398. overscrollPointsRange = Math.min(overscrollPointsRange, pick(
  50399. // Check for a single-point series:
  50400. series.closestPointRange, overscrollPointsRange));
  50401. if (len) {
  50402. i = 0;
  50403. while (i < len - 1) {
  50404. if (ordinalPositions[i] !== ordinalPositions[i + 1]) {
  50405. uniqueOrdinalPositions.push(ordinalPositions[i + 1]);
  50406. }
  50407. i++;
  50408. }
  50409. // Check first item:
  50410. if (uniqueOrdinalPositions[0] !== ordinalPositions[0]) {
  50411. uniqueOrdinalPositions.unshift(ordinalPositions[0]);
  50412. }
  50413. ordinalPositions = uniqueOrdinalPositions;
  50414. }
  50415. }
  50416. if (series.isSeriesBoosting) {
  50417. hasBoostedSeries = true;
  50418. }
  50419. });
  50420. if (hasBoostedSeries) {
  50421. ordinalPositions.length = 0;
  50422. }
  50423. // cache the length
  50424. len = ordinalPositions.length;
  50425. // Check if we really need the overhead of mapping axis data
  50426. // against the ordinal positions. If the series consist of
  50427. // evenly spaced data any way, we don't need any ordinal logic.
  50428. if (len > 2) { // two points have equal distance by default
  50429. dist = ordinalPositions[1] - ordinalPositions[0];
  50430. i = len - 1;
  50431. while (i-- && !useOrdinal) {
  50432. if (ordinalPositions[i + 1] - ordinalPositions[i] !== dist) {
  50433. useOrdinal = true;
  50434. }
  50435. }
  50436. // When zooming in on a week, prevent axis padding for
  50437. // weekends even though the data within the week is evenly
  50438. // spaced.
  50439. if (!axis.options.keepOrdinalPadding &&
  50440. (ordinalPositions[0] - min > dist ||
  50441. max - ordinalPositions[ordinalPositions.length - 1] >
  50442. dist)) {
  50443. useOrdinal = true;
  50444. }
  50445. }
  50446. else if (axis.options.overscroll) {
  50447. if (len === 2) {
  50448. // Exactly two points, distance for overscroll is fixed:
  50449. overscrollPointsRange =
  50450. ordinalPositions[1] - ordinalPositions[0];
  50451. }
  50452. else if (len === 1) {
  50453. // We have just one point, closest distance is unknown.
  50454. // Assume then it is last point and overscrolled range:
  50455. overscrollPointsRange = axis.options.overscroll;
  50456. ordinalPositions = [
  50457. ordinalPositions[0],
  50458. ordinalPositions[0] + overscrollPointsRange
  50459. ];
  50460. }
  50461. else {
  50462. // In case of zooming in on overscrolled range, stick to
  50463. // the old range:
  50464. overscrollPointsRange = ordinal.overscrollPointsRange;
  50465. }
  50466. }
  50467. // Record the slope and offset to compute the linear values from
  50468. // the array index. Since the ordinal positions may exceed the
  50469. // current range, get the start and end positions within it
  50470. // (#719, #665b)
  50471. if (useOrdinal || axis.forceOrdinal) {
  50472. if (axis.options.overscroll) {
  50473. ordinal.overscrollPointsRange = overscrollPointsRange;
  50474. ordinalPositions = ordinalPositions.concat(ordinal.getOverscrollPositions());
  50475. }
  50476. // Register
  50477. ordinal.positions = ordinalPositions;
  50478. // This relies on the ordinalPositions being set. Use
  50479. // Math.max and Math.min to prevent padding on either sides
  50480. // of the data.
  50481. minIndex = axis.ordinal2lin(// #5979
  50482. Math.max(min, ordinalPositions[0]), true);
  50483. maxIndex = Math.max(axis.ordinal2lin(Math.min(max, ordinalPositions[ordinalPositions.length - 1]), true), 1); // #3339
  50484. // Set the slope and offset of the values compared to the
  50485. // indices in the ordinal positions
  50486. ordinal.slope = slope = (max - min) / (maxIndex - minIndex);
  50487. ordinal.offset = min - (minIndex * slope);
  50488. }
  50489. else {
  50490. ordinal.overscrollPointsRange = pick(axis.closestPointRange, ordinal.overscrollPointsRange);
  50491. ordinal.positions = axis.ordinal.slope = ordinal.offset =
  50492. void 0;
  50493. }
  50494. }
  50495. axis.isOrdinal = isOrdinal && useOrdinal; // #3818, #4196, #4926
  50496. ordinal.groupIntervalFactor = null; // reset for next run
  50497. };
  50498. /**
  50499. * Get the ordinal positions for the entire data set. This is necessary
  50500. * in chart panning because we need to find out what points or data
  50501. * groups are available outside the visible range. When a panning
  50502. * operation starts, if an index for the given grouping does not exists,
  50503. * it is created and cached. This index is deleted on updated data, so
  50504. * it will be regenerated the next time a panning operation starts.
  50505. *
  50506. * @private
  50507. */
  50508. Composition.prototype.getExtendedPositions = function () {
  50509. var ordinal = this,
  50510. axis = ordinal.axis,
  50511. axisProto = axis.constructor.prototype,
  50512. chart = axis.chart,
  50513. grouping = axis.series[0].currentDataGrouping,
  50514. ordinalIndex = ordinal.index,
  50515. key = grouping ?
  50516. grouping.count + grouping.unitName :
  50517. 'raw',
  50518. overscroll = axis.options.overscroll,
  50519. extremes = axis.getExtremes(),
  50520. fakeAxis,
  50521. fakeSeries;
  50522. // If this is the first time, or the ordinal index is deleted by
  50523. // updatedData,
  50524. // create it.
  50525. if (!ordinalIndex) {
  50526. ordinalIndex = ordinal.index = {};
  50527. }
  50528. if (!ordinalIndex[key]) {
  50529. // Create a fake axis object where the extended ordinal
  50530. // positions are emulated
  50531. fakeAxis = {
  50532. series: [],
  50533. chart: chart,
  50534. forceOrdinal: false,
  50535. getExtremes: function () {
  50536. return {
  50537. min: extremes.dataMin,
  50538. max: extremes.dataMax + overscroll
  50539. };
  50540. },
  50541. getGroupPixelWidth: axisProto.getGroupPixelWidth,
  50542. getTimeTicks: axisProto.getTimeTicks,
  50543. options: {
  50544. ordinal: true
  50545. },
  50546. ordinal: {
  50547. getGroupIntervalFactor: this.getGroupIntervalFactor
  50548. },
  50549. ordinal2lin: axisProto.ordinal2lin,
  50550. val2lin: axisProto.val2lin // #2590
  50551. };
  50552. fakeAxis.ordinal.axis = fakeAxis;
  50553. // Add the fake series to hold the full data, then apply
  50554. // processData to it
  50555. axis.series.forEach(function (series) {
  50556. fakeSeries = {
  50557. xAxis: fakeAxis,
  50558. xData: series.xData.slice(),
  50559. chart: chart,
  50560. destroyGroupedData: H.noop,
  50561. getProcessedData: Series.prototype.getProcessedData
  50562. };
  50563. fakeSeries.xData = fakeSeries.xData.concat(ordinal.getOverscrollPositions());
  50564. fakeSeries.options = {
  50565. dataGrouping: grouping ? {
  50566. enabled: true,
  50567. forced: true,
  50568. // doesn't matter which, use the fastest
  50569. approximation: 'open',
  50570. units: [[
  50571. grouping.unitName,
  50572. [grouping.count]
  50573. ]]
  50574. } : {
  50575. enabled: false
  50576. }
  50577. };
  50578. fakeAxis.series.push(fakeSeries);
  50579. series.processData.apply(fakeSeries);
  50580. // Force to use the ordinal when points are evenly spaced
  50581. // (e.g. weeks), #3825.
  50582. if (fakeSeries.closestPointRange !== fakeSeries.basePointRange && fakeSeries.currentDataGrouping) {
  50583. fakeAxis.forceOrdinal = true;
  50584. }
  50585. });
  50586. // Run beforeSetTickPositions to compute the ordinalPositions
  50587. axis.ordinal.beforeSetTickPositions.apply({ axis: fakeAxis });
  50588. // Cache it
  50589. ordinalIndex[key] = fakeAxis.ordinal.positions;
  50590. }
  50591. return ordinalIndex[key];
  50592. };
  50593. /**
  50594. * Find the factor to estimate how wide the plot area would have been if
  50595. * ordinal gaps were included. This value is used to compute an imagined
  50596. * plot width in order to establish the data grouping interval.
  50597. *
  50598. * A real world case is the intraday-candlestick example. Without this
  50599. * logic, it would show the correct data grouping when viewing a range
  50600. * within each day, but once moving the range to include the gap between
  50601. * two days, the interval would include the cut-away night hours and the
  50602. * data grouping would be wrong. So the below method tries to compensate
  50603. * by identifying the most common point interval, in this case days.
  50604. *
  50605. * An opposite case is presented in issue #718. We have a long array of
  50606. * daily data, then one point is appended one hour after the last point.
  50607. * We expect the data grouping not to change.
  50608. *
  50609. * In the future, if we find cases where this estimation doesn't work
  50610. * optimally, we might need to add a second pass to the data grouping
  50611. * logic, where we do another run with a greater interval if the number
  50612. * of data groups is more than a certain fraction of the desired group
  50613. * count.
  50614. *
  50615. * @private
  50616. */
  50617. Composition.prototype.getGroupIntervalFactor = function (xMin, xMax, series) {
  50618. var ordinal = this,
  50619. axis = ordinal.axis,
  50620. i,
  50621. processedXData = series.processedXData,
  50622. len = processedXData.length,
  50623. distances = [],
  50624. median,
  50625. groupIntervalFactor = ordinal.groupIntervalFactor;
  50626. // Only do this computation for the first series, let the other
  50627. // inherit it (#2416)
  50628. if (!groupIntervalFactor) {
  50629. // Register all the distances in an array
  50630. for (i = 0; i < len - 1; i++) {
  50631. distances[i] =
  50632. processedXData[i + 1] - processedXData[i];
  50633. }
  50634. // Sort them and find the median
  50635. distances.sort(function (a, b) {
  50636. return a - b;
  50637. });
  50638. median = distances[Math.floor(len / 2)];
  50639. // Compensate for series that don't extend through the entire
  50640. // axis extent. #1675.
  50641. xMin = Math.max(xMin, processedXData[0]);
  50642. xMax = Math.min(xMax, processedXData[len - 1]);
  50643. ordinal.groupIntervalFactor = groupIntervalFactor =
  50644. (len * median) / (xMax - xMin);
  50645. }
  50646. // Return the factor needed for data grouping
  50647. return groupIntervalFactor;
  50648. };
  50649. /**
  50650. * Get ticks for an ordinal axis within a range where points don't
  50651. * exist. It is required when overscroll is enabled. We can't base on
  50652. * points, because we may not have any, so we use approximated
  50653. * pointRange and generate these ticks between Axis.dataMax,
  50654. * Axis.dataMax + Axis.overscroll evenly spaced. Used in panning and
  50655. * navigator scrolling.
  50656. *
  50657. * @private
  50658. */
  50659. Composition.prototype.getOverscrollPositions = function () {
  50660. var ordinal = this,
  50661. axis = ordinal.axis,
  50662. extraRange = axis.options.overscroll,
  50663. distance = ordinal.overscrollPointsRange,
  50664. positions = [],
  50665. max = axis.dataMax;
  50666. if (defined(distance)) {
  50667. // Max + pointRange because we need to scroll to the last
  50668. positions.push(max);
  50669. while (max <= axis.dataMax + extraRange) {
  50670. max += distance;
  50671. positions.push(max);
  50672. }
  50673. }
  50674. return positions;
  50675. };
  50676. /**
  50677. * Make the tick intervals closer because the ordinal gaps make the
  50678. * ticks spread out or cluster.
  50679. *
  50680. * @private
  50681. */
  50682. Composition.prototype.postProcessTickInterval = function (tickInterval) {
  50683. // Problem: https://jsfiddle.net/highcharts/FQm4E/1/
  50684. // This is a case where this algorithm doesn't work optimally. In
  50685. // this case, the tick labels are spread out per week, but all the
  50686. // gaps reside within weeks. So we have a situation where the labels
  50687. // are courser than the ordinal gaps, and thus the tick interval
  50688. // should not be altered.
  50689. var ordinal = this,
  50690. axis = ordinal.axis,
  50691. ordinalSlope = ordinal.slope,
  50692. ret;
  50693. if (ordinalSlope) {
  50694. if (!axis.options.breaks) {
  50695. ret = tickInterval / (ordinalSlope / axis.closestPointRange);
  50696. }
  50697. else {
  50698. ret = axis.closestPointRange || tickInterval; // #7275
  50699. }
  50700. }
  50701. else {
  50702. ret = tickInterval;
  50703. }
  50704. return ret;
  50705. };
  50706. return Composition;
  50707. }());
  50708. OrdinalAxis.Composition = Composition;
  50709. /* *
  50710. *
  50711. * Functions
  50712. *
  50713. * */
  50714. /**
  50715. * Extends the axis with ordinal support.
  50716. *
  50717. * @private
  50718. *
  50719. * @param AxisClass
  50720. * Axis class to extend.
  50721. *
  50722. * @param ChartClass
  50723. * Chart class to use.
  50724. *
  50725. * @param SeriesClass
  50726. * Series class to use.
  50727. */
  50728. function compose(AxisClass, ChartClass, SeriesClass) {
  50729. AxisClass.keepProps.push('ordinal');
  50730. var axisProto = AxisClass.prototype;
  50731. /**
  50732. * In an ordinal axis, there might be areas with dense consentrations of
  50733. * points, then large gaps between some. Creating equally distributed
  50734. * ticks over this entire range may lead to a huge number of ticks that
  50735. * will later be removed. So instead, break the positions up in
  50736. * segments, find the tick positions for each segment then concatenize
  50737. * them. This method is used from both data grouping logic and X axis
  50738. * tick position logic.
  50739. *
  50740. * @private
  50741. */
  50742. AxisClass.prototype.getTimeTicks = function (normalizedInterval, min, max, startOfWeek, positions, closestDistance, findHigherRanks) {
  50743. if (positions === void 0) { positions = []; }
  50744. if (closestDistance === void 0) { closestDistance = 0; }
  50745. var start = 0,
  50746. end,
  50747. segmentPositions,
  50748. higherRanks = {},
  50749. hasCrossedHigherRank,
  50750. info,
  50751. posLength,
  50752. outsideMax,
  50753. groupPositions = [],
  50754. lastGroupPosition = -Number.MAX_VALUE,
  50755. tickPixelIntervalOption = this.options.tickPixelInterval,
  50756. time = this.chart.time,
  50757. // Record all the start positions of a segment, to use when
  50758. // deciding what's a gap in the data.
  50759. segmentStarts = [];
  50760. // The positions are not always defined, for example for ordinal
  50761. // positions when data has regular interval (#1557, #2090)
  50762. if ((!this.options.ordinal && !this.options.breaks) ||
  50763. !positions ||
  50764. positions.length < 3 ||
  50765. typeof min === 'undefined') {
  50766. return time.getTimeTicks.apply(time, arguments);
  50767. }
  50768. // Analyze the positions array to split it into segments on gaps
  50769. // larger than 5 times the closest distance. The closest distance is
  50770. // already found at this point, so we reuse that instead of
  50771. // computing it again.
  50772. posLength = positions.length;
  50773. for (end = 0; end < posLength; end++) {
  50774. outsideMax = end && positions[end - 1] > max;
  50775. if (positions[end] < min) { // Set the last position before min
  50776. start = end;
  50777. }
  50778. if (end === posLength - 1 ||
  50779. positions[end + 1] - positions[end] > closestDistance * 5 ||
  50780. outsideMax) {
  50781. // For each segment, calculate the tick positions from the
  50782. // getTimeTicks utility function. The interval will be the
  50783. // same regardless of how long the segment is.
  50784. if (positions[end] > lastGroupPosition) { // #1475
  50785. segmentPositions = time.getTimeTicks(normalizedInterval, positions[start], positions[end], startOfWeek);
  50786. // Prevent duplicate groups, for example for multiple
  50787. // segments within one larger time frame (#1475)
  50788. while (segmentPositions.length &&
  50789. segmentPositions[0] <= lastGroupPosition) {
  50790. segmentPositions.shift();
  50791. }
  50792. if (segmentPositions.length) {
  50793. lastGroupPosition =
  50794. segmentPositions[segmentPositions.length - 1];
  50795. }
  50796. segmentStarts.push(groupPositions.length);
  50797. groupPositions = groupPositions.concat(segmentPositions);
  50798. }
  50799. // Set start of next segment
  50800. start = end + 1;
  50801. }
  50802. if (outsideMax) {
  50803. break;
  50804. }
  50805. }
  50806. // Get the grouping info from the last of the segments. The info is
  50807. // the same for all segments.
  50808. if (segmentPositions) {
  50809. info = segmentPositions.info;
  50810. // Optionally identify ticks with higher rank, for example
  50811. // when the ticks have crossed midnight.
  50812. if (findHigherRanks && info.unitRange <= timeUnits.hour) {
  50813. end = groupPositions.length - 1;
  50814. // Compare points two by two
  50815. for (start = 1; start < end; start++) {
  50816. if (time.dateFormat('%d', groupPositions[start]) !==
  50817. time.dateFormat('%d', groupPositions[start - 1])) {
  50818. higherRanks[groupPositions[start]] = 'day';
  50819. hasCrossedHigherRank = true;
  50820. }
  50821. }
  50822. // If the complete array has crossed midnight, we want
  50823. // to mark the first positions also as higher rank
  50824. if (hasCrossedHigherRank) {
  50825. higherRanks[groupPositions[0]] = 'day';
  50826. }
  50827. info.higherRanks = higherRanks;
  50828. }
  50829. // Save the info
  50830. info.segmentStarts = segmentStarts;
  50831. groupPositions.info = info;
  50832. }
  50833. else {
  50834. error(12, false, this.chart);
  50835. }
  50836. // Don't show ticks within a gap in the ordinal axis, where the
  50837. // space between two points is greater than a portion of the tick
  50838. // pixel interval
  50839. if (findHigherRanks && defined(tickPixelIntervalOption)) {
  50840. var length_1 = groupPositions.length,
  50841. i = length_1,
  50842. itemToRemove = void 0,
  50843. translated = void 0,
  50844. translatedArr = [],
  50845. lastTranslated = void 0,
  50846. medianDistance = void 0,
  50847. distance = void 0,
  50848. distances = [];
  50849. // Find median pixel distance in order to keep a reasonably even
  50850. // distance between ticks (#748)
  50851. while (i--) {
  50852. translated = this.translate(groupPositions[i]);
  50853. if (lastTranslated) {
  50854. distances[i] = lastTranslated - translated;
  50855. }
  50856. translatedArr[i] = lastTranslated = translated;
  50857. }
  50858. distances.sort();
  50859. medianDistance = distances[Math.floor(distances.length / 2)];
  50860. if (medianDistance < tickPixelIntervalOption * 0.6) {
  50861. medianDistance = null;
  50862. }
  50863. // Now loop over again and remove ticks where needed
  50864. i = groupPositions[length_1 - 1] > max ? length_1 - 1 : length_1; // #817
  50865. lastTranslated = void 0;
  50866. while (i--) {
  50867. translated = translatedArr[i];
  50868. distance = Math.abs(lastTranslated - translated);
  50869. // #4175 - when axis is reversed, the distance, is negative
  50870. // but tickPixelIntervalOption positive, so we need to
  50871. // compare the same values
  50872. // Remove ticks that are closer than 0.6 times the pixel
  50873. // interval from the one to the right, but not if it is
  50874. // close to the median distance (#748).
  50875. if (lastTranslated &&
  50876. distance < tickPixelIntervalOption * 0.8 &&
  50877. (medianDistance === null || distance < medianDistance * 0.8)) {
  50878. // Is this a higher ranked position with a normal
  50879. // position to the right?
  50880. if (higherRanks[groupPositions[i]] &&
  50881. !higherRanks[groupPositions[i + 1]]) {
  50882. // Yes: remove the lower ranked neighbour to the
  50883. // right
  50884. itemToRemove = i + 1;
  50885. lastTranslated = translated; // #709
  50886. }
  50887. else {
  50888. // No: remove this one
  50889. itemToRemove = i;
  50890. }
  50891. groupPositions.splice(itemToRemove, 1);
  50892. }
  50893. else {
  50894. lastTranslated = translated;
  50895. }
  50896. }
  50897. }
  50898. return groupPositions;
  50899. };
  50900. /**
  50901. * Translate from linear (internal) to axis value.
  50902. *
  50903. * @private
  50904. * @function Highcharts.Axis#lin2val
  50905. *
  50906. * @param {number} val
  50907. * The linear abstracted value.
  50908. *
  50909. * @param {boolean} [fromIndex]
  50910. * Translate from an index in the ordinal positions rather than a
  50911. * value.
  50912. *
  50913. * @return {number}
  50914. */
  50915. axisProto.lin2val = function (val, fromIndex) {
  50916. var axis = this,
  50917. ordinal = axis.ordinal,
  50918. ordinalPositions = ordinal.positions,
  50919. ret;
  50920. // the visible range contains only equally spaced values
  50921. if (!ordinalPositions) {
  50922. ret = val;
  50923. }
  50924. else {
  50925. var ordinalSlope = ordinal.slope,
  50926. ordinalOffset = ordinal.offset,
  50927. i = ordinalPositions.length - 1,
  50928. linearEquivalentLeft = void 0,
  50929. linearEquivalentRight = void 0,
  50930. distance = void 0;
  50931. // Handle the case where we translate from the index directly,
  50932. // used only when panning an ordinal axis
  50933. if (fromIndex) {
  50934. if (val < 0) { // out of range, in effect panning to the left
  50935. val = ordinalPositions[0];
  50936. }
  50937. else if (val > i) { // out of range, panning to the right
  50938. val = ordinalPositions[i];
  50939. }
  50940. else { // split it up
  50941. i = Math.floor(val);
  50942. distance = val - i; // the decimal
  50943. }
  50944. // Loop down along the ordinal positions. When the linear
  50945. // equivalent of i matches an ordinal position, interpolate
  50946. // between the left and right values.
  50947. }
  50948. else {
  50949. while (i--) {
  50950. linearEquivalentLeft =
  50951. (ordinalSlope * i) + ordinalOffset;
  50952. if (val >= linearEquivalentLeft) {
  50953. linearEquivalentRight =
  50954. (ordinalSlope *
  50955. (i + 1)) +
  50956. ordinalOffset;
  50957. // something between 0 and 1
  50958. distance = (val - linearEquivalentLeft) /
  50959. (linearEquivalentRight - linearEquivalentLeft);
  50960. break;
  50961. }
  50962. }
  50963. }
  50964. // If the index is within the range of the ordinal positions,
  50965. // return the associated or interpolated value. If not, just
  50966. // return the value.
  50967. return (typeof distance !== 'undefined' &&
  50968. typeof ordinalPositions[i] !== 'undefined' ?
  50969. ordinalPositions[i] + (distance ?
  50970. distance *
  50971. (ordinalPositions[i + 1] - ordinalPositions[i]) :
  50972. 0) :
  50973. val);
  50974. }
  50975. return ret;
  50976. };
  50977. /**
  50978. * Translate from a linear axis value to the corresponding ordinal axis
  50979. * position. If there are no gaps in the ordinal axis this will be the
  50980. * same. The translated value is the value that the point would have if
  50981. * the axis were linear, using the same min and max.
  50982. *
  50983. * @private
  50984. * @function Highcharts.Axis#val2lin
  50985. *
  50986. * @param {number} val
  50987. * The axis value.
  50988. *
  50989. * @param {boolean} [toIndex]
  50990. * Whether to return the index in the ordinalPositions or the new value.
  50991. *
  50992. * @return {number}
  50993. */
  50994. axisProto.val2lin = function (val, toIndex) {
  50995. var axis = this,
  50996. ordinal = axis.ordinal,
  50997. ordinalPositions = ordinal.positions,
  50998. ret;
  50999. if (!ordinalPositions) {
  51000. ret = val;
  51001. }
  51002. else {
  51003. var ordinalLength = ordinalPositions.length,
  51004. i = void 0,
  51005. distance = void 0,
  51006. ordinalIndex = void 0;
  51007. // first look for an exact match in the ordinalpositions array
  51008. i = ordinalLength;
  51009. while (i--) {
  51010. if (ordinalPositions[i] === val) {
  51011. ordinalIndex = i;
  51012. break;
  51013. }
  51014. }
  51015. // if that failed, find the intermediate position between the
  51016. // two nearest values
  51017. i = ordinalLength - 1;
  51018. while (i--) {
  51019. if (val > ordinalPositions[i] || i === 0) { // interpolate
  51020. // something between 0 and 1
  51021. distance = (val - ordinalPositions[i]) /
  51022. (ordinalPositions[i + 1] - ordinalPositions[i]);
  51023. ordinalIndex = i + distance;
  51024. break;
  51025. }
  51026. }
  51027. ret = toIndex ?
  51028. ordinalIndex :
  51029. ordinal.slope *
  51030. (ordinalIndex || 0) +
  51031. ordinal.offset;
  51032. }
  51033. return ret;
  51034. };
  51035. // Record this to prevent overwriting by broken-axis module (#5979)
  51036. axisProto.ordinal2lin = axisProto.val2lin;
  51037. /* eslint-disable no-invalid-this */
  51038. addEvent(AxisClass, 'afterInit', function () {
  51039. var axis = this;
  51040. if (!axis.ordinal) {
  51041. axis.ordinal = new OrdinalAxis.Composition(axis);
  51042. }
  51043. });
  51044. addEvent(AxisClass, 'foundExtremes', function () {
  51045. var axis = this;
  51046. if (axis.isXAxis &&
  51047. defined(axis.options.overscroll) &&
  51048. axis.max === axis.dataMax &&
  51049. (
  51050. // Panning is an execption. We don't want to apply
  51051. // overscroll when panning over the dataMax
  51052. !axis.chart.mouseIsDown ||
  51053. axis.isInternal) && (
  51054. // Scrollbar buttons are the other execption:
  51055. !axis.eventArgs ||
  51056. axis.eventArgs && axis.eventArgs.trigger !== 'navigator')) {
  51057. axis.max += axis.options.overscroll;
  51058. // Live data and buttons require translation for the min:
  51059. if (!axis.isInternal && defined(axis.userMin)) {
  51060. axis.min += axis.options.overscroll;
  51061. }
  51062. }
  51063. });
  51064. // For ordinal axis, that loads data async, redraw axis after data is
  51065. // loaded. If we don't do that, axis will have the same extremes as
  51066. // previously, but ordinal positions won't be calculated. See #10290
  51067. addEvent(AxisClass, 'afterSetScale', function () {
  51068. var axis = this;
  51069. if (axis.horiz && !axis.isDirty) {
  51070. axis.isDirty = axis.isOrdinal &&
  51071. axis.chart.navigator &&
  51072. !axis.chart.navigator.adaptToUpdatedData;
  51073. }
  51074. });
  51075. addEvent(AxisClass, 'initialAxisTranslation', function () {
  51076. var axis = this;
  51077. if (axis.ordinal) {
  51078. axis.ordinal.beforeSetTickPositions();
  51079. axis.tickInterval = axis.ordinal.postProcessTickInterval(axis.tickInterval);
  51080. }
  51081. });
  51082. // Extending the Chart.pan method for ordinal axes
  51083. addEvent(ChartClass, 'pan', function (e) {
  51084. var chart = this,
  51085. xAxis = chart.xAxis[0],
  51086. overscroll = xAxis.options.overscroll,
  51087. chartX = e.originalEvent.chartX,
  51088. panning = chart.options.chart.panning,
  51089. runBase = false;
  51090. if (panning &&
  51091. panning.type !== 'y' &&
  51092. xAxis.options.ordinal &&
  51093. xAxis.series.length) {
  51094. var mouseDownX = chart.mouseDownX,
  51095. extremes = xAxis.getExtremes(),
  51096. dataMax = extremes.dataMax,
  51097. min = extremes.min,
  51098. max = extremes.max,
  51099. trimmedRange = void 0,
  51100. hoverPoints = chart.hoverPoints,
  51101. closestPointRange = (xAxis.closestPointRange ||
  51102. (xAxis.ordinal && xAxis.ordinal.overscrollPointsRange)),
  51103. pointPixelWidth = (xAxis.translationSlope *
  51104. (xAxis.ordinal.slope || closestPointRange)),
  51105. // how many ordinal units did we move?
  51106. movedUnits = (mouseDownX - chartX) / pointPixelWidth,
  51107. // get index of all the chart's points
  51108. extendedAxis = { ordinal: { positions: xAxis.ordinal.getExtendedPositions() } },
  51109. ordinalPositions = void 0,
  51110. searchAxisLeft = void 0,
  51111. lin2val = xAxis.lin2val,
  51112. val2lin = xAxis.val2lin,
  51113. searchAxisRight = void 0;
  51114. // we have an ordinal axis, but the data is equally spaced
  51115. if (!extendedAxis.ordinal.positions) {
  51116. runBase = true;
  51117. }
  51118. else if (Math.abs(movedUnits) > 1) {
  51119. // Remove active points for shared tooltip
  51120. if (hoverPoints) {
  51121. hoverPoints.forEach(function (point) {
  51122. point.setState();
  51123. });
  51124. }
  51125. if (movedUnits < 0) {
  51126. searchAxisLeft = extendedAxis;
  51127. searchAxisRight = xAxis.ordinal.positions ? xAxis : extendedAxis;
  51128. }
  51129. else {
  51130. searchAxisLeft = xAxis.ordinal.positions ? xAxis : extendedAxis;
  51131. searchAxisRight = extendedAxis;
  51132. }
  51133. // In grouped data series, the last ordinal position
  51134. // represents the grouped data, which is to the left of the
  51135. // real data max. If we don't compensate for this, we will
  51136. // be allowed to pan grouped data series passed the right of
  51137. // the plot area.
  51138. ordinalPositions = searchAxisRight.ordinal.positions;
  51139. if (dataMax >
  51140. ordinalPositions[ordinalPositions.length - 1]) {
  51141. ordinalPositions.push(dataMax);
  51142. }
  51143. // Get the new min and max values by getting the ordinal
  51144. // index for the current extreme, then add the moved units
  51145. // and translate back to values. This happens on the
  51146. // extended ordinal positions if the new position is out of
  51147. // range, else it happens on the current x axis which is
  51148. // smaller and faster.
  51149. chart.fixedRange = max - min;
  51150. trimmedRange = xAxis.navigatorAxis.toFixedRange(null, null, lin2val.apply(searchAxisLeft, [
  51151. val2lin.apply(searchAxisLeft, [min, true]) + movedUnits,
  51152. true // translate from index
  51153. ]), lin2val.apply(searchAxisRight, [
  51154. val2lin.apply(searchAxisRight, [max, true]) + movedUnits,
  51155. true // translate from index
  51156. ]));
  51157. // Apply it if it is within the available data range
  51158. if (trimmedRange.min >= Math.min(extremes.dataMin, min) &&
  51159. trimmedRange.max <= Math.max(dataMax, max) + overscroll) {
  51160. xAxis.setExtremes(trimmedRange.min, trimmedRange.max, true, false, { trigger: 'pan' });
  51161. }
  51162. chart.mouseDownX = chartX; // set new reference for next run
  51163. css(chart.container, { cursor: 'move' });
  51164. }
  51165. }
  51166. else {
  51167. runBase = true;
  51168. }
  51169. // revert to the linear chart.pan version
  51170. if (runBase || (panning && /y/.test(panning.type))) {
  51171. if (overscroll) {
  51172. xAxis.max = xAxis.dataMax + overscroll;
  51173. }
  51174. }
  51175. else {
  51176. e.preventDefault();
  51177. }
  51178. });
  51179. addEvent(SeriesClass, 'updatedData', function () {
  51180. var xAxis = this.xAxis;
  51181. // Destroy the extended ordinal index on updated data
  51182. if (xAxis && xAxis.options.ordinal) {
  51183. delete xAxis.ordinal.index;
  51184. }
  51185. });
  51186. /* eslint-enable no-invalid-this */
  51187. }
  51188. OrdinalAxis.compose = compose;
  51189. })(OrdinalAxis || (OrdinalAxis = {}));
  51190. OrdinalAxis.compose(Axis, Chart, Series); // @todo move to StockChart, remove from master
  51191. return OrdinalAxis;
  51192. });
  51193. _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) {
  51194. /* *
  51195. *
  51196. * (c) 2009-2021 Torstein Honsi
  51197. *
  51198. * License: www.highcharts.com/license
  51199. *
  51200. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  51201. *
  51202. * */
  51203. var addEvent = U.addEvent,
  51204. find = U.find,
  51205. fireEvent = U.fireEvent,
  51206. isArray = U.isArray,
  51207. isNumber = U.isNumber,
  51208. pick = U.pick;
  51209. /**
  51210. * Axis with support of broken data rows.
  51211. * @private
  51212. * @class
  51213. */
  51214. var BrokenAxis;
  51215. (function (BrokenAxis) {
  51216. /* *
  51217. *
  51218. * Functions
  51219. *
  51220. * */
  51221. /* eslint-disable valid-jsdoc */
  51222. /**
  51223. * Adds support for broken axes.
  51224. * @private
  51225. */
  51226. function compose(AxisClass, SeriesClass) {
  51227. if (AxisClass.keepProps.indexOf('brokenAxis') === -1) {
  51228. AxisClass.keepProps.push('brokenAxis');
  51229. var seriesProto = Series.prototype;
  51230. seriesProto.drawBreaks = seriesDrawBreaks;
  51231. seriesProto.gappedPath = seriesGappedPath;
  51232. addEvent(AxisClass, 'init', onInit);
  51233. addEvent(AxisClass, 'afterInit', onAfterInit);
  51234. addEvent(AxisClass, 'afterSetTickPositions', onAfterSetTickPositions);
  51235. addEvent(AxisClass, 'afterSetOptions', onAfterSetOptions);
  51236. addEvent(SeriesClass, 'afterGeneratePoints', onSeriesAfterGeneratePoints);
  51237. addEvent(SeriesClass, 'afterRender', onSeriesAfterRender);
  51238. }
  51239. return AxisClass;
  51240. }
  51241. BrokenAxis.compose = compose;
  51242. /**
  51243. * @private
  51244. */
  51245. function onAfterInit() {
  51246. if (typeof this.brokenAxis !== 'undefined') {
  51247. this.brokenAxis.setBreaks(this.options.breaks, false);
  51248. }
  51249. }
  51250. /**
  51251. * Force Axis to be not-ordinal when breaks are defined.
  51252. * @private
  51253. */
  51254. function onAfterSetOptions() {
  51255. var axis = this;
  51256. if (axis.brokenAxis && axis.brokenAxis.hasBreaks) {
  51257. axis.options.ordinal = false;
  51258. }
  51259. }
  51260. /**
  51261. * @private
  51262. */
  51263. function onAfterSetTickPositions() {
  51264. var axis = this,
  51265. brokenAxis = axis.brokenAxis;
  51266. if (brokenAxis &&
  51267. brokenAxis.hasBreaks) {
  51268. var tickPositions = axis.tickPositions,
  51269. info = axis.tickPositions.info,
  51270. newPositions = [];
  51271. for (var i = 0; i < tickPositions.length; i++) {
  51272. if (!brokenAxis.isInAnyBreak(tickPositions[i])) {
  51273. newPositions.push(tickPositions[i]);
  51274. }
  51275. }
  51276. axis.tickPositions = newPositions;
  51277. axis.tickPositions.info = info;
  51278. }
  51279. }
  51280. /**
  51281. * @private
  51282. */
  51283. function onInit() {
  51284. var axis = this;
  51285. if (!axis.brokenAxis) {
  51286. axis.brokenAxis = new Additions(axis);
  51287. }
  51288. }
  51289. /**
  51290. * @private
  51291. */
  51292. function onSeriesAfterGeneratePoints() {
  51293. var _a = this,
  51294. isDirty = _a.isDirty,
  51295. connectNulls = _a.options.connectNulls,
  51296. points = _a.points,
  51297. xAxis = _a.xAxis,
  51298. yAxis = _a.yAxis;
  51299. // Set, or reset visibility of the points. Axis.setBreaks marks
  51300. // the series as isDirty
  51301. if (isDirty) {
  51302. var i = points.length;
  51303. while (i--) {
  51304. var point = points[i];
  51305. // Respect nulls inside the break (#4275)
  51306. var nullGap = point.y === null && connectNulls === false;
  51307. var isPointInBreak = (!nullGap && ((xAxis &&
  51308. xAxis.brokenAxis &&
  51309. xAxis.brokenAxis.isInAnyBreak(point.x,
  51310. true)) || (yAxis &&
  51311. yAxis.brokenAxis &&
  51312. yAxis.brokenAxis.isInAnyBreak(point.y,
  51313. true))));
  51314. // Set point.visible if in any break.
  51315. // If not in break, reset visible to original value.
  51316. point.visible = isPointInBreak ?
  51317. false :
  51318. point.options.visible !== false;
  51319. }
  51320. }
  51321. }
  51322. /**
  51323. * @private
  51324. */
  51325. function onSeriesAfterRender() {
  51326. this.drawBreaks(this.xAxis, ['x']);
  51327. this.drawBreaks(this.yAxis, pick(this.pointArrayMap, ['y']));
  51328. }
  51329. /**
  51330. * @private
  51331. */
  51332. function seriesDrawBreaks(axis, keys) {
  51333. var series = this,
  51334. points = series.points;
  51335. var breaks,
  51336. threshold,
  51337. eventName,
  51338. y;
  51339. if (axis && // #5950
  51340. axis.brokenAxis &&
  51341. axis.brokenAxis.hasBreaks) {
  51342. var brokenAxis_1 = axis.brokenAxis;
  51343. keys.forEach(function (key) {
  51344. breaks = brokenAxis_1 && brokenAxis_1.breakArray || [];
  51345. threshold = axis.isXAxis ?
  51346. axis.min :
  51347. pick(series.options.threshold, axis.min);
  51348. points.forEach(function (point) {
  51349. y = pick(point['stack' + key.toUpperCase()], point[key]);
  51350. breaks.forEach(function (brk) {
  51351. if (isNumber(threshold) && isNumber(y)) {
  51352. eventName = false;
  51353. if ((threshold < brk.from && y > brk.to) ||
  51354. (threshold > brk.from && y < brk.from)) {
  51355. eventName = 'pointBreak';
  51356. }
  51357. else if ((threshold < brk.from && y > brk.from && y < brk.to) ||
  51358. (threshold > brk.from && y > brk.to && y < brk.from)) {
  51359. eventName = 'pointInBreak';
  51360. }
  51361. if (eventName) {
  51362. fireEvent(axis, eventName, { point: point, brk: brk });
  51363. }
  51364. }
  51365. });
  51366. });
  51367. });
  51368. }
  51369. }
  51370. /**
  51371. * Extend getGraphPath by identifying gaps in the data so that we
  51372. * can draw a gap in the line or area. This was moved from ordinal
  51373. * axis module to broken axis module as of #5045.
  51374. *
  51375. * @private
  51376. * @function Highcharts.Series#gappedPath
  51377. *
  51378. * @return {Highcharts.SVGPathArray}
  51379. * Gapped path
  51380. */
  51381. function seriesGappedPath() {
  51382. var currentDataGrouping = this.currentDataGrouping,
  51383. groupingSize = currentDataGrouping && currentDataGrouping.gapSize,
  51384. points = this.points.slice(),
  51385. yAxis = this.yAxis;
  51386. var gapSize = this.options.gapSize,
  51387. i = points.length - 1,
  51388. stack;
  51389. /**
  51390. * Defines when to display a gap in the graph, together with the
  51391. * [gapUnit](plotOptions.series.gapUnit) option.
  51392. *
  51393. * In case when `dataGrouping` is enabled, points can be grouped
  51394. * into a larger time span. This can make the grouped points to
  51395. * have a greater distance than the absolute value of `gapSize`
  51396. * property, which will result in disappearing graph completely.
  51397. * To prevent this situation the mentioned distance between
  51398. * grouped points is used instead of previously defined
  51399. * `gapSize`.
  51400. *
  51401. * In practice, this option is most often used to visualize gaps
  51402. * in time series. In a stock chart, intraday data is available
  51403. * for daytime hours, while gaps will appear in nights and
  51404. * weekends.
  51405. *
  51406. * @see [gapUnit](plotOptions.series.gapUnit)
  51407. * @see [xAxis.breaks](#xAxis.breaks)
  51408. *
  51409. * @sample {highstock} stock/plotoptions/series-gapsize/
  51410. * Setting the gap size to 2 introduces gaps for weekends in
  51411. * daily datasets.
  51412. *
  51413. * @type {number}
  51414. * @default 0
  51415. * @product highstock
  51416. * @requires modules/broken-axis
  51417. * @apioption plotOptions.series.gapSize
  51418. */
  51419. /**
  51420. * Together with [gapSize](plotOptions.series.gapSize), this
  51421. * option defines where to draw gaps in the graph.
  51422. *
  51423. * When the `gapUnit` is `"relative"` (default), a gap size of 5
  51424. * means that if the distance between two points is greater than
  51425. * 5 times that of the two closest points, the graph will be
  51426. * broken.
  51427. *
  51428. * When the `gapUnit` is `"value"`, the gap is based on absolute
  51429. * axis values, which on a datetime axis is milliseconds. This
  51430. * also applies to the navigator series that inherits gap
  51431. * options from the base series.
  51432. *
  51433. * @see [gapSize](plotOptions.series.gapSize)
  51434. *
  51435. * @type {string}
  51436. * @default relative
  51437. * @since 5.0.13
  51438. * @product highstock
  51439. * @validvalue ["relative", "value"]
  51440. * @requires modules/broken-axis
  51441. * @apioption plotOptions.series.gapUnit
  51442. */
  51443. if (gapSize && i > 0) { // #5008
  51444. // Gap unit is relative
  51445. if (this.options.gapUnit !== 'value') {
  51446. gapSize *= this.basePointRange;
  51447. }
  51448. // Setting a new gapSize in case dataGrouping is enabled
  51449. // (#7686)
  51450. if (groupingSize &&
  51451. groupingSize > gapSize &&
  51452. // Except when DG is forced (e.g. from other series)
  51453. // and has lower granularity than actual points (#11351)
  51454. groupingSize >= this.basePointRange) {
  51455. gapSize = groupingSize;
  51456. }
  51457. // extension for ordinal breaks
  51458. var current = void 0,
  51459. next = void 0;
  51460. while (i--) {
  51461. // Reassign next if it is not visible
  51462. if (!(next && next.visible !== false)) {
  51463. next = points[i + 1];
  51464. }
  51465. current = points[i];
  51466. // Skip iteration if one of the points is not visible
  51467. if (next.visible === false || current.visible === false) {
  51468. continue;
  51469. }
  51470. if (next.x - current.x > gapSize) {
  51471. var xRange = (current.x + next.x) / 2;
  51472. points.splice(// insert after this one
  51473. i + 1, 0, {
  51474. isNull: true,
  51475. x: xRange
  51476. });
  51477. // For stacked chart generate empty stack items,
  51478. // #6546
  51479. if (yAxis.stacking && this.options.stacking) {
  51480. stack = yAxis.stacking.stacks[this.stackKey][xRange] =
  51481. new StackItem(yAxis, yAxis.options
  51482. .stackLabels, false, xRange, this.stack);
  51483. stack.total = 0;
  51484. }
  51485. }
  51486. // Assign current to next for the upcoming iteration
  51487. next = current;
  51488. }
  51489. }
  51490. // Call base method
  51491. return this.getGraphPath(points);
  51492. }
  51493. /* *
  51494. *
  51495. * Class
  51496. *
  51497. * */
  51498. /**
  51499. * Provides support for broken axes.
  51500. * @private
  51501. * @class
  51502. */
  51503. var Additions = /** @class */ (function () {
  51504. /* *
  51505. *
  51506. * Constructors
  51507. *
  51508. * */
  51509. function Additions(axis) {
  51510. this.hasBreaks = false;
  51511. this.axis = axis;
  51512. }
  51513. /* *
  51514. *
  51515. * Static Functions
  51516. *
  51517. * */
  51518. /**
  51519. * @private
  51520. */
  51521. Additions.isInBreak = function (brk, val) {
  51522. var repeat = brk.repeat || Infinity,
  51523. from = brk.from,
  51524. length = brk.to - brk.from,
  51525. test = (val >= from ?
  51526. (val - from) % repeat :
  51527. repeat - ((from - val) % repeat));
  51528. var ret;
  51529. if (!brk.inclusive) {
  51530. ret = test < length && test !== 0;
  51531. }
  51532. else {
  51533. ret = test <= length;
  51534. }
  51535. return ret;
  51536. };
  51537. /**
  51538. * @private
  51539. */
  51540. Additions.lin2Val = function (val) {
  51541. var axis = this;
  51542. var brokenAxis = axis.brokenAxis;
  51543. var breakArray = brokenAxis && brokenAxis.breakArray;
  51544. if (!breakArray || !isNumber(val)) {
  51545. return val;
  51546. }
  51547. var nval = val,
  51548. brk,
  51549. i;
  51550. for (i = 0; i < breakArray.length; i++) {
  51551. brk = breakArray[i];
  51552. if (brk.from >= nval) {
  51553. break;
  51554. }
  51555. else if (brk.to < nval) {
  51556. nval += brk.len;
  51557. }
  51558. else if (Additions.isInBreak(brk, nval)) {
  51559. nval += brk.len;
  51560. }
  51561. }
  51562. return nval;
  51563. };
  51564. /**
  51565. * @private
  51566. */
  51567. Additions.val2Lin = function (val) {
  51568. var axis = this;
  51569. var brokenAxis = axis.brokenAxis;
  51570. var breakArray = brokenAxis && brokenAxis.breakArray;
  51571. if (!breakArray || !isNumber(val)) {
  51572. return val;
  51573. }
  51574. var nval = val,
  51575. brk,
  51576. i;
  51577. for (i = 0; i < breakArray.length; i++) {
  51578. brk = breakArray[i];
  51579. if (brk.to <= val) {
  51580. nval -= brk.len;
  51581. }
  51582. else if (brk.from >= val) {
  51583. break;
  51584. }
  51585. else if (Additions.isInBreak(brk, val)) {
  51586. nval -= (val - brk.from);
  51587. break;
  51588. }
  51589. }
  51590. return nval;
  51591. };
  51592. /* *
  51593. *
  51594. * Functions
  51595. *
  51596. * */
  51597. /**
  51598. * Returns the first break found where the x is larger then break.from
  51599. * and smaller then break.to.
  51600. *
  51601. * @param {number} x
  51602. * The number which should be within a break.
  51603. *
  51604. * @param {Array<Highcharts.XAxisBreaksOptions>} breaks
  51605. * The array of breaks to search within.
  51606. *
  51607. * @return {Highcharts.XAxisBreaksOptions|undefined}
  51608. * Returns the first break found that matches, returns false if no break
  51609. * is found.
  51610. */
  51611. Additions.prototype.findBreakAt = function (x, breaks) {
  51612. return find(breaks, function (b) {
  51613. return b.from < x && x < b.to;
  51614. });
  51615. };
  51616. /**
  51617. * @private
  51618. */
  51619. Additions.prototype.isInAnyBreak = function (val, testKeep) {
  51620. var brokenAxis = this,
  51621. axis = brokenAxis.axis,
  51622. breaks = axis.options.breaks || [];
  51623. var i = breaks.length,
  51624. inbrk,
  51625. keep,
  51626. ret;
  51627. if (i && isNumber(val)) {
  51628. while (i--) {
  51629. if (Additions.isInBreak(breaks[i], val)) {
  51630. inbrk = true;
  51631. if (!keep) {
  51632. keep = pick(breaks[i].showPoints, !axis.isXAxis);
  51633. }
  51634. }
  51635. }
  51636. if (inbrk && testKeep) {
  51637. ret = inbrk && !keep;
  51638. }
  51639. else {
  51640. ret = inbrk;
  51641. }
  51642. }
  51643. return ret;
  51644. };
  51645. /**
  51646. * Dynamically set or unset breaks in an axis. This function in lighter
  51647. * than usin Axis.update, and it also preserves animation.
  51648. *
  51649. * @private
  51650. * @function Highcharts.Axis#setBreaks
  51651. *
  51652. * @param {Array<Highcharts.XAxisBreaksOptions>} [breaks]
  51653. * The breaks to add. When `undefined` it removes existing breaks.
  51654. *
  51655. * @param {boolean} [redraw=true]
  51656. * Whether to redraw the chart immediately.
  51657. */
  51658. Additions.prototype.setBreaks = function (breaks, redraw) {
  51659. var brokenAxis = this;
  51660. var axis = brokenAxis.axis;
  51661. var hasBreaks = (isArray(breaks) && !!breaks.length);
  51662. axis.isDirty = brokenAxis.hasBreaks !== hasBreaks;
  51663. brokenAxis.hasBreaks = hasBreaks;
  51664. axis.options.breaks = axis.userOptions.breaks = breaks;
  51665. axis.forceRedraw = true; // Force recalculation in setScale
  51666. // Recalculate series related to the axis.
  51667. axis.series.forEach(function (series) {
  51668. series.isDirty = true;
  51669. });
  51670. if (!hasBreaks && axis.val2lin === Additions.val2Lin) {
  51671. // Revert to prototype functions
  51672. delete axis.val2lin;
  51673. delete axis.lin2val;
  51674. }
  51675. if (hasBreaks) {
  51676. axis.userOptions.ordinal = false;
  51677. axis.lin2val = Additions.lin2Val;
  51678. axis.val2lin = Additions.val2Lin;
  51679. axis.setExtremes = function (newMin, newMax, redraw, animation, eventArguments) {
  51680. // If trying to set extremes inside a break, extend min to
  51681. // after, and max to before the break ( #3857 )
  51682. if (brokenAxis.hasBreaks) {
  51683. var breaks_1 = (this.options.breaks || []);
  51684. var axisBreak = void 0;
  51685. while ((axisBreak = brokenAxis.findBreakAt(newMin, breaks_1))) {
  51686. newMin = axisBreak.to;
  51687. }
  51688. while ((axisBreak = brokenAxis.findBreakAt(newMax, breaks_1))) {
  51689. newMax = axisBreak.from;
  51690. }
  51691. // If both min and max is within the same break.
  51692. if (newMax < newMin) {
  51693. newMax = newMin;
  51694. }
  51695. }
  51696. Axis.prototype.setExtremes.call(this, newMin, newMax, redraw, animation, eventArguments);
  51697. };
  51698. axis.setAxisTranslation = function () {
  51699. Axis.prototype.setAxisTranslation.call(this);
  51700. brokenAxis.unitLength = void 0;
  51701. if (brokenAxis.hasBreaks) {
  51702. var breaks_2 = axis.options.breaks || [],
  51703. // Temporary one:
  51704. breakArrayT_1 = [],
  51705. breakArray_1 = [],
  51706. pointRangePadding = pick(axis.pointRangePadding, 0);
  51707. var length_1 = 0,
  51708. inBrk_1,
  51709. repeat_1,
  51710. min_1 = axis.userMin || axis.min,
  51711. max_1 = axis.userMax || axis.max,
  51712. start_1,
  51713. i_1;
  51714. // Min & max check (#4247)
  51715. breaks_2.forEach(function (brk) {
  51716. repeat_1 = brk.repeat || Infinity;
  51717. if (isNumber(min_1) && isNumber(max_1)) {
  51718. if (Additions.isInBreak(brk, min_1)) {
  51719. min_1 += (brk.to % repeat_1) - (min_1 % repeat_1);
  51720. }
  51721. if (Additions.isInBreak(brk, max_1)) {
  51722. max_1 -= (max_1 % repeat_1) - (brk.from % repeat_1);
  51723. }
  51724. }
  51725. });
  51726. // Construct an array holding all breaks in the axis
  51727. breaks_2.forEach(function (brk) {
  51728. start_1 = brk.from;
  51729. repeat_1 = brk.repeat || Infinity;
  51730. if (isNumber(min_1) && isNumber(max_1)) {
  51731. while (start_1 - repeat_1 > min_1) {
  51732. start_1 -= repeat_1;
  51733. }
  51734. while (start_1 < min_1) {
  51735. start_1 += repeat_1;
  51736. }
  51737. for (i_1 = start_1; i_1 < max_1; i_1 += repeat_1) {
  51738. breakArrayT_1.push({
  51739. value: i_1,
  51740. move: 'in'
  51741. });
  51742. breakArrayT_1.push({
  51743. value: i_1 + brk.to - brk.from,
  51744. move: 'out',
  51745. size: brk.breakSize
  51746. });
  51747. }
  51748. }
  51749. });
  51750. breakArrayT_1.sort(function (a, b) {
  51751. return ((a.value === b.value) ?
  51752. ((a.move === 'in' ? 0 : 1) -
  51753. (b.move === 'in' ? 0 : 1)) :
  51754. a.value - b.value);
  51755. });
  51756. // Simplify the breaks
  51757. inBrk_1 = 0;
  51758. start_1 = min_1;
  51759. breakArrayT_1.forEach(function (brk) {
  51760. inBrk_1 += (brk.move === 'in' ? 1 : -1);
  51761. if (inBrk_1 === 1 && brk.move === 'in') {
  51762. start_1 = brk.value;
  51763. }
  51764. if (inBrk_1 === 0 && isNumber(start_1)) {
  51765. breakArray_1.push({
  51766. from: start_1,
  51767. to: brk.value,
  51768. len: brk.value - start_1 - (brk.size || 0)
  51769. });
  51770. length_1 += brk.value - start_1 - (brk.size || 0);
  51771. }
  51772. });
  51773. brokenAxis.breakArray = breakArray_1;
  51774. // Used with staticScale, and below the actual axis
  51775. // length, when breaks are substracted.
  51776. if (isNumber(min_1) && isNumber(max_1) && isNumber(axis.min)) {
  51777. brokenAxis.unitLength = max_1 - min_1 - length_1 +
  51778. pointRangePadding;
  51779. fireEvent(axis, 'afterBreaks');
  51780. if (axis.staticScale) {
  51781. axis.transA = axis.staticScale;
  51782. }
  51783. else if (brokenAxis.unitLength) {
  51784. axis.transA *=
  51785. (max_1 - axis.min + pointRangePadding) /
  51786. brokenAxis.unitLength;
  51787. }
  51788. if (pointRangePadding) {
  51789. axis.minPixelPadding =
  51790. axis.transA * (axis.minPointOffset || 0);
  51791. }
  51792. axis.min = min_1;
  51793. axis.max = max_1;
  51794. }
  51795. }
  51796. };
  51797. }
  51798. if (pick(redraw, true)) {
  51799. axis.chart.redraw();
  51800. }
  51801. };
  51802. return Additions;
  51803. }());
  51804. BrokenAxis.Additions = Additions;
  51805. })(BrokenAxis || (BrokenAxis = {}));
  51806. /* *
  51807. *
  51808. * Default Export
  51809. *
  51810. * */
  51811. return BrokenAxis;
  51812. });
  51813. _registerModule(_modules, 'masters/modules/broken-axis.src.js', [_modules['Core/Globals.js'], _modules['Core/Axis/BrokenAxis.js']], function (Highcharts, BrokenAxis) {
  51814. var G = Highcharts;
  51815. // Compositions
  51816. BrokenAxis.compose(G.Axis, G.Series);
  51817. });
  51818. _registerModule(_modules, 'Extensions/DataGrouping.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Axis/DateTimeAxis.js'], _modules['Core/FormatUtilities.js'], _modules['Core/Globals.js'], _modules['Core/Series/Point.js'], _modules['Core/Series/Series.js'], _modules['Core/Tooltip.js'], _modules['Core/DefaultOptions.js'], _modules['Core/Utilities.js']], function (Axis, DateTimeAxis, F, H, Point, Series, Tooltip, D, U) {
  51819. /* *
  51820. *
  51821. * (c) 2010-2021 Torstein Honsi
  51822. *
  51823. * License: www.highcharts.com/license
  51824. *
  51825. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  51826. *
  51827. * */
  51828. var format = F.format;
  51829. var seriesProto = Series.prototype;
  51830. var addEvent = U.addEvent,
  51831. arrayMax = U.arrayMax,
  51832. arrayMin = U.arrayMin,
  51833. correctFloat = U.correctFloat,
  51834. defined = U.defined,
  51835. error = U.error,
  51836. extend = U.extend,
  51837. isNumber = U.isNumber,
  51838. merge = U.merge,
  51839. pick = U.pick;
  51840. /**
  51841. * @typedef {"average"|"averages"|"open"|"high"|"low"|"close"|"sum"} Highcharts.DataGroupingApproximationValue
  51842. */
  51843. /**
  51844. * The position of the point inside the group.
  51845. *
  51846. * @typedef {"start"|"middle"|"end"} Highcharts.DataGroupingAnchor
  51847. */
  51848. /**
  51849. * The position of the first or last point in the series inside the group.
  51850. *
  51851. * @typedef {"start"|"middle"|"end"|"firstPoint"|"lastPoint"} Highcharts.DataGroupingAnchorExtremes
  51852. */
  51853. /**
  51854. * @interface Highcharts.DataGroupingInfoObject
  51855. */ /**
  51856. * @name Highcharts.DataGroupingInfoObject#length
  51857. * @type {number}
  51858. */ /**
  51859. * @name Highcharts.DataGroupingInfoObject#options
  51860. * @type {Highcharts.SeriesOptionsType|undefined}
  51861. */ /**
  51862. * @name Highcharts.DataGroupingInfoObject#start
  51863. * @type {number}
  51864. */
  51865. ''; // detach doclets above
  51866. /* ************************************************************************** *
  51867. * Start data grouping module *
  51868. * ************************************************************************** */
  51869. /* eslint-disable no-invalid-this, valid-jsdoc */
  51870. /**
  51871. * Define the available approximation types. The data grouping
  51872. * approximations takes an array or numbers as the first parameter. In case
  51873. * of ohlc, four arrays are sent in as four parameters. Each array consists
  51874. * only of numbers. In case null values belong to the group, the property
  51875. * .hasNulls will be set to true on the array.
  51876. *
  51877. * @product highstock
  51878. *
  51879. * @private
  51880. * @name Highcharts.approximations
  51881. * @type {Highcharts.Dictionary<Function>}
  51882. */
  51883. var approximations = H.approximations = {
  51884. sum: function (arr) {
  51885. var len = arr.length,
  51886. ret;
  51887. // 1. it consists of nulls exclusive
  51888. if (!len && arr.hasNulls) {
  51889. ret = null;
  51890. // 2. it has a length and real values
  51891. }
  51892. else if (len) {
  51893. ret = 0;
  51894. while (len--) {
  51895. ret += arr[len];
  51896. }
  51897. }
  51898. // 3. it has zero length, so just return undefined
  51899. // => doNothing()
  51900. return ret;
  51901. },
  51902. average: function (arr) {
  51903. var len = arr.length,
  51904. ret = approximations.sum(arr);
  51905. // If we have a number, return it divided by the length. If not,
  51906. // return null or undefined based on what the sum method finds.
  51907. if (isNumber(ret) && len) {
  51908. ret = correctFloat(ret / len);
  51909. }
  51910. return ret;
  51911. },
  51912. // The same as average, but for series with multiple values, like area
  51913. // ranges.
  51914. averages: function () {
  51915. var ret = [];
  51916. [].forEach.call(arguments, function (arr) {
  51917. ret.push(approximations.average(arr));
  51918. });
  51919. // Return undefined when first elem. is undefined and let
  51920. // sum method handle null (#7377)
  51921. return typeof ret[0] === 'undefined' ? void 0 : ret;
  51922. },
  51923. open: function (arr) {
  51924. return arr.length ? arr[0] : (arr.hasNulls ? null : void 0);
  51925. },
  51926. high: function (arr) {
  51927. return arr.length ?
  51928. arrayMax(arr) :
  51929. (arr.hasNulls ? null : void 0);
  51930. },
  51931. low: function (arr) {
  51932. return arr.length ?
  51933. arrayMin(arr) :
  51934. (arr.hasNulls ? null : void 0);
  51935. },
  51936. close: function (arr) {
  51937. return arr.length ?
  51938. arr[arr.length - 1] :
  51939. (arr.hasNulls ? null : void 0);
  51940. },
  51941. // ohlc and range are special cases where a multidimensional array is
  51942. // input and an array is output
  51943. ohlc: function (open, high, low, close) {
  51944. open = approximations.open(open);
  51945. high = approximations.high(high);
  51946. low = approximations.low(low);
  51947. close = approximations.close(close);
  51948. if (isNumber(open) ||
  51949. isNumber(high) ||
  51950. isNumber(low) ||
  51951. isNumber(close)) {
  51952. return [open, high, low, close];
  51953. }
  51954. // else, return is undefined
  51955. },
  51956. range: function (low, high) {
  51957. low = approximations.low(low);
  51958. high = approximations.high(high);
  51959. if (isNumber(low) || isNumber(high)) {
  51960. return [low, high];
  51961. }
  51962. if (low === null && high === null) {
  51963. return null;
  51964. }
  51965. // else, return is undefined
  51966. }
  51967. };
  51968. var groupData = function (xData,
  51969. yData,
  51970. groupPositions,
  51971. approximation) {
  51972. var series = this,
  51973. data = series.data,
  51974. dataOptions = series.options && series.options.data,
  51975. groupedXData = [],
  51976. groupedYData = [],
  51977. groupMap = [],
  51978. dataLength = xData.length,
  51979. pointX,
  51980. pointY,
  51981. groupedY,
  51982. // when grouping the fake extended axis for panning,
  51983. // we don't need to consider y
  51984. handleYData = !!yData,
  51985. values = [],
  51986. approximationFn,
  51987. pointArrayMap = series.pointArrayMap,
  51988. pointArrayMapLength = pointArrayMap && pointArrayMap.length,
  51989. extendedPointArrayMap = ['x'].concat(pointArrayMap || ['y']),
  51990. groupAll = this.options.dataGrouping && this.options.dataGrouping.groupAll,
  51991. pos = 0,
  51992. start = 0,
  51993. valuesLen,
  51994. i,
  51995. j;
  51996. /**
  51997. * @private
  51998. */
  51999. function getApproximation(approx) {
  52000. if (typeof approx === 'function') {
  52001. return approx;
  52002. }
  52003. if (approximations[approx]) {
  52004. return approximations[approx];
  52005. }
  52006. return approximations[(series.getDGApproximation && series.getDGApproximation()) ||
  52007. 'average'];
  52008. }
  52009. approximationFn = getApproximation(approximation);
  52010. // Calculate values array size from pointArrayMap length
  52011. if (pointArrayMapLength) {
  52012. pointArrayMap.forEach(function () {
  52013. values.push([]);
  52014. });
  52015. }
  52016. else {
  52017. values.push([]);
  52018. }
  52019. valuesLen = pointArrayMapLength || 1;
  52020. // Start with the first point within the X axis range (#2696)
  52021. for (i = 0; i <= dataLength; i++) {
  52022. if (xData[i] >= groupPositions[0]) {
  52023. break;
  52024. }
  52025. }
  52026. for (i; i <= dataLength; i++) {
  52027. // when a new group is entered, summarize and initialize
  52028. // the previous group
  52029. while ((typeof groupPositions[pos + 1] !== 'undefined' &&
  52030. xData[i] >= groupPositions[pos + 1]) ||
  52031. i === dataLength) { // get the last group
  52032. // get group x and y
  52033. pointX = groupPositions[pos];
  52034. series.dataGroupInfo = {
  52035. start: groupAll ? start : (series.cropStart + start),
  52036. length: values[0].length
  52037. };
  52038. groupedY = approximationFn.apply(series, values);
  52039. // By default, let options of the first grouped point be passed over
  52040. // to the grouped point. This allows preserving properties like
  52041. // `name` and `color` or custom properties. Implementers can
  52042. // override this from the approximation function, where they can
  52043. // write custom options to `this.dataGroupInfo.options`.
  52044. if (series.pointClass && !defined(series.dataGroupInfo.options)) {
  52045. // Convert numbers and arrays into objects
  52046. series.dataGroupInfo.options = merge(series.pointClass.prototype
  52047. .optionsToObject.call({ series: series }, series.options.data[series.cropStart + start]));
  52048. // Make sure the raw data (x, y, open, high etc) is not copied
  52049. // over and overwriting approximated data.
  52050. extendedPointArrayMap.forEach(function (key) {
  52051. delete series.dataGroupInfo.options[key];
  52052. });
  52053. }
  52054. // push the grouped data
  52055. if (typeof groupedY !== 'undefined') {
  52056. groupedXData.push(pointX);
  52057. groupedYData.push(groupedY);
  52058. groupMap.push(series.dataGroupInfo);
  52059. }
  52060. // reset the aggregate arrays
  52061. start = i;
  52062. for (j = 0; j < valuesLen; j++) {
  52063. values[j].length = 0; // faster than values[j] = []
  52064. values[j].hasNulls = false;
  52065. }
  52066. // Advance on the group positions
  52067. pos += 1;
  52068. // don't loop beyond the last group
  52069. if (i === dataLength) {
  52070. break;
  52071. }
  52072. }
  52073. // break out
  52074. if (i === dataLength) {
  52075. break;
  52076. }
  52077. // for each raw data point, push it to an array that contains all values
  52078. // for this specific group
  52079. if (pointArrayMap) {
  52080. var index = (series.options.dataGrouping &&
  52081. series.options.dataGrouping.groupAll ?
  52082. i : series.cropStart + i),
  52083. point = (data && data[index]) ||
  52084. series.pointClass.prototype.applyOptions.apply({
  52085. series: series
  52086. },
  52087. [dataOptions[index]]),
  52088. val = void 0;
  52089. for (j = 0; j < pointArrayMapLength; j++) {
  52090. val = point[pointArrayMap[j]];
  52091. if (isNumber(val)) {
  52092. values[j].push(val);
  52093. }
  52094. else if (val === null) {
  52095. values[j].hasNulls = true;
  52096. }
  52097. }
  52098. }
  52099. else {
  52100. pointY = handleYData ? yData[i] : null;
  52101. if (isNumber(pointY)) {
  52102. values[0].push(pointY);
  52103. }
  52104. else if (pointY === null) {
  52105. values[0].hasNulls = true;
  52106. }
  52107. }
  52108. }
  52109. return {
  52110. groupedXData: groupedXData,
  52111. groupedYData: groupedYData,
  52112. groupMap: groupMap
  52113. };
  52114. };
  52115. var anchorPoints = function (series,
  52116. groupedXData,
  52117. xMax) {
  52118. var options = series.options,
  52119. dataGroupingOptions = options.dataGrouping,
  52120. totalRange = series.currentDataGrouping && series.currentDataGrouping.gapSize;
  52121. var i;
  52122. // DataGrouping x-coordinates.
  52123. if (dataGroupingOptions && series.xData && totalRange && series.groupMap) {
  52124. var groupedDataLength = groupedXData.length - 1,
  52125. anchor = dataGroupingOptions.anchor,
  52126. firstAnchor = pick(dataGroupingOptions.firstAnchor,
  52127. anchor),
  52128. lastAnchor = pick(dataGroupingOptions.lastAnchor,
  52129. anchor);
  52130. // Anchor points that are not extremes.
  52131. if (anchor && anchor !== 'start') {
  52132. var shiftInterval = totalRange *
  52133. { middle: 0.5,
  52134. end: 1 }[anchor];
  52135. i = groupedXData.length - 1;
  52136. while (i-- && i > 0) {
  52137. groupedXData[i] += shiftInterval;
  52138. }
  52139. }
  52140. // Change the first point position, but only when it is
  52141. // the first point in the data set not in the current zoom.
  52142. if (firstAnchor &&
  52143. firstAnchor !== 'start' &&
  52144. series.xData[0] >= groupedXData[0]) {
  52145. var groupStart = series.groupMap[0].start,
  52146. groupLength = series.groupMap[0].length;
  52147. var firstGroupstEnd = void 0;
  52148. if (isNumber(groupStart) && isNumber(groupLength)) {
  52149. firstGroupstEnd = groupStart + (groupLength - 1);
  52150. }
  52151. groupedXData[0] = {
  52152. middle: groupedXData[0] + 0.5 * totalRange,
  52153. end: groupedXData[0] + totalRange,
  52154. firstPoint: series.xData[0],
  52155. lastPoint: firstGroupstEnd && series.xData[firstGroupstEnd]
  52156. }[firstAnchor];
  52157. }
  52158. // Change the last point position but only when it is
  52159. // the last point in the data set not in the current zoom.
  52160. if (lastAnchor &&
  52161. lastAnchor !== 'start' &&
  52162. totalRange &&
  52163. groupedXData[groupedDataLength] >= xMax - totalRange) {
  52164. var lastGroupStart = series.groupMap[series.groupMap.length - 1].start;
  52165. groupedXData[groupedDataLength] = {
  52166. middle: groupedXData[groupedDataLength] + 0.5 * totalRange,
  52167. end: groupedXData[groupedDataLength] + totalRange,
  52168. firstPoint: lastGroupStart && series.xData[lastGroupStart],
  52169. lastPoint: series.xData[series.xData.length - 1]
  52170. }[lastAnchor];
  52171. }
  52172. }
  52173. };
  52174. var adjustExtremes = function (xAxis,
  52175. groupedXData) {
  52176. // Make sure the X axis extends to show the first group (#2533)
  52177. // But only for visible series (#5493, #6393)
  52178. if (defined(groupedXData[0]) &&
  52179. isNumber(xAxis.min) &&
  52180. isNumber(xAxis.dataMin) &&
  52181. groupedXData[0] < xAxis.min) {
  52182. if ((!defined(xAxis.options.min) &&
  52183. xAxis.min <= xAxis.dataMin) ||
  52184. xAxis.min === xAxis.dataMin) {
  52185. xAxis.min = Math.min(groupedXData[0],
  52186. xAxis.min);
  52187. }
  52188. xAxis.dataMin = Math.min(groupedXData[0], xAxis.dataMin);
  52189. }
  52190. // When the last anchor set, change the extremes that
  52191. // the last point is visible (#12455).
  52192. if (defined(groupedXData[groupedXData.length - 1]) &&
  52193. isNumber(xAxis.max) &&
  52194. isNumber(xAxis.dataMax) &&
  52195. groupedXData[groupedXData.length - 1] > xAxis.max) {
  52196. if ((!defined(xAxis.options.max) &&
  52197. isNumber(xAxis.dataMax) &&
  52198. xAxis.max >= xAxis.dataMax) || xAxis.max === xAxis.dataMax) {
  52199. xAxis.max = Math.max(groupedXData[groupedXData.length - 1], xAxis.max);
  52200. }
  52201. xAxis.dataMax = Math.max(groupedXData[groupedXData.length - 1], xAxis.dataMax);
  52202. }
  52203. };
  52204. var dataGrouping = {
  52205. approximations: approximations,
  52206. groupData: groupData
  52207. };
  52208. // -----------------------------------------------------------------------------
  52209. // The following code applies to implementation of data grouping on a Series
  52210. var baseProcessData = seriesProto.processData, baseGeneratePoints = seriesProto.generatePoints,
  52211. /** @ignore */
  52212. commonOptions = {
  52213. // enabled: null, // (true for stock charts, false for basic),
  52214. // forced: undefined,
  52215. groupPixelWidth: 2,
  52216. // the first one is the point or start value, the second is the start
  52217. // value if we're dealing with range, the third one is the end value if
  52218. // dealing with a range
  52219. dateTimeLabelFormats: {
  52220. millisecond: [
  52221. '%A, %b %e, %H:%M:%S.%L',
  52222. '%A, %b %e, %H:%M:%S.%L',
  52223. '-%H:%M:%S.%L'
  52224. ],
  52225. second: [
  52226. '%A, %b %e, %H:%M:%S',
  52227. '%A, %b %e, %H:%M:%S',
  52228. '-%H:%M:%S'
  52229. ],
  52230. minute: [
  52231. '%A, %b %e, %H:%M',
  52232. '%A, %b %e, %H:%M',
  52233. '-%H:%M'
  52234. ],
  52235. hour: [
  52236. '%A, %b %e, %H:%M',
  52237. '%A, %b %e, %H:%M',
  52238. '-%H:%M'
  52239. ],
  52240. day: [
  52241. '%A, %b %e, %Y',
  52242. '%A, %b %e',
  52243. '-%A, %b %e, %Y'
  52244. ],
  52245. week: [
  52246. 'Week from %A, %b %e, %Y',
  52247. '%A, %b %e',
  52248. '-%A, %b %e, %Y'
  52249. ],
  52250. month: [
  52251. '%B %Y',
  52252. '%B',
  52253. '-%B %Y'
  52254. ],
  52255. year: [
  52256. '%Y',
  52257. '%Y',
  52258. '-%Y'
  52259. ]
  52260. }
  52261. // smoothed = false, // enable this for navigator series only
  52262. }, specificOptions = {
  52263. line: {},
  52264. spline: {},
  52265. area: {},
  52266. areaspline: {},
  52267. arearange: {},
  52268. column: {
  52269. groupPixelWidth: 10
  52270. },
  52271. columnrange: {
  52272. groupPixelWidth: 10
  52273. },
  52274. candlestick: {
  52275. groupPixelWidth: 10
  52276. },
  52277. ohlc: {
  52278. groupPixelWidth: 5
  52279. }
  52280. },
  52281. // units are defined in a separate array to allow complete overriding in
  52282. // case of a user option
  52283. defaultDataGroupingUnits = H.defaultDataGroupingUnits = [
  52284. [
  52285. 'millisecond',
  52286. [1, 2, 5, 10, 20, 25, 50, 100, 200, 500] // allowed multiples
  52287. ], [
  52288. 'second',
  52289. [1, 2, 5, 10, 15, 30]
  52290. ], [
  52291. 'minute',
  52292. [1, 2, 5, 10, 15, 30]
  52293. ], [
  52294. 'hour',
  52295. [1, 2, 3, 4, 6, 8, 12]
  52296. ], [
  52297. 'day',
  52298. [1]
  52299. ], [
  52300. 'week',
  52301. [1]
  52302. ], [
  52303. 'month',
  52304. [1, 3, 6]
  52305. ], [
  52306. 'year',
  52307. null
  52308. ]
  52309. ];
  52310. // Set default approximations to the prototypes if present. Properties are
  52311. // inherited down. Can be overridden for individual series types.
  52312. seriesProto.getDGApproximation = function () {
  52313. if (this.is('arearange')) {
  52314. return 'range';
  52315. }
  52316. if (this.is('ohlc')) {
  52317. return 'ohlc';
  52318. }
  52319. if (this.is('column')) {
  52320. return 'sum';
  52321. }
  52322. return 'average';
  52323. };
  52324. /**
  52325. * Takes parallel arrays of x and y data and groups the data into intervals
  52326. * defined by groupPositions, a collection of starting x values for each group.
  52327. *
  52328. * @private
  52329. * @function Highcharts.Series#groupData
  52330. *
  52331. * @param {Array<number>} xData
  52332. *
  52333. * @param {Array<number>|Array<Array<number>>} yData
  52334. *
  52335. * @param {boolean} groupPositions
  52336. *
  52337. * @param {string|Function} approximation
  52338. *
  52339. * @return {void}
  52340. */
  52341. seriesProto.groupData = groupData;
  52342. // Extend the basic processData method, that crops the data to the current zoom
  52343. // range, with data grouping logic.
  52344. seriesProto.processData = function () {
  52345. var series = this,
  52346. chart = series.chart,
  52347. options = series.options,
  52348. dataGroupingOptions = options.dataGrouping,
  52349. groupingEnabled = series.allowDG !== false && dataGroupingOptions &&
  52350. pick(dataGroupingOptions.enabled,
  52351. chart.options.isStock),
  52352. visible = (series.visible || !chart.options.chart.ignoreHiddenSeries),
  52353. hasGroupedData,
  52354. skip,
  52355. lastDataGrouping = this.currentDataGrouping,
  52356. currentDataGrouping,
  52357. croppedData,
  52358. revertRequireSorting = false;
  52359. // Run base method
  52360. series.forceCrop = groupingEnabled; // #334
  52361. series.groupPixelWidth = null; // #2110
  52362. series.hasProcessed = true; // #2692
  52363. // Data needs to be sorted for dataGrouping
  52364. if (groupingEnabled && !series.requireSorting) {
  52365. series.requireSorting = revertRequireSorting = true;
  52366. }
  52367. // Skip if processData returns false or if grouping is disabled (in that
  52368. // order)
  52369. skip = (baseProcessData.apply(series, arguments) === false ||
  52370. !groupingEnabled);
  52371. // Revert original requireSorting value if changed
  52372. if (revertRequireSorting) {
  52373. series.requireSorting = false;
  52374. }
  52375. if (!skip) {
  52376. series.destroyGroupedData();
  52377. var i = void 0,
  52378. processedXData = dataGroupingOptions.groupAll ?
  52379. series.xData :
  52380. series.processedXData,
  52381. processedYData = dataGroupingOptions.groupAll ?
  52382. series.yData :
  52383. series.processedYData,
  52384. plotSizeX = chart.plotSizeX,
  52385. xAxis = series.xAxis,
  52386. ordinal = xAxis.options.ordinal,
  52387. groupPixelWidth = series.groupPixelWidth =
  52388. xAxis.getGroupPixelWidth && xAxis.getGroupPixelWidth();
  52389. // Execute grouping if the amount of points is greater than the limit
  52390. // defined in groupPixelWidth
  52391. if (groupPixelWidth &&
  52392. processedXData &&
  52393. processedXData.length) {
  52394. hasGroupedData = true;
  52395. // Force recreation of point instances in series.translate, #5699
  52396. series.isDirty = true;
  52397. series.points = null; // #6709
  52398. var extremes = xAxis.getExtremes(),
  52399. xMin = extremes.min,
  52400. xMax = extremes.max,
  52401. groupIntervalFactor = (ordinal &&
  52402. xAxis.ordinal &&
  52403. xAxis.ordinal.getGroupIntervalFactor(xMin,
  52404. xMax,
  52405. series)) || 1,
  52406. interval = (groupPixelWidth * (xMax - xMin) / plotSizeX) *
  52407. groupIntervalFactor,
  52408. groupPositions = xAxis.getTimeTicks(DateTimeAxis.AdditionsClass.prototype.normalizeTimeTickInterval(interval,
  52409. dataGroupingOptions.units ||
  52410. defaultDataGroupingUnits),
  52411. // Processed data may extend beyond axis (#4907)
  52412. Math.min(xMin,
  52413. processedXData[0]),
  52414. Math.max(xMax,
  52415. processedXData[processedXData.length - 1]),
  52416. xAxis.options.startOfWeek,
  52417. processedXData,
  52418. series.closestPointRange),
  52419. groupedData = seriesProto.groupData.apply(series,
  52420. [
  52421. processedXData,
  52422. processedYData,
  52423. groupPositions,
  52424. dataGroupingOptions.approximation
  52425. ]),
  52426. groupedXData = groupedData.groupedXData,
  52427. groupedYData = groupedData.groupedYData,
  52428. gapSize = 0;
  52429. // The smoothed option is deprecated, instead,
  52430. // there is a fallback to the new anchoring mechanism. #12455.
  52431. if (dataGroupingOptions && dataGroupingOptions.smoothed && groupedXData.length) {
  52432. dataGroupingOptions.firstAnchor = 'firstPoint';
  52433. dataGroupingOptions.anchor = 'middle';
  52434. dataGroupingOptions.lastAnchor = 'lastPoint';
  52435. error(32, false, chart, { 'dataGrouping.smoothed': 'use dataGrouping.anchor' });
  52436. }
  52437. anchorPoints(series, groupedXData, xMax);
  52438. // Record what data grouping values were used
  52439. for (i = 1; i < groupPositions.length; i++) {
  52440. // The grouped gapSize needs to be the largest distance between
  52441. // the group to capture varying group sizes like months or DST
  52442. // crossing (#10000). Also check that the gap is not at the
  52443. // start of a segment.
  52444. if (!groupPositions.info.segmentStarts ||
  52445. groupPositions.info.segmentStarts.indexOf(i) === -1) {
  52446. gapSize = Math.max(groupPositions[i] - groupPositions[i - 1], gapSize);
  52447. }
  52448. }
  52449. currentDataGrouping = groupPositions.info;
  52450. currentDataGrouping.gapSize = gapSize;
  52451. series.closestPointRange = groupPositions.info.totalRange;
  52452. series.groupMap = groupedData.groupMap;
  52453. if (visible) {
  52454. adjustExtremes(xAxis, groupedXData);
  52455. }
  52456. // We calculated all group positions but we should render
  52457. // only the ones within the visible range
  52458. if (dataGroupingOptions.groupAll) {
  52459. croppedData = series.cropData(groupedXData, groupedYData, xAxis.min, xAxis.max, 1 // Ordinal xAxis will remove left-most points otherwise
  52460. );
  52461. groupedXData = croppedData.xData;
  52462. groupedYData = croppedData.yData;
  52463. series.cropStart = croppedData.start; // #15005
  52464. }
  52465. // Set series props
  52466. series.processedXData = groupedXData;
  52467. series.processedYData = groupedYData;
  52468. }
  52469. else {
  52470. series.groupMap = null;
  52471. }
  52472. series.hasGroupedData = hasGroupedData;
  52473. series.currentDataGrouping = currentDataGrouping;
  52474. series.preventGraphAnimation =
  52475. (lastDataGrouping && lastDataGrouping.totalRange) !==
  52476. (currentDataGrouping && currentDataGrouping.totalRange);
  52477. }
  52478. };
  52479. // Destroy the grouped data points. #622, #740
  52480. seriesProto.destroyGroupedData = function () {
  52481. // Clear previous groups
  52482. if (this.groupedData) {
  52483. this.groupedData.forEach(function (point, i) {
  52484. if (point) {
  52485. this.groupedData[i] = point.destroy ?
  52486. point.destroy() : null;
  52487. }
  52488. }, this);
  52489. // Clears all:
  52490. // - `this.groupedData`
  52491. // - `this.points`
  52492. // - `preserve` object in series.update()
  52493. this.groupedData.length = 0;
  52494. }
  52495. };
  52496. // Override the generatePoints method by adding a reference to grouped data
  52497. seriesProto.generatePoints = function () {
  52498. baseGeneratePoints.apply(this);
  52499. // Record grouped data in order to let it be destroyed the next time
  52500. // processData runs
  52501. this.destroyGroupedData(); // #622
  52502. this.groupedData = this.hasGroupedData ? this.points : null;
  52503. };
  52504. // Override point prototype to throw a warning when trying to update grouped
  52505. // points.
  52506. addEvent(Point, 'update', function () {
  52507. if (this.dataGroup) {
  52508. error(24, false, this.series.chart);
  52509. return false;
  52510. }
  52511. });
  52512. // Extend the original method, make the tooltip's header reflect the grouped
  52513. // range.
  52514. addEvent(Tooltip, 'headerFormatter', function (e) {
  52515. var tooltip = this,
  52516. chart = this.chart,
  52517. time = chart.time,
  52518. labelConfig = e.labelConfig,
  52519. series = labelConfig.series,
  52520. options = series.options,
  52521. tooltipOptions = series.tooltipOptions,
  52522. dataGroupingOptions = options.dataGrouping,
  52523. xDateFormat = tooltipOptions.xDateFormat,
  52524. xDateFormatEnd,
  52525. xAxis = series.xAxis,
  52526. currentDataGrouping,
  52527. dateTimeLabelFormats,
  52528. labelFormats,
  52529. formattedKey,
  52530. formatString = tooltipOptions[(e.isFooter ? 'footer' : 'header') + 'Format'];
  52531. // apply only to grouped series
  52532. if (xAxis &&
  52533. xAxis.options.type === 'datetime' &&
  52534. dataGroupingOptions &&
  52535. isNumber(labelConfig.key)) {
  52536. // set variables
  52537. currentDataGrouping = series.currentDataGrouping;
  52538. dateTimeLabelFormats = dataGroupingOptions.dateTimeLabelFormats ||
  52539. // Fallback to commonOptions (#9693)
  52540. commonOptions.dateTimeLabelFormats;
  52541. // if we have grouped data, use the grouping information to get the
  52542. // right format
  52543. if (currentDataGrouping) {
  52544. labelFormats =
  52545. dateTimeLabelFormats[currentDataGrouping.unitName];
  52546. if (currentDataGrouping.count === 1) {
  52547. xDateFormat = labelFormats[0];
  52548. }
  52549. else {
  52550. xDateFormat = labelFormats[1];
  52551. xDateFormatEnd = labelFormats[2];
  52552. }
  52553. // if not grouped, and we don't have set the xDateFormat option, get the
  52554. // best fit, so if the least distance between points is one minute, show
  52555. // it, but if the least distance is one day, skip hours and minutes etc.
  52556. }
  52557. else if (!xDateFormat && dateTimeLabelFormats) {
  52558. xDateFormat = tooltip.getXDateFormat(labelConfig, tooltipOptions, xAxis);
  52559. }
  52560. // now format the key
  52561. formattedKey = time.dateFormat(xDateFormat, labelConfig.key);
  52562. if (xDateFormatEnd) {
  52563. formattedKey += time.dateFormat(xDateFormatEnd, labelConfig.key + currentDataGrouping.totalRange - 1);
  52564. }
  52565. // Replace default header style with class name
  52566. if (series.chart.styledMode) {
  52567. formatString = this.styledModeFormat(formatString);
  52568. }
  52569. // return the replaced format
  52570. e.text = format(formatString, {
  52571. point: extend(labelConfig.point, { key: formattedKey }),
  52572. series: series
  52573. }, chart);
  52574. e.preventDefault();
  52575. }
  52576. });
  52577. // Destroy grouped data on series destroy
  52578. addEvent(Series, 'destroy', seriesProto.destroyGroupedData);
  52579. // Handle default options for data grouping. This must be set at runtime because
  52580. // some series types are defined after this.
  52581. addEvent(Series, 'afterSetOptions', function (e) {
  52582. var options = e.options,
  52583. type = this.type,
  52584. plotOptions = this.chart.options.plotOptions,
  52585. defaultOptions = D.defaultOptions.plotOptions[type].dataGrouping,
  52586. // External series, for example technical indicators should also
  52587. // inherit commonOptions which are not available outside this module
  52588. baseOptions = this.useCommonDataGrouping && commonOptions;
  52589. if (specificOptions[type] || baseOptions) { // #1284
  52590. if (!defaultOptions) {
  52591. defaultOptions = merge(commonOptions, specificOptions[type]);
  52592. }
  52593. var rangeSelector = this.chart.rangeSelector;
  52594. options.dataGrouping = merge(baseOptions, defaultOptions, plotOptions.series && plotOptions.series.dataGrouping, // #1228
  52595. // Set by the StockChart constructor:
  52596. plotOptions[type].dataGrouping, this.userOptions.dataGrouping, !options.isInternal &&
  52597. rangeSelector &&
  52598. isNumber(rangeSelector.selected) &&
  52599. rangeSelector.buttonOptions[rangeSelector.selected].dataGrouping);
  52600. }
  52601. });
  52602. // When resetting the scale reset the hasProccessed flag to avoid taking
  52603. // previous data grouping of neighbour series into accound when determining
  52604. // group pixel width (#2692).
  52605. addEvent(Axis, 'afterSetScale', function () {
  52606. this.series.forEach(function (series) {
  52607. series.hasProcessed = false;
  52608. });
  52609. });
  52610. // Get the data grouping pixel width based on the greatest defined individual
  52611. // width of the axis' series, and if whether one of the axes need grouping.
  52612. Axis.prototype.getGroupPixelWidth = function () {
  52613. var series = this.series,
  52614. len = series.length,
  52615. i,
  52616. groupPixelWidth = 0,
  52617. doGrouping = false,
  52618. dataLength,
  52619. dgOptions;
  52620. // If multiple series are compared on the same x axis, give them the same
  52621. // group pixel width (#334)
  52622. i = len;
  52623. while (i--) {
  52624. dgOptions = series[i].options.dataGrouping;
  52625. if (dgOptions) {
  52626. groupPixelWidth = Math.max(groupPixelWidth,
  52627. // Fallback to commonOptions (#9693)
  52628. pick(dgOptions.groupPixelWidth, commonOptions.groupPixelWidth));
  52629. }
  52630. }
  52631. // If one of the series needs grouping, apply it to all (#1634)
  52632. i = len;
  52633. while (i--) {
  52634. dgOptions = series[i].options.dataGrouping;
  52635. if (dgOptions && series[i].hasProcessed) { // #2692
  52636. dataLength = (series[i].processedXData || series[i].data).length;
  52637. // Execute grouping if the amount of points is greater than the
  52638. // limit defined in groupPixelWidth
  52639. if (series[i].groupPixelWidth ||
  52640. dataLength >
  52641. (this.chart.plotSizeX / groupPixelWidth) ||
  52642. (dataLength && dgOptions.forced)) {
  52643. doGrouping = true;
  52644. }
  52645. }
  52646. }
  52647. return doGrouping ? groupPixelWidth : 0;
  52648. };
  52649. /**
  52650. * Highcharts Stock only. Force data grouping on all the axis' series.
  52651. *
  52652. * @product highstock
  52653. *
  52654. * @function Highcharts.Axis#setDataGrouping
  52655. *
  52656. * @param {boolean|Highcharts.DataGroupingOptionsObject} [dataGrouping]
  52657. * A `dataGrouping` configuration. Use `false` to disable data grouping
  52658. * dynamically.
  52659. *
  52660. * @param {boolean} [redraw=true]
  52661. * Whether to redraw the chart or wait for a later call to
  52662. * {@link Chart#redraw}.
  52663. */
  52664. Axis.prototype.setDataGrouping = function (dataGrouping, redraw) {
  52665. var axis = this;
  52666. var i;
  52667. redraw = pick(redraw, true);
  52668. if (!dataGrouping) {
  52669. dataGrouping = {
  52670. forced: false,
  52671. units: null
  52672. };
  52673. }
  52674. // Axis is instantiated, update all series
  52675. if (this instanceof Axis) {
  52676. i = this.series.length;
  52677. while (i--) {
  52678. this.series[i].update({
  52679. dataGrouping: dataGrouping
  52680. }, false);
  52681. }
  52682. // Axis not yet instanciated, alter series options
  52683. }
  52684. else {
  52685. this.chart.options.series.forEach(function (seriesOptions) {
  52686. seriesOptions.dataGrouping = dataGrouping;
  52687. }, false);
  52688. }
  52689. // Clear ordinal slope, so we won't accidentaly use the old one (#7827)
  52690. if (axis.ordinal) {
  52691. axis.ordinal.slope = void 0;
  52692. }
  52693. if (redraw) {
  52694. this.chart.redraw();
  52695. }
  52696. };
  52697. H.dataGrouping = dataGrouping;
  52698. /* eslint-enable no-invalid-this, valid-jsdoc */
  52699. /**
  52700. * Data grouping is the concept of sampling the data values into larger
  52701. * blocks in order to ease readability and increase performance of the
  52702. * JavaScript charts. Highcharts Stock by default applies data grouping when
  52703. * the points become closer than a certain pixel value, determined by
  52704. * the `groupPixelWidth` option.
  52705. *
  52706. * If data grouping is applied, the grouping information of grouped
  52707. * points can be read from the [Point.dataGroup](
  52708. * /class-reference/Highcharts.Point#dataGroup). If point options other than
  52709. * the data itself are set, for example `name` or `color` or custom properties,
  52710. * the grouping logic doesn't know how to group it. In this case the options of
  52711. * the first point instance are copied over to the group point. This can be
  52712. * altered through a custom `approximation` callback function.
  52713. *
  52714. * @declare Highcharts.DataGroupingOptionsObject
  52715. * @product highstock
  52716. * @requires product:highstock
  52717. * @requires module:modules/datagrouping
  52718. * @apioption plotOptions.series.dataGrouping
  52719. */
  52720. /**
  52721. * Specifies how the points should be located on the X axis inside the group.
  52722. * Points that are extremes can be set separately. Available options:
  52723. *
  52724. * - `start` places the point at the beginning of the group
  52725. * (e.g. range 00:00:00 - 23:59:59 -> 00:00:00)
  52726. *
  52727. * - `middle` places the point in the middle of the group
  52728. * (e.g. range 00:00:00 - 23:59:59 -> 12:00:00)
  52729. *
  52730. * - `end` places the point at the end of the group
  52731. * (e.g. range 00:00:00 - 23:59:59 -> 23:59:59)
  52732. *
  52733. * @sample {highstock} stock/plotoptions/series-datagrouping-anchor
  52734. * Changing the point x-coordinate inside the group.
  52735. *
  52736. * @see [dataGrouping.firstAnchor](#plotOptions.series.dataGrouping.firstAnchor)
  52737. * @see [dataGrouping.lastAnchor](#plotOptions.series.dataGrouping.lastAnchor)
  52738. *
  52739. * @type {Highcharts.DataGroupingAnchor}
  52740. * @since 9.1.0
  52741. * @default start
  52742. * @apioption plotOptions.series.dataGrouping.anchor
  52743. */
  52744. /**
  52745. * The method of approximation inside a group. When for example 30 days
  52746. * are grouped into one month, this determines what value should represent
  52747. * the group. Possible values are "average", "averages", "open", "high",
  52748. * "low", "close" and "sum". For OHLC and candlestick series the approximation
  52749. * is "ohlc" by default, which finds the open, high, low and close values
  52750. * within all the grouped data. For ranges, the approximation is "range",
  52751. * which finds the low and high values. For multi-dimensional data,
  52752. * like ranges and OHLC, "averages" will compute the average for each
  52753. * dimension.
  52754. *
  52755. * Custom aggregate methods can be added by assigning a callback function
  52756. * as the approximation. This function takes a numeric array as the
  52757. * argument and should return a single numeric value or `null`. Note
  52758. * that the numeric array will never contain null values, only true
  52759. * numbers. Instead, if null values are present in the raw data, the
  52760. * numeric array will have an `.hasNulls` property set to `true`. For
  52761. * single-value data sets the data is available in the first argument
  52762. * of the callback function. For OHLC data sets, all the open values
  52763. * are in the first argument, all high values in the second etc.
  52764. *
  52765. * Since v4.2.7, grouping meta data is available in the approximation
  52766. * callback from `this.dataGroupInfo`. It can be used to extract information
  52767. * from the raw data.
  52768. *
  52769. * Defaults to `average` for line-type series, `sum` for columns, `range`
  52770. * for range series and `ohlc` for OHLC and candlestick.
  52771. *
  52772. * @sample {highstock} stock/plotoptions/series-datagrouping-approximation
  52773. * Approximation callback with custom data
  52774. * @sample {highstock} stock/plotoptions/series-datagrouping-simple-approximation
  52775. * Simple approximation demo
  52776. *
  52777. * @type {Highcharts.DataGroupingApproximationValue|Function}
  52778. * @apioption plotOptions.series.dataGrouping.approximation
  52779. */
  52780. /**
  52781. * Datetime formats for the header of the tooltip in a stock chart.
  52782. * The format can vary within a chart depending on the currently selected
  52783. * time range and the current data grouping.
  52784. *
  52785. * The default formats are:
  52786. * ```js
  52787. * {
  52788. * millisecond: [
  52789. * '%A, %b %e, %H:%M:%S.%L', '%A, %b %e, %H:%M:%S.%L', '-%H:%M:%S.%L'
  52790. * ],
  52791. * second: ['%A, %b %e, %H:%M:%S', '%A, %b %e, %H:%M:%S', '-%H:%M:%S'],
  52792. * minute: ['%A, %b %e, %H:%M', '%A, %b %e, %H:%M', '-%H:%M'],
  52793. * hour: ['%A, %b %e, %H:%M', '%A, %b %e, %H:%M', '-%H:%M'],
  52794. * day: ['%A, %b %e, %Y', '%A, %b %e', '-%A, %b %e, %Y'],
  52795. * week: ['Week from %A, %b %e, %Y', '%A, %b %e', '-%A, %b %e, %Y'],
  52796. * month: ['%B %Y', '%B', '-%B %Y'],
  52797. * year: ['%Y', '%Y', '-%Y']
  52798. * }
  52799. * ```
  52800. *
  52801. * For each of these array definitions, the first item is the format
  52802. * used when the active time span is one unit. For instance, if the
  52803. * current data applies to one week, the first item of the week array
  52804. * is used. The second and third items are used when the active time
  52805. * span is more than two units. For instance, if the current data applies
  52806. * to two weeks, the second and third item of the week array are used,
  52807. * and applied to the start and end date of the time span.
  52808. *
  52809. * @type {object}
  52810. * @apioption plotOptions.series.dataGrouping.dateTimeLabelFormats
  52811. */
  52812. /**
  52813. * Enable or disable data grouping.
  52814. *
  52815. * @type {boolean}
  52816. * @default true
  52817. * @apioption plotOptions.series.dataGrouping.enabled
  52818. */
  52819. /**
  52820. * Specifies how the first grouped point is positioned on the xAxis.
  52821. * If firstAnchor and/or lastAnchor are defined, then those options take
  52822. * precedence over anchor for the first and/or last grouped points.
  52823. * Available options:
  52824. *
  52825. * -`start` places the point at the beginning of the group
  52826. * (e.g. range 00:00:00 - 23:59:59 -> 00:00:00)
  52827. *
  52828. * -`middle` places the point in the middle of the group
  52829. * (e.g. range 00:00:00 - 23:59:59 -> 12:00:00)
  52830. *
  52831. * -`end` places the point at the end of the group
  52832. * (e.g. range 00:00:00 - 23:59:59 -> 23:59:59)
  52833. *
  52834. * -`firstPoint` the first point in the group
  52835. * (e.g. points at 00:13, 00:35, 00:59 -> 00:13)
  52836. *
  52837. * -`lastPoint` the last point in the group
  52838. * (e.g. points at 00:13, 00:35, 00:59 -> 00:59)
  52839. *
  52840. * @sample {highstock} stock/plotoptions/series-datagrouping-first-anchor
  52841. * Applying first and last anchor.
  52842. *
  52843. * @see [dataGrouping.anchor](#plotOptions.series.dataGrouping.anchor)
  52844. *
  52845. * @type {Highcharts.DataGroupingAnchorExtremes}
  52846. * @since 9.1.0
  52847. * @default start
  52848. * @apioption plotOptions.series.dataGrouping.firstAnchor
  52849. */
  52850. /**
  52851. * When data grouping is forced, it runs no matter how small the intervals
  52852. * are. This can be handy for example when the sum should be calculated
  52853. * for values appearing at random times within each hour.
  52854. *
  52855. * @type {boolean}
  52856. * @default false
  52857. * @apioption plotOptions.series.dataGrouping.forced
  52858. */
  52859. /**
  52860. * The approximate pixel width of each group. If for example a series
  52861. * with 30 points is displayed over a 600 pixel wide plot area, no grouping
  52862. * is performed. If however the series contains so many points that
  52863. * the spacing is less than the groupPixelWidth, Highcharts will try
  52864. * to group it into appropriate groups so that each is more or less
  52865. * two pixels wide. If multiple series with different group pixel widths
  52866. * are drawn on the same x axis, all series will take the greatest width.
  52867. * For example, line series have 2px default group width, while column
  52868. * series have 10px. If combined, both the line and the column will
  52869. * have 10px by default.
  52870. *
  52871. * @type {number}
  52872. * @default 2
  52873. * @apioption plotOptions.series.dataGrouping.groupPixelWidth
  52874. */
  52875. /**
  52876. * By default only points within the visible range are grouped. Enabling this
  52877. * option will force data grouping to calculate all grouped points for a given
  52878. * dataset. That option prevents for example a column series from calculating
  52879. * a grouped point partially. The effect is similar to
  52880. * [Series.getExtremesFromAll](#plotOptions.series.getExtremesFromAll) but does
  52881. * not affect yAxis extremes.
  52882. *
  52883. * @sample {highstock} stock/plotoptions/series-datagrouping-groupall/
  52884. * Two series with the same data but different groupAll setting
  52885. *
  52886. * @type {boolean}
  52887. * @default false
  52888. * @since 6.1.0
  52889. * @apioption plotOptions.series.dataGrouping.groupAll
  52890. */
  52891. /**
  52892. * Specifies how the last grouped point is positioned on the xAxis.
  52893. * If firstAnchor and/or lastAnchor are defined, then those options take
  52894. * precedence over anchor for the first and/or last grouped points.
  52895. * Available options:
  52896. *
  52897. * -`start` places the point at the beginning of the group
  52898. * (e.g. range 00:00:00 - 23:59:59 -> 00:00:00)
  52899. *
  52900. * -`middle` places the point in the middle of the group
  52901. * (e.g. range 00:00:00 - 23:59:59 -> 12:00:00)
  52902. *
  52903. * -`end` places the point at the end of the group
  52904. * (e.g. range 00:00:00 - 23:59:59 -> 23:59:59)
  52905. *
  52906. * -`firstPoint` the first point in the group
  52907. * (e.g. points at 00:13, 00:35, 00:59 -> 00:13)
  52908. *
  52909. * -`lastPoint` the last point in the group
  52910. * (e.g. points at 00:13, 00:35, 00:59 -> 00:59)
  52911. *
  52912. * @sample {highstock} stock/plotoptions/series-datagrouping-first-anchor
  52913. * Applying first and last anchor.
  52914. *
  52915. * @sample {highstock} stock/plotoptions/series-datagrouping-last-anchor
  52916. * Applying the last anchor in the chart with live data.
  52917. *
  52918. * @see [dataGrouping.anchor](#plotOptions.series.dataGrouping.anchor)
  52919. *
  52920. * @type {Highcharts.DataGroupingAnchorExtremes}
  52921. * @since 9.1.0
  52922. * @default start
  52923. * @apioption plotOptions.series.dataGrouping.lastAnchor
  52924. */
  52925. /**
  52926. * Normally, a group is indexed by the start of that group, so for example
  52927. * when 30 daily values are grouped into one month, that month's x value
  52928. * will be the 1st of the month. This apparently shifts the data to
  52929. * the left. When the smoothed option is true, this is compensated for.
  52930. * The data is shifted to the middle of the group, and min and max
  52931. * values are preserved. Internally, this is used in the Navigator series.
  52932. *
  52933. * @type {boolean}
  52934. * @default false
  52935. * @deprecated
  52936. * @apioption plotOptions.series.dataGrouping.smoothed
  52937. */
  52938. /**
  52939. * An array determining what time intervals the data is allowed to be
  52940. * grouped to. Each array item is an array where the first value is
  52941. * the time unit and the second value another array of allowed multiples.
  52942. *
  52943. * Defaults to:
  52944. * ```js
  52945. * units: [[
  52946. * 'millisecond', // unit name
  52947. * [1, 2, 5, 10, 20, 25, 50, 100, 200, 500] // allowed multiples
  52948. * ], [
  52949. * 'second',
  52950. * [1, 2, 5, 10, 15, 30]
  52951. * ], [
  52952. * 'minute',
  52953. * [1, 2, 5, 10, 15, 30]
  52954. * ], [
  52955. * 'hour',
  52956. * [1, 2, 3, 4, 6, 8, 12]
  52957. * ], [
  52958. * 'day',
  52959. * [1]
  52960. * ], [
  52961. * 'week',
  52962. * [1]
  52963. * ], [
  52964. * 'month',
  52965. * [1, 3, 6]
  52966. * ], [
  52967. * 'year',
  52968. * null
  52969. * ]]
  52970. * ```
  52971. *
  52972. * @type {Array<Array<string,(Array<number>|null)>>}
  52973. * @apioption plotOptions.series.dataGrouping.units
  52974. */
  52975. /**
  52976. * The approximate pixel width of each group. If for example a series
  52977. * with 30 points is displayed over a 600 pixel wide plot area, no grouping
  52978. * is performed. If however the series contains so many points that
  52979. * the spacing is less than the groupPixelWidth, Highcharts will try
  52980. * to group it into appropriate groups so that each is more or less
  52981. * two pixels wide. Defaults to `10`.
  52982. *
  52983. * @sample {highstock} stock/plotoptions/series-datagrouping-grouppixelwidth/
  52984. * Two series with the same data density but different groupPixelWidth
  52985. *
  52986. * @type {number}
  52987. * @default 10
  52988. * @apioption plotOptions.column.dataGrouping.groupPixelWidth
  52989. */
  52990. ''; // required by JSDoc parsing
  52991. return dataGrouping;
  52992. });
  52993. _registerModule(_modules, 'Series/OHLC/OHLCPoint.js', [_modules['Core/Series/SeriesRegistry.js']], function (SeriesRegistry) {
  52994. /* *
  52995. *
  52996. * (c) 2010-2021 Torstein Honsi
  52997. *
  52998. * License: www.highcharts.com/license
  52999. *
  53000. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  53001. *
  53002. * */
  53003. var __extends = (this && this.__extends) || (function () {
  53004. var extendStatics = function (d,
  53005. b) {
  53006. extendStatics = Object.setPrototypeOf ||
  53007. ({ __proto__: [] } instanceof Array && function (d,
  53008. b) { d.__proto__ = b; }) ||
  53009. function (d,
  53010. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  53011. return extendStatics(d, b);
  53012. };
  53013. return function (d, b) {
  53014. extendStatics(d, b);
  53015. function __() { this.constructor = d; }
  53016. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  53017. };
  53018. })();
  53019. var ColumnSeries = SeriesRegistry.seriesTypes.column;
  53020. /* *
  53021. *
  53022. * Class
  53023. *
  53024. * */
  53025. var OHLCPoint = /** @class */ (function (_super) {
  53026. __extends(OHLCPoint, _super);
  53027. function OHLCPoint() {
  53028. /* *
  53029. *
  53030. * Properties
  53031. *
  53032. * */
  53033. var _this = _super !== null && _super.apply(this,
  53034. arguments) || this;
  53035. _this.close = void 0;
  53036. _this.high = void 0;
  53037. _this.low = void 0;
  53038. _this.open = void 0;
  53039. _this.options = void 0;
  53040. _this.plotClose = void 0;
  53041. _this.plotOpen = void 0;
  53042. _this.series = void 0;
  53043. return _this;
  53044. /* eslint-enable valid-jsdoc */
  53045. }
  53046. /* *
  53047. *
  53048. * Functions
  53049. *
  53050. * */
  53051. /* eslint-disable valid-jsdoc */
  53052. /**
  53053. * Extend the parent method by adding up or down to the class name.
  53054. * @private
  53055. * @function Highcharts.seriesTypes.ohlc#getClassName
  53056. * @return {string}
  53057. */
  53058. OHLCPoint.prototype.getClassName = function () {
  53059. return _super.prototype.getClassName.call(this) +
  53060. (this.open < this.close ?
  53061. ' highcharts-point-up' :
  53062. ' highcharts-point-down');
  53063. };
  53064. /**
  53065. * Save upColor as point color (#14826).
  53066. * @private
  53067. * @function Highcharts.seriesTypes.ohlc#resolveUpColor
  53068. */
  53069. OHLCPoint.prototype.resolveUpColor = function () {
  53070. if (this.open < this.close &&
  53071. !this.options.color &&
  53072. this.series.options.upColor) {
  53073. this.color = this.series.options.upColor;
  53074. }
  53075. };
  53076. /**
  53077. * Extend the parent method by saving upColor.
  53078. * @private
  53079. * @function Highcharts.seriesTypes.ohlc#resolveColor
  53080. */
  53081. OHLCPoint.prototype.resolveColor = function () {
  53082. _super.prototype.resolveColor.call(this);
  53083. this.resolveUpColor();
  53084. };
  53085. /**
  53086. * Extend the parent method by saving upColor.
  53087. * @private
  53088. * @function Highcharts.seriesTypes.ohlc#getZone
  53089. *
  53090. * @return {Highcharts.SeriesZonesOptionsObject}
  53091. * The zone item.
  53092. */
  53093. OHLCPoint.prototype.getZone = function () {
  53094. var zone = _super.prototype.getZone.call(this);
  53095. this.resolveUpColor();
  53096. return zone;
  53097. };
  53098. return OHLCPoint;
  53099. }(ColumnSeries.prototype.pointClass));
  53100. /* *
  53101. *
  53102. * Default Export
  53103. *
  53104. * */
  53105. return OHLCPoint;
  53106. });
  53107. _registerModule(_modules, 'Series/OHLC/OHLCSeries.js', [_modules['Series/OHLC/OHLCPoint.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (OHLCPoint, SeriesRegistry, U) {
  53108. /* *
  53109. *
  53110. * (c) 2010-2021 Torstein Honsi
  53111. *
  53112. * License: www.highcharts.com/license
  53113. *
  53114. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  53115. *
  53116. * */
  53117. var __extends = (this && this.__extends) || (function () {
  53118. var extendStatics = function (d,
  53119. b) {
  53120. extendStatics = Object.setPrototypeOf ||
  53121. ({ __proto__: [] } instanceof Array && function (d,
  53122. b) { d.__proto__ = b; }) ||
  53123. function (d,
  53124. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  53125. return extendStatics(d, b);
  53126. };
  53127. return function (d, b) {
  53128. extendStatics(d, b);
  53129. function __() { this.constructor = d; }
  53130. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  53131. };
  53132. })();
  53133. var ColumnSeries = SeriesRegistry.seriesTypes.column;
  53134. var extend = U.extend,
  53135. merge = U.merge;
  53136. /* *
  53137. *
  53138. * Class
  53139. *
  53140. * */
  53141. /**
  53142. * The ohlc series type.
  53143. *
  53144. * @private
  53145. * @class
  53146. * @name Highcharts.seriesTypes.ohlc
  53147. *
  53148. * @augments Highcharts.Series
  53149. */
  53150. var OHLCSeries = /** @class */ (function (_super) {
  53151. __extends(OHLCSeries, _super);
  53152. function OHLCSeries() {
  53153. /* *
  53154. *
  53155. * Static Properties
  53156. *
  53157. * */
  53158. var _this = _super !== null && _super.apply(this,
  53159. arguments) || this;
  53160. /* *
  53161. *
  53162. * Properties
  53163. *
  53164. * */
  53165. _this.data = void 0;
  53166. _this.options = void 0;
  53167. _this.points = void 0;
  53168. _this.yData = void 0;
  53169. return _this;
  53170. /* eslint-enable valid-jsdoc */
  53171. }
  53172. /* *
  53173. *
  53174. * Functions
  53175. *
  53176. * */
  53177. /* eslint-disable valid-jsdoc */
  53178. /**
  53179. * Draw the data points
  53180. * @private
  53181. */
  53182. OHLCSeries.prototype.drawPoints = function () {
  53183. var series = this,
  53184. points = series.points,
  53185. chart = series.chart,
  53186. /**
  53187. * Extend vertical stem to open and close values.
  53188. */
  53189. extendStem = function (path,
  53190. halfStrokeWidth,
  53191. openOrClose) {
  53192. var start = path[0];
  53193. var end = path[1];
  53194. // We don't need to worry about crisp - openOrClose value
  53195. // is already crisped and halfStrokeWidth should remove it.
  53196. if (typeof start[2] === 'number') {
  53197. start[2] = Math.max(openOrClose + halfStrokeWidth, start[2]);
  53198. }
  53199. if (typeof end[2] === 'number') {
  53200. end[2] = Math.min(openOrClose - halfStrokeWidth, end[2]);
  53201. }
  53202. };
  53203. points.forEach(function (point) {
  53204. var plotOpen,
  53205. plotClose,
  53206. crispCorr,
  53207. halfWidth,
  53208. path,
  53209. graphic = point.graphic,
  53210. crispX,
  53211. isNew = !graphic,
  53212. strokeWidth;
  53213. if (typeof point.plotY !== 'undefined') {
  53214. // Create and/or update the graphic
  53215. if (!graphic) {
  53216. point.graphic = graphic = chart.renderer.path()
  53217. .add(series.group);
  53218. }
  53219. if (!chart.styledMode) {
  53220. graphic.attr(series.pointAttribs(point, (point.selected && 'select'))); // #3897
  53221. }
  53222. // crisp vector coordinates
  53223. strokeWidth = graphic.strokeWidth();
  53224. crispCorr = (strokeWidth % 2) / 2;
  53225. // #2596:
  53226. crispX = Math.round(point.plotX) - crispCorr;
  53227. halfWidth = Math.round(point.shapeArgs.width / 2);
  53228. // the vertical stem
  53229. path = [
  53230. ['M', crispX, Math.round(point.yBottom)],
  53231. ['L', crispX, Math.round(point.plotHigh)]
  53232. ];
  53233. // open
  53234. if (point.open !== null) {
  53235. plotOpen = Math.round(point.plotOpen) + crispCorr;
  53236. path.push(['M', crispX, plotOpen], ['L', crispX - halfWidth, plotOpen]);
  53237. extendStem(path, strokeWidth / 2, plotOpen);
  53238. }
  53239. // close
  53240. if (point.close !== null) {
  53241. plotClose = Math.round(point.plotClose) + crispCorr;
  53242. path.push(['M', crispX, plotClose], ['L', crispX + halfWidth, plotClose]);
  53243. extendStem(path, strokeWidth / 2, plotClose);
  53244. }
  53245. graphic[isNew ? 'attr' : 'animate']({ d: path })
  53246. .addClass(point.getClassName(), true);
  53247. }
  53248. });
  53249. };
  53250. /**
  53251. * @private
  53252. * @function Highcarts.seriesTypes.ohlc#init
  53253. * @return {void}
  53254. */
  53255. OHLCSeries.prototype.init = function () {
  53256. _super.prototype.init.apply(this, arguments);
  53257. this.options.stacking = void 0; // #8817
  53258. };
  53259. /**
  53260. * Postprocess mapping between options and SVG attributes
  53261. * @private
  53262. */
  53263. OHLCSeries.prototype.pointAttribs = function (point, state) {
  53264. var attribs = _super.prototype.pointAttribs.call(this,
  53265. point,
  53266. state),
  53267. options = this.options;
  53268. delete attribs.fill;
  53269. if (!point.options.color &&
  53270. options.upColor &&
  53271. point.open < point.close) {
  53272. attribs.stroke = options.upColor;
  53273. }
  53274. return attribs;
  53275. };
  53276. OHLCSeries.prototype.toYData = function (point) {
  53277. // return a plain array for speedy calculation
  53278. return [point.open, point.high, point.low, point.close];
  53279. };
  53280. /**
  53281. * Translate data points from raw values x and y to plotX and plotY
  53282. *
  53283. * @private
  53284. * @function Highcharts.seriesTypes.ohlc#translate
  53285. * @return {void}
  53286. */
  53287. OHLCSeries.prototype.translate = function () {
  53288. var series = this,
  53289. yAxis = series.yAxis,
  53290. hasModifyValue = !!series.modifyValue,
  53291. translated = [
  53292. 'plotOpen',
  53293. 'plotHigh',
  53294. 'plotLow',
  53295. 'plotClose',
  53296. 'yBottom'
  53297. ]; // translate OHLC for
  53298. _super.prototype.translate.apply(series);
  53299. // Do the translation
  53300. series.points.forEach(function (point) {
  53301. [point.open, point.high, point.low, point.close, point.low]
  53302. .forEach(function (value, i) {
  53303. if (value !== null) {
  53304. if (hasModifyValue) {
  53305. value = series.modifyValue(value);
  53306. }
  53307. point[translated[i]] =
  53308. yAxis.toPixels(value, true);
  53309. }
  53310. });
  53311. // Align the tooltip to the high value to avoid covering the
  53312. // point
  53313. point.tooltipPos[1] =
  53314. point.plotHigh + yAxis.pos - series.chart.plotTop;
  53315. });
  53316. };
  53317. /**
  53318. * An OHLC chart is a style of financial chart used to describe price
  53319. * movements over time. It displays open, high, low and close values per
  53320. * data point.
  53321. *
  53322. * @sample stock/demo/ohlc/
  53323. * OHLC chart
  53324. *
  53325. * @extends plotOptions.column
  53326. * @excluding borderColor, borderRadius, borderWidth, crisp, stacking,
  53327. * stack
  53328. * @product highstock
  53329. * @optionparent plotOptions.ohlc
  53330. */
  53331. OHLCSeries.defaultOptions = merge(ColumnSeries.defaultOptions, {
  53332. /**
  53333. * The approximate pixel width of each group. If for example a series
  53334. * with 30 points is displayed over a 600 pixel wide plot area, no
  53335. * grouping is performed. If however the series contains so many points
  53336. * that the spacing is less than the groupPixelWidth, Highcharts will
  53337. * try to group it into appropriate groups so that each is more or less
  53338. * two pixels wide. Defaults to `5`.
  53339. *
  53340. * @type {number}
  53341. * @default 5
  53342. * @product highstock
  53343. * @apioption plotOptions.ohlc.dataGrouping.groupPixelWidth
  53344. */
  53345. /**
  53346. * The pixel width of the line/border. Defaults to `1`.
  53347. *
  53348. * @sample {highstock} stock/plotoptions/ohlc-linewidth/
  53349. * A greater line width
  53350. *
  53351. * @type {number}
  53352. * @default 1
  53353. * @product highstock
  53354. *
  53355. * @private
  53356. */
  53357. lineWidth: 1,
  53358. tooltip: {
  53359. pointFormat: '<span style="color:{point.color}">\u25CF</span> ' +
  53360. '<b> {series.name}</b><br/>' +
  53361. 'Open: {point.open}<br/>' +
  53362. 'High: {point.high}<br/>' +
  53363. 'Low: {point.low}<br/>' +
  53364. 'Close: {point.close}<br/>'
  53365. },
  53366. threshold: null,
  53367. states: {
  53368. /**
  53369. * @extends plotOptions.column.states.hover
  53370. * @product highstock
  53371. */
  53372. hover: {
  53373. /**
  53374. * The pixel width of the line representing the OHLC point.
  53375. *
  53376. * @type {number}
  53377. * @default 3
  53378. * @product highstock
  53379. */
  53380. lineWidth: 3
  53381. }
  53382. },
  53383. /**
  53384. * Determines which one of `open`, `high`, `low`, `close` values should
  53385. * be represented as `point.y`, which is later used to set dataLabel
  53386. * position and [compare](#plotOptions.series.compare).
  53387. *
  53388. * @sample {highstock} stock/plotoptions/ohlc-pointvalkey/
  53389. * Possible values
  53390. *
  53391. * @type {string}
  53392. * @default close
  53393. * @validvalue ["open", "high", "low", "close"]
  53394. * @product highstock
  53395. * @apioption plotOptions.ohlc.pointValKey
  53396. */
  53397. /**
  53398. * @default close
  53399. * @apioption plotOptions.ohlc.colorKey
  53400. */
  53401. /**
  53402. * Line color for up points.
  53403. *
  53404. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  53405. * @product highstock
  53406. * @apioption plotOptions.ohlc.upColor
  53407. */
  53408. stickyTracking: true
  53409. });
  53410. return OHLCSeries;
  53411. }(ColumnSeries));
  53412. extend(OHLCSeries.prototype, {
  53413. animate: null,
  53414. directTouch: false,
  53415. pointArrayMap: ['open', 'high', 'low', 'close'],
  53416. pointAttrToOptions: {
  53417. stroke: 'color',
  53418. 'stroke-width': 'lineWidth'
  53419. },
  53420. pointValKey: 'close'
  53421. });
  53422. OHLCSeries.prototype.pointClass = OHLCPoint;
  53423. SeriesRegistry.registerSeriesType('ohlc', OHLCSeries);
  53424. /* *
  53425. *
  53426. * Default Export
  53427. *
  53428. * */
  53429. /* *
  53430. *
  53431. * API Options
  53432. *
  53433. * */
  53434. /**
  53435. * A `ohlc` series. If the [type](#series.ohlc.type) option is not
  53436. * specified, it is inherited from [chart.type](#chart.type).
  53437. *
  53438. * @extends series,plotOptions.ohlc
  53439. * @excluding dataParser, dataURL
  53440. * @product highstock
  53441. * @apioption series.ohlc
  53442. */
  53443. /**
  53444. * An array of data points for the series. For the `ohlc` series type,
  53445. * points can be given in the following ways:
  53446. *
  53447. * 1. An array of arrays with 5 or 4 values. In this case, the values correspond
  53448. * to `x,open,high,low,close`. If the first value is a string, it is applied
  53449. * as the name of the point, and the `x` value is inferred. The `x` value can
  53450. * also be omitted, in which case the inner arrays should be of length 4\.
  53451. * Then the `x` value is automatically calculated, either starting at 0 and
  53452. * incremented by 1, or from `pointStart` and `pointInterval` given in the
  53453. * series options.
  53454. * ```js
  53455. * data: [
  53456. * [0, 6, 5, 6, 7],
  53457. * [1, 9, 4, 8, 2],
  53458. * [2, 6, 3, 4, 10]
  53459. * ]
  53460. * ```
  53461. *
  53462. * 2. An array of objects with named values. The following snippet shows only a
  53463. * few settings, see the complete options set below. If the total number of
  53464. * data points exceeds the series'
  53465. * [turboThreshold](#series.ohlc.turboThreshold), this option is not
  53466. * available.
  53467. * ```js
  53468. * data: [{
  53469. * x: 1,
  53470. * open: 3,
  53471. * high: 4,
  53472. * low: 5,
  53473. * close: 2,
  53474. * name: "Point2",
  53475. * color: "#00FF00"
  53476. * }, {
  53477. * x: 1,
  53478. * open: 4,
  53479. * high: 3,
  53480. * low: 6,
  53481. * close: 7,
  53482. * name: "Point1",
  53483. * color: "#FF00FF"
  53484. * }]
  53485. * ```
  53486. *
  53487. * @type {Array<Array<(number|string),number,number,number>|Array<(number|string),number,number,number,number>|*>}
  53488. * @extends series.arearange.data
  53489. * @excluding y, marker
  53490. * @product highstock
  53491. * @apioption series.ohlc.data
  53492. */
  53493. /**
  53494. * The closing value of each data point.
  53495. *
  53496. * @type {number}
  53497. * @product highstock
  53498. * @apioption series.ohlc.data.close
  53499. */
  53500. /**
  53501. * The opening value of each data point.
  53502. *
  53503. * @type {number}
  53504. * @product highstock
  53505. * @apioption series.ohlc.data.open
  53506. */
  53507. ''; // adds doclets above to transpilat
  53508. return OHLCSeries;
  53509. });
  53510. _registerModule(_modules, 'Series/Candlestick/CandlestickSeries.js', [_modules['Core/DefaultOptions.js'], _modules['Core/Color/Palette.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (D, palette, SeriesRegistry, U) {
  53511. /* *
  53512. *
  53513. * (c) 2010-2021 Torstein Honsi
  53514. *
  53515. * License: www.highcharts.com/license
  53516. *
  53517. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  53518. *
  53519. * */
  53520. var __extends = (this && this.__extends) || (function () {
  53521. var extendStatics = function (d,
  53522. b) {
  53523. extendStatics = Object.setPrototypeOf ||
  53524. ({ __proto__: [] } instanceof Array && function (d,
  53525. b) { d.__proto__ = b; }) ||
  53526. function (d,
  53527. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  53528. return extendStatics(d, b);
  53529. };
  53530. return function (d, b) {
  53531. extendStatics(d, b);
  53532. function __() { this.constructor = d; }
  53533. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  53534. };
  53535. })();
  53536. var defaultOptions = D.defaultOptions;
  53537. var _a = SeriesRegistry.seriesTypes,
  53538. ColumnSeries = _a.column,
  53539. OHLCSeries = _a.ohlc;
  53540. var merge = U.merge;
  53541. /* *
  53542. *
  53543. * Code
  53544. *
  53545. * */
  53546. /**
  53547. * The candlestick series type.
  53548. *
  53549. * @private
  53550. * @class
  53551. * @name Highcharts.seriesTypes.candlestick
  53552. *
  53553. * @augments Highcharts.seriesTypes.ohlc
  53554. */
  53555. var CandlestickSeries = /** @class */ (function (_super) {
  53556. __extends(CandlestickSeries, _super);
  53557. function CandlestickSeries() {
  53558. /* *
  53559. *
  53560. * Static properties
  53561. *
  53562. * */
  53563. var _this = _super !== null && _super.apply(this,
  53564. arguments) || this;
  53565. /* *
  53566. *
  53567. * Properties
  53568. *
  53569. * */
  53570. _this.data = void 0;
  53571. _this.options = void 0;
  53572. _this.points = void 0;
  53573. return _this;
  53574. }
  53575. /* *
  53576. *
  53577. * Functions
  53578. *
  53579. * */
  53580. /* eslint-disable valid-jsdoc */
  53581. /**
  53582. * Postprocess mapping between options and SVG attributes
  53583. *
  53584. * @private
  53585. * @function Highcharts.seriesTypes.candlestick#pointAttribs
  53586. */
  53587. CandlestickSeries.prototype.pointAttribs = function (point, state) {
  53588. var attribs = ColumnSeries.prototype.pointAttribs.call(this,
  53589. point,
  53590. state),
  53591. options = this.options,
  53592. isUp = point.open < point.close,
  53593. stroke = options.lineColor || this.color,
  53594. color = point.color || this.color, // (#14826)
  53595. stateOptions;
  53596. attribs['stroke-width'] = options.lineWidth;
  53597. attribs.fill = point.options.color ||
  53598. (isUp ? (options.upColor || color) : color);
  53599. attribs.stroke = point.options.lineColor ||
  53600. (isUp ? (options.upLineColor || stroke) : stroke);
  53601. // Select or hover states
  53602. if (state) {
  53603. stateOptions = options.states[state];
  53604. attribs.fill = stateOptions.color || attribs.fill;
  53605. attribs.stroke = stateOptions.lineColor || attribs.stroke;
  53606. attribs['stroke-width'] =
  53607. stateOptions.lineWidth || attribs['stroke-width'];
  53608. }
  53609. return attribs;
  53610. };
  53611. /**
  53612. * Draw the data points.
  53613. *
  53614. * @private
  53615. * @function Highcharts.seriesTypes.candlestick#drawPoints
  53616. * @return {void}
  53617. */
  53618. CandlestickSeries.prototype.drawPoints = function () {
  53619. var series = this,
  53620. points = series.points,
  53621. chart = series.chart,
  53622. reversedYAxis = series.yAxis.reversed;
  53623. points.forEach(function (point) {
  53624. var graphic = point.graphic,
  53625. plotOpen,
  53626. plotClose,
  53627. topBox,
  53628. bottomBox,
  53629. hasTopWhisker,
  53630. hasBottomWhisker,
  53631. crispCorr,
  53632. crispX,
  53633. path,
  53634. halfWidth,
  53635. isNew = !graphic;
  53636. if (typeof point.plotY !== 'undefined') {
  53637. if (!graphic) {
  53638. point.graphic = graphic = chart.renderer.path()
  53639. .add(series.group);
  53640. }
  53641. if (!series.chart.styledMode) {
  53642. graphic
  53643. .attr(series.pointAttribs(point, (point.selected && 'select'))) // #3897
  53644. .shadow(series.options.shadow);
  53645. }
  53646. // Crisp vector coordinates
  53647. crispCorr = (graphic.strokeWidth() % 2) / 2;
  53648. // #2596:
  53649. crispX = Math.round(point.plotX) - crispCorr;
  53650. plotOpen = point.plotOpen;
  53651. plotClose = point.plotClose;
  53652. topBox = Math.min(plotOpen, plotClose);
  53653. bottomBox = Math.max(plotOpen, plotClose);
  53654. halfWidth = Math.round(point.shapeArgs.width / 2);
  53655. hasTopWhisker = reversedYAxis ?
  53656. bottomBox !== point.yBottom :
  53657. Math.round(topBox) !==
  53658. Math.round(point.plotHigh);
  53659. hasBottomWhisker = reversedYAxis ?
  53660. Math.round(topBox) !==
  53661. Math.round(point.plotHigh) :
  53662. bottomBox !== point.yBottom;
  53663. topBox = Math.round(topBox) + crispCorr;
  53664. bottomBox = Math.round(bottomBox) + crispCorr;
  53665. // Create the path. Due to a bug in Chrome 49, the path is
  53666. // first instanciated with no values, then the values
  53667. // pushed. For unknown reasons, instanciating the path array
  53668. // with all the values would lead to a crash when updating
  53669. // frequently (#5193).
  53670. path = [];
  53671. path.push(['M', crispX - halfWidth, bottomBox], ['L', crispX - halfWidth, topBox], ['L', crispX + halfWidth, topBox], ['L', crispX + halfWidth, bottomBox], ['Z'], // Ensure a nice rectangle #2602
  53672. ['M', crispX, topBox], [
  53673. 'L',
  53674. // #460, #2094
  53675. crispX,
  53676. hasTopWhisker ?
  53677. Math.round(reversedYAxis ?
  53678. point.yBottom :
  53679. point.plotHigh) :
  53680. topBox
  53681. ], ['M', crispX, bottomBox], [
  53682. 'L',
  53683. // #460, #2094
  53684. crispX,
  53685. hasBottomWhisker ?
  53686. Math.round(reversedYAxis ?
  53687. point.plotHigh :
  53688. point.yBottom) :
  53689. bottomBox
  53690. ]);
  53691. graphic[isNew ? 'attr' : 'animate']({ d: path })
  53692. .addClass(point.getClassName(), true);
  53693. }
  53694. });
  53695. /* eslint-enable valid-jsdoc */
  53696. };
  53697. /**
  53698. * A candlestick chart is a style of financial chart used to describe price
  53699. * movements over time.
  53700. *
  53701. * @sample stock/demo/candlestick/
  53702. * Candlestick chart
  53703. *
  53704. * @extends plotOptions.ohlc
  53705. * @excluding borderColor,borderRadius,borderWidth
  53706. * @product highstock
  53707. * @optionparent plotOptions.candlestick
  53708. */
  53709. CandlestickSeries.defaultOptions = merge(OHLCSeries.defaultOptions, defaultOptions.plotOptions, {
  53710. /**
  53711. * The specific line color for up candle sticks. The default is to
  53712. * inherit the general `lineColor` setting.
  53713. *
  53714. * @sample {highstock} stock/plotoptions/candlestick-linecolor/
  53715. * Candlestick line colors
  53716. *
  53717. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  53718. * @since 1.3.6
  53719. * @product highstock
  53720. * @apioption plotOptions.candlestick.upLineColor
  53721. */
  53722. /**
  53723. * @type {Highcharts.DataGroupingApproximationValue|Function}
  53724. * @default ohlc
  53725. * @product highstock
  53726. * @apioption plotOptions.candlestick.dataGrouping.approximation
  53727. */
  53728. states: {
  53729. /**
  53730. * @extends plotOptions.column.states.hover
  53731. * @product highstock
  53732. */
  53733. hover: {
  53734. /**
  53735. * The pixel width of the line/border around the candlestick.
  53736. *
  53737. * @product highstock
  53738. */
  53739. lineWidth: 2
  53740. }
  53741. },
  53742. /**
  53743. * @extends plotOptions.ohlc.tooltip
  53744. */
  53745. tooltip: defaultOptions.plotOptions.ohlc.tooltip,
  53746. /**
  53747. * @type {number|null}
  53748. * @product highstock
  53749. */
  53750. threshold: null,
  53751. /**
  53752. * The color of the line/border of the candlestick.
  53753. *
  53754. * In styled mode, the line stroke can be set with the
  53755. * `.highcharts-candlestick-series .highcahrts-point` rule.
  53756. *
  53757. * @see [upLineColor](#plotOptions.candlestick.upLineColor)
  53758. *
  53759. * @sample {highstock} stock/plotoptions/candlestick-linecolor/
  53760. * Candlestick line colors
  53761. *
  53762. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  53763. * @default #000000
  53764. * @product highstock
  53765. */
  53766. lineColor: palette.neutralColor100,
  53767. /**
  53768. * The pixel width of the candlestick line/border. Defaults to `1`.
  53769. *
  53770. *
  53771. * In styled mode, the line stroke width can be set with the
  53772. * `.highcharts-candlestick-series .highcahrts-point` rule.
  53773. *
  53774. * @product highstock
  53775. */
  53776. lineWidth: 1,
  53777. /**
  53778. * The fill color of the candlestick when values are rising.
  53779. *
  53780. * In styled mode, the up color can be set with the
  53781. * `.highcharts-candlestick-series .highcharts-point-up` rule.
  53782. *
  53783. * @sample {highstock} stock/plotoptions/candlestick-color/
  53784. * Custom colors
  53785. * @sample {highstock} highcharts/css/candlestick/
  53786. * Colors in styled mode
  53787. *
  53788. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  53789. * @default #ffffff
  53790. * @product highstock
  53791. */
  53792. upColor: palette.backgroundColor,
  53793. /**
  53794. * @product highstock
  53795. */
  53796. stickyTracking: true
  53797. });
  53798. return CandlestickSeries;
  53799. }(OHLCSeries));
  53800. SeriesRegistry.registerSeriesType('candlestick', CandlestickSeries);
  53801. /* *
  53802. *
  53803. * Default Export
  53804. *
  53805. * */
  53806. /* *
  53807. *
  53808. * API Options
  53809. *
  53810. * */
  53811. /**
  53812. * A `candlestick` series. If the [type](#series.candlestick.type)
  53813. * option is not specified, it is inherited from [chart.type](
  53814. * #chart.type).
  53815. *
  53816. * @type {*}
  53817. * @extends series,plotOptions.candlestick
  53818. * @excluding dataParser, dataURL, marker
  53819. * @product highstock
  53820. * @apioption series.candlestick
  53821. */
  53822. /**
  53823. * An array of data points for the series. For the `candlestick` series
  53824. * type, points can be given in the following ways:
  53825. *
  53826. * 1. An array of arrays with 5 or 4 values. In this case, the values correspond
  53827. * to `x,open,high,low,close`. If the first value is a string, it is applied
  53828. * as the name of the point, and the `x` value is inferred. The `x` value can
  53829. * also be omitted, in which case the inner arrays should be of length 4.
  53830. * Then the `x` value is automatically calculated, either starting at 0 and
  53831. * incremented by 1, or from `pointStart` and `pointInterval` given in the
  53832. * series options.
  53833. * ```js
  53834. * data: [
  53835. * [0, 7, 2, 0, 4],
  53836. * [1, 1, 4, 2, 8],
  53837. * [2, 3, 3, 9, 3]
  53838. * ]
  53839. * ```
  53840. *
  53841. * 2. An array of objects with named values. The following snippet shows only a
  53842. * few settings, see the complete options set below. If the total number of
  53843. * data points exceeds the series'
  53844. * [turboThreshold](#series.candlestick.turboThreshold), this option is not
  53845. * available.
  53846. * ```js
  53847. * data: [{
  53848. * x: 1,
  53849. * open: 9,
  53850. * high: 2,
  53851. * low: 4,
  53852. * close: 6,
  53853. * name: "Point2",
  53854. * color: "#00FF00"
  53855. * }, {
  53856. * x: 1,
  53857. * open: 1,
  53858. * high: 4,
  53859. * low: 7,
  53860. * close: 7,
  53861. * name: "Point1",
  53862. * color: "#FF00FF"
  53863. * }]
  53864. * ```
  53865. *
  53866. * @type {Array<Array<(number|string),number,number,number>|Array<(number|string),number,number,number,number>|*>}
  53867. * @extends series.ohlc.data
  53868. * @excluding y
  53869. * @product highstock
  53870. * @apioption series.candlestick.data
  53871. */
  53872. ''; // adds doclets above to transpilat
  53873. return CandlestickSeries;
  53874. });
  53875. _registerModule(_modules, 'Series/Flags/FlagsPoint.js', [_modules['Core/Series/SeriesRegistry.js'], _modules['Core/Utilities.js']], function (SeriesRegistry, U) {
  53876. /* *
  53877. *
  53878. * (c) 2010-2021 Torstein Honsi
  53879. *
  53880. * License: www.highcharts.com/license
  53881. *
  53882. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  53883. *
  53884. * */
  53885. var __extends = (this && this.__extends) || (function () {
  53886. var extendStatics = function (d,
  53887. b) {
  53888. extendStatics = Object.setPrototypeOf ||
  53889. ({ __proto__: [] } instanceof Array && function (d,
  53890. b) { d.__proto__ = b; }) ||
  53891. function (d,
  53892. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  53893. return extendStatics(d, b);
  53894. };
  53895. return function (d, b) {
  53896. extendStatics(d, b);
  53897. function __() { this.constructor = d; }
  53898. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  53899. };
  53900. })();
  53901. var ColumnSeries = SeriesRegistry.seriesTypes.column;
  53902. var isNumber = U.isNumber;
  53903. /* *
  53904. *
  53905. * Class
  53906. *
  53907. * */
  53908. var FlagsPoint = /** @class */ (function (_super) {
  53909. __extends(FlagsPoint, _super);
  53910. function FlagsPoint() {
  53911. /* *
  53912. *
  53913. * Properties
  53914. *
  53915. * */
  53916. var _this = _super !== null && _super.apply(this,
  53917. arguments) || this;
  53918. _this.options = void 0;
  53919. _this.series = void 0;
  53920. return _this;
  53921. }
  53922. /* *
  53923. *
  53924. * Functions
  53925. *
  53926. * */
  53927. /* eslint-disable valid-jsdoc */
  53928. /**
  53929. * @private
  53930. */
  53931. FlagsPoint.prototype.isValid = function () {
  53932. // #9233 - Prevent from treating flags as null points (even if
  53933. // they have no y values defined).
  53934. return isNumber(this.y) || typeof this.y === 'undefined';
  53935. };
  53936. /**
  53937. * @private
  53938. */
  53939. FlagsPoint.prototype.hasNewShapeType = function () {
  53940. var shape = this.options.shape || this.series.options.shape;
  53941. return this.graphic && shape && shape !== this.graphic.symbolKey;
  53942. };
  53943. return FlagsPoint;
  53944. }(ColumnSeries.prototype.pointClass));
  53945. /* *
  53946. *
  53947. * Default Export
  53948. *
  53949. * */
  53950. return FlagsPoint;
  53951. });
  53952. _registerModule(_modules, 'Mixins/OnSeries.js', [_modules['Series/Column/ColumnSeries.js'], _modules['Core/Series/Series.js'], _modules['Core/Utilities.js']], function (ColumnSeries, Series, U) {
  53953. /* *
  53954. *
  53955. * (c) 2010-2021 Torstein Honsi
  53956. *
  53957. * License: www.highcharts.com/license
  53958. *
  53959. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  53960. *
  53961. * */
  53962. var columnProto = ColumnSeries.prototype;
  53963. var seriesProto = Series.prototype;
  53964. var defined = U.defined,
  53965. stableSort = U.stableSort;
  53966. /**
  53967. * @private
  53968. * @mixin onSeriesMixin
  53969. */
  53970. var onSeriesMixin = {
  53971. /* eslint-disable valid-jsdoc */
  53972. /**
  53973. * Override getPlotBox. If the onSeries option is valid,
  53974. return the plot box
  53975. * of the onSeries,
  53976. otherwise proceed as usual.
  53977. *
  53978. * @private
  53979. * @function onSeriesMixin.getPlotBox
  53980. * @return {Highcharts.SeriesPlotBoxObject}
  53981. */
  53982. getPlotBox: function () {
  53983. return seriesProto.getPlotBox.call((this.options.onSeries &&
  53984. this.chart.get(this.options.onSeries)) || this);
  53985. },
  53986. /**
  53987. * Extend the translate method by placing the point on the related series
  53988. *
  53989. * @private
  53990. * @function onSeriesMixin.translate
  53991. * @return {void}
  53992. */
  53993. translate: function () {
  53994. columnProto.translate.apply(this);
  53995. var series = this,
  53996. options = series.options,
  53997. chart = series.chart,
  53998. points = series.points,
  53999. cursor = points.length - 1,
  54000. point,
  54001. lastPoint,
  54002. optionsOnSeries = options.onSeries,
  54003. onSeries = (optionsOnSeries &&
  54004. chart.get(optionsOnSeries)),
  54005. onKey = options.onKey || 'y',
  54006. step = onSeries && onSeries.options.step,
  54007. onData = (onSeries && onSeries.points),
  54008. i = onData && onData.length,
  54009. inverted = chart.inverted,
  54010. xAxis = series.xAxis,
  54011. yAxis = series.yAxis,
  54012. xOffset = 0,
  54013. leftPoint,
  54014. lastX,
  54015. rightPoint,
  54016. currentDataGrouping,
  54017. distanceRatio;
  54018. // relate to a master series
  54019. if (onSeries && onSeries.visible && i) {
  54020. xOffset = (onSeries.pointXOffset || 0) + (onSeries.barW || 0) / 2;
  54021. currentDataGrouping = onSeries.currentDataGrouping;
  54022. lastX = (onData[i - 1].x +
  54023. (currentDataGrouping ? currentDataGrouping.totalRange : 0)); // #2374
  54024. // sort the data points
  54025. stableSort(points, function (a, b) {
  54026. return (a.x - b.x);
  54027. });
  54028. onKey = 'plot' + onKey[0].toUpperCase() + onKey.substr(1);
  54029. while (i-- && points[cursor]) {
  54030. leftPoint = onData[i];
  54031. point = points[cursor];
  54032. point.y = leftPoint.y;
  54033. if (leftPoint.x <= point.x &&
  54034. typeof leftPoint[onKey] !== 'undefined') {
  54035. if (point.x <= lastX) { // #803
  54036. point.plotY = leftPoint[onKey];
  54037. // interpolate between points, #666
  54038. if (leftPoint.x < point.x &&
  54039. !step) {
  54040. rightPoint = onData[i + 1];
  54041. if (rightPoint &&
  54042. typeof rightPoint[onKey] !== 'undefined') {
  54043. // the distance ratio, between 0 and 1
  54044. distanceRatio =
  54045. (point.x - leftPoint.x) /
  54046. (rightPoint.x - leftPoint.x);
  54047. point.plotY +=
  54048. distanceRatio *
  54049. // the plotY distance
  54050. (rightPoint[onKey] - leftPoint[onKey]);
  54051. point.y +=
  54052. distanceRatio *
  54053. (rightPoint.y - leftPoint.y);
  54054. }
  54055. }
  54056. }
  54057. cursor--;
  54058. i++; // check again for points in the same x position
  54059. if (cursor < 0) {
  54060. break;
  54061. }
  54062. }
  54063. }
  54064. }
  54065. // Add plotY position and handle stacking
  54066. points.forEach(function (point, i) {
  54067. var stackIndex;
  54068. point.plotX += xOffset; // #2049
  54069. // Undefined plotY means the point is either on axis, outside series
  54070. // range or hidden series. If the series is outside the range of the
  54071. // x axis it should fall through with an undefined plotY, but then
  54072. // we must remove the shapeArgs (#847). For inverted charts, we need
  54073. // to calculate position anyway, because series.invertGroups is not
  54074. // defined
  54075. if (typeof point.plotY === 'undefined' || inverted) {
  54076. if (point.plotX >= 0 &&
  54077. point.plotX <= xAxis.len) {
  54078. // We're inside xAxis range
  54079. if (inverted) {
  54080. point.plotY = xAxis.translate(point.x, 0, 1, 0, 1);
  54081. point.plotX = defined(point.y) ?
  54082. yAxis.translate(point.y, 0, 0, 0, 1) :
  54083. 0;
  54084. }
  54085. else {
  54086. point.plotY = (xAxis.opposite ? 0 : series.yAxis.len) +
  54087. xAxis.offset; // For the windbarb demo
  54088. }
  54089. }
  54090. else {
  54091. point.shapeArgs = {}; // 847
  54092. }
  54093. }
  54094. // if multiple flags appear at the same x, order them into a stack
  54095. lastPoint = points[i - 1];
  54096. if (lastPoint && lastPoint.plotX === point.plotX) {
  54097. if (typeof lastPoint.stackIndex === 'undefined') {
  54098. lastPoint.stackIndex = 0;
  54099. }
  54100. stackIndex = lastPoint.stackIndex + 1;
  54101. }
  54102. point.stackIndex = stackIndex; // #3639
  54103. });
  54104. this.onSeries = onSeries;
  54105. }
  54106. /* eslint-enable valid-jsdoc */
  54107. };
  54108. return onSeriesMixin;
  54109. });
  54110. _registerModule(_modules, 'Series/Flags/FlagsSymbols.js', [_modules['Core/Renderer/RendererRegistry.js'], _modules['Core/Renderer/SVG/SVGRenderer.js']], function (RendererRegistry, SVGRenderer) {
  54111. /* *
  54112. *
  54113. * Imports
  54114. *
  54115. * */
  54116. var symbols = SVGRenderer.prototype.symbols;
  54117. /* *
  54118. *
  54119. * Symbols
  54120. *
  54121. * */
  54122. // create the flag icon with anchor
  54123. symbols.flag = function (x, y, w, h, options) {
  54124. var anchorX = (options && options.anchorX) || x,
  54125. anchorY = (options && options.anchorY) || y;
  54126. // To do: unwanted any cast because symbols.circle has wrong type, it
  54127. // actually returns an SVGPathArray
  54128. var path = symbols.circle(anchorX - 1,
  54129. anchorY - 1, 2, 2);
  54130. path.push(['M', anchorX, anchorY], ['L', x, y + h], ['L', x, y], ['L', x + w, y], ['L', x + w, y + h], ['L', x, y + h], ['Z']);
  54131. return path;
  54132. };
  54133. /**
  54134. * Create the circlepin and squarepin icons with anchor.
  54135. * @private
  54136. * @param {string} shape - circle or square
  54137. * @return {void}
  54138. */
  54139. function createPinSymbol(shape) {
  54140. symbols[(shape + 'pin')] = function (x, y, w, h, options) {
  54141. var anchorX = options && options.anchorX,
  54142. anchorY = options && options.anchorY;
  54143. var path;
  54144. // For single-letter flags, make sure circular flags are not taller
  54145. // than their width
  54146. if (shape === 'circle' && h > w) {
  54147. x -= Math.round((h - w) / 2);
  54148. w = h;
  54149. }
  54150. path = (symbols[shape])(x, y, w, h);
  54151. if (anchorX && anchorY) {
  54152. /**
  54153. * If the label is below the anchor, draw the connecting line from
  54154. * the top edge of the label, otherwise start drawing from the
  54155. * bottom edge
  54156. */
  54157. var labelX = anchorX;
  54158. if (shape === 'circle') {
  54159. labelX = x + w / 2;
  54160. }
  54161. else {
  54162. var startSeg = path[0];
  54163. var endSeg = path[1];
  54164. if (startSeg[0] === 'M' && endSeg[0] === 'L') {
  54165. labelX = (startSeg[1] + endSeg[1]) / 2;
  54166. }
  54167. }
  54168. var labelY = (y > anchorY) ? y : y + h;
  54169. path.push([
  54170. 'M',
  54171. labelX,
  54172. labelY
  54173. ], [
  54174. 'L',
  54175. anchorX,
  54176. anchorY
  54177. ]);
  54178. path = path.concat(symbols.circle(anchorX - 1, anchorY - 1, 2, 2));
  54179. }
  54180. return path;
  54181. };
  54182. }
  54183. createPinSymbol('circle');
  54184. createPinSymbol('square');
  54185. /**
  54186. * The symbol callbacks are generated on the SVGRenderer object in all browsers.
  54187. * Even VML browsers need this in order to generate shapes in export. Now share
  54188. * them with the VMLRenderer.
  54189. */
  54190. var Renderer = RendererRegistry.getRendererType();
  54191. if (Renderer !== SVGRenderer) {
  54192. Renderer.prototype.symbols.circlepin = symbols.circlepin;
  54193. Renderer.prototype.symbols.flag = symbols.flag;
  54194. Renderer.prototype.symbols.squarepin = symbols.squarepin;
  54195. }
  54196. /* *
  54197. *
  54198. * Default Export
  54199. *
  54200. * */
  54201. return symbols;
  54202. });
  54203. _registerModule(_modules, 'Series/Flags/FlagsSeries.js', [_modules['Series/Flags/FlagsPoint.js'], _modules['Core/Globals.js'], _modules['Mixins/OnSeries.js'], _modules['Core/Color/Palette.js'], _modules['Core/Series/SeriesRegistry.js'], _modules['Core/Renderer/SVG/SVGElement.js'], _modules['Core/Utilities.js']], function (FlagsPoint, H, OnSeriesMixin, palette, SeriesRegistry, SVGElement, U) {
  54204. /* *
  54205. *
  54206. * (c) 2010-2021 Torstein Honsi
  54207. *
  54208. * License: www.highcharts.com/license
  54209. *
  54210. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  54211. *
  54212. * */
  54213. var __extends = (this && this.__extends) || (function () {
  54214. var extendStatics = function (d,
  54215. b) {
  54216. extendStatics = Object.setPrototypeOf ||
  54217. ({ __proto__: [] } instanceof Array && function (d,
  54218. b) { d.__proto__ = b; }) ||
  54219. function (d,
  54220. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  54221. return extendStatics(d, b);
  54222. };
  54223. return function (d, b) {
  54224. extendStatics(d, b);
  54225. function __() { this.constructor = d; }
  54226. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  54227. };
  54228. })();
  54229. var noop = H.noop;
  54230. var Series = SeriesRegistry.series,
  54231. ColumnSeries = SeriesRegistry.seriesTypes.column;
  54232. var addEvent = U.addEvent,
  54233. defined = U.defined,
  54234. extend = U.extend,
  54235. merge = U.merge,
  54236. objectEach = U.objectEach,
  54237. wrap = U.wrap;
  54238. /**
  54239. * The Flags series.
  54240. *
  54241. * @private
  54242. * @class
  54243. * @name Highcharts.seriesTypes.flags
  54244. *
  54245. * @augments Highcharts.Series
  54246. */
  54247. var FlagsSeries = /** @class */ (function (_super) {
  54248. __extends(FlagsSeries, _super);
  54249. function FlagsSeries() {
  54250. /* *
  54251. *
  54252. * Static Properties
  54253. *
  54254. * */
  54255. var _this = _super !== null && _super.apply(this,
  54256. arguments) || this;
  54257. /* *
  54258. *
  54259. * Properties
  54260. *
  54261. * */
  54262. _this.data = void 0;
  54263. _this.options = void 0;
  54264. _this.points = void 0;
  54265. return _this;
  54266. /* eslint-enable valid-jsdoc */
  54267. }
  54268. /* *
  54269. *
  54270. * Functions
  54271. *
  54272. * */
  54273. /* eslint-disable valid-jsdoc */
  54274. /**
  54275. * Disable animation, but keep clipping (#8546).
  54276. * @private
  54277. */
  54278. FlagsSeries.prototype.animate = function (init) {
  54279. if (init) {
  54280. this.setClip();
  54281. }
  54282. };
  54283. /**
  54284. * Draw the markers.
  54285. * @private
  54286. */
  54287. FlagsSeries.prototype.drawPoints = function () {
  54288. var series = this,
  54289. points = series.points,
  54290. chart = series.chart,
  54291. renderer = chart.renderer,
  54292. plotX,
  54293. plotY,
  54294. inverted = chart.inverted,
  54295. options = series.options,
  54296. optionsY = options.y,
  54297. shape,
  54298. i,
  54299. point,
  54300. graphic,
  54301. stackIndex,
  54302. anchorY,
  54303. attribs,
  54304. outsideRight,
  54305. yAxis = series.yAxis,
  54306. boxesMap = {},
  54307. boxes = [],
  54308. centered;
  54309. i = points.length;
  54310. while (i--) {
  54311. point = points[i];
  54312. outsideRight =
  54313. (inverted ? point.plotY : point.plotX) >
  54314. series.xAxis.len;
  54315. plotX = point.plotX;
  54316. stackIndex = point.stackIndex;
  54317. shape = point.options.shape || options.shape;
  54318. plotY = point.plotY;
  54319. if (typeof plotY !== 'undefined') {
  54320. plotY = point.plotY + optionsY -
  54321. (typeof stackIndex !== 'undefined' &&
  54322. (stackIndex * options.stackDistance));
  54323. }
  54324. // skip connectors for higher level stacked points
  54325. point.anchorX = stackIndex ? void 0 : point.plotX;
  54326. anchorY = stackIndex ? void 0 : point.plotY;
  54327. centered = shape !== 'flag';
  54328. graphic = point.graphic;
  54329. // Only draw the point if y is defined and the flag is within
  54330. // the visible area
  54331. if (typeof plotY !== 'undefined' &&
  54332. plotX >= 0 &&
  54333. !outsideRight) {
  54334. // #15384
  54335. if (graphic && point.hasNewShapeType()) {
  54336. graphic = graphic.destroy();
  54337. }
  54338. // Create the flag
  54339. if (!graphic) {
  54340. graphic = point.graphic = renderer.label('', null, null, shape, null, null, options.useHTML)
  54341. .addClass('highcharts-point')
  54342. .add(series.markerGroup);
  54343. // Add reference to the point for tracker (#6303)
  54344. if (point.graphic.div) {
  54345. point.graphic.div.point = point;
  54346. }
  54347. graphic.isNew = true;
  54348. }
  54349. graphic.attr({
  54350. align: centered ? 'center' : 'left',
  54351. width: options.width,
  54352. height: options.height,
  54353. 'text-align': options.textAlign
  54354. });
  54355. if (!chart.styledMode) {
  54356. graphic
  54357. .attr(series.pointAttribs(point))
  54358. .css(merge(options.style, point.style))
  54359. .shadow(options.shadow);
  54360. }
  54361. if (plotX > 0) { // #3119
  54362. plotX -= graphic.strokeWidth() % 2; // #4285
  54363. }
  54364. // Plant the flag
  54365. attribs = {
  54366. y: plotY,
  54367. anchorY: anchorY
  54368. };
  54369. if (options.allowOverlapX) {
  54370. attribs.x = plotX;
  54371. attribs.anchorX = point.anchorX;
  54372. }
  54373. graphic.attr({
  54374. text: point.options.title || options.title || 'A'
  54375. })[graphic.isNew ? 'attr' : 'animate'](attribs);
  54376. // Rig for the distribute function
  54377. if (!options.allowOverlapX) {
  54378. if (!boxesMap[point.plotX]) {
  54379. boxesMap[point.plotX] = {
  54380. align: centered ? 0.5 : 0,
  54381. size: graphic.width,
  54382. target: plotX,
  54383. anchorX: plotX
  54384. };
  54385. }
  54386. else {
  54387. boxesMap[point.plotX].size = Math.max(boxesMap[point.plotX].size, graphic.width);
  54388. }
  54389. }
  54390. // Set the tooltip anchor position
  54391. point.tooltipPos = [
  54392. plotX,
  54393. plotY + yAxis.pos - chart.plotTop
  54394. ]; // #6327
  54395. }
  54396. else if (graphic) {
  54397. point.graphic = graphic.destroy();
  54398. }
  54399. }
  54400. // Handle X-dimension overlapping
  54401. if (!options.allowOverlapX) {
  54402. objectEach(boxesMap, function (box) {
  54403. box.plotX = box.anchorX;
  54404. boxes.push(box);
  54405. });
  54406. H.distribute(boxes, inverted ? yAxis.len : this.xAxis.len, 100);
  54407. points.forEach(function (point) {
  54408. var box = point.graphic && boxesMap[point.plotX];
  54409. if (box) {
  54410. point.graphic[point.graphic.isNew ? 'attr' : 'animate']({
  54411. x: box.pos + box.align * box.size,
  54412. anchorX: point.anchorX
  54413. });
  54414. // Hide flag when its box position is not specified
  54415. // (#8573, #9299)
  54416. if (!defined(box.pos)) {
  54417. point.graphic.attr({
  54418. x: -9999,
  54419. anchorX: -9999
  54420. });
  54421. point.graphic.isNew = true;
  54422. }
  54423. else {
  54424. point.graphic.isNew = false;
  54425. }
  54426. }
  54427. });
  54428. }
  54429. // Can be a mix of SVG and HTML and we need events for both (#6303)
  54430. if (options.useHTML) {
  54431. wrap(series.markerGroup, 'on', function (proceed) {
  54432. return SVGElement.prototype.on.apply(
  54433. // for HTML
  54434. // eslint-disable-next-line no-invalid-this
  54435. proceed.apply(this, [].slice.call(arguments, 1)),
  54436. // and for SVG
  54437. [].slice.call(arguments, 1));
  54438. });
  54439. }
  54440. };
  54441. /**
  54442. * Extend the column trackers with listeners to expand and contract
  54443. * stacks.
  54444. * @private
  54445. */
  54446. FlagsSeries.prototype.drawTracker = function () {
  54447. var series = this,
  54448. points = series.points;
  54449. _super.prototype.drawTracker.call(this);
  54450. /* *
  54451. * Bring each stacked flag up on mouse over, this allows readability
  54452. * of vertically stacked elements as well as tight points on the x
  54453. * axis. #1924.
  54454. */
  54455. points.forEach(function (point) {
  54456. var graphic = point.graphic;
  54457. if (graphic) {
  54458. if (point.unbindMouseOver) {
  54459. point.unbindMouseOver();
  54460. }
  54461. point.unbindMouseOver = addEvent(graphic.element, 'mouseover', function () {
  54462. // Raise this point
  54463. if (point.stackIndex > 0 &&
  54464. !point.raised) {
  54465. point._y = graphic.y;
  54466. graphic.attr({
  54467. y: point._y - 8
  54468. });
  54469. point.raised = true;
  54470. }
  54471. // Revert other raised points
  54472. points.forEach(function (otherPoint) {
  54473. if (otherPoint !== point &&
  54474. otherPoint.raised &&
  54475. otherPoint.graphic) {
  54476. otherPoint.graphic.attr({
  54477. y: otherPoint._y
  54478. });
  54479. otherPoint.raised = false;
  54480. }
  54481. });
  54482. });
  54483. }
  54484. });
  54485. };
  54486. /**
  54487. * Get presentational attributes
  54488. * @private
  54489. */
  54490. FlagsSeries.prototype.pointAttribs = function (point, state) {
  54491. var options = this.options,
  54492. color = (point && point.color) || this.color,
  54493. lineColor = options.lineColor,
  54494. lineWidth = (point && point.lineWidth),
  54495. fill = (point && point.fillColor) || options.fillColor;
  54496. if (state) {
  54497. fill = options.states[state].fillColor;
  54498. lineColor = options.states[state].lineColor;
  54499. lineWidth = options.states[state].lineWidth;
  54500. }
  54501. return {
  54502. fill: fill || color,
  54503. stroke: lineColor || color,
  54504. 'stroke-width': lineWidth || options.lineWidth || 0
  54505. };
  54506. };
  54507. /**
  54508. * @private
  54509. */
  54510. FlagsSeries.prototype.setClip = function () {
  54511. Series.prototype.setClip.apply(this, arguments);
  54512. if (this.options.clip !== false &&
  54513. this.sharedClipKey &&
  54514. this.markerGroup) {
  54515. this.markerGroup.clip(this.chart.sharedClips[this.sharedClipKey]);
  54516. }
  54517. };
  54518. /**
  54519. * Flags are used to mark events in stock charts. They can be added on the
  54520. * timeline, or attached to a specific series.
  54521. *
  54522. * @sample stock/demo/flags-general/
  54523. * Flags on a line series
  54524. *
  54525. * @extends plotOptions.column
  54526. * @excluding animation, borderColor, borderRadius, borderWidth,
  54527. * colorByPoint, dataGrouping, pointPadding, pointWidth,
  54528. * turboThreshold
  54529. * @product highstock
  54530. * @optionparent plotOptions.flags
  54531. */
  54532. FlagsSeries.defaultOptions = merge(ColumnSeries.defaultOptions, {
  54533. /**
  54534. * In case the flag is placed on a series, on what point key to place
  54535. * it. Line and columns have one key, `y`. In range or OHLC-type series,
  54536. * however, the flag can optionally be placed on the `open`, `high`,
  54537. * `low` or `close` key.
  54538. *
  54539. * @sample {highstock} stock/plotoptions/flags-onkey/
  54540. * Range series, flag on high
  54541. *
  54542. * @type {string}
  54543. * @default y
  54544. * @since 4.2.2
  54545. * @product highstock
  54546. * @validvalue ["y", "open", "high", "low", "close"]
  54547. * @apioption plotOptions.flags.onKey
  54548. */
  54549. /**
  54550. * The id of the series that the flags should be drawn on. If no id
  54551. * is given, the flags are drawn on the x axis.
  54552. *
  54553. * @sample {highstock} stock/plotoptions/flags/
  54554. * Flags on series and on x axis
  54555. *
  54556. * @type {string}
  54557. * @product highstock
  54558. * @apioption plotOptions.flags.onSeries
  54559. */
  54560. pointRange: 0,
  54561. /**
  54562. * Whether the flags are allowed to overlap sideways. If `false`, the
  54563. * flags are moved sideways using an algorithm that seeks to place every
  54564. * flag as close as possible to its original position.
  54565. *
  54566. * @sample {highstock} stock/plotoptions/flags-allowoverlapx
  54567. * Allow sideways overlap
  54568. *
  54569. * @since 6.0.4
  54570. */
  54571. allowOverlapX: false,
  54572. /**
  54573. * The shape of the marker. Can be one of "flag", "circlepin",
  54574. * "squarepin", or an image of the format `url(/path-to-image.jpg)`.
  54575. * Individual shapes can also be set for each point.
  54576. *
  54577. * @sample {highstock} stock/plotoptions/flags/
  54578. * Different shapes
  54579. *
  54580. * @type {Highcharts.FlagsShapeValue}
  54581. * @product highstock
  54582. */
  54583. shape: 'flag',
  54584. /**
  54585. * When multiple flags in the same series fall on the same value, this
  54586. * number determines the vertical offset between them.
  54587. *
  54588. * @sample {highstock} stock/plotoptions/flags-stackdistance/
  54589. * A greater stack distance
  54590. *
  54591. * @product highstock
  54592. */
  54593. stackDistance: 12,
  54594. /**
  54595. * Text alignment for the text inside the flag.
  54596. *
  54597. * @since 5.0.0
  54598. * @product highstock
  54599. * @validvalue ["left", "center", "right"]
  54600. */
  54601. textAlign: 'center',
  54602. /**
  54603. * Specific tooltip options for flag series. Flag series tooltips are
  54604. * different from most other types in that a flag doesn't have a data
  54605. * value, so the tooltip rather displays the `text` option for each
  54606. * point.
  54607. *
  54608. * @extends plotOptions.series.tooltip
  54609. * @excluding changeDecimals, valueDecimals, valuePrefix, valueSuffix
  54610. * @product highstock
  54611. */
  54612. tooltip: {
  54613. pointFormat: '{point.text}'
  54614. },
  54615. threshold: null,
  54616. /**
  54617. * The text to display on each flag. This can be defined on series
  54618. * level, or individually for each point. Defaults to `"A"`.
  54619. *
  54620. * @type {string}
  54621. * @default A
  54622. * @product highstock
  54623. * @apioption plotOptions.flags.title
  54624. */
  54625. /**
  54626. * The y position of the top left corner of the flag relative to either
  54627. * the series (if onSeries is defined), or the x axis. Defaults to
  54628. * `-30`.
  54629. *
  54630. * @product highstock
  54631. */
  54632. y: -30,
  54633. /**
  54634. * Whether to use HTML to render the flag texts. Using HTML allows for
  54635. * advanced formatting, images and reliable bi-directional text
  54636. * rendering. Note that exported images won't respect the HTML, and that
  54637. * HTML won't respect Z-index settings.
  54638. *
  54639. * @type {boolean}
  54640. * @default false
  54641. * @since 1.3
  54642. * @product highstock
  54643. * @apioption plotOptions.flags.useHTML
  54644. */
  54645. /**
  54646. * Fixed width of the flag's shape. By default, width is autocalculated
  54647. * according to the flag's title.
  54648. *
  54649. * @sample {highstock} stock/demo/flags-shapes/
  54650. * Flags with fixed width
  54651. *
  54652. * @type {number}
  54653. * @product highstock
  54654. * @apioption plotOptions.flags.width
  54655. */
  54656. /**
  54657. * Fixed height of the flag's shape. By default, height is
  54658. * autocalculated according to the flag's title.
  54659. *
  54660. * @type {number}
  54661. * @product highstock
  54662. * @apioption plotOptions.flags.height
  54663. */
  54664. /**
  54665. * The fill color for the flags.
  54666. *
  54667. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  54668. * @product highstock
  54669. */
  54670. fillColor: palette.backgroundColor,
  54671. /**
  54672. * The color of the line/border of the flag.
  54673. *
  54674. * In styled mode, the stroke is set in the
  54675. * `.highcharts-flag-series.highcharts-point` rule.
  54676. *
  54677. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  54678. * @default #000000
  54679. * @product highstock
  54680. * @apioption plotOptions.flags.lineColor
  54681. */
  54682. /**
  54683. * The pixel width of the flag's line/border.
  54684. *
  54685. * @product highstock
  54686. */
  54687. lineWidth: 1,
  54688. states: {
  54689. /**
  54690. * @extends plotOptions.column.states.hover
  54691. * @product highstock
  54692. */
  54693. hover: {
  54694. /**
  54695. * The color of the line/border of the flag.
  54696. *
  54697. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  54698. * @product highstock
  54699. */
  54700. lineColor: palette.neutralColor100,
  54701. /**
  54702. * The fill or background color of the flag.
  54703. *
  54704. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  54705. * @product highstock
  54706. */
  54707. fillColor: palette.highlightColor20
  54708. }
  54709. },
  54710. /**
  54711. * The text styles of the flag.
  54712. *
  54713. * In styled mode, the styles are set in the
  54714. * `.highcharts-flag-series .highcharts-point` rule.
  54715. *
  54716. * @type {Highcharts.CSSObject}
  54717. * @default {"fontSize": "11px", "fontWeight": "bold"}
  54718. * @product highstock
  54719. */
  54720. style: {
  54721. /** @ignore-option */
  54722. fontSize: '11px',
  54723. /** @ignore-option */
  54724. fontWeight: 'bold'
  54725. }
  54726. });
  54727. return FlagsSeries;
  54728. }(ColumnSeries));
  54729. extend(FlagsSeries.prototype, {
  54730. allowDG: false,
  54731. /**
  54732. * @private
  54733. * @function Highcharts.seriesTypes.flags#buildKDTree
  54734. */
  54735. buildKDTree: noop,
  54736. forceCrop: true,
  54737. getPlotBox: OnSeriesMixin.getPlotBox,
  54738. /**
  54739. * Inherit the initialization from base Series.
  54740. *
  54741. * @private
  54742. * @borrows Highcharts.Series#init as Highcharts.seriesTypes.flags#init
  54743. */
  54744. init: Series.prototype.init,
  54745. /**
  54746. * Don't invert the flag marker group (#4960).
  54747. *
  54748. * @private
  54749. * @function Highcharts.seriesTypes.flags#invertGroups
  54750. */
  54751. invertGroups: noop,
  54752. // Flags series group should not be invertible (#14063).
  54753. invertible: false,
  54754. noSharedTooltip: true,
  54755. pointClass: FlagsPoint,
  54756. sorted: false,
  54757. takeOrdinalPosition: false,
  54758. trackerGroups: ['markerGroup'],
  54759. translate: OnSeriesMixin.translate
  54760. });
  54761. SeriesRegistry.registerSeriesType('flags', FlagsSeries);
  54762. /* *
  54763. *
  54764. * Default Export
  54765. *
  54766. * */
  54767. /* *
  54768. *
  54769. * API Declarations
  54770. *
  54771. * */
  54772. /**
  54773. * @typedef {"circlepin"|"flag"|"squarepin"} Highcharts.FlagsShapeValue
  54774. */
  54775. ''; // detach doclets above
  54776. /* *
  54777. *
  54778. * API Option
  54779. *
  54780. * */
  54781. /**
  54782. * A `flags` series. If the [type](#series.flags.type) option is not
  54783. * specified, it is inherited from [chart.type](#chart.type).
  54784. *
  54785. * @extends series,plotOptions.flags
  54786. * @excluding animation, borderColor, borderRadius, borderWidth, colorByPoint,
  54787. * connectNulls, dashStyle, dataGrouping, dataParser, dataURL,
  54788. * gapSize, gapUnit, linecap, lineWidth, marker, pointPadding,
  54789. * pointWidth, step, turboThreshold, useOhlcData
  54790. * @product highstock
  54791. * @apioption series.flags
  54792. */
  54793. /**
  54794. * An array of data points for the series. For the `flags` series type,
  54795. * points can be given in the following ways:
  54796. *
  54797. * 1. An array of objects with named values. The following snippet shows only a
  54798. * few settings, see the complete options set below. If the total number of
  54799. * data points exceeds the series'
  54800. * [turboThreshold](#series.flags.turboThreshold), this option is not
  54801. * available.
  54802. * ```js
  54803. * data: [{
  54804. * x: 1,
  54805. * title: "A",
  54806. * text: "First event"
  54807. * }, {
  54808. * x: 1,
  54809. * title: "B",
  54810. * text: "Second event"
  54811. * }]
  54812. * ```
  54813. *
  54814. * @type {Array<*>}
  54815. * @extends series.line.data
  54816. * @excluding dataLabels, marker, name, y
  54817. * @product highstock
  54818. * @apioption series.flags.data
  54819. */
  54820. /**
  54821. * The fill color of an individual flag. By default it inherits from
  54822. * the series color.
  54823. *
  54824. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  54825. * @product highstock
  54826. * @apioption series.flags.data.fillColor
  54827. */
  54828. /**
  54829. * The longer text to be shown in the flag's tooltip.
  54830. *
  54831. * @type {string}
  54832. * @product highstock
  54833. * @apioption series.flags.data.text
  54834. */
  54835. /**
  54836. * The short text to be shown on the flag.
  54837. *
  54838. * @type {string}
  54839. * @product highstock
  54840. * @apioption series.flags.data.title
  54841. */
  54842. ''; // adds doclets above to transpiled file
  54843. return FlagsSeries;
  54844. });
  54845. _registerModule(_modules, 'Extensions/RangeSelector.js', [_modules['Core/Axis/Axis.js'], _modules['Core/Chart/Chart.js'], _modules['Core/Globals.js'], _modules['Core/DefaultOptions.js'], _modules['Core/Color/Palette.js'], _modules['Core/Renderer/SVG/SVGElement.js'], _modules['Core/Utilities.js']], function (Axis, Chart, H, D, palette, SVGElement, U) {
  54846. /* *
  54847. *
  54848. * (c) 2010-2021 Torstein Honsi
  54849. *
  54850. * License: www.highcharts.com/license
  54851. *
  54852. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  54853. *
  54854. * */
  54855. var defaultOptions = D.defaultOptions;
  54856. var addEvent = U.addEvent,
  54857. createElement = U.createElement,
  54858. css = U.css,
  54859. defined = U.defined,
  54860. destroyObjectProperties = U.destroyObjectProperties,
  54861. discardElement = U.discardElement,
  54862. extend = U.extend,
  54863. find = U.find,
  54864. fireEvent = U.fireEvent,
  54865. isNumber = U.isNumber,
  54866. merge = U.merge,
  54867. objectEach = U.objectEach,
  54868. pad = U.pad,
  54869. pick = U.pick,
  54870. pInt = U.pInt,
  54871. splat = U.splat;
  54872. /**
  54873. * Define the time span for the button
  54874. *
  54875. * @typedef {"all"|"day"|"hour"|"millisecond"|"minute"|"month"|"second"|"week"|"year"|"ytd"} Highcharts.RangeSelectorButtonTypeValue
  54876. */
  54877. /**
  54878. * Callback function to react on button clicks.
  54879. *
  54880. * @callback Highcharts.RangeSelectorClickCallbackFunction
  54881. *
  54882. * @param {global.Event} e
  54883. * Event arguments.
  54884. *
  54885. * @param {boolean|undefined}
  54886. * Return false to cancel the default button event.
  54887. */
  54888. /**
  54889. * Callback function to parse values entered in the input boxes and return a
  54890. * valid JavaScript time as milliseconds since 1970.
  54891. *
  54892. * @callback Highcharts.RangeSelectorParseCallbackFunction
  54893. *
  54894. * @param {string} value
  54895. * Input value to parse.
  54896. *
  54897. * @return {number}
  54898. * Parsed JavaScript time value.
  54899. */
  54900. /* ************************************************************************** *
  54901. * Start Range Selector code *
  54902. * ************************************************************************** */
  54903. extend(defaultOptions, {
  54904. /**
  54905. * The range selector is a tool for selecting ranges to display within
  54906. * the chart. It provides buttons to select preconfigured ranges in
  54907. * the chart, like 1 day, 1 week, 1 month etc. It also provides input
  54908. * boxes where min and max dates can be manually input.
  54909. *
  54910. * @product highstock gantt
  54911. * @optionparent rangeSelector
  54912. */
  54913. rangeSelector: {
  54914. /**
  54915. * Whether to enable all buttons from the start. By default buttons are
  54916. * only enabled if the corresponding time range exists on the X axis,
  54917. * but enabling all buttons allows for dynamically loading different
  54918. * time ranges.
  54919. *
  54920. * @sample {highstock} stock/rangeselector/allbuttonsenabled-true/
  54921. * All buttons enabled
  54922. *
  54923. * @since 2.0.3
  54924. */
  54925. allButtonsEnabled: false,
  54926. /**
  54927. * An array of configuration objects for the buttons.
  54928. *
  54929. * Defaults to:
  54930. * ```js
  54931. * buttons: [{
  54932. * type: 'month',
  54933. * count: 1,
  54934. * text: '1m',
  54935. * title: 'View 1 month'
  54936. * }, {
  54937. * type: 'month',
  54938. * count: 3,
  54939. * text: '3m',
  54940. * title: 'View 3 months'
  54941. * }, {
  54942. * type: 'month',
  54943. * count: 6,
  54944. * text: '6m',
  54945. * title: 'View 6 months'
  54946. * }, {
  54947. * type: 'ytd',
  54948. * text: 'YTD',
  54949. * title: 'View year to date'
  54950. * }, {
  54951. * type: 'year',
  54952. * count: 1,
  54953. * text: '1y',
  54954. * title: 'View 1 year'
  54955. * }, {
  54956. * type: 'all',
  54957. * text: 'All',
  54958. * title: 'View all'
  54959. * }]
  54960. * ```
  54961. *
  54962. * @sample {highstock} stock/rangeselector/datagrouping/
  54963. * Data grouping by buttons
  54964. *
  54965. * @type {Array<*>}
  54966. */
  54967. buttons: void 0,
  54968. /**
  54969. * How many units of the defined type the button should span. If `type`
  54970. * is "month" and `count` is 3, the button spans three months.
  54971. *
  54972. * @type {number}
  54973. * @default 1
  54974. * @apioption rangeSelector.buttons.count
  54975. */
  54976. /**
  54977. * Fires when clicking on the rangeSelector button. One parameter,
  54978. * event, is passed to the function, containing common event
  54979. * information.
  54980. *
  54981. * ```js
  54982. * click: function(e) {
  54983. * console.log(this);
  54984. * }
  54985. * ```
  54986. *
  54987. * Return false to stop default button's click action.
  54988. *
  54989. * @sample {highstock} stock/rangeselector/button-click/
  54990. * Click event on the button
  54991. *
  54992. * @type {Highcharts.RangeSelectorClickCallbackFunction}
  54993. * @apioption rangeSelector.buttons.events.click
  54994. */
  54995. /**
  54996. * Additional range (in milliseconds) added to the end of the calculated
  54997. * time span.
  54998. *
  54999. * @sample {highstock} stock/rangeselector/min-max-offsets/
  55000. * Button offsets
  55001. *
  55002. * @type {number}
  55003. * @default 0
  55004. * @since 6.0.0
  55005. * @apioption rangeSelector.buttons.offsetMax
  55006. */
  55007. /**
  55008. * Additional range (in milliseconds) added to the start of the
  55009. * calculated time span.
  55010. *
  55011. * @sample {highstock} stock/rangeselector/min-max-offsets/
  55012. * Button offsets
  55013. *
  55014. * @type {number}
  55015. * @default 0
  55016. * @since 6.0.0
  55017. * @apioption rangeSelector.buttons.offsetMin
  55018. */
  55019. /**
  55020. * When buttons apply dataGrouping on a series, by default zooming
  55021. * in/out will deselect buttons and unset dataGrouping. Enable this
  55022. * option to keep buttons selected when extremes change.
  55023. *
  55024. * @sample {highstock} stock/rangeselector/preserve-datagrouping/
  55025. * Different preserveDataGrouping settings
  55026. *
  55027. * @type {boolean}
  55028. * @default false
  55029. * @since 6.1.2
  55030. * @apioption rangeSelector.buttons.preserveDataGrouping
  55031. */
  55032. /**
  55033. * A custom data grouping object for each button.
  55034. *
  55035. * @see [series.dataGrouping](#plotOptions.series.dataGrouping)
  55036. *
  55037. * @sample {highstock} stock/rangeselector/datagrouping/
  55038. * Data grouping by range selector buttons
  55039. *
  55040. * @type {*}
  55041. * @extends plotOptions.series.dataGrouping
  55042. * @apioption rangeSelector.buttons.dataGrouping
  55043. */
  55044. /**
  55045. * The text for the button itself.
  55046. *
  55047. * @type {string}
  55048. * @apioption rangeSelector.buttons.text
  55049. */
  55050. /**
  55051. * Explanation for the button, shown as a tooltip on hover, and used by
  55052. * assistive technology.
  55053. *
  55054. * @type {string}
  55055. * @apioption rangeSelector.buttons.title
  55056. */
  55057. /**
  55058. * Defined the time span for the button. Can be one of `millisecond`,
  55059. * `second`, `minute`, `hour`, `day`, `week`, `month`, `year`, `ytd`,
  55060. * and `all`.
  55061. *
  55062. * @type {Highcharts.RangeSelectorButtonTypeValue}
  55063. * @apioption rangeSelector.buttons.type
  55064. */
  55065. /**
  55066. * The space in pixels between the buttons in the range selector.
  55067. */
  55068. buttonSpacing: 5,
  55069. /**
  55070. * Whether to collapse the range selector buttons into a dropdown when
  55071. * there is not enough room to show everything in a single row, instead
  55072. * of dividing the range selector into multiple rows.
  55073. * Can be one of the following:
  55074. * - `always`: Always collapse
  55075. * - `responsive`: Only collapse when there is not enough room
  55076. * - `never`: Never collapse
  55077. *
  55078. * @sample {highstock} stock/rangeselector/dropdown/
  55079. * Dropdown option
  55080. *
  55081. * @validvalue ["always", "responsive", "never"]
  55082. * @since 9.0.0
  55083. */
  55084. dropdown: 'responsive',
  55085. /**
  55086. * Enable or disable the range selector. Default to `true` for stock
  55087. * charts, using the `stockChart` factory.
  55088. *
  55089. * @sample {highstock} stock/rangeselector/enabled/
  55090. * Disable the range selector
  55091. *
  55092. * @type {boolean|undefined}
  55093. * @default {highstock} true
  55094. */
  55095. enabled: void 0,
  55096. /**
  55097. * The vertical alignment of the rangeselector box. Allowed properties
  55098. * are `top`, `middle`, `bottom`.
  55099. *
  55100. * @sample {highstock} stock/rangeselector/vertical-align-middle/
  55101. * Middle
  55102. * @sample {highstock} stock/rangeselector/vertical-align-bottom/
  55103. * Bottom
  55104. *
  55105. * @type {Highcharts.VerticalAlignValue}
  55106. * @since 6.0.0
  55107. */
  55108. verticalAlign: 'top',
  55109. /**
  55110. * A collection of attributes for the buttons. The object takes SVG
  55111. * attributes like `fill`, `stroke`, `stroke-width`, as well as `style`,
  55112. * a collection of CSS properties for the text.
  55113. *
  55114. * The object can also be extended with states, so you can set
  55115. * presentational options for `hover`, `select` or `disabled` button
  55116. * states.
  55117. *
  55118. * CSS styles for the text label.
  55119. *
  55120. * In styled mode, the buttons are styled by the
  55121. * `.highcharts-range-selector-buttons .highcharts-button` rule with its
  55122. * different states.
  55123. *
  55124. * @sample {highstock} stock/rangeselector/styling/
  55125. * Styling the buttons and inputs
  55126. *
  55127. * @type {Highcharts.SVGAttributes}
  55128. */
  55129. buttonTheme: {
  55130. /** @ignore */
  55131. width: 28,
  55132. /** @ignore */
  55133. height: 18,
  55134. /** @ignore */
  55135. padding: 2,
  55136. /** @ignore */
  55137. zIndex: 7 // #484, #852
  55138. },
  55139. /**
  55140. * When the rangeselector is floating, the plot area does not reserve
  55141. * space for it. This opens for positioning anywhere on the chart.
  55142. *
  55143. * @sample {highstock} stock/rangeselector/floating/
  55144. * Placing the range selector between the plot area and the
  55145. * navigator
  55146. *
  55147. * @since 6.0.0
  55148. */
  55149. floating: false,
  55150. /**
  55151. * The x offset of the range selector relative to its horizontal
  55152. * alignment within `chart.spacingLeft` and `chart.spacingRight`.
  55153. *
  55154. * @since 6.0.0
  55155. */
  55156. x: 0,
  55157. /**
  55158. * The y offset of the range selector relative to its horizontal
  55159. * alignment within `chart.spacingLeft` and `chart.spacingRight`.
  55160. *
  55161. * @since 6.0.0
  55162. */
  55163. y: 0,
  55164. /**
  55165. * Deprecated. The height of the range selector. Currently it is
  55166. * calculated dynamically.
  55167. *
  55168. * @deprecated
  55169. * @type {number|undefined}
  55170. * @since 2.1.9
  55171. */
  55172. height: void 0,
  55173. /**
  55174. * The border color of the date input boxes.
  55175. *
  55176. * @sample {highstock} stock/rangeselector/styling/
  55177. * Styling the buttons and inputs
  55178. *
  55179. * @type {Highcharts.ColorString}
  55180. * @since 1.3.7
  55181. */
  55182. inputBoxBorderColor: 'none',
  55183. /**
  55184. * The pixel height of the date input boxes.
  55185. *
  55186. * @sample {highstock} stock/rangeselector/styling/
  55187. * Styling the buttons and inputs
  55188. *
  55189. * @since 1.3.7
  55190. */
  55191. inputBoxHeight: 17,
  55192. /**
  55193. * The pixel width of the date input boxes. When `undefined`, the width
  55194. * is fitted to the rendered content.
  55195. *
  55196. * @sample {highstock} stock/rangeselector/styling/
  55197. * Styling the buttons and inputs
  55198. *
  55199. * @type {number|undefined}
  55200. * @since 1.3.7
  55201. */
  55202. inputBoxWidth: void 0,
  55203. /**
  55204. * The date format in the input boxes when not selected for editing.
  55205. * Defaults to `%b %e, %Y`.
  55206. *
  55207. * This is used to determine which type of input to show,
  55208. * `datetime-local`, `date` or `time` and falling back to `text` when
  55209. * the browser does not support the input type or the format contains
  55210. * milliseconds.
  55211. *
  55212. * @sample {highstock} stock/rangeselector/input-type/
  55213. * Input types
  55214. * @sample {highstock} stock/rangeselector/input-format/
  55215. * Milliseconds in the range selector
  55216. *
  55217. */
  55218. inputDateFormat: '%b %e, %Y',
  55219. /**
  55220. * A custom callback function to parse values entered in the input boxes
  55221. * and return a valid JavaScript time as milliseconds since 1970.
  55222. * The first argument passed is a value to parse,
  55223. * second is a boolean indicating use of the UTC time.
  55224. *
  55225. * This will only get called for inputs of type `text`. Since v8.2.3,
  55226. * the input type is dynamically determined based on the granularity
  55227. * of the `inputDateFormat` and the browser support.
  55228. *
  55229. * @sample {highstock} stock/rangeselector/input-format/
  55230. * Milliseconds in the range selector
  55231. *
  55232. * @type {Highcharts.RangeSelectorParseCallbackFunction}
  55233. * @since 1.3.3
  55234. */
  55235. inputDateParser: void 0,
  55236. /**
  55237. * The date format in the input boxes when they are selected for
  55238. * editing. This must be a format that is recognized by JavaScript
  55239. * Date.parse.
  55240. *
  55241. * This will only be used for inputs of type `text`. Since v8.2.3,
  55242. * the input type is dynamically determined based on the granularity
  55243. * of the `inputDateFormat` and the browser support.
  55244. *
  55245. * @sample {highstock} stock/rangeselector/input-format/
  55246. * Milliseconds in the range selector
  55247. *
  55248. */
  55249. inputEditDateFormat: '%Y-%m-%d',
  55250. /**
  55251. * Enable or disable the date input boxes.
  55252. */
  55253. inputEnabled: true,
  55254. /**
  55255. * Positioning for the input boxes. Allowed properties are `align`,
  55256. * `x` and `y`.
  55257. *
  55258. * @since 1.2.4
  55259. */
  55260. inputPosition: {
  55261. /**
  55262. * The alignment of the input box. Allowed properties are `left`,
  55263. * `center`, `right`.
  55264. *
  55265. * @sample {highstock} stock/rangeselector/input-button-position/
  55266. * Alignment
  55267. *
  55268. * @type {Highcharts.AlignValue}
  55269. * @since 6.0.0
  55270. */
  55271. align: 'right',
  55272. /**
  55273. * X offset of the input row.
  55274. */
  55275. x: 0,
  55276. /**
  55277. * Y offset of the input row.
  55278. */
  55279. y: 0
  55280. },
  55281. /**
  55282. * The space in pixels between the labels and the date input boxes in
  55283. * the range selector.
  55284. *
  55285. * @since 9.0.0
  55286. */
  55287. inputSpacing: 5,
  55288. /**
  55289. * The index of the button to appear pre-selected.
  55290. *
  55291. * @type {number}
  55292. */
  55293. selected: void 0,
  55294. /**
  55295. * Positioning for the button row.
  55296. *
  55297. * @since 1.2.4
  55298. */
  55299. buttonPosition: {
  55300. /**
  55301. * The alignment of the input box. Allowed properties are `left`,
  55302. * `center`, `right`.
  55303. *
  55304. * @sample {highstock} stock/rangeselector/input-button-position/
  55305. * Alignment
  55306. *
  55307. * @type {Highcharts.AlignValue}
  55308. * @since 6.0.0
  55309. */
  55310. align: 'left',
  55311. /**
  55312. * X offset of the button row.
  55313. */
  55314. x: 0,
  55315. /**
  55316. * Y offset of the button row.
  55317. */
  55318. y: 0
  55319. },
  55320. /**
  55321. * CSS for the HTML inputs in the range selector.
  55322. *
  55323. * In styled mode, the inputs are styled by the
  55324. * `.highcharts-range-input text` rule in SVG mode, and
  55325. * `input.highcharts-range-selector` when active.
  55326. *
  55327. * @sample {highstock} stock/rangeselector/styling/
  55328. * Styling the buttons and inputs
  55329. *
  55330. * @type {Highcharts.CSSObject}
  55331. * @apioption rangeSelector.inputStyle
  55332. */
  55333. inputStyle: {
  55334. /** @ignore */
  55335. color: palette.highlightColor80,
  55336. /** @ignore */
  55337. cursor: 'pointer'
  55338. },
  55339. /**
  55340. * CSS styles for the labels - the Zoom, From and To texts.
  55341. *
  55342. * In styled mode, the labels are styled by the
  55343. * `.highcharts-range-label` class.
  55344. *
  55345. * @sample {highstock} stock/rangeselector/styling/
  55346. * Styling the buttons and inputs
  55347. *
  55348. * @type {Highcharts.CSSObject}
  55349. */
  55350. labelStyle: {
  55351. /** @ignore */
  55352. color: palette.neutralColor60
  55353. }
  55354. }
  55355. });
  55356. extend(defaultOptions.lang,
  55357. /**
  55358. * Language object. The language object is global and it can't be set
  55359. * on each chart initialization. Instead, use `Highcharts.setOptions` to
  55360. * set it before any chart is initialized.
  55361. *
  55362. * ```js
  55363. * Highcharts.setOptions({
  55364. * lang: {
  55365. * months: [
  55366. * 'Janvier', 'Février', 'Mars', 'Avril',
  55367. * 'Mai', 'Juin', 'Juillet', 'Août',
  55368. * 'Septembre', 'Octobre', 'Novembre', 'Décembre'
  55369. * ],
  55370. * weekdays: [
  55371. * 'Dimanche', 'Lundi', 'Mardi', 'Mercredi',
  55372. * 'Jeudi', 'Vendredi', 'Samedi'
  55373. * ]
  55374. * }
  55375. * });
  55376. * ```
  55377. *
  55378. * @optionparent lang
  55379. */
  55380. {
  55381. /**
  55382. * The text for the label for the range selector buttons.
  55383. *
  55384. * @product highstock gantt
  55385. */
  55386. rangeSelectorZoom: 'Zoom',
  55387. /**
  55388. * The text for the label for the "from" input box in the range
  55389. * selector. Since v9.0, this string is empty as the label is not
  55390. * rendered by default.
  55391. *
  55392. * @product highstock gantt
  55393. */
  55394. rangeSelectorFrom: '',
  55395. /**
  55396. * The text for the label for the "to" input box in the range selector.
  55397. *
  55398. * @product highstock gantt
  55399. */
  55400. rangeSelectorTo: '→'
  55401. });
  55402. /* eslint-disable no-invalid-this, valid-jsdoc */
  55403. /**
  55404. * The range selector.
  55405. *
  55406. * @private
  55407. * @class
  55408. * @name Highcharts.RangeSelector
  55409. * @param {Highcharts.Chart} chart
  55410. */
  55411. var RangeSelector = /** @class */ (function () {
  55412. function RangeSelector(chart) {
  55413. /* *
  55414. *
  55415. * Properties
  55416. *
  55417. * */
  55418. this.buttons = void 0;
  55419. this.buttonOptions = RangeSelector.prototype.defaultButtons;
  55420. this.initialButtonGroupWidth = 0;
  55421. this.options = void 0;
  55422. this.chart = chart;
  55423. // Run RangeSelector
  55424. this.init(chart);
  55425. }
  55426. /**
  55427. * The method to run when one of the buttons in the range selectors is
  55428. * clicked
  55429. *
  55430. * @private
  55431. * @function Highcharts.RangeSelector#clickButton
  55432. * @param {number} i
  55433. * The index of the button
  55434. * @param {boolean} [redraw]
  55435. * @return {void}
  55436. */
  55437. RangeSelector.prototype.clickButton = function (i, redraw) {
  55438. var rangeSelector = this,
  55439. chart = rangeSelector.chart,
  55440. rangeOptions = rangeSelector.buttonOptions[i],
  55441. baseAxis = chart.xAxis[0],
  55442. unionExtremes = (chart.scroller && chart.scroller.getUnionExtremes()) || baseAxis || {},
  55443. dataMin = unionExtremes.dataMin,
  55444. dataMax = unionExtremes.dataMax,
  55445. newMin,
  55446. newMax = baseAxis && Math.round(Math.min(baseAxis.max,
  55447. pick(dataMax,
  55448. baseAxis.max))), // #1568
  55449. type = rangeOptions.type,
  55450. baseXAxisOptions,
  55451. range = rangeOptions._range,
  55452. rangeMin,
  55453. minSetting,
  55454. rangeSetting,
  55455. ctx,
  55456. ytdExtremes,
  55457. dataGrouping = rangeOptions.dataGrouping;
  55458. // chart has no data, base series is removed
  55459. if (dataMin === null || dataMax === null) {
  55460. return;
  55461. }
  55462. // Set the fixed range before range is altered
  55463. chart.fixedRange = range;
  55464. rangeSelector.setSelected(i);
  55465. // Apply dataGrouping associated to button
  55466. if (dataGrouping) {
  55467. this.forcedDataGrouping = true;
  55468. Axis.prototype.setDataGrouping.call(baseAxis || { chart: this.chart }, dataGrouping, false);
  55469. this.frozenStates = rangeOptions.preserveDataGrouping;
  55470. }
  55471. // Apply range
  55472. if (type === 'month' || type === 'year') {
  55473. if (!baseAxis) {
  55474. // This is set to the user options and picked up later when the
  55475. // axis is instantiated so that we know the min and max.
  55476. range = rangeOptions;
  55477. }
  55478. else {
  55479. ctx = {
  55480. range: rangeOptions,
  55481. max: newMax,
  55482. chart: chart,
  55483. dataMin: dataMin,
  55484. dataMax: dataMax
  55485. };
  55486. newMin = baseAxis.minFromRange.call(ctx);
  55487. if (isNumber(ctx.newMax)) {
  55488. newMax = ctx.newMax;
  55489. }
  55490. }
  55491. // Fixed times like minutes, hours, days
  55492. }
  55493. else if (range) {
  55494. newMin = Math.max(newMax - range, dataMin);
  55495. newMax = Math.min(newMin + range, dataMax);
  55496. }
  55497. else if (type === 'ytd') {
  55498. // On user clicks on the buttons, or a delayed action running from
  55499. // the beforeRender event (below), the baseAxis is defined.
  55500. if (baseAxis) {
  55501. // When "ytd" is the pre-selected button for the initial view,
  55502. // its calculation is delayed and rerun in the beforeRender
  55503. // event (below). When the series are initialized, but before
  55504. // the chart is rendered, we have access to the xData array
  55505. // (#942).
  55506. if (typeof dataMax === 'undefined') {
  55507. dataMin = Number.MAX_VALUE;
  55508. dataMax = Number.MIN_VALUE;
  55509. chart.series.forEach(function (series) {
  55510. // reassign it to the last item
  55511. var xData = series.xData;
  55512. dataMin = Math.min(xData[0], dataMin);
  55513. dataMax = Math.max(xData[xData.length - 1], dataMax);
  55514. });
  55515. redraw = false;
  55516. }
  55517. ytdExtremes = rangeSelector.getYTDExtremes(dataMax, dataMin, chart.time.useUTC);
  55518. newMin = rangeMin = ytdExtremes.min;
  55519. newMax = ytdExtremes.max;
  55520. // "ytd" is pre-selected. We don't yet have access to processed
  55521. // point and extremes data (things like pointStart and pointInterval
  55522. // are missing), so we delay the process (#942)
  55523. }
  55524. else {
  55525. rangeSelector.deferredYTDClick = i;
  55526. return;
  55527. }
  55528. }
  55529. else if (type === 'all' && baseAxis) {
  55530. // If the navigator exist and the axis range is declared reset that
  55531. // range and from now on only use the range set by a user, #14742.
  55532. if (chart.navigator && chart.navigator.baseSeries[0]) {
  55533. chart.navigator.baseSeries[0].xAxis.options.range = void 0;
  55534. }
  55535. newMin = dataMin;
  55536. newMax = dataMax;
  55537. }
  55538. if (defined(newMin)) {
  55539. newMin += rangeOptions._offsetMin;
  55540. }
  55541. if (defined(newMax)) {
  55542. newMax += rangeOptions._offsetMax;
  55543. }
  55544. if (this.dropdown) {
  55545. this.dropdown.selectedIndex = i + 1;
  55546. }
  55547. // Update the chart
  55548. if (!baseAxis) {
  55549. // Axis not yet instanciated. Temporarily set min and range
  55550. // options and remove them on chart load (#4317).
  55551. baseXAxisOptions = splat(chart.options.xAxis)[0];
  55552. rangeSetting = baseXAxisOptions.range;
  55553. baseXAxisOptions.range = range;
  55554. minSetting = baseXAxisOptions.min;
  55555. baseXAxisOptions.min = rangeMin;
  55556. addEvent(chart, 'load', function resetMinAndRange() {
  55557. baseXAxisOptions.range = rangeSetting;
  55558. baseXAxisOptions.min = minSetting;
  55559. });
  55560. }
  55561. else {
  55562. // Existing axis object. Set extremes after render time.
  55563. baseAxis.setExtremes(newMin, newMax, pick(redraw, true), void 0, // auto animation
  55564. {
  55565. trigger: 'rangeSelectorButton',
  55566. rangeSelectorButton: rangeOptions
  55567. });
  55568. }
  55569. fireEvent(this, 'afterBtnClick');
  55570. };
  55571. /**
  55572. * Set the selected option. This method only sets the internal flag, it
  55573. * doesn't update the buttons or the actual zoomed range.
  55574. *
  55575. * @private
  55576. * @function Highcharts.RangeSelector#setSelected
  55577. * @param {number} [selected]
  55578. * @return {void}
  55579. */
  55580. RangeSelector.prototype.setSelected = function (selected) {
  55581. this.selected = this.options.selected = selected;
  55582. };
  55583. /**
  55584. * Initialize the range selector
  55585. *
  55586. * @private
  55587. * @function Highcharts.RangeSelector#init
  55588. * @param {Highcharts.Chart} chart
  55589. * @return {void}
  55590. */
  55591. RangeSelector.prototype.init = function (chart) {
  55592. var rangeSelector = this,
  55593. options = chart.options.rangeSelector,
  55594. buttonOptions = options.buttons || rangeSelector.defaultButtons.slice(),
  55595. selectedOption = options.selected,
  55596. blurInputs = function () {
  55597. var minInput = rangeSelector.minInput,
  55598. maxInput = rangeSelector.maxInput;
  55599. // #3274 in some case blur is not defined
  55600. if (minInput && minInput.blur) {
  55601. fireEvent(minInput, 'blur');
  55602. }
  55603. if (maxInput && maxInput.blur) {
  55604. fireEvent(maxInput, 'blur');
  55605. }
  55606. };
  55607. rangeSelector.chart = chart;
  55608. rangeSelector.options = options;
  55609. rangeSelector.buttons = [];
  55610. rangeSelector.buttonOptions = buttonOptions;
  55611. this.eventsToUnbind = [];
  55612. this.eventsToUnbind.push(addEvent(chart.container, 'mousedown', blurInputs));
  55613. this.eventsToUnbind.push(addEvent(chart, 'resize', blurInputs));
  55614. // Extend the buttonOptions with actual range
  55615. buttonOptions.forEach(rangeSelector.computeButtonRange);
  55616. // zoomed range based on a pre-selected button index
  55617. if (typeof selectedOption !== 'undefined' &&
  55618. buttonOptions[selectedOption]) {
  55619. this.clickButton(selectedOption, false);
  55620. }
  55621. this.eventsToUnbind.push(addEvent(chart, 'load', function () {
  55622. // If a data grouping is applied to the current button, release it
  55623. // when extremes change
  55624. if (chart.xAxis && chart.xAxis[0]) {
  55625. addEvent(chart.xAxis[0], 'setExtremes', function (e) {
  55626. if (this.max - this.min !==
  55627. chart.fixedRange &&
  55628. e.trigger !== 'rangeSelectorButton' &&
  55629. e.trigger !== 'updatedData' &&
  55630. rangeSelector.forcedDataGrouping &&
  55631. !rangeSelector.frozenStates) {
  55632. this.setDataGrouping(false, false);
  55633. }
  55634. });
  55635. }
  55636. }));
  55637. };
  55638. /**
  55639. * Dynamically update the range selector buttons after a new range has been
  55640. * set
  55641. *
  55642. * @private
  55643. * @function Highcharts.RangeSelector#updateButtonStates
  55644. * @return {void}
  55645. */
  55646. RangeSelector.prototype.updateButtonStates = function () {
  55647. var rangeSelector = this,
  55648. chart = this.chart,
  55649. dropdown = this.dropdown,
  55650. baseAxis = chart.xAxis[0],
  55651. actualRange = Math.round(baseAxis.max - baseAxis.min),
  55652. hasNoData = !baseAxis.hasVisibleSeries,
  55653. day = 24 * 36e5, // A single day in milliseconds
  55654. unionExtremes = (chart.scroller &&
  55655. chart.scroller.getUnionExtremes()) || baseAxis,
  55656. dataMin = unionExtremes.dataMin,
  55657. dataMax = unionExtremes.dataMax,
  55658. ytdExtremes = rangeSelector.getYTDExtremes(dataMax,
  55659. dataMin,
  55660. chart.time.useUTC),
  55661. ytdMin = ytdExtremes.min,
  55662. ytdMax = ytdExtremes.max,
  55663. selected = rangeSelector.selected,
  55664. selectedExists = isNumber(selected),
  55665. allButtonsEnabled = rangeSelector.options.allButtonsEnabled,
  55666. buttons = rangeSelector.buttons;
  55667. rangeSelector.buttonOptions.forEach(function (rangeOptions, i) {
  55668. var range = rangeOptions._range,
  55669. type = rangeOptions.type,
  55670. count = rangeOptions.count || 1,
  55671. button = buttons[i],
  55672. state = 0,
  55673. disable,
  55674. select,
  55675. offsetRange = rangeOptions._offsetMax -
  55676. rangeOptions._offsetMin,
  55677. isSelected = i === selected,
  55678. // Disable buttons where the range exceeds what is allowed in
  55679. // the current view
  55680. isTooGreatRange = range >
  55681. dataMax - dataMin,
  55682. // Disable buttons where the range is smaller than the minimum
  55683. // range
  55684. isTooSmallRange = range < baseAxis.minRange,
  55685. // Do not select the YTD button if not explicitly told so
  55686. isYTDButNotSelected = false,
  55687. // Disable the All button if we're already showing all
  55688. isAllButAlreadyShowingAll = false,
  55689. isSameRange = range === actualRange;
  55690. // Months and years have a variable range so we check the extremes
  55691. if ((type === 'month' || type === 'year') &&
  55692. (actualRange + 36e5 >=
  55693. { month: 28, year: 365 }[type] * day * count - offsetRange) &&
  55694. (actualRange - 36e5 <=
  55695. { month: 31, year: 366 }[type] * day * count + offsetRange)) {
  55696. isSameRange = true;
  55697. }
  55698. else if (type === 'ytd') {
  55699. isSameRange = (ytdMax - ytdMin + offsetRange) === actualRange;
  55700. isYTDButNotSelected = !isSelected;
  55701. }
  55702. else if (type === 'all') {
  55703. isSameRange = (baseAxis.max - baseAxis.min >=
  55704. dataMax - dataMin);
  55705. isAllButAlreadyShowingAll = (!isSelected &&
  55706. selectedExists &&
  55707. isSameRange);
  55708. }
  55709. // The new zoom area happens to match the range for a button - mark
  55710. // it selected. This happens when scrolling across an ordinal gap.
  55711. // It can be seen in the intraday demos when selecting 1h and scroll
  55712. // across the night gap.
  55713. disable = (!allButtonsEnabled &&
  55714. (isTooGreatRange ||
  55715. isTooSmallRange ||
  55716. isAllButAlreadyShowingAll ||
  55717. hasNoData));
  55718. select = ((isSelected && isSameRange) ||
  55719. (isSameRange && !selectedExists && !isYTDButNotSelected) ||
  55720. (isSelected && rangeSelector.frozenStates));
  55721. if (disable) {
  55722. state = 3;
  55723. }
  55724. else if (select) {
  55725. selectedExists = true; // Only one button can be selected
  55726. state = 2;
  55727. }
  55728. // If state has changed, update the button
  55729. if (button.state !== state) {
  55730. button.setState(state);
  55731. if (dropdown) {
  55732. dropdown.options[i + 1].disabled = disable;
  55733. if (state === 2) {
  55734. dropdown.selectedIndex = i + 1;
  55735. }
  55736. }
  55737. // Reset (#9209)
  55738. if (state === 0 && selected === i) {
  55739. rangeSelector.setSelected();
  55740. }
  55741. }
  55742. });
  55743. };
  55744. /**
  55745. * Compute and cache the range for an individual button
  55746. *
  55747. * @private
  55748. * @function Highcharts.RangeSelector#computeButtonRange
  55749. * @param {Highcharts.RangeSelectorButtonsOptions} rangeOptions
  55750. * @return {void}
  55751. */
  55752. RangeSelector.prototype.computeButtonRange = function (rangeOptions) {
  55753. var type = rangeOptions.type,
  55754. count = rangeOptions.count || 1,
  55755. // these time intervals have a fixed number of milliseconds, as
  55756. // opposed to month, ytd and year
  55757. fixedTimes = {
  55758. millisecond: 1,
  55759. second: 1000,
  55760. minute: 60 * 1000,
  55761. hour: 3600 * 1000,
  55762. day: 24 * 3600 * 1000,
  55763. week: 7 * 24 * 3600 * 1000
  55764. };
  55765. // Store the range on the button object
  55766. if (fixedTimes[type]) {
  55767. rangeOptions._range = fixedTimes[type] * count;
  55768. }
  55769. else if (type === 'month' || type === 'year') {
  55770. rangeOptions._range = {
  55771. month: 30,
  55772. year: 365
  55773. }[type] * 24 * 36e5 * count;
  55774. }
  55775. rangeOptions._offsetMin = pick(rangeOptions.offsetMin, 0);
  55776. rangeOptions._offsetMax = pick(rangeOptions.offsetMax, 0);
  55777. rangeOptions._range +=
  55778. rangeOptions._offsetMax - rangeOptions._offsetMin;
  55779. };
  55780. /**
  55781. * Get the unix timestamp of a HTML input for the dates
  55782. *
  55783. * @private
  55784. * @function Highcharts.RangeSelector#getInputValue
  55785. * @param {string} name
  55786. * @return {number}
  55787. */
  55788. RangeSelector.prototype.getInputValue = function (name) {
  55789. var input = name === 'min' ? this.minInput : this.maxInput;
  55790. var options = this.chart.options.rangeSelector;
  55791. var time = this.chart.time;
  55792. if (input) {
  55793. return ((input.type === 'text' && options.inputDateParser) ||
  55794. this.defaultInputDateParser)(input.value, time.useUTC, time);
  55795. }
  55796. return 0;
  55797. };
  55798. /**
  55799. * Set the internal and displayed value of a HTML input for the dates
  55800. *
  55801. * @private
  55802. * @function Highcharts.RangeSelector#setInputValue
  55803. * @param {string} name
  55804. * @param {number} [inputTime]
  55805. * @return {void}
  55806. */
  55807. RangeSelector.prototype.setInputValue = function (name, inputTime) {
  55808. var options = this.options, time = this.chart.time, input = name === 'min' ? this.minInput : this.maxInput, dateBox = name === 'min' ? this.minDateBox : this.maxDateBox;
  55809. if (input) {
  55810. var hcTimeAttr = input.getAttribute('data-hc-time');
  55811. var updatedTime = defined(hcTimeAttr) ? Number(hcTimeAttr) : void 0;
  55812. if (defined(inputTime)) {
  55813. var previousTime = updatedTime;
  55814. if (defined(previousTime)) {
  55815. input.setAttribute('data-hc-time-previous', previousTime);
  55816. }
  55817. input.setAttribute('data-hc-time', inputTime);
  55818. updatedTime = inputTime;
  55819. }
  55820. input.value = time.dateFormat(this.inputTypeFormats[input.type] || options.inputEditDateFormat, updatedTime);
  55821. if (dateBox) {
  55822. dateBox.attr({
  55823. text: time.dateFormat(options.inputDateFormat, updatedTime)
  55824. });
  55825. }
  55826. }
  55827. };
  55828. /**
  55829. * Set the min and max value of a HTML input for the dates
  55830. *
  55831. * @private
  55832. * @function Highcharts.RangeSelector#setInputExtremes
  55833. * @param {string} name
  55834. * @param {number} min
  55835. * @param {number} max
  55836. * @return {void}
  55837. */
  55838. RangeSelector.prototype.setInputExtremes = function (name, min, max) {
  55839. var input = name === 'min' ? this.minInput : this.maxInput;
  55840. if (input) {
  55841. var format = this.inputTypeFormats[input.type];
  55842. var time = this.chart.time;
  55843. if (format) {
  55844. var newMin = time.dateFormat(format,
  55845. min);
  55846. if (input.min !== newMin) {
  55847. input.min = newMin;
  55848. }
  55849. var newMax = time.dateFormat(format,
  55850. max);
  55851. if (input.max !== newMax) {
  55852. input.max = newMax;
  55853. }
  55854. }
  55855. }
  55856. };
  55857. /**
  55858. * @private
  55859. * @function Highcharts.RangeSelector#showInput
  55860. * @param {string} name
  55861. * @return {void}
  55862. */
  55863. RangeSelector.prototype.showInput = function (name) {
  55864. var dateBox = name === 'min' ? this.minDateBox : this.maxDateBox;
  55865. var input = name === 'min' ? this.minInput : this.maxInput;
  55866. if (input && dateBox && this.inputGroup) {
  55867. var isTextInput = input.type === 'text';
  55868. var _a = this.inputGroup,
  55869. translateX = _a.translateX,
  55870. translateY = _a.translateY;
  55871. var inputBoxWidth = this.options.inputBoxWidth;
  55872. css(input, {
  55873. width: isTextInput ? ((dateBox.width + (inputBoxWidth ? -2 : 20)) + 'px') : 'auto',
  55874. height: isTextInput ? ((dateBox.height - 2) + 'px') : 'auto',
  55875. border: '2px solid silver'
  55876. });
  55877. if (isTextInput && inputBoxWidth) {
  55878. css(input, {
  55879. left: (translateX + dateBox.x) + 'px',
  55880. top: translateY + 'px'
  55881. });
  55882. // Inputs of types date, time or datetime-local should be centered
  55883. // on top of the dateBox
  55884. }
  55885. else {
  55886. css(input, {
  55887. left: Math.min(Math.round(dateBox.x +
  55888. translateX -
  55889. (input.offsetWidth - dateBox.width) / 2), this.chart.chartWidth - input.offsetWidth) + 'px',
  55890. top: (translateY - (input.offsetHeight - dateBox.height) / 2) + 'px'
  55891. });
  55892. }
  55893. }
  55894. };
  55895. /**
  55896. * @private
  55897. * @function Highcharts.RangeSelector#hideInput
  55898. * @param {string} name
  55899. * @return {void}
  55900. */
  55901. RangeSelector.prototype.hideInput = function (name) {
  55902. var input = name === 'min' ? this.minInput : this.maxInput;
  55903. if (input) {
  55904. css(input, {
  55905. top: '-9999em',
  55906. border: 0,
  55907. width: '1px',
  55908. height: '1px'
  55909. });
  55910. }
  55911. };
  55912. /**
  55913. * @private
  55914. * @function Highcharts.RangeSelector#defaultInputDateParser
  55915. */
  55916. RangeSelector.prototype.defaultInputDateParser = function (inputDate, useUTC, time) {
  55917. var hasTimezone = function (str) {
  55918. return str.length > 6 &&
  55919. (str.lastIndexOf('-') === str.length - 6 ||
  55920. str.lastIndexOf('+') === str.length - 6);
  55921. };
  55922. var input = inputDate.split('/').join('-').split(' ').join('T');
  55923. if (input.indexOf('T') === -1) {
  55924. input += 'T00:00';
  55925. }
  55926. if (useUTC) {
  55927. input += 'Z';
  55928. }
  55929. else if (H.isSafari && !hasTimezone(input)) {
  55930. var offset = new Date(input).getTimezoneOffset() / 60;
  55931. input += offset <= 0 ? "+" + pad(-offset) + ":00" : "-" + pad(offset) + ":00";
  55932. }
  55933. var date = Date.parse(input);
  55934. // If the value isn't parsed directly to a value by the
  55935. // browser's Date.parse method, like YYYY-MM-DD in IE8, try
  55936. // parsing it a different way
  55937. if (!isNumber(date)) {
  55938. var parts = inputDate.split('-');
  55939. date = Date.UTC(pInt(parts[0]), pInt(parts[1]) - 1, pInt(parts[2]));
  55940. }
  55941. if (time && useUTC && isNumber(date)) {
  55942. date += time.getTimezoneOffset(date);
  55943. }
  55944. return date;
  55945. };
  55946. /**
  55947. * Draw either the 'from' or the 'to' HTML input box of the range selector
  55948. *
  55949. * @private
  55950. * @function Highcharts.RangeSelector#drawInput
  55951. * @param {string} name
  55952. * @return {RangeSelectorInputElements}
  55953. */
  55954. RangeSelector.prototype.drawInput = function (name) {
  55955. var _a = this,
  55956. chart = _a.chart,
  55957. div = _a.div,
  55958. inputGroup = _a.inputGroup;
  55959. var rangeSelector = this,
  55960. chartStyle = chart.renderer.style || {},
  55961. renderer = chart.renderer,
  55962. options = chart.options.rangeSelector,
  55963. lang = defaultOptions.lang,
  55964. isMin = name === 'min';
  55965. /**
  55966. * @private
  55967. */
  55968. function updateExtremes() {
  55969. var value = rangeSelector.getInputValue(name),
  55970. chartAxis = chart.xAxis[0],
  55971. dataAxis = chart.scroller && chart.scroller.xAxis ?
  55972. chart.scroller.xAxis :
  55973. chartAxis,
  55974. dataMin = dataAxis.dataMin,
  55975. dataMax = dataAxis.dataMax;
  55976. var maxInput = rangeSelector.maxInput,
  55977. minInput = rangeSelector.minInput;
  55978. if (value !== Number(input.getAttribute('data-hc-time-previous')) &&
  55979. isNumber(value)) {
  55980. input.setAttribute('data-hc-time-previous', value);
  55981. // Validate the extremes. If it goes beyound the data min or
  55982. // max, use the actual data extreme (#2438).
  55983. if (isMin && maxInput && isNumber(dataMin)) {
  55984. if (value > Number(maxInput.getAttribute('data-hc-time'))) {
  55985. value = void 0;
  55986. }
  55987. else if (value < dataMin) {
  55988. value = dataMin;
  55989. }
  55990. }
  55991. else if (minInput && isNumber(dataMax)) {
  55992. if (value < Number(minInput.getAttribute('data-hc-time'))) {
  55993. value = void 0;
  55994. }
  55995. else if (value > dataMax) {
  55996. value = dataMax;
  55997. }
  55998. }
  55999. // Set the extremes
  56000. if (typeof value !== 'undefined') { // @todo typof undefined
  56001. chartAxis.setExtremes(isMin ? value : chartAxis.min, isMin ? chartAxis.max : value, void 0, void 0, { trigger: 'rangeSelectorInput' });
  56002. }
  56003. }
  56004. }
  56005. // Create the text label
  56006. var text = lang[isMin ? 'rangeSelectorFrom' : 'rangeSelectorTo'];
  56007. var label = renderer
  56008. .label(text, 0)
  56009. .addClass('highcharts-range-label')
  56010. .attr({
  56011. padding: text ? 2 : 0,
  56012. height: text ? options.inputBoxHeight : 0
  56013. })
  56014. .add(inputGroup);
  56015. // Create an SVG label that shows updated date ranges and and records
  56016. // click events that bring in the HTML input.
  56017. var dateBox = renderer
  56018. .label('', 0)
  56019. .addClass('highcharts-range-input')
  56020. .attr({
  56021. padding: 2,
  56022. width: options.inputBoxWidth,
  56023. height: options.inputBoxHeight,
  56024. 'text-align': 'center'
  56025. })
  56026. .on('click',
  56027. function () {
  56028. // If it is already focused, the onfocus event doesn't fire
  56029. // (#3713)
  56030. rangeSelector.showInput(name);
  56031. rangeSelector[name + 'Input'].focus();
  56032. });
  56033. if (!chart.styledMode) {
  56034. dateBox.attr({
  56035. stroke: options.inputBoxBorderColor,
  56036. 'stroke-width': 1
  56037. });
  56038. }
  56039. dateBox.add(inputGroup);
  56040. // Create the HTML input element. This is rendered as 1x1 pixel then set
  56041. // to the right size when focused.
  56042. var input = createElement('input', {
  56043. name: name,
  56044. className: 'highcharts-range-selector'
  56045. },
  56046. void 0,
  56047. div);
  56048. // #14788: Setting input.type to an unsupported type throws in IE, so
  56049. // we need to use setAttribute instead
  56050. input.setAttribute('type', preferredInputType(options.inputDateFormat || '%b %e, %Y'));
  56051. if (!chart.styledMode) {
  56052. // Styles
  56053. label.css(merge(chartStyle, options.labelStyle));
  56054. dateBox.css(merge({
  56055. color: palette.neutralColor80
  56056. }, chartStyle, options.inputStyle));
  56057. css(input, extend({
  56058. position: 'absolute',
  56059. border: 0,
  56060. boxShadow: '0 0 15px rgba(0,0,0,0.3)',
  56061. width: '1px',
  56062. height: '1px',
  56063. padding: 0,
  56064. textAlign: 'center',
  56065. fontSize: chartStyle.fontSize,
  56066. fontFamily: chartStyle.fontFamily,
  56067. top: '-9999em' // #4798
  56068. }, options.inputStyle));
  56069. }
  56070. // Blow up the input box
  56071. input.onfocus = function () {
  56072. rangeSelector.showInput(name);
  56073. };
  56074. // Hide away the input box
  56075. input.onblur = function () {
  56076. // update extermes only when inputs are active
  56077. if (input === H.doc.activeElement) { // Only when focused
  56078. // Update also when no `change` event is triggered, like when
  56079. // clicking inside the SVG (#4710)
  56080. updateExtremes();
  56081. }
  56082. // #10404 - move hide and blur outside focus
  56083. rangeSelector.hideInput(name);
  56084. rangeSelector.setInputValue(name);
  56085. input.blur(); // #4606
  56086. };
  56087. var keyDown = false;
  56088. // handle changes in the input boxes
  56089. input.onchange = function () {
  56090. // Update extremes and blur input when clicking date input calendar
  56091. if (!keyDown) {
  56092. updateExtremes();
  56093. rangeSelector.hideInput(name);
  56094. input.blur();
  56095. }
  56096. };
  56097. input.onkeypress = function (event) {
  56098. // IE does not fire onchange on enter
  56099. if (event.keyCode === 13) {
  56100. updateExtremes();
  56101. }
  56102. };
  56103. input.onkeydown = function (event) {
  56104. keyDown = true;
  56105. // Arrow keys
  56106. if (event.keyCode === 38 || event.keyCode === 40) {
  56107. updateExtremes();
  56108. }
  56109. };
  56110. input.onkeyup = function () {
  56111. keyDown = false;
  56112. };
  56113. return { dateBox: dateBox, input: input, label: label };
  56114. };
  56115. /**
  56116. * Get the position of the range selector buttons and inputs. This can be
  56117. * overridden from outside for custom positioning.
  56118. *
  56119. * @private
  56120. * @function Highcharts.RangeSelector#getPosition
  56121. *
  56122. * @return {Highcharts.Dictionary<number>}
  56123. */
  56124. RangeSelector.prototype.getPosition = function () {
  56125. var chart = this.chart,
  56126. options = chart.options.rangeSelector,
  56127. top = options.verticalAlign === 'top' ?
  56128. chart.plotTop - chart.axisOffset[0] :
  56129. 0; // set offset only for varticalAlign top
  56130. return {
  56131. buttonTop: top + options.buttonPosition.y,
  56132. inputTop: top + options.inputPosition.y - 10
  56133. };
  56134. };
  56135. /**
  56136. * Get the extremes of YTD. Will choose dataMax if its value is lower than
  56137. * the current timestamp. Will choose dataMin if its value is higher than
  56138. * the timestamp for the start of current year.
  56139. *
  56140. * @private
  56141. * @function Highcharts.RangeSelector#getYTDExtremes
  56142. *
  56143. * @param {number} dataMax
  56144. *
  56145. * @param {number} dataMin
  56146. *
  56147. * @return {*}
  56148. * Returns min and max for the YTD
  56149. */
  56150. RangeSelector.prototype.getYTDExtremes = function (dataMax, dataMin, useUTC) {
  56151. var time = this.chart.time,
  56152. min,
  56153. now = new time.Date(dataMax),
  56154. year = time.get('FullYear',
  56155. now),
  56156. startOfYear = useUTC ?
  56157. time.Date.UTC(year, 0, 1) : // eslint-disable-line new-cap
  56158. +new time.Date(year, 0, 1);
  56159. min = Math.max(dataMin, startOfYear);
  56160. var ts = now.getTime();
  56161. return {
  56162. max: Math.min(dataMax || ts, ts),
  56163. min: min
  56164. };
  56165. };
  56166. /**
  56167. * Render the range selector including the buttons and the inputs. The first
  56168. * time render is called, the elements are created and positioned. On
  56169. * subsequent calls, they are moved and updated.
  56170. *
  56171. * @private
  56172. * @function Highcharts.RangeSelector#render
  56173. * @param {number} [min]
  56174. * X axis minimum
  56175. * @param {number} [max]
  56176. * X axis maximum
  56177. * @return {void}
  56178. */
  56179. RangeSelector.prototype.render = function (min, max) {
  56180. var chart = this.chart,
  56181. renderer = chart.renderer,
  56182. container = chart.container,
  56183. chartOptions = chart.options,
  56184. options = chartOptions.rangeSelector,
  56185. // Place inputs above the container
  56186. inputsZIndex = pick(chartOptions.chart.style &&
  56187. chartOptions.chart.style.zIndex, 0) + 1,
  56188. inputEnabled = options.inputEnabled,
  56189. rendered = this.rendered;
  56190. if (options.enabled === false) {
  56191. return;
  56192. }
  56193. // create the elements
  56194. if (!rendered) {
  56195. this.group = renderer.g('range-selector-group')
  56196. .attr({
  56197. zIndex: 7
  56198. })
  56199. .add();
  56200. this.div = createElement('div', void 0, {
  56201. position: 'relative',
  56202. height: 0,
  56203. zIndex: inputsZIndex
  56204. });
  56205. if (this.buttonOptions.length) {
  56206. this.renderButtons();
  56207. }
  56208. // First create a wrapper outside the container in order to make
  56209. // the inputs work and make export correct
  56210. if (container.parentNode) {
  56211. container.parentNode.insertBefore(this.div, container);
  56212. }
  56213. if (inputEnabled) {
  56214. // Create the group to keep the inputs
  56215. this.inputGroup = renderer.g('input-group').add(this.group);
  56216. var minElems = this.drawInput('min');
  56217. this.minDateBox = minElems.dateBox;
  56218. this.minLabel = minElems.label;
  56219. this.minInput = minElems.input;
  56220. var maxElems = this.drawInput('max');
  56221. this.maxDateBox = maxElems.dateBox;
  56222. this.maxLabel = maxElems.label;
  56223. this.maxInput = maxElems.input;
  56224. }
  56225. }
  56226. if (inputEnabled) {
  56227. // Set or reset the input values
  56228. this.setInputValue('min', min);
  56229. this.setInputValue('max', max);
  56230. var unionExtremes = (chart.scroller && chart.scroller.getUnionExtremes()) || chart.xAxis[0] || {};
  56231. if (defined(unionExtremes.dataMin) && defined(unionExtremes.dataMax)) {
  56232. var minRange = chart.xAxis[0].minRange || 0;
  56233. this.setInputExtremes('min', unionExtremes.dataMin, Math.min(unionExtremes.dataMax, this.getInputValue('max')) - minRange);
  56234. this.setInputExtremes('max', Math.max(unionExtremes.dataMin, this.getInputValue('min')) + minRange, unionExtremes.dataMax);
  56235. }
  56236. // Reflow
  56237. if (this.inputGroup) {
  56238. var x_1 = 0;
  56239. [
  56240. this.minLabel,
  56241. this.minDateBox,
  56242. this.maxLabel,
  56243. this.maxDateBox
  56244. ].forEach(function (label) {
  56245. if (label) {
  56246. var width = label.getBBox().width;
  56247. if (width) {
  56248. label.attr({ x: x_1 });
  56249. x_1 += width + options.inputSpacing;
  56250. }
  56251. }
  56252. });
  56253. }
  56254. }
  56255. this.alignElements();
  56256. this.rendered = true;
  56257. };
  56258. /**
  56259. * Render the range buttons. This only runs the first time, later the
  56260. * positioning is laid out in alignElements.
  56261. *
  56262. * @private
  56263. * @function Highcharts.RangeSelector#renderButtons
  56264. * @return {void}
  56265. */
  56266. RangeSelector.prototype.renderButtons = function () {
  56267. var _this = this;
  56268. var _a = this,
  56269. buttons = _a.buttons,
  56270. chart = _a.chart,
  56271. options = _a.options;
  56272. var lang = defaultOptions.lang;
  56273. var renderer = chart.renderer;
  56274. var buttonTheme = merge(options.buttonTheme);
  56275. var states = buttonTheme && buttonTheme.states;
  56276. // Prevent the button from resetting the width when the button state
  56277. // changes since we need more control over the width when collapsing
  56278. // the buttons
  56279. var width = buttonTheme.width || 28;
  56280. delete buttonTheme.width;
  56281. delete buttonTheme.states;
  56282. this.buttonGroup = renderer.g('range-selector-buttons').add(this.group);
  56283. var dropdown = this.dropdown = createElement('select',
  56284. void 0, {
  56285. position: 'absolute',
  56286. width: '1px',
  56287. height: '1px',
  56288. padding: 0,
  56289. border: 0,
  56290. top: '-9999em',
  56291. cursor: 'pointer',
  56292. opacity: 0.0001
  56293. },
  56294. this.div);
  56295. // Prevent page zoom on iPhone
  56296. addEvent(dropdown, 'touchstart', function () {
  56297. dropdown.style.fontSize = '16px';
  56298. });
  56299. // Forward events from select to button
  56300. [
  56301. [H.isMS ? 'mouseover' : 'mouseenter'],
  56302. [H.isMS ? 'mouseout' : 'mouseleave'],
  56303. ['change', 'click']
  56304. ].forEach(function (_a) {
  56305. var from = _a[0],
  56306. to = _a[1];
  56307. addEvent(dropdown, from, function () {
  56308. var button = buttons[_this.currentButtonIndex()];
  56309. if (button) {
  56310. fireEvent(button.element, to || from);
  56311. }
  56312. });
  56313. });
  56314. this.zoomText = renderer
  56315. .label((lang && lang.rangeSelectorZoom) || '', 0)
  56316. .attr({
  56317. padding: options.buttonTheme.padding,
  56318. height: options.buttonTheme.height,
  56319. paddingLeft: 0,
  56320. paddingRight: 0
  56321. })
  56322. .add(this.buttonGroup);
  56323. if (!this.chart.styledMode) {
  56324. this.zoomText.css(options.labelStyle);
  56325. buttonTheme['stroke-width'] = pick(buttonTheme['stroke-width'], 0);
  56326. }
  56327. createElement('option', {
  56328. textContent: this.zoomText.textStr,
  56329. disabled: true
  56330. }, void 0, dropdown);
  56331. this.buttonOptions.forEach(function (rangeOptions, i) {
  56332. createElement('option', {
  56333. textContent: rangeOptions.title || rangeOptions.text
  56334. }, void 0, dropdown);
  56335. buttons[i] = renderer
  56336. .button(rangeOptions.text, 0, 0, function (e) {
  56337. // extract events from button object and call
  56338. var buttonEvents = (rangeOptions.events &&
  56339. rangeOptions.events.click),
  56340. callDefaultEvent;
  56341. if (buttonEvents) {
  56342. callDefaultEvent =
  56343. buttonEvents.call(rangeOptions, e);
  56344. }
  56345. if (callDefaultEvent !== false) {
  56346. _this.clickButton(i);
  56347. }
  56348. _this.isActive = true;
  56349. }, buttonTheme, states && states.hover, states && states.select, states && states.disabled)
  56350. .attr({
  56351. 'text-align': 'center',
  56352. width: width
  56353. })
  56354. .add(_this.buttonGroup);
  56355. if (rangeOptions.title) {
  56356. buttons[i].attr('title', rangeOptions.title);
  56357. }
  56358. });
  56359. };
  56360. /**
  56361. * Align the elements horizontally and vertically.
  56362. *
  56363. * @private
  56364. * @function Highcharts.RangeSelector#alignElements
  56365. * @return {void}
  56366. */
  56367. RangeSelector.prototype.alignElements = function () {
  56368. var _this = this;
  56369. var _a = this,
  56370. buttonGroup = _a.buttonGroup,
  56371. buttons = _a.buttons,
  56372. chart = _a.chart,
  56373. group = _a.group,
  56374. inputGroup = _a.inputGroup,
  56375. options = _a.options,
  56376. zoomText = _a.zoomText;
  56377. var chartOptions = chart.options;
  56378. var navButtonOptions = (chartOptions.exporting &&
  56379. chartOptions.exporting.enabled !== false &&
  56380. chartOptions.navigation &&
  56381. chartOptions.navigation.buttonOptions);
  56382. var buttonPosition = options.buttonPosition,
  56383. inputPosition = options.inputPosition,
  56384. verticalAlign = options.verticalAlign;
  56385. // Get the X offset required to avoid overlapping with the exporting
  56386. // button. This is is used both by the buttonGroup and the inputGroup.
  56387. var getXOffsetForExportButton = function (group,
  56388. position) {
  56389. if (navButtonOptions &&
  56390. _this.titleCollision(chart) &&
  56391. verticalAlign === 'top' &&
  56392. position.align === 'right' && ((position.y -
  56393. group.getBBox().height - 12) <
  56394. ((navButtonOptions.y || 0) +
  56395. (navButtonOptions.height || 0) +
  56396. chart.spacing[0]))) {
  56397. return -40;
  56398. }
  56399. return 0;
  56400. };
  56401. var plotLeft = chart.plotLeft;
  56402. if (group && buttonPosition && inputPosition) {
  56403. var translateX = buttonPosition.x - chart.spacing[3];
  56404. if (buttonGroup) {
  56405. this.positionButtons();
  56406. if (!this.initialButtonGroupWidth) {
  56407. var width_1 = 0;
  56408. if (zoomText) {
  56409. width_1 += zoomText.getBBox().width + 5;
  56410. }
  56411. buttons.forEach(function (button, i) {
  56412. width_1 += button.width;
  56413. if (i !== buttons.length - 1) {
  56414. width_1 += options.buttonSpacing;
  56415. }
  56416. });
  56417. this.initialButtonGroupWidth = width_1;
  56418. }
  56419. plotLeft -= chart.spacing[3];
  56420. this.updateButtonStates();
  56421. // Detect collision between button group and exporting
  56422. var xOffsetForExportButton_1 = getXOffsetForExportButton(buttonGroup,
  56423. buttonPosition);
  56424. this.alignButtonGroup(xOffsetForExportButton_1);
  56425. // Skip animation
  56426. group.placed = buttonGroup.placed = chart.hasLoaded;
  56427. }
  56428. var xOffsetForExportButton = 0;
  56429. if (inputGroup) {
  56430. // Detect collision between the input group and exporting button
  56431. xOffsetForExportButton = getXOffsetForExportButton(inputGroup, inputPosition);
  56432. if (inputPosition.align === 'left') {
  56433. translateX = plotLeft;
  56434. }
  56435. else if (inputPosition.align === 'right') {
  56436. translateX = -Math.max(chart.axisOffset[1], -xOffsetForExportButton);
  56437. }
  56438. // Update the alignment to the updated spacing box
  56439. inputGroup.align({
  56440. y: inputPosition.y,
  56441. width: inputGroup.getBBox().width,
  56442. align: inputPosition.align,
  56443. // fix wrong getBBox() value on right align
  56444. x: inputPosition.x + translateX - 2
  56445. }, true, chart.spacingBox);
  56446. // Skip animation
  56447. inputGroup.placed = chart.hasLoaded;
  56448. }
  56449. this.handleCollision(xOffsetForExportButton);
  56450. // Vertical align
  56451. group.align({
  56452. verticalAlign: verticalAlign
  56453. }, true, chart.spacingBox);
  56454. var alignTranslateY = group.alignAttr.translateY;
  56455. // Set position
  56456. var groupHeight = group.getBBox().height + 20; // # 20 padding
  56457. var translateY = 0;
  56458. // Calculate bottom position
  56459. if (verticalAlign === 'bottom') {
  56460. var legendOptions = chart.legend && chart.legend.options;
  56461. var legendHeight = (legendOptions &&
  56462. legendOptions.verticalAlign === 'bottom' &&
  56463. legendOptions.enabled &&
  56464. !legendOptions.floating ?
  56465. (chart.legend.legendHeight +
  56466. pick(legendOptions.margin, 10)) :
  56467. 0);
  56468. groupHeight = groupHeight + legendHeight - 20;
  56469. translateY = (alignTranslateY -
  56470. groupHeight -
  56471. (options.floating ? 0 : options.y) -
  56472. (chart.titleOffset ? chart.titleOffset[2] : 0) -
  56473. 10 // 10 spacing
  56474. );
  56475. }
  56476. if (verticalAlign === 'top') {
  56477. if (options.floating) {
  56478. translateY = 0;
  56479. }
  56480. if (chart.titleOffset && chart.titleOffset[0]) {
  56481. translateY = chart.titleOffset[0];
  56482. }
  56483. translateY += ((chart.margin[0] - chart.spacing[0]) || 0);
  56484. }
  56485. else if (verticalAlign === 'middle') {
  56486. if (inputPosition.y === buttonPosition.y) {
  56487. translateY = alignTranslateY;
  56488. }
  56489. else if (inputPosition.y || buttonPosition.y) {
  56490. if (inputPosition.y < 0 ||
  56491. buttonPosition.y < 0) {
  56492. translateY -= Math.min(inputPosition.y, buttonPosition.y);
  56493. }
  56494. else {
  56495. translateY = alignTranslateY - groupHeight;
  56496. }
  56497. }
  56498. }
  56499. group.translate(options.x, options.y + Math.floor(translateY));
  56500. // Translate HTML inputs
  56501. var _b = this,
  56502. minInput = _b.minInput,
  56503. maxInput = _b.maxInput,
  56504. dropdown = _b.dropdown;
  56505. if (options.inputEnabled && minInput && maxInput) {
  56506. minInput.style.marginTop = group.translateY + 'px';
  56507. maxInput.style.marginTop = group.translateY + 'px';
  56508. }
  56509. if (dropdown) {
  56510. dropdown.style.marginTop = group.translateY + 'px';
  56511. }
  56512. }
  56513. };
  56514. /**
  56515. * Align the button group horizontally and vertically.
  56516. *
  56517. * @private
  56518. * @function Highcharts.RangeSelector#alignButtonGroup
  56519. * @param {number} xOffsetForExportButton
  56520. * @param {number} [width]
  56521. * @return {void}
  56522. */
  56523. RangeSelector.prototype.alignButtonGroup = function (xOffsetForExportButton, width) {
  56524. var _a = this,
  56525. chart = _a.chart,
  56526. options = _a.options,
  56527. buttonGroup = _a.buttonGroup,
  56528. buttons = _a.buttons;
  56529. var buttonPosition = options.buttonPosition;
  56530. var plotLeft = chart.plotLeft - chart.spacing[3];
  56531. var translateX = buttonPosition.x - chart.spacing[3];
  56532. if (buttonPosition.align === 'right') {
  56533. translateX += xOffsetForExportButton - plotLeft; // #13014
  56534. }
  56535. else if (buttonPosition.align === 'center') {
  56536. translateX -= plotLeft / 2;
  56537. }
  56538. if (buttonGroup) {
  56539. // Align button group
  56540. buttonGroup.align({
  56541. y: buttonPosition.y,
  56542. width: pick(width, this.initialButtonGroupWidth),
  56543. align: buttonPosition.align,
  56544. x: translateX
  56545. }, true, chart.spacingBox);
  56546. }
  56547. };
  56548. /**
  56549. * @private
  56550. * @function Highcharts.RangeSelector#positionButtons
  56551. * @return {void}
  56552. */
  56553. RangeSelector.prototype.positionButtons = function () {
  56554. var _a = this,
  56555. buttons = _a.buttons,
  56556. chart = _a.chart,
  56557. options = _a.options,
  56558. zoomText = _a.zoomText;
  56559. var verb = chart.hasLoaded ? 'animate' : 'attr';
  56560. var buttonPosition = options.buttonPosition;
  56561. var plotLeft = chart.plotLeft;
  56562. var buttonLeft = plotLeft;
  56563. if (zoomText && zoomText.visibility !== 'hidden') {
  56564. // #8769, allow dynamically updating margins
  56565. zoomText[verb]({
  56566. x: pick(plotLeft + buttonPosition.x, plotLeft)
  56567. });
  56568. // Button start position
  56569. buttonLeft += buttonPosition.x +
  56570. zoomText.getBBox().width + 5;
  56571. }
  56572. this.buttonOptions.forEach(function (rangeOptions, i) {
  56573. if (buttons[i].visibility !== 'hidden') {
  56574. buttons[i][verb]({ x: buttonLeft });
  56575. // increase button position for the next button
  56576. buttonLeft += buttons[i].width + options.buttonSpacing;
  56577. }
  56578. else {
  56579. buttons[i][verb]({ x: plotLeft });
  56580. }
  56581. });
  56582. };
  56583. /**
  56584. * Handle collision between the button group and the input group
  56585. *
  56586. * @private
  56587. * @function Highcharts.RangeSelector#handleCollision
  56588. *
  56589. * @param {number} xOffsetForExportButton
  56590. * The X offset of the group required to make room for the
  56591. * exporting button
  56592. * @return {void}
  56593. */
  56594. RangeSelector.prototype.handleCollision = function (xOffsetForExportButton) {
  56595. var _this = this;
  56596. var _a = this,
  56597. chart = _a.chart,
  56598. buttonGroup = _a.buttonGroup,
  56599. inputGroup = _a.inputGroup;
  56600. var _b = this.options,
  56601. buttonPosition = _b.buttonPosition,
  56602. dropdown = _b.dropdown,
  56603. inputPosition = _b.inputPosition;
  56604. var maxButtonWidth = function () {
  56605. var buttonWidth = 0;
  56606. _this.buttons.forEach(function (button) {
  56607. var bBox = button.getBBox();
  56608. if (bBox.width > buttonWidth) {
  56609. buttonWidth = bBox.width;
  56610. }
  56611. });
  56612. return buttonWidth;
  56613. };
  56614. var groupsOverlap = function (buttonGroupWidth) {
  56615. if (inputGroup && buttonGroup) {
  56616. var inputGroupX = (inputGroup.alignAttr.translateX +
  56617. inputGroup.alignOptions.x -
  56618. xOffsetForExportButton +
  56619. // getBBox for detecing left margin
  56620. inputGroup.getBBox().x +
  56621. // 2px padding to not overlap input and label
  56622. 2);
  56623. var inputGroupWidth = inputGroup.alignOptions.width;
  56624. var buttonGroupX = buttonGroup.alignAttr.translateX +
  56625. buttonGroup.getBBox().x;
  56626. return (buttonGroupX + buttonGroupWidth > inputGroupX) &&
  56627. (inputGroupX + inputGroupWidth > buttonGroupX) &&
  56628. (buttonPosition.y <
  56629. (inputPosition.y +
  56630. inputGroup.getBBox().height));
  56631. }
  56632. return false;
  56633. };
  56634. var moveInputsDown = function () {
  56635. if (inputGroup && buttonGroup) {
  56636. inputGroup.attr({
  56637. translateX: inputGroup.alignAttr.translateX + (chart.axisOffset[1] >= -xOffsetForExportButton ?
  56638. 0 :
  56639. -xOffsetForExportButton),
  56640. translateY: inputGroup.alignAttr.translateY +
  56641. buttonGroup.getBBox().height + 10
  56642. });
  56643. }
  56644. };
  56645. if (buttonGroup) {
  56646. if (dropdown === 'always') {
  56647. this.collapseButtons(xOffsetForExportButton);
  56648. if (groupsOverlap(maxButtonWidth())) {
  56649. // Move the inputs down if there is still a collision
  56650. // after collapsing the buttons
  56651. moveInputsDown();
  56652. }
  56653. return;
  56654. }
  56655. if (dropdown === 'never') {
  56656. this.expandButtons();
  56657. }
  56658. }
  56659. // Detect collision
  56660. if (inputGroup && buttonGroup) {
  56661. if ((inputPosition.align === buttonPosition.align) ||
  56662. // 20 is minimal spacing between elements
  56663. groupsOverlap(this.initialButtonGroupWidth + 20)) {
  56664. if (dropdown === 'responsive') {
  56665. this.collapseButtons(xOffsetForExportButton);
  56666. if (groupsOverlap(maxButtonWidth())) {
  56667. moveInputsDown();
  56668. }
  56669. }
  56670. else {
  56671. moveInputsDown();
  56672. }
  56673. }
  56674. else if (dropdown === 'responsive') {
  56675. this.expandButtons();
  56676. }
  56677. }
  56678. else if (buttonGroup && dropdown === 'responsive') {
  56679. if (this.initialButtonGroupWidth > chart.plotWidth) {
  56680. this.collapseButtons(xOffsetForExportButton);
  56681. }
  56682. else {
  56683. this.expandButtons();
  56684. }
  56685. }
  56686. };
  56687. /**
  56688. * Collapse the buttons and put the select element on top.
  56689. *
  56690. * @private
  56691. * @function Highcharts.RangeSelector#collapseButtons
  56692. * @param {number} xOffsetForExportButton
  56693. * @return {void}
  56694. */
  56695. RangeSelector.prototype.collapseButtons = function (xOffsetForExportButton) {
  56696. var _a = this,
  56697. buttons = _a.buttons,
  56698. buttonOptions = _a.buttonOptions,
  56699. chart = _a.chart,
  56700. dropdown = _a.dropdown,
  56701. options = _a.options,
  56702. zoomText = _a.zoomText;
  56703. var userButtonTheme = (chart.userOptions.rangeSelector &&
  56704. chart.userOptions.rangeSelector.buttonTheme) || {};
  56705. var getAttribs = function (text) { return ({
  56706. text: text ? text + " \u25BE" : '▾',
  56707. width: 'auto',
  56708. paddingLeft: pick(options.buttonTheme.paddingLeft,
  56709. userButtonTheme.padding, 8),
  56710. paddingRight: pick(options.buttonTheme.paddingRight,
  56711. userButtonTheme.padding, 8)
  56712. }); };
  56713. if (zoomText) {
  56714. zoomText.hide();
  56715. }
  56716. var hasActiveButton = false;
  56717. buttonOptions.forEach(function (rangeOptions, i) {
  56718. var button = buttons[i];
  56719. if (button.state !== 2) {
  56720. button.hide();
  56721. }
  56722. else {
  56723. button.show();
  56724. button.attr(getAttribs(rangeOptions.text));
  56725. hasActiveButton = true;
  56726. }
  56727. });
  56728. if (!hasActiveButton) {
  56729. if (dropdown) {
  56730. dropdown.selectedIndex = 0;
  56731. }
  56732. buttons[0].show();
  56733. buttons[0].attr(getAttribs(this.zoomText && this.zoomText.textStr));
  56734. }
  56735. var align = options.buttonPosition.align;
  56736. this.positionButtons();
  56737. if (align === 'right' || align === 'center') {
  56738. this.alignButtonGroup(xOffsetForExportButton, buttons[this.currentButtonIndex()].getBBox().width);
  56739. }
  56740. this.showDropdown();
  56741. };
  56742. /**
  56743. * Show all the buttons and hide the select element.
  56744. *
  56745. * @private
  56746. * @function Highcharts.RangeSelector#expandButtons
  56747. * @return {void}
  56748. */
  56749. RangeSelector.prototype.expandButtons = function () {
  56750. var _a = this,
  56751. buttons = _a.buttons,
  56752. buttonOptions = _a.buttonOptions,
  56753. options = _a.options,
  56754. zoomText = _a.zoomText;
  56755. this.hideDropdown();
  56756. if (zoomText) {
  56757. zoomText.show();
  56758. }
  56759. buttonOptions.forEach(function (rangeOptions, i) {
  56760. var button = buttons[i];
  56761. button.show();
  56762. button.attr({
  56763. text: rangeOptions.text,
  56764. width: options.buttonTheme.width || 28,
  56765. paddingLeft: pick(options.buttonTheme.paddingLeft, 'unset'),
  56766. paddingRight: pick(options.buttonTheme.paddingRight, 'unset')
  56767. });
  56768. if (button.state < 2) {
  56769. button.setState(0);
  56770. }
  56771. });
  56772. this.positionButtons();
  56773. };
  56774. /**
  56775. * Get the index of the visible button when the buttons are collapsed.
  56776. *
  56777. * @private
  56778. * @function Highcharts.RangeSelector#currentButtonIndex
  56779. * @return {number}
  56780. */
  56781. RangeSelector.prototype.currentButtonIndex = function () {
  56782. var dropdown = this.dropdown;
  56783. if (dropdown && dropdown.selectedIndex > 0) {
  56784. return dropdown.selectedIndex - 1;
  56785. }
  56786. return 0;
  56787. };
  56788. /**
  56789. * Position the select element on top of the button.
  56790. *
  56791. * @private
  56792. * @function Highcharts.RangeSelector#showDropdown
  56793. * @return {void}
  56794. */
  56795. RangeSelector.prototype.showDropdown = function () {
  56796. var _a = this,
  56797. buttonGroup = _a.buttonGroup,
  56798. buttons = _a.buttons,
  56799. chart = _a.chart,
  56800. dropdown = _a.dropdown;
  56801. if (buttonGroup && dropdown) {
  56802. var translateX = buttonGroup.translateX,
  56803. translateY = buttonGroup.translateY;
  56804. var bBox = buttons[this.currentButtonIndex()].getBBox();
  56805. css(dropdown, {
  56806. left: (chart.plotLeft + translateX) + 'px',
  56807. top: (translateY + 0.5) + 'px',
  56808. width: bBox.width + 'px',
  56809. height: bBox.height + 'px'
  56810. });
  56811. this.hasVisibleDropdown = true;
  56812. }
  56813. };
  56814. /**
  56815. * @private
  56816. * @function Highcharts.RangeSelector#hideDropdown
  56817. * @return {void}
  56818. */
  56819. RangeSelector.prototype.hideDropdown = function () {
  56820. var dropdown = this.dropdown;
  56821. if (dropdown) {
  56822. css(dropdown, {
  56823. top: '-9999em',
  56824. width: '1px',
  56825. height: '1px'
  56826. });
  56827. this.hasVisibleDropdown = false;
  56828. }
  56829. };
  56830. /**
  56831. * Extracts height of range selector
  56832. *
  56833. * @private
  56834. * @function Highcharts.RangeSelector#getHeight
  56835. * @return {number}
  56836. * Returns rangeSelector height
  56837. */
  56838. RangeSelector.prototype.getHeight = function () {
  56839. var rangeSelector = this,
  56840. options = rangeSelector.options,
  56841. rangeSelectorGroup = rangeSelector.group,
  56842. inputPosition = options.inputPosition,
  56843. buttonPosition = options.buttonPosition,
  56844. yPosition = options.y,
  56845. buttonPositionY = buttonPosition.y,
  56846. inputPositionY = inputPosition.y,
  56847. rangeSelectorHeight = 0,
  56848. minPosition;
  56849. if (options.height) {
  56850. return options.height;
  56851. }
  56852. // Align the elements before we read the height in case we're switching
  56853. // between wrapped and non-wrapped layout
  56854. this.alignElements();
  56855. rangeSelectorHeight = rangeSelectorGroup ?
  56856. // 13px to keep back compatibility
  56857. (rangeSelectorGroup.getBBox(true).height) + 13 +
  56858. yPosition :
  56859. 0;
  56860. minPosition = Math.min(inputPositionY, buttonPositionY);
  56861. if ((inputPositionY < 0 && buttonPositionY < 0) ||
  56862. (inputPositionY > 0 && buttonPositionY > 0)) {
  56863. rangeSelectorHeight += Math.abs(minPosition);
  56864. }
  56865. return rangeSelectorHeight;
  56866. };
  56867. /**
  56868. * Detect collision with title or subtitle
  56869. *
  56870. * @private
  56871. * @function Highcharts.RangeSelector#titleCollision
  56872. *
  56873. * @param {Highcharts.Chart} chart
  56874. *
  56875. * @return {boolean}
  56876. * Returns collision status
  56877. */
  56878. RangeSelector.prototype.titleCollision = function (chart) {
  56879. return !(chart.options.title.text ||
  56880. chart.options.subtitle.text);
  56881. };
  56882. /**
  56883. * Update the range selector with new options
  56884. *
  56885. * @private
  56886. * @function Highcharts.RangeSelector#update
  56887. * @param {Highcharts.RangeSelectorOptions} options
  56888. * @return {void}
  56889. */
  56890. RangeSelector.prototype.update = function (options) {
  56891. var chart = this.chart;
  56892. merge(true, chart.options.rangeSelector, options);
  56893. this.destroy();
  56894. this.init(chart);
  56895. this.render();
  56896. };
  56897. /**
  56898. * Destroys allocated elements.
  56899. *
  56900. * @private
  56901. * @function Highcharts.RangeSelector#destroy
  56902. */
  56903. RangeSelector.prototype.destroy = function () {
  56904. var rSelector = this,
  56905. minInput = rSelector.minInput,
  56906. maxInput = rSelector.maxInput;
  56907. if (rSelector.eventsToUnbind) {
  56908. rSelector.eventsToUnbind.forEach(function (unbind) { return unbind(); });
  56909. rSelector.eventsToUnbind = void 0;
  56910. }
  56911. // Destroy elements in collections
  56912. destroyObjectProperties(rSelector.buttons);
  56913. // Clear input element events
  56914. if (minInput) {
  56915. minInput.onfocus = minInput.onblur = minInput.onchange = null;
  56916. }
  56917. if (maxInput) {
  56918. maxInput.onfocus = maxInput.onblur = maxInput.onchange = null;
  56919. }
  56920. // Destroy HTML and SVG elements
  56921. objectEach(rSelector, function (val, key) {
  56922. if (val && key !== 'chart') {
  56923. if (val instanceof SVGElement) {
  56924. // SVGElement
  56925. val.destroy();
  56926. }
  56927. else if (val instanceof window.HTMLElement) {
  56928. // HTML element
  56929. discardElement(val);
  56930. }
  56931. }
  56932. if (val !== RangeSelector.prototype[key]) {
  56933. rSelector[key] = null;
  56934. }
  56935. }, this);
  56936. };
  56937. return RangeSelector;
  56938. }());
  56939. /**
  56940. * The default buttons for pre-selecting time frames
  56941. */
  56942. RangeSelector.prototype.defaultButtons = [{
  56943. type: 'month',
  56944. count: 1,
  56945. text: '1m',
  56946. title: 'View 1 month'
  56947. }, {
  56948. type: 'month',
  56949. count: 3,
  56950. text: '3m',
  56951. title: 'View 3 months'
  56952. }, {
  56953. type: 'month',
  56954. count: 6,
  56955. text: '6m',
  56956. title: 'View 6 months'
  56957. }, {
  56958. type: 'ytd',
  56959. text: 'YTD',
  56960. title: 'View year to date'
  56961. }, {
  56962. type: 'year',
  56963. count: 1,
  56964. text: '1y',
  56965. title: 'View 1 year'
  56966. }, {
  56967. type: 'all',
  56968. text: 'All',
  56969. title: 'View all'
  56970. }];
  56971. /**
  56972. * The date formats to use when setting min, max and value on date inputs
  56973. */
  56974. RangeSelector.prototype.inputTypeFormats = {
  56975. 'datetime-local': '%Y-%m-%dT%H:%M:%S',
  56976. 'date': '%Y-%m-%d',
  56977. 'time': '%H:%M:%S'
  56978. };
  56979. /**
  56980. * Get the preferred input type based on a date format string.
  56981. *
  56982. * @private
  56983. * @function preferredInputType
  56984. * @param {string} format
  56985. * @return {string}
  56986. */
  56987. function preferredInputType(format) {
  56988. var ms = format.indexOf('%L') !== -1;
  56989. if (ms) {
  56990. return 'text';
  56991. }
  56992. var date = ['a', 'A', 'd', 'e', 'w', 'b', 'B', 'm', 'o', 'y', 'Y'].some(function (char) {
  56993. return format.indexOf('%' + char) !== -1;
  56994. });
  56995. var time = ['H', 'k', 'I', 'l', 'M', 'S'].some(function (char) {
  56996. return format.indexOf('%' + char) !== -1;
  56997. });
  56998. if (date && time) {
  56999. return 'datetime-local';
  57000. }
  57001. if (date) {
  57002. return 'date';
  57003. }
  57004. if (time) {
  57005. return 'time';
  57006. }
  57007. return 'text';
  57008. }
  57009. /**
  57010. * Get the axis min value based on the range option and the current max. For
  57011. * stock charts this is extended via the {@link RangeSelector} so that if the
  57012. * selected range is a multiple of months or years, it is compensated for
  57013. * various month lengths.
  57014. *
  57015. * @private
  57016. * @function Highcharts.Axis#minFromRange
  57017. * @return {number|undefined}
  57018. * The new minimum value.
  57019. */
  57020. Axis.prototype.minFromRange = function () {
  57021. var rangeOptions = this.range,
  57022. type = rangeOptions.type,
  57023. min,
  57024. max = this.max,
  57025. dataMin,
  57026. range,
  57027. time = this.chart.time,
  57028. // Get the true range from a start date
  57029. getTrueRange = function (base,
  57030. count) {
  57031. var timeName = type === 'year' ? 'FullYear' : 'Month';
  57032. var date = new time.Date(base);
  57033. var basePeriod = time.get(timeName,
  57034. date);
  57035. time.set(timeName, date, basePeriod + count);
  57036. if (basePeriod === time.get(timeName, date)) {
  57037. time.set('Date', date, 0); // #6537
  57038. }
  57039. return date.getTime() - base;
  57040. };
  57041. if (isNumber(rangeOptions)) {
  57042. min = max - rangeOptions;
  57043. range = rangeOptions;
  57044. }
  57045. else {
  57046. min = max + getTrueRange(max, -rangeOptions.count);
  57047. // Let the fixedRange reflect initial settings (#5930)
  57048. if (this.chart) {
  57049. this.chart.fixedRange = max - min;
  57050. }
  57051. }
  57052. dataMin = pick(this.dataMin, Number.MIN_VALUE);
  57053. if (!isNumber(min)) {
  57054. min = dataMin;
  57055. }
  57056. if (min <= dataMin) {
  57057. min = dataMin;
  57058. if (typeof range === 'undefined') { // #4501
  57059. range = getTrueRange(min, rangeOptions.count);
  57060. }
  57061. this.newMax = Math.min(min + range, this.dataMax);
  57062. }
  57063. if (!isNumber(max)) {
  57064. min = void 0;
  57065. }
  57066. return min;
  57067. };
  57068. if (!H.RangeSelector) {
  57069. var chartDestroyEvents_1 = [];
  57070. var initRangeSelector_1 = function (chart) {
  57071. var extremes,
  57072. rangeSelector = chart.rangeSelector,
  57073. legend,
  57074. alignTo,
  57075. verticalAlign;
  57076. /**
  57077. * @private
  57078. */
  57079. function render() {
  57080. if (rangeSelector) {
  57081. extremes = chart.xAxis[0].getExtremes();
  57082. legend = chart.legend;
  57083. verticalAlign = (rangeSelector &&
  57084. rangeSelector.options.verticalAlign);
  57085. if (isNumber(extremes.min)) {
  57086. rangeSelector.render(extremes.min, extremes.max);
  57087. }
  57088. // Re-align the legend so that it's below the rangeselector
  57089. if (legend.display &&
  57090. verticalAlign === 'top' &&
  57091. verticalAlign === legend.options.verticalAlign) {
  57092. // Create a new alignment box for the legend.
  57093. alignTo = merge(chart.spacingBox);
  57094. if (legend.options.layout === 'vertical') {
  57095. alignTo.y = chart.plotTop;
  57096. }
  57097. else {
  57098. alignTo.y += rangeSelector.getHeight();
  57099. }
  57100. legend.group.placed = false; // Don't animate the alignment.
  57101. legend.align(alignTo);
  57102. }
  57103. }
  57104. }
  57105. if (rangeSelector) {
  57106. var events = find(chartDestroyEvents_1,
  57107. function (e) { return e[0] === chart; });
  57108. if (!events) {
  57109. chartDestroyEvents_1.push([chart, [
  57110. // redraw the scroller on setExtremes
  57111. addEvent(chart.xAxis[0], 'afterSetExtremes', function (e) {
  57112. if (rangeSelector) {
  57113. rangeSelector.render(e.min, e.max);
  57114. }
  57115. }),
  57116. // redraw the scroller chart resize
  57117. addEvent(chart, 'redraw', render)
  57118. ]]);
  57119. }
  57120. // do it now
  57121. render();
  57122. }
  57123. };
  57124. // Initialize rangeselector for stock charts
  57125. addEvent(Chart, 'afterGetContainer', function () {
  57126. if (this.options.rangeSelector &&
  57127. this.options.rangeSelector.enabled) {
  57128. this.rangeSelector = new RangeSelector(this);
  57129. }
  57130. });
  57131. addEvent(Chart, 'beforeRender', function () {
  57132. var chart = this,
  57133. axes = chart.axes,
  57134. rangeSelector = chart.rangeSelector,
  57135. verticalAlign;
  57136. if (rangeSelector) {
  57137. if (isNumber(rangeSelector.deferredYTDClick)) {
  57138. rangeSelector.clickButton(rangeSelector.deferredYTDClick);
  57139. delete rangeSelector.deferredYTDClick;
  57140. }
  57141. axes.forEach(function (axis) {
  57142. axis.updateNames();
  57143. axis.setScale();
  57144. });
  57145. chart.getAxisMargins();
  57146. rangeSelector.render();
  57147. verticalAlign = rangeSelector.options.verticalAlign;
  57148. if (!rangeSelector.options.floating) {
  57149. if (verticalAlign === 'bottom') {
  57150. this.extraBottomMargin = true;
  57151. }
  57152. else if (verticalAlign !== 'middle') {
  57153. this.extraTopMargin = true;
  57154. }
  57155. }
  57156. }
  57157. });
  57158. addEvent(Chart, 'update', function (e) {
  57159. var chart = this,
  57160. options = e.options,
  57161. optionsRangeSelector = options.rangeSelector,
  57162. rangeSelector = chart.rangeSelector,
  57163. verticalAlign,
  57164. extraBottomMarginWas = this.extraBottomMargin,
  57165. extraTopMarginWas = this.extraTopMargin;
  57166. if (optionsRangeSelector &&
  57167. optionsRangeSelector.enabled &&
  57168. !defined(rangeSelector) &&
  57169. this.options.rangeSelector) {
  57170. this.options.rangeSelector.enabled = true;
  57171. this.rangeSelector = rangeSelector = new RangeSelector(this);
  57172. }
  57173. this.extraBottomMargin = false;
  57174. this.extraTopMargin = false;
  57175. if (rangeSelector) {
  57176. initRangeSelector_1(this);
  57177. verticalAlign = (optionsRangeSelector &&
  57178. optionsRangeSelector.verticalAlign) || (rangeSelector.options && rangeSelector.options.verticalAlign);
  57179. if (!rangeSelector.options.floating) {
  57180. if (verticalAlign === 'bottom') {
  57181. this.extraBottomMargin = true;
  57182. }
  57183. else if (verticalAlign !== 'middle') {
  57184. this.extraTopMargin = true;
  57185. }
  57186. }
  57187. if (this.extraBottomMargin !== extraBottomMarginWas ||
  57188. this.extraTopMargin !== extraTopMarginWas) {
  57189. this.isDirtyBox = true;
  57190. }
  57191. }
  57192. });
  57193. addEvent(Chart, 'render', function () {
  57194. var chart = this,
  57195. rangeSelector = chart.rangeSelector,
  57196. verticalAlign;
  57197. if (rangeSelector && !rangeSelector.options.floating) {
  57198. rangeSelector.render();
  57199. verticalAlign = rangeSelector.options.verticalAlign;
  57200. if (verticalAlign === 'bottom') {
  57201. this.extraBottomMargin = true;
  57202. }
  57203. else if (verticalAlign !== 'middle') {
  57204. this.extraTopMargin = true;
  57205. }
  57206. }
  57207. });
  57208. addEvent(Chart, 'getMargins', function () {
  57209. var rangeSelector = this.rangeSelector,
  57210. rangeSelectorHeight;
  57211. if (rangeSelector) {
  57212. rangeSelectorHeight = rangeSelector.getHeight();
  57213. if (this.extraTopMargin) {
  57214. this.plotTop += rangeSelectorHeight;
  57215. }
  57216. if (this.extraBottomMargin) {
  57217. this.marginBottom += rangeSelectorHeight;
  57218. }
  57219. }
  57220. });
  57221. Chart.prototype.callbacks.push(initRangeSelector_1);
  57222. // Remove resize/afterSetExtremes at chart destroy
  57223. addEvent(Chart, 'destroy', function destroyEvents() {
  57224. for (var i = 0; i < chartDestroyEvents_1.length; i++) {
  57225. var events = chartDestroyEvents_1[i];
  57226. if (events[0] === this) {
  57227. events[1].forEach(function (unbind) { return unbind(); });
  57228. chartDestroyEvents_1.splice(i, 1);
  57229. return;
  57230. }
  57231. }
  57232. });
  57233. H.RangeSelector = RangeSelector;
  57234. }
  57235. return RangeSelector;
  57236. });
  57237. _registerModule(_modules, 'Core/Chart/StockChart.js', [_modules['Core/Animation/AnimationUtilities.js'], _modules['Core/Axis/Axis.js'], _modules['Core/Chart/Chart.js'], _modules['Core/FormatUtilities.js'], _modules['Core/DefaultOptions.js'], _modules['Core/Color/Palette.js'], _modules['Core/Series/Point.js'], _modules['Core/Series/Series.js'], _modules['Core/Renderer/SVG/SVGRenderer.js'], _modules['Core/Utilities.js']], function (A, Axis, Chart, F, D, Palette, Point, Series, SVGRenderer, U) {
  57238. /* *
  57239. *
  57240. * (c) 2010-2021 Torstein Honsi
  57241. *
  57242. * License: www.highcharts.com/license
  57243. *
  57244. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  57245. *
  57246. * */
  57247. var __extends = (this && this.__extends) || (function () {
  57248. var extendStatics = function (d,
  57249. b) {
  57250. extendStatics = Object.setPrototypeOf ||
  57251. ({ __proto__: [] } instanceof Array && function (d,
  57252. b) { d.__proto__ = b; }) ||
  57253. function (d,
  57254. b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  57255. return extendStatics(d, b);
  57256. };
  57257. return function (d, b) {
  57258. extendStatics(d, b);
  57259. function __() { this.constructor = d; }
  57260. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  57261. };
  57262. })();
  57263. var animObject = A.animObject;
  57264. var format = F.format;
  57265. var getOptions = D.getOptions;
  57266. var pointTooltipFormatter = Point.prototype.tooltipFormatter;
  57267. var _a = Series.prototype,
  57268. seriesInit = _a.init,
  57269. seriesProcessData = _a.processData;
  57270. var addEvent = U.addEvent,
  57271. arrayMax = U.arrayMax,
  57272. arrayMin = U.arrayMin,
  57273. clamp = U.clamp,
  57274. defined = U.defined,
  57275. extend = U.extend,
  57276. find = U.find,
  57277. isNumber = U.isNumber,
  57278. isString = U.isString,
  57279. merge = U.merge,
  57280. pick = U.pick,
  57281. splat = U.splat;
  57282. // Has a dependency on Navigator due to the use of
  57283. // defaultOptions.navigator
  57284. // Has a dependency on Scrollbar due to the use of
  57285. // defaultOptions.scrollbar
  57286. // Has a dependency on RangeSelector due to the use of
  57287. // defaultOptions.rangeSelector
  57288. /* *
  57289. *
  57290. * Class
  57291. *
  57292. * */
  57293. /**
  57294. * Stock-optimized chart. Use {@link Highcharts.Chart|Chart} for common charts.
  57295. *
  57296. * @requires modules/stock
  57297. *
  57298. * @class
  57299. * @name Highcharts.StockChart
  57300. * @extends Highcharts.Chart
  57301. */
  57302. var StockChart = /** @class */ (function (_super) {
  57303. __extends(StockChart, _super);
  57304. function StockChart() {
  57305. return _super !== null && _super.apply(this, arguments) || this;
  57306. }
  57307. /**
  57308. * Initializes the chart. The constructor's arguments are passed on
  57309. * directly.
  57310. *
  57311. * @function Highcharts.StockChart#init
  57312. *
  57313. * @param {Highcharts.Options} userOptions
  57314. * Custom options.
  57315. *
  57316. * @param {Function} [callback]
  57317. * Function to run when the chart has loaded and and all external
  57318. * images are loaded.
  57319. *
  57320. * @return {void}
  57321. *
  57322. * @fires Highcharts.StockChart#event:init
  57323. * @fires Highcharts.StockChart#event:afterInit
  57324. */
  57325. StockChart.prototype.init = function (userOptions, callback) {
  57326. var defaultOptions = getOptions(),
  57327. xAxisOptions = userOptions.xAxis,
  57328. yAxisOptions = userOptions.yAxis,
  57329. // Always disable startOnTick:true on the main axis when the
  57330. // navigator is enabled (#1090)
  57331. navigatorEnabled = pick(userOptions.navigator && userOptions.navigator.enabled,
  57332. defaultOptions.navigator.enabled,
  57333. true);
  57334. // Avoid doing these twice
  57335. userOptions.xAxis = userOptions.yAxis = void 0;
  57336. var options = merge({
  57337. chart: {
  57338. panning: {
  57339. enabled: true,
  57340. type: 'x'
  57341. },
  57342. pinchType: 'x'
  57343. },
  57344. navigator: {
  57345. enabled: navigatorEnabled
  57346. },
  57347. scrollbar: {
  57348. // #4988 - check if setOptions was called
  57349. enabled: pick(defaultOptions.scrollbar && defaultOptions.scrollbar.enabled,
  57350. true)
  57351. },
  57352. rangeSelector: {
  57353. // #4988 - check if setOptions was called
  57354. enabled: pick(defaultOptions.rangeSelector.enabled,
  57355. true)
  57356. },
  57357. title: {
  57358. text: null
  57359. },
  57360. tooltip: {
  57361. split: pick(defaultOptions.tooltip.split,
  57362. true),
  57363. crosshairs: true
  57364. },
  57365. legend: {
  57366. enabled: false
  57367. }
  57368. },
  57369. userOptions, // user's options
  57370. {
  57371. isStock: true // internal flag
  57372. });
  57373. userOptions.xAxis = xAxisOptions;
  57374. userOptions.yAxis = yAxisOptions;
  57375. // apply X axis options to both single and multi y axes
  57376. options.xAxis = splat(userOptions.xAxis || {}).map(function (xAxisOptions, i) {
  57377. return merge(getDefaultAxisOptions('xAxis', xAxisOptions), defaultOptions.xAxis, // #3802
  57378. defaultOptions.xAxis && defaultOptions.xAxis[i], // #7690
  57379. xAxisOptions, // user options
  57380. getForcedAxisOptions('xAxis', userOptions));
  57381. });
  57382. // apply Y axis options to both single and multi y axes
  57383. options.yAxis = splat(userOptions.yAxis || {}).map(function (yAxisOptions, i) {
  57384. return merge(getDefaultAxisOptions('yAxis', yAxisOptions), defaultOptions.yAxis, // #3802
  57385. defaultOptions.yAxis && defaultOptions.yAxis[i], // #7690
  57386. yAxisOptions // user options
  57387. );
  57388. });
  57389. _super.prototype.init.call(this, options, callback);
  57390. };
  57391. /**
  57392. * Factory for creating different axis types.
  57393. * Extended to add stock defaults.
  57394. *
  57395. * @private
  57396. * @function Highcharts.StockChart#createAxis
  57397. *
  57398. * @param {string} type
  57399. * An axis type.
  57400. *
  57401. * @param {Chart.CreateAxisOptionsObject} options
  57402. * The axis creation options.
  57403. *
  57404. * @return {Highcharts.Axis | Highcharts.ColorAxis}
  57405. */
  57406. StockChart.prototype.createAxis = function (type, options) {
  57407. options.axis = merge(getDefaultAxisOptions(type, options.axis), options.axis, getForcedAxisOptions(type, this.userOptions));
  57408. return _super.prototype.createAxis.call(this, type, options);
  57409. };
  57410. return StockChart;
  57411. }(Chart));
  57412. /* eslint-disable no-invalid-this, valid-jsdoc */
  57413. (function (StockChart) {
  57414. /**
  57415. * Factory function for creating new stock charts. Creates a new
  57416. * {@link Highcharts.StockChart|StockChart} object with different default
  57417. * options than the basic Chart.
  57418. *
  57419. * @example
  57420. * let chart = Highcharts.stockChart('container', {
  57421. * series: [{
  57422. * data: [1, 2, 3, 4, 5, 6, 7, 8, 9],
  57423. * pointInterval: 24 * 60 * 60 * 1000
  57424. * }]
  57425. * });
  57426. *
  57427. * @function Highcharts.stockChart
  57428. *
  57429. * @param {string|Highcharts.HTMLDOMElement} [renderTo]
  57430. * The DOM element to render to, or its id.
  57431. *
  57432. * @param {Highcharts.Options} options
  57433. * The chart options structure as described in the
  57434. * [options reference](https://api.highcharts.com/highstock).
  57435. *
  57436. * @param {Highcharts.ChartCallbackFunction} [callback]
  57437. * A function to execute when the chart object is finished loading
  57438. * and rendering. In most cases the chart is built in one thread,
  57439. * but in Internet Explorer version 8 or less the chart is sometimes
  57440. * initialized before the document is ready, and in these cases the
  57441. * chart object will not be finished synchronously. As a
  57442. * consequence, code that relies on the newly built Chart object
  57443. * should always run in the callback. Defining a
  57444. * [chart.events.load](https://api.highcharts.com/highstock/chart.events.load)
  57445. * handler is equivalent.
  57446. *
  57447. * @return {Highcharts.StockChart}
  57448. * The chart object.
  57449. */
  57450. function stockChart(a, b, c) {
  57451. return new StockChart(a, b, c);
  57452. }
  57453. StockChart.stockChart = stockChart;
  57454. })(StockChart || (StockChart = {}));
  57455. /**
  57456. * Get stock-specific default axis options.
  57457. *
  57458. * @private
  57459. * @function getDefaultAxisOptions
  57460. * @param {string} type
  57461. * @param {Highcharts.AxisOptions} options
  57462. * @return {Highcharts.AxisOptions}
  57463. */
  57464. function getDefaultAxisOptions(type, options) {
  57465. if (type === 'xAxis') {
  57466. return {
  57467. minPadding: 0,
  57468. maxPadding: 0,
  57469. overscroll: 0,
  57470. ordinal: true,
  57471. title: {
  57472. text: null
  57473. },
  57474. labels: {
  57475. overflow: 'justify'
  57476. },
  57477. showLastLabel: true
  57478. };
  57479. }
  57480. if (type === 'yAxis') {
  57481. return {
  57482. labels: {
  57483. y: -2
  57484. },
  57485. opposite: pick(options.opposite, true),
  57486. /**
  57487. * @default {highcharts} true
  57488. * @default {highstock} false
  57489. * @apioption yAxis.showLastLabel
  57490. *
  57491. * @private
  57492. */
  57493. showLastLabel: !!(
  57494. // #6104, show last label by default for category axes
  57495. options.categories ||
  57496. options.type === 'category'),
  57497. title: {
  57498. text: null
  57499. }
  57500. };
  57501. }
  57502. return {};
  57503. }
  57504. /**
  57505. * Get stock-specific forced axis options.
  57506. *
  57507. * @private
  57508. * @function getForcedAxisOptions
  57509. * @param {string} type
  57510. * @param {Highcharts.Options} chartOptions
  57511. * @return {Highcharts.AxisOptions}
  57512. */
  57513. function getForcedAxisOptions(type, chartOptions) {
  57514. if (type === 'xAxis') {
  57515. var defaultOptions = getOptions(),
  57516. // Always disable startOnTick:true on the main axis when the
  57517. // navigator is enabled (#1090)
  57518. navigatorEnabled = pick(chartOptions.navigator && chartOptions.navigator.enabled,
  57519. defaultOptions.navigator.enabled,
  57520. true);
  57521. var axisOptions = {
  57522. type: 'datetime',
  57523. categories: void 0
  57524. };
  57525. if (navigatorEnabled) {
  57526. axisOptions.startOnTick = false;
  57527. axisOptions.endOnTick = false;
  57528. }
  57529. return axisOptions;
  57530. }
  57531. return {};
  57532. }
  57533. /* *
  57534. *
  57535. * Compositions
  57536. *
  57537. * */
  57538. // Handle som Stock-specific series defaults, override the plotOptions before
  57539. // series options are handled.
  57540. addEvent(Series, 'setOptions', function (e) {
  57541. var overrides;
  57542. if (this.chart.options.isStock) {
  57543. if (this.is('column') || this.is('columnrange')) {
  57544. overrides = {
  57545. borderWidth: 0,
  57546. shadow: false
  57547. };
  57548. }
  57549. else if (!this.is('scatter') && !this.is('sma')) {
  57550. overrides = {
  57551. marker: {
  57552. enabled: false,
  57553. radius: 2
  57554. }
  57555. };
  57556. }
  57557. if (overrides) {
  57558. e.plotOptions[this.type] = merge(e.plotOptions[this.type], overrides);
  57559. }
  57560. }
  57561. });
  57562. // Override the automatic label alignment so that the first Y axis' labels
  57563. // are drawn on top of the grid line, and subsequent axes are drawn outside
  57564. addEvent(Axis, 'autoLabelAlign', function (e) {
  57565. var chart = this.chart,
  57566. options = this.options,
  57567. panes = chart._labelPanes = chart._labelPanes || {},
  57568. key,
  57569. labelOptions = this.options.labels;
  57570. if (this.chart.options.isStock && this.coll === 'yAxis') {
  57571. key = options.top + ',' + options.height;
  57572. // do it only for the first Y axis of each pane
  57573. if (!panes[key] && labelOptions.enabled) {
  57574. if (labelOptions.x === 15) { // default
  57575. labelOptions.x = 0;
  57576. }
  57577. if (typeof labelOptions.align === 'undefined') {
  57578. labelOptions.align = 'right';
  57579. }
  57580. panes[key] = this;
  57581. e.align = 'right';
  57582. e.preventDefault();
  57583. }
  57584. }
  57585. });
  57586. // Clear axis from label panes (#6071)
  57587. addEvent(Axis, 'destroy', function () {
  57588. var chart = this.chart, key = this.options && (this.options.top + ',' + this.options.height);
  57589. if (key && chart._labelPanes && chart._labelPanes[key] === this) {
  57590. delete chart._labelPanes[key];
  57591. }
  57592. });
  57593. // Override getPlotLinePath to allow for multipane charts
  57594. addEvent(Axis, 'getPlotLinePath', function (e) {
  57595. var axis = this,
  57596. series = (this.isLinked && !this.series ?
  57597. this.linkedParent.series :
  57598. this.series),
  57599. chart = axis.chart,
  57600. renderer = chart.renderer,
  57601. axisLeft = axis.left,
  57602. axisTop = axis.top,
  57603. x1,
  57604. y1,
  57605. x2,
  57606. y2,
  57607. result = [],
  57608. axes = [], // #3416 need a default array
  57609. axes2,
  57610. uniqueAxes,
  57611. translatedValue = e.translatedValue,
  57612. value = e.value,
  57613. force = e.force,
  57614. transVal;
  57615. /**
  57616. * Return the other axis based on either the axis option or on related
  57617. * series.
  57618. * @private
  57619. */
  57620. function getAxis(coll) {
  57621. var otherColl = coll === 'xAxis' ? 'yAxis' : 'xAxis',
  57622. opt = axis.options[otherColl];
  57623. // Other axis indexed by number
  57624. if (isNumber(opt)) {
  57625. return [chart[otherColl][opt]];
  57626. }
  57627. // Other axis indexed by id (like navigator)
  57628. if (isString(opt)) {
  57629. return [chart.get(opt)];
  57630. }
  57631. // Auto detect based on existing series
  57632. return series.map(function (s) {
  57633. return s[otherColl];
  57634. });
  57635. }
  57636. if ( // For stock chart, by default render paths across the panes
  57637. // except the case when `acrossPanes` is disabled by user (#6644)
  57638. (chart.options.isStock && e.acrossPanes !== false) &&
  57639. // Ignore in case of colorAxis or zAxis. #3360, #3524, #6720
  57640. axis.coll === 'xAxis' || axis.coll === 'yAxis') {
  57641. e.preventDefault();
  57642. // Get the related axes based on series
  57643. axes = getAxis(axis.coll);
  57644. // Get the related axes based options.*Axis setting #2810
  57645. axes2 = (axis.isXAxis ? chart.yAxis : chart.xAxis);
  57646. axes2.forEach(function (A) {
  57647. if (defined(A.options.id) ?
  57648. A.options.id.indexOf('navigator') === -1 :
  57649. true) {
  57650. var a = (A.isXAxis ? 'yAxis' : 'xAxis'),
  57651. rax = (defined(A.options[a]) ?
  57652. chart[a][A.options[a]] :
  57653. chart[a][0]);
  57654. if (axis === rax) {
  57655. axes.push(A);
  57656. }
  57657. }
  57658. });
  57659. // Remove duplicates in the axes array. If there are no axes in the axes
  57660. // array, we are adding an axis without data, so we need to populate
  57661. // this with grid lines (#2796).
  57662. uniqueAxes = axes.length ?
  57663. [] :
  57664. [axis.isXAxis ? chart.yAxis[0] : chart.xAxis[0]]; // #3742
  57665. axes.forEach(function (axis2) {
  57666. if (uniqueAxes.indexOf(axis2) === -1 &&
  57667. // Do not draw on axis which overlap completely. #5424
  57668. !find(uniqueAxes, function (unique) {
  57669. return unique.pos === axis2.pos && unique.len === axis2.len;
  57670. })) {
  57671. uniqueAxes.push(axis2);
  57672. }
  57673. });
  57674. transVal = pick(translatedValue, axis.translate(value, null, null, e.old));
  57675. if (isNumber(transVal)) {
  57676. if (axis.horiz) {
  57677. uniqueAxes.forEach(function (axis2) {
  57678. var skip;
  57679. y1 = axis2.pos;
  57680. y2 = y1 + axis2.len;
  57681. x1 = x2 = Math.round(transVal + axis.transB);
  57682. // outside plot area
  57683. if (force !== 'pass' &&
  57684. (x1 < axisLeft || x1 > axisLeft + axis.width)) {
  57685. if (force) {
  57686. x1 = x2 = clamp(x1, axisLeft, axisLeft + axis.width);
  57687. }
  57688. else {
  57689. skip = true;
  57690. }
  57691. }
  57692. if (!skip) {
  57693. result.push(['M', x1, y1], ['L', x2, y2]);
  57694. }
  57695. });
  57696. }
  57697. else {
  57698. uniqueAxes.forEach(function (axis2) {
  57699. var skip;
  57700. x1 = axis2.pos;
  57701. x2 = x1 + axis2.len;
  57702. y1 = y2 = Math.round(axisTop + axis.height - transVal);
  57703. // outside plot area
  57704. if (force !== 'pass' &&
  57705. (y1 < axisTop || y1 > axisTop + axis.height)) {
  57706. if (force) {
  57707. y1 = y2 = clamp(y1, axisTop, axisTop + axis.height);
  57708. }
  57709. else {
  57710. skip = true;
  57711. }
  57712. }
  57713. if (!skip) {
  57714. result.push(['M', x1, y1], ['L', x2, y2]);
  57715. }
  57716. });
  57717. }
  57718. }
  57719. e.path = result.length > 0 ?
  57720. renderer.crispPolyLine(result, e.lineWidth || 1) :
  57721. // #3557 getPlotLinePath in regular Highcharts also returns null
  57722. null;
  57723. }
  57724. });
  57725. /**
  57726. * Function to crisp a line with multiple segments
  57727. *
  57728. * @private
  57729. * @function Highcharts.SVGRenderer#crispPolyLine
  57730. * @param {Highcharts.SVGPathArray} points
  57731. * @param {number} width
  57732. * @return {Highcharts.SVGPathArray}
  57733. */
  57734. SVGRenderer.prototype.crispPolyLine = function (points, width) {
  57735. // points format: [['M', 0, 0], ['L', 100, 0]]
  57736. // normalize to a crisp line
  57737. for (var i = 0; i < points.length; i = i + 2) {
  57738. var start = points[i],
  57739. end = points[i + 1];
  57740. if (start[1] === end[1]) {
  57741. // Substract due to #1129. Now bottom and left axis gridlines behave
  57742. // the same.
  57743. start[1] = end[1] =
  57744. Math.round(start[1]) - (width % 2 / 2);
  57745. }
  57746. if (start[2] === end[2]) {
  57747. start[2] = end[2] =
  57748. Math.round(start[2]) + (width % 2 / 2);
  57749. }
  57750. }
  57751. return points;
  57752. };
  57753. // Wrapper to hide the label
  57754. addEvent(Axis, 'afterHideCrosshair', function () {
  57755. if (this.crossLabel) {
  57756. this.crossLabel = this.crossLabel.hide();
  57757. }
  57758. });
  57759. // Extend crosshairs to also draw the label
  57760. addEvent(Axis, 'afterDrawCrosshair', function (event) {
  57761. // Check if the label has to be drawn
  57762. if (!this.crosshair ||
  57763. !this.crosshair.label ||
  57764. !this.crosshair.label.enabled ||
  57765. !this.cross ||
  57766. !isNumber(this.min) ||
  57767. !isNumber(this.max)) {
  57768. return;
  57769. }
  57770. var chart = this.chart, log = this.logarithmic, options = this.crosshair.label, // the label's options
  57771. horiz = this.horiz, // axis orientation
  57772. opposite = this.opposite, // axis position
  57773. left = this.left, // left position
  57774. top = this.top, // top position
  57775. crossLabel = this.crossLabel, // the svgElement
  57776. posx, posy, crossBox, formatOption = options.format, formatFormat = '', limit, align, tickInside = this.options.tickPosition === 'inside', snap = this.crosshair.snap !== false, offset = 0,
  57777. // Use last available event (#5287)
  57778. e = event.e || (this.cross && this.cross.e), point = event.point, min = this.min, max = this.max;
  57779. if (log) {
  57780. min = log.lin2log(min);
  57781. max = log.lin2log(max);
  57782. }
  57783. align = (horiz ? 'center' : opposite ?
  57784. (this.labelAlign === 'right' ? 'right' : 'left') :
  57785. (this.labelAlign === 'left' ? 'left' : 'center'));
  57786. // If the label does not exist yet, create it.
  57787. if (!crossLabel) {
  57788. crossLabel = this.crossLabel = chart.renderer
  57789. .label('', 0, void 0, options.shape || 'callout')
  57790. .addClass('highcharts-crosshair-label highcharts-color-' + (point ?
  57791. point.series.colorIndex :
  57792. this.series[0] && this.series[0].colorIndex))
  57793. .attr({
  57794. align: options.align || align,
  57795. padding: pick(options.padding, 8),
  57796. r: pick(options.borderRadius, 3),
  57797. zIndex: 2
  57798. })
  57799. .add(this.labelGroup);
  57800. // Presentational
  57801. if (!chart.styledMode) {
  57802. crossLabel
  57803. .attr({
  57804. fill: options.backgroundColor ||
  57805. point && point.series && point.series.color || // #14888
  57806. Palette.neutralColor60,
  57807. stroke: options.borderColor || '',
  57808. 'stroke-width': options.borderWidth || 0
  57809. })
  57810. .css(extend({
  57811. color: Palette.backgroundColor,
  57812. fontWeight: 'normal',
  57813. fontSize: '11px',
  57814. textAlign: 'center'
  57815. }, options.style || {}));
  57816. }
  57817. }
  57818. if (horiz) {
  57819. posx = snap ? (point.plotX || 0) + left : e.chartX;
  57820. posy = top + (opposite ? 0 : this.height);
  57821. }
  57822. else {
  57823. posx = opposite ? this.width + left : 0;
  57824. posy = snap ? (point.plotY || 0) + top : e.chartY;
  57825. }
  57826. if (!formatOption && !options.formatter) {
  57827. if (this.dateTime) {
  57828. formatFormat = '%b %d, %Y';
  57829. }
  57830. formatOption =
  57831. '{value' + (formatFormat ? ':' + formatFormat : '') + '}';
  57832. }
  57833. // Show the label
  57834. var value = snap ?
  57835. (this.isXAxis ? point.x : point.y) :
  57836. this.toValue(horiz ? e.chartX : e.chartY);
  57837. // Crosshair should be rendered within Axis range (#7219). Also, the point
  57838. // of currentPriceIndicator should be inside the plot area, #14879.
  57839. var isInside = point ?
  57840. point.series.isPointInside(point) :
  57841. (isNumber(value) && value > min && value < max);
  57842. var text = '';
  57843. if (formatOption) {
  57844. text = format(formatOption, { value: value }, chart);
  57845. }
  57846. else if (options.formatter && isNumber(value)) {
  57847. text = options.formatter.call(this, value);
  57848. }
  57849. crossLabel.attr({
  57850. text: text,
  57851. x: posx,
  57852. y: posy,
  57853. visibility: isInside ? 'visible' : 'hidden'
  57854. });
  57855. crossBox = crossLabel.getBBox();
  57856. // now it is placed we can correct its position
  57857. if (isNumber(crossLabel.y)) {
  57858. if (horiz) {
  57859. if ((tickInside && !opposite) || (!tickInside && opposite)) {
  57860. posy = crossLabel.y - crossBox.height;
  57861. }
  57862. }
  57863. else {
  57864. posy = crossLabel.y - (crossBox.height / 2);
  57865. }
  57866. }
  57867. // check the edges
  57868. if (horiz) {
  57869. limit = {
  57870. left: left - crossBox.x,
  57871. right: left + this.width - crossBox.x
  57872. };
  57873. }
  57874. else {
  57875. limit = {
  57876. left: this.labelAlign === 'left' ? left : 0,
  57877. right: this.labelAlign === 'right' ?
  57878. left + this.width :
  57879. chart.chartWidth
  57880. };
  57881. }
  57882. // left edge
  57883. if (crossLabel.translateX < limit.left) {
  57884. offset = limit.left - crossLabel.translateX;
  57885. }
  57886. // right edge
  57887. if (crossLabel.translateX + crossBox.width >= limit.right) {
  57888. offset = -(crossLabel.translateX + crossBox.width - limit.right);
  57889. }
  57890. // show the crosslabel
  57891. crossLabel.attr({
  57892. x: posx + offset,
  57893. y: posy,
  57894. // First set x and y, then anchorX and anchorY, when box is actually
  57895. // calculated, #5702
  57896. anchorX: horiz ?
  57897. posx :
  57898. (this.opposite ? 0 : chart.chartWidth),
  57899. anchorY: horiz ?
  57900. (this.opposite ? chart.chartHeight : 0) :
  57901. posy + crossBox.height / 2
  57902. });
  57903. });
  57904. /* ************************************************************************** *
  57905. * Start value compare logic *
  57906. * ************************************************************************** */
  57907. /**
  57908. * Extend series.init by adding a method to modify the y value used for plotting
  57909. * on the y axis. This method is called both from the axis when finding dataMin
  57910. * and dataMax, and from the series.translate method.
  57911. *
  57912. * @ignore
  57913. * @function Highcharts.Series#init
  57914. */
  57915. Series.prototype.init = function () {
  57916. // Call base method
  57917. seriesInit.apply(this, arguments);
  57918. // Set comparison mode
  57919. this.initCompare(this.options.compare);
  57920. };
  57921. /**
  57922. * Highcharts Stock only. Set the
  57923. * [compare](https://api.highcharts.com/highstock/plotOptions.series.compare)
  57924. * mode of the series after render time. In most cases it is more useful running
  57925. * {@link Axis#setCompare} on the X axis to update all its series.
  57926. *
  57927. * @function Highcharts.Series#setCompare
  57928. *
  57929. * @param {string} [compare]
  57930. * Can be one of `null` (default), `"percent"` or `"value"`.
  57931. */
  57932. Series.prototype.setCompare = function (compare) {
  57933. this.initCompare(compare);
  57934. // Survive to export, #5485
  57935. this.userOptions.compare = compare;
  57936. };
  57937. /**
  57938. * @ignore
  57939. * @function Highcharts.Series#initCompare
  57940. *
  57941. * @param {string} [compare]
  57942. * Can be one of `null` (default), `"percent"` or `"value"`.
  57943. */
  57944. Series.prototype.initCompare = function (compare) {
  57945. // Set or unset the modifyValue method
  57946. this.modifyValue = (compare === 'value' || compare === 'percent') ?
  57947. function (value, point) {
  57948. var compareValue = this.compareValue;
  57949. if (typeof value !== 'undefined' &&
  57950. typeof compareValue !== 'undefined') { // #2601, #5814
  57951. // Get the modified value
  57952. if (compare === 'value') {
  57953. value -= compareValue;
  57954. // Compare percent
  57955. }
  57956. else {
  57957. value = 100 * (value / compareValue) -
  57958. (this.options.compareBase === 100 ? 0 : 100);
  57959. }
  57960. // record for tooltip etc.
  57961. if (point) {
  57962. point.change = value;
  57963. }
  57964. return value;
  57965. }
  57966. return 0;
  57967. } :
  57968. null;
  57969. // Mark dirty
  57970. if (this.chart.hasRendered) {
  57971. this.isDirty = true;
  57972. }
  57973. };
  57974. /**
  57975. * Extend series.processData by finding the first y value in the plot area,
  57976. * used for comparing the following values
  57977. *
  57978. * @ignore
  57979. * @function Highcharts.Series#processData
  57980. */
  57981. Series.prototype.processData = function (force) {
  57982. var series = this,
  57983. i,
  57984. keyIndex = -1,
  57985. processedXData,
  57986. processedYData,
  57987. compareStart = series.options.compareStart === true ? 0 : 1,
  57988. length,
  57989. compareValue;
  57990. // call base method
  57991. seriesProcessData.apply(this, arguments);
  57992. if (series.xAxis && series.processedYData) { // not pies
  57993. // local variables
  57994. processedXData = series.processedXData;
  57995. processedYData = series.processedYData;
  57996. length = processedYData.length;
  57997. // For series with more than one value (range, OHLC etc), compare
  57998. // against close or the pointValKey (#4922, #3112, #9854)
  57999. if (series.pointArrayMap) {
  58000. keyIndex = series.pointArrayMap.indexOf(series.options.pointValKey || series.pointValKey || 'y');
  58001. }
  58002. // find the first value for comparison
  58003. for (i = 0; i < length - compareStart; i++) {
  58004. compareValue = processedYData[i] && keyIndex > -1 ?
  58005. processedYData[i][keyIndex] :
  58006. processedYData[i];
  58007. if (isNumber(compareValue) &&
  58008. processedXData[i + compareStart] >=
  58009. series.xAxis.min &&
  58010. compareValue !== 0) {
  58011. series.compareValue = compareValue;
  58012. break;
  58013. }
  58014. }
  58015. }
  58016. return;
  58017. };
  58018. // Modify series extremes
  58019. addEvent(Series, 'afterGetExtremes', function (e) {
  58020. var dataExtremes = e.dataExtremes;
  58021. if (this.modifyValue && dataExtremes) {
  58022. var extremes = [
  58023. this.modifyValue(dataExtremes.dataMin),
  58024. this.modifyValue(dataExtremes.dataMax)
  58025. ];
  58026. dataExtremes.dataMin = arrayMin(extremes);
  58027. dataExtremes.dataMax = arrayMax(extremes);
  58028. }
  58029. });
  58030. /**
  58031. * Highcharts Stock only. Set the compare mode on all series
  58032. * belonging to an Y axis after render time.
  58033. *
  58034. * @see [series.plotOptions.compare](https://api.highcharts.com/highstock/series.plotOptions.compare)
  58035. *
  58036. * @sample stock/members/axis-setcompare/
  58037. * Set compoare
  58038. *
  58039. * @function Highcharts.Axis#setCompare
  58040. *
  58041. * @param {string} [compare]
  58042. * The compare mode. Can be one of `null` (default), `"value"` or
  58043. * `"percent"`.
  58044. *
  58045. * @param {boolean} [redraw=true]
  58046. * Whether to redraw the chart or to wait for a later call to
  58047. * {@link Chart#redraw}.
  58048. */
  58049. Axis.prototype.setCompare = function (compare, redraw) {
  58050. if (!this.isXAxis) {
  58051. this.series.forEach(function (series) {
  58052. series.setCompare(compare);
  58053. });
  58054. if (pick(redraw, true)) {
  58055. this.chart.redraw();
  58056. }
  58057. }
  58058. };
  58059. /**
  58060. * Extend the tooltip formatter by adding support for the point.change variable
  58061. * as well as the changeDecimals option.
  58062. *
  58063. * @ignore
  58064. * @function Highcharts.Point#tooltipFormatter
  58065. *
  58066. * @param {string} pointFormat
  58067. */
  58068. Point.prototype.tooltipFormatter = function (pointFormat) {
  58069. var point = this;
  58070. var numberFormatter = point.series.chart.numberFormatter;
  58071. pointFormat = pointFormat.replace('{point.change}', (point.change > 0 ? '+' : '') + numberFormatter(point.change, pick(point.series.tooltipOptions.changeDecimals, 2)));
  58072. return pointTooltipFormatter.apply(this, [pointFormat]);
  58073. };
  58074. /* ************************************************************************** *
  58075. * End value compare logic *
  58076. * ************************************************************************** */
  58077. // Extend the Series prototype to create a separate series clip box. This is
  58078. // related to using multiple panes, and a future pane logic should incorporate
  58079. // this feature (#2754).
  58080. addEvent(Series, 'render', function () {
  58081. var chart = this.chart,
  58082. clipHeight;
  58083. // Only do this on not 3d (#2939, #5904) nor polar (#6057) charts, and only
  58084. // if the series type handles clipping in the animate method (#2975).
  58085. if (!(chart.is3d && chart.is3d()) &&
  58086. !chart.polar &&
  58087. this.xAxis &&
  58088. !this.xAxis.isRadial && // Gauge, #6192
  58089. this.options.clip !== false // #15128
  58090. ) {
  58091. clipHeight = this.yAxis.len;
  58092. // Include xAxis line width (#8031) but only if the Y axis ends on the
  58093. // edge of the X axis (#11005).
  58094. if (this.xAxis.axisLine) {
  58095. var dist = chart.plotTop + chart.plotHeight -
  58096. this.yAxis.pos - this.yAxis.len,
  58097. lineHeightCorrection = Math.floor(this.xAxis.axisLine.strokeWidth() / 2);
  58098. if (dist >= 0) {
  58099. clipHeight -= Math.max(lineHeightCorrection - dist, 0);
  58100. }
  58101. }
  58102. // First render, initial clip box. clipBox also needs to be updated if
  58103. // the series is rendered again before starting animating, in
  58104. // compliance with a responsive rule (#13858).
  58105. if (!chart.hasLoaded || (!this.clipBox && this.isDirty && !this.isDirtyData)) {
  58106. this.clipBox = this.clipBox || merge(chart.clipBox);
  58107. this.clipBox.width = this.xAxis.len;
  58108. this.clipBox.height = clipHeight;
  58109. }
  58110. if (chart.hasRendered) {
  58111. var animation = animObject(this.options.animation);
  58112. // #15435: this.sharedClipKey might not have been set yet, for
  58113. // example when updating the series, so we need to use this
  58114. // function instead
  58115. var sharedClipKey = this.getSharedClipKey(animation);
  58116. var clipRect = chart.sharedClips[sharedClipKey];
  58117. // On redrawing, resizing etc, update the clip rectangle.
  58118. //
  58119. // #15435: Update it even when we are creating/updating clipBox,
  58120. // since there could be series updating and pane size changes
  58121. // happening at the same time and we dont destroy shared clips in
  58122. // stock.
  58123. if (clipRect) {
  58124. // animate in case resize is done during initial animation
  58125. clipRect.animate({
  58126. width: this.xAxis.len,
  58127. height: clipHeight
  58128. });
  58129. var markerClipRect = chart.sharedClips[sharedClipKey + 'm'];
  58130. // also change markers clip animation for consistency
  58131. // (marker clip rects should exist only on chart init)
  58132. if (markerClipRect) {
  58133. markerClipRect.animate({
  58134. width: this.xAxis.len
  58135. });
  58136. }
  58137. }
  58138. }
  58139. }
  58140. });
  58141. addEvent(Chart, 'update', function (e) {
  58142. var options = e.options;
  58143. // Use case: enabling scrollbar from a disabled state.
  58144. // Scrollbar needs to be initialized from a controller, Navigator in this
  58145. // case (#6615)
  58146. if ('scrollbar' in options && this.navigator) {
  58147. merge(true, this.options.scrollbar, options.scrollbar);
  58148. this.navigator.update({}, false);
  58149. delete options.scrollbar;
  58150. }
  58151. });
  58152. /* *
  58153. *
  58154. * Default Export
  58155. *
  58156. * */
  58157. /* *
  58158. *
  58159. * API Options
  58160. *
  58161. * */
  58162. /**
  58163. * Compare the values of the series against the first non-null, non-
  58164. * zero value in the visible range. The y axis will show percentage
  58165. * or absolute change depending on whether `compare` is set to `"percent"`
  58166. * or `"value"`. When this is applied to multiple series, it allows
  58167. * comparing the development of the series against each other. Adds
  58168. * a `change` field to every point object.
  58169. *
  58170. * @see [compareBase](#plotOptions.series.compareBase)
  58171. * @see [Axis.setCompare()](/class-reference/Highcharts.Axis#setCompare)
  58172. *
  58173. * @sample {highstock} stock/plotoptions/series-compare-percent/
  58174. * Percent
  58175. * @sample {highstock} stock/plotoptions/series-compare-value/
  58176. * Value
  58177. *
  58178. * @type {string}
  58179. * @since 1.0.1
  58180. * @product highstock
  58181. * @apioption plotOptions.series.compare
  58182. */
  58183. /**
  58184. * Defines if comparison should start from the first point within the visible
  58185. * range or should start from the first point **before** the range.
  58186. *
  58187. * In other words, this flag determines if first point within the visible range
  58188. * will have 0% (`compareStart=true`) or should have been already calculated
  58189. * according to the previous point (`compareStart=false`).
  58190. *
  58191. * @sample {highstock} stock/plotoptions/series-comparestart/
  58192. * Calculate compare within visible range
  58193. *
  58194. * @type {boolean}
  58195. * @default false
  58196. * @since 6.0.0
  58197. * @product highstock
  58198. * @apioption plotOptions.series.compareStart
  58199. */
  58200. /**
  58201. * When [compare](#plotOptions.series.compare) is `percent`, this option
  58202. * dictates whether to use 0 or 100 as the base of comparison.
  58203. *
  58204. * @sample {highstock} stock/plotoptions/series-comparebase/
  58205. * Compare base is 100
  58206. *
  58207. * @type {number}
  58208. * @default 0
  58209. * @since 5.0.6
  58210. * @product highstock
  58211. * @validvalue [0, 100]
  58212. * @apioption plotOptions.series.compareBase
  58213. */
  58214. ''; // keeps doclets above in transpiled file
  58215. return StockChart;
  58216. });
  58217. _registerModule(_modules, 'masters/modules/stock.src.js', [_modules['Core/Globals.js'], _modules['Core/Scrollbar.js'], _modules['Core/Chart/StockChart.js']], function (Highcharts, Scrollbar, StockChart) {
  58218. var G = Highcharts;
  58219. // Classes
  58220. G.Scrollbar = Scrollbar;
  58221. G.StockChart = G.stockChart = StockChart.stockChart;
  58222. // Compositions
  58223. Scrollbar.compose(G.Axis);
  58224. });
  58225. _registerModule(_modules, 'masters/highstock.src.js', [_modules['masters/highcharts.src.js']], function (Highcharts) {
  58226. Highcharts.product = 'Highstock';
  58227. return Highcharts;
  58228. });
  58229. _modules['masters/highstock.src.js']._modules = _modules;
  58230. return _modules['masters/highstock.src.js'];
  58231. }));