Axis.js 234 KB

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