Axis.js 232 KB

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