Axis.js 224 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634
  1. /* *
  2. *
  3. * (c) 2010-2019 Torstein Honsi
  4. *
  5. * License: www.highcharts.com/license
  6. *
  7. * !!!!!!! SOURCE GETS TRANSPILED BY TYPESCRIPT. EDIT TS FILE ONLY. !!!!!!!
  8. *
  9. * */
  10. 'use strict';
  11. import H from './Globals.js';
  12. /**
  13. * Options for the path on the Axis to be calculated.
  14. * @interface Highcharts.AxisPlotLinePathOptionsObject
  15. */ /**
  16. * Axis value.
  17. * @name Highcharts.AxisPlotLinePathOptionsObject#value
  18. * @type {number|undefined}
  19. */ /**
  20. * Line width used for calculation crisp line coordinates. Defaults to 1.
  21. * @name Highcharts.AxisPlotLinePathOptionsObject#lineWidth
  22. * @type {number|undefined}
  23. */ /**
  24. * If `false`, the function will return null when it falls outside the axis
  25. * bounds. If `true`, the function will return a path aligned to the plot area
  26. * sides if it falls outside. If `pass`, it will return a path outside.
  27. * @name Highcharts.AxisPlotLinePathOptionsObject#force
  28. * @type {string|boolean|undefined}
  29. */ /**
  30. * Used in Highstock. When `true`, plot paths (crosshair, plotLines, gridLines)
  31. * will be rendered on all axes when defined on the first axis.
  32. * @name Highcharts.AxisPlotLinePathOptionsObject#acrossPanes
  33. * @type {boolean|undefined}
  34. */ /**
  35. * Use old coordinates (for resizing and rescaling).
  36. * If not set, defaults to `false`.
  37. * @name Highcharts.AxisPlotLinePathOptionsObject#old
  38. * @type {boolean|undefined}
  39. */ /**
  40. * If given, return the plot line path of a pixel position on the axis.
  41. * @name Highcharts.AxisPlotLinePathOptionsObject#translatedValue
  42. * @type {number|undefined}
  43. */ /**
  44. * Used in Polar axes. Reverse the positions for concatenation of polygonal
  45. * plot bands
  46. * @name Highcharts.AxisPlotLinePathOptionsObject#reverse
  47. * @type {boolean|undefined}
  48. */
  49. /**
  50. * Options for crosshairs on axes.
  51. *
  52. * @product highstock
  53. *
  54. * @typedef {Highcharts.XAxisCrosshairOptions|Highcharts.YAxisCrosshairOptions} Highcharts.AxisCrosshairOptions
  55. */
  56. /**
  57. * @typedef {"navigator"|"pan"|"rangeSelectorButton"|"rangeSelectorInput"|"scrollbar"|"traverseUpButton"|"zoom"} Highcharts.AxisExtremesTriggerValue
  58. */
  59. /**
  60. * @callback Highcharts.AxisEventCallbackFunction
  61. *
  62. * @param {Highcharts.Axis} this
  63. */
  64. /**
  65. * @interface Highcharts.AxisLabelsFormatterContextObject
  66. */ /**
  67. * @name Highcharts.AxisLabelsFormatterContextObject#axis
  68. * @type {Highcharts.Axis}
  69. */ /**
  70. * @name Highcharts.AxisLabelsFormatterContextObject#chart
  71. * @type {Highcharts.Chart}
  72. */ /**
  73. * @name Highcharts.AxisLabelsFormatterContextObject#isFirst
  74. * @type {boolean}
  75. */ /**
  76. * @name Highcharts.AxisLabelsFormatterContextObject#isLast
  77. * @type {boolean}
  78. */ /**
  79. * @name Highcharts.AxisLabelsFormatterContextObject#pos
  80. * @type {number}
  81. */ /**
  82. * @name Highcharts.AxisLabelsFormatterContextObject#value
  83. * @type {number}
  84. */
  85. /**
  86. * Options for axes.
  87. *
  88. * @typedef {Highcharts.XAxisOptions|Highcharts.YAxisOptions|Highcharts.ZAxisOptions} Highcharts.AxisOptions
  89. */
  90. /**
  91. * @callback Highcharts.AxisPointBreakEventCallbackFunction
  92. *
  93. * @param {Highcharts.Axis} this
  94. *
  95. * @param {Highcharts.AxisPointBreakEventObject} evt
  96. */
  97. /**
  98. * @interface Highcharts.AxisPointBreakEventObject
  99. */ /**
  100. * @name Highcharts.AxisPointBreakEventObject#brk
  101. * @type {Highcharts.Dictionary<number>}
  102. */ /**
  103. * @name Highcharts.AxisPointBreakEventObject#point
  104. * @type {Highcharts.Point}
  105. */ /**
  106. * @name Highcharts.AxisPointBreakEventObject#preventDefault
  107. * @type {Function}
  108. */ /**
  109. * @name Highcharts.AxisPointBreakEventObject#target
  110. * @type {Highcharts.SVGElement}
  111. */ /**
  112. * @name Highcharts.AxisPointBreakEventObject#type
  113. * @type {"pointBreak"|"pointInBreak"}
  114. */
  115. /**
  116. * @callback Highcharts.AxisSetExtremesEventCallbackFunction
  117. *
  118. * @param {Highcharts.Axis} this
  119. *
  120. * @param {Highcharts.AxisSetExtremesEventObject} evt
  121. */
  122. /**
  123. * @interface Highcharts.AxisSetExtremesEventObject
  124. * @extends Highcharts.ExtremesObject
  125. */ /**
  126. * @name Highcharts.AxisSetExtremesEventObject#preventDefault
  127. * @type {Function}
  128. */ /**
  129. * @name Highcharts.AxisSetExtremesEventObject#target
  130. * @type {Highcharts.SVGElement}
  131. */ /**
  132. * @name Highcharts.AxisSetExtremesEventObject#trigger
  133. * @type {Highcharts.AxisExtremesTriggerValue|string}
  134. */ /**
  135. * @name Highcharts.AxisSetExtremesEventObject#type
  136. * @type {"setExtremes"}
  137. */
  138. /**
  139. * @callback Highcharts.AxisTickPositionerCallbackFunction
  140. *
  141. * @param {Highcharts.Axis} this
  142. *
  143. * @return {Array<number>}
  144. */
  145. /**
  146. * @interface Highcharts.AxisTickPositionsArray
  147. * @augments Array<number>
  148. */
  149. /**
  150. * @typedef {"high"|"low"|"middle"} Highcharts.AxisTitleAlignValue
  151. */
  152. /**
  153. * @typedef {Highcharts.XAxisTitleOptions|Highcharts.YAxisTitleOptions|Highcharts.ZAxisTitleOptions} Highcharts.AxisTitleOptions
  154. */
  155. /**
  156. * @typedef {"linear"|"logarithmic"|"datetime"|"category"|"treegrid"} Highcharts.AxisTypeValue
  157. */
  158. /**
  159. * The returned object literal from the {@link Highcharts.Axis#getExtremes}
  160. * function.
  161. *
  162. * @interface Highcharts.ExtremesObject
  163. */ /**
  164. * The maximum value of the axis' associated series.
  165. * @name Highcharts.ExtremesObject#dataMax
  166. * @type {number}
  167. */ /**
  168. * The minimum value of the axis' associated series.
  169. * @name Highcharts.ExtremesObject#dataMin
  170. * @type {number}
  171. */ /**
  172. * The maximum axis value, either automatic or set manually. If the `max` option
  173. * is not set, `maxPadding` is 0 and `endOnTick` is false, this value will be
  174. * the same as `dataMax`.
  175. * @name Highcharts.ExtremesObject#max
  176. * @type {number}
  177. */ /**
  178. * The minimum axis value, either automatic or set manually. If the `min` option
  179. * is not set, `minPadding` is 0 and `startOnTick` is false, this value will be
  180. * the same as `dataMin`.
  181. * @name Highcharts.ExtremesObject#min
  182. * @type {number}
  183. */ /**
  184. * The user defined maximum, either from the `max` option or from a zoom or
  185. * `setExtremes` action.
  186. * @name Highcharts.ExtremesObject#userMax
  187. * @type {number}
  188. */ /**
  189. * The user defined minimum, either from the `min` option or from a zoom or
  190. * `setExtremes` action.
  191. * @name Highcharts.ExtremesObject#userMin
  192. * @type {number}
  193. */
  194. /**
  195. * Formatter function for the text of a crosshair label.
  196. *
  197. * @callback Highcharts.XAxisCrosshairLabelFormatterCallbackFunction
  198. *
  199. * @param {Highcharts.Axis} this
  200. * Axis context
  201. *
  202. * @param {number} value
  203. * Y value of the data point
  204. *
  205. * @return {string}
  206. */
  207. import U from './Utilities.js';
  208. var animObject = U.animObject, arrayMax = U.arrayMax, arrayMin = U.arrayMin, clamp = U.clamp, correctFloat = U.correctFloat, defined = U.defined, destroyObjectProperties = U.destroyObjectProperties, extend = U.extend, isArray = U.isArray, isNumber = U.isNumber, isString = U.isString, objectEach = U.objectEach, pick = U.pick, relativeLength = U.relativeLength, splat = U.splat, syncTimeout = U.syncTimeout;
  209. import './Color.js';
  210. import './Options.js';
  211. import './Tick.js';
  212. var addEvent = H.addEvent, color = H.color, defaultOptions = H.defaultOptions, deg2rad = H.deg2rad, fireEvent = H.fireEvent, format = H.format, getMagnitude = H.getMagnitude, merge = H.merge, normalizeTickInterval = H.normalizeTickInterval, removeEvent = H.removeEvent, seriesTypes = H.seriesTypes, Tick = H.Tick;
  213. /* eslint-disable no-invalid-this, valid-jsdoc */
  214. /**
  215. * Create a new axis object. Called internally when instanciating a new chart or
  216. * adding axes by {@link Highcharts.Chart#addAxis}.
  217. *
  218. * A chart can have from 0 axes (pie chart) to multiples. In a normal, single
  219. * series cartesian chart, there is one X axis and one Y axis.
  220. *
  221. * The X axis or axes are referenced by {@link Highcharts.Chart.xAxis}, which is
  222. * an array of Axis objects. If there is only one axis, it can be referenced
  223. * through `chart.xAxis[0]`, and multiple axes have increasing indices. The same
  224. * pattern goes for Y axes.
  225. *
  226. * If you need to get the axes from a series object, use the `series.xAxis` and
  227. * `series.yAxis` properties. These are not arrays, as one series can only be
  228. * associated to one X and one Y axis.
  229. *
  230. * A third way to reference the axis programmatically is by `id`. Add an `id` in
  231. * the axis configuration options, and get the axis by
  232. * {@link Highcharts.Chart#get}.
  233. *
  234. * Configuration options for the axes are given in options.xAxis and
  235. * options.yAxis.
  236. *
  237. * @class
  238. * @name Highcharts.Axis
  239. *
  240. * @param {Highcharts.Chart} chart
  241. * The Chart instance to apply the axis on.
  242. *
  243. * @param {Highcharts.AxisOptions} options
  244. * Axis options.
  245. */
  246. var Axis = function () {
  247. this.init.apply(this, arguments);
  248. /* eslint-enable no-invalid-this, valid-jsdoc */
  249. };
  250. extend(Axis.prototype, /** @lends Highcharts.Axis.prototype */ {
  251. /**
  252. * The X axis or category axis. Normally this is the horizontal axis,
  253. * though if the chart is inverted this is the vertical axis. In case of
  254. * multiple axes, the xAxis node is an array of configuration objects.
  255. *
  256. * See the [Axis class](/class-reference/Highcharts.Axis) for programmatic
  257. * access to the axis.
  258. *
  259. * @productdesc {highmaps}
  260. * In Highmaps, the axis is hidden, but it is used behind the scenes to
  261. * control features like zooming and panning. Zooming is in effect the same
  262. * as setting the extremes of one of the exes.
  263. *
  264. * @type {*|Array<*>}
  265. * @optionparent xAxis
  266. *
  267. * @private
  268. */
  269. defaultOptions: {
  270. /**
  271. * When using multiple axis, the ticks of two or more opposite axes
  272. * will automatically be aligned by adding ticks to the axis or axes
  273. * with the least ticks, as if `tickAmount` were specified.
  274. *
  275. * This can be prevented by setting `alignTicks` to false. If the grid
  276. * lines look messy, it's a good idea to hide them for the secondary
  277. * axis by setting `gridLineWidth` to 0.
  278. *
  279. * If `startOnTick` or `endOnTick` in an Axis options are set to false,
  280. * then the `alignTicks ` will be disabled for the Axis.
  281. *
  282. * Disabled for logarithmic axes.
  283. *
  284. * @type {boolean}
  285. * @default true
  286. * @product highcharts highstock gantt
  287. * @apioption xAxis.alignTicks
  288. */
  289. /**
  290. * Whether to allow decimals in this axis' ticks. When counting
  291. * integers, like persons or hits on a web page, decimals should
  292. * be avoided in the labels.
  293. *
  294. * @see [minTickInterval](#xAxis.minTickInterval)
  295. *
  296. * @sample {highcharts|highstock} highcharts/yaxis/allowdecimals-true/
  297. * True by default
  298. * @sample {highcharts|highstock} highcharts/yaxis/allowdecimals-false/
  299. * False
  300. *
  301. * @type {boolean}
  302. * @default true
  303. * @since 2.0
  304. * @apioption xAxis.allowDecimals
  305. */
  306. /**
  307. * When using an alternate grid color, a band is painted across the
  308. * plot area between every other grid line.
  309. *
  310. * @sample {highcharts} highcharts/yaxis/alternategridcolor/
  311. * Alternate grid color on the Y axis
  312. * @sample {highstock} stock/xaxis/alternategridcolor/
  313. * Alternate grid color on the Y axis
  314. *
  315. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  316. * @apioption xAxis.alternateGridColor
  317. */
  318. /**
  319. * An array defining breaks in the axis, the sections defined will be
  320. * left out and all the points shifted closer to each other.
  321. *
  322. * @productdesc {highcharts}
  323. * Requires that the broken-axis.js module is loaded.
  324. *
  325. * @sample {highcharts} highcharts/axisbreak/break-simple/
  326. * Simple break
  327. * @sample {highcharts|highstock} highcharts/axisbreak/break-visualized/
  328. * Advanced with callback
  329. * @sample {highstock} stock/demo/intraday-breaks/
  330. * Break on nights and weekends
  331. *
  332. * @type {Array<*>}
  333. * @since 4.1.0
  334. * @product highcharts highstock gantt
  335. * @apioption xAxis.breaks
  336. */
  337. /**
  338. * A number indicating how much space should be left between the start
  339. * and the end of the break. The break size is given in axis units,
  340. * so for instance on a `datetime` axis, a break size of 3600000 would
  341. * indicate the equivalent of an hour.
  342. *
  343. * @type {number}
  344. * @default 0
  345. * @since 4.1.0
  346. * @product highcharts highstock gantt
  347. * @apioption xAxis.breaks.breakSize
  348. */
  349. /**
  350. * The point where the break starts.
  351. *
  352. * @type {number}
  353. * @since 4.1.0
  354. * @product highcharts highstock gantt
  355. * @apioption xAxis.breaks.from
  356. */
  357. /**
  358. * Defines an interval after which the break appears again. By default
  359. * the breaks do not repeat.
  360. *
  361. * @type {number}
  362. * @default 0
  363. * @since 4.1.0
  364. * @product highcharts highstock gantt
  365. * @apioption xAxis.breaks.repeat
  366. */
  367. /**
  368. * The point where the break ends.
  369. *
  370. * @type {number}
  371. * @since 4.1.0
  372. * @product highcharts highstock gantt
  373. * @apioption xAxis.breaks.to
  374. */
  375. /**
  376. * If categories are present for the xAxis, names are used instead of
  377. * numbers for that axis.
  378. *
  379. * Since Highcharts 3.0, categories can also
  380. * be extracted by giving each point a [name](#series.data) and setting
  381. * axis [type](#xAxis.type) to `category`. However, if you have multiple
  382. * series, best practice remains defining the `categories` array.
  383. *
  384. * Example: `categories: ['Apples', 'Bananas', 'Oranges']`
  385. *
  386. * @sample {highcharts} highcharts/demo/line-labels/
  387. * With
  388. * @sample {highcharts} highcharts/xaxis/categories/
  389. * Without
  390. *
  391. * @type {Array<string>}
  392. * @product highcharts gantt
  393. * @apioption xAxis.categories
  394. */
  395. /**
  396. * The highest allowed value for automatically computed axis extremes.
  397. *
  398. * @see [floor](#xAxis.floor)
  399. *
  400. * @sample {highcharts|highstock} highcharts/yaxis/floor-ceiling/
  401. * Floor and ceiling
  402. *
  403. * @type {number}
  404. * @since 4.0
  405. * @product highcharts highstock gantt
  406. * @apioption xAxis.ceiling
  407. */
  408. /**
  409. * A class name that opens for styling the axis by CSS, especially in
  410. * Highcharts styled mode. The class name is applied to group elements
  411. * for the grid, axis elements and labels.
  412. *
  413. * @sample {highcharts|highstock|highmaps} highcharts/css/axis/
  414. * Multiple axes with separate styling
  415. *
  416. * @type {string}
  417. * @since 5.0.0
  418. * @apioption xAxis.className
  419. */
  420. /**
  421. * Configure a crosshair that follows either the mouse pointer or the
  422. * hovered point.
  423. *
  424. * In styled mode, the crosshairs are styled in the
  425. * `.highcharts-crosshair`, `.highcharts-crosshair-thin` or
  426. * `.highcharts-xaxis-category` classes.
  427. *
  428. * @productdesc {highstock}
  429. * In Highstock, by default, the crosshair is enabled on the X axis and
  430. * disabled on the Y axis.
  431. *
  432. * @sample {highcharts} highcharts/xaxis/crosshair-both/
  433. * Crosshair on both axes
  434. * @sample {highstock} stock/xaxis/crosshairs-xy/
  435. * Crosshair on both axes
  436. * @sample {highmaps} highcharts/xaxis/crosshair-both/
  437. * Crosshair on both axes
  438. *
  439. * @declare Highcharts.AxisCrosshairOptions
  440. * @type {boolean|*}
  441. * @default false
  442. * @since 4.1
  443. * @apioption xAxis.crosshair
  444. */
  445. /**
  446. * A class name for the crosshair, especially as a hook for styling.
  447. *
  448. * @type {string}
  449. * @since 5.0.0
  450. * @apioption xAxis.crosshair.className
  451. */
  452. /**
  453. * The color of the crosshair. Defaults to `#cccccc` for numeric and
  454. * datetime axes, and `rgba(204,214,235,0.25)` for category axes, where
  455. * the crosshair by default highlights the whole category.
  456. *
  457. * @sample {highcharts|highstock|highmaps} highcharts/xaxis/crosshair-customized/
  458. * Customized crosshairs
  459. *
  460. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  461. * @default #cccccc
  462. * @since 4.1
  463. * @apioption xAxis.crosshair.color
  464. */
  465. /**
  466. * The dash style for the crosshair. See
  467. * [plotOptions.series.dashStyle](#plotOptions.series.dashStyle)
  468. * for possible values.
  469. *
  470. * @sample {highcharts|highmaps} highcharts/xaxis/crosshair-dotted/
  471. * Dotted crosshair
  472. * @sample {highstock} stock/xaxis/crosshair-dashed/
  473. * Dashed X axis crosshair
  474. *
  475. * @type {Highcharts.DashStyleValue}
  476. * @default Solid
  477. * @since 4.1
  478. * @apioption xAxis.crosshair.dashStyle
  479. */
  480. /**
  481. * A label on the axis next to the crosshair.
  482. *
  483. * In styled mode, the label is styled with the
  484. * `.highcharts-crosshair-label` class.
  485. *
  486. * @sample {highstock} stock/xaxis/crosshair-label/
  487. * Crosshair labels
  488. * @sample {highstock} highcharts/css/crosshair-label/
  489. * Style mode
  490. *
  491. * @declare Highcharts.AxisCrosshairLabelOptions
  492. * @since 2.1
  493. * @product highstock
  494. * @apioption xAxis.crosshair.label
  495. */
  496. /**
  497. * Alignment of the label compared to the axis. Defaults to `"left"` for
  498. * right-side axes, `"right"` for left-side axes and `"center"` for
  499. * horizontal axes.
  500. *
  501. * @type {Highcharts.AlignValue}
  502. * @since 2.1
  503. * @product highstock
  504. * @apioption xAxis.crosshair.label.align
  505. */
  506. /**
  507. * The background color for the label. Defaults to the related series
  508. * color, or `#666666` if that is not available.
  509. *
  510. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  511. * @since 2.1
  512. * @product highstock
  513. * @apioption xAxis.crosshair.label.backgroundColor
  514. */
  515. /**
  516. * The border color for the crosshair label
  517. *
  518. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  519. * @since 2.1
  520. * @product highstock
  521. * @apioption xAxis.crosshair.label.borderColor
  522. */
  523. /**
  524. * The border corner radius of the crosshair label.
  525. *
  526. * @type {number}
  527. * @default 3
  528. * @since 2.1.10
  529. * @product highstock
  530. * @apioption xAxis.crosshair.label.borderRadius
  531. */
  532. /**
  533. * The border width for the crosshair label.
  534. *
  535. * @type {number}
  536. * @default 0
  537. * @since 2.1
  538. * @product highstock
  539. * @apioption xAxis.crosshair.label.borderWidth
  540. */
  541. /**
  542. * Flag to enable crosshair's label.
  543. *
  544. * @sample {highstock} stock/xaxis/crosshairs-xy/
  545. * Enabled label for yAxis' crosshair
  546. *
  547. * @type {boolean}
  548. * @default false
  549. * @since 2.1
  550. * @product highstock
  551. * @apioption xAxis.crosshair.label.enabled
  552. */
  553. /**
  554. * A format string for the crosshair label. Defaults to `{value}` for
  555. * numeric axes and `{value:%b %d, %Y}` for datetime axes.
  556. *
  557. * @type {string}
  558. * @since 2.1
  559. * @product highstock
  560. * @apioption xAxis.crosshair.label.format
  561. */
  562. /**
  563. * Formatter function for the label text.
  564. *
  565. * @type {Highcharts.XAxisCrosshairLabelFormatterCallbackFunction}
  566. * @since 2.1
  567. * @product highstock
  568. * @apioption xAxis.crosshair.label.formatter
  569. */
  570. /**
  571. * Padding inside the crosshair label.
  572. *
  573. * @type {number}
  574. * @default 8
  575. * @since 2.1
  576. * @product highstock
  577. * @apioption xAxis.crosshair.label.padding
  578. */
  579. /**
  580. * The shape to use for the label box.
  581. *
  582. * @type {string}
  583. * @default callout
  584. * @since 2.1
  585. * @product highstock
  586. * @apioption xAxis.crosshair.label.shape
  587. */
  588. /**
  589. * Text styles for the crosshair label.
  590. *
  591. * @type {Highcharts.CSSObject}
  592. * @default {"color": "white", "fontWeight": "normal", "fontSize": "11px", "textAlign": "center"}
  593. * @since 2.1
  594. * @product highstock
  595. * @apioption xAxis.crosshair.label.style
  596. */
  597. /**
  598. * Whether the crosshair should snap to the point or follow the pointer
  599. * independent of points.
  600. *
  601. * @sample {highcharts|highstock} highcharts/xaxis/crosshair-snap-false/
  602. * True by default
  603. * @sample {highmaps} maps/demo/latlon-advanced/
  604. * Snap is false
  605. *
  606. * @type {boolean}
  607. * @default true
  608. * @since 4.1
  609. * @apioption xAxis.crosshair.snap
  610. */
  611. /**
  612. * The pixel width of the crosshair. Defaults to 1 for numeric or
  613. * datetime axes, and for one category width for category axes.
  614. *
  615. * @sample {highcharts} highcharts/xaxis/crosshair-customized/
  616. * Customized crosshairs
  617. * @sample {highstock} highcharts/xaxis/crosshair-customized/
  618. * Customized crosshairs
  619. * @sample {highmaps} highcharts/xaxis/crosshair-customized/
  620. * Customized crosshairs
  621. *
  622. * @type {number}
  623. * @default 1
  624. * @since 4.1
  625. * @apioption xAxis.crosshair.width
  626. */
  627. /**
  628. * The Z index of the crosshair. Higher Z indices allow drawing the
  629. * crosshair on top of the series or behind the grid lines.
  630. *
  631. * @type {number}
  632. * @default 2
  633. * @since 4.1
  634. * @apioption xAxis.crosshair.zIndex
  635. */
  636. /**
  637. * Whether to zoom axis. If `chart.zoomType` is set, the option allows
  638. * to disable zooming on an individual axis.
  639. *
  640. * @sample {highcharts} highcharts/xaxis/zoomenabled/
  641. * Zoom enabled is false
  642. *
  643. *
  644. * @type {boolean}
  645. * @default enabled
  646. * @apioption xAxis.zoomEnabled
  647. */
  648. /**
  649. * For a datetime axis, the scale will automatically adjust to the
  650. * appropriate unit. This member gives the default string
  651. * representations used for each unit. For intermediate values,
  652. * different units may be used, for example the `day` unit can be used
  653. * on midnight and `hour` unit be used for intermediate values on the
  654. * same axis. For an overview of the replacement codes, see
  655. * [dateFormat](/class-reference/Highcharts#dateFormat).
  656. *
  657. * Defaults to:
  658. * ```js
  659. * {
  660. * millisecond: '%H:%M:%S.%L',
  661. * second: '%H:%M:%S',
  662. * minute: '%H:%M',
  663. * hour: '%H:%M',
  664. * day: '%e. %b',
  665. * week: '%e. %b',
  666. * month: '%b \'%y',
  667. * year: '%Y'
  668. * }
  669. * ```
  670. *
  671. * @sample {highcharts} highcharts/xaxis/datetimelabelformats/
  672. * Different day format on X axis
  673. * @sample {highstock} stock/xaxis/datetimelabelformats/
  674. * More information in x axis labels
  675. *
  676. * @declare Highcharts.AxisDateTimeLabelFormatsOptions
  677. * @product highcharts highstock gantt
  678. */
  679. dateTimeLabelFormats: {
  680. /**
  681. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  682. * @type {string|*}
  683. */
  684. millisecond: {
  685. main: '%H:%M:%S.%L',
  686. range: false
  687. },
  688. /**
  689. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  690. * @type {string|*}
  691. */
  692. second: {
  693. main: '%H:%M:%S',
  694. range: false
  695. },
  696. /**
  697. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  698. * @type {string|*}
  699. */
  700. minute: {
  701. main: '%H:%M',
  702. range: false
  703. },
  704. /**
  705. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  706. * @type {string|*}
  707. */
  708. hour: {
  709. main: '%H:%M',
  710. range: false
  711. },
  712. /**
  713. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  714. * @type {string|*}
  715. */
  716. day: {
  717. main: '%e. %b'
  718. },
  719. /**
  720. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  721. * @type {string|*}
  722. */
  723. week: {
  724. main: '%e. %b'
  725. },
  726. /**
  727. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  728. * @type {string|*}
  729. */
  730. month: {
  731. main: '%b \'%y'
  732. },
  733. /**
  734. * @declare Highcharts.AxisDateTimeLabelFormatsOptionsObject
  735. * @type {string|*}
  736. */
  737. year: {
  738. main: '%Y'
  739. }
  740. },
  741. /**
  742. * Whether to force the axis to end on a tick. Use this option with
  743. * the `maxPadding` option to control the axis end.
  744. *
  745. * @productdesc {highstock}
  746. * In Highstock, `endOnTick` is always false when the navigator or
  747. * vertical panning is enabled, to prevent jumpy scrolling.
  748. *
  749. * @sample {highcharts} highcharts/chart/reflow-true/
  750. * True by default
  751. * @sample {highcharts} highcharts/yaxis/endontick/
  752. * False
  753. * @sample {highstock} stock/demo/basic-line/
  754. * True by default
  755. * @sample {highstock} stock/xaxis/endontick/
  756. * False
  757. *
  758. * @since 1.2.0
  759. */
  760. endOnTick: false,
  761. /**
  762. * Event handlers for the axis.
  763. *
  764. * @type {*}
  765. * @apioption xAxis.events
  766. */
  767. /**
  768. * An event fired after the breaks have rendered.
  769. *
  770. * @see [breaks](#xAxis.breaks)
  771. *
  772. * @sample {highcharts} highcharts/axisbreak/break-event/
  773. * AfterBreak Event
  774. *
  775. * @type {Highcharts.AxisEventCallbackFunction}
  776. * @since 4.1.0
  777. * @product highcharts gantt
  778. * @apioption xAxis.events.afterBreaks
  779. */
  780. /**
  781. * As opposed to the `setExtremes` event, this event fires after the
  782. * final min and max values are computed and corrected for `minRange`.
  783. *
  784. * Fires when the minimum and maximum is set for the axis, either by
  785. * calling the `.setExtremes()` method or by selecting an area in the
  786. * chart. One parameter, `event`, is passed to the function, containing
  787. * common event information.
  788. *
  789. * The new user set minimum and maximum values can be found by
  790. * `event.min` and `event.max`. These reflect the axis minimum and
  791. * maximum in axis values. The actual data extremes are found in
  792. * `event.dataMin` and `event.dataMax`.
  793. *
  794. * @type {Highcharts.AxisSetExtremesEventCallbackFunction}
  795. * @since 2.3
  796. * @context Highcharts.Axis
  797. * @apioption xAxis.events.afterSetExtremes
  798. */
  799. /**
  800. * An event fired when a break from this axis occurs on a point.
  801. *
  802. * @see [breaks](#xAxis.breaks)
  803. *
  804. * @sample {highcharts} highcharts/axisbreak/break-visualized/
  805. * Visualization of a Break
  806. *
  807. * @type {Highcharts.AxisPointBreakEventCallbackFunction}
  808. * @since 4.1.0
  809. * @product highcharts gantt
  810. * @context Highcharts.Axis
  811. * @apioption xAxis.events.pointBreak
  812. */
  813. /**
  814. * An event fired when a point falls inside a break from this axis.
  815. *
  816. * @type {Highcharts.AxisPointBreakEventCallbackFunction}
  817. * @product highcharts highstock gantt
  818. * @context Highcharts.Axis
  819. * @apioption xAxis.events.pointInBreak
  820. */
  821. /**
  822. * Fires when the minimum and maximum is set for the axis, either by
  823. * calling the `.setExtremes()` method or by selecting an area in the
  824. * chart. One parameter, `event`, is passed to the function,
  825. * containing common event information.
  826. *
  827. * The new user set minimum and maximum values can be found by
  828. * `event.min` and `event.max`. These reflect the axis minimum and
  829. * maximum in data values. When an axis is zoomed all the way out from
  830. * the "Reset zoom" button, `event.min` and `event.max` are null, and
  831. * the new extremes are set based on `this.dataMin` and `this.dataMax`.
  832. *
  833. * @sample {highstock} stock/xaxis/events-setextremes/
  834. * Log new extremes on x axis
  835. *
  836. * @type {Highcharts.AxisSetExtremesEventCallbackFunction}
  837. * @since 1.2.0
  838. * @context Highcharts.Axis
  839. * @apioption xAxis.events.setExtremes
  840. */
  841. /**
  842. * The lowest allowed value for automatically computed axis extremes.
  843. *
  844. * @see [ceiling](#yAxis.ceiling)
  845. *
  846. * @sample {highcharts} highcharts/yaxis/floor-ceiling/
  847. * Floor and ceiling
  848. * @sample {highstock} stock/demo/lazy-loading/
  849. * Prevent negative stock price on Y axis
  850. *
  851. * @type {number}
  852. * @since 4.0
  853. * @product highcharts highstock gantt
  854. * @apioption xAxis.floor
  855. */
  856. /**
  857. * The dash or dot style of the grid lines. For possible values, see
  858. * [this demonstration](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-dashstyle-all/).
  859. *
  860. * @sample {highcharts} highcharts/yaxis/gridlinedashstyle/
  861. * Long dashes
  862. * @sample {highstock} stock/xaxis/gridlinedashstyle/
  863. * Long dashes
  864. *
  865. * @type {Highcharts.DashStyleValue}
  866. * @default Solid
  867. * @since 1.2
  868. * @apioption xAxis.gridLineDashStyle
  869. */
  870. /**
  871. * The Z index of the grid lines.
  872. *
  873. * @sample {highcharts|highstock} highcharts/xaxis/gridzindex/
  874. * A Z index of 4 renders the grid above the graph
  875. *
  876. * @type {number}
  877. * @default 1
  878. * @product highcharts highstock gantt
  879. * @apioption xAxis.gridZIndex
  880. */
  881. /**
  882. * An id for the axis. This can be used after render time to get
  883. * a pointer to the axis object through `chart.get()`.
  884. *
  885. * @sample {highcharts} highcharts/xaxis/id/
  886. * Get the object
  887. * @sample {highstock} stock/xaxis/id/
  888. * Get the object
  889. *
  890. * @type {string}
  891. * @since 1.2.0
  892. * @apioption xAxis.id
  893. */
  894. /**
  895. * The axis labels show the number or category for each tick.
  896. *
  897. * Since v8.0.0: Labels are animated in categorized x-axis with
  898. * updating data if `tickInterval` and `step` is set to 1.
  899. *
  900. * @productdesc {highmaps}
  901. * X and Y axis labels are by default disabled in Highmaps, but the
  902. * functionality is inherited from Highcharts and used on `colorAxis`,
  903. * and can be enabled on X and Y axes too.
  904. */
  905. labels: {
  906. /**
  907. * What part of the string the given position is anchored to.
  908. * If `left`, the left side of the string is at the axis position.
  909. * Can be one of `"left"`, `"center"` or `"right"`. Defaults to
  910. * an intelligent guess based on which side of the chart the axis
  911. * is on and the rotation of the label.
  912. *
  913. * @see [reserveSpace](#xAxis.labels.reserveSpace)
  914. *
  915. * @sample {highcharts} highcharts/xaxis/labels-align-left/
  916. * Left
  917. * @sample {highcharts} highcharts/xaxis/labels-align-right/
  918. * Right
  919. * @sample {highcharts} highcharts/xaxis/labels-reservespace-true/
  920. * Left-aligned labels on a vertical category axis
  921. *
  922. * @type {Highcharts.AlignValue}
  923. * @apioption xAxis.labels.align
  924. */
  925. /**
  926. * For horizontal axes, the allowed degrees of label rotation
  927. * to prevent overlapping labels. If there is enough space,
  928. * labels are not rotated. As the chart gets narrower, it
  929. * will start rotating the labels -45 degrees, then remove
  930. * every second label and try again with rotations 0 and -45 etc.
  931. * Set it to `false` to disable rotation, which will
  932. * cause the labels to word-wrap if possible.
  933. *
  934. * @sample {highcharts|highstock} highcharts/xaxis/labels-autorotation-default/
  935. * Default auto rotation of 0 or -45
  936. * @sample {highcharts|highstock} highcharts/xaxis/labels-autorotation-0-90/
  937. * Custom graded auto rotation
  938. *
  939. * @type {Array<number>|false}
  940. * @default [-45]
  941. * @since 4.1.0
  942. * @product highcharts highstock gantt
  943. * @apioption xAxis.labels.autoRotation
  944. */
  945. /**
  946. * When each category width is more than this many pixels, we don't
  947. * apply auto rotation. Instead, we lay out the axis label with word
  948. * wrap. A lower limit makes sense when the label contains multiple
  949. * short words that don't extend the available horizontal space for
  950. * each label.
  951. *
  952. * @sample {highcharts} highcharts/xaxis/labels-autorotationlimit/
  953. * Lower limit
  954. *
  955. * @type {number}
  956. * @default 80
  957. * @since 4.1.5
  958. * @product highcharts gantt
  959. * @apioption xAxis.labels.autoRotationLimit
  960. */
  961. /**
  962. * Polar charts only. The label's pixel distance from the perimeter
  963. * of the plot area.
  964. *
  965. * @type {number}
  966. * @default 15
  967. * @product highcharts gantt
  968. * @apioption xAxis.labels.distance
  969. */
  970. /**
  971. * Enable or disable the axis labels.
  972. *
  973. * @sample {highcharts} highcharts/xaxis/labels-enabled/
  974. * X axis labels disabled
  975. * @sample {highstock} stock/xaxis/labels-enabled/
  976. * X axis labels disabled
  977. *
  978. * @default {highcharts|highstock|gantt} true
  979. * @default {highmaps} false
  980. */
  981. enabled: true,
  982. /**
  983. * A [format string](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting)
  984. * for the axis label.
  985. *
  986. * @sample {highcharts|highstock} highcharts/yaxis/labels-format/
  987. * Add units to Y axis label
  988. *
  989. * @type {string}
  990. * @default {value}
  991. * @since 3.0
  992. * @apioption xAxis.labels.format
  993. */
  994. /**
  995. * Callback JavaScript function to format the label. The value
  996. * is given by `this.value`. Additional properties for `this` are
  997. * `axis`, `chart`, `isFirst` and `isLast`. The value of the default
  998. * label formatter can be retrieved by calling
  999. * `this.axis.defaultLabelFormatter.call(this)` within the function.
  1000. *
  1001. * Defaults to:
  1002. * ```js
  1003. * function() {
  1004. * return this.value;
  1005. * }
  1006. * ```
  1007. *
  1008. * @sample {highcharts} highcharts/xaxis/labels-formatter-linked/
  1009. * Linked category names
  1010. * @sample {highcharts} highcharts/xaxis/labels-formatter-extended/
  1011. * Modified numeric labels
  1012. * @sample {highstock} stock/xaxis/labels-formatter/
  1013. * Added units on Y axis
  1014. *
  1015. * @type {Highcharts.FormatterCallbackFunction<Highcharts.AxisLabelsFormatterContextObject>}
  1016. * @apioption xAxis.labels.formatter
  1017. */
  1018. /**
  1019. * The number of pixels to indent the labels per level in a treegrid
  1020. * axis.
  1021. *
  1022. * @sample gantt/treegrid-axis/demo
  1023. * Indentation 10px by default.
  1024. * @sample gantt/treegrid-axis/indentation-0px
  1025. * Indentation set to 0px.
  1026. *
  1027. * @product gantt
  1028. */
  1029. indentation: 10,
  1030. /**
  1031. * Horizontal axis only. When `staggerLines` is not set,
  1032. * `maxStaggerLines` defines how many lines the axis is allowed to
  1033. * add to automatically avoid overlapping X labels. Set to `1` to
  1034. * disable overlap detection.
  1035. *
  1036. * @deprecated
  1037. * @type {number}
  1038. * @default 5
  1039. * @since 1.3.3
  1040. * @apioption xAxis.labels.maxStaggerLines
  1041. */
  1042. /**
  1043. * How to handle overflowing labels on horizontal axis. If set to
  1044. * `"allow"`, it will not be aligned at all. By default it
  1045. * `"justify"` labels inside the chart area. If there is room to
  1046. * move it, it will be aligned to the edge, else it will be removed.
  1047. *
  1048. * @type {string}
  1049. * @default justify
  1050. * @since 2.2.5
  1051. * @validvalue ["allow", "justify"]
  1052. * @apioption xAxis.labels.overflow
  1053. */
  1054. /**
  1055. * The pixel padding for axis labels, to ensure white space between
  1056. * them.
  1057. *
  1058. * @type {number}
  1059. * @default 5
  1060. * @product highcharts gantt
  1061. * @apioption xAxis.labels.padding
  1062. */
  1063. /**
  1064. * Whether to reserve space for the labels. By default, space is
  1065. * reserved for the labels in these cases:
  1066. *
  1067. * * On all horizontal axes.
  1068. * * On vertical axes if `label.align` is `right` on a left-side
  1069. * axis or `left` on a right-side axis.
  1070. * * On vertical axes if `label.align` is `center`.
  1071. *
  1072. * This can be turned off when for example the labels are rendered
  1073. * inside the plot area instead of outside.
  1074. *
  1075. * @see [labels.align](#xAxis.labels.align)
  1076. *
  1077. * @sample {highcharts} highcharts/xaxis/labels-reservespace/
  1078. * No reserved space, labels inside plot
  1079. * @sample {highcharts} highcharts/xaxis/labels-reservespace-true/
  1080. * Left-aligned labels on a vertical category axis
  1081. *
  1082. * @type {boolean}
  1083. * @since 4.1.10
  1084. * @product highcharts gantt
  1085. * @apioption xAxis.labels.reserveSpace
  1086. */
  1087. /**
  1088. * Rotation of the labels in degrees.
  1089. *
  1090. * @sample {highcharts} highcharts/xaxis/labels-rotation/
  1091. * X axis labels rotated 90°
  1092. *
  1093. * @type {number}
  1094. * @default 0
  1095. * @apioption xAxis.labels.rotation
  1096. */
  1097. /**
  1098. * Horizontal axes only. The number of lines to spread the labels
  1099. * over to make room or tighter labels.
  1100. *
  1101. * @sample {highcharts} highcharts/xaxis/labels-staggerlines/
  1102. * Show labels over two lines
  1103. * @sample {highstock} stock/xaxis/labels-staggerlines/
  1104. * Show labels over two lines
  1105. *
  1106. * @type {number}
  1107. * @since 2.1
  1108. * @apioption xAxis.labels.staggerLines
  1109. */
  1110. /**
  1111. * To show only every _n_'th label on the axis, set the step to _n_.
  1112. * Setting the step to 2 shows every other label.
  1113. *
  1114. * By default, the step is calculated automatically to avoid
  1115. * overlap. To prevent this, set it to 1\. This usually only
  1116. * happens on a category axis, and is often a sign that you have
  1117. * chosen the wrong axis type.
  1118. *
  1119. * Read more at
  1120. * [Axis docs](https://www.highcharts.com/docs/chart-concepts/axes)
  1121. * => What axis should I use?
  1122. *
  1123. * @sample {highcharts} highcharts/xaxis/labels-step/
  1124. * Showing only every other axis label on a categorized
  1125. * x-axis
  1126. * @sample {highcharts} highcharts/xaxis/labels-step-auto/
  1127. * Auto steps on a category axis
  1128. *
  1129. * @type {number}
  1130. * @since 2.1
  1131. * @apioption xAxis.labels.step
  1132. */
  1133. /**
  1134. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  1135. * to render the labels.
  1136. *
  1137. * @type {boolean}
  1138. * @default false
  1139. * @apioption xAxis.labels.useHTML
  1140. */
  1141. /**
  1142. * The x position offset of the label relative to the tick position
  1143. * on the axis.
  1144. *
  1145. * @sample {highcharts} highcharts/xaxis/labels-x/
  1146. * Y axis labels placed on grid lines
  1147. */
  1148. x: 0,
  1149. /**
  1150. * The y position offset of the label relative to the tick position
  1151. * on the axis. The default makes it adapt to the font size on
  1152. * bottom axis.
  1153. *
  1154. * @sample {highcharts} highcharts/xaxis/labels-x/
  1155. * Y axis labels placed on grid lines
  1156. *
  1157. * @type {number}
  1158. * @apioption xAxis.labels.y
  1159. */
  1160. /**
  1161. * The Z index for the axis labels.
  1162. *
  1163. * @type {number}
  1164. * @default 7
  1165. * @apioption xAxis.labels.zIndex
  1166. */
  1167. /**
  1168. * CSS styles for the label. Use `whiteSpace: 'nowrap'` to prevent
  1169. * wrapping of category labels. Use `textOverflow: 'none'` to
  1170. * prevent ellipsis (dots).
  1171. *
  1172. * In styled mode, the labels are styled with the
  1173. * `.highcharts-axis-labels` class.
  1174. *
  1175. * @sample {highcharts} highcharts/xaxis/labels-style/
  1176. * Red X axis labels
  1177. *
  1178. * @type {Highcharts.CSSObject}
  1179. */
  1180. style: {
  1181. /** @internal */
  1182. color: '#666666',
  1183. /** @internal */
  1184. cursor: 'default',
  1185. /** @internal */
  1186. fontSize: '11px'
  1187. }
  1188. },
  1189. /**
  1190. * The left position as the horizontal axis. If it's a number, it is
  1191. * interpreted as pixel position relative to the chart.
  1192. *
  1193. * Since Highcharts v5.0.13: If it's a percentage string, it is
  1194. * interpreted as percentages of the plot width, offset from plot area
  1195. * left.
  1196. *
  1197. * @type {number|string}
  1198. * @product highcharts highstock
  1199. * @apioption xAxis.left
  1200. */
  1201. /**
  1202. * The top position as the vertical axis. If it's a number, it is
  1203. * interpreted as pixel position relative to the chart.
  1204. *
  1205. * Since Highcharts 2: If it's a percentage string, it is interpreted
  1206. * as percentages of the plot height, offset from plot area top.
  1207. *
  1208. * @type {number|string}
  1209. * @product highcharts highstock
  1210. * @apioption xAxis.top
  1211. */
  1212. /**
  1213. * Index of another axis that this axis is linked to. When an axis is
  1214. * linked to a master axis, it will take the same extremes as
  1215. * the master, but as assigned by min or max or by setExtremes.
  1216. * It can be used to show additional info, or to ease reading the
  1217. * chart by duplicating the scales.
  1218. *
  1219. * @sample {highcharts} highcharts/xaxis/linkedto/
  1220. * Different string formats of the same date
  1221. * @sample {highcharts} highcharts/yaxis/linkedto/
  1222. * Y values on both sides
  1223. *
  1224. * @type {number}
  1225. * @since 2.0.2
  1226. * @product highcharts highstock gantt
  1227. * @apioption xAxis.linkedTo
  1228. */
  1229. /**
  1230. * The maximum value of the axis. If `null`, the max value is
  1231. * automatically calculated.
  1232. *
  1233. * If the [endOnTick](#yAxis.endOnTick) option is true, the `max` value
  1234. * might be rounded up.
  1235. *
  1236. * If a [tickAmount](#yAxis.tickAmount) is set, the axis may be extended
  1237. * beyond the set max in order to reach the given number of ticks. The
  1238. * same may happen in a chart with multiple axes, determined by [chart.
  1239. * alignTicks](#chart), where a `tickAmount` is applied internally.
  1240. *
  1241. * @sample {highcharts} highcharts/yaxis/max-200/
  1242. * Y axis max of 200
  1243. * @sample {highcharts} highcharts/yaxis/max-logarithmic/
  1244. * Y axis max on logarithmic axis
  1245. * @sample {highstock} stock/xaxis/min-max/
  1246. * Fixed min and max on X axis
  1247. * @sample {highmaps} maps/axis/min-max/
  1248. * Pre-zoomed to a specific area
  1249. *
  1250. * @type {number|null}
  1251. * @apioption xAxis.max
  1252. */
  1253. /**
  1254. * Padding of the max value relative to the length of the axis. A
  1255. * padding of 0.05 will make a 100px axis 5px longer. This is useful
  1256. * when you don't want the highest data value to appear on the edge
  1257. * of the plot area. When the axis' `max` option is set or a max extreme
  1258. * is set using `axis.setExtremes()`, the maxPadding will be ignored.
  1259. *
  1260. * @sample {highcharts} highcharts/yaxis/maxpadding/
  1261. * Max padding of 0.25 on y axis
  1262. * @sample {highstock} stock/xaxis/minpadding-maxpadding/
  1263. * Greater min- and maxPadding
  1264. * @sample {highmaps} maps/chart/plotbackgroundcolor-gradient/
  1265. * Add some padding
  1266. *
  1267. * @default {highcharts} 0.01
  1268. * @default {highstock|highmaps} 0
  1269. * @since 1.2.0
  1270. */
  1271. maxPadding: 0.01,
  1272. /**
  1273. * Deprecated. Use `minRange` instead.
  1274. *
  1275. * @deprecated
  1276. * @type {number}
  1277. * @product highcharts highstock
  1278. * @apioption xAxis.maxZoom
  1279. */
  1280. /**
  1281. * The minimum value of the axis. If `null` the min value is
  1282. * automatically calculated.
  1283. *
  1284. * If the [startOnTick](#yAxis.startOnTick) option is true (default),
  1285. * the `min` value might be rounded down.
  1286. *
  1287. * The automatically calculated minimum value is also affected by
  1288. * [floor](#yAxis.floor), [softMin](#yAxis.softMin),
  1289. * [minPadding](#yAxis.minPadding), [minRange](#yAxis.minRange)
  1290. * as well as [series.threshold](#plotOptions.series.threshold)
  1291. * and [series.softThreshold](#plotOptions.series.softThreshold).
  1292. *
  1293. * @sample {highcharts} highcharts/yaxis/min-startontick-false/
  1294. * -50 with startOnTick to false
  1295. * @sample {highcharts} highcharts/yaxis/min-startontick-true/
  1296. * -50 with startOnTick true by default
  1297. * @sample {highstock} stock/xaxis/min-max/
  1298. * Set min and max on X axis
  1299. * @sample {highmaps} maps/axis/min-max/
  1300. * Pre-zoomed to a specific area
  1301. *
  1302. * @type {number|null}
  1303. * @apioption xAxis.min
  1304. */
  1305. /**
  1306. * The dash or dot style of the minor grid lines. For possible values,
  1307. * see [this demonstration](https://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/plotoptions/series-dashstyle-all/).
  1308. *
  1309. * @sample {highcharts} highcharts/yaxis/minorgridlinedashstyle/
  1310. * Long dashes on minor grid lines
  1311. * @sample {highstock} stock/xaxis/minorgridlinedashstyle/
  1312. * Long dashes on minor grid lines
  1313. *
  1314. * @type {Highcharts.DashStyleValue}
  1315. * @default Solid
  1316. * @since 1.2
  1317. * @apioption xAxis.minorGridLineDashStyle
  1318. */
  1319. /**
  1320. * Specific tick interval in axis units for the minor ticks. On a linear
  1321. * axis, if `"auto"`, the minor tick interval is calculated as a fifth
  1322. * of the tickInterval. If `null` or `undefined`, minor ticks are not
  1323. * shown.
  1324. *
  1325. * On logarithmic axes, the unit is the power of the value. For example,
  1326. * setting the minorTickInterval to 1 puts one tick on each of 0.1, 1,
  1327. * 10, 100 etc. Setting the minorTickInterval to 0.1 produces 9 ticks
  1328. * between 1 and 10, 10 and 100 etc.
  1329. *
  1330. * If user settings dictate minor ticks to become too dense, they don't
  1331. * make sense, and will be ignored to prevent performance problems.
  1332. *
  1333. * @sample {highcharts} highcharts/yaxis/minortickinterval-null/
  1334. * Null by default
  1335. * @sample {highcharts} highcharts/yaxis/minortickinterval-5/
  1336. * 5 units
  1337. * @sample {highcharts} highcharts/yaxis/minortickinterval-log-auto/
  1338. * "auto"
  1339. * @sample {highcharts} highcharts/yaxis/minortickinterval-log/
  1340. * 0.1
  1341. * @sample {highstock} stock/demo/basic-line/
  1342. * Null by default
  1343. * @sample {highstock} stock/xaxis/minortickinterval-auto/
  1344. * "auto"
  1345. *
  1346. * @type {number|string|null}
  1347. * @apioption xAxis.minorTickInterval
  1348. */
  1349. /**
  1350. * The pixel length of the minor tick marks.
  1351. *
  1352. * @sample {highcharts} highcharts/yaxis/minorticklength/
  1353. * 10px on Y axis
  1354. * @sample {highstock} stock/xaxis/minorticks/
  1355. * 10px on Y axis
  1356. */
  1357. minorTickLength: 2,
  1358. /**
  1359. * The position of the minor tick marks relative to the axis line.
  1360. * Can be one of `inside` and `outside`.
  1361. *
  1362. * @sample {highcharts} highcharts/yaxis/minortickposition-outside/
  1363. * Outside by default
  1364. * @sample {highcharts} highcharts/yaxis/minortickposition-inside/
  1365. * Inside
  1366. * @sample {highstock} stock/xaxis/minorticks/
  1367. * Inside
  1368. *
  1369. * @validvalue ["inside", "outside"]
  1370. */
  1371. minorTickPosition: 'outside',
  1372. /**
  1373. * Enable or disable minor ticks. Unless
  1374. * [minorTickInterval](#xAxis.minorTickInterval) is set, the tick
  1375. * interval is calculated as a fifth of the `tickInterval`.
  1376. *
  1377. * On a logarithmic axis, minor ticks are laid out based on a best
  1378. * guess, attempting to enter approximately 5 minor ticks between
  1379. * each major tick.
  1380. *
  1381. * Prior to v6.0.0, ticks were unabled in auto layout by setting
  1382. * `minorTickInterval` to `"auto"`.
  1383. *
  1384. * @productdesc {highcharts}
  1385. * On axes using [categories](#xAxis.categories), minor ticks are not
  1386. * supported.
  1387. *
  1388. * @sample {highcharts} highcharts/yaxis/minorticks-true/
  1389. * Enabled on linear Y axis
  1390. *
  1391. * @type {boolean}
  1392. * @default false
  1393. * @since 6.0.0
  1394. * @apioption xAxis.minorTicks
  1395. */
  1396. /**
  1397. * The pixel width of the minor tick mark.
  1398. *
  1399. * @sample {highcharts} highcharts/yaxis/minortickwidth/
  1400. * 3px width
  1401. * @sample {highstock} stock/xaxis/minorticks/
  1402. * 1px width
  1403. *
  1404. * @type {number}
  1405. * @default 0
  1406. * @apioption xAxis.minorTickWidth
  1407. */
  1408. /**
  1409. * Padding of the min value relative to the length of the axis. A
  1410. * padding of 0.05 will make a 100px axis 5px longer. This is useful
  1411. * when you don't want the lowest data value to appear on the edge
  1412. * of the plot area. When the axis' `min` option is set or a min extreme
  1413. * is set using `axis.setExtremes()`, the minPadding will be ignored.
  1414. *
  1415. * @sample {highcharts} highcharts/yaxis/minpadding/
  1416. * Min padding of 0.2
  1417. * @sample {highstock} stock/xaxis/minpadding-maxpadding/
  1418. * Greater min- and maxPadding
  1419. * @sample {highmaps} maps/chart/plotbackgroundcolor-gradient/
  1420. * Add some padding
  1421. *
  1422. * @default {highcharts} 0.01
  1423. * @default {highstock|highmaps} 0
  1424. * @since 1.2.0
  1425. * @product highcharts highstock gantt
  1426. */
  1427. minPadding: 0.01,
  1428. /**
  1429. * The minimum range to display on this axis. The entire axis will not
  1430. * be allowed to span over a smaller interval than this. For example,
  1431. * for a datetime axis the main unit is milliseconds. If minRange is
  1432. * set to 3600000, you can't zoom in more than to one hour.
  1433. *
  1434. * The default minRange for the x axis is five times the smallest
  1435. * interval between any of the data points.
  1436. *
  1437. * On a logarithmic axis, the unit for the minimum range is the power.
  1438. * So a minRange of 1 means that the axis can be zoomed to 10-100,
  1439. * 100-1000, 1000-10000 etc.
  1440. *
  1441. * Note that the `minPadding`, `maxPadding`, `startOnTick` and
  1442. * `endOnTick` settings also affect how the extremes of the axis
  1443. * are computed.
  1444. *
  1445. * @sample {highcharts} highcharts/xaxis/minrange/
  1446. * Minimum range of 5
  1447. * @sample {highstock} stock/xaxis/minrange/
  1448. * Max zoom of 6 months overrides user selections
  1449. * @sample {highmaps} maps/axis/minrange/
  1450. * Minimum range of 1000
  1451. *
  1452. * @type {number}
  1453. * @apioption xAxis.minRange
  1454. */
  1455. /**
  1456. * The minimum tick interval allowed in axis values. For example on
  1457. * zooming in on an axis with daily data, this can be used to prevent
  1458. * the axis from showing hours. Defaults to the closest distance between
  1459. * two points on the axis.
  1460. *
  1461. * @type {number}
  1462. * @since 2.3.0
  1463. * @apioption xAxis.minTickInterval
  1464. */
  1465. /**
  1466. * The distance in pixels from the plot area to the axis line.
  1467. * A positive offset moves the axis with it's line, labels and ticks
  1468. * away from the plot area. This is typically used when two or more
  1469. * axes are displayed on the same side of the plot. With multiple
  1470. * axes the offset is dynamically adjusted to avoid collision, this
  1471. * can be overridden by setting offset explicitly.
  1472. *
  1473. * @sample {highcharts} highcharts/yaxis/offset/
  1474. * Y axis offset of 70
  1475. * @sample {highcharts} highcharts/yaxis/offset-centered/
  1476. * Axes positioned in the center of the plot
  1477. * @sample {highstock} stock/xaxis/offset/
  1478. * Y axis offset by 70 px
  1479. *
  1480. * @type {number}
  1481. * @default 0
  1482. * @apioption xAxis.offset
  1483. */
  1484. /**
  1485. * Whether to display the axis on the opposite side of the normal. The
  1486. * normal is on the left side for vertical axes and bottom for
  1487. * horizontal, so the opposite sides will be right and top respectively.
  1488. * This is typically used with dual or multiple axes.
  1489. *
  1490. * @sample {highcharts} highcharts/yaxis/opposite/
  1491. * Secondary Y axis opposite
  1492. * @sample {highstock} stock/xaxis/opposite/
  1493. * Y axis on left side
  1494. *
  1495. * @type {boolean}
  1496. * @default false
  1497. * @apioption xAxis.opposite
  1498. */
  1499. /**
  1500. * In an ordinal axis, the points are equally spaced in the chart
  1501. * regardless of the actual time or x distance between them. This means
  1502. * that missing data periods (e.g. nights or weekends for a stock chart)
  1503. * will not take up space in the chart.
  1504. * Having `ordinal: false` will show any gaps created by the `gapSize`
  1505. * setting proportionate to their duration.
  1506. *
  1507. * In stock charts the X axis is ordinal by default, unless
  1508. * the boost module is used and at least one of the series' data length
  1509. * exceeds the [boostThreshold](#series.line.boostThreshold).
  1510. *
  1511. * @sample {highstock} stock/xaxis/ordinal-true/
  1512. * True by default
  1513. * @sample {highstock} stock/xaxis/ordinal-false/
  1514. * False
  1515. *
  1516. * @type {boolean}
  1517. * @default true
  1518. * @since 1.1
  1519. * @product highstock
  1520. * @apioption xAxis.ordinal
  1521. */
  1522. /**
  1523. * Additional range on the right side of the xAxis. Works similar to
  1524. * `xAxis.maxPadding`, but value is set in milliseconds. Can be set for
  1525. * both main `xAxis` and the navigator's `xAxis`.
  1526. *
  1527. * @sample {highstock} stock/xaxis/overscroll/
  1528. * One minute overscroll with live data
  1529. *
  1530. * @type {number}
  1531. * @default 0
  1532. * @since 6.0.0
  1533. * @product highstock
  1534. * @apioption xAxis.overscroll
  1535. */
  1536. /**
  1537. * Refers to the index in the [panes](#panes) array. Used for circular
  1538. * gauges and polar charts. When the option is not set then first pane
  1539. * will be used.
  1540. *
  1541. * @sample highcharts/demo/gauge-vu-meter
  1542. * Two gauges with different center
  1543. *
  1544. * @type {number}
  1545. * @product highcharts
  1546. * @apioption xAxis.pane
  1547. */
  1548. /**
  1549. * The zoomed range to display when only defining one or none of `min`
  1550. * or `max`. For example, to show the latest month, a range of one month
  1551. * can be set.
  1552. *
  1553. * @sample {highstock} stock/xaxis/range/
  1554. * Setting a zoomed range when the rangeSelector is disabled
  1555. *
  1556. * @type {number}
  1557. * @product highstock
  1558. * @apioption xAxis.range
  1559. */
  1560. /**
  1561. * Whether to reverse the axis so that the highest number is closest
  1562. * to the origin. If the chart is inverted, the x axis is reversed by
  1563. * default.
  1564. *
  1565. * @sample {highcharts} highcharts/yaxis/reversed/
  1566. * Reversed Y axis
  1567. * @sample {highstock} stock/xaxis/reversed/
  1568. * Reversed Y axis
  1569. *
  1570. * @type {boolean}
  1571. * @default false
  1572. * @apioption xAxis.reversed
  1573. */
  1574. // reversed: false,
  1575. /**
  1576. * This option determines how stacks should be ordered within a group.
  1577. * For example reversed xAxis also reverses stacks, so first series
  1578. * comes last in a group. To keep order like for non-reversed xAxis
  1579. * enable this option.
  1580. *
  1581. * @sample {highcharts} highcharts/xaxis/reversedstacks/
  1582. * Reversed stacks comparison
  1583. * @sample {highstock} highcharts/xaxis/reversedstacks/
  1584. * Reversed stacks comparison
  1585. *
  1586. * @type {boolean}
  1587. * @default false
  1588. * @since 6.1.1
  1589. * @product highcharts highstock
  1590. * @apioption xAxis.reversedStacks
  1591. */
  1592. /**
  1593. * An optional scrollbar to display on the X axis in response to
  1594. * limiting the minimum and maximum of the axis values.
  1595. *
  1596. * In styled mode, all the presentational options for the scrollbar are
  1597. * replaced by the classes `.highcharts-scrollbar-thumb`,
  1598. * `.highcharts-scrollbar-arrow`, `.highcharts-scrollbar-button`,
  1599. * `.highcharts-scrollbar-rifles` and `.highcharts-scrollbar-track`.
  1600. *
  1601. * @sample {highstock} stock/yaxis/heatmap-scrollbars/
  1602. * Heatmap with both scrollbars
  1603. *
  1604. * @extends scrollbar
  1605. * @since 4.2.6
  1606. * @product highstock
  1607. * @apioption xAxis.scrollbar
  1608. */
  1609. /**
  1610. * Whether to show the axis line and title when the axis has no data.
  1611. *
  1612. * @sample {highcharts} highcharts/yaxis/showempty/
  1613. * When clicking the legend to hide series, one axis preserves
  1614. * line and title, the other doesn't
  1615. * @sample {highstock} highcharts/yaxis/showempty/
  1616. * When clicking the legend to hide series, one axis preserves
  1617. * line and title, the other doesn't
  1618. *
  1619. * @since 1.1
  1620. */
  1621. showEmpty: true,
  1622. /**
  1623. * Whether to show the first tick label.
  1624. *
  1625. * @sample {highcharts} highcharts/xaxis/showfirstlabel-false/
  1626. * Set to false on X axis
  1627. * @sample {highstock} stock/xaxis/showfirstlabel/
  1628. * Labels below plot lines on Y axis
  1629. *
  1630. * @type {boolean}
  1631. * @default true
  1632. * @apioption xAxis.showFirstLabel
  1633. */
  1634. /**
  1635. * Whether to show the last tick label. Defaults to `true` on cartesian
  1636. * charts, and `false` on polar charts.
  1637. *
  1638. * @sample {highcharts} highcharts/xaxis/showlastlabel-true/
  1639. * Set to true on X axis
  1640. * @sample {highstock} stock/xaxis/showfirstlabel/
  1641. * Labels below plot lines on Y axis
  1642. *
  1643. * @type {boolean}
  1644. * @default true
  1645. * @product highcharts highstock gantt
  1646. * @apioption xAxis.showLastLabel
  1647. */
  1648. /**
  1649. * A soft maximum for the axis. If the series data maximum is less than
  1650. * this, the axis will stay at this maximum, but if the series data
  1651. * maximum is higher, the axis will flex to show all data.
  1652. *
  1653. * @sample highcharts/yaxis/softmin-softmax/
  1654. * Soft min and max
  1655. *
  1656. * @type {number}
  1657. * @since 5.0.1
  1658. * @product highcharts highstock gantt
  1659. * @apioption xAxis.softMax
  1660. */
  1661. /**
  1662. * A soft minimum for the axis. If the series data minimum is greater
  1663. * than this, the axis will stay at this minimum, but if the series
  1664. * data minimum is lower, the axis will flex to show all data.
  1665. *
  1666. * @sample highcharts/yaxis/softmin-softmax/
  1667. * Soft min and max
  1668. *
  1669. * @type {number}
  1670. * @since 5.0.1
  1671. * @product highcharts highstock gantt
  1672. * @apioption xAxis.softMin
  1673. */
  1674. /**
  1675. * For datetime axes, this decides where to put the tick between weeks.
  1676. * 0 = Sunday, 1 = Monday.
  1677. *
  1678. * @sample {highcharts} highcharts/xaxis/startofweek-monday/
  1679. * Monday by default
  1680. * @sample {highcharts} highcharts/xaxis/startofweek-sunday/
  1681. * Sunday
  1682. * @sample {highstock} stock/xaxis/startofweek-1
  1683. * Monday by default
  1684. * @sample {highstock} stock/xaxis/startofweek-0
  1685. * Sunday
  1686. *
  1687. * @product highcharts highstock gantt
  1688. */
  1689. startOfWeek: 1,
  1690. /**
  1691. * Whether to force the axis to start on a tick. Use this option with
  1692. * the `minPadding` option to control the axis start.
  1693. *
  1694. * @productdesc {highstock}
  1695. * In Highstock, `startOnTick` is always false when either the
  1696. * navigator or vertical panning is enabled, to prevent jumpy
  1697. * scrolling.
  1698. *
  1699. * @sample {highcharts} highcharts/xaxis/startontick-false/
  1700. * False by default
  1701. * @sample {highcharts} highcharts/xaxis/startontick-true/
  1702. * True
  1703. * @sample {highstock} stock/xaxis/endontick/
  1704. * False for Y axis
  1705. *
  1706. * @since 1.2.0
  1707. */
  1708. startOnTick: false,
  1709. /**
  1710. * The amount of ticks to draw on the axis. This opens up for aligning
  1711. * the ticks of multiple charts or panes within a chart. This option
  1712. * overrides the `tickPixelInterval` option.
  1713. *
  1714. * This option only has an effect on linear axes. Datetime, logarithmic
  1715. * or category axes are not affected.
  1716. *
  1717. * @sample {highcharts} highcharts/yaxis/tickamount/
  1718. * 8 ticks on Y axis
  1719. * @sample {highstock} highcharts/yaxis/tickamount/
  1720. * 8 ticks on Y axis
  1721. *
  1722. * @type {number}
  1723. * @since 4.1.0
  1724. * @product highcharts highstock gantt
  1725. * @apioption xAxis.tickAmount
  1726. */
  1727. /**
  1728. * The interval of the tick marks in axis units. When `undefined`, the
  1729. * tick interval is computed to approximately follow the
  1730. * [tickPixelInterval](#xAxis.tickPixelInterval) on linear and datetime
  1731. * axes. On categorized axes, a `undefined` tickInterval will default to
  1732. * 1, one category. Note that datetime axes are based on milliseconds,
  1733. * so for example an interval of one day is expressed as
  1734. * `24 * 3600 * 1000`.
  1735. *
  1736. * On logarithmic axes, the tickInterval is based on powers, so a
  1737. * tickInterval of 1 means one tick on each of 0.1, 1, 10, 100 etc. A
  1738. * tickInterval of 2 means a tick of 0.1, 10, 1000 etc. A tickInterval
  1739. * of 0.2 puts a tick on 0.1, 0.2, 0.4, 0.6, 0.8, 1, 2, 4, 6, 8, 10, 20,
  1740. * 40 etc.
  1741. *
  1742. *
  1743. * If the tickInterval is too dense for labels to be drawn, Highcharts
  1744. * may remove ticks.
  1745. *
  1746. * If the chart has multiple axes, the [alignTicks](#chart.alignTicks)
  1747. * option may interfere with the `tickInterval` setting.
  1748. *
  1749. * @see [tickPixelInterval](#xAxis.tickPixelInterval)
  1750. * @see [tickPositions](#xAxis.tickPositions)
  1751. * @see [tickPositioner](#xAxis.tickPositioner)
  1752. *
  1753. * @sample {highcharts} highcharts/xaxis/tickinterval-5/
  1754. * Tick interval of 5 on a linear axis
  1755. * @sample {highstock} stock/xaxis/tickinterval/
  1756. * Tick interval of 0.01 on Y axis
  1757. *
  1758. * @type {number}
  1759. * @apioption xAxis.tickInterval
  1760. */
  1761. /**
  1762. * The pixel length of the main tick marks.
  1763. *
  1764. * @sample {highcharts} highcharts/xaxis/ticklength/
  1765. * 20 px tick length on the X axis
  1766. * @sample {highstock} stock/xaxis/ticks/
  1767. * Formatted ticks on X axis
  1768. */
  1769. tickLength: 10,
  1770. /**
  1771. * If tickInterval is `null` this option sets the approximate pixel
  1772. * interval of the tick marks. Not applicable to categorized axis.
  1773. *
  1774. * The tick interval is also influenced by the [minTickInterval](
  1775. * #xAxis.minTickInterval) option, that, by default prevents ticks from
  1776. * being denser than the data points.
  1777. *
  1778. * @see [tickInterval](#xAxis.tickInterval)
  1779. * @see [tickPositioner](#xAxis.tickPositioner)
  1780. * @see [tickPositions](#xAxis.tickPositions)
  1781. *
  1782. * @sample {highcharts} highcharts/xaxis/tickpixelinterval-50/
  1783. * 50 px on X axis
  1784. * @sample {highstock} stock/xaxis/tickpixelinterval/
  1785. * 200 px on X axis
  1786. */
  1787. tickPixelInterval: 100,
  1788. /**
  1789. * For categorized axes only. If `on` the tick mark is placed in the
  1790. * center of the category, if `between` the tick mark is placed between
  1791. * categories. The default is `between` if the `tickInterval` is 1, else
  1792. * `on`.
  1793. *
  1794. * @sample {highcharts} highcharts/xaxis/tickmarkplacement-between/
  1795. * "between" by default
  1796. * @sample {highcharts} highcharts/xaxis/tickmarkplacement-on/
  1797. * "on"
  1798. *
  1799. * @product highcharts gantt
  1800. * @validvalue ["on", "between"]
  1801. */
  1802. tickmarkPlacement: 'between',
  1803. /**
  1804. * The position of the major tick marks relative to the axis line.
  1805. * Can be one of `inside` and `outside`.
  1806. *
  1807. * @sample {highcharts} highcharts/xaxis/tickposition-outside/
  1808. * "outside" by default
  1809. * @sample {highcharts} highcharts/xaxis/tickposition-inside/
  1810. * "inside"
  1811. * @sample {highstock} stock/xaxis/ticks/
  1812. * Formatted ticks on X axis
  1813. *
  1814. * @validvalue ["inside", "outside"]
  1815. */
  1816. tickPosition: 'outside',
  1817. /**
  1818. * A callback function returning array defining where the ticks are
  1819. * laid out on the axis. This overrides the default behaviour of
  1820. * [tickPixelInterval](#xAxis.tickPixelInterval) and [tickInterval](
  1821. * #xAxis.tickInterval). The automatic tick positions are accessible
  1822. * through `this.tickPositions` and can be modified by the callback.
  1823. *
  1824. * @see [tickPositions](#xAxis.tickPositions)
  1825. *
  1826. * @sample {highcharts} highcharts/xaxis/tickpositions-tickpositioner/
  1827. * Demo of tickPositions and tickPositioner
  1828. * @sample {highstock} highcharts/xaxis/tickpositions-tickpositioner/
  1829. * Demo of tickPositions and tickPositioner
  1830. *
  1831. * @type {Highcharts.AxisTickPositionerCallbackFunction}
  1832. * @apioption xAxis.tickPositioner
  1833. */
  1834. /**
  1835. * An array defining where the ticks are laid out on the axis. This
  1836. * overrides the default behaviour of [tickPixelInterval](
  1837. * #xAxis.tickPixelInterval) and [tickInterval](#xAxis.tickInterval).
  1838. *
  1839. * @see [tickPositioner](#xAxis.tickPositioner)
  1840. *
  1841. * @sample {highcharts} highcharts/xaxis/tickpositions-tickpositioner/
  1842. * Demo of tickPositions and tickPositioner
  1843. * @sample {highstock} highcharts/xaxis/tickpositions-tickpositioner/
  1844. * Demo of tickPositions and tickPositioner
  1845. *
  1846. * @type {Array<number>}
  1847. * @apioption xAxis.tickPositions
  1848. */
  1849. /**
  1850. * The pixel width of the major tick marks. Defaults to 0 on category
  1851. * axes, otherwise 1.
  1852. *
  1853. * In styled mode, the stroke width is given in the `.highcharts-tick`
  1854. * class, but in order for the element to be generated on category axes,
  1855. * the option must be explicitly set to 1.
  1856. *
  1857. * @sample {highcharts} highcharts/xaxis/tickwidth/
  1858. * 10 px width
  1859. * @sample {highcharts} highcharts/css/axis-grid/
  1860. * Styled mode
  1861. * @sample {highstock} stock/xaxis/ticks/
  1862. * Formatted ticks on X axis
  1863. * @sample {highstock} highcharts/css/axis-grid/
  1864. * Styled mode
  1865. *
  1866. * @type {undefined|number}
  1867. * @default {highstock} 1
  1868. * @default {highmaps} 0
  1869. * @apioption xAxis.tickWidth
  1870. */
  1871. /**
  1872. * The axis title, showing next to the axis line.
  1873. *
  1874. * @productdesc {highmaps}
  1875. * In Highmaps, the axis is hidden by default, but adding an axis title
  1876. * is still possible. X axis and Y axis titles will appear at the bottom
  1877. * and left by default.
  1878. */
  1879. title: {
  1880. /**
  1881. * Deprecated. Set the `text` to `null` to disable the title.
  1882. *
  1883. * @deprecated
  1884. * @type {boolean}
  1885. * @product highcharts
  1886. * @apioption xAxis.title.enabled
  1887. */
  1888. /**
  1889. * The pixel distance between the axis labels or line and the title.
  1890. * Defaults to 0 for horizontal axes, 10 for vertical
  1891. *
  1892. * @sample {highcharts} highcharts/xaxis/title-margin/
  1893. * Y axis title margin of 60
  1894. *
  1895. * @type {number}
  1896. * @apioption xAxis.title.margin
  1897. */
  1898. /**
  1899. * The distance of the axis title from the axis line. By default,
  1900. * this distance is computed from the offset width of the labels,
  1901. * the labels' distance from the axis and the title's margin.
  1902. * However when the offset option is set, it overrides all this.
  1903. *
  1904. * @sample {highcharts} highcharts/yaxis/title-offset/
  1905. * Place the axis title on top of the axis
  1906. * @sample {highstock} highcharts/yaxis/title-offset/
  1907. * Place the axis title on top of the Y axis
  1908. *
  1909. * @type {number}
  1910. * @since 2.2.0
  1911. * @apioption xAxis.title.offset
  1912. */
  1913. /**
  1914. * Whether to reserve space for the title when laying out the axis.
  1915. *
  1916. * @type {boolean}
  1917. * @default true
  1918. * @since 5.0.11
  1919. * @product highcharts highstock gantt
  1920. * @apioption xAxis.title.reserveSpace
  1921. */
  1922. /**
  1923. * The rotation of the text in degrees. 0 is horizontal, 270 is
  1924. * vertical reading from bottom to top.
  1925. *
  1926. * @sample {highcharts} highcharts/yaxis/title-offset/
  1927. * Horizontal
  1928. *
  1929. * @type {number}
  1930. * @default 0
  1931. * @apioption xAxis.title.rotation
  1932. */
  1933. /**
  1934. * The actual text of the axis title. It can contain basic HTML tags
  1935. * like `b`, `i` and `span` with style.
  1936. *
  1937. * @sample {highcharts} highcharts/xaxis/title-text/
  1938. * Custom HTML
  1939. * @sample {highstock} stock/xaxis/title-text/
  1940. * Titles for both axes
  1941. *
  1942. * @type {string|null}
  1943. * @apioption xAxis.title.text
  1944. */
  1945. /**
  1946. * Alignment of the text, can be `"left"`, `"right"` or `"center"`.
  1947. * Default alignment depends on the
  1948. * [title.align](xAxis.title.align):
  1949. *
  1950. * Horizontal axes:
  1951. * - for `align` = `"low"`, `textAlign` is set to `left`
  1952. * - for `align` = `"middle"`, `textAlign` is set to `center`
  1953. * - for `align` = `"high"`, `textAlign` is set to `right`
  1954. *
  1955. * Vertical axes:
  1956. * - for `align` = `"low"` and `opposite` = `true`, `textAlign` is
  1957. * set to `right`
  1958. * - for `align` = `"low"` and `opposite` = `false`, `textAlign` is
  1959. * set to `left`
  1960. * - for `align` = `"middle"`, `textAlign` is set to `center`
  1961. * - for `align` = `"high"` and `opposite` = `true` `textAlign` is
  1962. * set to `left`
  1963. * - for `align` = `"high"` and `opposite` = `false` `textAlign` is
  1964. * set to `right`
  1965. *
  1966. * @type {Highcharts.AlignValue}
  1967. * @apioption xAxis.title.textAlign
  1968. */
  1969. /**
  1970. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  1971. * to render the axis title.
  1972. *
  1973. * @type {boolean}
  1974. * @default false
  1975. * @product highcharts highstock gantt
  1976. * @apioption xAxis.title.useHTML
  1977. */
  1978. /**
  1979. * Horizontal pixel offset of the title position.
  1980. *
  1981. * @type {number}
  1982. * @default 0
  1983. * @since 4.1.6
  1984. * @product highcharts highstock gantt
  1985. * @apioption xAxis.title.x
  1986. */
  1987. /**
  1988. * Vertical pixel offset of the title position.
  1989. *
  1990. * @type {number}
  1991. * @product highcharts highstock gantt
  1992. * @apioption xAxis.title.y
  1993. */
  1994. /**
  1995. * Alignment of the title relative to the axis values. Possible
  1996. * values are "low", "middle" or "high".
  1997. *
  1998. * @sample {highcharts} highcharts/xaxis/title-align-low/
  1999. * "low"
  2000. * @sample {highcharts} highcharts/xaxis/title-align-center/
  2001. * "middle" by default
  2002. * @sample {highcharts} highcharts/xaxis/title-align-high/
  2003. * "high"
  2004. * @sample {highcharts} highcharts/yaxis/title-offset/
  2005. * Place the Y axis title on top of the axis
  2006. * @sample {highstock} stock/xaxis/title-align/
  2007. * Aligned to "high" value
  2008. *
  2009. * @type {Highcharts.AxisTitleAlignValue}
  2010. */
  2011. align: 'middle',
  2012. /**
  2013. * CSS styles for the title. If the title text is longer than the
  2014. * axis length, it will wrap to multiple lines by default. This can
  2015. * be customized by setting `textOverflow: 'ellipsis'`, by
  2016. * setting a specific `width` or by setting `whiteSpace: 'nowrap'`.
  2017. *
  2018. * In styled mode, the stroke width is given in the
  2019. * `.highcharts-axis-title` class.
  2020. *
  2021. * @sample {highcharts} highcharts/xaxis/title-style/
  2022. * Red
  2023. * @sample {highcharts} highcharts/css/axis/
  2024. * Styled mode
  2025. *
  2026. * @type {Highcharts.CSSObject}
  2027. */
  2028. style: {
  2029. /** @internal */
  2030. color: '#666666'
  2031. }
  2032. },
  2033. /**
  2034. * The type of axis. Can be one of `linear`, `logarithmic`, `datetime`
  2035. * or `category`. In a datetime axis, the numbers are given in
  2036. * milliseconds, and tick marks are placed on appropriate values like
  2037. * full hours or days. In a category axis, the
  2038. * [point names](#series.line.data.name) of the chart's series are used
  2039. * for categories, if not a [categories](#xAxis.categories) array is
  2040. * defined.
  2041. *
  2042. * @sample {highcharts} highcharts/xaxis/type-linear/
  2043. * Linear
  2044. * @sample {highcharts} highcharts/yaxis/type-log/
  2045. * Logarithmic
  2046. * @sample {highcharts} highcharts/yaxis/type-log-minorgrid/
  2047. * Logarithmic with minor grid lines
  2048. * @sample {highcharts} highcharts/xaxis/type-log-both/
  2049. * Logarithmic on two axes
  2050. * @sample {highcharts} highcharts/yaxis/type-log-negative/
  2051. * Logarithmic with extension to emulate negative values
  2052. *
  2053. * @type {Highcharts.AxisTypeValue}
  2054. * @product highcharts gantt
  2055. */
  2056. type: 'linear',
  2057. /**
  2058. * If there are multiple axes on the same side of the chart, the pixel
  2059. * margin between the axes. Defaults to 0 on vertical axes, 15 on
  2060. * horizontal axes.
  2061. *
  2062. * @type {number}
  2063. * @since 7.0.3
  2064. * @apioption xAxis.margin
  2065. */
  2066. /**
  2067. * Applies only when the axis `type` is `category`. When `uniqueNames`
  2068. * is true, points are placed on the X axis according to their names.
  2069. * If the same point name is repeated in the same or another series,
  2070. * the point is placed on the same X position as other points of the
  2071. * same name. When `uniqueNames` is false, the points are laid out in
  2072. * increasing X positions regardless of their names, and the X axis
  2073. * category will take the name of the last point in each position.
  2074. *
  2075. * @sample {highcharts} highcharts/xaxis/uniquenames-true/
  2076. * True by default
  2077. * @sample {highcharts} highcharts/xaxis/uniquenames-false/
  2078. * False
  2079. *
  2080. * @type {boolean}
  2081. * @default true
  2082. * @since 4.2.7
  2083. * @product highcharts gantt
  2084. * @apioption xAxis.uniqueNames
  2085. */
  2086. /**
  2087. * Datetime axis only. An array determining what time intervals the
  2088. * ticks are allowed to fall on. Each array item is an array where the
  2089. * first value is the time unit and the second value another array of
  2090. * allowed multiples.
  2091. *
  2092. * Defaults to:
  2093. * ```js
  2094. * units: [[
  2095. * 'millisecond', // unit name
  2096. * [1, 2, 5, 10, 20, 25, 50, 100, 200, 500] // allowed multiples
  2097. * ], [
  2098. * 'second',
  2099. * [1, 2, 5, 10, 15, 30]
  2100. * ], [
  2101. * 'minute',
  2102. * [1, 2, 5, 10, 15, 30]
  2103. * ], [
  2104. * 'hour',
  2105. * [1, 2, 3, 4, 6, 8, 12]
  2106. * ], [
  2107. * 'day',
  2108. * [1]
  2109. * ], [
  2110. * 'week',
  2111. * [1]
  2112. * ], [
  2113. * 'month',
  2114. * [1, 3, 6]
  2115. * ], [
  2116. * 'year',
  2117. * null
  2118. * ]]
  2119. * ```
  2120. *
  2121. * @type {Array<Array<string,(Array<number>|null)>>}
  2122. * @product highcharts highstock gantt
  2123. * @apioption xAxis.units
  2124. */
  2125. /**
  2126. * Whether axis, including axis title, line, ticks and labels, should
  2127. * be visible.
  2128. *
  2129. * @type {boolean}
  2130. * @default true
  2131. * @since 4.1.9
  2132. * @product highcharts highstock gantt
  2133. * @apioption xAxis.visible
  2134. */
  2135. /**
  2136. * Color of the minor, secondary grid lines.
  2137. *
  2138. * In styled mode, the stroke width is given in the
  2139. * `.highcharts-minor-grid-line` class.
  2140. *
  2141. * @sample {highcharts} highcharts/yaxis/minorgridlinecolor/
  2142. * Bright grey lines from Y axis
  2143. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  2144. * Styled mode
  2145. * @sample {highstock} stock/xaxis/minorgridlinecolor/
  2146. * Bright grey lines from Y axis
  2147. *
  2148. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  2149. * @default #f2f2f2
  2150. */
  2151. minorGridLineColor: '#f2f2f2',
  2152. /**
  2153. * Width of the minor, secondary grid lines.
  2154. *
  2155. * In styled mode, the stroke width is given in the
  2156. * `.highcharts-grid-line` class.
  2157. *
  2158. * @sample {highcharts} highcharts/yaxis/minorgridlinewidth/
  2159. * 2px lines from Y axis
  2160. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  2161. * Styled mode
  2162. * @sample {highstock} stock/xaxis/minorgridlinewidth/
  2163. * 2px lines from Y axis
  2164. */
  2165. minorGridLineWidth: 1,
  2166. /**
  2167. * Color for the minor tick marks.
  2168. *
  2169. * @sample {highcharts} highcharts/yaxis/minortickcolor/
  2170. * Black tick marks on Y axis
  2171. * @sample {highstock} stock/xaxis/minorticks/
  2172. * Black tick marks on Y axis
  2173. *
  2174. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  2175. * @default #999999
  2176. */
  2177. minorTickColor: '#999999',
  2178. /**
  2179. * The color of the line marking the axis itself.
  2180. *
  2181. * In styled mode, the line stroke is given in the
  2182. * `.highcharts-axis-line` or `.highcharts-xaxis-line` class.
  2183. *
  2184. * @productdesc {highmaps}
  2185. * In Highmaps, the axis line is hidden by default, because the axis is
  2186. * not visible by default.
  2187. *
  2188. * @sample {highcharts} highcharts/yaxis/linecolor/
  2189. * A red line on Y axis
  2190. * @sample {highcharts|highstock} highcharts/css/axis/
  2191. * Axes in styled mode
  2192. * @sample {highstock} stock/xaxis/linecolor/
  2193. * A red line on X axis
  2194. *
  2195. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  2196. * @default #ccd6eb
  2197. */
  2198. lineColor: '#ccd6eb',
  2199. /**
  2200. * The width of the line marking the axis itself.
  2201. *
  2202. * In styled mode, the stroke width is given in the
  2203. * `.highcharts-axis-line` or `.highcharts-xaxis-line` class.
  2204. *
  2205. * @sample {highcharts} highcharts/yaxis/linecolor/
  2206. * A 1px line on Y axis
  2207. * @sample {highcharts|highstock} highcharts/css/axis/
  2208. * Axes in styled mode
  2209. * @sample {highstock} stock/xaxis/linewidth/
  2210. * A 2px line on X axis
  2211. *
  2212. * @default {highcharts|highstock} 1
  2213. * @default {highmaps} 0
  2214. */
  2215. lineWidth: 1,
  2216. /**
  2217. * Color of the grid lines extending the ticks across the plot area.
  2218. *
  2219. * In styled mode, the stroke is given in the `.highcharts-grid-line`
  2220. * class.
  2221. *
  2222. * @productdesc {highmaps}
  2223. * In Highmaps, the grid lines are hidden by default.
  2224. *
  2225. * @sample {highcharts} highcharts/yaxis/gridlinecolor/
  2226. * Green lines
  2227. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  2228. * Styled mode
  2229. * @sample {highstock} stock/xaxis/gridlinecolor/
  2230. * Green lines
  2231. *
  2232. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  2233. * @default #e6e6e6
  2234. */
  2235. gridLineColor: '#e6e6e6',
  2236. // gridLineDashStyle: 'solid',
  2237. /**
  2238. * The width of the grid lines extending the ticks across the plot area.
  2239. *
  2240. * In styled mode, the stroke width is given in the
  2241. * `.highcharts-grid-line` class.
  2242. *
  2243. * @sample {highcharts} highcharts/yaxis/gridlinewidth/
  2244. * 2px lines
  2245. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  2246. * Styled mode
  2247. * @sample {highstock} stock/xaxis/gridlinewidth/
  2248. * 2px lines
  2249. *
  2250. * @type {number}
  2251. * @default 0
  2252. * @apioption xAxis.gridLineWidth
  2253. */
  2254. // gridLineWidth: 0,
  2255. /**
  2256. * The height as the vertical axis. If it's a number, it is
  2257. * interpreted as pixels.
  2258. *
  2259. * Since Highcharts 2: If it's a percentage string, it is interpreted
  2260. * as percentages of the total plot height.
  2261. *
  2262. * @type {number|string}
  2263. * @product highcharts highstock
  2264. * @apioption xAxis.height
  2265. */
  2266. /**
  2267. * The width as the horizontal axis. If it's a number, it is interpreted
  2268. * as pixels.
  2269. *
  2270. * Since Highcharts v5.0.13: If it's a percentage string, it is
  2271. * interpreted as percentages of the total plot width.
  2272. *
  2273. * @type {number|string}
  2274. * @product highcharts highstock
  2275. * @apioption xAxis.width
  2276. */
  2277. /**
  2278. * Color for the main tick marks.
  2279. *
  2280. * In styled mode, the stroke is given in the `.highcharts-tick`
  2281. * class.
  2282. *
  2283. * @sample {highcharts} highcharts/xaxis/tickcolor/
  2284. * Red ticks on X axis
  2285. * @sample {highcharts|highstock} highcharts/css/axis-grid/
  2286. * Styled mode
  2287. * @sample {highstock} stock/xaxis/ticks/
  2288. * Formatted ticks on X axis
  2289. *
  2290. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  2291. * @default #ccd6eb
  2292. */
  2293. tickColor: '#ccd6eb'
  2294. // tickWidth: 1
  2295. },
  2296. /**
  2297. * The Y axis or value axis. Normally this is the vertical axis,
  2298. * though if the chart is inverted this is the horizontal axis.
  2299. * In case of multiple axes, the yAxis node is an array of
  2300. * configuration objects.
  2301. *
  2302. * See [the Axis object](/class-reference/Highcharts.Axis) for programmatic
  2303. * access to the axis.
  2304. *
  2305. * @type {*|Array<*>}
  2306. * @extends xAxis
  2307. * @excluding currentDateIndicator,ordinal,overscroll
  2308. * @optionparent yAxis
  2309. *
  2310. * @private
  2311. */
  2312. defaultYAxisOptions: {
  2313. /**
  2314. * The type of axis. Can be one of `linear`, `logarithmic`, `datetime`,
  2315. * `category` or `treegrid`. Defaults to `treegrid` for Gantt charts,
  2316. * `linear` for other chart types.
  2317. *
  2318. * In a datetime axis, the numbers are given in milliseconds, and tick
  2319. * marks are placed on appropriate values, like full hours or days. In a
  2320. * category or treegrid axis, the [point names](#series.line.data.name)
  2321. * of the chart's series are used for categories, if a
  2322. * [categories](#xAxis.categories) array is not defined.
  2323. *
  2324. * @sample {highcharts} highcharts/yaxis/type-log-minorgrid/
  2325. * Logarithmic with minor grid lines
  2326. * @sample {highcharts} highcharts/yaxis/type-log-negative/
  2327. * Logarithmic with extension to emulate negative values
  2328. * @sample {gantt} gantt/treegrid-axis/demo
  2329. * Treegrid axis
  2330. *
  2331. * @type {Highcharts.AxisTypeValue}
  2332. * @default {highcharts} linear
  2333. * @default {gantt} treegrid
  2334. * @product highcharts gantt
  2335. * @apioption yAxis.type
  2336. */
  2337. /**
  2338. * The height of the Y axis. If it's a number, it is interpreted as
  2339. * pixels.
  2340. *
  2341. * Since Highcharts 2: If it's a percentage string, it is interpreted as
  2342. * percentages of the total plot height.
  2343. *
  2344. * @see [yAxis.top](#yAxis.top)
  2345. *
  2346. * @sample {highstock} stock/demo/candlestick-and-volume/
  2347. * Percentage height panes
  2348. *
  2349. * @type {number|string}
  2350. * @product highcharts highstock
  2351. * @apioption yAxis.height
  2352. */
  2353. /**
  2354. * Solid gauge only. Unless [stops](#yAxis.stops) are set, the color
  2355. * to represent the maximum value of the Y axis.
  2356. *
  2357. * @sample {highcharts} highcharts/yaxis/mincolor-maxcolor/
  2358. * Min and max colors
  2359. *
  2360. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  2361. * @default #003399
  2362. * @since 4.0
  2363. * @product highcharts
  2364. * @apioption yAxis.maxColor
  2365. */
  2366. /**
  2367. * Solid gauge only. Unless [stops](#yAxis.stops) are set, the color
  2368. * to represent the minimum value of the Y axis.
  2369. *
  2370. * @sample {highcharts} highcharts/yaxis/mincolor-maxcolor/
  2371. * Min and max color
  2372. *
  2373. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  2374. * @default #e6ebf5
  2375. * @since 4.0
  2376. * @product highcharts
  2377. * @apioption yAxis.minColor
  2378. */
  2379. /**
  2380. * Whether to reverse the axis so that the highest number is closest
  2381. * to the origin.
  2382. *
  2383. * @sample {highcharts} highcharts/yaxis/reversed/
  2384. * Reversed Y axis
  2385. * @sample {highstock} stock/xaxis/reversed/
  2386. * Reversed Y axis
  2387. *
  2388. * @type {boolean}
  2389. * @default {highcharts} false
  2390. * @default {highstock} false
  2391. * @default {highmaps} true
  2392. * @default {gantt} true
  2393. * @apioption yAxis.reversed
  2394. */
  2395. /**
  2396. * If `true`, the first series in a stack will be drawn on top in a
  2397. * positive, non-reversed Y axis. If `false`, the first series is in
  2398. * the base of the stack.
  2399. *
  2400. * @sample {highcharts} highcharts/yaxis/reversedstacks-false/
  2401. * Non-reversed stacks
  2402. * @sample {highstock} highcharts/yaxis/reversedstacks-false/
  2403. * Non-reversed stacks
  2404. *
  2405. * @type {boolean}
  2406. * @default true
  2407. * @since 3.0.10
  2408. * @product highcharts highstock
  2409. * @apioption yAxis.reversedStacks
  2410. */
  2411. /**
  2412. * Solid gauge series only. Color stops for the solid gauge. Use this
  2413. * in cases where a linear gradient between a `minColor` and `maxColor`
  2414. * is not sufficient. The stops is an array of tuples, where the first
  2415. * item is a float between 0 and 1 assigning the relative position in
  2416. * the gradient, and the second item is the color.
  2417. *
  2418. * For solid gauges, the Y axis also inherits the concept of
  2419. * [data classes](http://api.highcharts.com/highmaps#colorAxis.dataClasses)
  2420. * from the Highmaps color axis.
  2421. *
  2422. * @see [minColor](#yAxis.minColor)
  2423. * @see [maxColor](#yAxis.maxColor)
  2424. *
  2425. * @sample {highcharts} highcharts/demo/gauge-solid/
  2426. * True by default
  2427. *
  2428. * @type {Array<Highcharts.GradientColorStopObject>}
  2429. * @since 4.0
  2430. * @product highcharts
  2431. * @apioption yAxis.stops
  2432. */
  2433. /**
  2434. * The pixel width of the major tick marks.
  2435. *
  2436. * @sample {highcharts} highcharts/xaxis/tickwidth/ 10 px width
  2437. * @sample {highstock} stock/xaxis/ticks/ Formatted ticks on X axis
  2438. *
  2439. * @type {number}
  2440. * @default 0
  2441. * @product highcharts highstock gantt
  2442. * @apioption yAxis.tickWidth
  2443. */
  2444. /**
  2445. * Angular gauges and solid gauges only.
  2446. * The label's pixel distance from the perimeter of the plot area.
  2447. *
  2448. * Since v7.1.2: If it's a percentage string, it is interpreted the
  2449. * same as [series.radius](#plotOptions.gauge.radius), so label can be
  2450. * aligned under the gauge's shape.
  2451. *
  2452. * @sample {highcharts} highcharts/yaxis/labels-distance/
  2453. * Labels centered under the arc
  2454. *
  2455. * @type {number|string}
  2456. * @default -25
  2457. * @product highcharts
  2458. * @apioption yAxis.labels.distance
  2459. */
  2460. /**
  2461. * The y position offset of the label relative to the tick position
  2462. * on the axis.
  2463. *
  2464. * @sample {highcharts} highcharts/xaxis/labels-x/
  2465. * Y axis labels placed on grid lines
  2466. *
  2467. * @type {number}
  2468. * @default {highcharts} 3
  2469. * @default {highstock} -2
  2470. * @default {highmaps} 3
  2471. * @apioption yAxis.labels.y
  2472. */
  2473. /**
  2474. * @productdesc {highstock}
  2475. * In Highstock, `endOnTick` is always false when either the
  2476. * navigator or vertical panning is enabled, to prevent jumpy
  2477. * scrolling.
  2478. */
  2479. endOnTick: true,
  2480. /**
  2481. * Padding of the max value relative to the length of the axis. A
  2482. * padding of 0.05 will make a 100px axis 5px longer. This is useful
  2483. * when you don't want the highest data value to appear on the edge
  2484. * of the plot area. When the axis' `max` option is set or a max extreme
  2485. * is set using `axis.setExtremes()`, the maxPadding will be ignored.
  2486. *
  2487. * Also the `softThreshold` option takes precedence over `maxPadding`,
  2488. * so if the data is tangent to the threshold, `maxPadding` may not
  2489. * apply unless `softThreshold` is set to false.
  2490. *
  2491. * @sample {highcharts} highcharts/yaxis/maxpadding-02/
  2492. * Max padding of 0.2
  2493. * @sample {highstock} stock/xaxis/minpadding-maxpadding/
  2494. * Greater min- and maxPadding
  2495. *
  2496. * @since 1.2.0
  2497. * @product highcharts highstock gantt
  2498. */
  2499. maxPadding: 0.05,
  2500. /**
  2501. * Padding of the min value relative to the length of the axis. A
  2502. * padding of 0.05 will make a 100px axis 5px longer. This is useful
  2503. * when you don't want the lowest data value to appear on the edge
  2504. * of the plot area. When the axis' `min` option is set or a max extreme
  2505. * is set using `axis.setExtremes()`, the maxPadding will be ignored.
  2506. *
  2507. * Also the `softThreshold` option takes precedence over `minPadding`,
  2508. * so if the data is tangent to the threshold, `minPadding` may not
  2509. * apply unless `softThreshold` is set to false.
  2510. *
  2511. * @sample {highcharts} highcharts/yaxis/minpadding/
  2512. * Min padding of 0.2
  2513. * @sample {highstock} stock/xaxis/minpadding-maxpadding/
  2514. * Greater min- and maxPadding
  2515. *
  2516. * @since 1.2.0
  2517. * @product highcharts highstock gantt
  2518. */
  2519. minPadding: 0.05,
  2520. /**
  2521. * @productdesc {highstock}
  2522. * In Highstock 1.x, the Y axis was placed on the left side by default.
  2523. *
  2524. * @sample {highcharts} highcharts/yaxis/opposite/
  2525. * Secondary Y axis opposite
  2526. * @sample {highstock} stock/xaxis/opposite/
  2527. * Y axis on left side
  2528. *
  2529. * @type {boolean}
  2530. * @default {highstock} true
  2531. * @default {highcharts} false
  2532. * @product highstock highcharts gantt
  2533. * @apioption yAxis.opposite
  2534. */
  2535. /**
  2536. * @see [tickInterval](#xAxis.tickInterval)
  2537. * @see [tickPositioner](#xAxis.tickPositioner)
  2538. * @see [tickPositions](#xAxis.tickPositions)
  2539. */
  2540. tickPixelInterval: 72,
  2541. showLastLabel: true,
  2542. /**
  2543. * @extends xAxis.labels
  2544. */
  2545. labels: {
  2546. /**
  2547. * What part of the string the given position is anchored to. Can
  2548. * be one of `"left"`, `"center"` or `"right"`. The exact position
  2549. * also depends on the `labels.x` setting.
  2550. *
  2551. * Angular gauges and solid gauges defaults to `"center"`.
  2552. * Solid gauges with two labels have additional option `"auto"`
  2553. * for automatic horizontal and vertical alignment.
  2554. *
  2555. * @see [yAxis.labels.distance](#yAxis.labels.distance)
  2556. *
  2557. * @sample {highcharts} highcharts/yaxis/labels-align-left/
  2558. * Left
  2559. * @sample {highcharts} highcharts/series-solidgauge/labels-auto-aligned/
  2560. * Solid gauge labels auto aligned
  2561. *
  2562. * @type {Highcharts.AlignValue}
  2563. * @default {highcharts|highmaps} right
  2564. * @default {highstock} left
  2565. * @apioption yAxis.labels.align
  2566. */
  2567. /**
  2568. * The x position offset of the label relative to the tick position
  2569. * on the axis. Defaults to -15 for left axis, 15 for right axis.
  2570. *
  2571. * @sample {highcharts} highcharts/xaxis/labels-x/
  2572. * Y axis labels placed on grid lines
  2573. */
  2574. x: -8
  2575. },
  2576. /**
  2577. * @productdesc {highmaps}
  2578. * In Highmaps, the axis line is hidden by default, because the axis is
  2579. * not visible by default.
  2580. *
  2581. * @type {Highcharts.ColorString|Highcharts.GradientColorObject|Highcharts.PatternObject}
  2582. * @apioption yAxis.lineColor
  2583. */
  2584. /**
  2585. * @sample {highcharts} highcharts/yaxis/max-200/
  2586. * Y axis max of 200
  2587. * @sample {highcharts} highcharts/yaxis/max-logarithmic/
  2588. * Y axis max on logarithmic axis
  2589. * @sample {highstock} stock/yaxis/min-max/
  2590. * Fixed min and max on Y axis
  2591. * @sample {highmaps} maps/axis/min-max/
  2592. * Pre-zoomed to a specific area
  2593. *
  2594. * @apioption yAxis.max
  2595. */
  2596. /**
  2597. * @sample {highcharts} highcharts/yaxis/min-startontick-false/
  2598. * -50 with startOnTick to false
  2599. * @sample {highcharts} highcharts/yaxis/min-startontick-true/
  2600. * -50 with startOnTick true by default
  2601. * @sample {highstock} stock/yaxis/min-max/
  2602. * Fixed min and max on Y axis
  2603. * @sample {highmaps} maps/axis/min-max/
  2604. * Pre-zoomed to a specific area
  2605. *
  2606. * @apioption yAxis.min
  2607. */
  2608. /**
  2609. * An optional scrollbar to display on the Y axis in response to
  2610. * limiting the minimum an maximum of the axis values.
  2611. *
  2612. * In styled mode, all the presentational options for the scrollbar
  2613. * are replaced by the classes `.highcharts-scrollbar-thumb`,
  2614. * `.highcharts-scrollbar-arrow`, `.highcharts-scrollbar-button`,
  2615. * `.highcharts-scrollbar-rifles` and `.highcharts-scrollbar-track`.
  2616. *
  2617. * @sample {highstock} stock/yaxis/scrollbar/
  2618. * Scrollbar on the Y axis
  2619. *
  2620. * @extends scrollbar
  2621. * @since 4.2.6
  2622. * @product highstock
  2623. * @excluding height
  2624. * @apioption yAxis.scrollbar
  2625. */
  2626. /**
  2627. * Enable the scrollbar on the Y axis.
  2628. *
  2629. * @sample {highstock} stock/yaxis/scrollbar/
  2630. * Enabled on Y axis
  2631. *
  2632. * @type {boolean}
  2633. * @default false
  2634. * @since 4.2.6
  2635. * @product highstock
  2636. * @apioption yAxis.scrollbar.enabled
  2637. */
  2638. /**
  2639. * Pixel margin between the scrollbar and the axis elements.
  2640. *
  2641. * @type {number}
  2642. * @default 10
  2643. * @since 4.2.6
  2644. * @product highstock
  2645. * @apioption yAxis.scrollbar.margin
  2646. */
  2647. /**
  2648. * Whether to show the scrollbar when it is fully zoomed out at max
  2649. * range. Setting it to `false` on the Y axis makes the scrollbar stay
  2650. * hidden until the user zooms in, like common in browsers.
  2651. *
  2652. * @type {boolean}
  2653. * @default true
  2654. * @since 4.2.6
  2655. * @product highstock
  2656. * @apioption yAxis.scrollbar.showFull
  2657. */
  2658. /**
  2659. * The width of a vertical scrollbar or height of a horizontal
  2660. * scrollbar. Defaults to 20 on touch devices.
  2661. *
  2662. * @type {number}
  2663. * @default 14
  2664. * @since 4.2.6
  2665. * @product highstock
  2666. * @apioption yAxis.scrollbar.size
  2667. */
  2668. /**
  2669. * Z index of the scrollbar elements.
  2670. *
  2671. * @type {number}
  2672. * @default 3
  2673. * @since 4.2.6
  2674. * @product highstock
  2675. * @apioption yAxis.scrollbar.zIndex
  2676. */
  2677. /**
  2678. * A soft maximum for the axis. If the series data maximum is less
  2679. * than this, the axis will stay at this maximum, but if the series
  2680. * data maximum is higher, the axis will flex to show all data.
  2681. *
  2682. * **Note**: The [series.softThreshold](
  2683. * #plotOptions.series.softThreshold) option takes precedence over this
  2684. * option.
  2685. *
  2686. * @sample highcharts/yaxis/softmin-softmax/
  2687. * Soft min and max
  2688. *
  2689. * @type {number}
  2690. * @since 5.0.1
  2691. * @product highcharts highstock gantt
  2692. * @apioption yAxis.softMax
  2693. */
  2694. /**
  2695. * A soft minimum for the axis. If the series data minimum is greater
  2696. * than this, the axis will stay at this minimum, but if the series
  2697. * data minimum is lower, the axis will flex to show all data.
  2698. *
  2699. * **Note**: The [series.softThreshold](
  2700. * #plotOptions.series.softThreshold) option takes precedence over this
  2701. * option.
  2702. *
  2703. * @sample highcharts/yaxis/softmin-softmax/
  2704. * Soft min and max
  2705. *
  2706. * @type {number}
  2707. * @since 5.0.1
  2708. * @product highcharts highstock gantt
  2709. * @apioption yAxis.softMin
  2710. */
  2711. /**
  2712. * Defines the horizontal alignment of the stack total label. Can be one
  2713. * of `"left"`, `"center"` or `"right"`. The default value is calculated
  2714. * at runtime and depends on orientation and whether the stack is
  2715. * positive or negative.
  2716. *
  2717. * @sample {highcharts} highcharts/yaxis/stacklabels-align-left/
  2718. * Aligned to the left
  2719. * @sample {highcharts} highcharts/yaxis/stacklabels-align-center/
  2720. * Aligned in center
  2721. * @sample {highcharts} highcharts/yaxis/stacklabels-align-right/
  2722. * Aligned to the right
  2723. *
  2724. * @type {Highcharts.AlignValue}
  2725. * @since 2.1.5
  2726. * @product highcharts
  2727. * @apioption yAxis.stackLabels.align
  2728. */
  2729. /**
  2730. * A [format string](http://docs.highcharts.com/#formatting) for the
  2731. * data label. Available variables are the same as for `formatter`.
  2732. *
  2733. * @type {string}
  2734. * @default {total}
  2735. * @since 3.0.2
  2736. * @product highcharts highstock
  2737. * @apioption yAxis.stackLabels.format
  2738. */
  2739. /**
  2740. * Rotation of the labels in degrees.
  2741. *
  2742. * @sample {highcharts} highcharts/yaxis/stacklabels-rotation/
  2743. * Labels rotated 45°
  2744. *
  2745. * @type {number}
  2746. * @default 0
  2747. * @since 2.1.5
  2748. * @product highcharts
  2749. * @apioption yAxis.stackLabels.rotation
  2750. */
  2751. /**
  2752. * The text alignment for the label. While `align` determines where the
  2753. * texts anchor point is placed with regards to the stack, `textAlign`
  2754. * determines how the text is aligned against its anchor point. Possible
  2755. * values are `"left"`, `"center"` and `"right"`. The default value is
  2756. * calculated at runtime and depends on orientation and whether the
  2757. * stack is positive or negative.
  2758. *
  2759. * @sample {highcharts} highcharts/yaxis/stacklabels-textalign-left/
  2760. * Label in center position but text-aligned left
  2761. *
  2762. * @type {Highcharts.AlignValue}
  2763. * @since 2.1.5
  2764. * @product highcharts
  2765. * @apioption yAxis.stackLabels.textAlign
  2766. */
  2767. /**
  2768. * Whether to [use HTML](https://www.highcharts.com/docs/chart-concepts/labels-and-string-formatting#html)
  2769. * to render the labels.
  2770. *
  2771. * @type {boolean}
  2772. * @default false
  2773. * @since 3.0
  2774. * @product highcharts highstock
  2775. * @apioption yAxis.stackLabels.useHTML
  2776. */
  2777. /**
  2778. * Defines the vertical alignment of the stack total label. Can be one
  2779. * of `"top"`, `"middle"` or `"bottom"`. The default value is calculated
  2780. * at runtime and depends on orientation and whether the stack is
  2781. * positive or negative.
  2782. *
  2783. * @sample {highcharts} highcharts/yaxis/stacklabels-verticalalign-top/
  2784. * Vertically aligned top
  2785. * @sample {highcharts} highcharts/yaxis/stacklabels-verticalalign-middle/
  2786. * Vertically aligned middle
  2787. * @sample {highcharts} highcharts/yaxis/stacklabels-verticalalign-bottom/
  2788. * Vertically aligned bottom
  2789. *
  2790. * @type {Highcharts.VerticalAlignValue}
  2791. * @since 2.1.5
  2792. * @product highcharts
  2793. * @apioption yAxis.stackLabels.verticalAlign
  2794. */
  2795. /**
  2796. * The x position offset of the label relative to the left of the
  2797. * stacked bar. The default value is calculated at runtime and depends
  2798. * on orientation and whether the stack is positive or negative.
  2799. *
  2800. * @sample {highcharts} highcharts/yaxis/stacklabels-x/
  2801. * Stack total labels with x offset
  2802. *
  2803. * @type {number}
  2804. * @since 2.1.5
  2805. * @product highcharts
  2806. * @apioption yAxis.stackLabels.x
  2807. */
  2808. /**
  2809. * The y position offset of the label relative to the tick position
  2810. * on the axis. The default value is calculated at runtime and depends
  2811. * on orientation and whether the stack is positive or negative.
  2812. *
  2813. * @sample {highcharts} highcharts/yaxis/stacklabels-y/
  2814. * Stack total labels with y offset
  2815. *
  2816. * @type {number}
  2817. * @since 2.1.5
  2818. * @product highcharts
  2819. * @apioption yAxis.stackLabels.y
  2820. */
  2821. /**
  2822. * Whether to force the axis to start on a tick. Use this option with
  2823. * the `maxPadding` option to control the axis start.
  2824. *
  2825. * @sample {highcharts} highcharts/xaxis/startontick-false/
  2826. * False by default
  2827. * @sample {highcharts} highcharts/xaxis/startontick-true/
  2828. * True
  2829. * @sample {highstock} stock/xaxis/endontick/
  2830. * False for Y axis
  2831. *
  2832. * @since 1.2.0
  2833. * @product highcharts highstock gantt
  2834. */
  2835. startOnTick: true,
  2836. title: {
  2837. /**
  2838. * The pixel distance between the axis labels and the title.
  2839. * Positive values are outside the axis line, negative are inside.
  2840. *
  2841. * @sample {highcharts} highcharts/xaxis/title-margin/
  2842. * Y axis title margin of 60
  2843. *
  2844. * @type {number}
  2845. * @default 40
  2846. * @apioption yAxis.title.margin
  2847. */
  2848. /**
  2849. * The rotation of the text in degrees. 0 is horizontal, 270 is
  2850. * vertical reading from bottom to top.
  2851. *
  2852. * @sample {highcharts} highcharts/yaxis/title-offset/
  2853. * Horizontal
  2854. */
  2855. rotation: 270,
  2856. /**
  2857. * The actual text of the axis title. Horizontal texts can contain
  2858. * HTML, but rotated texts are painted using vector techniques and
  2859. * must be clean text. The Y axis title is disabled by setting the
  2860. * `text` option to `undefined`.
  2861. *
  2862. * @sample {highcharts} highcharts/xaxis/title-text/
  2863. * Custom HTML
  2864. *
  2865. * @type {string|null}
  2866. * @default {highcharts} Values
  2867. * @default {highstock} undefined
  2868. * @product highcharts highstock gantt
  2869. */
  2870. text: 'Values'
  2871. },
  2872. /**
  2873. * The top position of the Y axis. If it's a number, it is interpreted
  2874. * as pixel position relative to the chart.
  2875. *
  2876. * Since Highcharts 2: If it's a percentage string, it is interpreted as
  2877. * percentages of the plot height, offset from plot area top.
  2878. *
  2879. * @see [yAxis.height](#yAxis.height)
  2880. *
  2881. * @sample {highstock} stock/demo/candlestick-and-volume/
  2882. * Percentage height panes
  2883. *
  2884. * @type {number|string}
  2885. * @product highcharts highstock
  2886. * @apioption yAxis.top
  2887. */
  2888. /**
  2889. * The stack labels show the total value for each bar in a stacked
  2890. * column or bar chart. The label will be placed on top of positive
  2891. * columns and below negative columns. In case of an inverted column
  2892. * chart or a bar chart the label is placed to the right of positive
  2893. * bars and to the left of negative bars.
  2894. *
  2895. * @product highcharts
  2896. */
  2897. stackLabels: {
  2898. /**
  2899. * Allow the stack labels to overlap.
  2900. *
  2901. * @sample {highcharts} highcharts/yaxis/stacklabels-allowoverlap-false/
  2902. * Default false
  2903. *
  2904. * @since 5.0.13
  2905. * @product highcharts
  2906. */
  2907. allowOverlap: false,
  2908. /**
  2909. * Enable or disable the stack total labels.
  2910. *
  2911. * @sample {highcharts} highcharts/yaxis/stacklabels-enabled/
  2912. * Enabled stack total labels
  2913. * @sample {highcharts} highcharts/yaxis/stacklabels-enabled-waterfall/
  2914. * Enabled stack labels in waterfall chart
  2915. *
  2916. * @since 2.1.5
  2917. * @product highcharts
  2918. */
  2919. enabled: false,
  2920. /**
  2921. * Whether to hide stack labels that are outside the plot area.
  2922. * By default, the stack label is moved
  2923. * inside the plot area according to the
  2924. * [overflow](/highcharts/#yAxis/stackLabels/overflow)
  2925. * option.
  2926. *
  2927. * @type {boolean}
  2928. * @since 7.1.3
  2929. */
  2930. crop: true,
  2931. /**
  2932. * How to handle stack total labels that flow outside the plot area.
  2933. * The default is set to `"justify"`,
  2934. * which aligns them inside the plot area.
  2935. * For columns and bars, this means it will be moved inside the bar.
  2936. * To display stack labels outside the plot area,
  2937. * set `crop` to `false` and `overflow` to `"allow"`.
  2938. *
  2939. * @sample highcharts/yaxis/stacklabels-overflow/
  2940. * Stack labels flows outside the plot area.
  2941. *
  2942. * @type {Highcharts.DataLabelsOverflowValue}
  2943. * @since 7.1.3
  2944. */
  2945. overflow: 'justify',
  2946. /* eslint-disable valid-jsdoc */
  2947. /**
  2948. * Callback JavaScript function to format the label. The value is
  2949. * given by `this.total`.
  2950. *
  2951. * @sample {highcharts} highcharts/yaxis/stacklabels-formatter/
  2952. * Added units to stack total value
  2953. *
  2954. * @type {Highcharts.FormatterCallbackFunction<Highcharts.StackItemObject>}
  2955. * @since 2.1.5
  2956. * @product highcharts
  2957. */
  2958. formatter: function () {
  2959. var numberFormatter = this.axis.chart.numberFormatter;
  2960. /* eslint-enable valid-jsdoc */
  2961. return numberFormatter(this.total, -1);
  2962. },
  2963. /**
  2964. * CSS styles for the label.
  2965. *
  2966. * In styled mode, the styles are set in the
  2967. * `.highcharts-stack-label` class.
  2968. *
  2969. * @sample {highcharts} highcharts/yaxis/stacklabels-style/
  2970. * Red stack total labels
  2971. *
  2972. * @type {Highcharts.CSSObject}
  2973. * @since 2.1.5
  2974. * @product highcharts
  2975. */
  2976. style: {
  2977. /** @internal */
  2978. color: '#000000',
  2979. /** @internal */
  2980. fontSize: '11px',
  2981. /** @internal */
  2982. fontWeight: 'bold',
  2983. /** @internal */
  2984. textOutline: '1px contrast'
  2985. }
  2986. },
  2987. gridLineWidth: 1,
  2988. lineWidth: 0
  2989. // tickWidth: 0
  2990. },
  2991. /**
  2992. * The Z axis or depth axis for 3D plots.
  2993. *
  2994. * See the [Axis class](/class-reference/Highcharts.Axis) for programmatic
  2995. * access to the axis.
  2996. *
  2997. * @sample {highcharts} highcharts/3d/scatter-zaxis-categories/
  2998. * Z-Axis with Categories
  2999. * @sample {highcharts} highcharts/3d/scatter-zaxis-grid/
  3000. * Z-Axis with styling
  3001. *
  3002. * @type {*|Array<*>}
  3003. * @extends xAxis
  3004. * @since 5.0.0
  3005. * @product highcharts
  3006. * @excluding breaks, crosshair, height, left, lineColor, lineWidth,
  3007. * nameToX, showEmpty, top, width
  3008. * @apioption zAxis
  3009. *
  3010. * @private
  3011. */
  3012. // This variable extends the defaultOptions for left axes.
  3013. defaultLeftAxisOptions: {
  3014. labels: {
  3015. x: -15
  3016. },
  3017. title: {
  3018. rotation: 270
  3019. }
  3020. },
  3021. // This variable extends the defaultOptions for right axes.
  3022. defaultRightAxisOptions: {
  3023. labels: {
  3024. x: 15
  3025. },
  3026. title: {
  3027. rotation: 90
  3028. }
  3029. },
  3030. // This variable extends the defaultOptions for bottom axes.
  3031. defaultBottomAxisOptions: {
  3032. labels: {
  3033. autoRotation: [-45],
  3034. x: 0
  3035. // overflow: undefined,
  3036. // staggerLines: null
  3037. },
  3038. margin: 15,
  3039. title: {
  3040. rotation: 0
  3041. }
  3042. },
  3043. // This variable extends the defaultOptions for top axes.
  3044. defaultTopAxisOptions: {
  3045. labels: {
  3046. autoRotation: [-45],
  3047. x: 0
  3048. // overflow: undefined
  3049. // staggerLines: null
  3050. },
  3051. margin: 15,
  3052. title: {
  3053. rotation: 0
  3054. }
  3055. },
  3056. /* eslint-disable no-invalid-this, valid-jsdoc */
  3057. /**
  3058. * Overrideable function to initialize the axis.
  3059. *
  3060. * @see {@link Axis}
  3061. *
  3062. * @function Highcharts.Axis#init
  3063. *
  3064. * @param {Highcharts.Chart} chart
  3065. *
  3066. * @param {Highcharts.AxisOptions} userOptions
  3067. *
  3068. * @return {void}
  3069. *
  3070. * @fires Highcharts.Axis#event:afterInit
  3071. * @fires Highcharts.Axis#event:init
  3072. */
  3073. init: function (chart, userOptions) {
  3074. var isXAxis = userOptions.isX, axis = this;
  3075. /**
  3076. * The Chart that the axis belongs to.
  3077. *
  3078. * @name Highcharts.Axis#chart
  3079. * @type {Highcharts.Chart}
  3080. */
  3081. axis.chart = chart;
  3082. /**
  3083. * Whether the axis is horizontal.
  3084. *
  3085. * @name Highcharts.Axis#horiz
  3086. * @type {boolean|undefined}
  3087. */
  3088. axis.horiz = chart.inverted && !axis.isZAxis ? !isXAxis : isXAxis;
  3089. /**
  3090. * Whether the axis is the x-axis.
  3091. *
  3092. * @name Highcharts.Axis#isXAxis
  3093. * @type {boolean|undefined}
  3094. */
  3095. axis.isXAxis = isXAxis;
  3096. /**
  3097. * The collection where the axis belongs, for example `xAxis`, `yAxis`
  3098. * or `colorAxis`. Corresponds to properties on Chart, for example
  3099. * {@link Chart.xAxis}.
  3100. *
  3101. * @name Highcharts.Axis#coll
  3102. * @type {string}
  3103. */
  3104. axis.coll = axis.coll || (isXAxis ? 'xAxis' : 'yAxis');
  3105. fireEvent(this, 'init', { userOptions: userOptions });
  3106. axis.opposite = userOptions.opposite; // needed in setOptions
  3107. /**
  3108. * The side on which the axis is rendered. 0 is top, 1 is right, 2
  3109. * is bottom and 3 is left.
  3110. *
  3111. * @name Highcharts.Axis#side
  3112. * @type {number}
  3113. */
  3114. axis.side = userOptions.side || (axis.horiz ?
  3115. (axis.opposite ? 0 : 2) : // top : bottom
  3116. (axis.opposite ? 1 : 3)); // right : left
  3117. /**
  3118. * Current options for the axis after merge of defaults and user's
  3119. * options.
  3120. *
  3121. * @name Highcharts.Axis#options
  3122. * @type {Highcharts.AxisOptions}
  3123. */
  3124. axis.setOptions(userOptions);
  3125. var options = this.options, type = options.type, isDatetimeAxis = type === 'datetime';
  3126. axis.labelFormatter = options.labels.formatter ||
  3127. // can be overwritten by dynamic format
  3128. axis.defaultLabelFormatter;
  3129. /**
  3130. * User's options for this axis without defaults.
  3131. *
  3132. * @name Highcharts.Axis#userOptions
  3133. * @type {Highcharts.AxisOptions}
  3134. */
  3135. axis.userOptions = userOptions;
  3136. axis.minPixelPadding = 0;
  3137. /**
  3138. * Whether the axis is reversed. Based on the `axis.reversed`,
  3139. * option, but inverted charts have reversed xAxis by default.
  3140. *
  3141. * @name Highcharts.Axis#reversed
  3142. * @type {boolean}
  3143. */
  3144. axis.reversed = options.reversed;
  3145. axis.visible = options.visible !== false;
  3146. axis.zoomEnabled = options.zoomEnabled !== false;
  3147. // Initial categories
  3148. axis.hasNames =
  3149. type === 'category' || options.categories === true;
  3150. /**
  3151. * If categories are present for the axis, names are used instead of
  3152. * numbers for that axis.
  3153. *
  3154. * Since Highcharts 3.0, categories can also be extracted by giving each
  3155. * point a name and setting axis type to `category`. However, if you
  3156. * have multiple series, best practice remains defining the `categories`
  3157. * array.
  3158. *
  3159. * @see [xAxis.categories](/highcharts/xAxis.categories)
  3160. *
  3161. * @name Highcharts.Axis#categories
  3162. * @type {Array<string>}
  3163. * @readonly
  3164. */
  3165. axis.categories = options.categories || axis.hasNames;
  3166. if (!axis.names) { // Preserve on update (#3830)
  3167. axis.names = [];
  3168. axis.names.keys = {};
  3169. }
  3170. // Placeholder for plotlines and plotbands groups
  3171. axis.plotLinesAndBandsGroups = {};
  3172. // Shorthand types
  3173. axis.isLog = type === 'logarithmic';
  3174. axis.isDatetimeAxis = isDatetimeAxis;
  3175. axis.positiveValuesOnly = axis.isLog && !axis.allowNegativeLog;
  3176. // Flag, if axis is linked to another axis
  3177. axis.isLinked = defined(options.linkedTo);
  3178. /**
  3179. * List of major ticks mapped by postition on axis.
  3180. *
  3181. * @see {@link Highcharts.Tick}
  3182. *
  3183. * @name Highcharts.Axis#ticks
  3184. * @type {Highcharts.Dictionary<Highcharts.Tick>}
  3185. */
  3186. axis.ticks = {};
  3187. axis.labelEdge = [];
  3188. /**
  3189. * List of minor ticks mapped by position on the axis.
  3190. *
  3191. * @see {@link Highcharts.Tick}
  3192. *
  3193. * @name Highcharts.Axis#minorTicks
  3194. * @type {Highcharts.Dictionary<Highcharts.Tick>}
  3195. */
  3196. axis.minorTicks = {};
  3197. // List of plotLines/Bands
  3198. axis.plotLinesAndBands = [];
  3199. // Alternate bands
  3200. axis.alternateBands = {};
  3201. // Axis metrics
  3202. axis.len = 0;
  3203. axis.minRange = axis.userMinRange = options.minRange || options.maxZoom;
  3204. axis.range = options.range;
  3205. axis.offset = options.offset || 0;
  3206. // Dictionary for stacks
  3207. axis.stacks = {};
  3208. axis.oldStacks = {};
  3209. axis.stacksTouched = 0;
  3210. /**
  3211. * The maximum value of the axis. In a logarithmic axis, this is the
  3212. * logarithm of the real value, and the real value can be obtained from
  3213. * {@link Axis#getExtremes}.
  3214. *
  3215. * @name Highcharts.Axis#max
  3216. * @type {number|null}
  3217. */
  3218. axis.max = null;
  3219. /**
  3220. * The minimum value of the axis. In a logarithmic axis, this is the
  3221. * logarithm of the real value, and the real value can be obtained from
  3222. * {@link Axis#getExtremes}.
  3223. *
  3224. * @name Highcharts.Axis#min
  3225. * @type {number|null}
  3226. */
  3227. axis.min = null;
  3228. /**
  3229. * The processed crosshair options.
  3230. *
  3231. * @name Highcharts.Axis#crosshair
  3232. * @type {boolean|Highcharts.AxisCrosshairOptions}
  3233. */
  3234. axis.crosshair = pick(options.crosshair, splat(chart.options.tooltip.crosshairs)[isXAxis ? 0 : 1], false);
  3235. var events = axis.options.events;
  3236. // Register. Don't add it again on Axis.update().
  3237. if (chart.axes.indexOf(axis) === -1) { //
  3238. if (isXAxis) { // #2713
  3239. chart.axes.splice(chart.xAxis.length, 0, axis);
  3240. }
  3241. else {
  3242. chart.axes.push(axis);
  3243. }
  3244. chart[axis.coll].push(axis);
  3245. }
  3246. /**
  3247. * All series associated to the axis.
  3248. *
  3249. * @name Highcharts.Axis#series
  3250. * @type {Array<Highcharts.Series>}
  3251. */
  3252. axis.series = axis.series || []; // populated by Series
  3253. // Reversed axis
  3254. if (chart.inverted &&
  3255. !axis.isZAxis &&
  3256. isXAxis &&
  3257. typeof axis.reversed === 'undefined') {
  3258. axis.reversed = true;
  3259. }
  3260. // register event listeners
  3261. objectEach(events, function (event, eventType) {
  3262. if (H.isFunction(event)) {
  3263. addEvent(axis, eventType, event);
  3264. }
  3265. });
  3266. // extend logarithmic axis
  3267. axis.lin2log = options.linearToLogConverter || axis.lin2log;
  3268. if (axis.isLog) {
  3269. axis.val2lin = axis.log2lin;
  3270. axis.lin2val = axis.lin2log;
  3271. }
  3272. fireEvent(this, 'afterInit');
  3273. },
  3274. /**
  3275. * Merge and set options.
  3276. *
  3277. * @private
  3278. * @function Highcharts.Axis#setOptions
  3279. * @param {Highcharts.AxisOptions} userOptions
  3280. * @return {void}
  3281. * @fires Highcharts.Axis#event:afterSetOptions
  3282. */
  3283. setOptions: function (userOptions) {
  3284. this.options = merge(this.defaultOptions, (this.coll === 'yAxis') && this.defaultYAxisOptions, [
  3285. this.defaultTopAxisOptions,
  3286. this.defaultRightAxisOptions,
  3287. this.defaultBottomAxisOptions,
  3288. this.defaultLeftAxisOptions
  3289. ][this.side], merge(
  3290. // if set in setOptions (#1053):
  3291. defaultOptions[this.coll], userOptions));
  3292. fireEvent(this, 'afterSetOptions', { userOptions: userOptions });
  3293. },
  3294. /**
  3295. * The default label formatter. The context is a special config object for
  3296. * the label. In apps, use the
  3297. * [labels.formatter](https://api.highcharts.com/highcharts/xAxis.labels.formatter)
  3298. * instead, except when a modification is needed.
  3299. *
  3300. * @function Highcharts.Axis#defaultLabelFormatter
  3301. *
  3302. * @this Highcharts.AxisLabelsFormatterContextObject
  3303. *
  3304. * @return {string}
  3305. * The formatted label content.
  3306. */
  3307. defaultLabelFormatter: function () {
  3308. var axis = this.axis, value = this.value, time = axis.chart.time, categories = axis.categories, dateTimeLabelFormat = this.dateTimeLabelFormat, lang = defaultOptions.lang, numericSymbols = lang.numericSymbols, numSymMagnitude = lang.numericSymbolMagnitude || 1000, i = numericSymbols && numericSymbols.length, multi, ret, formatOption = axis.options.labels.format,
  3309. // make sure the same symbol is added for all labels on a linear
  3310. // axis
  3311. numericSymbolDetector = axis.isLog ?
  3312. Math.abs(value) :
  3313. axis.tickInterval;
  3314. var chart = this.chart;
  3315. var numberFormatter = chart.numberFormatter;
  3316. if (formatOption) {
  3317. ret = format(formatOption, this, chart);
  3318. }
  3319. else if (categories) {
  3320. ret = value;
  3321. }
  3322. else if (dateTimeLabelFormat) { // datetime axis
  3323. ret = time.dateFormat(dateTimeLabelFormat, value);
  3324. }
  3325. else if (i && numericSymbolDetector >= 1000) {
  3326. // Decide whether we should add a numeric symbol like k (thousands)
  3327. // or M (millions). If we are to enable this in tooltip or other
  3328. // places as well, we can move this logic to the numberFormatter and
  3329. // enable it by a parameter.
  3330. while (i-- && typeof ret === 'undefined') {
  3331. multi = Math.pow(numSymMagnitude, i + 1);
  3332. if (
  3333. // Only accept a numeric symbol when the distance is more
  3334. // than a full unit. So for example if the symbol is k, we
  3335. // don't accept numbers like 0.5k.
  3336. numericSymbolDetector >= multi &&
  3337. // Accept one decimal before the symbol. Accepts 0.5k but
  3338. // not 0.25k. How does this work with the previous?
  3339. (value * 10) % multi === 0 &&
  3340. numericSymbols[i] !== null &&
  3341. value !== 0) { // #5480
  3342. ret = numberFormatter(value / multi, -1) +
  3343. numericSymbols[i];
  3344. }
  3345. }
  3346. }
  3347. if (typeof ret === 'undefined') {
  3348. if (Math.abs(value) >= 10000) { // add thousands separators
  3349. ret = numberFormatter(value, -1);
  3350. }
  3351. else { // small numbers
  3352. ret = numberFormatter(value, -1, void 0, ''); // #2466
  3353. }
  3354. }
  3355. return ret;
  3356. },
  3357. /**
  3358. * Get the minimum and maximum for the series of each axis. The function
  3359. * analyzes the axis series and updates `this.dataMin` and `this.dataMax`.
  3360. * @private
  3361. * @fires Highcharts.Axis#event:afterGetSeriesExtremes
  3362. * @fires Highcharts.Axis#event:getSeriesExtremes
  3363. */
  3364. getSeriesExtremes: function () {
  3365. var axis = this, chart = axis.chart, xExtremes;
  3366. fireEvent(this, 'getSeriesExtremes', null, function () {
  3367. axis.hasVisibleSeries = false;
  3368. // Reset properties in case we're redrawing (#3353)
  3369. axis.dataMin = axis.dataMax = axis.threshold = null;
  3370. axis.softThreshold = !axis.isXAxis;
  3371. if (axis.buildStacks) {
  3372. axis.buildStacks();
  3373. }
  3374. // loop through this axis' series
  3375. axis.series.forEach(function (series) {
  3376. if (series.visible ||
  3377. !chart.options.chart.ignoreHiddenSeries) {
  3378. var seriesOptions = series.options, xData, threshold = seriesOptions.threshold, seriesDataMin, seriesDataMax;
  3379. axis.hasVisibleSeries = true;
  3380. // Validate threshold in logarithmic axes
  3381. if (axis.positiveValuesOnly && threshold <= 0) {
  3382. threshold = null;
  3383. }
  3384. // Get dataMin and dataMax for X axes
  3385. if (axis.isXAxis) {
  3386. xData = series.xData;
  3387. if (xData.length) {
  3388. xExtremes = series.getXExtremes(xData);
  3389. // If xData contains values which is not numbers,
  3390. // then filter them out. To prevent performance hit,
  3391. // we only do this after we have already found
  3392. // seriesDataMin because in most cases all data is
  3393. // valid. #5234.
  3394. seriesDataMin = xExtremes.min;
  3395. seriesDataMax = xExtremes.max;
  3396. if (!isNumber(seriesDataMin) &&
  3397. // #5010:
  3398. !(seriesDataMin instanceof Date)) {
  3399. xData = xData.filter(isNumber);
  3400. xExtremes = series.getXExtremes(xData);
  3401. // Do it again with valid data
  3402. seriesDataMin = xExtremes.min;
  3403. seriesDataMax = xExtremes.max;
  3404. }
  3405. if (xData.length) {
  3406. axis.dataMin = Math.min(pick(axis.dataMin, seriesDataMin), seriesDataMin);
  3407. axis.dataMax = Math.max(pick(axis.dataMax, seriesDataMax), seriesDataMax);
  3408. }
  3409. }
  3410. // Get dataMin and dataMax for Y axes, as well as handle
  3411. // stacking and processed data
  3412. }
  3413. else {
  3414. // Get this particular series extremes
  3415. series.getExtremes();
  3416. seriesDataMax = series.dataMax;
  3417. seriesDataMin = series.dataMin;
  3418. // Get the dataMin and dataMax so far. If percentage is
  3419. // used, the min and max are always 0 and 100. If
  3420. // seriesDataMin and seriesDataMax is null, then series
  3421. // doesn't have active y data, we continue with nulls
  3422. if (defined(seriesDataMin) && defined(seriesDataMax)) {
  3423. axis.dataMin = Math.min(pick(axis.dataMin, seriesDataMin), seriesDataMin);
  3424. axis.dataMax = Math.max(pick(axis.dataMax, seriesDataMax), seriesDataMax);
  3425. }
  3426. // Adjust to threshold
  3427. if (defined(threshold)) {
  3428. axis.threshold = threshold;
  3429. }
  3430. // If any series has a hard threshold, it takes
  3431. // precedence
  3432. if (!seriesOptions.softThreshold ||
  3433. axis.positiveValuesOnly) {
  3434. axis.softThreshold = false;
  3435. }
  3436. }
  3437. }
  3438. });
  3439. });
  3440. fireEvent(this, 'afterGetSeriesExtremes');
  3441. },
  3442. /**
  3443. * Translate from axis value to pixel position on the chart, or back. Use
  3444. * the `toPixels` and `toValue` functions in applications.
  3445. * @private
  3446. * @return {number|undefined}
  3447. */
  3448. translate: function (val, backwards, cvsCoord, old, handleLog, pointPlacement) {
  3449. var axis = this.linkedParent || this, // #1417
  3450. sign = 1, cvsOffset = 0, localA = old ? axis.oldTransA : axis.transA, localMin = old ? axis.oldMin : axis.min, returnValue = 0, minPixelPadding = axis.minPixelPadding, doPostTranslate = (axis.isOrdinal ||
  3451. axis.isBroken ||
  3452. (axis.isLog && handleLog)) && axis.lin2val;
  3453. if (!localA) {
  3454. localA = axis.transA;
  3455. }
  3456. // In vertical axes, the canvas coordinates start from 0 at the top like
  3457. // in SVG.
  3458. if (cvsCoord) {
  3459. sign *= -1; // canvas coordinates inverts the value
  3460. cvsOffset = axis.len;
  3461. }
  3462. // Handle reversed axis
  3463. if (axis.reversed) {
  3464. sign *= -1;
  3465. cvsOffset -= sign * (axis.sector || axis.len);
  3466. }
  3467. // From pixels to value
  3468. if (backwards) { // reverse translation
  3469. val = val * sign + cvsOffset;
  3470. val -= minPixelPadding;
  3471. // from chart pixel to value:
  3472. returnValue = val / localA + localMin;
  3473. if (doPostTranslate) { // log and ordinal axes
  3474. returnValue = axis.lin2val(returnValue);
  3475. }
  3476. // From value to pixels
  3477. }
  3478. else {
  3479. if (doPostTranslate) { // log and ordinal axes
  3480. val = axis.val2lin(val);
  3481. }
  3482. returnValue = isNumber(localMin) ?
  3483. (sign * (val - localMin) * localA +
  3484. cvsOffset +
  3485. (sign * minPixelPadding) +
  3486. (isNumber(pointPlacement) ?
  3487. localA * pointPlacement :
  3488. 0)) :
  3489. void 0;
  3490. }
  3491. return returnValue;
  3492. },
  3493. /**
  3494. * Translate a value in terms of axis units into pixels within the chart.
  3495. *
  3496. * @function Highcharts.Axis#toPixels
  3497. *
  3498. * @param {number} value
  3499. * A value in terms of axis units.
  3500. *
  3501. * @param {boolean} paneCoordinates
  3502. * Whether to return the pixel coordinate relative to the chart or
  3503. * just the axis/pane itself.
  3504. *
  3505. * @return {number}
  3506. * Pixel position of the value on the chart or axis.
  3507. */
  3508. toPixels: function (value, paneCoordinates) {
  3509. return this.translate(value, false, !this.horiz, null, true) +
  3510. (paneCoordinates ? 0 : this.pos);
  3511. },
  3512. /**
  3513. * Translate a pixel position along the axis to a value in terms of axis
  3514. * units.
  3515. *
  3516. * @function Highcharts.Axis#toValue
  3517. *
  3518. * @param {number} pixel
  3519. * The pixel value coordinate.
  3520. *
  3521. * @param {boolean} [paneCoordiantes=false]
  3522. * Whether the input pixel is relative to the chart or just the
  3523. * axis/pane itself.
  3524. *
  3525. * @return {number}
  3526. * The axis value.
  3527. */
  3528. toValue: function (pixel, paneCoordinates) {
  3529. return this.translate(pixel - (paneCoordinates ? 0 : this.pos), true, !this.horiz, null, true);
  3530. },
  3531. /**
  3532. * Create the path for a plot line that goes from the given value on
  3533. * this axis, across the plot to the opposite side. Also used internally for
  3534. * grid lines and crosshairs.
  3535. *
  3536. * @function Highcharts.Axis#getPlotLinePath
  3537. *
  3538. * @param {Highcharts.AxisPlotLinePathOptionsObject} options
  3539. * Options for the path.
  3540. *
  3541. * @return {Highcharts.SVGPathArray|null}
  3542. * The SVG path definition for the plot line.
  3543. */
  3544. getPlotLinePath: function (options) {
  3545. var axis = this, chart = axis.chart, axisLeft = axis.left, axisTop = axis.top, old = options.old, value = options.value, translatedValue = options.translatedValue, lineWidth = options.lineWidth, force = options.force, x1, y1, x2, y2, cHeight = (old && chart.oldChartHeight) || chart.chartHeight, cWidth = (old && chart.oldChartWidth) || chart.chartWidth, skip, transB = axis.transB, evt,
  3546. /**
  3547. * Check if x is between a and b. If not, either move to a/b
  3548. * or skip, depending on the force parameter.
  3549. */
  3550. between = function (x, a, b) {
  3551. if (force !== 'pass' && x < a || x > b) {
  3552. if (force) {
  3553. x = clamp(x, a, b);
  3554. }
  3555. else {
  3556. skip = true;
  3557. }
  3558. }
  3559. return x;
  3560. };
  3561. evt = {
  3562. value: value,
  3563. lineWidth: lineWidth,
  3564. old: old,
  3565. force: force,
  3566. acrossPanes: options.acrossPanes,
  3567. translatedValue: translatedValue
  3568. };
  3569. fireEvent(this, 'getPlotLinePath', evt, function (e) {
  3570. translatedValue = pick(translatedValue, axis.translate(value, null, null, old));
  3571. // Keep the translated value within sane bounds, and avoid Infinity
  3572. // to fail the isNumber test (#7709).
  3573. translatedValue = clamp(translatedValue, -1e5, 1e5);
  3574. x1 = x2 = Math.round(translatedValue + transB);
  3575. y1 = y2 = Math.round(cHeight - translatedValue - transB);
  3576. if (!isNumber(translatedValue)) { // no min or max
  3577. skip = true;
  3578. force = false; // #7175, don't force it when path is invalid
  3579. }
  3580. else if (axis.horiz) {
  3581. y1 = axisTop;
  3582. y2 = cHeight - axis.bottom;
  3583. x1 = x2 = between(x1, axisLeft, axisLeft + axis.width);
  3584. }
  3585. else {
  3586. x1 = axisLeft;
  3587. x2 = cWidth - axis.right;
  3588. y1 = y2 = between(y1, axisTop, axisTop + axis.height);
  3589. }
  3590. e.path = skip && !force ?
  3591. null :
  3592. chart.renderer.crispLine(['M', x1, y1, 'L', x2, y2], lineWidth || 1);
  3593. });
  3594. return evt.path;
  3595. },
  3596. /**
  3597. * Internal function to et the tick positions of a linear axis to round
  3598. * values like whole tens or every five.
  3599. *
  3600. * @function Highcharts.Axis#getLinearTickPositions
  3601. *
  3602. * @param {number} tickInterval
  3603. * The normalized tick interval.
  3604. *
  3605. * @param {number} min
  3606. * Axis minimum.
  3607. *
  3608. * @param {number} max
  3609. * Axis maximum.
  3610. *
  3611. * @return {Array<number>}
  3612. * An array of axis values where ticks should be placed.
  3613. */
  3614. getLinearTickPositions: function (tickInterval, min, max) {
  3615. var pos, lastPos, roundedMin = correctFloat(Math.floor(min / tickInterval) * tickInterval), roundedMax = correctFloat(Math.ceil(max / tickInterval) * tickInterval), tickPositions = [], precision;
  3616. // When the precision is higher than what we filter out in
  3617. // correctFloat, skip it (#6183).
  3618. if (correctFloat(roundedMin + tickInterval) === roundedMin) {
  3619. precision = 20;
  3620. }
  3621. // For single points, add a tick regardless of the relative position
  3622. // (#2662, #6274)
  3623. if (this.single) {
  3624. return [min];
  3625. }
  3626. // Populate the intermediate values
  3627. pos = roundedMin;
  3628. while (pos <= roundedMax) {
  3629. // Place the tick on the rounded value
  3630. tickPositions.push(pos);
  3631. // Always add the raw tickInterval, not the corrected one.
  3632. pos = correctFloat(pos + tickInterval, precision);
  3633. // If the interval is not big enough in the current min - max range
  3634. // to actually increase the loop variable, we need to break out to
  3635. // prevent endless loop. Issue #619
  3636. if (pos === lastPos) {
  3637. break;
  3638. }
  3639. // Record the last value
  3640. lastPos = pos;
  3641. }
  3642. return tickPositions;
  3643. },
  3644. /**
  3645. * Resolve the new minorTicks/minorTickInterval options into the legacy
  3646. * loosely typed minorTickInterval option.
  3647. *
  3648. * @function Highcharts.Axis#getMinorTickInterval
  3649. * @return {number|"auto"|null}
  3650. */
  3651. getMinorTickInterval: function () {
  3652. var options = this.options;
  3653. if (options.minorTicks === true) {
  3654. return pick(options.minorTickInterval, 'auto');
  3655. }
  3656. if (options.minorTicks === false) {
  3657. return null;
  3658. }
  3659. return options.minorTickInterval;
  3660. },
  3661. /**
  3662. * Internal function to return the minor tick positions. For logarithmic
  3663. * axes, the same logic as for major ticks is reused.
  3664. *
  3665. * @function Highcharts.Axis#getMinorTickPositions
  3666. *
  3667. * @return {Array<number>}
  3668. * An array of axis values where ticks should be placed.
  3669. */
  3670. getMinorTickPositions: function () {
  3671. var axis = this, options = axis.options, tickPositions = axis.tickPositions, minorTickInterval = axis.minorTickInterval, minorTickPositions = [], pos, pointRangePadding = axis.pointRangePadding || 0, min = axis.min - pointRangePadding, // #1498
  3672. max = axis.max + pointRangePadding, // #1498
  3673. range = max - min;
  3674. // If minor ticks get too dense, they are hard to read, and may cause
  3675. // long running script. So we don't draw them.
  3676. if (range && range / minorTickInterval < axis.len / 3) { // #3875
  3677. if (axis.isLog) {
  3678. // For each interval in the major ticks, compute the minor ticks
  3679. // separately.
  3680. this.paddedTicks.forEach(function (pos, i, paddedTicks) {
  3681. if (i) {
  3682. minorTickPositions.push.apply(minorTickPositions, axis.getLogTickPositions(minorTickInterval, paddedTicks[i - 1], paddedTicks[i], true));
  3683. }
  3684. });
  3685. }
  3686. else if (axis.isDatetimeAxis &&
  3687. this.getMinorTickInterval() === 'auto') { // #1314
  3688. minorTickPositions = minorTickPositions.concat(axis.getTimeTicks(axis.normalizeTimeTickInterval(minorTickInterval), min, max, options.startOfWeek));
  3689. }
  3690. else {
  3691. for (pos = min + (tickPositions[0] - min) % minorTickInterval; pos <= max; pos += minorTickInterval) {
  3692. // Very, very, tight grid lines (#5771)
  3693. if (pos === minorTickPositions[0]) {
  3694. break;
  3695. }
  3696. minorTickPositions.push(pos);
  3697. }
  3698. }
  3699. }
  3700. if (minorTickPositions.length !== 0) {
  3701. axis.trimTicks(minorTickPositions); // #3652 #3743 #1498 #6330
  3702. }
  3703. return minorTickPositions;
  3704. },
  3705. /**
  3706. * Adjust the min and max for the minimum range. Keep in mind that the
  3707. * series data is not yet processed, so we don't have information on data
  3708. * cropping and grouping, or updated `axis.pointRange` or
  3709. * `series.pointRange`. The data can't be processed until we have finally
  3710. * established min and max.
  3711. * @private
  3712. */
  3713. adjustForMinRange: function () {
  3714. var axis = this, options = axis.options, min = axis.min, max = axis.max, zoomOffset, spaceAvailable, closestDataRange, i, distance, xData, loopLength, minArgs, maxArgs, minRange;
  3715. // Set the automatic minimum range based on the closest point distance
  3716. if (axis.isXAxis &&
  3717. typeof axis.minRange === 'undefined' &&
  3718. !axis.isLog) {
  3719. if (defined(options.min) || defined(options.max)) {
  3720. axis.minRange = null; // don't do this again
  3721. }
  3722. else {
  3723. // Find the closest distance between raw data points, as opposed
  3724. // to closestPointRange that applies to processed points
  3725. // (cropped and grouped)
  3726. axis.series.forEach(function (series) {
  3727. xData = series.xData;
  3728. loopLength = series.xIncrement ? 1 : xData.length - 1;
  3729. for (i = loopLength; i > 0; i--) {
  3730. distance = xData[i] - xData[i - 1];
  3731. if (typeof closestDataRange === 'undefined' ||
  3732. distance < closestDataRange) {
  3733. closestDataRange = distance;
  3734. }
  3735. }
  3736. });
  3737. axis.minRange = Math.min(closestDataRange * 5, axis.dataMax - axis.dataMin);
  3738. }
  3739. }
  3740. // if minRange is exceeded, adjust
  3741. if (max - min < axis.minRange) {
  3742. spaceAvailable =
  3743. axis.dataMax - axis.dataMin >=
  3744. axis.minRange;
  3745. minRange = axis.minRange;
  3746. zoomOffset = (minRange - max + min) / 2;
  3747. // if min and max options have been set, don't go beyond it
  3748. minArgs = [
  3749. min - zoomOffset,
  3750. pick(options.min, min - zoomOffset)
  3751. ];
  3752. // If space is available, stay within the data range
  3753. if (spaceAvailable) {
  3754. minArgs[2] = axis.isLog ?
  3755. axis.log2lin(axis.dataMin) :
  3756. axis.dataMin;
  3757. }
  3758. min = arrayMax(minArgs);
  3759. maxArgs = [
  3760. min + minRange,
  3761. pick(options.max, min + minRange)
  3762. ];
  3763. // If space is availabe, stay within the data range
  3764. if (spaceAvailable) {
  3765. maxArgs[2] = axis.isLog ?
  3766. axis.log2lin(axis.dataMax) :
  3767. axis.dataMax;
  3768. }
  3769. max = arrayMin(maxArgs);
  3770. // now if the max is adjusted, adjust the min back
  3771. if (max - min < minRange) {
  3772. minArgs[0] = max - minRange;
  3773. minArgs[1] = pick(options.min, max - minRange);
  3774. min = arrayMax(minArgs);
  3775. }
  3776. }
  3777. // Record modified extremes
  3778. axis.min = min;
  3779. axis.max = max;
  3780. },
  3781. /**
  3782. * Find the closestPointRange across all series.
  3783. * @private
  3784. */
  3785. getClosest: function () {
  3786. var ret;
  3787. if (this.categories) {
  3788. ret = 1;
  3789. }
  3790. else {
  3791. this.series.forEach(function (series) {
  3792. var seriesClosest = series.closestPointRange, visible = series.visible ||
  3793. !series.chart.options.chart.ignoreHiddenSeries;
  3794. if (!series.noSharedTooltip &&
  3795. defined(seriesClosest) &&
  3796. visible) {
  3797. ret = defined(ret) ?
  3798. Math.min(ret, seriesClosest) :
  3799. seriesClosest;
  3800. }
  3801. });
  3802. }
  3803. return ret;
  3804. },
  3805. /**
  3806. * When a point name is given and no x, search for the name in the existing
  3807. * categories, or if categories aren't provided, search names or create a
  3808. * new category (#2522).
  3809. * @private
  3810. * @param {Highcharts.Point} point The point to inspect.
  3811. * @return {number} The X value that the point is given.
  3812. */
  3813. nameToX: function (point) {
  3814. var explicitCategories = isArray(this.categories), names = explicitCategories ? this.categories : this.names, nameX = point.options.x, x;
  3815. point.series.requireSorting = false;
  3816. if (!defined(nameX)) {
  3817. nameX = this.options.uniqueNames === false ?
  3818. point.series.autoIncrement() :
  3819. (explicitCategories ?
  3820. names.indexOf(point.name) :
  3821. pick(names.keys[point.name], -1));
  3822. }
  3823. if (nameX === -1) { // Not found in currenct categories
  3824. if (!explicitCategories) {
  3825. x = names.length;
  3826. }
  3827. }
  3828. else {
  3829. x = nameX;
  3830. }
  3831. // Write the last point's name to the names array
  3832. if (typeof x !== 'undefined') {
  3833. this.names[x] = point.name;
  3834. // Backwards mapping is much faster than array searching (#7725)
  3835. this.names.keys[point.name] = x;
  3836. }
  3837. return x;
  3838. },
  3839. /**
  3840. * When changes have been done to series data, update the axis.names.
  3841. * @private
  3842. */
  3843. updateNames: function () {
  3844. var axis = this, names = this.names, i = names.length;
  3845. if (i > 0) {
  3846. Object.keys(names.keys).forEach(function (key) {
  3847. delete (names.keys)[key];
  3848. });
  3849. names.length = 0;
  3850. this.minRange = this.userMinRange; // Reset
  3851. (this.series || []).forEach(function (series) {
  3852. // Reset incrementer (#5928)
  3853. series.xIncrement = null;
  3854. // When adding a series, points are not yet generated
  3855. if (!series.points || series.isDirtyData) {
  3856. // When we're updating the series with data that is longer
  3857. // than it was, and cropThreshold is passed, we need to make
  3858. // sure that the axis.max is increased _before_ running the
  3859. // premature processData. Otherwise this early iteration of
  3860. // processData will crop the points to axis.max, and the
  3861. // names array will be too short (#5857).
  3862. axis.max = Math.max(axis.max, series.xData.length - 1);
  3863. series.processData();
  3864. series.generatePoints();
  3865. }
  3866. series.data.forEach(function (point, i) {
  3867. var x;
  3868. if (point &&
  3869. point.options &&
  3870. typeof point.name !== 'undefined' // #9562
  3871. ) {
  3872. x = axis.nameToX(point);
  3873. if (typeof x !== 'undefined' && x !== point.x) {
  3874. point.x = x;
  3875. series.xData[i] = x;
  3876. }
  3877. }
  3878. });
  3879. });
  3880. }
  3881. },
  3882. /**
  3883. * Update translation information.
  3884. * @private
  3885. * @param {boolean} [saveOld]
  3886. * @fires Highcharts.Axis#event:afterSetAxisTranslation
  3887. */
  3888. setAxisTranslation: function (saveOld) {
  3889. var axis = this, range = axis.max - axis.min, pointRange = axis.axisPointRange || 0, closestPointRange, minPointOffset = 0, pointRangePadding = 0, linkedParent = axis.linkedParent, ordinalCorrection, hasCategories = !!axis.categories, transA = axis.transA, isXAxis = axis.isXAxis;
  3890. // Adjust translation for padding. Y axis with categories need to go
  3891. // through the same (#1784).
  3892. if (isXAxis || hasCategories || pointRange) {
  3893. // Get the closest points
  3894. closestPointRange = axis.getClosest();
  3895. if (linkedParent) {
  3896. minPointOffset = linkedParent.minPointOffset;
  3897. pointRangePadding = linkedParent.pointRangePadding;
  3898. }
  3899. else {
  3900. axis.series.forEach(function (series) {
  3901. var seriesPointRange = hasCategories ?
  3902. 1 :
  3903. (isXAxis ?
  3904. pick(series.options.pointRange, closestPointRange, 0) :
  3905. (axis.axisPointRange || 0)), // #2806
  3906. pointPlacement = series.options.pointPlacement;
  3907. pointRange = Math.max(pointRange, seriesPointRange);
  3908. if (!axis.single || hasCategories) {
  3909. // TODO: series should internally set x- and y-
  3910. // pointPlacement to simplify this logic.
  3911. var isPointPlacementAxis = (seriesTypes.xrange &&
  3912. series instanceof seriesTypes.xrange) ? !isXAxis : isXAxis;
  3913. // minPointOffset is the value padding to the left of
  3914. // the axis in order to make room for points with a
  3915. // pointRange, typically columns. When the
  3916. // pointPlacement option is 'between' or 'on', this
  3917. // padding does not apply.
  3918. minPointOffset = Math.max(minPointOffset, isPointPlacementAxis && isString(pointPlacement) ?
  3919. 0 :
  3920. seriesPointRange / 2);
  3921. // Determine the total padding needed to the length of
  3922. // the axis to make room for the pointRange. If the
  3923. // series' pointPlacement is 'on', no padding is added.
  3924. pointRangePadding = Math.max(pointRangePadding, isPointPlacementAxis && pointPlacement === 'on' ?
  3925. 0 :
  3926. seriesPointRange);
  3927. }
  3928. });
  3929. }
  3930. // Record minPointOffset and pointRangePadding
  3931. ordinalCorrection = axis.ordinalSlope && closestPointRange ?
  3932. axis.ordinalSlope / closestPointRange :
  3933. 1; // #988, #1853
  3934. axis.minPointOffset = minPointOffset =
  3935. minPointOffset * ordinalCorrection;
  3936. axis.pointRangePadding =
  3937. pointRangePadding = pointRangePadding * ordinalCorrection;
  3938. // pointRange means the width reserved for each point, like in a
  3939. // column chart
  3940. axis.pointRange = Math.min(pointRange, axis.single && hasCategories ? 1 : range);
  3941. // closestPointRange means the closest distance between points. In
  3942. // columns it is mostly equal to pointRange, but in lines pointRange
  3943. // is 0 while closestPointRange is some other value
  3944. if (isXAxis) {
  3945. axis.closestPointRange = closestPointRange;
  3946. }
  3947. }
  3948. // Secondary values
  3949. if (saveOld) {
  3950. axis.oldTransA = transA;
  3951. }
  3952. axis.translationSlope = axis.transA = transA =
  3953. axis.staticScale ||
  3954. axis.len / ((range + pointRangePadding) || 1);
  3955. // Translation addend
  3956. axis.transB = axis.horiz ? axis.left : axis.bottom;
  3957. axis.minPixelPadding = transA * minPointOffset;
  3958. fireEvent(this, 'afterSetAxisTranslation');
  3959. },
  3960. /**
  3961. * @private
  3962. * @return {number}
  3963. */
  3964. minFromRange: function () {
  3965. return this.max - this.range;
  3966. },
  3967. /**
  3968. * Set the tick positions to round values and optionally extend the extremes
  3969. * to the nearest tick.
  3970. * @private
  3971. * @param {boolean} secondPass
  3972. * @fires Highcharts.Axis#event:foundExtremes
  3973. */
  3974. setTickInterval: function (secondPass) {
  3975. var axis = this, chart = axis.chart, options = axis.options, isLog = axis.isLog, isDatetimeAxis = axis.isDatetimeAxis, isXAxis = axis.isXAxis, isLinked = axis.isLinked, maxPadding = options.maxPadding, minPadding = options.minPadding, length, linkedParentExtremes, tickIntervalOption = options.tickInterval, minTickInterval, tickPixelIntervalOption = options.tickPixelInterval, categories = axis.categories, threshold = isNumber(axis.threshold) ? axis.threshold : null, softThreshold = axis.softThreshold, thresholdMin, thresholdMax, hardMin, hardMax;
  3976. if (!isDatetimeAxis && !categories && !isLinked) {
  3977. this.getTickAmount();
  3978. }
  3979. // Min or max set either by zooming/setExtremes or initial options
  3980. hardMin = pick(axis.userMin, options.min);
  3981. hardMax = pick(axis.userMax, options.max);
  3982. // Linked axis gets the extremes from the parent axis
  3983. if (isLinked) {
  3984. axis.linkedParent = chart[axis.coll][options.linkedTo];
  3985. linkedParentExtremes = axis.linkedParent.getExtremes();
  3986. axis.min = pick(linkedParentExtremes.min, linkedParentExtremes.dataMin);
  3987. axis.max = pick(linkedParentExtremes.max, linkedParentExtremes.dataMax);
  3988. if (options.type !== axis.linkedParent.options.type) {
  3989. // Can't link axes of different type
  3990. H.error(11, 1, chart);
  3991. }
  3992. // Initial min and max from the extreme data values
  3993. }
  3994. else {
  3995. // Adjust to hard threshold
  3996. if (!softThreshold && defined(threshold)) {
  3997. if (axis.dataMin >= threshold) {
  3998. thresholdMin = threshold;
  3999. minPadding = 0;
  4000. }
  4001. else if (axis.dataMax <= threshold) {
  4002. thresholdMax = threshold;
  4003. maxPadding = 0;
  4004. }
  4005. }
  4006. axis.min = pick(hardMin, thresholdMin, axis.dataMin);
  4007. axis.max = pick(hardMax, thresholdMax, axis.dataMax);
  4008. }
  4009. if (isLog) {
  4010. if (axis.positiveValuesOnly &&
  4011. !secondPass &&
  4012. Math.min(axis.min, pick(axis.dataMin, axis.min)) <= 0) { // #978
  4013. // Can't plot negative values on log axis
  4014. H.error(10, 1, chart);
  4015. }
  4016. // The correctFloat cures #934, float errors on full tens. But it
  4017. // was too aggressive for #4360 because of conversion back to lin,
  4018. // therefore use precision 15.
  4019. axis.min = correctFloat(axis.log2lin(axis.min), 16);
  4020. axis.max = correctFloat(axis.log2lin(axis.max), 16);
  4021. }
  4022. // handle zoomed range
  4023. if (axis.range && defined(axis.max)) {
  4024. // #618, #6773:
  4025. axis.userMin = axis.min = hardMin =
  4026. Math.max(axis.dataMin, axis.minFromRange());
  4027. axis.userMax = hardMax = axis.max;
  4028. axis.range = null; // don't use it when running setExtremes
  4029. }
  4030. // Hook for Highstock Scroller. Consider combining with beforePadding.
  4031. fireEvent(axis, 'foundExtremes');
  4032. // Hook for adjusting this.min and this.max. Used by bubble series.
  4033. if (axis.beforePadding) {
  4034. axis.beforePadding();
  4035. }
  4036. // adjust min and max for the minimum range
  4037. axis.adjustForMinRange();
  4038. // Pad the values to get clear of the chart's edges. To avoid
  4039. // tickInterval taking the padding into account, we do this after
  4040. // computing tick interval (#1337).
  4041. if (!categories &&
  4042. !axis.axisPointRange &&
  4043. !axis.usePercentage &&
  4044. !isLinked &&
  4045. defined(axis.min) &&
  4046. defined(axis.max)) {
  4047. length = axis.max - axis.min;
  4048. if (length) {
  4049. if (!defined(hardMin) && minPadding) {
  4050. axis.min -= length * minPadding;
  4051. }
  4052. if (!defined(hardMax) && maxPadding) {
  4053. axis.max += length * maxPadding;
  4054. }
  4055. }
  4056. }
  4057. // Handle options for floor, ceiling, softMin and softMax (#6359)
  4058. if (!isNumber(axis.userMin)) {
  4059. if (isNumber(options.softMin) && options.softMin < axis.min) {
  4060. axis.min = hardMin = options.softMin; // #6894
  4061. }
  4062. if (isNumber(options.floor)) {
  4063. axis.min = Math.max(axis.min, options.floor);
  4064. }
  4065. }
  4066. if (!isNumber(axis.userMax)) {
  4067. if (isNumber(options.softMax) && options.softMax > axis.max) {
  4068. axis.max = hardMax = options.softMax; // #6894
  4069. }
  4070. if (isNumber(options.ceiling)) {
  4071. axis.max = Math.min(axis.max, options.ceiling);
  4072. }
  4073. }
  4074. // When the threshold is soft, adjust the extreme value only if the data
  4075. // extreme and the padded extreme land on either side of the threshold.
  4076. // For example, a series of [0, 1, 2, 3] would make the yAxis add a tick
  4077. // for -1 because of the default minPadding and startOnTick options.
  4078. // This is prevented by the softThreshold option.
  4079. if (softThreshold && defined(axis.dataMin)) {
  4080. threshold = threshold || 0;
  4081. if (!defined(hardMin) &&
  4082. axis.min < threshold &&
  4083. axis.dataMin >= threshold) {
  4084. axis.min = axis.options.minRange ?
  4085. Math.min(threshold, axis.max -
  4086. axis.minRange) :
  4087. threshold;
  4088. }
  4089. else if (!defined(hardMax) &&
  4090. axis.max > threshold &&
  4091. axis.dataMax <= threshold) {
  4092. axis.max = axis.options.minRange ?
  4093. Math.max(threshold, axis.min +
  4094. axis.minRange) :
  4095. threshold;
  4096. }
  4097. }
  4098. // get tickInterval
  4099. if (axis.min === axis.max ||
  4100. typeof axis.min === 'undefined' ||
  4101. typeof axis.max === 'undefined') {
  4102. axis.tickInterval = 1;
  4103. }
  4104. else if (isLinked &&
  4105. !tickIntervalOption &&
  4106. tickPixelIntervalOption ===
  4107. axis.linkedParent.options.tickPixelInterval) {
  4108. axis.tickInterval = tickIntervalOption =
  4109. axis.linkedParent.tickInterval;
  4110. }
  4111. else {
  4112. axis.tickInterval = pick(tickIntervalOption, this.tickAmount ?
  4113. ((axis.max - axis.min) /
  4114. Math.max(this.tickAmount - 1, 1)) :
  4115. void 0,
  4116. // For categoried axis, 1 is default, for linear axis use
  4117. // tickPix
  4118. categories ?
  4119. 1 :
  4120. // don't let it be more than the data range
  4121. (axis.max - axis.min) *
  4122. tickPixelIntervalOption /
  4123. Math.max(axis.len, tickPixelIntervalOption));
  4124. }
  4125. // Now we're finished detecting min and max, crop and group series data.
  4126. // This is in turn needed in order to find tick positions in ordinal
  4127. // axes.
  4128. if (isXAxis && !secondPass) {
  4129. axis.series.forEach(function (series) {
  4130. series.processData(axis.min !== axis.oldMin || axis.max !== axis.oldMax);
  4131. });
  4132. }
  4133. // set the translation factor used in translate function
  4134. axis.setAxisTranslation(true);
  4135. // hook for ordinal axes and radial axes
  4136. if (axis.beforeSetTickPositions) {
  4137. axis.beforeSetTickPositions();
  4138. }
  4139. // hook for extensions, used in Highstock ordinal axes
  4140. if (axis.postProcessTickInterval) {
  4141. axis.tickInterval = axis.postProcessTickInterval(axis.tickInterval);
  4142. }
  4143. // In column-like charts, don't cramp in more ticks than there are
  4144. // points (#1943, #4184)
  4145. if (axis.pointRange && !tickIntervalOption) {
  4146. axis.tickInterval = Math.max(axis.pointRange, axis.tickInterval);
  4147. }
  4148. // Before normalizing the tick interval, handle minimum tick interval.
  4149. // This applies only if tickInterval is not defined.
  4150. minTickInterval = pick(options.minTickInterval, (axis.isDatetimeAxis && axis.closestPointRange));
  4151. if (!tickIntervalOption && axis.tickInterval < minTickInterval) {
  4152. axis.tickInterval = minTickInterval;
  4153. }
  4154. // for linear axes, get magnitude and normalize the interval
  4155. if (!isDatetimeAxis && !isLog && !tickIntervalOption) {
  4156. axis.tickInterval = normalizeTickInterval(axis.tickInterval, null, getMagnitude(axis.tickInterval),
  4157. // If the tick interval is between 0.5 and 5 and the axis max is
  4158. // in the order of thousands, chances are we are dealing with
  4159. // years. Don't allow decimals. #3363.
  4160. pick(options.allowDecimals, !(axis.tickInterval > 0.5 &&
  4161. axis.tickInterval < 5 &&
  4162. axis.max > 1000 &&
  4163. axis.max < 9999)), !!this.tickAmount);
  4164. }
  4165. // Prevent ticks from getting so close that we can't draw the labels
  4166. if (!this.tickAmount) {
  4167. axis.tickInterval = axis.unsquish();
  4168. }
  4169. this.setTickPositions();
  4170. },
  4171. /**
  4172. * Now we have computed the normalized tickInterval, get the tick positions
  4173. *
  4174. * @function Highcharts.Axis#setTickPositions
  4175. *
  4176. * @fires Highcharts.Axis#event:afterSetTickPositions
  4177. */
  4178. setTickPositions: function () {
  4179. var options = this.options, tickPositions, tickPositionsOption = options.tickPositions, minorTickIntervalOption = this.getMinorTickInterval(), tickPositioner = options.tickPositioner, startOnTick = options.startOnTick, endOnTick = options.endOnTick;
  4180. // Set the tickmarkOffset
  4181. this.tickmarkOffset = (this.categories &&
  4182. options.tickmarkPlacement === 'between' &&
  4183. this.tickInterval === 1) ? 0.5 : 0; // #3202
  4184. // get minorTickInterval
  4185. this.minorTickInterval =
  4186. minorTickIntervalOption === 'auto' &&
  4187. this.tickInterval ?
  4188. this.tickInterval / 5 :
  4189. minorTickIntervalOption;
  4190. // When there is only one point, or all points have the same value on
  4191. // this axis, then min and max are equal and tickPositions.length is 0
  4192. // or 1. In this case, add some padding in order to center the point,
  4193. // but leave it with one tick. #1337.
  4194. this.single =
  4195. this.min === this.max &&
  4196. defined(this.min) &&
  4197. !this.tickAmount &&
  4198. (
  4199. // Data is on integer (#6563)
  4200. parseInt(this.min, 10) === this.min ||
  4201. // Between integers and decimals are not allowed (#6274)
  4202. options.allowDecimals !== false);
  4203. /**
  4204. * Contains the current positions that are laid out on the axis. The
  4205. * positions are numbers in terms of axis values. In a category axis
  4206. * they are integers, in a datetime axis they are also integers, but
  4207. * designating milliseconds.
  4208. *
  4209. * This property is read only - for modifying the tick positions, use
  4210. * the `tickPositioner` callback or [axis.tickPositions(
  4211. * https://api.highcharts.com/highcharts/xAxis.tickPositions) option
  4212. * instead.
  4213. *
  4214. * @name Highcharts.Axis#tickPositions
  4215. * @type {Array<number>|undefined}
  4216. */
  4217. this.tickPositions =
  4218. // Find the tick positions. Work on a copy (#1565)
  4219. tickPositions =
  4220. (tickPositionsOption && tickPositionsOption.slice());
  4221. if (!tickPositions) {
  4222. // Too many ticks (#6405). Create a friendly warning and provide two
  4223. // ticks so at least we can show the data series.
  4224. if (!this.ordinalPositions &&
  4225. ((this.max - this.min) /
  4226. this.tickInterval >
  4227. Math.max(2 * this.len, 200))) {
  4228. tickPositions = [this.min, this.max];
  4229. H.error(19, false, this.chart);
  4230. }
  4231. else if (this.isDatetimeAxis) {
  4232. tickPositions = this.getTimeTicks(this.normalizeTimeTickInterval(this.tickInterval, options.units), this.min, this.max, options.startOfWeek, this.ordinalPositions, this.closestPointRange, true);
  4233. }
  4234. else if (this.isLog) {
  4235. tickPositions = this.getLogTickPositions(this.tickInterval, this.min, this.max);
  4236. }
  4237. else {
  4238. tickPositions = this.getLinearTickPositions(this.tickInterval, this.min, this.max);
  4239. }
  4240. // Too dense ticks, keep only the first and last (#4477)
  4241. if (tickPositions.length > this.len) {
  4242. tickPositions = [tickPositions[0], tickPositions.pop()];
  4243. // Reduce doubled value (#7339)
  4244. if (tickPositions[0] === tickPositions[1]) {
  4245. tickPositions.length = 1;
  4246. }
  4247. }
  4248. this.tickPositions = tickPositions;
  4249. // Run the tick positioner callback, that allows modifying auto tick
  4250. // positions.
  4251. if (tickPositioner) {
  4252. tickPositioner = tickPositioner.apply(this, [this.min, this.max]);
  4253. if (tickPositioner) {
  4254. this.tickPositions = tickPositions = tickPositioner;
  4255. }
  4256. }
  4257. }
  4258. // Reset min/max or remove extremes based on start/end on tick
  4259. this.paddedTicks = tickPositions.slice(0); // Used for logarithmic minor
  4260. this.trimTicks(tickPositions, startOnTick, endOnTick);
  4261. if (!this.isLinked) {
  4262. // Substract half a unit (#2619, #2846, #2515, #3390),
  4263. // but not in case of multiple ticks (#6897)
  4264. if (this.single && tickPositions.length < 2 && !this.categories) {
  4265. this.min -= 0.5;
  4266. this.max += 0.5;
  4267. }
  4268. if (!tickPositionsOption && !tickPositioner) {
  4269. this.adjustTickAmount();
  4270. }
  4271. }
  4272. fireEvent(this, 'afterSetTickPositions');
  4273. },
  4274. /**
  4275. * Handle startOnTick and endOnTick by either adapting to padding min/max or
  4276. * rounded min/max. Also handle single data points.
  4277. * @private
  4278. */
  4279. trimTicks: function (tickPositions, startOnTick, endOnTick) {
  4280. var roundedMin = tickPositions[0], roundedMax = tickPositions[tickPositions.length - 1], minPointOffset = this.minPointOffset || 0;
  4281. fireEvent(this, 'trimTicks');
  4282. if (!this.isLinked) {
  4283. if (startOnTick && roundedMin !== -Infinity) { // #6502
  4284. this.min = roundedMin;
  4285. }
  4286. else {
  4287. while (this.min - minPointOffset > tickPositions[0]) {
  4288. tickPositions.shift();
  4289. }
  4290. }
  4291. if (endOnTick) {
  4292. this.max = roundedMax;
  4293. }
  4294. else {
  4295. while (this.max + minPointOffset <
  4296. tickPositions[tickPositions.length - 1]) {
  4297. tickPositions.pop();
  4298. }
  4299. }
  4300. // If no tick are left, set one tick in the middle (#3195)
  4301. if (tickPositions.length === 0 &&
  4302. defined(roundedMin) &&
  4303. !this.options.tickPositions) {
  4304. tickPositions.push((roundedMax + roundedMin) / 2);
  4305. }
  4306. }
  4307. },
  4308. /**
  4309. * Check if there are multiple axes in the same pane.
  4310. * @private
  4311. * @return {boolean|undefined} True if there are other axes.
  4312. */
  4313. alignToOthers: function () {
  4314. var others = // Whether there is another axis to pair with this one
  4315. {}, hasOther, options = this.options;
  4316. if (
  4317. // Only if alignTicks is true
  4318. this.chart.options.chart.alignTicks !== false &&
  4319. options.alignTicks !== false &&
  4320. // Disabled when startOnTick or endOnTick are false (#7604)
  4321. options.startOnTick !== false &&
  4322. options.endOnTick !== false &&
  4323. // Don't try to align ticks on a log axis, they are not evenly
  4324. // spaced (#6021)
  4325. !this.isLog) {
  4326. this.chart[this.coll].forEach(function (axis) {
  4327. var otherOptions = axis.options, horiz = axis.horiz, key = [
  4328. horiz ? otherOptions.left : otherOptions.top,
  4329. otherOptions.width,
  4330. otherOptions.height,
  4331. otherOptions.pane
  4332. ].join(',');
  4333. if (axis.series.length) { // #4442
  4334. if (others[key]) {
  4335. hasOther = true; // #4201
  4336. }
  4337. else {
  4338. others[key] = 1;
  4339. }
  4340. }
  4341. });
  4342. }
  4343. return hasOther;
  4344. },
  4345. /**
  4346. * Find the max ticks of either the x and y axis collection, and record it
  4347. * in `this.tickAmount`.
  4348. * @private
  4349. * @return {void}
  4350. */
  4351. getTickAmount: function () {
  4352. var options = this.options, tickAmount = options.tickAmount, tickPixelInterval = options.tickPixelInterval;
  4353. if (!defined(options.tickInterval) &&
  4354. this.len < tickPixelInterval &&
  4355. !this.isRadial &&
  4356. !this.isLog &&
  4357. options.startOnTick &&
  4358. options.endOnTick) {
  4359. tickAmount = 2;
  4360. }
  4361. if (!tickAmount && this.alignToOthers()) {
  4362. // Add 1 because 4 tick intervals require 5 ticks (including first
  4363. // and last)
  4364. tickAmount = Math.ceil(this.len / tickPixelInterval) + 1;
  4365. }
  4366. // For tick amounts of 2 and 3, compute five ticks and remove the
  4367. // intermediate ones. This prevents the axis from adding ticks that are
  4368. // too far away from the data extremes.
  4369. if (tickAmount < 4) {
  4370. this.finalTickAmt = tickAmount;
  4371. tickAmount = 5;
  4372. }
  4373. this.tickAmount = tickAmount;
  4374. },
  4375. /**
  4376. * When using multiple axes, adjust the number of ticks to match the highest
  4377. * number of ticks in that group.
  4378. * @private
  4379. * @return {void}
  4380. */
  4381. adjustTickAmount: function () {
  4382. var axis = this, axisOptions = axis.options, tickInterval = axis.tickInterval, tickPositions = axis.tickPositions, tickAmount = axis.tickAmount, finalTickAmt = axis.finalTickAmt, currentTickAmount = tickPositions && tickPositions.length, threshold = pick(axis.threshold, axis.softThreshold ? 0 : null), min, len, i;
  4383. if (axis.hasData()) {
  4384. if (currentTickAmount < tickAmount) {
  4385. min = axis.min;
  4386. while (tickPositions.length < tickAmount) {
  4387. // Extend evenly for both sides unless we're on the
  4388. // threshold (#3965)
  4389. if (tickPositions.length % 2 ||
  4390. min === threshold) {
  4391. // to the end
  4392. tickPositions.push(correctFloat(tickPositions[tickPositions.length - 1] +
  4393. tickInterval));
  4394. }
  4395. else {
  4396. // to the start
  4397. tickPositions.unshift(correctFloat(tickPositions[0] - tickInterval));
  4398. }
  4399. }
  4400. axis.transA *= (currentTickAmount - 1) / (tickAmount - 1);
  4401. // Do not crop when ticks are not extremes (#9841)
  4402. axis.min = axisOptions.startOnTick ?
  4403. tickPositions[0] :
  4404. Math.min(axis.min, tickPositions[0]);
  4405. axis.max = axisOptions.endOnTick ?
  4406. tickPositions[tickPositions.length - 1] :
  4407. Math.max(axis.max, tickPositions[tickPositions.length - 1]);
  4408. // We have too many ticks, run second pass to try to reduce ticks
  4409. }
  4410. else if (currentTickAmount > tickAmount) {
  4411. axis.tickInterval *= 2;
  4412. axis.setTickPositions();
  4413. }
  4414. // The finalTickAmt property is set in getTickAmount
  4415. if (defined(finalTickAmt)) {
  4416. i = len = tickPositions.length;
  4417. while (i--) {
  4418. if (
  4419. // Remove every other tick
  4420. (finalTickAmt === 3 && i % 2 === 1) ||
  4421. // Remove all but first and last
  4422. (finalTickAmt <= 2 && i > 0 && i < len - 1)) {
  4423. tickPositions.splice(i, 1);
  4424. }
  4425. }
  4426. axis.finalTickAmt = void 0;
  4427. }
  4428. }
  4429. },
  4430. /**
  4431. * Set the scale based on data min and max, user set min and max or options.
  4432. * @private
  4433. * @return {void}
  4434. * @fires Highcharts.Axis#event:afterSetScale
  4435. */
  4436. setScale: function () {
  4437. var axis = this, isDirtyData = axis.series.some(function (series) {
  4438. return (series.isDirtyData ||
  4439. series.isDirty ||
  4440. // When x axis is dirty, we need new data extremes for y as
  4441. // well:
  4442. series.xAxis && series.xAxis.isDirty);
  4443. }), isDirtyAxisLength;
  4444. axis.oldMin = axis.min;
  4445. axis.oldMax = axis.max;
  4446. axis.oldAxisLength = axis.len;
  4447. // set the new axisLength
  4448. axis.setAxisSize();
  4449. isDirtyAxisLength = axis.len !== axis.oldAxisLength;
  4450. // do we really need to go through all this?
  4451. if (isDirtyAxisLength ||
  4452. isDirtyData ||
  4453. axis.isLinked ||
  4454. axis.forceRedraw ||
  4455. axis.userMin !== axis.oldUserMin ||
  4456. axis.userMax !== axis.oldUserMax ||
  4457. axis.alignToOthers()) {
  4458. if (axis.resetStacks) {
  4459. axis.resetStacks();
  4460. }
  4461. axis.forceRedraw = false;
  4462. // get data extremes if needed
  4463. axis.getSeriesExtremes();
  4464. // get fixed positions based on tickInterval
  4465. axis.setTickInterval();
  4466. // record old values to decide whether a rescale is necessary later
  4467. // on (#540)
  4468. axis.oldUserMin = axis.userMin;
  4469. axis.oldUserMax = axis.userMax;
  4470. // Mark as dirty if it is not already set to dirty and extremes have
  4471. // changed. #595.
  4472. if (!axis.isDirty) {
  4473. axis.isDirty =
  4474. isDirtyAxisLength ||
  4475. axis.min !== axis.oldMin ||
  4476. axis.max !== axis.oldMax;
  4477. }
  4478. }
  4479. else if (axis.cleanStacks) {
  4480. axis.cleanStacks();
  4481. }
  4482. fireEvent(this, 'afterSetScale');
  4483. },
  4484. /**
  4485. * Set the minimum and maximum of the axes after render time. If the
  4486. * `startOnTick` and `endOnTick` options are true, the minimum and maximum
  4487. * values are rounded off to the nearest tick. To prevent this, these
  4488. * options can be set to false before calling setExtremes. Also, setExtremes
  4489. * will not allow a range lower than the `minRange` option, which by default
  4490. * is the range of five points.
  4491. *
  4492. * @sample highcharts/members/axis-setextremes/
  4493. * Set extremes from a button
  4494. * @sample highcharts/members/axis-setextremes-datetime/
  4495. * Set extremes on a datetime axis
  4496. * @sample highcharts/members/axis-setextremes-off-ticks/
  4497. * Set extremes off ticks
  4498. * @sample stock/members/axis-setextremes/
  4499. * Set extremes in Highstock
  4500. * @sample maps/members/axis-setextremes/
  4501. * Set extremes in Highmaps
  4502. *
  4503. * @function Highcharts.Axis#setExtremes
  4504. *
  4505. * @param {number} [newMin]
  4506. * The new minimum value.
  4507. *
  4508. * @param {number} [newMax]
  4509. * The new maximum value.
  4510. *
  4511. * @param {boolean} [redraw=true]
  4512. * Whether to redraw the chart or wait for an explicit call to
  4513. * {@link Highcharts.Chart#redraw}
  4514. *
  4515. * @param {boolean|Highcharts.AnimationOptionsObject} [animation=true]
  4516. * Enable or modify animations.
  4517. *
  4518. * @param {*} [eventArguments]
  4519. * Arguments to be accessed in event handler.
  4520. *
  4521. * @return {void}
  4522. *
  4523. * @fires Highcharts.Axis#event:setExtremes
  4524. */
  4525. setExtremes: function (newMin, newMax, redraw, animation, eventArguments) {
  4526. var axis = this, chart = axis.chart;
  4527. redraw = pick(redraw, true); // defaults to true
  4528. axis.series.forEach(function (serie) {
  4529. delete serie.kdTree;
  4530. });
  4531. // Extend the arguments with min and max
  4532. eventArguments = extend(eventArguments, {
  4533. min: newMin,
  4534. max: newMax
  4535. });
  4536. // Fire the event
  4537. fireEvent(axis, 'setExtremes', eventArguments, function () {
  4538. axis.userMin = newMin;
  4539. axis.userMax = newMax;
  4540. axis.eventArgs = eventArguments;
  4541. if (redraw) {
  4542. chart.redraw(animation);
  4543. }
  4544. });
  4545. },
  4546. /**
  4547. * Overridable method for zooming chart. Pulled out in a separate method to
  4548. * allow overriding in stock charts.
  4549. * @private
  4550. * @function Highcharts.Axis#zoom
  4551. * @param {number} newMin
  4552. * @param {number} newMax
  4553. * @return {boolean}
  4554. */
  4555. zoom: function (newMin, newMax) {
  4556. var dataMin = this.dataMin, dataMax = this.dataMax, options = this.options, min = Math.min(dataMin, pick(options.min, dataMin)), max = Math.max(dataMax, pick(options.max, dataMax)), evt = {
  4557. newMin: newMin,
  4558. newMax: newMax
  4559. };
  4560. fireEvent(this, 'zoom', evt, function (e) {
  4561. // Use e.newMin and e.newMax - event handlers may have altered them
  4562. var newMin = e.newMin, newMax = e.newMax;
  4563. if (newMin !== this.min || newMax !== this.max) { // #5790
  4564. // Prevent pinch zooming out of range. Check for defined is for
  4565. // #1946. #1734.
  4566. if (!this.allowZoomOutside) {
  4567. // #6014, sometimes newMax will be smaller than min (or
  4568. // newMin will be larger than max).
  4569. if (defined(dataMin)) {
  4570. if (newMin < min) {
  4571. newMin = min;
  4572. }
  4573. if (newMin > max) {
  4574. newMin = max;
  4575. }
  4576. }
  4577. if (defined(dataMax)) {
  4578. if (newMax < min) {
  4579. newMax = min;
  4580. }
  4581. if (newMax > max) {
  4582. newMax = max;
  4583. }
  4584. }
  4585. }
  4586. // In full view, displaying the reset zoom button is not
  4587. // required
  4588. this.displayBtn = (typeof newMin !== 'undefined' ||
  4589. typeof newMax !== 'undefined');
  4590. // Do it
  4591. this.setExtremes(newMin, newMax, false, void 0, { trigger: 'zoom' });
  4592. }
  4593. e.zoomed = true;
  4594. });
  4595. return evt.zoomed;
  4596. },
  4597. /**
  4598. * Update the axis metrics.
  4599. * @private
  4600. * @return {void}
  4601. */
  4602. setAxisSize: function () {
  4603. var chart = this.chart, options = this.options,
  4604. // [top, right, bottom, left]
  4605. offsets = options.offsets || [0, 0, 0, 0], horiz = this.horiz,
  4606. // Check for percentage based input values. Rounding fixes problems
  4607. // with column overflow and plot line filtering (#4898, #4899)
  4608. width = this.width = Math.round(relativeLength(pick(options.width, chart.plotWidth - offsets[3] + offsets[1]), chart.plotWidth)), height = this.height = Math.round(relativeLength(pick(options.height, chart.plotHeight - offsets[0] + offsets[2]), chart.plotHeight)), top = this.top = Math.round(relativeLength(pick(options.top, chart.plotTop + offsets[0]), chart.plotHeight, chart.plotTop)), left = this.left = Math.round(relativeLength(pick(options.left, chart.plotLeft + offsets[3]), chart.plotWidth, chart.plotLeft));
  4609. // Expose basic values to use in Series object and navigator
  4610. this.bottom = chart.chartHeight - height - top;
  4611. this.right = chart.chartWidth - width - left;
  4612. // Direction agnostic properties
  4613. this.len = Math.max(horiz ? width : height, 0); // Math.max fixes #905
  4614. this.pos = horiz ? left : top; // distance from SVG origin
  4615. },
  4616. /**
  4617. * Get the current extremes for the axis.
  4618. *
  4619. * @sample highcharts/members/axis-getextremes/
  4620. * Report extremes by click on a button
  4621. * @sample maps/members/axis-getextremes/
  4622. * Get extremes in Highmaps
  4623. *
  4624. * @function Highcharts.Axis#getExtremes
  4625. *
  4626. * @returns {Highcharts.ExtremesObject}
  4627. * An object containing extremes information.
  4628. */
  4629. getExtremes: function () {
  4630. var axis = this, isLog = axis.isLog;
  4631. return {
  4632. min: isLog ?
  4633. correctFloat(axis.lin2log(axis.min)) :
  4634. axis.min,
  4635. max: isLog ?
  4636. correctFloat(axis.lin2log(axis.max)) :
  4637. axis.max,
  4638. dataMin: axis.dataMin,
  4639. dataMax: axis.dataMax,
  4640. userMin: axis.userMin,
  4641. userMax: axis.userMax
  4642. };
  4643. },
  4644. /**
  4645. * Get the zero plane either based on zero or on the min or max value.
  4646. * Used in bar and area plots.
  4647. *
  4648. * @function Highcharts.Axis#getThreshold
  4649. *
  4650. * @param {number} threshold
  4651. * The threshold in axis values.
  4652. *
  4653. * @return {number|undefined}
  4654. * The translated threshold position in terms of pixels, and
  4655. * corrected to stay within the axis bounds.
  4656. */
  4657. getThreshold: function (threshold) {
  4658. var axis = this, isLog = axis.isLog, realMin = isLog ? axis.lin2log(axis.min) : axis.min, realMax = isLog ? axis.lin2log(axis.max) : axis.max;
  4659. if (threshold === null || threshold === -Infinity) {
  4660. threshold = realMin;
  4661. }
  4662. else if (threshold === Infinity) {
  4663. threshold = realMax;
  4664. }
  4665. else if (realMin > threshold) {
  4666. threshold = realMin;
  4667. }
  4668. else if (realMax < threshold) {
  4669. threshold = realMax;
  4670. }
  4671. return axis.translate(threshold, 0, 1, 0, 1);
  4672. },
  4673. /**
  4674. * Compute auto alignment for the axis label based on which side the axis is
  4675. * on and the given rotation for the label.
  4676. * @private
  4677. * @param {number} rotation The rotation in degrees as set by either the
  4678. * `rotation` or `autoRotation` options.
  4679. * @return {Highcharts.AlignValue} Can be `"center"`, `"left"` or `"right"`.
  4680. */
  4681. autoLabelAlign: function (rotation) {
  4682. var angle = (pick(rotation, 0) - (this.side * 90) + 720) % 360, evt = { align: 'center' };
  4683. fireEvent(this, 'autoLabelAlign', evt, function (e) {
  4684. if (angle > 15 && angle < 165) {
  4685. e.align = 'right';
  4686. }
  4687. else if (angle > 195 && angle < 345) {
  4688. e.align = 'left';
  4689. }
  4690. });
  4691. return evt.align;
  4692. },
  4693. /**
  4694. * Get the tick length and width for the axis based on axis options.
  4695. * @private
  4696. * @param {string} [prefix]
  4697. * 'tick' or 'minorTick'
  4698. * @return {Array<number>}
  4699. * An array of tickLength and tickWidth
  4700. */
  4701. tickSize: function (prefix) {
  4702. var options = this.options, tickLength = options[prefix + 'Length'], tickWidth = pick(options[prefix + 'Width'],
  4703. // Default to 1 on linear and datetime X axes
  4704. prefix === 'tick' && this.isXAxis && !this.categories ? 1 : 0), e, tickSize;
  4705. if (tickWidth && tickLength) {
  4706. // Negate the length
  4707. if (options[prefix + 'Position'] === 'inside') {
  4708. tickLength = -tickLength;
  4709. }
  4710. tickSize = [tickLength, tickWidth];
  4711. }
  4712. e = { tickSize: tickSize };
  4713. fireEvent(this, 'afterTickSize', e);
  4714. return e.tickSize;
  4715. },
  4716. /**
  4717. * Return the size of the labels.
  4718. * @private
  4719. * @return {Highcharts.FontMetricsObject}
  4720. */
  4721. labelMetrics: function () {
  4722. var index = this.tickPositions && this.tickPositions[0] || 0;
  4723. return this.chart.renderer.fontMetrics(this.options.labels.style &&
  4724. this.options.labels.style.fontSize, this.ticks[index] && this.ticks[index].label);
  4725. },
  4726. /**
  4727. * Prevent the ticks from getting so close we can't draw the labels. On a
  4728. * horizontal axis, this is handled by rotating the labels, removing ticks
  4729. * and adding ellipsis. On a vertical axis remove ticks and add ellipsis.
  4730. * @private
  4731. * @return {number}
  4732. */
  4733. unsquish: function () {
  4734. var labelOptions = this.options.labels, horiz = this.horiz, tickInterval = this.tickInterval, newTickInterval = tickInterval, slotSize = this.len / (((this.categories ? 1 : 0) +
  4735. this.max -
  4736. this.min) /
  4737. tickInterval), rotation, rotationOption = labelOptions.rotation, labelMetrics = this.labelMetrics(), step, bestScore = Number.MAX_VALUE, autoRotation, range = this.max - this.min,
  4738. // Return the multiple of tickInterval that is needed to avoid
  4739. // collision
  4740. getStep = function (spaceNeeded) {
  4741. var step = spaceNeeded / (slotSize || 1);
  4742. step = step > 1 ? Math.ceil(step) : 1;
  4743. // Guard for very small or negative angles (#9835)
  4744. if (step * tickInterval > range &&
  4745. spaceNeeded !== Infinity &&
  4746. slotSize !== Infinity &&
  4747. range) {
  4748. step = Math.ceil(range / tickInterval);
  4749. }
  4750. return correctFloat(step * tickInterval);
  4751. };
  4752. if (horiz) {
  4753. autoRotation = !labelOptions.staggerLines &&
  4754. !labelOptions.step &&
  4755. ( // #3971
  4756. defined(rotationOption) ?
  4757. [rotationOption] :
  4758. slotSize < pick(labelOptions.autoRotationLimit, 80) && labelOptions.autoRotation);
  4759. if (autoRotation) {
  4760. // Loop over the given autoRotation options, and determine
  4761. // which gives the best score. The best score is that with
  4762. // the lowest number of steps and a rotation closest
  4763. // to horizontal.
  4764. autoRotation.forEach(function (rot) {
  4765. var score;
  4766. if (rot === rotationOption ||
  4767. (rot && rot >= -90 && rot <= 90)) { // #3891
  4768. step = getStep(Math.abs(labelMetrics.h / Math.sin(deg2rad * rot)));
  4769. score = step + Math.abs(rot / 360);
  4770. if (score < bestScore) {
  4771. bestScore = score;
  4772. rotation = rot;
  4773. newTickInterval = step;
  4774. }
  4775. }
  4776. });
  4777. }
  4778. }
  4779. else if (!labelOptions.step) { // #4411
  4780. newTickInterval = getStep(labelMetrics.h);
  4781. }
  4782. this.autoRotation = autoRotation;
  4783. this.labelRotation = pick(rotation, rotationOption);
  4784. return newTickInterval;
  4785. },
  4786. /**
  4787. * Get the general slot width for labels/categories on this axis. This may
  4788. * change between the pre-render (from Axis.getOffset) and the final tick
  4789. * rendering and placement.
  4790. * @private
  4791. * @param {Highcharts.Tick} [tick] Optionally, calculate the slot width
  4792. * basing on tick label. It is used in highcharts-3d module, where the slots
  4793. * has different widths depending on perspective angles.
  4794. * @return {number} The pixel width allocated to each axis label.
  4795. */
  4796. getSlotWidth: function (tick) {
  4797. // #5086, #1580, #1931
  4798. var chart = this.chart, horiz = this.horiz, labelOptions = this.options.labels, slotCount = Math.max(this.tickPositions.length - (this.categories ? 0 : 1), 1), marginLeft = chart.margin[3];
  4799. return (tick &&
  4800. tick.slotWidth // Used by grid axis
  4801. ) || (horiz &&
  4802. (labelOptions.step || 0) < 2 &&
  4803. !labelOptions.rotation && // #4415
  4804. ((this.staggerLines || 1) * this.len) / slotCount) || (!horiz && (
  4805. // #7028
  4806. (labelOptions.style &&
  4807. parseInt(labelOptions.style.width, 10)) ||
  4808. (marginLeft &&
  4809. (marginLeft - chart.spacing[3])) ||
  4810. chart.chartWidth * 0.33));
  4811. },
  4812. /**
  4813. * Render the axis labels and determine whether ellipsis or rotation need to
  4814. * be applied.
  4815. * @private
  4816. * @return {void}
  4817. */
  4818. renderUnsquish: function () {
  4819. var chart = this.chart, renderer = chart.renderer, tickPositions = this.tickPositions, ticks = this.ticks, labelOptions = this.options.labels, labelStyleOptions = (labelOptions && labelOptions.style || {}), horiz = this.horiz, slotWidth = this.getSlotWidth(), innerWidth = Math.max(1, Math.round(slotWidth - 2 * (labelOptions.padding || 5))), attr = {}, labelMetrics = this.labelMetrics(), textOverflowOption = (labelOptions.style &&
  4820. labelOptions.style.textOverflow), commonWidth, commonTextOverflow, maxLabelLength = 0, label, i, pos;
  4821. // Set rotation option unless it is "auto", like in gauges
  4822. if (!isString(labelOptions.rotation)) {
  4823. // #4443:
  4824. attr.rotation = labelOptions.rotation || 0;
  4825. }
  4826. // Get the longest label length
  4827. tickPositions.forEach(function (tick) {
  4828. tick = ticks[tick];
  4829. // Replace label - sorting animation
  4830. if (tick.movedLabel) {
  4831. tick.replaceMovedLabel();
  4832. }
  4833. if (tick &&
  4834. tick.label &&
  4835. tick.label.textPxLength > maxLabelLength) {
  4836. maxLabelLength = tick.label.textPxLength;
  4837. }
  4838. });
  4839. this.maxLabelLength = maxLabelLength;
  4840. // Handle auto rotation on horizontal axis
  4841. if (this.autoRotation) {
  4842. // Apply rotation only if the label is too wide for the slot, and
  4843. // the label is wider than its height.
  4844. if (maxLabelLength > innerWidth &&
  4845. maxLabelLength > labelMetrics.h) {
  4846. attr.rotation = this.labelRotation;
  4847. }
  4848. else {
  4849. this.labelRotation = 0;
  4850. }
  4851. // Handle word-wrap or ellipsis on vertical axis
  4852. }
  4853. else if (slotWidth) {
  4854. // For word-wrap or ellipsis
  4855. commonWidth = innerWidth;
  4856. if (!textOverflowOption) {
  4857. commonTextOverflow = 'clip';
  4858. // On vertical axis, only allow word wrap if there is room
  4859. // for more lines.
  4860. i = tickPositions.length;
  4861. while (!horiz && i--) {
  4862. pos = tickPositions[i];
  4863. label = ticks[pos].label;
  4864. if (label) {
  4865. // Reset ellipsis in order to get the correct
  4866. // bounding box (#4070)
  4867. if (label.styles &&
  4868. label.styles.textOverflow === 'ellipsis') {
  4869. label.css({ textOverflow: 'clip' });
  4870. // Set the correct width in order to read
  4871. // the bounding box height (#4678, #5034)
  4872. }
  4873. else if (label.textPxLength > slotWidth) {
  4874. label.css({ width: slotWidth + 'px' });
  4875. }
  4876. if (label.getBBox().height > (this.len / tickPositions.length -
  4877. (labelMetrics.h - labelMetrics.f))) {
  4878. label.specificTextOverflow = 'ellipsis';
  4879. }
  4880. }
  4881. }
  4882. }
  4883. }
  4884. // Add ellipsis if the label length is significantly longer than ideal
  4885. if (attr.rotation) {
  4886. commonWidth = (maxLabelLength > chart.chartHeight * 0.5 ?
  4887. chart.chartHeight * 0.33 :
  4888. maxLabelLength);
  4889. if (!textOverflowOption) {
  4890. commonTextOverflow = 'ellipsis';
  4891. }
  4892. }
  4893. // Set the explicit or automatic label alignment
  4894. this.labelAlign = labelOptions.align ||
  4895. this.autoLabelAlign(this.labelRotation);
  4896. if (this.labelAlign) {
  4897. attr.align = this.labelAlign;
  4898. }
  4899. // Apply general and specific CSS
  4900. tickPositions.forEach(function (pos) {
  4901. var tick = ticks[pos], label = tick && tick.label, widthOption = labelStyleOptions.width, css = {};
  4902. if (label) {
  4903. // This needs to go before the CSS in old IE (#4502)
  4904. label.attr(attr);
  4905. if (tick.shortenLabel) {
  4906. tick.shortenLabel();
  4907. }
  4908. else if (commonWidth &&
  4909. !widthOption &&
  4910. // Setting width in this case messes with the bounding box
  4911. // (#7975)
  4912. labelStyleOptions.whiteSpace !== 'nowrap' &&
  4913. (
  4914. // Speed optimizing, #7656
  4915. commonWidth < label.textPxLength ||
  4916. // Resetting CSS, #4928
  4917. label.element.tagName === 'SPAN')) {
  4918. css.width = commonWidth;
  4919. if (!textOverflowOption) {
  4920. css.textOverflow = (label.specificTextOverflow ||
  4921. commonTextOverflow);
  4922. }
  4923. label.css(css);
  4924. // Reset previously shortened label (#8210)
  4925. }
  4926. else if (label.styles &&
  4927. label.styles.width &&
  4928. !css.width &&
  4929. !widthOption) {
  4930. label.css({ width: null });
  4931. }
  4932. delete label.specificTextOverflow;
  4933. tick.rotation = attr.rotation;
  4934. }
  4935. }, this);
  4936. // Note: Why is this not part of getLabelPosition?
  4937. this.tickRotCorr = renderer.rotCorr(labelMetrics.b, this.labelRotation || 0, this.side !== 0);
  4938. },
  4939. /**
  4940. * Return true if the axis has associated data.
  4941. *
  4942. * @function Highcharts.Axis#hasData
  4943. *
  4944. * @return {boolean}
  4945. * True if the axis has associated visible series and those series
  4946. * have either valid data points or explicit `min` and `max`
  4947. * settings.
  4948. */
  4949. hasData: function () {
  4950. return this.series.some(function (s) {
  4951. return s.hasData();
  4952. }) ||
  4953. (this.options.showEmpty &&
  4954. defined(this.min) &&
  4955. defined(this.max));
  4956. },
  4957. /**
  4958. * Adds the title defined in axis.options.title.
  4959. *
  4960. * @function Highcharts.Axis#addTitle
  4961. *
  4962. * @param {boolean} [display]
  4963. * Whether or not to display the title.
  4964. *
  4965. * @return {void}
  4966. */
  4967. addTitle: function (display) {
  4968. var axis = this, renderer = axis.chart.renderer, horiz = axis.horiz, opposite = axis.opposite, options = axis.options, axisTitleOptions = options.title, textAlign, styledMode = axis.chart.styledMode;
  4969. if (!axis.axisTitle) {
  4970. textAlign = axisTitleOptions.textAlign;
  4971. if (!textAlign) {
  4972. textAlign = (horiz ? {
  4973. low: 'left',
  4974. middle: 'center',
  4975. high: 'right'
  4976. } : {
  4977. low: opposite ? 'right' : 'left',
  4978. middle: 'center',
  4979. high: opposite ? 'left' : 'right'
  4980. })[axisTitleOptions.align];
  4981. }
  4982. axis.axisTitle = renderer
  4983. .text(axisTitleOptions.text, 0, 0, axisTitleOptions.useHTML)
  4984. .attr({
  4985. zIndex: 7,
  4986. rotation: axisTitleOptions.rotation || 0,
  4987. align: textAlign
  4988. })
  4989. .addClass('highcharts-axis-title');
  4990. // #7814, don't mutate style option
  4991. if (!styledMode) {
  4992. axis.axisTitle.css(merge(axisTitleOptions.style));
  4993. }
  4994. axis.axisTitle.add(axis.axisGroup);
  4995. axis.axisTitle.isNew = true;
  4996. }
  4997. // Max width defaults to the length of the axis
  4998. if (!styledMode &&
  4999. !axisTitleOptions.style.width &&
  5000. !axis.isRadial) {
  5001. axis.axisTitle.css({
  5002. width: axis.len
  5003. });
  5004. }
  5005. // hide or show the title depending on whether showEmpty is set
  5006. axis.axisTitle[display ? 'show' : 'hide'](display);
  5007. },
  5008. /**
  5009. * Generates a tick for initial positioning.
  5010. * @private
  5011. * @param {number} pos The tick position in axis values.
  5012. * @param {number} [i] The index of the tick in {@link Axis.tickPositions}.
  5013. */
  5014. generateTick: function (pos) {
  5015. var ticks = this.ticks;
  5016. if (!ticks[pos]) {
  5017. ticks[pos] = new Tick(this, pos);
  5018. }
  5019. else {
  5020. ticks[pos].addLabel(); // update labels depending on tick interval
  5021. }
  5022. },
  5023. /**
  5024. * Render the tick labels to a preliminary position to get their sizes
  5025. * @private
  5026. * @return {void}
  5027. * @fires Highcharts.Axis#event:afterGetOffset
  5028. */
  5029. getOffset: function () {
  5030. var axis = this, chart = axis.chart, renderer = chart.renderer, options = axis.options, tickPositions = axis.tickPositions, ticks = axis.ticks, horiz = axis.horiz, side = axis.side, invertedSide = chart.inverted &&
  5031. !axis.isZAxis ? [1, 0, 3, 2][side] : side, hasData, showAxis, titleOffset = 0, titleOffsetOption, titleMargin = 0, axisTitleOptions = options.title, labelOptions = options.labels, labelOffset = 0, // reset
  5032. labelOffsetPadded, axisOffset = chart.axisOffset, clipOffset = chart.clipOffset, clip, directionFactor = [-1, 1, 1, -1][side], className = options.className, axisParent = axis.axisParent, // Used in color axis
  5033. lineHeightCorrection, tickSize;
  5034. // For reuse in Axis.render
  5035. hasData = axis.hasData();
  5036. axis.showAxis = showAxis = hasData || pick(options.showEmpty, true);
  5037. // Set/reset staggerLines
  5038. axis.staggerLines = axis.horiz && labelOptions.staggerLines;
  5039. // Create the axisGroup and gridGroup elements on first iteration
  5040. if (!axis.axisGroup) {
  5041. axis.gridGroup = renderer.g('grid')
  5042. .attr({ zIndex: options.gridZIndex || 1 })
  5043. .addClass('highcharts-' + this.coll.toLowerCase() + '-grid ' +
  5044. (className || ''))
  5045. .add(axisParent);
  5046. axis.axisGroup = renderer.g('axis')
  5047. .attr({ zIndex: options.zIndex || 2 })
  5048. .addClass('highcharts-' + this.coll.toLowerCase() + ' ' +
  5049. (className || ''))
  5050. .add(axisParent);
  5051. axis.labelGroup = renderer.g('axis-labels')
  5052. .attr({ zIndex: labelOptions.zIndex || 7 })
  5053. .addClass('highcharts-' + axis.coll.toLowerCase() + '-labels ' +
  5054. (className || ''))
  5055. .add(axisParent);
  5056. }
  5057. if (hasData || axis.isLinked) {
  5058. // Generate ticks
  5059. tickPositions.forEach(function (pos, i) {
  5060. // i is not used here, but may be used in overrides
  5061. axis.generateTick(pos, i);
  5062. });
  5063. axis.renderUnsquish();
  5064. // Left side must be align: right and right side must
  5065. // have align: left for labels
  5066. axis.reserveSpaceDefault = (side === 0 ||
  5067. side === 2 ||
  5068. { 1: 'left', 3: 'right' }[side] === axis.labelAlign);
  5069. if (pick(labelOptions.reserveSpace, axis.labelAlign === 'center' ? true : null, axis.reserveSpaceDefault)) {
  5070. tickPositions.forEach(function (pos) {
  5071. // get the highest offset
  5072. labelOffset = Math.max(ticks[pos].getLabelSize(), labelOffset);
  5073. });
  5074. }
  5075. if (axis.staggerLines) {
  5076. labelOffset *= axis.staggerLines;
  5077. }
  5078. axis.labelOffset = labelOffset * (axis.opposite ? -1 : 1);
  5079. }
  5080. else { // doesn't have data
  5081. objectEach(ticks, function (tick, n) {
  5082. tick.destroy();
  5083. delete ticks[n];
  5084. });
  5085. }
  5086. if (axisTitleOptions &&
  5087. axisTitleOptions.text &&
  5088. axisTitleOptions.enabled !== false) {
  5089. axis.addTitle(showAxis);
  5090. if (showAxis && axisTitleOptions.reserveSpace !== false) {
  5091. axis.titleOffset = titleOffset =
  5092. axis.axisTitle.getBBox()[horiz ? 'height' : 'width'];
  5093. titleOffsetOption = axisTitleOptions.offset;
  5094. titleMargin = defined(titleOffsetOption) ?
  5095. 0 :
  5096. pick(axisTitleOptions.margin, horiz ? 5 : 10);
  5097. }
  5098. }
  5099. // Render the axis line
  5100. axis.renderLine();
  5101. // handle automatic or user set offset
  5102. axis.offset = directionFactor * pick(options.offset, axisOffset[side] ? axisOffset[side] + (options.margin || 0) : 0);
  5103. axis.tickRotCorr = axis.tickRotCorr || { x: 0, y: 0 }; // polar
  5104. if (side === 0) {
  5105. lineHeightCorrection = -axis.labelMetrics().h;
  5106. }
  5107. else if (side === 2) {
  5108. lineHeightCorrection = axis.tickRotCorr.y;
  5109. }
  5110. else {
  5111. lineHeightCorrection = 0;
  5112. }
  5113. // Find the padded label offset
  5114. labelOffsetPadded = Math.abs(labelOffset) + titleMargin;
  5115. if (labelOffset) {
  5116. labelOffsetPadded -= lineHeightCorrection;
  5117. labelOffsetPadded += directionFactor * (horiz ?
  5118. pick(labelOptions.y, axis.tickRotCorr.y + directionFactor * 8) :
  5119. labelOptions.x);
  5120. }
  5121. axis.axisTitleMargin = pick(titleOffsetOption, labelOffsetPadded);
  5122. if (axis.getMaxLabelDimensions) {
  5123. axis.maxLabelDimensions = axis.getMaxLabelDimensions(ticks, tickPositions);
  5124. }
  5125. // Due to GridAxis.tickSize, tickSize should be calculated after ticks
  5126. // has rendered.
  5127. tickSize = this.tickSize('tick');
  5128. axisOffset[side] = Math.max(axisOffset[side], axis.axisTitleMargin + titleOffset +
  5129. directionFactor * axis.offset, labelOffsetPadded, // #3027
  5130. tickPositions && tickPositions.length && tickSize ?
  5131. tickSize[0] + directionFactor * axis.offset :
  5132. 0 // #4866
  5133. );
  5134. // Decide the clipping needed to keep the graph inside
  5135. // the plot area and axis lines
  5136. clip = options.offset ?
  5137. 0 :
  5138. // #4308, #4371:
  5139. Math.floor(axis.axisLine.strokeWidth() / 2) * 2;
  5140. clipOffset[invertedSide] =
  5141. Math.max(clipOffset[invertedSide], clip);
  5142. fireEvent(this, 'afterGetOffset');
  5143. },
  5144. /**
  5145. * Internal function to get the path for the axis line. Extended for polar
  5146. * charts.
  5147. *
  5148. * @function Highcharts.Axis#getLinePath
  5149. *
  5150. * @param {number} lineWidth
  5151. * The line width in pixels.
  5152. *
  5153. * @return {Highcharts.SVGPathArray}
  5154. * The SVG path definition in array form.
  5155. */
  5156. getLinePath: function (lineWidth) {
  5157. var chart = this.chart, opposite = this.opposite, offset = this.offset, horiz = this.horiz, lineLeft = this.left + (opposite ? this.width : 0) + offset, lineTop = chart.chartHeight - this.bottom -
  5158. (opposite ? this.height : 0) + offset;
  5159. if (opposite) {
  5160. lineWidth *= -1; // crispify the other way - #1480, #1687
  5161. }
  5162. return chart.renderer
  5163. .crispLine([
  5164. 'M',
  5165. horiz ?
  5166. this.left :
  5167. lineLeft,
  5168. horiz ?
  5169. lineTop :
  5170. this.top,
  5171. 'L',
  5172. horiz ?
  5173. chart.chartWidth - this.right :
  5174. lineLeft,
  5175. horiz ?
  5176. lineTop :
  5177. chart.chartHeight - this.bottom
  5178. ], lineWidth);
  5179. },
  5180. /**
  5181. * Render the axis line. Called internally when rendering and redrawing the
  5182. * axis.
  5183. *
  5184. * @function Highcharts.Axis#renderLine
  5185. *
  5186. * @return {void}
  5187. */
  5188. renderLine: function () {
  5189. if (!this.axisLine) {
  5190. this.axisLine = this.chart.renderer.path()
  5191. .addClass('highcharts-axis-line')
  5192. .add(this.axisGroup);
  5193. if (!this.chart.styledMode) {
  5194. this.axisLine.attr({
  5195. stroke: this.options.lineColor,
  5196. 'stroke-width': this.options.lineWidth,
  5197. zIndex: 7
  5198. });
  5199. }
  5200. }
  5201. },
  5202. /**
  5203. * Position the axis title.
  5204. * @private
  5205. * @return {Highcharts.PositionObject} X and Y positions for the title.
  5206. */
  5207. getTitlePosition: function () {
  5208. // compute anchor points for each of the title align options
  5209. var horiz = this.horiz, axisLeft = this.left, axisTop = this.top, axisLength = this.len, axisTitleOptions = this.options.title, margin = horiz ? axisLeft : axisTop, opposite = this.opposite, offset = this.offset, xOption = axisTitleOptions.x || 0, yOption = axisTitleOptions.y || 0, axisTitle = this.axisTitle, fontMetrics = this.chart.renderer.fontMetrics(axisTitleOptions.style &&
  5210. axisTitleOptions.style.fontSize, axisTitle),
  5211. // The part of a multiline text that is below the baseline of the
  5212. // first line. Subtract 1 to preserve pixel-perfectness from the
  5213. // old behaviour (v5.0.12), where only one line was allowed.
  5214. textHeightOvershoot = Math.max(axisTitle.getBBox(null, 0).height - fontMetrics.h - 1, 0),
  5215. // the position in the length direction of the axis
  5216. alongAxis = {
  5217. low: margin + (horiz ? 0 : axisLength),
  5218. middle: margin + axisLength / 2,
  5219. high: margin + (horiz ? axisLength : 0)
  5220. }[axisTitleOptions.align],
  5221. // the position in the perpendicular direction of the axis
  5222. offAxis = (horiz ? axisTop + this.height : axisLeft) +
  5223. (horiz ? 1 : -1) * // horizontal axis reverses the margin
  5224. (opposite ? -1 : 1) * // so does opposite axes
  5225. this.axisTitleMargin +
  5226. [
  5227. -textHeightOvershoot,
  5228. textHeightOvershoot,
  5229. fontMetrics.f,
  5230. -textHeightOvershoot // left
  5231. ][this.side], titlePosition = {
  5232. x: horiz ?
  5233. alongAxis + xOption :
  5234. offAxis + (opposite ? this.width : 0) + offset + xOption,
  5235. y: horiz ?
  5236. offAxis + yOption - (opposite ? this.height : 0) + offset :
  5237. alongAxis + yOption
  5238. };
  5239. fireEvent(this, 'afterGetTitlePosition', { titlePosition: titlePosition });
  5240. return titlePosition;
  5241. },
  5242. /**
  5243. * Render a minor tick into the given position. If a minor tick already
  5244. * exists in this position, move it.
  5245. *
  5246. * @function Highcharts.Axis#renderMinorTick
  5247. *
  5248. * @param {number} pos
  5249. * The position in axis values.
  5250. *
  5251. * @return {void}
  5252. */
  5253. renderMinorTick: function (pos) {
  5254. var slideInTicks = this.chart.hasRendered && isNumber(this.oldMin), minorTicks = this.minorTicks;
  5255. if (!minorTicks[pos]) {
  5256. minorTicks[pos] = new Tick(this, pos, 'minor');
  5257. }
  5258. // Render new ticks in old position
  5259. if (slideInTicks && minorTicks[pos].isNew) {
  5260. minorTicks[pos].render(null, true);
  5261. }
  5262. minorTicks[pos].render(null, false, 1);
  5263. },
  5264. /**
  5265. * Render a major tick into the given position. If a tick already exists
  5266. * in this position, move it.
  5267. *
  5268. * @function Highcharts.Axis#renderTick
  5269. *
  5270. * @param {number} pos
  5271. * The position in axis values.
  5272. *
  5273. * @param {number} i
  5274. * The tick index.
  5275. *
  5276. * @return {void}
  5277. */
  5278. renderTick: function (pos, i) {
  5279. var isLinked = this.isLinked, ticks = this.ticks, slideInTicks = this.chart.hasRendered && isNumber(this.oldMin);
  5280. // Linked axes need an extra check to find out if
  5281. if (!isLinked ||
  5282. (pos >= this.min && pos <= this.max)) {
  5283. if (!ticks[pos]) {
  5284. ticks[pos] = new Tick(this, pos);
  5285. }
  5286. // NOTE this seems like overkill. Could be handled in tick.render by
  5287. // setting old position in attr, then set new position in animate.
  5288. // render new ticks in old position
  5289. if (slideInTicks && ticks[pos].isNew) {
  5290. // Start with negative opacity so that it is visible from
  5291. // halfway into the animation
  5292. ticks[pos].render(i, true, -1);
  5293. }
  5294. ticks[pos].render(i);
  5295. }
  5296. },
  5297. /**
  5298. * Render the axis.
  5299. * @private
  5300. * @return {void}
  5301. * @fires Highcharts.Axis#event:afterRender
  5302. */
  5303. render: function () {
  5304. var axis = this, chart = axis.chart, renderer = chart.renderer, options = axis.options, isLog = axis.isLog, isLinked = axis.isLinked, tickPositions = axis.tickPositions, axisTitle = axis.axisTitle, ticks = axis.ticks, minorTicks = axis.minorTicks, alternateBands = axis.alternateBands, stackLabelOptions = options.stackLabels, alternateGridColor = options.alternateGridColor, tickmarkOffset = axis.tickmarkOffset, axisLine = axis.axisLine, showAxis = axis.showAxis, animation = animObject(renderer.globalAnimation), from, to;
  5305. // Reset
  5306. axis.labelEdge.length = 0;
  5307. axis.overlap = false;
  5308. // Mark all elements inActive before we go over and mark the active ones
  5309. [ticks, minorTicks, alternateBands].forEach(function (coll) {
  5310. objectEach(coll, function (tick) {
  5311. tick.isActive = false;
  5312. });
  5313. });
  5314. // If the series has data draw the ticks. Else only the line and title
  5315. if (axis.hasData() || isLinked) {
  5316. // minor ticks
  5317. if (axis.minorTickInterval && !axis.categories) {
  5318. axis.getMinorTickPositions().forEach(function (pos) {
  5319. axis.renderMinorTick(pos);
  5320. });
  5321. }
  5322. // Major ticks. Pull out the first item and render it last so that
  5323. // we can get the position of the neighbour label. #808.
  5324. if (tickPositions.length) { // #1300
  5325. tickPositions.forEach(function (pos, i) {
  5326. axis.renderTick(pos, i);
  5327. });
  5328. // In a categorized axis, the tick marks are displayed
  5329. // between labels. So we need to add a tick mark and
  5330. // grid line at the left edge of the X axis.
  5331. if (tickmarkOffset && (axis.min === 0 || axis.single)) {
  5332. if (!ticks[-1]) {
  5333. ticks[-1] = new Tick(axis, -1, null, true);
  5334. }
  5335. ticks[-1].render(-1);
  5336. }
  5337. }
  5338. // alternate grid color
  5339. if (alternateGridColor) {
  5340. tickPositions.forEach(function (pos, i) {
  5341. to = typeof tickPositions[i + 1] !== 'undefined' ?
  5342. tickPositions[i + 1] + tickmarkOffset :
  5343. axis.max - tickmarkOffset;
  5344. if (i % 2 === 0 &&
  5345. pos < axis.max &&
  5346. to <= axis.max + (chart.polar ?
  5347. -tickmarkOffset :
  5348. tickmarkOffset)) { // #2248, #4660
  5349. if (!alternateBands[pos]) {
  5350. alternateBands[pos] = new H.PlotLineOrBand(axis);
  5351. }
  5352. from = pos + tickmarkOffset; // #949
  5353. alternateBands[pos].options = {
  5354. from: isLog ? axis.lin2log(from) : from,
  5355. to: isLog ? axis.lin2log(to) : to,
  5356. color: alternateGridColor
  5357. };
  5358. alternateBands[pos].render();
  5359. alternateBands[pos].isActive = true;
  5360. }
  5361. });
  5362. }
  5363. // custom plot lines and bands
  5364. if (!axis._addedPlotLB) { // only first time
  5365. (options.plotLines || [])
  5366. .concat(options.plotBands || [])
  5367. .forEach(function (plotLineOptions) {
  5368. axis.addPlotBandOrLine(plotLineOptions);
  5369. });
  5370. axis._addedPlotLB = true;
  5371. }
  5372. } // end if hasData
  5373. // Remove inactive ticks
  5374. [ticks, minorTicks, alternateBands].forEach(function (coll) {
  5375. var i, forDestruction = [], delay = animation.duration, destroyInactiveItems = function () {
  5376. i = forDestruction.length;
  5377. while (i--) {
  5378. // When resizing rapidly, the same items
  5379. // may be destroyed in different timeouts,
  5380. // or the may be reactivated
  5381. if (coll[forDestruction[i]] &&
  5382. !coll[forDestruction[i]].isActive) {
  5383. coll[forDestruction[i]].destroy();
  5384. delete coll[forDestruction[i]];
  5385. }
  5386. }
  5387. };
  5388. objectEach(coll, function (tick, pos) {
  5389. if (!tick.isActive) {
  5390. // Render to zero opacity
  5391. tick.render(pos, false, 0);
  5392. tick.isActive = false;
  5393. forDestruction.push(pos);
  5394. }
  5395. });
  5396. // When the objects are finished fading out, destroy them
  5397. syncTimeout(destroyInactiveItems, coll === alternateBands ||
  5398. !chart.hasRendered ||
  5399. !delay ?
  5400. 0 :
  5401. delay);
  5402. });
  5403. // Set the axis line path
  5404. if (axisLine) {
  5405. axisLine[axisLine.isPlaced ? 'animate' : 'attr']({
  5406. d: this.getLinePath(axisLine.strokeWidth())
  5407. });
  5408. axisLine.isPlaced = true;
  5409. // Show or hide the line depending on options.showEmpty
  5410. axisLine[showAxis ? 'show' : 'hide'](showAxis);
  5411. }
  5412. if (axisTitle && showAxis) {
  5413. var titleXy = axis.getTitlePosition();
  5414. if (isNumber(titleXy.y)) {
  5415. axisTitle[axisTitle.isNew ? 'attr' : 'animate'](titleXy);
  5416. axisTitle.isNew = false;
  5417. }
  5418. else {
  5419. axisTitle.attr('y', -9999);
  5420. axisTitle.isNew = true;
  5421. }
  5422. }
  5423. // Stacked totals:
  5424. if (stackLabelOptions && stackLabelOptions.enabled) {
  5425. axis.renderStackTotals();
  5426. }
  5427. // End stacked totals
  5428. axis.isDirty = false;
  5429. fireEvent(this, 'afterRender');
  5430. },
  5431. /**
  5432. * Redraw the axis to reflect changes in the data or axis extremes. Called
  5433. * internally from Highcharts.Chart#redraw.
  5434. * @private
  5435. * @return {void}
  5436. */
  5437. redraw: function () {
  5438. if (this.visible) {
  5439. // render the axis
  5440. this.render();
  5441. // move plot lines and bands
  5442. this.plotLinesAndBands.forEach(function (plotLine) {
  5443. plotLine.render();
  5444. });
  5445. }
  5446. // mark associated series as dirty and ready for redraw
  5447. this.series.forEach(function (series) {
  5448. series.isDirty = true;
  5449. });
  5450. },
  5451. // Properties to survive after destroy, needed for Axis.update (#4317,
  5452. // #5773, #5881).
  5453. keepProps: ['extKey', 'hcEvents', 'names', 'series', 'userMax', 'userMin'],
  5454. /**
  5455. * Destroys an Axis instance. See {@link Axis#remove} for the API endpoint
  5456. * to fully remove the axis.
  5457. * @private
  5458. * @param {boolean} [keepEvents] Whether to preserve events, used internally
  5459. * in Axis.update.
  5460. * @return {void}
  5461. */
  5462. destroy: function (keepEvents) {
  5463. var axis = this, stacks = axis.stacks, plotLinesAndBands = axis.plotLinesAndBands, plotGroup, i;
  5464. fireEvent(this, 'destroy', { keepEvents: keepEvents });
  5465. // Remove the events
  5466. if (!keepEvents) {
  5467. removeEvent(axis);
  5468. }
  5469. // Destroy each stack total
  5470. objectEach(stacks, function (stack, stackKey) {
  5471. destroyObjectProperties(stack);
  5472. stacks[stackKey] = null;
  5473. });
  5474. // Destroy collections
  5475. [axis.ticks, axis.minorTicks, axis.alternateBands].forEach(function (coll) {
  5476. destroyObjectProperties(coll);
  5477. });
  5478. if (plotLinesAndBands) {
  5479. i = plotLinesAndBands.length;
  5480. while (i--) { // #1975
  5481. plotLinesAndBands[i].destroy();
  5482. }
  5483. }
  5484. // Destroy elements
  5485. ['stackTotalGroup', 'axisLine', 'axisTitle', 'axisGroup',
  5486. 'gridGroup', 'labelGroup', 'cross', 'scrollbar'].forEach(function (prop) {
  5487. if (axis[prop]) {
  5488. axis[prop] = axis[prop].destroy();
  5489. }
  5490. });
  5491. // Destroy each generated group for plotlines and plotbands
  5492. for (plotGroup in axis.plotLinesAndBandsGroups) { // eslint-disable-line guard-for-in
  5493. axis.plotLinesAndBandsGroups[plotGroup] =
  5494. axis.plotLinesAndBandsGroups[plotGroup].destroy();
  5495. }
  5496. // Delete all properties and fall back to the prototype.
  5497. objectEach(axis, function (val, key) {
  5498. if (axis.keepProps.indexOf(key) === -1) {
  5499. delete axis[key];
  5500. }
  5501. });
  5502. },
  5503. /**
  5504. * Internal function to draw a crosshair.
  5505. *
  5506. * @function Highcharts.Axis#drawCrosshair
  5507. *
  5508. * @param {Highcharts.PointerEventObject} [e]
  5509. * The event arguments from the modified pointer event, extended with
  5510. * `chartX` and `chartY`
  5511. *
  5512. * @param {Highcharts.Point} [point]
  5513. * The Point object if the crosshair snaps to points.
  5514. *
  5515. * @return {void}
  5516. *
  5517. * @fires Highcharts.Axis#event:afterDrawCrosshair
  5518. * @fires Highcharts.Axis#event:drawCrosshair
  5519. */
  5520. drawCrosshair: function (e, point) {
  5521. var path, options = this.crosshair, snap = pick(options.snap, true), pos, categorized, graphic = this.cross, crossOptions;
  5522. fireEvent(this, 'drawCrosshair', { e: e, point: point });
  5523. // Use last available event when updating non-snapped crosshairs without
  5524. // mouse interaction (#5287)
  5525. if (!e) {
  5526. e = this.cross && this.cross.e;
  5527. }
  5528. if (
  5529. // Disabled in options
  5530. !this.crosshair ||
  5531. // Snap
  5532. ((defined(point) || !snap) === false)) {
  5533. this.hideCrosshair();
  5534. }
  5535. else {
  5536. // Get the path
  5537. if (!snap) {
  5538. pos = e &&
  5539. (this.horiz ?
  5540. e.chartX - this.pos :
  5541. this.len - e.chartY + this.pos);
  5542. }
  5543. else if (defined(point)) {
  5544. // #3834
  5545. pos = pick(this.coll !== 'colorAxis' ?
  5546. point.crosshairPos : // 3D axis extension
  5547. null, this.isXAxis ?
  5548. point.plotX :
  5549. this.len - point.plotY);
  5550. }
  5551. if (defined(pos)) {
  5552. crossOptions = {
  5553. // value, only used on radial
  5554. value: point && (this.isXAxis ?
  5555. point.x :
  5556. pick(point.stackY, point.y)),
  5557. translatedValue: pos
  5558. };
  5559. if (this.chart.polar) {
  5560. // Additional information required for crosshairs in
  5561. // polar chart
  5562. extend(crossOptions, {
  5563. isCrosshair: true,
  5564. chartX: e && e.chartX,
  5565. chartY: e && e.chartY,
  5566. point: point
  5567. });
  5568. }
  5569. path = this.getPlotLinePath(crossOptions) ||
  5570. null; // #3189
  5571. }
  5572. if (!defined(path)) {
  5573. this.hideCrosshair();
  5574. return;
  5575. }
  5576. categorized = this.categories && !this.isRadial;
  5577. // Draw the cross
  5578. if (!graphic) {
  5579. this.cross = graphic = this.chart.renderer
  5580. .path()
  5581. .addClass('highcharts-crosshair highcharts-crosshair-' +
  5582. (categorized ? 'category ' : 'thin ') +
  5583. options.className)
  5584. .attr({
  5585. zIndex: pick(options.zIndex, 2)
  5586. })
  5587. .add();
  5588. // Presentational attributes
  5589. if (!this.chart.styledMode) {
  5590. graphic.attr({
  5591. stroke: options.color ||
  5592. (categorized ?
  5593. color('#ccd6eb')
  5594. .setOpacity(0.25).get() :
  5595. '#cccccc'),
  5596. 'stroke-width': pick(options.width, 1)
  5597. }).css({
  5598. 'pointer-events': 'none'
  5599. });
  5600. if (options.dashStyle) {
  5601. graphic.attr({
  5602. dashstyle: options.dashStyle
  5603. });
  5604. }
  5605. }
  5606. }
  5607. graphic.show().attr({
  5608. d: path
  5609. });
  5610. if (categorized && !options.width) {
  5611. graphic.attr({
  5612. 'stroke-width': this.transA
  5613. });
  5614. }
  5615. this.cross.e = e;
  5616. }
  5617. fireEvent(this, 'afterDrawCrosshair', { e: e, point: point });
  5618. },
  5619. /**
  5620. * Hide the crosshair if visible.
  5621. *
  5622. * @function Highcharts.Axis#hideCrosshair
  5623. *
  5624. * @return {void}
  5625. */
  5626. hideCrosshair: function () {
  5627. if (this.cross) {
  5628. this.cross.hide();
  5629. }
  5630. fireEvent(this, 'afterHideCrosshair');
  5631. }
  5632. }); // end Axis
  5633. H.Axis = Axis;
  5634. export default Axis;